From e36047d8e55aaf3c648cfaf69e714d959b512195 Mon Sep 17 00:00:00 2001 From: OMGeeky Date: Mon, 13 May 2024 18:47:09 +0200 Subject: [PATCH] make youtube3 --- gen/youtube3/Cargo.toml | 37 + gen/youtube3/LICENSE.md | 30 + gen/youtube3/README.md | 270 + gen/youtube3/src/api/call_builders.rs | 25627 ++++++++++++++++++++++ gen/youtube3/src/api/enums.rs | 12279 +++++++++++ gen/youtube3/src/api/hub.rs | 208 + gen/youtube3/src/api/method_builders.rs | 2941 +++ gen/youtube3/src/api/mod.rs | 35 + gen/youtube3/src/api/schemas.rs | 7108 ++++++ gen/youtube3/src/api/utilities.rs | 48 + gen/youtube3/src/lib.rs | 290 + 11 files changed, 48873 insertions(+) create mode 100644 gen/youtube3/Cargo.toml create mode 100644 gen/youtube3/LICENSE.md create mode 100644 gen/youtube3/README.md create mode 100644 gen/youtube3/src/api/call_builders.rs create mode 100644 gen/youtube3/src/api/enums.rs create mode 100644 gen/youtube3/src/api/hub.rs create mode 100644 gen/youtube3/src/api/method_builders.rs create mode 100644 gen/youtube3/src/api/mod.rs create mode 100644 gen/youtube3/src/api/schemas.rs create mode 100644 gen/youtube3/src/api/utilities.rs create mode 100644 gen/youtube3/src/lib.rs diff --git a/gen/youtube3/Cargo.toml b/gen/youtube3/Cargo.toml new file mode 100644 index 0000000000..7679c08d74 --- /dev/null +++ b/gen/youtube3/Cargo.toml @@ -0,0 +1,37 @@ +# DO NOT EDIT ! +# This file was generated automatically from 'src/generator/templates/Cargo.toml.mako' +# DO NOT EDIT ! +[package] + +name = "google-youtube3" +version = "5.0.5+20240417" +authors = ["Sebastian Thiel "] +description = "A complete library to interact with YouTube (protocol v3)" +repository = "https://github.com/Byron/google-apis-rs/tree/main/gen/youtube3" +homepage = "https://developers.google.com/youtube/" +documentation = "https://docs.rs/google-youtube3/5.0.5+20240417" +license = "MIT" +keywords = ["youtube", "google", "protocol", "web", "api"] +autobins = false +edition = "2018" + + +[dependencies] +anyhow = "^ 1.0" +hyper-rustls = "0.25.0" +mime = "^ 0.3.0" +serde = { version = "^ 1.0", features = ["derive"] } +serde_json = "^ 1.0" +itertools = "^ 0.10" +google-apis-common = { path = "../../google-apis-common", version = "6.0.3" } +hyper = "^ 0.14" +http = "^0.2" +tokio = "^1.0" +tower-service = "^0.3.1" +url = "= 1.7" + + + +[features] +yup-oauth2 = ["google-apis-common/yup-oauth2"] +default = ["yup-oauth2"] diff --git a/gen/youtube3/LICENSE.md b/gen/youtube3/LICENSE.md new file mode 100644 index 0000000000..c14f19eef3 --- /dev/null +++ b/gen/youtube3/LICENSE.md @@ -0,0 +1,30 @@ + +The MIT License (MIT) +===================== + +Copyright 2015–2024 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/youtube3/README.md b/gen/youtube3/README.md new file mode 100644 index 0000000000..253cd0c8c2 --- /dev/null +++ b/gen/youtube3/README.md @@ -0,0 +1,270 @@ + +The `google-youtube3` library allows access to all features of the *Google YouTube* service. + +This documentation was generated from *YouTube* crate version *5.0.5+20240417*, where *20240417* is the exact revision of the *youtube:v3* schema built by the [mako](http://www.makotemplates.org/) code generator *v5.0.5*. + +Everything else about the *YouTube* *v3* API can be found at the +[official documentation site](https://developers.google.com/youtube/). +# Features + +Handle the following *Resources* with ease from the central [hub](https://docs.rs/google-youtube3/5.0.5+20240417/google_youtube3/YouTube) ... + +* [abuse reports](https://docs.rs/google-youtube3/5.0.5+20240417/google_youtube3/api::AbuseReport) + * [*insert*](https://docs.rs/google-youtube3/5.0.5+20240417/google_youtube3/api::AbuseReportInsertCall) +* [activities](https://docs.rs/google-youtube3/5.0.5+20240417/google_youtube3/api::Activity) + * [*list*](https://docs.rs/google-youtube3/5.0.5+20240417/google_youtube3/api::ActivityListCall) +* [captions](https://docs.rs/google-youtube3/5.0.5+20240417/google_youtube3/api::Caption) + * [*delete*](https://docs.rs/google-youtube3/5.0.5+20240417/google_youtube3/api::CaptionDeleteCall), [*download*](https://docs.rs/google-youtube3/5.0.5+20240417/google_youtube3/api::CaptionDownloadCall), [*insert*](https://docs.rs/google-youtube3/5.0.5+20240417/google_youtube3/api::CaptionInsertCall), [*list*](https://docs.rs/google-youtube3/5.0.5+20240417/google_youtube3/api::CaptionListCall) and [*update*](https://docs.rs/google-youtube3/5.0.5+20240417/google_youtube3/api::CaptionUpdateCall) +* channel banners + * [*insert*](https://docs.rs/google-youtube3/5.0.5+20240417/google_youtube3/api::ChannelBannerInsertCall) +* [channel sections](https://docs.rs/google-youtube3/5.0.5+20240417/google_youtube3/api::ChannelSection) + * [*delete*](https://docs.rs/google-youtube3/5.0.5+20240417/google_youtube3/api::ChannelSectionDeleteCall), [*insert*](https://docs.rs/google-youtube3/5.0.5+20240417/google_youtube3/api::ChannelSectionInsertCall), [*list*](https://docs.rs/google-youtube3/5.0.5+20240417/google_youtube3/api::ChannelSectionListCall) and [*update*](https://docs.rs/google-youtube3/5.0.5+20240417/google_youtube3/api::ChannelSectionUpdateCall) +* [channels](https://docs.rs/google-youtube3/5.0.5+20240417/google_youtube3/api::Channel) + * [*list*](https://docs.rs/google-youtube3/5.0.5+20240417/google_youtube3/api::ChannelListCall) and [*update*](https://docs.rs/google-youtube3/5.0.5+20240417/google_youtube3/api::ChannelUpdateCall) +* [comment threads](https://docs.rs/google-youtube3/5.0.5+20240417/google_youtube3/api::CommentThread) + * [*insert*](https://docs.rs/google-youtube3/5.0.5+20240417/google_youtube3/api::CommentThreadInsertCall) and [*list*](https://docs.rs/google-youtube3/5.0.5+20240417/google_youtube3/api::CommentThreadListCall) +* [comments](https://docs.rs/google-youtube3/5.0.5+20240417/google_youtube3/api::Comment) + * [*delete*](https://docs.rs/google-youtube3/5.0.5+20240417/google_youtube3/api::CommentDeleteCall), [*insert*](https://docs.rs/google-youtube3/5.0.5+20240417/google_youtube3/api::CommentInsertCall), [*list*](https://docs.rs/google-youtube3/5.0.5+20240417/google_youtube3/api::CommentListCall), [*mark as spam*](https://docs.rs/google-youtube3/5.0.5+20240417/google_youtube3/api::CommentMarkAsSpamCall), [*set moderation status*](https://docs.rs/google-youtube3/5.0.5+20240417/google_youtube3/api::CommentSetModerationStatusCall) and [*update*](https://docs.rs/google-youtube3/5.0.5+20240417/google_youtube3/api::CommentUpdateCall) +* [i18n languages](https://docs.rs/google-youtube3/5.0.5+20240417/google_youtube3/api::I18nLanguage) + * [*list*](https://docs.rs/google-youtube3/5.0.5+20240417/google_youtube3/api::I18nLanguageListCall) +* [i18n regions](https://docs.rs/google-youtube3/5.0.5+20240417/google_youtube3/api::I18nRegion) + * [*list*](https://docs.rs/google-youtube3/5.0.5+20240417/google_youtube3/api::I18nRegionListCall) +* [live broadcasts](https://docs.rs/google-youtube3/5.0.5+20240417/google_youtube3/api::LiveBroadcast) + * [*bind*](https://docs.rs/google-youtube3/5.0.5+20240417/google_youtube3/api::LiveBroadcastBindCall), [*delete*](https://docs.rs/google-youtube3/5.0.5+20240417/google_youtube3/api::LiveBroadcastDeleteCall), [*insert*](https://docs.rs/google-youtube3/5.0.5+20240417/google_youtube3/api::LiveBroadcastInsertCall), [*insert cuepoint*](https://docs.rs/google-youtube3/5.0.5+20240417/google_youtube3/api::LiveBroadcastInsertCuepointCall), [*list*](https://docs.rs/google-youtube3/5.0.5+20240417/google_youtube3/api::LiveBroadcastListCall), [*transition*](https://docs.rs/google-youtube3/5.0.5+20240417/google_youtube3/api::LiveBroadcastTransitionCall) and [*update*](https://docs.rs/google-youtube3/5.0.5+20240417/google_youtube3/api::LiveBroadcastUpdateCall) +* [live chat bans](https://docs.rs/google-youtube3/5.0.5+20240417/google_youtube3/api::LiveChatBan) + * [*delete*](https://docs.rs/google-youtube3/5.0.5+20240417/google_youtube3/api::LiveChatBanDeleteCall) and [*insert*](https://docs.rs/google-youtube3/5.0.5+20240417/google_youtube3/api::LiveChatBanInsertCall) +* [live chat messages](https://docs.rs/google-youtube3/5.0.5+20240417/google_youtube3/api::LiveChatMessage) + * [*delete*](https://docs.rs/google-youtube3/5.0.5+20240417/google_youtube3/api::LiveChatMessageDeleteCall), [*insert*](https://docs.rs/google-youtube3/5.0.5+20240417/google_youtube3/api::LiveChatMessageInsertCall) and [*list*](https://docs.rs/google-youtube3/5.0.5+20240417/google_youtube3/api::LiveChatMessageListCall) +* [live chat moderators](https://docs.rs/google-youtube3/5.0.5+20240417/google_youtube3/api::LiveChatModerator) + * [*delete*](https://docs.rs/google-youtube3/5.0.5+20240417/google_youtube3/api::LiveChatModeratorDeleteCall), [*insert*](https://docs.rs/google-youtube3/5.0.5+20240417/google_youtube3/api::LiveChatModeratorInsertCall) and [*list*](https://docs.rs/google-youtube3/5.0.5+20240417/google_youtube3/api::LiveChatModeratorListCall) +* [live streams](https://docs.rs/google-youtube3/5.0.5+20240417/google_youtube3/api::LiveStream) + * [*delete*](https://docs.rs/google-youtube3/5.0.5+20240417/google_youtube3/api::LiveStreamDeleteCall), [*insert*](https://docs.rs/google-youtube3/5.0.5+20240417/google_youtube3/api::LiveStreamInsertCall), [*list*](https://docs.rs/google-youtube3/5.0.5+20240417/google_youtube3/api::LiveStreamListCall) and [*update*](https://docs.rs/google-youtube3/5.0.5+20240417/google_youtube3/api::LiveStreamUpdateCall) +* [members](https://docs.rs/google-youtube3/5.0.5+20240417/google_youtube3/api::Member) + * [*list*](https://docs.rs/google-youtube3/5.0.5+20240417/google_youtube3/api::MemberListCall) +* [memberships levels](https://docs.rs/google-youtube3/5.0.5+20240417/google_youtube3/api::MembershipsLevel) + * [*list*](https://docs.rs/google-youtube3/5.0.5+20240417/google_youtube3/api::MembershipsLevelListCall) +* [playlist images](https://docs.rs/google-youtube3/5.0.5+20240417/google_youtube3/api::PlaylistImage) + * [*delete*](https://docs.rs/google-youtube3/5.0.5+20240417/google_youtube3/api::PlaylistImageDeleteCall), [*insert*](https://docs.rs/google-youtube3/5.0.5+20240417/google_youtube3/api::PlaylistImageInsertCall), [*list*](https://docs.rs/google-youtube3/5.0.5+20240417/google_youtube3/api::PlaylistImageListCall) and [*update*](https://docs.rs/google-youtube3/5.0.5+20240417/google_youtube3/api::PlaylistImageUpdateCall) +* [playlist items](https://docs.rs/google-youtube3/5.0.5+20240417/google_youtube3/api::PlaylistItem) + * [*delete*](https://docs.rs/google-youtube3/5.0.5+20240417/google_youtube3/api::PlaylistItemDeleteCall), [*insert*](https://docs.rs/google-youtube3/5.0.5+20240417/google_youtube3/api::PlaylistItemInsertCall), [*list*](https://docs.rs/google-youtube3/5.0.5+20240417/google_youtube3/api::PlaylistItemListCall) and [*update*](https://docs.rs/google-youtube3/5.0.5+20240417/google_youtube3/api::PlaylistItemUpdateCall) +* [playlists](https://docs.rs/google-youtube3/5.0.5+20240417/google_youtube3/api::Playlist) + * [*delete*](https://docs.rs/google-youtube3/5.0.5+20240417/google_youtube3/api::PlaylistDeleteCall), [*insert*](https://docs.rs/google-youtube3/5.0.5+20240417/google_youtube3/api::PlaylistInsertCall), [*list*](https://docs.rs/google-youtube3/5.0.5+20240417/google_youtube3/api::PlaylistListCall) and [*update*](https://docs.rs/google-youtube3/5.0.5+20240417/google_youtube3/api::PlaylistUpdateCall) +* search + * [*list*](https://docs.rs/google-youtube3/5.0.5+20240417/google_youtube3/api::SearchListCall) +* [subscriptions](https://docs.rs/google-youtube3/5.0.5+20240417/google_youtube3/api::Subscription) + * [*delete*](https://docs.rs/google-youtube3/5.0.5+20240417/google_youtube3/api::SubscriptionDeleteCall), [*insert*](https://docs.rs/google-youtube3/5.0.5+20240417/google_youtube3/api::SubscriptionInsertCall) and [*list*](https://docs.rs/google-youtube3/5.0.5+20240417/google_youtube3/api::SubscriptionListCall) +* [super chat events](https://docs.rs/google-youtube3/5.0.5+20240417/google_youtube3/api::SuperChatEvent) + * [*list*](https://docs.rs/google-youtube3/5.0.5+20240417/google_youtube3/api::SuperChatEventListCall) +* tests + * [*insert*](https://docs.rs/google-youtube3/5.0.5+20240417/google_youtube3/api::TestInsertCall) +* [third party links](https://docs.rs/google-youtube3/5.0.5+20240417/google_youtube3/api::ThirdPartyLink) + * [*delete*](https://docs.rs/google-youtube3/5.0.5+20240417/google_youtube3/api::ThirdPartyLinkDeleteCall), [*insert*](https://docs.rs/google-youtube3/5.0.5+20240417/google_youtube3/api::ThirdPartyLinkInsertCall), [*list*](https://docs.rs/google-youtube3/5.0.5+20240417/google_youtube3/api::ThirdPartyLinkListCall) and [*update*](https://docs.rs/google-youtube3/5.0.5+20240417/google_youtube3/api::ThirdPartyLinkUpdateCall) +* [thumbnails](https://docs.rs/google-youtube3/5.0.5+20240417/google_youtube3/api::Thumbnail) + * [*set*](https://docs.rs/google-youtube3/5.0.5+20240417/google_youtube3/api::ThumbnailSetCall) +* [video abuse report reasons](https://docs.rs/google-youtube3/5.0.5+20240417/google_youtube3/api::VideoAbuseReportReason) + * [*list*](https://docs.rs/google-youtube3/5.0.5+20240417/google_youtube3/api::VideoAbuseReportReasonListCall) +* [video categories](https://docs.rs/google-youtube3/5.0.5+20240417/google_youtube3/api::VideoCategory) + * [*list*](https://docs.rs/google-youtube3/5.0.5+20240417/google_youtube3/api::VideoCategoryListCall) +* [videos](https://docs.rs/google-youtube3/5.0.5+20240417/google_youtube3/api::Video) + * [*delete*](https://docs.rs/google-youtube3/5.0.5+20240417/google_youtube3/api::VideoDeleteCall), [*get rating*](https://docs.rs/google-youtube3/5.0.5+20240417/google_youtube3/api::VideoGetRatingCall), [*insert*](https://docs.rs/google-youtube3/5.0.5+20240417/google_youtube3/api::VideoInsertCall), [*list*](https://docs.rs/google-youtube3/5.0.5+20240417/google_youtube3/api::VideoListCall), [*rate*](https://docs.rs/google-youtube3/5.0.5+20240417/google_youtube3/api::VideoRateCall), [*report abuse*](https://docs.rs/google-youtube3/5.0.5+20240417/google_youtube3/api::VideoReportAbuseCall) and [*update*](https://docs.rs/google-youtube3/5.0.5+20240417/google_youtube3/api::VideoUpdateCall) +* watermarks + * [*set*](https://docs.rs/google-youtube3/5.0.5+20240417/google_youtube3/api::WatermarkSetCall) and [*unset*](https://docs.rs/google-youtube3/5.0.5+20240417/google_youtube3/api::WatermarkUnsetCall) +* youtube + * [*v3 update comment threads*](https://docs.rs/google-youtube3/5.0.5+20240417/google_youtube3/api::YoutubeV3UpdateCommentThreadCall) + + +Upload supported by ... + +* [*insert captions*](https://docs.rs/google-youtube3/5.0.5+20240417/google_youtube3/api::CaptionInsertCall) +* [*update captions*](https://docs.rs/google-youtube3/5.0.5+20240417/google_youtube3/api::CaptionUpdateCall) +* [*insert channel banners*](https://docs.rs/google-youtube3/5.0.5+20240417/google_youtube3/api::ChannelBannerInsertCall) +* [*insert playlist images*](https://docs.rs/google-youtube3/5.0.5+20240417/google_youtube3/api::PlaylistImageInsertCall) +* [*update playlist images*](https://docs.rs/google-youtube3/5.0.5+20240417/google_youtube3/api::PlaylistImageUpdateCall) +* [*set thumbnails*](https://docs.rs/google-youtube3/5.0.5+20240417/google_youtube3/api::ThumbnailSetCall) +* [*insert videos*](https://docs.rs/google-youtube3/5.0.5+20240417/google_youtube3/api::VideoInsertCall) +* [*set watermarks*](https://docs.rs/google-youtube3/5.0.5+20240417/google_youtube3/api::WatermarkSetCall) + +Download supported by ... + +* [*download captions*](https://docs.rs/google-youtube3/5.0.5+20240417/google_youtube3/api::CaptionDownloadCall) + + + +# Structure of this Library + +The API is structured into the following primary items: + +* **[Hub](https://docs.rs/google-youtube3/5.0.5+20240417/google_youtube3/YouTube)** + * a central object to maintain state and allow accessing all *Activities* + * creates [*Method Builders*](https://docs.rs/google-youtube3/5.0.5+20240417/google_youtube3/client::MethodsBuilder) which in turn + allow access to individual [*Call Builders*](https://docs.rs/google-youtube3/5.0.5+20240417/google_youtube3/client::CallBuilder) +* **[Resources](https://docs.rs/google-youtube3/5.0.5+20240417/google_youtube3/client::Resource)** + * primary types that you can apply *Activities* to + * a collection of properties and *Parts* + * **[Parts](https://docs.rs/google-youtube3/5.0.5+20240417/google_youtube3/client::Part)** + * a collection of properties + * never directly used in *Activities* +* **[Activities](https://docs.rs/google-youtube3/5.0.5+20240417/google_youtube3/client::CallBuilder)** + * operations to apply to *Resources* + +All *structures* are marked with applicable traits to further categorize them and ease browsing. + +Generally speaking, you can invoke *Activities* like this: + +```Rust,ignore +let r = hub.resource().activity(...).doit().await +``` + +Or specifically ... + +```ignore +let r = hub.videos().delete(...).doit().await +let r = hub.videos().get_rating(...).doit().await +let r = hub.videos().insert(...).doit().await +let r = hub.videos().list(...).doit().await +let r = hub.videos().rate(...).doit().await +let r = hub.videos().report_abuse(...).doit().await +let r = hub.videos().update(...).doit().await +``` + +The `resource()` and `activity(...)` calls create [builders][builder-pattern]. The second one dealing with `Activities` +supports various methods to configure the impending operation (not shown here). It is made such that all required arguments have to be +specified right away (i.e. `(...)`), whereas all optional ones can be [build up][builder-pattern] as desired. +The `doit()` method performs the actual communication with the server and returns the respective result. + +# Usage + +## Setting up your Project + +To use this library, you would put the following lines into your `Cargo.toml` file: + +```toml +[dependencies] +google-youtube3 = "*" +serde = "^1.0" +serde_json = "^1.0" +``` + +## A complete example + +```Rust +extern crate hyper; +extern crate hyper_rustls; +extern crate google_youtube3 as youtube3; +use youtube3::{Result, Error}; +use std::default::Default; +use youtube3::{YouTube, oauth2, hyper, hyper_rustls, chrono, FieldMask}; + +// Get an ApplicationSecret instance by some means. It contains the `client_id` and +// `client_secret`, among other things. +let secret: oauth2::ApplicationSecret = Default::default(); +// Instantiate the authenticator. It will choose a suitable authentication flow for you, +// unless you replace `None` with the desired Flow. +// Provide your own `AuthenticatorDelegate` to adjust the way it operates and get feedback about +// what's going on. You probably want to bring in your own `TokenStorage` to persist tokens and +// retrieve them from storage. +let auth = oauth2::InstalledFlowAuthenticator::builder( + secret, + oauth2::InstalledFlowReturnMethod::HTTPRedirect, + ).build().await.unwrap(); +let mut hub = YouTube::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().unwrap().https_or_http().enable_http1().build()), auth); +// You can configure optional parameters by calling the respective setters at will, and +// execute the final call using `doit()`. +// Values shown here are possibly random and not representative ! +let result = hub.videos().list(&vec!["et".into()]) + .video_category_id("magna") + .region_code("no") + .page_token("ipsum") + .on_behalf_of_content_owner("voluptua.") + .my_rating(&Default::default()) + .max_width(-27) + .max_results(93) + .max_height(-80) + .locale("amet.") + .add_id("takimata") + .hl("amet.") + .chart(&Default::default()) + .doit().await; + +match result { + Err(e) => match e { + // The Error enum provides details about what exactly happened. + // You can also just use its `Debug`, `Display` or `Error` traits + Error::HttpError(_) + |Error::Io(_) + |Error::MissingAPIKey + |Error::MissingToken(_) + |Error::Cancelled + |Error::UploadSizeLimitExceeded(_, _) + |Error::Failure(_) + |Error::BadRequest(_) + |Error::FieldClash(_) + |Error::JsonDecodeError(_, _) => println!("{}", e), + }, + Ok(res) => println!("Success: {:?}", res), +} + +``` +## Handling Errors + +All errors produced by the system are provided either as [Result](https://docs.rs/google-youtube3/5.0.5+20240417/google_youtube3/client::Result) enumeration as return value of +the doit() methods, or handed as possibly intermediate results to either the +[Hub Delegate](https://docs.rs/google-youtube3/5.0.5+20240417/google_youtube3/client::Delegate), or the [Authenticator Delegate](https://docs.rs/yup-oauth2/*/yup_oauth2/trait.AuthenticatorDelegate.html). + +When delegates handle errors or intermediate values, they may have a chance to instruct the system to retry. This +makes the system potentially resilient to all kinds of errors. + +## Uploads and Downloads +If a method supports downloads, the response body, which is part of the [Result](https://docs.rs/google-youtube3/5.0.5+20240417/google_youtube3/client::Result), should be +read by you to obtain the media. +If such a method also supports a [Response Result](https://docs.rs/google-youtube3/5.0.5+20240417/google_youtube3/client::ResponseResult), it will return that by default. +You can see it as meta-data for the actual media. To trigger a media download, you will have to set up the builder by making +this call: `.param("alt", "media")`. + +Methods supporting uploads can do so using up to 2 different protocols: +*simple* and *resumable*. The distinctiveness of each is represented by customized +`doit(...)` methods, which are then named `upload(...)` and `upload_resumable(...)` respectively. + +## Customization and Callbacks + +You may alter the way an `doit()` method is called by providing a [delegate](https://docs.rs/google-youtube3/5.0.5+20240417/google_youtube3/client::Delegate) to the +[Method Builder](https://docs.rs/google-youtube3/5.0.5+20240417/google_youtube3/client::CallBuilder) before making the final `doit()` call. +Respective methods will be called to provide progress information, as well as determine whether the system should +retry on failure. + +The [delegate trait](https://docs.rs/google-youtube3/5.0.5+20240417/google_youtube3/client::Delegate) is default-implemented, allowing you to customize it with minimal effort. + +## Optional Parts in Server-Requests + +All structures provided by this library are made to be [encodable](https://docs.rs/google-youtube3/5.0.5+20240417/google_youtube3/client::RequestValue) and +[decodable](https://docs.rs/google-youtube3/5.0.5+20240417/google_youtube3/client::ResponseResult) via *json*. Optionals are used to indicate that partial requests are responses +are valid. +Most optionals are are considered [Parts](https://docs.rs/google-youtube3/5.0.5+20240417/google_youtube3/client::Part) which are identifiable by name, which will be sent to +the server to indicate either the set parts of the request or the desired parts in the response. + +## Builder Arguments + +Using [method builders](https://docs.rs/google-youtube3/5.0.5+20240417/google_youtube3/client::CallBuilder), you are able to prepare an action call by repeatedly calling it's methods. +These will always take a single argument, for which the following statements are true. + +* [PODs][wiki-pod] are handed by copy +* strings are passed as `&str` +* [request values](https://docs.rs/google-youtube3/5.0.5+20240417/google_youtube3/client::RequestValue) are moved + +Arguments will always be copied or cloned into the builder, to make them independent of their original life times. + +[wiki-pod]: http://en.wikipedia.org/wiki/Plain_old_data_structure +[builder-pattern]: http://en.wikipedia.org/wiki/Builder_pattern +[google-go-api]: https://github.com/google/google-api-go-client + +# License +The **youtube3** library was generated by Sebastian Thiel, and is placed +under the *MIT* license. +You can read the full text at the repository's [license file][repo-license]. + +[repo-license]: https://github.com/Byron/google-apis-rsblob/main/LICENSE.md + diff --git a/gen/youtube3/src/api/call_builders.rs b/gen/youtube3/src/api/call_builders.rs new file mode 100644 index 0000000000..99d9a9e344 --- /dev/null +++ b/gen/youtube3/src/api/call_builders.rs @@ -0,0 +1,25627 @@ +use super::*; +/// Inserts a new resource into this collection. +/// +/// A builder for the *insert* method supported by a *abuseReport* resource. +/// It is not used directly, but through a [`AbuseReportMethods`] instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate hyper_rustls; +/// # extern crate google_youtube3 as youtube3; +/// use youtube3::api::AbuseReport; +/// # async fn dox() { +/// # use std::default::Default; +/// # use youtube3::{YouTube, oauth2, hyper, hyper_rustls, chrono, FieldMask}; +/// +/// # let secret: oauth2::ApplicationSecret = Default::default(); +/// # let auth = oauth2::InstalledFlowAuthenticator::builder( +/// # secret, +/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, +/// # ).build().await.unwrap(); +/// # let mut hub = YouTube::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().unwrap().https_or_http().enable_http1().build()), auth); +/// // As the method needs a request, you would usually fill it with the desired information +/// // into the respective structure. Some of the parts shown here might not be applicable ! +/// // Values shown here are possibly random and not representative ! +/// let mut req = AbuseReport::default(); +/// +/// // You can configure optional parameters by calling the respective setters at will, and +/// // execute the final call using `doit()`. +/// // Values shown here are possibly random and not representative ! +/// let result = hub.abuse_reports().insert(req) +/// .doit().await; +/// # } +/// ``` +pub struct AbuseReportInsertCall<'a, S> + where S: 'a { + + pub(super) hub: &'a YouTube, + pub(super) _request: AbuseReport, + pub(super) _part: Vec, + pub(super) _delegate: Option<&'a mut dyn client::Delegate>, + pub(super) _additional_params: HashMap, + pub(super) _scopes: BTreeSet +} + +impl<'a, S> client::CallBuilder for AbuseReportInsertCall<'a, S> {} + +impl<'a, S> AbuseReportInsertCall<'a, S> +where + S: tower_service::Service + Clone + Send + Sync + 'static, + S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, + S::Future: Send + Unpin + 'static, + S::Error: Into>, +{ + + + /// Perform the operation you have build so far. + pub async fn doit(mut self) -> client::Result<(hyper::Response, AbuseReport)> { + use std::io::{Read, Seek}; + use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; + use client::{ToParts, url::Params}; + use std::borrow::Cow; + + let mut dd = client::DefaultDelegate; + let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd); + dlg.begin(client::MethodInfo { id: "youtube.abuseReports.insert", + http_method: hyper::Method::POST }); + + for &field in ["alt", "part"].iter() { + if self._additional_params.contains_key(field) { + dlg.finished(false); + return Err(client::Error::FieldClash(field)); + } + } + + let mut params = Params::with_capacity(4 + self._additional_params.len()); + if self._part.is_empty() { + self._part.push(self._request.to_parts()); + } + if self._part.len() > 0 { + for f in self._part.iter() { + params.push("part", f); + } + } + + params.extend(self._additional_params.iter()); + + params.push("alt", "json"); + let mut url = self.hub._base_url.clone() + "youtube/v3/abuseReports"; + if self._scopes.is_empty() { + self._scopes.insert(Scope::Full.as_ref().to_string()); + } + + + let url = params.parse_with_url(&url); + + let mut json_mime_type = mime::APPLICATION_JSON; + let mut request_value_reader = + { + let mut value = json::value::to_value(&self._request).expect("serde to work"); + client::remove_json_null_values(&mut value); + let mut dst = io::Cursor::new(Vec::with_capacity(128)); + json::to_writer(&mut dst, &value).unwrap(); + dst + }; + let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); + request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); + + + loop { + let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]).await { + Ok(token) => token, + Err(e) => { + match dlg.token(e) { + Ok(token) => token, + Err(e) => { + dlg.finished(false); + return Err(client::Error::MissingToken(e)); + } + } + } + }; + request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); + let mut req_result = { + let client = &self.hub.client; + dlg.pre_request(); + let mut req_builder = hyper::Request::builder() + .method(hyper::Method::POST) + .uri(url.as_str()) + .header(USER_AGENT, self.hub._user_agent.clone()); + + if let Some(token) = token.as_ref() { + req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); + } + + + let request = req_builder + .header(CONTENT_TYPE, json_mime_type.to_string()) + .header(CONTENT_LENGTH, request_size as u64) + .body(hyper::body::Body::from(request_value_reader.get_ref().clone())); + + client.request(request.unwrap()).await + + }; + + match req_result { + Err(err) => { + if let client::Retry::After(d) = dlg.http_error(&err) { + sleep(d).await; + continue; + } + dlg.finished(false); + return Err(client::Error::HttpError(err)) + } + Ok(mut res) => { + if !res.status().is_success() { + let res_body_string = client::get_body_as_string(res.body_mut()).await; + let (parts, _) = res.into_parts(); + let body = hyper::Body::from(res_body_string.clone()); + let restored_response = hyper::Response::from_parts(parts, body); + + let server_response = json::from_str::(&res_body_string).ok(); + + if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { + sleep(d).await; + continue; + } + + dlg.finished(false); + + return match server_response { + Some(error_value) => Err(client::Error::BadRequest(error_value)), + None => Err(client::Error::Failure(restored_response)), + } + } + let result_value = { + let res_body_string = client::get_body_as_string(res.body_mut()).await; + + match json::from_str(&res_body_string) { + Ok(decoded) => (res, decoded), + Err(err) => { + dlg.response_json_decode_error(&res_body_string, &err); + return Err(client::Error::JsonDecodeError(res_body_string, err)); + } + } + }; + + dlg.finished(true); + return Ok(result_value) + } + } + } + } + + + /// + /// Sets the *request* property to the given value. + /// + /// Even though the property as already been set when instantiating this call, + /// we provide this method for API completeness. + pub fn request(mut self, new_value: AbuseReport) -> AbuseReportInsertCall<'a, S> { + self._request = new_value; + self + } + /// The *part* parameter serves two purposes in this operation. It identifies the properties that the write operation will set as well as the properties that the API response will include. + /// + /// Append the given value to the *part* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + /// + /// Even though the *parts* list is automatically derived from *Resource* passed in + /// during instantiation and indicates which values you are passing, the response would contain the very same parts. + /// This may not always be desirable, as you can obtain (newly generated) parts you cannot pass in, + /// like statistics that are generated server side. Therefore you should use this method to specify + /// the parts you provide in addition to the ones you want in the response. + pub fn add_part(mut self, new_value: &str) -> AbuseReportInsertCall<'a, S> { + self._part.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. + /// + /// ````text + /// It should be used to handle progress information, and to implement a certain level of resilience. + /// ```` + /// + /// Sets the *delegate* property to the given value. + pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> AbuseReportInsertCall<'a, S> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not be used to set any of the known parameters + /// which have their own setter method. If done anyway, the request will fail. + /// + /// # Additional Parameters + /// + /// * *$.xgafv* (query-string) - V1 error format. + /// * *access_token* (query-string) - OAuth access token. + /// * *alt* (query-string) - Data format for response. + /// * *callback* (query-string) - JSONP + /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. + /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. + /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. + /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. + /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. + /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). + /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). + pub fn param(mut self, name: T, value: T) -> AbuseReportInsertCall<'a, S> + where T: AsRef { + self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); + self + } + + /// Identifies the authorization scope for the method you are building. + /// + /// Use this method to actively specify which scope should be used, instead of 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: St) -> AbuseReportInsertCall<'a, S> + where St: AsRef { + self._scopes.insert(String::from(scope.as_ref())); + self + } + /// Identifies the authorization scope(s) for the method you are building. + /// + /// See [`Self::add_scope()`] for details. + pub fn add_scopes(mut self, scopes: I) -> AbuseReportInsertCall<'a, S> + where I: IntoIterator, + St: AsRef { + self._scopes + .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); + self + } + + /// Removes all scopes, and no default scope will be used either. + /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] + /// for details). + pub fn clear_scopes(mut self) -> AbuseReportInsertCall<'a, S> { + self._scopes.clear(); + self + } +} + + +/// Retrieves a list of resources, possibly filtered. +/// +/// A builder for the *list* method supported by a *activity* resource. +/// It is not used directly, but through a [`ActivityMethods`] instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate hyper_rustls; +/// # extern crate google_youtube3 as youtube3; +/// # async fn dox() { +/// # use std::default::Default; +/// # use youtube3::{YouTube, oauth2, hyper, hyper_rustls, chrono, FieldMask}; +/// +/// # let secret: oauth2::ApplicationSecret = Default::default(); +/// # let auth = oauth2::InstalledFlowAuthenticator::builder( +/// # secret, +/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, +/// # ).build().await.unwrap(); +/// # let mut hub = YouTube::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().unwrap().https_or_http().enable_http1().build()), auth); +/// // You can configure optional parameters by calling the respective setters at will, and +/// // execute the final call using `doit()`. +/// // Values shown here are possibly random and not representative ! +/// let result = hub.activities().list(&vec!["ea".into()]) +/// .region_code("dolor") +/// .published_before(chrono::Utc::now()) +/// .published_after(chrono::Utc::now()) +/// .page_token("Lorem") +/// .mine(false) +/// .max_results(58) +/// .home(false) +/// .channel_id("sed") +/// .doit().await; +/// # } +/// ``` +pub struct ActivityListCall<'a, S> + where S: 'a { + + pub(super) hub: &'a YouTube, + pub(super) _part: Vec, + pub(super) _region_code: Option, + pub(super) _published_before: Option>, + pub(super) _published_after: Option>, + pub(super) _page_token: Option, + pub(super) _mine: Option, + pub(super) _max_results: Option, + pub(super) _home: Option, + pub(super) _channel_id: Option, + pub(super) _delegate: Option<&'a mut dyn client::Delegate>, + pub(super) _additional_params: HashMap, + pub(super) _scopes: BTreeSet +} + +impl<'a, S> client::CallBuilder for ActivityListCall<'a, S> {} + +impl<'a, S> ActivityListCall<'a, S> +where + S: tower_service::Service + Clone + Send + Sync + 'static, + S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, + S::Future: Send + Unpin + 'static, + S::Error: Into>, +{ + + + /// Perform the operation you have build so far. + pub async fn doit(mut self) -> client::Result<(hyper::Response, ActivityListResponse)> { + use std::io::{Read, Seek}; + use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; + use client::{ToParts, url::Params}; + use std::borrow::Cow; + + let mut dd = client::DefaultDelegate; + let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd); + dlg.begin(client::MethodInfo { id: "youtube.activities.list", + http_method: hyper::Method::GET }); + + for &field in ["alt", "part", "regionCode", "publishedBefore", "publishedAfter", "pageToken", "mine", "maxResults", "home", "channelId"].iter() { + if self._additional_params.contains_key(field) { + dlg.finished(false); + return Err(client::Error::FieldClash(field)); + } + } + + let mut params = Params::with_capacity(11 + self._additional_params.len()); + if self._part.len() > 0 { + for f in self._part.iter() { + params.push("part", f); + } + } + if let Some(value) = self._region_code.as_ref() { + params.push("regionCode", value); + } + if let Some(value) = self._published_before.as_ref() { + params.push("publishedBefore", ::client::serde::datetime_to_string(&value)); + } + if let Some(value) = self._published_after.as_ref() { + params.push("publishedAfter", ::client::serde::datetime_to_string(&value)); + } + if let Some(value) = self._page_token.as_ref() { + params.push("pageToken", value); + } + if let Some(value) = self._mine.as_ref() { + params.push("mine", value.to_string()); + } + if let Some(value) = self._max_results.as_ref() { + params.push("maxResults", value.to_string()); + } + if let Some(value) = self._home.as_ref() { + params.push("home", value.to_string()); + } + if let Some(value) = self._channel_id.as_ref() { + params.push("channelId", value); + } + + params.extend(self._additional_params.iter()); + + params.push("alt", "json"); + let mut url = self.hub._base_url.clone() + "youtube/v3/activities"; + if self._scopes.is_empty() { + self._scopes.insert(Scope::Readonly.as_ref().to_string()); + } + + + let url = params.parse_with_url(&url); + + + + loop { + let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]).await { + Ok(token) => token, + Err(e) => { + match dlg.token(e) { + Ok(token) => token, + Err(e) => { + dlg.finished(false); + return Err(client::Error::MissingToken(e)); + } + } + } + }; + let mut req_result = { + let client = &self.hub.client; + dlg.pre_request(); + let mut req_builder = hyper::Request::builder() + .method(hyper::Method::GET) + .uri(url.as_str()) + .header(USER_AGENT, self.hub._user_agent.clone()); + + if let Some(token) = token.as_ref() { + req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); + } + + + let request = req_builder + .header(CONTENT_LENGTH, 0_u64) + .body(hyper::body::Body::empty()); + + client.request(request.unwrap()).await + + }; + + match req_result { + Err(err) => { + if let client::Retry::After(d) = dlg.http_error(&err) { + sleep(d).await; + continue; + } + dlg.finished(false); + return Err(client::Error::HttpError(err)) + } + Ok(mut res) => { + if !res.status().is_success() { + let res_body_string = client::get_body_as_string(res.body_mut()).await; + let (parts, _) = res.into_parts(); + let body = hyper::Body::from(res_body_string.clone()); + let restored_response = hyper::Response::from_parts(parts, body); + + let server_response = json::from_str::(&res_body_string).ok(); + + if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { + sleep(d).await; + continue; + } + + dlg.finished(false); + + return match server_response { + Some(error_value) => Err(client::Error::BadRequest(error_value)), + None => Err(client::Error::Failure(restored_response)), + } + } + let result_value = { + let res_body_string = client::get_body_as_string(res.body_mut()).await; + + match json::from_str(&res_body_string) { + Ok(decoded) => (res, decoded), + Err(err) => { + dlg.response_json_decode_error(&res_body_string, &err); + return Err(client::Error::JsonDecodeError(res_body_string, err)); + } + } + }; + + dlg.finished(true); + return Ok(result_value) + } + } + } + } + + + /// The *part* parameter specifies a comma-separated list of one or more activity resource properties that the API response will include. If the parameter identifies a property that contains child properties, the child properties will be included in the response. For example, in an activity resource, the snippet property contains other properties that identify the type of activity, a display title for the activity, and so forth. If you set *part=snippet*, the API response will also contain all of those nested properties. + /// + /// Append the given value to the *part* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + /// + /// Even though the property as already been set when instantiating this call, + /// we provide this method for API completeness. + pub fn add_part(mut self, new_value: &str) -> ActivityListCall<'a, S> { + self._part.push(new_value.to_string()); + self + } + /// + /// Sets the *region code* query property to the given value. + pub fn region_code(mut self, new_value: &str) -> ActivityListCall<'a, S> { + self._region_code = Some(new_value.to_string()); + self + } + /// + /// Sets the *published before* query property to the given value. + pub fn published_before(mut self, new_value: client::chrono::DateTime) -> ActivityListCall<'a, S> { + self._published_before = Some(new_value); + self + } + /// + /// Sets the *published after* query property to the given value. + pub fn published_after(mut self, new_value: client::chrono::DateTime) -> ActivityListCall<'a, S> { + self._published_after = Some(new_value); + self + } + /// The *pageToken* parameter identifies a specific page in the result set that should be returned. In an API response, the nextPageToken and prevPageToken properties identify other pages that could be retrieved. + /// + /// Sets the *page token* query property to the given value. + pub fn page_token(mut self, new_value: &str) -> ActivityListCall<'a, S> { + self._page_token = Some(new_value.to_string()); + self + } + /// + /// Sets the *mine* query property to the given value. + pub fn mine(mut self, new_value: bool) -> ActivityListCall<'a, S> { + self._mine = Some(new_value); + self + } + /// The *maxResults* parameter specifies the maximum number of items that should be returned in the result set. + /// + /// Sets the *max results* query property to the given value. + pub fn max_results(mut self, new_value: u32) -> ActivityListCall<'a, S> { + self._max_results = Some(new_value); + self + } + /// + /// Sets the *home* query property to the given value. + pub fn home(mut self, new_value: bool) -> ActivityListCall<'a, S> { + self._home = Some(new_value); + self + } + /// + /// Sets the *channel id* query property to the given value. + pub fn channel_id(mut self, new_value: &str) -> ActivityListCall<'a, S> { + self._channel_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. + /// + /// ````text + /// It should be used to handle progress information, and to implement a certain level of resilience. + /// ```` + /// + /// Sets the *delegate* property to the given value. + pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> ActivityListCall<'a, S> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not be used to set any of the known parameters + /// which have their own setter method. If done anyway, the request will fail. + /// + /// # Additional Parameters + /// + /// * *$.xgafv* (query-string) - V1 error format. + /// * *access_token* (query-string) - OAuth access token. + /// * *alt* (query-string) - Data format for response. + /// * *callback* (query-string) - JSONP + /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. + /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. + /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. + /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. + /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. + /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). + /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). + pub fn param(mut self, name: T, value: T) -> ActivityListCall<'a, S> + where T: AsRef { + self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); + self + } + + /// Identifies the authorization scope for the method you are building. + /// + /// Use this method to actively specify which scope should be used, instead of 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: St) -> ActivityListCall<'a, S> + where St: AsRef { + self._scopes.insert(String::from(scope.as_ref())); + self + } + /// Identifies the authorization scope(s) for the method you are building. + /// + /// See [`Self::add_scope()`] for details. + pub fn add_scopes(mut self, scopes: I) -> ActivityListCall<'a, S> + where I: IntoIterator, + St: AsRef { + self._scopes + .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); + self + } + + /// Removes all scopes, and no default scope will be used either. + /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] + /// for details). + pub fn clear_scopes(mut self) -> ActivityListCall<'a, S> { + self._scopes.clear(); + self + } +} + + +/// Deletes a resource. +/// +/// A builder for the *delete* method supported by a *caption* resource. +/// It is not used directly, but through a [`CaptionMethods`] instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate hyper_rustls; +/// # extern crate google_youtube3 as youtube3; +/// # async fn dox() { +/// # use std::default::Default; +/// # use youtube3::{YouTube, oauth2, hyper, hyper_rustls, chrono, FieldMask}; +/// +/// # let secret: oauth2::ApplicationSecret = Default::default(); +/// # let auth = oauth2::InstalledFlowAuthenticator::builder( +/// # secret, +/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, +/// # ).build().await.unwrap(); +/// # let mut hub = YouTube::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().unwrap().https_or_http().enable_http1().build()), auth); +/// // You can configure optional parameters by calling the respective setters at will, and +/// // execute the final call using `doit()`. +/// // Values shown here are possibly random and not representative ! +/// let result = hub.captions().delete("id") +/// .on_behalf_of_content_owner("Stet") +/// .on_behalf_of("kasd") +/// .doit().await; +/// # } +/// ``` +pub struct CaptionDeleteCall<'a, S> + where S: 'a { + + pub(super) hub: &'a YouTube, + pub(super) _id: String, + pub(super) _on_behalf_of_content_owner: Option, + pub(super) _on_behalf_of: Option, + pub(super) _delegate: Option<&'a mut dyn client::Delegate>, + pub(super) _additional_params: HashMap, + pub(super) _scopes: BTreeSet +} + +impl<'a, S> client::CallBuilder for CaptionDeleteCall<'a, S> {} + +impl<'a, S> CaptionDeleteCall<'a, S> +where + S: tower_service::Service + Clone + Send + Sync + 'static, + S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, + S::Future: Send + Unpin + 'static, + S::Error: Into>, +{ + + + /// Perform the operation you have build so far. + pub async fn doit(mut self) -> client::Result> { + use std::io::{Read, Seek}; + use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; + use client::{ToParts, url::Params}; + use std::borrow::Cow; + + let mut dd = client::DefaultDelegate; + let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd); + dlg.begin(client::MethodInfo { id: "youtube.captions.delete", + http_method: hyper::Method::DELETE }); + + for &field in ["id", "onBehalfOfContentOwner", "onBehalfOf"].iter() { + if self._additional_params.contains_key(field) { + dlg.finished(false); + return Err(client::Error::FieldClash(field)); + } + } + + let mut params = Params::with_capacity(4 + self._additional_params.len()); + params.push("id", &self._id); + if let Some(value) = self._on_behalf_of_content_owner.as_ref() { + params.push("onBehalfOfContentOwner", value); + } + if let Some(value) = self._on_behalf_of.as_ref() { + params.push("onBehalfOf", value); + } + + params.extend(self._additional_params.iter()); + + let mut url = self.hub._base_url.clone() + "youtube/v3/captions"; + if self._scopes.is_empty() { + self._scopes.insert(Scope::ForceSsl.as_ref().to_string()); + } + + + let url = params.parse_with_url(&url); + + + + loop { + let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]).await { + Ok(token) => token, + Err(e) => { + match dlg.token(e) { + Ok(token) => token, + Err(e) => { + dlg.finished(false); + return Err(client::Error::MissingToken(e)); + } + } + } + }; + let mut req_result = { + let client = &self.hub.client; + dlg.pre_request(); + let mut req_builder = hyper::Request::builder() + .method(hyper::Method::DELETE) + .uri(url.as_str()) + .header(USER_AGENT, self.hub._user_agent.clone()); + + if let Some(token) = token.as_ref() { + req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); + } + + + let request = req_builder + .header(CONTENT_LENGTH, 0_u64) + .body(hyper::body::Body::empty()); + + client.request(request.unwrap()).await + + }; + + match req_result { + Err(err) => { + if let client::Retry::After(d) = dlg.http_error(&err) { + sleep(d).await; + continue; + } + dlg.finished(false); + return Err(client::Error::HttpError(err)) + } + Ok(mut res) => { + if !res.status().is_success() { + let res_body_string = client::get_body_as_string(res.body_mut()).await; + let (parts, _) = res.into_parts(); + let body = hyper::Body::from(res_body_string.clone()); + let restored_response = hyper::Response::from_parts(parts, body); + + let server_response = json::from_str::(&res_body_string).ok(); + + if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { + sleep(d).await; + continue; + } + + dlg.finished(false); + + return match server_response { + Some(error_value) => Err(client::Error::BadRequest(error_value)), + None => Err(client::Error::Failure(restored_response)), + } + } + let result_value = res; + + dlg.finished(true); + return Ok(result_value) + } + } + } + } + + + /// + /// 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) -> CaptionDeleteCall<'a, S> { + self._id = new_value.to_string(); + self + } + /// *Note:* This parameter is intended exclusively for YouTube content partners. The *onBehalfOfContentOwner* parameter indicates that the request's authorization credentials identify a YouTube CMS user who is acting on behalf of the content owner specified in the parameter value. This parameter is intended for YouTube content partners that own and manage many different YouTube channels. It allows content owners to authenticate once and get access to all their video and channel data, without having to provide authentication credentials for each individual channel. The actual CMS account that the user authenticates with must be linked to the specified YouTube content owner. + /// + /// Sets the *on behalf of content owner* query property to the given value. + pub fn on_behalf_of_content_owner(mut self, new_value: &str) -> CaptionDeleteCall<'a, S> { + self._on_behalf_of_content_owner = Some(new_value.to_string()); + self + } + /// ID of the Google+ Page for the channel that the request is be on behalf of + /// + /// Sets the *on behalf of* query property to the given value. + pub fn on_behalf_of(mut self, new_value: &str) -> CaptionDeleteCall<'a, S> { + self._on_behalf_of = 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. + /// + /// ````text + /// It should be used to handle progress information, and to implement a certain level of resilience. + /// ```` + /// + /// Sets the *delegate* property to the given value. + pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> CaptionDeleteCall<'a, S> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not be used to set any of the known parameters + /// which have their own setter method. If done anyway, the request will fail. + /// + /// # Additional Parameters + /// + /// * *$.xgafv* (query-string) - V1 error format. + /// * *access_token* (query-string) - OAuth access token. + /// * *alt* (query-string) - Data format for response. + /// * *callback* (query-string) - JSONP + /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. + /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. + /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. + /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. + /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. + /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). + /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). + pub fn param(mut self, name: T, value: T) -> CaptionDeleteCall<'a, S> + where T: AsRef { + self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); + self + } + + /// Identifies the authorization scope for the method you are building. + /// + /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant + /// [`Scope::ForceSsl`]. + /// + /// The `scope` will be added to a set of scopes. This is important as one can maintain access + /// tokens for more than one scope. + /// + /// Usually there is more than one suitable scope to authorize an operation, some of which may + /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be + /// sufficient, a read-write scope will do as well. + pub fn add_scope(mut self, scope: St) -> CaptionDeleteCall<'a, S> + where St: AsRef { + self._scopes.insert(String::from(scope.as_ref())); + self + } + /// Identifies the authorization scope(s) for the method you are building. + /// + /// See [`Self::add_scope()`] for details. + pub fn add_scopes(mut self, scopes: I) -> CaptionDeleteCall<'a, S> + where I: IntoIterator, + St: AsRef { + self._scopes + .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); + self + } + + /// Removes all scopes, and no default scope will be used either. + /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] + /// for details). + pub fn clear_scopes(mut self) -> CaptionDeleteCall<'a, S> { + self._scopes.clear(); + self + } +} + + +/// Downloads a caption track. +/// +/// This method supports **media download**. To enable it, adjust the builder like this: +/// `.param("alt", "media")`. +/// +/// A builder for the *download* method supported by a *caption* resource. +/// It is not used directly, but through a [`CaptionMethods`] instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate hyper_rustls; +/// # extern crate google_youtube3 as youtube3; +/// # async fn dox() { +/// # use std::default::Default; +/// # use youtube3::{YouTube, oauth2, hyper, hyper_rustls, chrono, FieldMask}; +/// +/// # let secret: oauth2::ApplicationSecret = Default::default(); +/// # let auth = oauth2::InstalledFlowAuthenticator::builder( +/// # secret, +/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, +/// # ).build().await.unwrap(); +/// # let mut hub = YouTube::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().unwrap().https_or_http().enable_http1().build()), auth); +/// // You can configure optional parameters by calling the respective setters at will, and +/// // execute the final call using `doit()`. +/// // Values shown here are possibly random and not representative ! +/// let result = hub.captions().download("id") +/// .tlang("sed") +/// .tfmt("et") +/// .on_behalf_of_content_owner("et") +/// .on_behalf_of("vero") +/// .doit().await; +/// # } +/// ``` +pub struct CaptionDownloadCall<'a, S> + where S: 'a { + + pub(super) hub: &'a YouTube, + pub(super) _id: String, + pub(super) _tlang: Option, + pub(super) _tfmt: Option, + pub(super) _on_behalf_of_content_owner: Option, + pub(super) _on_behalf_of: Option, + pub(super) _delegate: Option<&'a mut dyn client::Delegate>, + pub(super) _additional_params: HashMap, + pub(super) _scopes: BTreeSet +} + +impl<'a, S> client::CallBuilder for CaptionDownloadCall<'a, S> {} + +impl<'a, S> CaptionDownloadCall<'a, S> +where + S: tower_service::Service + Clone + Send + Sync + 'static, + S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, + S::Future: Send + Unpin + 'static, + S::Error: Into>, +{ + + + /// Perform the operation you have build so far. + pub async fn doit(mut self) -> client::Result> { + use std::io::{Read, Seek}; + use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; + use client::{ToParts, url::Params}; + use std::borrow::Cow; + + let mut dd = client::DefaultDelegate; + let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd); + dlg.begin(client::MethodInfo { id: "youtube.captions.download", + http_method: hyper::Method::GET }); + + for &field in ["id", "tlang", "tfmt", "onBehalfOfContentOwner", "onBehalfOf"].iter() { + if self._additional_params.contains_key(field) { + dlg.finished(false); + return Err(client::Error::FieldClash(field)); + } + } + + let mut params = Params::with_capacity(6 + self._additional_params.len()); + params.push("id", &self._id); + if let Some(value) = self._tlang.as_ref() { + params.push("tlang", value); + } + if let Some(value) = self._tfmt.as_ref() { + params.push("tfmt", value); + } + if let Some(value) = self._on_behalf_of_content_owner.as_ref() { + params.push("onBehalfOfContentOwner", value); + } + if let Some(value) = self._on_behalf_of.as_ref() { + params.push("onBehalfOf", value); + } + + params.extend(self._additional_params.iter()); + + let mut url = self.hub._base_url.clone() + "youtube/v3/captions/{id}"; + if self._scopes.is_empty() { + self._scopes.insert(Scope::ForceSsl.as_ref().to_string()); + } + + for &(find_this, param_name) in [("{id}", "id")].iter() { + url = params.uri_replacement(url, param_name, find_this, false); + } + { + let to_remove = ["id"]; + params.remove_params(&to_remove); + } + + let url = params.parse_with_url(&url); + + + + loop { + let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]).await { + Ok(token) => token, + Err(e) => { + match dlg.token(e) { + Ok(token) => token, + Err(e) => { + dlg.finished(false); + return Err(client::Error::MissingToken(e)); + } + } + } + }; + let mut req_result = { + let client = &self.hub.client; + dlg.pre_request(); + let mut req_builder = hyper::Request::builder() + .method(hyper::Method::GET) + .uri(url.as_str()) + .header(USER_AGENT, self.hub._user_agent.clone()); + + if let Some(token) = token.as_ref() { + req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); + } + + + let request = req_builder + .header(CONTENT_LENGTH, 0_u64) + .body(hyper::body::Body::empty()); + + client.request(request.unwrap()).await + + }; + + match req_result { + Err(err) => { + if let client::Retry::After(d) = dlg.http_error(&err) { + sleep(d).await; + continue; + } + dlg.finished(false); + return Err(client::Error::HttpError(err)) + } + Ok(mut res) => { + if !res.status().is_success() { + let res_body_string = client::get_body_as_string(res.body_mut()).await; + let (parts, _) = res.into_parts(); + let body = hyper::Body::from(res_body_string.clone()); + let restored_response = hyper::Response::from_parts(parts, body); + + let server_response = json::from_str::(&res_body_string).ok(); + + if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { + sleep(d).await; + continue; + } + + dlg.finished(false); + + return match server_response { + Some(error_value) => Err(client::Error::BadRequest(error_value)), + None => Err(client::Error::Failure(restored_response)), + } + } + let result_value = res; + + dlg.finished(true); + return Ok(result_value) + } + } + } + } + + + /// The ID of the caption track to download, required for One Platform. + /// + /// 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) -> CaptionDownloadCall<'a, S> { + self._id = new_value.to_string(); + self + } + /// tlang is the language code; machine translate the captions into this language. + /// + /// Sets the *tlang* query property to the given value. + pub fn tlang(mut self, new_value: &str) -> CaptionDownloadCall<'a, S> { + self._tlang = Some(new_value.to_string()); + self + } + /// Convert the captions into this format. Supported options are sbv, srt, and vtt. + /// + /// Sets the *tfmt* query property to the given value. + pub fn tfmt(mut self, new_value: &str) -> CaptionDownloadCall<'a, S> { + self._tfmt = Some(new_value.to_string()); + self + } + /// *Note:* This parameter is intended exclusively for YouTube content partners. The *onBehalfOfContentOwner* parameter indicates that the request's authorization credentials identify a YouTube CMS user who is acting on behalf of the content owner specified in the parameter value. This parameter is intended for YouTube content partners that own and manage many different YouTube channels. It allows content owners to authenticate once and get access to all their video and channel data, without having to provide authentication credentials for each individual channel. The actual CMS account that the user authenticates with must be linked to the specified YouTube content owner. + /// + /// Sets the *on behalf of content owner* query property to the given value. + pub fn on_behalf_of_content_owner(mut self, new_value: &str) -> CaptionDownloadCall<'a, S> { + self._on_behalf_of_content_owner = Some(new_value.to_string()); + self + } + /// ID of the Google+ Page for the channel that the request is be on behalf of + /// + /// Sets the *on behalf of* query property to the given value. + pub fn on_behalf_of(mut self, new_value: &str) -> CaptionDownloadCall<'a, S> { + self._on_behalf_of = 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. + /// + /// ````text + /// It should be used to handle progress information, and to implement a certain level of resilience. + /// ```` + /// + /// Sets the *delegate* property to the given value. + pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> CaptionDownloadCall<'a, S> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not be used to set any of the known parameters + /// which have their own setter method. If done anyway, the request will fail. + /// + /// # Additional Parameters + /// + /// * *$.xgafv* (query-string) - V1 error format. + /// * *access_token* (query-string) - OAuth access token. + /// * *alt* (query-string) - Data format for response. + /// * *callback* (query-string) - JSONP + /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. + /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. + /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. + /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. + /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. + /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). + /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). + pub fn param(mut self, name: T, value: T) -> CaptionDownloadCall<'a, S> + where T: AsRef { + self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); + self + } + + /// Identifies the authorization scope for the method you are building. + /// + /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant + /// [`Scope::ForceSsl`]. + /// + /// The `scope` will be added to a set of scopes. This is important as one can maintain access + /// tokens for more than one scope. + /// + /// Usually there is more than one suitable scope to authorize an operation, some of which may + /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be + /// sufficient, a read-write scope will do as well. + pub fn add_scope(mut self, scope: St) -> CaptionDownloadCall<'a, S> + where St: AsRef { + self._scopes.insert(String::from(scope.as_ref())); + self + } + /// Identifies the authorization scope(s) for the method you are building. + /// + /// See [`Self::add_scope()`] for details. + pub fn add_scopes(mut self, scopes: I) -> CaptionDownloadCall<'a, S> + where I: IntoIterator, + St: AsRef { + self._scopes + .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); + self + } + + /// Removes all scopes, and no default scope will be used either. + /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] + /// for details). + pub fn clear_scopes(mut self) -> CaptionDownloadCall<'a, S> { + self._scopes.clear(); + self + } +} + + +/// Inserts a new resource into this collection. +/// +/// A builder for the *insert* method supported by a *caption* resource. +/// It is not used directly, but through a [`CaptionMethods`] instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate hyper_rustls; +/// # extern crate google_youtube3 as youtube3; +/// use youtube3::api::Caption; +/// use std::fs; +/// # async fn dox() { +/// # use std::default::Default; +/// # use youtube3::{YouTube, oauth2, hyper, hyper_rustls, chrono, FieldMask}; +/// +/// # let secret: oauth2::ApplicationSecret = Default::default(); +/// # let auth = oauth2::InstalledFlowAuthenticator::builder( +/// # secret, +/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, +/// # ).build().await.unwrap(); +/// # let mut hub = YouTube::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().unwrap().https_or_http().enable_http1().build()), auth); +/// // As the method needs a request, you would usually fill it with the desired information +/// // into the respective structure. Some of the parts shown here might not be applicable ! +/// // Values shown here are possibly random and not representative ! +/// let mut req = Caption::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.captions().insert(req) +/// .sync(false) +/// .on_behalf_of_content_owner("duo") +/// .on_behalf_of("dolore") +/// .upload(fs::File::open("file.ext").unwrap(), "application/octet-stream".parse().unwrap()).await; +/// # } +/// ``` +pub struct CaptionInsertCall<'a, S> + where S: 'a { + + pub(super) hub: &'a YouTube, + pub(super) _request: Caption, + pub(super) _part: Vec, + pub(super) _sync: Option, + pub(super) _on_behalf_of_content_owner: Option, + pub(super) _on_behalf_of: Option, + pub(super) _delegate: Option<&'a mut dyn client::Delegate>, + pub(super) _additional_params: HashMap, + pub(super) _scopes: BTreeSet +} + +impl<'a, S> client::CallBuilder for CaptionInsertCall<'a, S> {} + +impl<'a, S> CaptionInsertCall<'a, S> +where + S: tower_service::Service + Clone + Send + Sync + 'static, + S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, + S::Future: Send + Unpin + 'static, + S::Error: Into>, +{ + + + /// Perform the operation you have build so far. + async fn doit(mut self, mut reader: RS, reader_mime_type: mime::Mime, protocol: client::UploadProtocol) -> client::Result<(hyper::Response, Caption)> + where RS: client::ReadSeek { + use std::io::{Read, Seek}; + use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; + use client::{ToParts, url::Params}; + use std::borrow::Cow; + + let mut dd = client::DefaultDelegate; + let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd); + dlg.begin(client::MethodInfo { id: "youtube.captions.insert", + http_method: hyper::Method::POST }); + + for &field in ["alt", "part", "sync", "onBehalfOfContentOwner", "onBehalfOf"].iter() { + if self._additional_params.contains_key(field) { + dlg.finished(false); + return Err(client::Error::FieldClash(field)); + } + } + + let mut params = Params::with_capacity(7 + self._additional_params.len()); + if self._part.is_empty() { + self._part.push(self._request.to_parts()); + } + if self._part.len() > 0 { + for f in self._part.iter() { + params.push("part", f); + } + } + if let Some(value) = self._sync.as_ref() { + params.push("sync", value.to_string()); + } + if let Some(value) = self._on_behalf_of_content_owner.as_ref() { + params.push("onBehalfOfContentOwner", value); + } + if let Some(value) = self._on_behalf_of.as_ref() { + params.push("onBehalfOf", value); + } + + params.extend(self._additional_params.iter()); + + params.push("alt", "json"); + let (mut url, upload_type) = + if protocol == client::UploadProtocol::Resumable { + (self.hub._root_url.clone() + "resumable/upload/youtube/v3/captions", "resumable") + } else if protocol == client::UploadProtocol::Simple { + (self.hub._root_url.clone() + "upload/youtube/v3/captions", "multipart") + } else { + unreachable!() + }; + params.push("uploadType", upload_type); + if self._scopes.is_empty() { + self._scopes.insert(Scope::ForceSsl.as_ref().to_string()); + } + + + let url = params.parse_with_url(&url); + + let mut json_mime_type = mime::APPLICATION_JSON; + let mut request_value_reader = + { + let mut value = json::value::to_value(&self._request).expect("serde to work"); + client::remove_json_null_values(&mut value); + let mut dst = io::Cursor::new(Vec::with_capacity(128)); + json::to_writer(&mut dst, &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.get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]).await { + Ok(token) => token, + Err(e) => { + match dlg.token(e) { + Ok(token) => token, + Err(e) => { + dlg.finished(false); + return Err(client::Error::MissingToken(e)); + } + } + } + }; + 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; + Ok(hyper::Response::builder() + .status(hyper::StatusCode::OK) + .header("Location", upload_url.as_ref().unwrap().clone()) + .body(hyper::body::Body::empty()) + .unwrap()) + } else { + let mut mp_reader: client::MultiPartReader = Default::default(); + let (mut body_reader, content_type) = match protocol { + client::UploadProtocol::Simple => { + mp_reader.reserve_exact(2); + let size = reader.seek(io::SeekFrom::End(0)).unwrap(); + reader.seek(io::SeekFrom::Start(0)).unwrap(); + if size > 104857600 { + return Err(client::Error::UploadSizeLimitExceeded(size, 104857600)) + } + mp_reader.add_part(&mut request_value_reader, request_size, json_mime_type.clone()) + .add_part(&mut reader, size, reader_mime_type.clone()); + (&mut mp_reader as &mut (dyn io::Read + Send), client::MultiPartReader::mime_type()) + }, + _ => (&mut request_value_reader as &mut (dyn io::Read + Send), json_mime_type.clone()), + }; + let client = &self.hub.client; + dlg.pre_request(); + let mut req_builder = hyper::Request::builder() + .method(hyper::Method::POST) + .uri(url.as_str()) + .header(USER_AGENT, self.hub._user_agent.clone()); + + if let Some(token) = token.as_ref() { + req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); + } + + upload_url_from_server = true; + if protocol == client::UploadProtocol::Resumable { + req_builder = req_builder.header("X-Upload-Content-Type", format!("{}", reader_mime_type)); + } + + let mut body_reader_bytes = vec![]; + body_reader.read_to_end(&mut body_reader_bytes).unwrap(); + let request = req_builder + .header(CONTENT_TYPE, content_type.to_string()) + .body(hyper::body::Body::from(body_reader_bytes)); + + client.request(request.unwrap()).await + + } + }; + + match req_result { + Err(err) => { + if let client::Retry::After(d) = dlg.http_error(&err) { + sleep(d).await; + continue; + } + dlg.finished(false); + return Err(client::Error::HttpError(err)) + } + Ok(mut res) => { + if !res.status().is_success() { + let res_body_string = client::get_body_as_string(res.body_mut()).await; + let (parts, _) = res.into_parts(); + let body = hyper::Body::from(res_body_string.clone()); + let restored_response = hyper::Response::from_parts(parts, body); + + let server_response = json::from_str::(&res_body_string).ok(); + + if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { + sleep(d).await; + continue; + } + + dlg.finished(false); + + return match server_response { + Some(error_value) => Err(client::Error::BadRequest(error_value)), + None => Err(client::Error::Failure(restored_response)), + } + } + if protocol == client::UploadProtocol::Resumable { + let size = reader.seek(io::SeekFrom::End(0)).unwrap(); + reader.seek(io::SeekFrom::Start(0)).unwrap(); + if size > 104857600 { + return Err(client::Error::UploadSizeLimitExceeded(size, 104857600)) + } + let upload_result = { + let url_str = &res.headers().get("Location").expect("LOCATION header is part of protocol").to_str().unwrap(); + if upload_url_from_server { + dlg.store_upload_url(Some(url_str)); + } + + client::ResumableUploadHelper { + client: &self.hub.client, + delegate: dlg, + start_at: if upload_url_from_server { Some(0) } else { None }, + auth: &self.hub.auth, + user_agent: &self.hub._user_agent, + // TODO: Check this assumption + auth_header: format!("Bearer {}", token.ok_or_else(|| client::Error::MissingToken("resumable upload requires token".into()))?.as_str()), + url: url_str, + reader: &mut reader, + media_type: reader_mime_type.clone(), + content_length: size + }.upload().await + }; + match upload_result { + None => { + dlg.finished(false); + return Err(client::Error::Cancelled) + } + Some(Err(err)) => { + dlg.finished(false); + return Err(client::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(client::Error::Failure(res)) + } + } + } + } + let result_value = { + let res_body_string = client::get_body_as_string(res.body_mut()).await; + + match json::from_str(&res_body_string) { + Ok(decoded) => (res, decoded), + Err(err) => { + dlg.response_json_decode_error(&res_body_string, &err); + return Err(client::Error::JsonDecodeError(res_body_string, err)); + } + } + }; + + dlg.finished(true); + return Ok(result_value) + } + } + } + } + + /// 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(...)`. + /// + /// * *multipart*: yes + /// * *max size*: 104857600 + /// * *valid mime types*: 'text/xml', 'application/octet-stream' and '*/*' + pub async fn upload_resumable(self, resumeable_stream: RS, mime_type: mime::Mime) -> client::Result<(hyper::Response, Caption)> + where RS: client::ReadSeek { + self.doit(resumeable_stream, mime_type, client::UploadProtocol::Resumable).await + } + /// Upload media all at once. + /// If the upload fails for whichever reason, all progress is lost. + /// + /// * *multipart*: yes + /// * *max size*: 104857600 + /// * *valid mime types*: 'text/xml', 'application/octet-stream' and '*/*' + pub async fn upload(self, stream: RS, mime_type: mime::Mime) -> client::Result<(hyper::Response, Caption)> + where RS: client::ReadSeek { + self.doit(stream, mime_type, client::UploadProtocol::Simple).await + } + + /// + /// Sets the *request* property to the given value. + /// + /// Even though the property as already been set when instantiating this call, + /// we provide this method for API completeness. + pub fn request(mut self, new_value: Caption) -> CaptionInsertCall<'a, S> { + self._request = new_value; + self + } + /// The *part* parameter specifies the caption resource parts that the API response will include. Set the parameter value to snippet. + /// + /// Append the given value to the *part* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + /// + /// Even though the *parts* list is automatically derived from *Resource* passed in + /// during instantiation and indicates which values you are passing, the response would contain the very same parts. + /// This may not always be desirable, as you can obtain (newly generated) parts you cannot pass in, + /// like statistics that are generated server side. Therefore you should use this method to specify + /// the parts you provide in addition to the ones you want in the response. + pub fn add_part(mut self, new_value: &str) -> CaptionInsertCall<'a, S> { + self._part.push(new_value.to_string()); + self + } + /// Extra parameter to allow automatically syncing the uploaded caption/transcript with the audio. + /// + /// Sets the *sync* query property to the given value. + pub fn sync(mut self, new_value: bool) -> CaptionInsertCall<'a, S> { + self._sync = Some(new_value); + self + } + /// *Note:* This parameter is intended exclusively for YouTube content partners. The *onBehalfOfContentOwner* parameter indicates that the request's authorization credentials identify a YouTube CMS user who is acting on behalf of the content owner specified in the parameter value. This parameter is intended for YouTube content partners that own and manage many different YouTube channels. It allows content owners to authenticate once and get access to all their video and channel data, without having to provide authentication credentials for each individual channel. The actual CMS account that the user authenticates with must be linked to the specified YouTube content owner. + /// + /// Sets the *on behalf of content owner* query property to the given value. + pub fn on_behalf_of_content_owner(mut self, new_value: &str) -> CaptionInsertCall<'a, S> { + self._on_behalf_of_content_owner = Some(new_value.to_string()); + self + } + /// ID of the Google+ Page for the channel that the request is be on behalf of + /// + /// Sets the *on behalf of* query property to the given value. + pub fn on_behalf_of(mut self, new_value: &str) -> CaptionInsertCall<'a, S> { + self._on_behalf_of = 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. + /// + /// ````text + /// It should be used to handle progress information, and to implement a certain level of resilience. + /// ```` + /// + /// Sets the *delegate* property to the given value. + pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> CaptionInsertCall<'a, S> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not be used to set any of the known parameters + /// which have their own setter method. If done anyway, the request will fail. + /// + /// # Additional Parameters + /// + /// * *$.xgafv* (query-string) - V1 error format. + /// * *access_token* (query-string) - OAuth access token. + /// * *alt* (query-string) - Data format for response. + /// * *callback* (query-string) - JSONP + /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. + /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. + /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. + /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. + /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. + /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). + /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). + pub fn param(mut self, name: T, value: T) -> CaptionInsertCall<'a, S> + where T: AsRef { + self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); + self + } + + /// Identifies the authorization scope for the method you are building. + /// + /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant + /// [`Scope::ForceSsl`]. + /// + /// The `scope` will be added to a set of scopes. This is important as one can maintain access + /// tokens for more than one scope. + /// + /// Usually there is more than one suitable scope to authorize an operation, some of which may + /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be + /// sufficient, a read-write scope will do as well. + pub fn add_scope(mut self, scope: St) -> CaptionInsertCall<'a, S> + where St: AsRef { + self._scopes.insert(String::from(scope.as_ref())); + self + } + /// Identifies the authorization scope(s) for the method you are building. + /// + /// See [`Self::add_scope()`] for details. + pub fn add_scopes(mut self, scopes: I) -> CaptionInsertCall<'a, S> + where I: IntoIterator, + St: AsRef { + self._scopes + .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); + self + } + + /// Removes all scopes, and no default scope will be used either. + /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] + /// for details). + pub fn clear_scopes(mut self) -> CaptionInsertCall<'a, S> { + self._scopes.clear(); + self + } +} + + +/// Retrieves a list of resources, possibly filtered. +/// +/// A builder for the *list* method supported by a *caption* resource. +/// It is not used directly, but through a [`CaptionMethods`] instance. +/// +/// **Settable Parts** +/// +/// * *id* +/// * *snippet* +/// +/// # Scopes +/// +/// You will need authorization for at least one of the following scopes to make a valid call, possibly depending on *parts*: +/// +/// * *https://www.googleapis.com/auth/youtube.force-ssl* +/// * *https://www.googleapis.com/auth/youtubepartner* +/// +/// The default scope will be `Scope::ForceSsl`. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate hyper_rustls; +/// # extern crate google_youtube3 as youtube3; +/// # async fn dox() { +/// # use std::default::Default; +/// # use youtube3::{YouTube, oauth2, hyper, hyper_rustls, chrono, FieldMask}; +/// +/// # let secret: oauth2::ApplicationSecret = Default::default(); +/// # let auth = oauth2::InstalledFlowAuthenticator::builder( +/// # secret, +/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, +/// # ).build().await.unwrap(); +/// # let mut hub = YouTube::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().unwrap().https_or_http().enable_http1().build()), auth); +/// // You can configure optional parameters by calling the respective setters at will, and +/// // execute the final call using `doit()`. +/// // Values shown here are possibly random and not representative ! +/// let result = hub.captions().list(&vec!["et".into()], "videoId") +/// .on_behalf_of_content_owner("amet.") +/// .on_behalf_of("consetetur") +/// .add_id("diam") +/// .doit().await; +/// # } +/// ``` +pub struct CaptionListCall<'a, S> + where S: 'a { + + pub(super) hub: &'a YouTube, + pub(super) _part: Vec, + pub(super) _video_id: String, + pub(super) _on_behalf_of_content_owner: Option, + pub(super) _on_behalf_of: Option, + pub(super) _id: Vec, + pub(super) _delegate: Option<&'a mut dyn client::Delegate>, + pub(super) _additional_params: HashMap, + pub(super) _scopes: BTreeSet +} + +impl<'a, S> client::CallBuilder for CaptionListCall<'a, S> {} + +impl<'a, S> CaptionListCall<'a, S> +where + S: tower_service::Service + Clone + Send + Sync + 'static, + S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, + S::Future: Send + Unpin + 'static, + S::Error: Into>, +{ + + + /// Perform the operation you have build so far. + pub async fn doit(mut self) -> client::Result<(hyper::Response, CaptionListResponse)> { + use std::io::{Read, Seek}; + use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; + use client::{ToParts, url::Params}; + use std::borrow::Cow; + + let mut dd = client::DefaultDelegate; + let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd); + dlg.begin(client::MethodInfo { id: "youtube.captions.list", + http_method: hyper::Method::GET }); + + for &field in ["alt", "part", "videoId", "onBehalfOfContentOwner", "onBehalfOf", "id"].iter() { + if self._additional_params.contains_key(field) { + dlg.finished(false); + return Err(client::Error::FieldClash(field)); + } + } + + let mut params = Params::with_capacity(7 + self._additional_params.len()); + if self._part.len() > 0 { + for f in self._part.iter() { + params.push("part", f); + } + } + params.push("videoId", &self._video_id); + if let Some(value) = self._on_behalf_of_content_owner.as_ref() { + params.push("onBehalfOfContentOwner", value); + } + if let Some(value) = self._on_behalf_of.as_ref() { + params.push("onBehalfOf", value); + } + if self._id.len() > 0 { + for f in self._id.iter() { + params.push("id", f); + } + } + + params.extend(self._additional_params.iter()); + + params.push("alt", "json"); + let mut url = self.hub._base_url.clone() + "youtube/v3/captions"; + if self._scopes.is_empty() { + self._scopes.insert(Scope::ForceSsl.as_ref().to_string()); + } + + + let url = params.parse_with_url(&url); + + + + loop { + let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]).await { + Ok(token) => token, + Err(e) => { + match dlg.token(e) { + Ok(token) => token, + Err(e) => { + dlg.finished(false); + return Err(client::Error::MissingToken(e)); + } + } + } + }; + let mut req_result = { + let client = &self.hub.client; + dlg.pre_request(); + let mut req_builder = hyper::Request::builder() + .method(hyper::Method::GET) + .uri(url.as_str()) + .header(USER_AGENT, self.hub._user_agent.clone()); + + if let Some(token) = token.as_ref() { + req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); + } + + + let request = req_builder + .header(CONTENT_LENGTH, 0_u64) + .body(hyper::body::Body::empty()); + + client.request(request.unwrap()).await + + }; + + match req_result { + Err(err) => { + if let client::Retry::After(d) = dlg.http_error(&err) { + sleep(d).await; + continue; + } + dlg.finished(false); + return Err(client::Error::HttpError(err)) + } + Ok(mut res) => { + if !res.status().is_success() { + let res_body_string = client::get_body_as_string(res.body_mut()).await; + let (parts, _) = res.into_parts(); + let body = hyper::Body::from(res_body_string.clone()); + let restored_response = hyper::Response::from_parts(parts, body); + + let server_response = json::from_str::(&res_body_string).ok(); + + if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { + sleep(d).await; + continue; + } + + dlg.finished(false); + + return match server_response { + Some(error_value) => Err(client::Error::BadRequest(error_value)), + None => Err(client::Error::Failure(restored_response)), + } + } + let result_value = { + let res_body_string = client::get_body_as_string(res.body_mut()).await; + + match json::from_str(&res_body_string) { + Ok(decoded) => (res, decoded), + Err(err) => { + dlg.response_json_decode_error(&res_body_string, &err); + return Err(client::Error::JsonDecodeError(res_body_string, err)); + } + } + }; + + dlg.finished(true); + return Ok(result_value) + } + } + } + } + + + /// The *part* parameter specifies a comma-separated list of one or more caption resource parts that the API response will include. The part names that you can include in the parameter value are id and snippet. + /// + /// Append the given value to the *part* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + /// + /// Even though the property as already been set when instantiating this call, + /// we provide this method for API completeness. + /// + /// **Settable Parts** + /// + /// * *id* + /// * *snippet* + pub fn add_part(mut self, new_value: &str) -> CaptionListCall<'a, S> { + self._part.push(new_value.to_string()); + self + } + /// Returns the captions for the specified video. + /// + /// Sets the *video 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 video_id(mut self, new_value: &str) -> CaptionListCall<'a, S> { + self._video_id = new_value.to_string(); + self + } + /// *Note:* This parameter is intended exclusively for YouTube content partners. The *onBehalfOfContentOwner* parameter indicates that the request's authorization credentials identify a YouTube CMS user who is acting on behalf of the content owner specified in the parameter value. This parameter is intended for YouTube content partners that own and manage many different YouTube channels. It allows content owners to authenticate once and get access to all their video and channel data, without having to provide authentication credentials for each individual channel. The actual CMS account that the user authenticates with must be linked to the specified YouTube content owner. + /// + /// Sets the *on behalf of content owner* query property to the given value. + pub fn on_behalf_of_content_owner(mut self, new_value: &str) -> CaptionListCall<'a, S> { + self._on_behalf_of_content_owner = Some(new_value.to_string()); + self + } + /// ID of the Google+ Page for the channel that the request is on behalf of. + /// + /// Sets the *on behalf of* query property to the given value. + pub fn on_behalf_of(mut self, new_value: &str) -> CaptionListCall<'a, S> { + self._on_behalf_of = Some(new_value.to_string()); + self + } + /// Returns the captions with the given IDs for Stubby or Apiary. + /// + /// Append the given value to the *id* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + pub fn add_id(mut self, new_value: &str) -> CaptionListCall<'a, S> { + self._id.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. + /// + /// ````text + /// It should be used to handle progress information, and to implement a certain level of resilience. + /// ```` + /// + /// Sets the *delegate* property to the given value. + pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> CaptionListCall<'a, S> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not be used to set any of the known parameters + /// which have their own setter method. If done anyway, the request will fail. + /// + /// # Additional Parameters + /// + /// * *$.xgafv* (query-string) - V1 error format. + /// * *access_token* (query-string) - OAuth access token. + /// * *alt* (query-string) - Data format for response. + /// * *callback* (query-string) - JSONP + /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. + /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. + /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. + /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. + /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. + /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). + /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). + pub fn param(mut self, name: T, value: T) -> CaptionListCall<'a, S> + where T: AsRef { + self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); + self + } + + /// Identifies the authorization scope for the method you are building. + /// + /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant + /// [`Scope::ForceSsl`]. + /// + /// The `scope` will be added to a set of scopes. This is important as one can maintain access + /// tokens for more than one scope. + /// + /// Usually there is more than one suitable scope to authorize an operation, some of which may + /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be + /// sufficient, a read-write scope will do as well. + pub fn add_scope(mut self, scope: St) -> CaptionListCall<'a, S> + where St: AsRef { + self._scopes.insert(String::from(scope.as_ref())); + self + } + /// Identifies the authorization scope(s) for the method you are building. + /// + /// See [`Self::add_scope()`] for details. + pub fn add_scopes(mut self, scopes: I) -> CaptionListCall<'a, S> + where I: IntoIterator, + St: AsRef { + self._scopes + .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); + self + } + + /// Removes all scopes, and no default scope will be used either. + /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] + /// for details). + pub fn clear_scopes(mut self) -> CaptionListCall<'a, S> { + self._scopes.clear(); + self + } +} + + +/// Updates an existing resource. +/// +/// A builder for the *update* method supported by a *caption* resource. +/// It is not used directly, but through a [`CaptionMethods`] instance. +/// +/// **Settable Parts** +/// +/// * *id* +/// * *snippet* +/// +/// # Scopes +/// +/// You will need authorization for at least one of the following scopes to make a valid call, possibly depending on *parts*: +/// +/// * *https://www.googleapis.com/auth/youtube.force-ssl* +/// * *https://www.googleapis.com/auth/youtubepartner* +/// +/// The default scope will be `Scope::ForceSsl`. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate hyper_rustls; +/// # extern crate google_youtube3 as youtube3; +/// use youtube3::api::Caption; +/// use std::fs; +/// # async fn dox() { +/// # use std::default::Default; +/// # use youtube3::{YouTube, oauth2, hyper, hyper_rustls, chrono, FieldMask}; +/// +/// # let secret: oauth2::ApplicationSecret = Default::default(); +/// # let auth = oauth2::InstalledFlowAuthenticator::builder( +/// # secret, +/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, +/// # ).build().await.unwrap(); +/// # let mut hub = YouTube::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().unwrap().https_or_http().enable_http1().build()), auth); +/// // As the method needs a request, you would usually fill it with the desired information +/// // into the respective structure. Some of the parts shown here might not be applicable ! +/// // Values shown here are possibly random and not representative ! +/// let mut req = Caption::default(); +/// req.id = Some("dolor".to_string()); +/// req.snippet = Default::default(); // is CaptionSnippet +/// +/// // 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.captions().update(req) +/// .sync(false) +/// .on_behalf_of_content_owner("Stet") +/// .on_behalf_of("dolor") +/// .upload(fs::File::open("file.ext").unwrap(), "application/octet-stream".parse().unwrap()).await; +/// # } +/// ``` +pub struct CaptionUpdateCall<'a, S> + where S: 'a { + + pub(super) hub: &'a YouTube, + pub(super) _request: Caption, + pub(super) _part: Vec, + pub(super) _sync: Option, + pub(super) _on_behalf_of_content_owner: Option, + pub(super) _on_behalf_of: Option, + pub(super) _delegate: Option<&'a mut dyn client::Delegate>, + pub(super) _additional_params: HashMap, + pub(super) _scopes: BTreeSet +} + +impl<'a, S> client::CallBuilder for CaptionUpdateCall<'a, S> {} + +impl<'a, S> CaptionUpdateCall<'a, S> +where + S: tower_service::Service + Clone + Send + Sync + 'static, + S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, + S::Future: Send + Unpin + 'static, + S::Error: Into>, +{ + + + /// Perform the operation you have build so far. + async fn doit(mut self, mut reader: RS, reader_mime_type: mime::Mime, protocol: client::UploadProtocol) -> client::Result<(hyper::Response, Caption)> + where RS: client::ReadSeek { + use std::io::{Read, Seek}; + use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; + use client::{ToParts, url::Params}; + use std::borrow::Cow; + + let mut dd = client::DefaultDelegate; + let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd); + dlg.begin(client::MethodInfo { id: "youtube.captions.update", + http_method: hyper::Method::PUT }); + + for &field in ["alt", "part", "sync", "onBehalfOfContentOwner", "onBehalfOf"].iter() { + if self._additional_params.contains_key(field) { + dlg.finished(false); + return Err(client::Error::FieldClash(field)); + } + } + + let mut params = Params::with_capacity(7 + self._additional_params.len()); + if self._part.is_empty() { + self._part.push(self._request.to_parts()); + } + if self._part.len() > 0 { + for f in self._part.iter() { + params.push("part", f); + } + } + if let Some(value) = self._sync.as_ref() { + params.push("sync", value.to_string()); + } + if let Some(value) = self._on_behalf_of_content_owner.as_ref() { + params.push("onBehalfOfContentOwner", value); + } + if let Some(value) = self._on_behalf_of.as_ref() { + params.push("onBehalfOf", value); + } + + params.extend(self._additional_params.iter()); + + params.push("alt", "json"); + let (mut url, upload_type) = + if protocol == client::UploadProtocol::Resumable { + (self.hub._root_url.clone() + "resumable/upload/youtube/v3/captions", "resumable") + } else if protocol == client::UploadProtocol::Simple { + (self.hub._root_url.clone() + "upload/youtube/v3/captions", "multipart") + } else { + unreachable!() + }; + params.push("uploadType", upload_type); + if self._scopes.is_empty() { + self._scopes.insert(Scope::ForceSsl.as_ref().to_string()); + } + + + let url = params.parse_with_url(&url); + + let mut json_mime_type = mime::APPLICATION_JSON; + let mut request_value_reader = + { + let mut value = json::value::to_value(&self._request).expect("serde to work"); + client::remove_json_null_values(&mut value); + let mut dst = io::Cursor::new(Vec::with_capacity(128)); + json::to_writer(&mut dst, &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.get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]).await { + Ok(token) => token, + Err(e) => { + match dlg.token(e) { + Ok(token) => token, + Err(e) => { + dlg.finished(false); + return Err(client::Error::MissingToken(e)); + } + } + } + }; + 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; + Ok(hyper::Response::builder() + .status(hyper::StatusCode::OK) + .header("Location", upload_url.as_ref().unwrap().clone()) + .body(hyper::body::Body::empty()) + .unwrap()) + } else { + let mut mp_reader: client::MultiPartReader = Default::default(); + let (mut body_reader, content_type) = match protocol { + client::UploadProtocol::Simple => { + mp_reader.reserve_exact(2); + let size = reader.seek(io::SeekFrom::End(0)).unwrap(); + reader.seek(io::SeekFrom::Start(0)).unwrap(); + if size > 104857600 { + return Err(client::Error::UploadSizeLimitExceeded(size, 104857600)) + } + mp_reader.add_part(&mut request_value_reader, request_size, json_mime_type.clone()) + .add_part(&mut reader, size, reader_mime_type.clone()); + (&mut mp_reader as &mut (dyn io::Read + Send), client::MultiPartReader::mime_type()) + }, + _ => (&mut request_value_reader as &mut (dyn io::Read + Send), json_mime_type.clone()), + }; + let client = &self.hub.client; + dlg.pre_request(); + let mut req_builder = hyper::Request::builder() + .method(hyper::Method::PUT) + .uri(url.as_str()) + .header(USER_AGENT, self.hub._user_agent.clone()); + + if let Some(token) = token.as_ref() { + req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); + } + + upload_url_from_server = true; + if protocol == client::UploadProtocol::Resumable { + req_builder = req_builder.header("X-Upload-Content-Type", format!("{}", reader_mime_type)); + } + + let mut body_reader_bytes = vec![]; + body_reader.read_to_end(&mut body_reader_bytes).unwrap(); + let request = req_builder + .header(CONTENT_TYPE, content_type.to_string()) + .body(hyper::body::Body::from(body_reader_bytes)); + + client.request(request.unwrap()).await + + } + }; + + match req_result { + Err(err) => { + if let client::Retry::After(d) = dlg.http_error(&err) { + sleep(d).await; + continue; + } + dlg.finished(false); + return Err(client::Error::HttpError(err)) + } + Ok(mut res) => { + if !res.status().is_success() { + let res_body_string = client::get_body_as_string(res.body_mut()).await; + let (parts, _) = res.into_parts(); + let body = hyper::Body::from(res_body_string.clone()); + let restored_response = hyper::Response::from_parts(parts, body); + + let server_response = json::from_str::(&res_body_string).ok(); + + if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { + sleep(d).await; + continue; + } + + dlg.finished(false); + + return match server_response { + Some(error_value) => Err(client::Error::BadRequest(error_value)), + None => Err(client::Error::Failure(restored_response)), + } + } + if protocol == client::UploadProtocol::Resumable { + let size = reader.seek(io::SeekFrom::End(0)).unwrap(); + reader.seek(io::SeekFrom::Start(0)).unwrap(); + if size > 104857600 { + return Err(client::Error::UploadSizeLimitExceeded(size, 104857600)) + } + let upload_result = { + let url_str = &res.headers().get("Location").expect("LOCATION header is part of protocol").to_str().unwrap(); + if upload_url_from_server { + dlg.store_upload_url(Some(url_str)); + } + + client::ResumableUploadHelper { + client: &self.hub.client, + delegate: dlg, + start_at: if upload_url_from_server { Some(0) } else { None }, + auth: &self.hub.auth, + user_agent: &self.hub._user_agent, + // TODO: Check this assumption + auth_header: format!("Bearer {}", token.ok_or_else(|| client::Error::MissingToken("resumable upload requires token".into()))?.as_str()), + url: url_str, + reader: &mut reader, + media_type: reader_mime_type.clone(), + content_length: size + }.upload().await + }; + match upload_result { + None => { + dlg.finished(false); + return Err(client::Error::Cancelled) + } + Some(Err(err)) => { + dlg.finished(false); + return Err(client::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(client::Error::Failure(res)) + } + } + } + } + let result_value = { + let res_body_string = client::get_body_as_string(res.body_mut()).await; + + match json::from_str(&res_body_string) { + Ok(decoded) => (res, decoded), + Err(err) => { + dlg.response_json_decode_error(&res_body_string, &err); + return Err(client::Error::JsonDecodeError(res_body_string, err)); + } + } + }; + + dlg.finished(true); + return Ok(result_value) + } + } + } + } + + /// 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(...)`. + /// + /// * *multipart*: yes + /// * *max size*: 104857600 + /// * *valid mime types*: 'text/xml', 'application/octet-stream' and '*/*' + pub async fn upload_resumable(self, resumeable_stream: RS, mime_type: mime::Mime) -> client::Result<(hyper::Response, Caption)> + where RS: client::ReadSeek { + self.doit(resumeable_stream, mime_type, client::UploadProtocol::Resumable).await + } + /// Upload media all at once. + /// If the upload fails for whichever reason, all progress is lost. + /// + /// * *multipart*: yes + /// * *max size*: 104857600 + /// * *valid mime types*: 'text/xml', 'application/octet-stream' and '*/*' + pub async fn upload(self, stream: RS, mime_type: mime::Mime) -> client::Result<(hyper::Response, Caption)> + where RS: client::ReadSeek { + self.doit(stream, mime_type, client::UploadProtocol::Simple).await + } + + /// + /// Sets the *request* property to the given value. + /// + /// Even though the property as already been set when instantiating this call, + /// we provide this method for API completeness. + /// + /// **Settable Parts** + /// + /// * *id* + /// * *snippet* + pub fn request(mut self, new_value: Caption) -> CaptionUpdateCall<'a, S> { + self._request = new_value; + self + } + /// The *part* parameter specifies a comma-separated list of one or more caption resource parts that the API response will include. The part names that you can include in the parameter value are id and snippet. + /// + /// Append the given value to the *part* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + /// + /// Even though the *parts* list is automatically derived from *Resource* passed in + /// during instantiation and indicates which values you are passing, the response would contain the very same parts. + /// This may not always be desirable, as you can obtain (newly generated) parts you cannot pass in, + /// like statistics that are generated server side. Therefore you should use this method to specify + /// the parts you provide in addition to the ones you want in the response. + /// + /// **Settable Parts** + /// + /// * *id* + /// * *snippet* + pub fn add_part(mut self, new_value: &str) -> CaptionUpdateCall<'a, S> { + self._part.push(new_value.to_string()); + self + } + /// Extra parameter to allow automatically syncing the uploaded caption/transcript with the audio. + /// + /// Sets the *sync* query property to the given value. + pub fn sync(mut self, new_value: bool) -> CaptionUpdateCall<'a, S> { + self._sync = Some(new_value); + self + } + /// *Note:* This parameter is intended exclusively for YouTube content partners. The *onBehalfOfContentOwner* parameter indicates that the request's authorization credentials identify a YouTube CMS user who is acting on behalf of the content owner specified in the parameter value. This parameter is intended for YouTube content partners that own and manage many different YouTube channels. It allows content owners to authenticate once and get access to all their video and channel data, without having to provide authentication credentials for each individual channel. The actual CMS account that the user authenticates with must be linked to the specified YouTube content owner. + /// + /// Sets the *on behalf of content owner* query property to the given value. + pub fn on_behalf_of_content_owner(mut self, new_value: &str) -> CaptionUpdateCall<'a, S> { + self._on_behalf_of_content_owner = Some(new_value.to_string()); + self + } + /// ID of the Google+ Page for the channel that the request is on behalf of. + /// + /// Sets the *on behalf of* query property to the given value. + pub fn on_behalf_of(mut self, new_value: &str) -> CaptionUpdateCall<'a, S> { + self._on_behalf_of = 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. + /// + /// ````text + /// It should be used to handle progress information, and to implement a certain level of resilience. + /// ```` + /// + /// Sets the *delegate* property to the given value. + pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> CaptionUpdateCall<'a, S> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not be used to set any of the known parameters + /// which have their own setter method. If done anyway, the request will fail. + /// + /// # Additional Parameters + /// + /// * *$.xgafv* (query-string) - V1 error format. + /// * *access_token* (query-string) - OAuth access token. + /// * *alt* (query-string) - Data format for response. + /// * *callback* (query-string) - JSONP + /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. + /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. + /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. + /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. + /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. + /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). + /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). + pub fn param(mut self, name: T, value: T) -> CaptionUpdateCall<'a, S> + where T: AsRef { + self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); + self + } + + /// Identifies the authorization scope for the method you are building. + /// + /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant + /// [`Scope::ForceSsl`]. + /// + /// The `scope` will be added to a set of scopes. This is important as one can maintain access + /// tokens for more than one scope. + /// + /// Usually there is more than one suitable scope to authorize an operation, some of which may + /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be + /// sufficient, a read-write scope will do as well. + pub fn add_scope(mut self, scope: St) -> CaptionUpdateCall<'a, S> + where St: AsRef { + self._scopes.insert(String::from(scope.as_ref())); + self + } + /// Identifies the authorization scope(s) for the method you are building. + /// + /// See [`Self::add_scope()`] for details. + pub fn add_scopes(mut self, scopes: I) -> CaptionUpdateCall<'a, S> + where I: IntoIterator, + St: AsRef { + self._scopes + .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); + self + } + + /// Removes all scopes, and no default scope will be used either. + /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] + /// for details). + pub fn clear_scopes(mut self) -> CaptionUpdateCall<'a, S> { + self._scopes.clear(); + self + } +} + + +/// Inserts a new resource into this collection. +/// +/// A builder for the *insert* method supported by a *channelBanner* resource. +/// It is not used directly, but through a [`ChannelBannerMethods`] instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate hyper_rustls; +/// # extern crate google_youtube3 as youtube3; +/// use youtube3::api::ChannelBannerResource; +/// use std::fs; +/// # async fn dox() { +/// # use std::default::Default; +/// # use youtube3::{YouTube, oauth2, hyper, hyper_rustls, chrono, FieldMask}; +/// +/// # let secret: oauth2::ApplicationSecret = Default::default(); +/// # let auth = oauth2::InstalledFlowAuthenticator::builder( +/// # secret, +/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, +/// # ).build().await.unwrap(); +/// # let mut hub = YouTube::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().unwrap().https_or_http().enable_http1().build()), auth); +/// // As the method needs a request, you would usually fill it with the desired information +/// // into the respective structure. Some of the parts shown here might not be applicable ! +/// // Values shown here are possibly random and not representative ! +/// let mut req = ChannelBannerResource::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.channel_banners().insert(req) +/// .on_behalf_of_content_owner_channel("duo") +/// .on_behalf_of_content_owner("vero") +/// .channel_id("vero") +/// .upload_resumable(fs::File::open("file.ext").unwrap(), "application/octet-stream".parse().unwrap()).await; +/// # } +/// ``` +pub struct ChannelBannerInsertCall<'a, S> + where S: 'a { + + pub(super) hub: &'a YouTube, + pub(super) _request: ChannelBannerResource, + pub(super) _on_behalf_of_content_owner_channel: Option, + pub(super) _on_behalf_of_content_owner: Option, + pub(super) _channel_id: Option, + pub(super) _delegate: Option<&'a mut dyn client::Delegate>, + pub(super) _additional_params: HashMap, + pub(super) _scopes: BTreeSet +} + +impl<'a, S> client::CallBuilder for ChannelBannerInsertCall<'a, S> {} + +impl<'a, S> ChannelBannerInsertCall<'a, S> +where + S: tower_service::Service + Clone + Send + Sync + 'static, + S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, + S::Future: Send + Unpin + 'static, + S::Error: Into>, +{ + + + /// Perform the operation you have build so far. + async fn doit(mut self, mut reader: RS, reader_mime_type: mime::Mime, protocol: client::UploadProtocol) -> client::Result<(hyper::Response, ChannelBannerResource)> + where RS: client::ReadSeek { + use std::io::{Read, Seek}; + use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; + use client::{ToParts, url::Params}; + use std::borrow::Cow; + + let mut dd = client::DefaultDelegate; + let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd); + dlg.begin(client::MethodInfo { id: "youtube.channelBanners.insert", + http_method: hyper::Method::POST }); + + for &field in ["alt", "onBehalfOfContentOwnerChannel", "onBehalfOfContentOwner", "channelId"].iter() { + if self._additional_params.contains_key(field) { + dlg.finished(false); + return Err(client::Error::FieldClash(field)); + } + } + + let mut params = Params::with_capacity(6 + self._additional_params.len()); + if let Some(value) = self._on_behalf_of_content_owner_channel.as_ref() { + params.push("onBehalfOfContentOwnerChannel", value); + } + if let Some(value) = self._on_behalf_of_content_owner.as_ref() { + params.push("onBehalfOfContentOwner", value); + } + if let Some(value) = self._channel_id.as_ref() { + params.push("channelId", value); + } + + params.extend(self._additional_params.iter()); + + params.push("alt", "json"); + let (mut url, upload_type) = + if protocol == client::UploadProtocol::Resumable { + (self.hub._root_url.clone() + "resumable/upload/youtube/v3/channelBanners/insert", "resumable") + } else if protocol == client::UploadProtocol::Simple { + (self.hub._root_url.clone() + "upload/youtube/v3/channelBanners/insert", "multipart") + } else { + unreachable!() + }; + params.push("uploadType", upload_type); + if self._scopes.is_empty() { + self._scopes.insert(Scope::Full.as_ref().to_string()); + } + + + let url = params.parse_with_url(&url); + + let mut json_mime_type = mime::APPLICATION_JSON; + let mut request_value_reader = + { + let mut value = json::value::to_value(&self._request).expect("serde to work"); + client::remove_json_null_values(&mut value); + let mut dst = io::Cursor::new(Vec::with_capacity(128)); + json::to_writer(&mut dst, &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.get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]).await { + Ok(token) => token, + Err(e) => { + match dlg.token(e) { + Ok(token) => token, + Err(e) => { + dlg.finished(false); + return Err(client::Error::MissingToken(e)); + } + } + } + }; + 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; + Ok(hyper::Response::builder() + .status(hyper::StatusCode::OK) + .header("Location", upload_url.as_ref().unwrap().clone()) + .body(hyper::body::Body::empty()) + .unwrap()) + } else { + let mut mp_reader: client::MultiPartReader = Default::default(); + let (mut body_reader, content_type) = match protocol { + client::UploadProtocol::Simple => { + mp_reader.reserve_exact(2); + let size = reader.seek(io::SeekFrom::End(0)).unwrap(); + reader.seek(io::SeekFrom::Start(0)).unwrap(); + if size > 6291456 { + return Err(client::Error::UploadSizeLimitExceeded(size, 6291456)) + } + mp_reader.add_part(&mut request_value_reader, request_size, json_mime_type.clone()) + .add_part(&mut reader, size, reader_mime_type.clone()); + (&mut mp_reader as &mut (dyn io::Read + Send), client::MultiPartReader::mime_type()) + }, + _ => (&mut request_value_reader as &mut (dyn io::Read + Send), json_mime_type.clone()), + }; + let client = &self.hub.client; + dlg.pre_request(); + let mut req_builder = hyper::Request::builder() + .method(hyper::Method::POST) + .uri(url.as_str()) + .header(USER_AGENT, self.hub._user_agent.clone()); + + if let Some(token) = token.as_ref() { + req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); + } + + upload_url_from_server = true; + if protocol == client::UploadProtocol::Resumable { + req_builder = req_builder.header("X-Upload-Content-Type", format!("{}", reader_mime_type)); + } + + let mut body_reader_bytes = vec![]; + body_reader.read_to_end(&mut body_reader_bytes).unwrap(); + let request = req_builder + .header(CONTENT_TYPE, content_type.to_string()) + .body(hyper::body::Body::from(body_reader_bytes)); + + client.request(request.unwrap()).await + + } + }; + + match req_result { + Err(err) => { + if let client::Retry::After(d) = dlg.http_error(&err) { + sleep(d).await; + continue; + } + dlg.finished(false); + return Err(client::Error::HttpError(err)) + } + Ok(mut res) => { + if !res.status().is_success() { + let res_body_string = client::get_body_as_string(res.body_mut()).await; + let (parts, _) = res.into_parts(); + let body = hyper::Body::from(res_body_string.clone()); + let restored_response = hyper::Response::from_parts(parts, body); + + let server_response = json::from_str::(&res_body_string).ok(); + + if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { + sleep(d).await; + continue; + } + + dlg.finished(false); + + return match server_response { + Some(error_value) => Err(client::Error::BadRequest(error_value)), + None => Err(client::Error::Failure(restored_response)), + } + } + if protocol == client::UploadProtocol::Resumable { + let size = reader.seek(io::SeekFrom::End(0)).unwrap(); + reader.seek(io::SeekFrom::Start(0)).unwrap(); + if size > 6291456 { + return Err(client::Error::UploadSizeLimitExceeded(size, 6291456)) + } + let upload_result = { + let url_str = &res.headers().get("Location").expect("LOCATION header is part of protocol").to_str().unwrap(); + if upload_url_from_server { + dlg.store_upload_url(Some(url_str)); + } + + client::ResumableUploadHelper { + client: &self.hub.client, + delegate: dlg, + start_at: if upload_url_from_server { Some(0) } else { None }, + auth: &self.hub.auth, + user_agent: &self.hub._user_agent, + // TODO: Check this assumption + auth_header: format!("Bearer {}", token.ok_or_else(|| client::Error::MissingToken("resumable upload requires token".into()))?.as_str()), + url: url_str, + reader: &mut reader, + media_type: reader_mime_type.clone(), + content_length: size + }.upload().await + }; + match upload_result { + None => { + dlg.finished(false); + return Err(client::Error::Cancelled) + } + Some(Err(err)) => { + dlg.finished(false); + return Err(client::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(client::Error::Failure(res)) + } + } + } + } + let result_value = { + let res_body_string = client::get_body_as_string(res.body_mut()).await; + + match json::from_str(&res_body_string) { + Ok(decoded) => (res, decoded), + Err(err) => { + dlg.response_json_decode_error(&res_body_string, &err); + return Err(client::Error::JsonDecodeError(res_body_string, err)); + } + } + }; + + dlg.finished(true); + return Ok(result_value) + } + } + } + } + + /// 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(...)`. + /// + /// * *multipart*: yes + /// * *max size*: 6291456 + /// * *valid mime types*: 'image/jpeg', 'image/png' and 'application/octet-stream' + pub async fn upload_resumable(self, resumeable_stream: RS, mime_type: mime::Mime) -> client::Result<(hyper::Response, ChannelBannerResource)> + where RS: client::ReadSeek { + self.doit(resumeable_stream, mime_type, client::UploadProtocol::Resumable).await + } + /// Upload media all at once. + /// If the upload fails for whichever reason, all progress is lost. + /// + /// * *multipart*: yes + /// * *max size*: 6291456 + /// * *valid mime types*: 'image/jpeg', 'image/png' and 'application/octet-stream' + pub async fn upload(self, stream: RS, mime_type: mime::Mime) -> client::Result<(hyper::Response, ChannelBannerResource)> + where RS: client::ReadSeek { + self.doit(stream, mime_type, client::UploadProtocol::Simple).await + } + + /// + /// Sets the *request* property to the given value. + /// + /// Even though the property as already been set when instantiating this call, + /// we provide this method for API completeness. + pub fn request(mut self, new_value: ChannelBannerResource) -> ChannelBannerInsertCall<'a, S> { + self._request = new_value; + self + } + /// This parameter can only be used in a properly authorized request. *Note:* This parameter is intended exclusively for YouTube content partners. The *onBehalfOfContentOwnerChannel* parameter specifies the YouTube channel ID of the channel to which a video is being added. This parameter is required when a request specifies a value for the onBehalfOfContentOwner parameter, and it can only be used in conjunction with that parameter. In addition, the request must be authorized using a CMS account that is linked to the content owner that the onBehalfOfContentOwner parameter specifies. Finally, the channel that the onBehalfOfContentOwnerChannel parameter value specifies must be linked to the content owner that the onBehalfOfContentOwner parameter specifies. This parameter is intended for YouTube content partners that own and manage many different YouTube channels. It allows content owners to authenticate once and perform actions on behalf of the channel specified in the parameter value, without having to provide authentication credentials for each separate channel. + /// + /// Sets the *on behalf of content owner channel* query property to the given value. + pub fn on_behalf_of_content_owner_channel(mut self, new_value: &str) -> ChannelBannerInsertCall<'a, S> { + self._on_behalf_of_content_owner_channel = Some(new_value.to_string()); + self + } + /// *Note:* This parameter is intended exclusively for YouTube content partners. The *onBehalfOfContentOwner* parameter indicates that the request's authorization credentials identify a YouTube CMS user who is acting on behalf of the content owner specified in the parameter value. This parameter is intended for YouTube content partners that own and manage many different YouTube channels. It allows content owners to authenticate once and get access to all their video and channel data, without having to provide authentication credentials for each individual channel. The actual CMS account that the user authenticates with must be linked to the specified YouTube content owner. + /// + /// Sets the *on behalf of content owner* query property to the given value. + pub fn on_behalf_of_content_owner(mut self, new_value: &str) -> ChannelBannerInsertCall<'a, S> { + self._on_behalf_of_content_owner = Some(new_value.to_string()); + self + } + /// Unused, channel_id is currently derived from the security context of the requestor. + /// + /// Sets the *channel id* query property to the given value. + pub fn channel_id(mut self, new_value: &str) -> ChannelBannerInsertCall<'a, S> { + self._channel_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. + /// + /// ````text + /// It should be used to handle progress information, and to implement a certain level of resilience. + /// ```` + /// + /// Sets the *delegate* property to the given value. + pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> ChannelBannerInsertCall<'a, S> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not be used to set any of the known parameters + /// which have their own setter method. If done anyway, the request will fail. + /// + /// # Additional Parameters + /// + /// * *$.xgafv* (query-string) - V1 error format. + /// * *access_token* (query-string) - OAuth access token. + /// * *alt* (query-string) - Data format for response. + /// * *callback* (query-string) - JSONP + /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. + /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. + /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. + /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. + /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. + /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). + /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). + pub fn param(mut self, name: T, value: T) -> ChannelBannerInsertCall<'a, S> + where T: AsRef { + self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); + self + } + + /// Identifies the authorization scope for the method you are building. + /// + /// Use this method to actively specify which scope should be used, instead of 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: St) -> ChannelBannerInsertCall<'a, S> + where St: AsRef { + self._scopes.insert(String::from(scope.as_ref())); + self + } + /// Identifies the authorization scope(s) for the method you are building. + /// + /// See [`Self::add_scope()`] for details. + pub fn add_scopes(mut self, scopes: I) -> ChannelBannerInsertCall<'a, S> + where I: IntoIterator, + St: AsRef { + self._scopes + .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); + self + } + + /// Removes all scopes, and no default scope will be used either. + /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] + /// for details). + pub fn clear_scopes(mut self) -> ChannelBannerInsertCall<'a, S> { + self._scopes.clear(); + self + } +} + + +/// Deletes a resource. +/// +/// A builder for the *delete* method supported by a *channelSection* resource. +/// It is not used directly, but through a [`ChannelSectionMethods`] instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate hyper_rustls; +/// # extern crate google_youtube3 as youtube3; +/// # async fn dox() { +/// # use std::default::Default; +/// # use youtube3::{YouTube, oauth2, hyper, hyper_rustls, chrono, FieldMask}; +/// +/// # let secret: oauth2::ApplicationSecret = Default::default(); +/// # let auth = oauth2::InstalledFlowAuthenticator::builder( +/// # secret, +/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, +/// # ).build().await.unwrap(); +/// # let mut hub = YouTube::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().unwrap().https_or_http().enable_http1().build()), auth); +/// // You can configure optional parameters by calling the respective setters at will, and +/// // execute the final call using `doit()`. +/// // Values shown here are possibly random and not representative ! +/// let result = hub.channel_sections().delete("id") +/// .on_behalf_of_content_owner("Stet") +/// .doit().await; +/// # } +/// ``` +pub struct ChannelSectionDeleteCall<'a, S> + where S: 'a { + + pub(super) hub: &'a YouTube, + pub(super) _id: String, + pub(super) _on_behalf_of_content_owner: Option, + pub(super) _delegate: Option<&'a mut dyn client::Delegate>, + pub(super) _additional_params: HashMap, + pub(super) _scopes: BTreeSet +} + +impl<'a, S> client::CallBuilder for ChannelSectionDeleteCall<'a, S> {} + +impl<'a, S> ChannelSectionDeleteCall<'a, S> +where + S: tower_service::Service + Clone + Send + Sync + 'static, + S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, + S::Future: Send + Unpin + 'static, + S::Error: Into>, +{ + + + /// Perform the operation you have build so far. + pub async fn doit(mut self) -> client::Result> { + use std::io::{Read, Seek}; + use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; + use client::{ToParts, url::Params}; + use std::borrow::Cow; + + let mut dd = client::DefaultDelegate; + let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd); + dlg.begin(client::MethodInfo { id: "youtube.channelSections.delete", + http_method: hyper::Method::DELETE }); + + for &field in ["id", "onBehalfOfContentOwner"].iter() { + if self._additional_params.contains_key(field) { + dlg.finished(false); + return Err(client::Error::FieldClash(field)); + } + } + + let mut params = Params::with_capacity(3 + self._additional_params.len()); + params.push("id", &self._id); + if let Some(value) = self._on_behalf_of_content_owner.as_ref() { + params.push("onBehalfOfContentOwner", value); + } + + params.extend(self._additional_params.iter()); + + let mut url = self.hub._base_url.clone() + "youtube/v3/channelSections"; + if self._scopes.is_empty() { + self._scopes.insert(Scope::Full.as_ref().to_string()); + } + + + let url = params.parse_with_url(&url); + + + + loop { + let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]).await { + Ok(token) => token, + Err(e) => { + match dlg.token(e) { + Ok(token) => token, + Err(e) => { + dlg.finished(false); + return Err(client::Error::MissingToken(e)); + } + } + } + }; + let mut req_result = { + let client = &self.hub.client; + dlg.pre_request(); + let mut req_builder = hyper::Request::builder() + .method(hyper::Method::DELETE) + .uri(url.as_str()) + .header(USER_AGENT, self.hub._user_agent.clone()); + + if let Some(token) = token.as_ref() { + req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); + } + + + let request = req_builder + .header(CONTENT_LENGTH, 0_u64) + .body(hyper::body::Body::empty()); + + client.request(request.unwrap()).await + + }; + + match req_result { + Err(err) => { + if let client::Retry::After(d) = dlg.http_error(&err) { + sleep(d).await; + continue; + } + dlg.finished(false); + return Err(client::Error::HttpError(err)) + } + Ok(mut res) => { + if !res.status().is_success() { + let res_body_string = client::get_body_as_string(res.body_mut()).await; + let (parts, _) = res.into_parts(); + let body = hyper::Body::from(res_body_string.clone()); + let restored_response = hyper::Response::from_parts(parts, body); + + let server_response = json::from_str::(&res_body_string).ok(); + + if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { + sleep(d).await; + continue; + } + + dlg.finished(false); + + return match server_response { + Some(error_value) => Err(client::Error::BadRequest(error_value)), + None => Err(client::Error::Failure(restored_response)), + } + } + let result_value = res; + + dlg.finished(true); + return Ok(result_value) + } + } + } + } + + + /// + /// 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) -> ChannelSectionDeleteCall<'a, S> { + self._id = new_value.to_string(); + self + } + /// *Note:* This parameter is intended exclusively for YouTube content partners. The *onBehalfOfContentOwner* parameter indicates that the request's authorization credentials identify a YouTube CMS user who is acting on behalf of the content owner specified in the parameter value. This parameter is intended for YouTube content partners that own and manage many different YouTube channels. It allows content owners to authenticate once and get access to all their video and channel data, without having to provide authentication credentials for each individual channel. The CMS account that the user authenticates with must be linked to the specified YouTube content owner. + /// + /// Sets the *on behalf of content owner* query property to the given value. + pub fn on_behalf_of_content_owner(mut self, new_value: &str) -> ChannelSectionDeleteCall<'a, S> { + self._on_behalf_of_content_owner = 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. + /// + /// ````text + /// It should be used to handle progress information, and to implement a certain level of resilience. + /// ```` + /// + /// Sets the *delegate* property to the given value. + pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> ChannelSectionDeleteCall<'a, S> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not be used to set any of the known parameters + /// which have their own setter method. If done anyway, the request will fail. + /// + /// # Additional Parameters + /// + /// * *$.xgafv* (query-string) - V1 error format. + /// * *access_token* (query-string) - OAuth access token. + /// * *alt* (query-string) - Data format for response. + /// * *callback* (query-string) - JSONP + /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. + /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. + /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. + /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. + /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. + /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). + /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). + pub fn param(mut self, name: T, value: T) -> ChannelSectionDeleteCall<'a, S> + where T: AsRef { + self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); + self + } + + /// Identifies the authorization scope for the method you are building. + /// + /// Use this method to actively specify which scope should be used, instead of 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: St) -> ChannelSectionDeleteCall<'a, S> + where St: AsRef { + self._scopes.insert(String::from(scope.as_ref())); + self + } + /// Identifies the authorization scope(s) for the method you are building. + /// + /// See [`Self::add_scope()`] for details. + pub fn add_scopes(mut self, scopes: I) -> ChannelSectionDeleteCall<'a, S> + where I: IntoIterator, + St: AsRef { + self._scopes + .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); + self + } + + /// Removes all scopes, and no default scope will be used either. + /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] + /// for details). + pub fn clear_scopes(mut self) -> ChannelSectionDeleteCall<'a, S> { + self._scopes.clear(); + self + } +} + + +/// Inserts a new resource into this collection. +/// +/// A builder for the *insert* method supported by a *channelSection* resource. +/// It is not used directly, but through a [`ChannelSectionMethods`] instance. +/// +/// **Settable Parts** +/// +/// * *snippet* +/// * *contentDetails* +/// +/// # Scopes +/// +/// You will need authorization for at least one of the following scopes to make a valid call, possibly depending on *parts*: +/// +/// * *https://www.googleapis.com/auth/youtube* +/// * *https://www.googleapis.com/auth/youtube.force-ssl* +/// * *https://www.googleapis.com/auth/youtubepartner* +/// +/// The default scope will be `Scope::Full`. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate hyper_rustls; +/// # extern crate google_youtube3 as youtube3; +/// use youtube3::api::ChannelSection; +/// # async fn dox() { +/// # use std::default::Default; +/// # use youtube3::{YouTube, oauth2, hyper, hyper_rustls, chrono, FieldMask}; +/// +/// # let secret: oauth2::ApplicationSecret = Default::default(); +/// # let auth = oauth2::InstalledFlowAuthenticator::builder( +/// # secret, +/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, +/// # ).build().await.unwrap(); +/// # let mut hub = YouTube::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().unwrap().https_or_http().enable_http1().build()), auth); +/// // As the method needs a request, you would usually fill it with the desired information +/// // into the respective structure. Some of the parts shown here might not be applicable ! +/// // Values shown here are possibly random and not representative ! +/// let mut req = ChannelSection::default(); +/// req.content_details = Default::default(); // is ChannelSectionContentDetails +/// req.snippet = Default::default(); // is ChannelSectionSnippet +/// +/// // You can configure optional parameters by calling the respective setters at will, and +/// // execute the final call using `doit()`. +/// // Values shown here are possibly random and not representative ! +/// let result = hub.channel_sections().insert(req) +/// .on_behalf_of_content_owner_channel("vero") +/// .on_behalf_of_content_owner("elitr") +/// .doit().await; +/// # } +/// ``` +pub struct ChannelSectionInsertCall<'a, S> + where S: 'a { + + pub(super) hub: &'a YouTube, + pub(super) _request: ChannelSection, + pub(super) _part: Vec, + pub(super) _on_behalf_of_content_owner_channel: Option, + pub(super) _on_behalf_of_content_owner: Option, + pub(super) _delegate: Option<&'a mut dyn client::Delegate>, + pub(super) _additional_params: HashMap, + pub(super) _scopes: BTreeSet +} + +impl<'a, S> client::CallBuilder for ChannelSectionInsertCall<'a, S> {} + +impl<'a, S> ChannelSectionInsertCall<'a, S> +where + S: tower_service::Service + Clone + Send + Sync + 'static, + S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, + S::Future: Send + Unpin + 'static, + S::Error: Into>, +{ + + + /// Perform the operation you have build so far. + pub async fn doit(mut self) -> client::Result<(hyper::Response, ChannelSection)> { + use std::io::{Read, Seek}; + use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; + use client::{ToParts, url::Params}; + use std::borrow::Cow; + + let mut dd = client::DefaultDelegate; + let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd); + dlg.begin(client::MethodInfo { id: "youtube.channelSections.insert", + http_method: hyper::Method::POST }); + + for &field in ["alt", "part", "onBehalfOfContentOwnerChannel", "onBehalfOfContentOwner"].iter() { + if self._additional_params.contains_key(field) { + dlg.finished(false); + return Err(client::Error::FieldClash(field)); + } + } + + let mut params = Params::with_capacity(6 + self._additional_params.len()); + if self._part.is_empty() { + self._part.push(self._request.to_parts()); + } + if self._part.len() > 0 { + for f in self._part.iter() { + params.push("part", f); + } + } + if let Some(value) = self._on_behalf_of_content_owner_channel.as_ref() { + params.push("onBehalfOfContentOwnerChannel", value); + } + if let Some(value) = self._on_behalf_of_content_owner.as_ref() { + params.push("onBehalfOfContentOwner", value); + } + + params.extend(self._additional_params.iter()); + + params.push("alt", "json"); + let mut url = self.hub._base_url.clone() + "youtube/v3/channelSections"; + if self._scopes.is_empty() { + self._scopes.insert(Scope::Full.as_ref().to_string()); + } + + + let url = params.parse_with_url(&url); + + let mut json_mime_type = mime::APPLICATION_JSON; + let mut request_value_reader = + { + let mut value = json::value::to_value(&self._request).expect("serde to work"); + client::remove_json_null_values(&mut value); + let mut dst = io::Cursor::new(Vec::with_capacity(128)); + json::to_writer(&mut dst, &value).unwrap(); + dst + }; + let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); + request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); + + + loop { + let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]).await { + Ok(token) => token, + Err(e) => { + match dlg.token(e) { + Ok(token) => token, + Err(e) => { + dlg.finished(false); + return Err(client::Error::MissingToken(e)); + } + } + } + }; + request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); + let mut req_result = { + let client = &self.hub.client; + dlg.pre_request(); + let mut req_builder = hyper::Request::builder() + .method(hyper::Method::POST) + .uri(url.as_str()) + .header(USER_AGENT, self.hub._user_agent.clone()); + + if let Some(token) = token.as_ref() { + req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); + } + + + let request = req_builder + .header(CONTENT_TYPE, json_mime_type.to_string()) + .header(CONTENT_LENGTH, request_size as u64) + .body(hyper::body::Body::from(request_value_reader.get_ref().clone())); + + client.request(request.unwrap()).await + + }; + + match req_result { + Err(err) => { + if let client::Retry::After(d) = dlg.http_error(&err) { + sleep(d).await; + continue; + } + dlg.finished(false); + return Err(client::Error::HttpError(err)) + } + Ok(mut res) => { + if !res.status().is_success() { + let res_body_string = client::get_body_as_string(res.body_mut()).await; + let (parts, _) = res.into_parts(); + let body = hyper::Body::from(res_body_string.clone()); + let restored_response = hyper::Response::from_parts(parts, body); + + let server_response = json::from_str::(&res_body_string).ok(); + + if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { + sleep(d).await; + continue; + } + + dlg.finished(false); + + return match server_response { + Some(error_value) => Err(client::Error::BadRequest(error_value)), + None => Err(client::Error::Failure(restored_response)), + } + } + let result_value = { + let res_body_string = client::get_body_as_string(res.body_mut()).await; + + match json::from_str(&res_body_string) { + Ok(decoded) => (res, decoded), + Err(err) => { + dlg.response_json_decode_error(&res_body_string, &err); + return Err(client::Error::JsonDecodeError(res_body_string, err)); + } + } + }; + + dlg.finished(true); + return Ok(result_value) + } + } + } + } + + + /// + /// Sets the *request* property to the given value. + /// + /// Even though the property as already been set when instantiating this call, + /// we provide this method for API completeness. + /// + /// **Settable Parts** + /// + /// * *snippet* + /// * *contentDetails* + pub fn request(mut self, new_value: ChannelSection) -> ChannelSectionInsertCall<'a, S> { + self._request = new_value; + self + } + /// The *part* parameter serves two purposes in this operation. It identifies the properties that the write operation will set as well as the properties that the API response will include. The part names that you can include in the parameter value are snippet and contentDetails. + /// + /// Append the given value to the *part* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + /// + /// Even though the *parts* list is automatically derived from *Resource* passed in + /// during instantiation and indicates which values you are passing, the response would contain the very same parts. + /// This may not always be desirable, as you can obtain (newly generated) parts you cannot pass in, + /// like statistics that are generated server side. Therefore you should use this method to specify + /// the parts you provide in addition to the ones you want in the response. + /// + /// **Settable Parts** + /// + /// * *snippet* + /// * *contentDetails* + pub fn add_part(mut self, new_value: &str) -> ChannelSectionInsertCall<'a, S> { + self._part.push(new_value.to_string()); + self + } + /// This parameter can only be used in a properly authorized request. *Note:* This parameter is intended exclusively for YouTube content partners. The *onBehalfOfContentOwnerChannel* parameter specifies the YouTube channel ID of the channel to which a video is being added. This parameter is required when a request specifies a value for the onBehalfOfContentOwner parameter, and it can only be used in conjunction with that parameter. In addition, the request must be authorized using a CMS account that is linked to the content owner that the onBehalfOfContentOwner parameter specifies. Finally, the channel that the onBehalfOfContentOwnerChannel parameter value specifies must be linked to the content owner that the onBehalfOfContentOwner parameter specifies. This parameter is intended for YouTube content partners that own and manage many different YouTube channels. It allows content owners to authenticate once and perform actions on behalf of the channel specified in the parameter value, without having to provide authentication credentials for each separate channel. + /// + /// Sets the *on behalf of content owner channel* query property to the given value. + pub fn on_behalf_of_content_owner_channel(mut self, new_value: &str) -> ChannelSectionInsertCall<'a, S> { + self._on_behalf_of_content_owner_channel = Some(new_value.to_string()); + self + } + /// *Note:* This parameter is intended exclusively for YouTube content partners. The *onBehalfOfContentOwner* parameter indicates that the request's authorization credentials identify a YouTube CMS user who is acting on behalf of the content owner specified in the parameter value. This parameter is intended for YouTube content partners that own and manage many different YouTube channels. It allows content owners to authenticate once and get access to all their video and channel data, without having to provide authentication credentials for each individual channel. The CMS account that the user authenticates with must be linked to the specified YouTube content owner. + /// + /// Sets the *on behalf of content owner* query property to the given value. + pub fn on_behalf_of_content_owner(mut self, new_value: &str) -> ChannelSectionInsertCall<'a, S> { + self._on_behalf_of_content_owner = 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. + /// + /// ````text + /// It should be used to handle progress information, and to implement a certain level of resilience. + /// ```` + /// + /// Sets the *delegate* property to the given value. + pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> ChannelSectionInsertCall<'a, S> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not be used to set any of the known parameters + /// which have their own setter method. If done anyway, the request will fail. + /// + /// # Additional Parameters + /// + /// * *$.xgafv* (query-string) - V1 error format. + /// * *access_token* (query-string) - OAuth access token. + /// * *alt* (query-string) - Data format for response. + /// * *callback* (query-string) - JSONP + /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. + /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. + /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. + /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. + /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. + /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). + /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). + pub fn param(mut self, name: T, value: T) -> ChannelSectionInsertCall<'a, S> + where T: AsRef { + self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); + self + } + + /// Identifies the authorization scope for the method you are building. + /// + /// Use this method to actively specify which scope should be used, instead of 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: St) -> ChannelSectionInsertCall<'a, S> + where St: AsRef { + self._scopes.insert(String::from(scope.as_ref())); + self + } + /// Identifies the authorization scope(s) for the method you are building. + /// + /// See [`Self::add_scope()`] for details. + pub fn add_scopes(mut self, scopes: I) -> ChannelSectionInsertCall<'a, S> + where I: IntoIterator, + St: AsRef { + self._scopes + .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); + self + } + + /// Removes all scopes, and no default scope will be used either. + /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] + /// for details). + pub fn clear_scopes(mut self) -> ChannelSectionInsertCall<'a, S> { + self._scopes.clear(); + self + } +} + + +/// Retrieves a list of resources, possibly filtered. +/// +/// A builder for the *list* method supported by a *channelSection* resource. +/// It is not used directly, but through a [`ChannelSectionMethods`] instance. +/// +/// **Settable Parts** +/// +/// * *id* +/// * *snippet* +/// * *contentDetails* +/// +/// # Scopes +/// +/// You will need authorization for at least one of the following scopes to make a valid call, possibly depending on *parts*: +/// +/// * *https://www.googleapis.com/auth/youtube* +/// * *https://www.googleapis.com/auth/youtube.force-ssl* +/// * *https://www.googleapis.com/auth/youtube.readonly* +/// * *https://www.googleapis.com/auth/youtubepartner* +/// +/// The default scope will be `Scope::Readonly`. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate hyper_rustls; +/// # extern crate google_youtube3 as youtube3; +/// # async fn dox() { +/// # use std::default::Default; +/// # use youtube3::{YouTube, oauth2, hyper, hyper_rustls, chrono, FieldMask}; +/// +/// # let secret: oauth2::ApplicationSecret = Default::default(); +/// # let auth = oauth2::InstalledFlowAuthenticator::builder( +/// # secret, +/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, +/// # ).build().await.unwrap(); +/// # let mut hub = YouTube::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().unwrap().https_or_http().enable_http1().build()), auth); +/// // You can configure optional parameters by calling the respective setters at will, and +/// // execute the final call using `doit()`. +/// // Values shown here are possibly random and not representative ! +/// let result = hub.channel_sections().list(&vec!["Lorem".into()]) +/// .on_behalf_of_content_owner("diam") +/// .mine(true) +/// .add_id("ipsum") +/// .hl("accusam") +/// .channel_id("takimata") +/// .doit().await; +/// # } +/// ``` +pub struct ChannelSectionListCall<'a, S> + where S: 'a { + + pub(super) hub: &'a YouTube, + pub(super) _part: Vec, + pub(super) _on_behalf_of_content_owner: Option, + pub(super) _mine: Option, + pub(super) _id: Vec, + pub(super) _hl: Option, + pub(super) _channel_id: Option, + pub(super) _delegate: Option<&'a mut dyn client::Delegate>, + pub(super) _additional_params: HashMap, + pub(super) _scopes: BTreeSet +} + +impl<'a, S> client::CallBuilder for ChannelSectionListCall<'a, S> {} + +impl<'a, S> ChannelSectionListCall<'a, S> +where + S: tower_service::Service + Clone + Send + Sync + 'static, + S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, + S::Future: Send + Unpin + 'static, + S::Error: Into>, +{ + + + /// Perform the operation you have build so far. + pub async fn doit(mut self) -> client::Result<(hyper::Response, ChannelSectionListResponse)> { + use std::io::{Read, Seek}; + use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; + use client::{ToParts, url::Params}; + use std::borrow::Cow; + + let mut dd = client::DefaultDelegate; + let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd); + dlg.begin(client::MethodInfo { id: "youtube.channelSections.list", + http_method: hyper::Method::GET }); + + for &field in ["alt", "part", "onBehalfOfContentOwner", "mine", "id", "hl", "channelId"].iter() { + if self._additional_params.contains_key(field) { + dlg.finished(false); + return Err(client::Error::FieldClash(field)); + } + } + + let mut params = Params::with_capacity(8 + self._additional_params.len()); + if self._part.len() > 0 { + for f in self._part.iter() { + params.push("part", f); + } + } + if let Some(value) = self._on_behalf_of_content_owner.as_ref() { + params.push("onBehalfOfContentOwner", value); + } + if let Some(value) = self._mine.as_ref() { + params.push("mine", value.to_string()); + } + if self._id.len() > 0 { + for f in self._id.iter() { + params.push("id", f); + } + } + if let Some(value) = self._hl.as_ref() { + params.push("hl", value); + } + if let Some(value) = self._channel_id.as_ref() { + params.push("channelId", value); + } + + params.extend(self._additional_params.iter()); + + params.push("alt", "json"); + let mut url = self.hub._base_url.clone() + "youtube/v3/channelSections"; + if self._scopes.is_empty() { + self._scopes.insert(Scope::Readonly.as_ref().to_string()); + } + + + let url = params.parse_with_url(&url); + + + + loop { + let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]).await { + Ok(token) => token, + Err(e) => { + match dlg.token(e) { + Ok(token) => token, + Err(e) => { + dlg.finished(false); + return Err(client::Error::MissingToken(e)); + } + } + } + }; + let mut req_result = { + let client = &self.hub.client; + dlg.pre_request(); + let mut req_builder = hyper::Request::builder() + .method(hyper::Method::GET) + .uri(url.as_str()) + .header(USER_AGENT, self.hub._user_agent.clone()); + + if let Some(token) = token.as_ref() { + req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); + } + + + let request = req_builder + .header(CONTENT_LENGTH, 0_u64) + .body(hyper::body::Body::empty()); + + client.request(request.unwrap()).await + + }; + + match req_result { + Err(err) => { + if let client::Retry::After(d) = dlg.http_error(&err) { + sleep(d).await; + continue; + } + dlg.finished(false); + return Err(client::Error::HttpError(err)) + } + Ok(mut res) => { + if !res.status().is_success() { + let res_body_string = client::get_body_as_string(res.body_mut()).await; + let (parts, _) = res.into_parts(); + let body = hyper::Body::from(res_body_string.clone()); + let restored_response = hyper::Response::from_parts(parts, body); + + let server_response = json::from_str::(&res_body_string).ok(); + + if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { + sleep(d).await; + continue; + } + + dlg.finished(false); + + return match server_response { + Some(error_value) => Err(client::Error::BadRequest(error_value)), + None => Err(client::Error::Failure(restored_response)), + } + } + let result_value = { + let res_body_string = client::get_body_as_string(res.body_mut()).await; + + match json::from_str(&res_body_string) { + Ok(decoded) => (res, decoded), + Err(err) => { + dlg.response_json_decode_error(&res_body_string, &err); + return Err(client::Error::JsonDecodeError(res_body_string, err)); + } + } + }; + + dlg.finished(true); + return Ok(result_value) + } + } + } + } + + + /// The *part* parameter specifies a comma-separated list of one or more channelSection resource properties that the API response will include. The part names that you can include in the parameter value are id, snippet, and contentDetails. If the parameter identifies a property that contains child properties, the child properties will be included in the response. For example, in a channelSection resource, the snippet property contains other properties, such as a display title for the channelSection. If you set *part=snippet*, the API response will also contain all of those nested properties. + /// + /// Append the given value to the *part* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + /// + /// Even though the property as already been set when instantiating this call, + /// we provide this method for API completeness. + /// + /// **Settable Parts** + /// + /// * *id* + /// * *snippet* + /// * *contentDetails* + pub fn add_part(mut self, new_value: &str) -> ChannelSectionListCall<'a, S> { + self._part.push(new_value.to_string()); + self + } + /// *Note:* This parameter is intended exclusively for YouTube content partners. The *onBehalfOfContentOwner* parameter indicates that the request's authorization credentials identify a YouTube CMS user who is acting on behalf of the content owner specified in the parameter value. This parameter is intended for YouTube content partners that own and manage many different YouTube channels. It allows content owners to authenticate once and get access to all their video and channel data, without having to provide authentication credentials for each individual channel. The CMS account that the user authenticates with must be linked to the specified YouTube content owner. + /// + /// Sets the *on behalf of content owner* query property to the given value. + pub fn on_behalf_of_content_owner(mut self, new_value: &str) -> ChannelSectionListCall<'a, S> { + self._on_behalf_of_content_owner = Some(new_value.to_string()); + self + } + /// Return the ChannelSections owned by the authenticated user. + /// + /// Sets the *mine* query property to the given value. + pub fn mine(mut self, new_value: bool) -> ChannelSectionListCall<'a, S> { + self._mine = Some(new_value); + self + } + /// Return the ChannelSections with the given IDs for Stubby or Apiary. + /// + /// Append the given value to the *id* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + pub fn add_id(mut self, new_value: &str) -> ChannelSectionListCall<'a, S> { + self._id.push(new_value.to_string()); + self + } + /// Return content in specified language + /// + /// Sets the *hl* query property to the given value. + pub fn hl(mut self, new_value: &str) -> ChannelSectionListCall<'a, S> { + self._hl = Some(new_value.to_string()); + self + } + /// Return the ChannelSections owned by the specified channel ID. + /// + /// Sets the *channel id* query property to the given value. + pub fn channel_id(mut self, new_value: &str) -> ChannelSectionListCall<'a, S> { + self._channel_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. + /// + /// ````text + /// It should be used to handle progress information, and to implement a certain level of resilience. + /// ```` + /// + /// Sets the *delegate* property to the given value. + pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> ChannelSectionListCall<'a, S> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not be used to set any of the known parameters + /// which have their own setter method. If done anyway, the request will fail. + /// + /// # Additional Parameters + /// + /// * *$.xgafv* (query-string) - V1 error format. + /// * *access_token* (query-string) - OAuth access token. + /// * *alt* (query-string) - Data format for response. + /// * *callback* (query-string) - JSONP + /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. + /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. + /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. + /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. + /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. + /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). + /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). + pub fn param(mut self, name: T, value: T) -> ChannelSectionListCall<'a, S> + where T: AsRef { + self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); + self + } + + /// Identifies the authorization scope for the method you are building. + /// + /// Use this method to actively specify which scope should be used, instead of 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: St) -> ChannelSectionListCall<'a, S> + where St: AsRef { + self._scopes.insert(String::from(scope.as_ref())); + self + } + /// Identifies the authorization scope(s) for the method you are building. + /// + /// See [`Self::add_scope()`] for details. + pub fn add_scopes(mut self, scopes: I) -> ChannelSectionListCall<'a, S> + where I: IntoIterator, + St: AsRef { + self._scopes + .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); + self + } + + /// Removes all scopes, and no default scope will be used either. + /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] + /// for details). + pub fn clear_scopes(mut self) -> ChannelSectionListCall<'a, S> { + self._scopes.clear(); + self + } +} + + +/// Updates an existing resource. +/// +/// A builder for the *update* method supported by a *channelSection* resource. +/// It is not used directly, but through a [`ChannelSectionMethods`] instance. +/// +/// **Settable Parts** +/// +/// * *snippet* +/// * *contentDetails* +/// +/// # Scopes +/// +/// You will need authorization for at least one of the following scopes to make a valid call, possibly depending on *parts*: +/// +/// * *https://www.googleapis.com/auth/youtube* +/// * *https://www.googleapis.com/auth/youtube.force-ssl* +/// * *https://www.googleapis.com/auth/youtubepartner* +/// +/// The default scope will be `Scope::Full`. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate hyper_rustls; +/// # extern crate google_youtube3 as youtube3; +/// use youtube3::api::ChannelSection; +/// # async fn dox() { +/// # use std::default::Default; +/// # use youtube3::{YouTube, oauth2, hyper, hyper_rustls, chrono, FieldMask}; +/// +/// # let secret: oauth2::ApplicationSecret = Default::default(); +/// # let auth = oauth2::InstalledFlowAuthenticator::builder( +/// # secret, +/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, +/// # ).build().await.unwrap(); +/// # let mut hub = YouTube::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().unwrap().https_or_http().enable_http1().build()), auth); +/// // As the method needs a request, you would usually fill it with the desired information +/// // into the respective structure. Some of the parts shown here might not be applicable ! +/// // Values shown here are possibly random and not representative ! +/// let mut req = ChannelSection::default(); +/// req.content_details = Default::default(); // is ChannelSectionContentDetails +/// req.snippet = Default::default(); // is ChannelSectionSnippet +/// +/// // You can configure optional parameters by calling the respective setters at will, and +/// // execute the final call using `doit()`. +/// // Values shown here are possibly random and not representative ! +/// let result = hub.channel_sections().update(req) +/// .on_behalf_of_content_owner("consetetur") +/// .doit().await; +/// # } +/// ``` +pub struct ChannelSectionUpdateCall<'a, S> + where S: 'a { + + pub(super) hub: &'a YouTube, + pub(super) _request: ChannelSection, + pub(super) _part: Vec, + pub(super) _on_behalf_of_content_owner: Option, + pub(super) _delegate: Option<&'a mut dyn client::Delegate>, + pub(super) _additional_params: HashMap, + pub(super) _scopes: BTreeSet +} + +impl<'a, S> client::CallBuilder for ChannelSectionUpdateCall<'a, S> {} + +impl<'a, S> ChannelSectionUpdateCall<'a, S> +where + S: tower_service::Service + Clone + Send + Sync + 'static, + S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, + S::Future: Send + Unpin + 'static, + S::Error: Into>, +{ + + + /// Perform the operation you have build so far. + pub async fn doit(mut self) -> client::Result<(hyper::Response, ChannelSection)> { + use std::io::{Read, Seek}; + use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; + use client::{ToParts, url::Params}; + use std::borrow::Cow; + + let mut dd = client::DefaultDelegate; + let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd); + dlg.begin(client::MethodInfo { id: "youtube.channelSections.update", + http_method: hyper::Method::PUT }); + + for &field in ["alt", "part", "onBehalfOfContentOwner"].iter() { + if self._additional_params.contains_key(field) { + dlg.finished(false); + return Err(client::Error::FieldClash(field)); + } + } + + let mut params = Params::with_capacity(5 + self._additional_params.len()); + if self._part.is_empty() { + self._part.push(self._request.to_parts()); + } + if self._part.len() > 0 { + for f in self._part.iter() { + params.push("part", f); + } + } + if let Some(value) = self._on_behalf_of_content_owner.as_ref() { + params.push("onBehalfOfContentOwner", value); + } + + params.extend(self._additional_params.iter()); + + params.push("alt", "json"); + let mut url = self.hub._base_url.clone() + "youtube/v3/channelSections"; + if self._scopes.is_empty() { + self._scopes.insert(Scope::Full.as_ref().to_string()); + } + + + let url = params.parse_with_url(&url); + + let mut json_mime_type = mime::APPLICATION_JSON; + let mut request_value_reader = + { + let mut value = json::value::to_value(&self._request).expect("serde to work"); + client::remove_json_null_values(&mut value); + let mut dst = io::Cursor::new(Vec::with_capacity(128)); + json::to_writer(&mut dst, &value).unwrap(); + dst + }; + let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); + request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); + + + loop { + let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]).await { + Ok(token) => token, + Err(e) => { + match dlg.token(e) { + Ok(token) => token, + Err(e) => { + dlg.finished(false); + return Err(client::Error::MissingToken(e)); + } + } + } + }; + request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); + let mut req_result = { + let client = &self.hub.client; + dlg.pre_request(); + let mut req_builder = hyper::Request::builder() + .method(hyper::Method::PUT) + .uri(url.as_str()) + .header(USER_AGENT, self.hub._user_agent.clone()); + + if let Some(token) = token.as_ref() { + req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); + } + + + let request = req_builder + .header(CONTENT_TYPE, json_mime_type.to_string()) + .header(CONTENT_LENGTH, request_size as u64) + .body(hyper::body::Body::from(request_value_reader.get_ref().clone())); + + client.request(request.unwrap()).await + + }; + + match req_result { + Err(err) => { + if let client::Retry::After(d) = dlg.http_error(&err) { + sleep(d).await; + continue; + } + dlg.finished(false); + return Err(client::Error::HttpError(err)) + } + Ok(mut res) => { + if !res.status().is_success() { + let res_body_string = client::get_body_as_string(res.body_mut()).await; + let (parts, _) = res.into_parts(); + let body = hyper::Body::from(res_body_string.clone()); + let restored_response = hyper::Response::from_parts(parts, body); + + let server_response = json::from_str::(&res_body_string).ok(); + + if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { + sleep(d).await; + continue; + } + + dlg.finished(false); + + return match server_response { + Some(error_value) => Err(client::Error::BadRequest(error_value)), + None => Err(client::Error::Failure(restored_response)), + } + } + let result_value = { + let res_body_string = client::get_body_as_string(res.body_mut()).await; + + match json::from_str(&res_body_string) { + Ok(decoded) => (res, decoded), + Err(err) => { + dlg.response_json_decode_error(&res_body_string, &err); + return Err(client::Error::JsonDecodeError(res_body_string, err)); + } + } + }; + + dlg.finished(true); + return Ok(result_value) + } + } + } + } + + + /// + /// Sets the *request* property to the given value. + /// + /// Even though the property as already been set when instantiating this call, + /// we provide this method for API completeness. + /// + /// **Settable Parts** + /// + /// * *snippet* + /// * *contentDetails* + pub fn request(mut self, new_value: ChannelSection) -> ChannelSectionUpdateCall<'a, S> { + self._request = new_value; + self + } + /// The *part* parameter serves two purposes in this operation. It identifies the properties that the write operation will set as well as the properties that the API response will include. The part names that you can include in the parameter value are snippet and contentDetails. + /// + /// Append the given value to the *part* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + /// + /// Even though the *parts* list is automatically derived from *Resource* passed in + /// during instantiation and indicates which values you are passing, the response would contain the very same parts. + /// This may not always be desirable, as you can obtain (newly generated) parts you cannot pass in, + /// like statistics that are generated server side. Therefore you should use this method to specify + /// the parts you provide in addition to the ones you want in the response. + /// + /// **Settable Parts** + /// + /// * *snippet* + /// * *contentDetails* + pub fn add_part(mut self, new_value: &str) -> ChannelSectionUpdateCall<'a, S> { + self._part.push(new_value.to_string()); + self + } + /// *Note:* This parameter is intended exclusively for YouTube content partners. The *onBehalfOfContentOwner* parameter indicates that the request's authorization credentials identify a YouTube CMS user who is acting on behalf of the content owner specified in the parameter value. This parameter is intended for YouTube content partners that own and manage many different YouTube channels. It allows content owners to authenticate once and get access to all their video and channel data, without having to provide authentication credentials for each individual channel. The CMS account that the user authenticates with must be linked to the specified YouTube content owner. + /// + /// Sets the *on behalf of content owner* query property to the given value. + pub fn on_behalf_of_content_owner(mut self, new_value: &str) -> ChannelSectionUpdateCall<'a, S> { + self._on_behalf_of_content_owner = 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. + /// + /// ````text + /// It should be used to handle progress information, and to implement a certain level of resilience. + /// ```` + /// + /// Sets the *delegate* property to the given value. + pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> ChannelSectionUpdateCall<'a, S> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not be used to set any of the known parameters + /// which have their own setter method. If done anyway, the request will fail. + /// + /// # Additional Parameters + /// + /// * *$.xgafv* (query-string) - V1 error format. + /// * *access_token* (query-string) - OAuth access token. + /// * *alt* (query-string) - Data format for response. + /// * *callback* (query-string) - JSONP + /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. + /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. + /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. + /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. + /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. + /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). + /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). + pub fn param(mut self, name: T, value: T) -> ChannelSectionUpdateCall<'a, S> + where T: AsRef { + self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); + self + } + + /// Identifies the authorization scope for the method you are building. + /// + /// Use this method to actively specify which scope should be used, instead of 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: St) -> ChannelSectionUpdateCall<'a, S> + where St: AsRef { + self._scopes.insert(String::from(scope.as_ref())); + self + } + /// Identifies the authorization scope(s) for the method you are building. + /// + /// See [`Self::add_scope()`] for details. + pub fn add_scopes(mut self, scopes: I) -> ChannelSectionUpdateCall<'a, S> + where I: IntoIterator, + St: AsRef { + self._scopes + .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); + self + } + + /// Removes all scopes, and no default scope will be used either. + /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] + /// for details). + pub fn clear_scopes(mut self) -> ChannelSectionUpdateCall<'a, S> { + self._scopes.clear(); + self + } +} + + +/// Retrieves a list of resources, possibly filtered. +/// +/// A builder for the *list* method supported by a *channel* resource. +/// It is not used directly, but through a [`ChannelMethods`] instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate hyper_rustls; +/// # extern crate google_youtube3 as youtube3; +/// # async fn dox() { +/// # use std::default::Default; +/// # use youtube3::{YouTube, oauth2, hyper, hyper_rustls, chrono, FieldMask}; +/// +/// # let secret: oauth2::ApplicationSecret = Default::default(); +/// # let auth = oauth2::InstalledFlowAuthenticator::builder( +/// # secret, +/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, +/// # ).build().await.unwrap(); +/// # let mut hub = YouTube::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().unwrap().https_or_http().enable_http1().build()), auth); +/// // You can configure optional parameters by calling the respective setters at will, and +/// // execute the final call using `doit()`. +/// // Values shown here are possibly random and not representative ! +/// let result = hub.channels().list(&vec!["voluptua.".into()]) +/// .page_token("et") +/// .on_behalf_of_content_owner("erat") +/// .my_subscribers(false) +/// .mine(true) +/// .max_results(27) +/// .managed_by_me(false) +/// .add_id("dolore") +/// .hl("dolore") +/// .for_username("dolore") +/// .for_handle("voluptua.") +/// .category_id("amet.") +/// .doit().await; +/// # } +/// ``` +pub struct ChannelListCall<'a, S> + where S: 'a { + + pub(super) hub: &'a YouTube, + pub(super) _part: Vec, + pub(super) _page_token: Option, + pub(super) _on_behalf_of_content_owner: Option, + pub(super) _my_subscribers: Option, + pub(super) _mine: Option, + pub(super) _max_results: Option, + pub(super) _managed_by_me: Option, + pub(super) _id: Vec, + pub(super) _hl: Option, + pub(super) _for_username: Option, + pub(super) _for_handle: Option, + pub(super) _category_id: Option, + pub(super) _delegate: Option<&'a mut dyn client::Delegate>, + pub(super) _additional_params: HashMap, + pub(super) _scopes: BTreeSet +} + +impl<'a, S> client::CallBuilder for ChannelListCall<'a, S> {} + +impl<'a, S> ChannelListCall<'a, S> +where + S: tower_service::Service + Clone + Send + Sync + 'static, + S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, + S::Future: Send + Unpin + 'static, + S::Error: Into>, +{ + + + /// Perform the operation you have build so far. + pub async fn doit(mut self) -> client::Result<(hyper::Response, ChannelListResponse)> { + use std::io::{Read, Seek}; + use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; + use client::{ToParts, url::Params}; + use std::borrow::Cow; + + let mut dd = client::DefaultDelegate; + let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd); + dlg.begin(client::MethodInfo { id: "youtube.channels.list", + http_method: hyper::Method::GET }); + + for &field in ["alt", "part", "pageToken", "onBehalfOfContentOwner", "mySubscribers", "mine", "maxResults", "managedByMe", "id", "hl", "forUsername", "forHandle", "categoryId"].iter() { + if self._additional_params.contains_key(field) { + dlg.finished(false); + return Err(client::Error::FieldClash(field)); + } + } + + let mut params = Params::with_capacity(14 + self._additional_params.len()); + if self._part.len() > 0 { + for f in self._part.iter() { + params.push("part", f); + } + } + if let Some(value) = self._page_token.as_ref() { + params.push("pageToken", value); + } + if let Some(value) = self._on_behalf_of_content_owner.as_ref() { + params.push("onBehalfOfContentOwner", value); + } + if let Some(value) = self._my_subscribers.as_ref() { + params.push("mySubscribers", value.to_string()); + } + if let Some(value) = self._mine.as_ref() { + params.push("mine", value.to_string()); + } + if let Some(value) = self._max_results.as_ref() { + params.push("maxResults", value.to_string()); + } + if let Some(value) = self._managed_by_me.as_ref() { + params.push("managedByMe", value.to_string()); + } + if self._id.len() > 0 { + for f in self._id.iter() { + params.push("id", f); + } + } + if let Some(value) = self._hl.as_ref() { + params.push("hl", value); + } + if let Some(value) = self._for_username.as_ref() { + params.push("forUsername", value); + } + if let Some(value) = self._for_handle.as_ref() { + params.push("forHandle", value); + } + if let Some(value) = self._category_id.as_ref() { + params.push("categoryId", value); + } + + params.extend(self._additional_params.iter()); + + params.push("alt", "json"); + let mut url = self.hub._base_url.clone() + "youtube/v3/channels"; + if self._scopes.is_empty() { + self._scopes.insert(Scope::Readonly.as_ref().to_string()); + } + + + let url = params.parse_with_url(&url); + + + + loop { + let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]).await { + Ok(token) => token, + Err(e) => { + match dlg.token(e) { + Ok(token) => token, + Err(e) => { + dlg.finished(false); + return Err(client::Error::MissingToken(e)); + } + } + } + }; + let mut req_result = { + let client = &self.hub.client; + dlg.pre_request(); + let mut req_builder = hyper::Request::builder() + .method(hyper::Method::GET) + .uri(url.as_str()) + .header(USER_AGENT, self.hub._user_agent.clone()); + + if let Some(token) = token.as_ref() { + req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); + } + + + let request = req_builder + .header(CONTENT_LENGTH, 0_u64) + .body(hyper::body::Body::empty()); + + client.request(request.unwrap()).await + + }; + + match req_result { + Err(err) => { + if let client::Retry::After(d) = dlg.http_error(&err) { + sleep(d).await; + continue; + } + dlg.finished(false); + return Err(client::Error::HttpError(err)) + } + Ok(mut res) => { + if !res.status().is_success() { + let res_body_string = client::get_body_as_string(res.body_mut()).await; + let (parts, _) = res.into_parts(); + let body = hyper::Body::from(res_body_string.clone()); + let restored_response = hyper::Response::from_parts(parts, body); + + let server_response = json::from_str::(&res_body_string).ok(); + + if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { + sleep(d).await; + continue; + } + + dlg.finished(false); + + return match server_response { + Some(error_value) => Err(client::Error::BadRequest(error_value)), + None => Err(client::Error::Failure(restored_response)), + } + } + let result_value = { + let res_body_string = client::get_body_as_string(res.body_mut()).await; + + match json::from_str(&res_body_string) { + Ok(decoded) => (res, decoded), + Err(err) => { + dlg.response_json_decode_error(&res_body_string, &err); + return Err(client::Error::JsonDecodeError(res_body_string, err)); + } + } + }; + + dlg.finished(true); + return Ok(result_value) + } + } + } + } + + + /// The *part* parameter specifies a comma-separated list of one or more channel resource properties that the API response will include. If the parameter identifies a property that contains child properties, the child properties will be included in the response. For example, in a channel resource, the contentDetails property contains other properties, such as the uploads properties. As such, if you set *part=contentDetails*, the API response will also contain all of those nested properties. + /// + /// Append the given value to the *part* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + /// + /// Even though the property as already been set when instantiating this call, + /// we provide this method for API completeness. + pub fn add_part(mut self, new_value: &str) -> ChannelListCall<'a, S> { + self._part.push(new_value.to_string()); + self + } + /// The *pageToken* parameter identifies a specific page in the result set that should be returned. In an API response, the nextPageToken and prevPageToken properties identify other pages that could be retrieved. + /// + /// Sets the *page token* query property to the given value. + pub fn page_token(mut self, new_value: &str) -> ChannelListCall<'a, S> { + self._page_token = Some(new_value.to_string()); + self + } + /// *Note:* This parameter is intended exclusively for YouTube content partners. The *onBehalfOfContentOwner* parameter indicates that the request's authorization credentials identify a YouTube CMS user who is acting on behalf of the content owner specified in the parameter value. This parameter is intended for YouTube content partners that own and manage many different YouTube channels. It allows content owners to authenticate once and get access to all their video and channel data, without having to provide authentication credentials for each individual channel. The CMS account that the user authenticates with must be linked to the specified YouTube content owner. + /// + /// Sets the *on behalf of content owner* query property to the given value. + pub fn on_behalf_of_content_owner(mut self, new_value: &str) -> ChannelListCall<'a, S> { + self._on_behalf_of_content_owner = Some(new_value.to_string()); + self + } + /// Return the channels subscribed to the authenticated user + /// + /// Sets the *my subscribers* query property to the given value. + pub fn my_subscribers(mut self, new_value: bool) -> ChannelListCall<'a, S> { + self._my_subscribers = Some(new_value); + self + } + /// Return the ids of channels owned by the authenticated user. + /// + /// Sets the *mine* query property to the given value. + pub fn mine(mut self, new_value: bool) -> ChannelListCall<'a, S> { + self._mine = Some(new_value); + self + } + /// The *maxResults* parameter specifies the maximum number of items that should be returned in the result set. + /// + /// Sets the *max results* query property to the given value. + pub fn max_results(mut self, new_value: u32) -> ChannelListCall<'a, S> { + self._max_results = Some(new_value); + self + } + /// Return the channels managed by the authenticated user. + /// + /// Sets the *managed by me* query property to the given value. + pub fn managed_by_me(mut self, new_value: bool) -> ChannelListCall<'a, S> { + self._managed_by_me = Some(new_value); + self + } + /// Return the channels with the specified IDs. + /// + /// Append the given value to the *id* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + pub fn add_id(mut self, new_value: &str) -> ChannelListCall<'a, S> { + self._id.push(new_value.to_string()); + self + } + /// Stands for "host language". Specifies the localization language of the metadata to be filled into snippet.localized. The field is filled with the default metadata if there is no localization in the specified language. The parameter value must be a language code included in the list returned by the i18nLanguages.list method (e.g. en_US, es_MX). + /// + /// Sets the *hl* query property to the given value. + pub fn hl(mut self, new_value: &str) -> ChannelListCall<'a, S> { + self._hl = Some(new_value.to_string()); + self + } + /// Return the channel associated with a YouTube username. + /// + /// Sets the *for username* query property to the given value. + pub fn for_username(mut self, new_value: &str) -> ChannelListCall<'a, S> { + self._for_username = Some(new_value.to_string()); + self + } + /// Return the channel associated with a YouTube handle. + /// + /// Sets the *for handle* query property to the given value. + pub fn for_handle(mut self, new_value: &str) -> ChannelListCall<'a, S> { + self._for_handle = Some(new_value.to_string()); + self + } + /// Return the channels within the specified guide category ID. + /// + /// Sets the *category id* query property to the given value. + pub fn category_id(mut self, new_value: &str) -> ChannelListCall<'a, S> { + self._category_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. + /// + /// ````text + /// It should be used to handle progress information, and to implement a certain level of resilience. + /// ```` + /// + /// Sets the *delegate* property to the given value. + pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> ChannelListCall<'a, S> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not be used to set any of the known parameters + /// which have their own setter method. If done anyway, the request will fail. + /// + /// # Additional Parameters + /// + /// * *$.xgafv* (query-string) - V1 error format. + /// * *access_token* (query-string) - OAuth access token. + /// * *alt* (query-string) - Data format for response. + /// * *callback* (query-string) - JSONP + /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. + /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. + /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. + /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. + /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. + /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). + /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). + pub fn param(mut self, name: T, value: T) -> ChannelListCall<'a, S> + where T: AsRef { + self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); + self + } + + /// Identifies the authorization scope for the method you are building. + /// + /// Use this method to actively specify which scope should be used, instead of 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: St) -> ChannelListCall<'a, S> + where St: AsRef { + self._scopes.insert(String::from(scope.as_ref())); + self + } + /// Identifies the authorization scope(s) for the method you are building. + /// + /// See [`Self::add_scope()`] for details. + pub fn add_scopes(mut self, scopes: I) -> ChannelListCall<'a, S> + where I: IntoIterator, + St: AsRef { + self._scopes + .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); + self + } + + /// Removes all scopes, and no default scope will be used either. + /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] + /// for details). + pub fn clear_scopes(mut self) -> ChannelListCall<'a, S> { + self._scopes.clear(); + self + } +} + + +/// Updates an existing resource. +/// +/// A builder for the *update* method supported by a *channel* resource. +/// It is not used directly, but through a [`ChannelMethods`] instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate hyper_rustls; +/// # extern crate google_youtube3 as youtube3; +/// use youtube3::api::Channel; +/// # async fn dox() { +/// # use std::default::Default; +/// # use youtube3::{YouTube, oauth2, hyper, hyper_rustls, chrono, FieldMask}; +/// +/// # let secret: oauth2::ApplicationSecret = Default::default(); +/// # let auth = oauth2::InstalledFlowAuthenticator::builder( +/// # secret, +/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, +/// # ).build().await.unwrap(); +/// # let mut hub = YouTube::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().unwrap().https_or_http().enable_http1().build()), auth); +/// // As the method needs a request, you would usually fill it with the desired information +/// // into the respective structure. Some of the parts shown here might not be applicable ! +/// // Values shown here are possibly random and not representative ! +/// let mut req = Channel::default(); +/// +/// // You can configure optional parameters by calling the respective setters at will, and +/// // execute the final call using `doit()`. +/// // Values shown here are possibly random and not representative ! +/// let result = hub.channels().update(req) +/// .on_behalf_of_content_owner("ea") +/// .doit().await; +/// # } +/// ``` +pub struct ChannelUpdateCall<'a, S> + where S: 'a { + + pub(super) hub: &'a YouTube, + pub(super) _request: Channel, + pub(super) _part: Vec, + pub(super) _on_behalf_of_content_owner: Option, + pub(super) _delegate: Option<&'a mut dyn client::Delegate>, + pub(super) _additional_params: HashMap, + pub(super) _scopes: BTreeSet +} + +impl<'a, S> client::CallBuilder for ChannelUpdateCall<'a, S> {} + +impl<'a, S> ChannelUpdateCall<'a, S> +where + S: tower_service::Service + Clone + Send + Sync + 'static, + S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, + S::Future: Send + Unpin + 'static, + S::Error: Into>, +{ + + + /// Perform the operation you have build so far. + pub async fn doit(mut self) -> client::Result<(hyper::Response, Channel)> { + use std::io::{Read, Seek}; + use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; + use client::{ToParts, url::Params}; + use std::borrow::Cow; + + let mut dd = client::DefaultDelegate; + let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd); + dlg.begin(client::MethodInfo { id: "youtube.channels.update", + http_method: hyper::Method::PUT }); + + for &field in ["alt", "part", "onBehalfOfContentOwner"].iter() { + if self._additional_params.contains_key(field) { + dlg.finished(false); + return Err(client::Error::FieldClash(field)); + } + } + + let mut params = Params::with_capacity(5 + self._additional_params.len()); + if self._part.is_empty() { + self._part.push(self._request.to_parts()); + } + if self._part.len() > 0 { + for f in self._part.iter() { + params.push("part", f); + } + } + if let Some(value) = self._on_behalf_of_content_owner.as_ref() { + params.push("onBehalfOfContentOwner", value); + } + + params.extend(self._additional_params.iter()); + + params.push("alt", "json"); + let mut url = self.hub._base_url.clone() + "youtube/v3/channels"; + if self._scopes.is_empty() { + self._scopes.insert(Scope::Full.as_ref().to_string()); + } + + + let url = params.parse_with_url(&url); + + let mut json_mime_type = mime::APPLICATION_JSON; + let mut request_value_reader = + { + let mut value = json::value::to_value(&self._request).expect("serde to work"); + client::remove_json_null_values(&mut value); + let mut dst = io::Cursor::new(Vec::with_capacity(128)); + json::to_writer(&mut dst, &value).unwrap(); + dst + }; + let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); + request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); + + + loop { + let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]).await { + Ok(token) => token, + Err(e) => { + match dlg.token(e) { + Ok(token) => token, + Err(e) => { + dlg.finished(false); + return Err(client::Error::MissingToken(e)); + } + } + } + }; + request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); + let mut req_result = { + let client = &self.hub.client; + dlg.pre_request(); + let mut req_builder = hyper::Request::builder() + .method(hyper::Method::PUT) + .uri(url.as_str()) + .header(USER_AGENT, self.hub._user_agent.clone()); + + if let Some(token) = token.as_ref() { + req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); + } + + + let request = req_builder + .header(CONTENT_TYPE, json_mime_type.to_string()) + .header(CONTENT_LENGTH, request_size as u64) + .body(hyper::body::Body::from(request_value_reader.get_ref().clone())); + + client.request(request.unwrap()).await + + }; + + match req_result { + Err(err) => { + if let client::Retry::After(d) = dlg.http_error(&err) { + sleep(d).await; + continue; + } + dlg.finished(false); + return Err(client::Error::HttpError(err)) + } + Ok(mut res) => { + if !res.status().is_success() { + let res_body_string = client::get_body_as_string(res.body_mut()).await; + let (parts, _) = res.into_parts(); + let body = hyper::Body::from(res_body_string.clone()); + let restored_response = hyper::Response::from_parts(parts, body); + + let server_response = json::from_str::(&res_body_string).ok(); + + if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { + sleep(d).await; + continue; + } + + dlg.finished(false); + + return match server_response { + Some(error_value) => Err(client::Error::BadRequest(error_value)), + None => Err(client::Error::Failure(restored_response)), + } + } + let result_value = { + let res_body_string = client::get_body_as_string(res.body_mut()).await; + + match json::from_str(&res_body_string) { + Ok(decoded) => (res, decoded), + Err(err) => { + dlg.response_json_decode_error(&res_body_string, &err); + return Err(client::Error::JsonDecodeError(res_body_string, err)); + } + } + }; + + dlg.finished(true); + return Ok(result_value) + } + } + } + } + + + /// + /// Sets the *request* property to the given value. + /// + /// Even though the property as already been set when instantiating this call, + /// we provide this method for API completeness. + pub fn request(mut self, new_value: Channel) -> ChannelUpdateCall<'a, S> { + self._request = new_value; + self + } + /// The *part* parameter serves two purposes in this operation. It identifies the properties that the write operation will set as well as the properties that the API response will include. The API currently only allows the parameter value to be set to either brandingSettings or invideoPromotion. (You cannot update both of those parts with a single request.) Note that this method overrides the existing values for all of the mutable properties that are contained in any parts that the parameter value specifies. + /// + /// Append the given value to the *part* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + /// + /// Even though the *parts* list is automatically derived from *Resource* passed in + /// during instantiation and indicates which values you are passing, the response would contain the very same parts. + /// This may not always be desirable, as you can obtain (newly generated) parts you cannot pass in, + /// like statistics that are generated server side. Therefore you should use this method to specify + /// the parts you provide in addition to the ones you want in the response. + pub fn add_part(mut self, new_value: &str) -> ChannelUpdateCall<'a, S> { + self._part.push(new_value.to_string()); + self + } + /// The *onBehalfOfContentOwner* parameter indicates that the authenticated user is acting on behalf of the content owner specified in the parameter value. This parameter is intended for YouTube content partners that own and manage many different YouTube channels. It allows content owners to authenticate once and get access to all their video and channel data, without having to provide authentication credentials for each individual channel. The actual CMS account that the user authenticates with needs to be linked to the specified YouTube content owner. + /// + /// Sets the *on behalf of content owner* query property to the given value. + pub fn on_behalf_of_content_owner(mut self, new_value: &str) -> ChannelUpdateCall<'a, S> { + self._on_behalf_of_content_owner = 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. + /// + /// ````text + /// It should be used to handle progress information, and to implement a certain level of resilience. + /// ```` + /// + /// Sets the *delegate* property to the given value. + pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> ChannelUpdateCall<'a, S> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not be used to set any of the known parameters + /// which have their own setter method. If done anyway, the request will fail. + /// + /// # Additional Parameters + /// + /// * *$.xgafv* (query-string) - V1 error format. + /// * *access_token* (query-string) - OAuth access token. + /// * *alt* (query-string) - Data format for response. + /// * *callback* (query-string) - JSONP + /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. + /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. + /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. + /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. + /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. + /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). + /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). + pub fn param(mut self, name: T, value: T) -> ChannelUpdateCall<'a, S> + where T: AsRef { + self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); + self + } + + /// Identifies the authorization scope for the method you are building. + /// + /// Use this method to actively specify which scope should be used, instead of 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: St) -> ChannelUpdateCall<'a, S> + where St: AsRef { + self._scopes.insert(String::from(scope.as_ref())); + self + } + /// Identifies the authorization scope(s) for the method you are building. + /// + /// See [`Self::add_scope()`] for details. + pub fn add_scopes(mut self, scopes: I) -> ChannelUpdateCall<'a, S> + where I: IntoIterator, + St: AsRef { + self._scopes + .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); + self + } + + /// Removes all scopes, and no default scope will be used either. + /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] + /// for details). + pub fn clear_scopes(mut self) -> ChannelUpdateCall<'a, S> { + self._scopes.clear(); + self + } +} + + +/// Inserts a new resource into this collection. +/// +/// A builder for the *insert* method supported by a *commentThread* resource. +/// It is not used directly, but through a [`CommentThreadMethods`] instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate hyper_rustls; +/// # extern crate google_youtube3 as youtube3; +/// use youtube3::api::CommentThread; +/// # async fn dox() { +/// # use std::default::Default; +/// # use youtube3::{YouTube, oauth2, hyper, hyper_rustls, chrono, FieldMask}; +/// +/// # let secret: oauth2::ApplicationSecret = Default::default(); +/// # let auth = oauth2::InstalledFlowAuthenticator::builder( +/// # secret, +/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, +/// # ).build().await.unwrap(); +/// # let mut hub = YouTube::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().unwrap().https_or_http().enable_http1().build()), auth); +/// // As the method needs a request, you would usually fill it with the desired information +/// // into the respective structure. Some of the parts shown here might not be applicable ! +/// // Values shown here are possibly random and not representative ! +/// let mut req = CommentThread::default(); +/// +/// // You can configure optional parameters by calling the respective setters at will, and +/// // execute the final call using `doit()`. +/// // Values shown here are possibly random and not representative ! +/// let result = hub.comment_threads().insert(req) +/// .doit().await; +/// # } +/// ``` +pub struct CommentThreadInsertCall<'a, S> + where S: 'a { + + pub(super) hub: &'a YouTube, + pub(super) _request: CommentThread, + pub(super) _part: Vec, + pub(super) _delegate: Option<&'a mut dyn client::Delegate>, + pub(super) _additional_params: HashMap, + pub(super) _scopes: BTreeSet +} + +impl<'a, S> client::CallBuilder for CommentThreadInsertCall<'a, S> {} + +impl<'a, S> CommentThreadInsertCall<'a, S> +where + S: tower_service::Service + Clone + Send + Sync + 'static, + S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, + S::Future: Send + Unpin + 'static, + S::Error: Into>, +{ + + + /// Perform the operation you have build so far. + pub async fn doit(mut self) -> client::Result<(hyper::Response, CommentThread)> { + use std::io::{Read, Seek}; + use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; + use client::{ToParts, url::Params}; + use std::borrow::Cow; + + let mut dd = client::DefaultDelegate; + let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd); + dlg.begin(client::MethodInfo { id: "youtube.commentThreads.insert", + http_method: hyper::Method::POST }); + + for &field in ["alt", "part"].iter() { + if self._additional_params.contains_key(field) { + dlg.finished(false); + return Err(client::Error::FieldClash(field)); + } + } + + let mut params = Params::with_capacity(4 + self._additional_params.len()); + if self._part.is_empty() { + self._part.push(self._request.to_parts()); + } + if self._part.len() > 0 { + for f in self._part.iter() { + params.push("part", f); + } + } + + params.extend(self._additional_params.iter()); + + params.push("alt", "json"); + let mut url = self.hub._base_url.clone() + "youtube/v3/commentThreads"; + if self._scopes.is_empty() { + self._scopes.insert(Scope::ForceSsl.as_ref().to_string()); + } + + + let url = params.parse_with_url(&url); + + let mut json_mime_type = mime::APPLICATION_JSON; + let mut request_value_reader = + { + let mut value = json::value::to_value(&self._request).expect("serde to work"); + client::remove_json_null_values(&mut value); + let mut dst = io::Cursor::new(Vec::with_capacity(128)); + json::to_writer(&mut dst, &value).unwrap(); + dst + }; + let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); + request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); + + + loop { + let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]).await { + Ok(token) => token, + Err(e) => { + match dlg.token(e) { + Ok(token) => token, + Err(e) => { + dlg.finished(false); + return Err(client::Error::MissingToken(e)); + } + } + } + }; + request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); + let mut req_result = { + let client = &self.hub.client; + dlg.pre_request(); + let mut req_builder = hyper::Request::builder() + .method(hyper::Method::POST) + .uri(url.as_str()) + .header(USER_AGENT, self.hub._user_agent.clone()); + + if let Some(token) = token.as_ref() { + req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); + } + + + let request = req_builder + .header(CONTENT_TYPE, json_mime_type.to_string()) + .header(CONTENT_LENGTH, request_size as u64) + .body(hyper::body::Body::from(request_value_reader.get_ref().clone())); + + client.request(request.unwrap()).await + + }; + + match req_result { + Err(err) => { + if let client::Retry::After(d) = dlg.http_error(&err) { + sleep(d).await; + continue; + } + dlg.finished(false); + return Err(client::Error::HttpError(err)) + } + Ok(mut res) => { + if !res.status().is_success() { + let res_body_string = client::get_body_as_string(res.body_mut()).await; + let (parts, _) = res.into_parts(); + let body = hyper::Body::from(res_body_string.clone()); + let restored_response = hyper::Response::from_parts(parts, body); + + let server_response = json::from_str::(&res_body_string).ok(); + + if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { + sleep(d).await; + continue; + } + + dlg.finished(false); + + return match server_response { + Some(error_value) => Err(client::Error::BadRequest(error_value)), + None => Err(client::Error::Failure(restored_response)), + } + } + let result_value = { + let res_body_string = client::get_body_as_string(res.body_mut()).await; + + match json::from_str(&res_body_string) { + Ok(decoded) => (res, decoded), + Err(err) => { + dlg.response_json_decode_error(&res_body_string, &err); + return Err(client::Error::JsonDecodeError(res_body_string, err)); + } + } + }; + + dlg.finished(true); + return Ok(result_value) + } + } + } + } + + + /// + /// Sets the *request* property to the given value. + /// + /// Even though the property as already been set when instantiating this call, + /// we provide this method for API completeness. + pub fn request(mut self, new_value: CommentThread) -> CommentThreadInsertCall<'a, S> { + self._request = new_value; + self + } + /// The *part* parameter identifies the properties that the API response will include. Set the parameter value to snippet. The snippet part has a quota cost of 2 units. + /// + /// Append the given value to the *part* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + /// + /// Even though the *parts* list is automatically derived from *Resource* passed in + /// during instantiation and indicates which values you are passing, the response would contain the very same parts. + /// This may not always be desirable, as you can obtain (newly generated) parts you cannot pass in, + /// like statistics that are generated server side. Therefore you should use this method to specify + /// the parts you provide in addition to the ones you want in the response. + pub fn add_part(mut self, new_value: &str) -> CommentThreadInsertCall<'a, S> { + self._part.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. + /// + /// ````text + /// It should be used to handle progress information, and to implement a certain level of resilience. + /// ```` + /// + /// Sets the *delegate* property to the given value. + pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> CommentThreadInsertCall<'a, S> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not be used to set any of the known parameters + /// which have their own setter method. If done anyway, the request will fail. + /// + /// # Additional Parameters + /// + /// * *$.xgafv* (query-string) - V1 error format. + /// * *access_token* (query-string) - OAuth access token. + /// * *alt* (query-string) - Data format for response. + /// * *callback* (query-string) - JSONP + /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. + /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. + /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. + /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. + /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. + /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). + /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). + pub fn param(mut self, name: T, value: T) -> CommentThreadInsertCall<'a, S> + where T: AsRef { + self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); + self + } + + /// Identifies the authorization scope for the method you are building. + /// + /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant + /// [`Scope::ForceSsl`]. + /// + /// The `scope` will be added to a set of scopes. This is important as one can maintain access + /// tokens for more than one scope. + /// + /// Usually there is more than one suitable scope to authorize an operation, some of which may + /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be + /// sufficient, a read-write scope will do as well. + pub fn add_scope(mut self, scope: St) -> CommentThreadInsertCall<'a, S> + where St: AsRef { + self._scopes.insert(String::from(scope.as_ref())); + self + } + /// Identifies the authorization scope(s) for the method you are building. + /// + /// See [`Self::add_scope()`] for details. + pub fn add_scopes(mut self, scopes: I) -> CommentThreadInsertCall<'a, S> + where I: IntoIterator, + St: AsRef { + self._scopes + .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); + self + } + + /// Removes all scopes, and no default scope will be used either. + /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] + /// for details). + pub fn clear_scopes(mut self) -> CommentThreadInsertCall<'a, S> { + self._scopes.clear(); + self + } +} + + +/// Retrieves a list of resources, possibly filtered. +/// +/// A builder for the *list* method supported by a *commentThread* resource. +/// It is not used directly, but through a [`CommentThreadMethods`] instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate hyper_rustls; +/// # extern crate google_youtube3 as youtube3; +/// # async fn dox() { +/// # use std::default::Default; +/// # use youtube3::{YouTube, oauth2, hyper, hyper_rustls, chrono, FieldMask}; +/// +/// # let secret: oauth2::ApplicationSecret = Default::default(); +/// # let auth = oauth2::InstalledFlowAuthenticator::builder( +/// # secret, +/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, +/// # ).build().await.unwrap(); +/// # let mut hub = YouTube::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().unwrap().https_or_http().enable_http1().build()), auth); +/// // You can configure optional parameters by calling the respective setters at will, and +/// // execute the final call using `doit()`. +/// // Values shown here are possibly random and not representative ! +/// let result = hub.comment_threads().list(&vec!["sadipscing".into()]) +/// .video_id("Lorem") +/// .text_format(&Default::default()) +/// .search_terms("invidunt") +/// .page_token("no") +/// .order(&Default::default()) +/// .moderation_status(&Default::default()) +/// .max_results(94) +/// .add_id("At") +/// .channel_id("sed") +/// .all_threads_related_to_channel_id("sit") +/// .doit().await; +/// # } +/// ``` +pub struct CommentThreadListCall<'a, S> + where S: 'a { + + pub(super) hub: &'a YouTube, + pub(super) _part: Vec, + pub(super) _video_id: Option, + pub(super) _text_format: Option, + pub(super) _search_terms: Option, + pub(super) _page_token: Option, + pub(super) _order: Option, + pub(super) _moderation_status: Option, + pub(super) _max_results: Option, + pub(super) _id: Vec, + pub(super) _channel_id: Option, + pub(super) _all_threads_related_to_channel_id: Option, + pub(super) _delegate: Option<&'a mut dyn client::Delegate>, + pub(super) _additional_params: HashMap, + pub(super) _scopes: BTreeSet +} + +impl<'a, S> client::CallBuilder for CommentThreadListCall<'a, S> {} + +impl<'a, S> CommentThreadListCall<'a, S> +where + S: tower_service::Service + Clone + Send + Sync + 'static, + S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, + S::Future: Send + Unpin + 'static, + S::Error: Into>, +{ + + + /// Perform the operation you have build so far. + pub async fn doit(mut self) -> client::Result<(hyper::Response, CommentThreadListResponse)> { + use std::io::{Read, Seek}; + use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; + use client::{ToParts, url::Params}; + use std::borrow::Cow; + + let mut dd = client::DefaultDelegate; + let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd); + dlg.begin(client::MethodInfo { id: "youtube.commentThreads.list", + http_method: hyper::Method::GET }); + + for &field in ["alt", "part", "videoId", "textFormat", "searchTerms", "pageToken", "order", "moderationStatus", "maxResults", "id", "channelId", "allThreadsRelatedToChannelId"].iter() { + if self._additional_params.contains_key(field) { + dlg.finished(false); + return Err(client::Error::FieldClash(field)); + } + } + + let mut params = Params::with_capacity(13 + self._additional_params.len()); + if self._part.len() > 0 { + for f in self._part.iter() { + params.push("part", f); + } + } + if let Some(value) = self._video_id.as_ref() { + params.push("videoId", value); + } + if let Some(value) = self._text_format.as_ref() { + params.push("textFormat", value); + } + if let Some(value) = self._search_terms.as_ref() { + params.push("searchTerms", value); + } + if let Some(value) = self._page_token.as_ref() { + params.push("pageToken", value); + } + if let Some(value) = self._order.as_ref() { + params.push("order", value); + } + if let Some(value) = self._moderation_status.as_ref() { + params.push("moderationStatus", value); + } + if let Some(value) = self._max_results.as_ref() { + params.push("maxResults", value.to_string()); + } + if self._id.len() > 0 { + for f in self._id.iter() { + params.push("id", f); + } + } + if let Some(value) = self._channel_id.as_ref() { + params.push("channelId", value); + } + if let Some(value) = self._all_threads_related_to_channel_id.as_ref() { + params.push("allThreadsRelatedToChannelId", value); + } + + params.extend(self._additional_params.iter()); + + params.push("alt", "json"); + let mut url = self.hub._base_url.clone() + "youtube/v3/commentThreads"; + if self._scopes.is_empty() { + self._scopes.insert(Scope::ForceSsl.as_ref().to_string()); + } + + + let url = params.parse_with_url(&url); + + + + loop { + let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]).await { + Ok(token) => token, + Err(e) => { + match dlg.token(e) { + Ok(token) => token, + Err(e) => { + dlg.finished(false); + return Err(client::Error::MissingToken(e)); + } + } + } + }; + let mut req_result = { + let client = &self.hub.client; + dlg.pre_request(); + let mut req_builder = hyper::Request::builder() + .method(hyper::Method::GET) + .uri(url.as_str()) + .header(USER_AGENT, self.hub._user_agent.clone()); + + if let Some(token) = token.as_ref() { + req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); + } + + + let request = req_builder + .header(CONTENT_LENGTH, 0_u64) + .body(hyper::body::Body::empty()); + + client.request(request.unwrap()).await + + }; + + match req_result { + Err(err) => { + if let client::Retry::After(d) = dlg.http_error(&err) { + sleep(d).await; + continue; + } + dlg.finished(false); + return Err(client::Error::HttpError(err)) + } + Ok(mut res) => { + if !res.status().is_success() { + let res_body_string = client::get_body_as_string(res.body_mut()).await; + let (parts, _) = res.into_parts(); + let body = hyper::Body::from(res_body_string.clone()); + let restored_response = hyper::Response::from_parts(parts, body); + + let server_response = json::from_str::(&res_body_string).ok(); + + if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { + sleep(d).await; + continue; + } + + dlg.finished(false); + + return match server_response { + Some(error_value) => Err(client::Error::BadRequest(error_value)), + None => Err(client::Error::Failure(restored_response)), + } + } + let result_value = { + let res_body_string = client::get_body_as_string(res.body_mut()).await; + + match json::from_str(&res_body_string) { + Ok(decoded) => (res, decoded), + Err(err) => { + dlg.response_json_decode_error(&res_body_string, &err); + return Err(client::Error::JsonDecodeError(res_body_string, err)); + } + } + }; + + dlg.finished(true); + return Ok(result_value) + } + } + } + } + + + /// The *part* parameter specifies a comma-separated list of one or more commentThread resource properties that the API response will include. + /// + /// Append the given value to the *part* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + /// + /// Even though the property as already been set when instantiating this call, + /// we provide this method for API completeness. + pub fn add_part(mut self, new_value: &str) -> CommentThreadListCall<'a, S> { + self._part.push(new_value.to_string()); + self + } + /// Returns the comment threads of the specified video. + /// + /// Sets the *video id* query property to the given value. + pub fn video_id(mut self, new_value: &str) -> CommentThreadListCall<'a, S> { + self._video_id = Some(new_value.to_string()); + self + } + /// The requested text format for the returned comments. + /// + /// Sets the *text format* query property to the given value. + pub fn text_format(mut self, new_value: &CommentThreadTextFormatEnum) -> CommentThreadListCall<'a, S> { + self._text_format = Some(new_value.clone()); + self + } + /// Limits the returned comment threads to those matching the specified key words. Not compatible with the 'id' filter. + /// + /// Sets the *search terms* query property to the given value. + pub fn search_terms(mut self, new_value: &str) -> CommentThreadListCall<'a, S> { + self._search_terms = Some(new_value.to_string()); + self + } + /// The *pageToken* parameter identifies a specific page in the result set that should be returned. In an API response, the nextPageToken and prevPageToken properties identify other pages that could be retrieved. + /// + /// Sets the *page token* query property to the given value. + pub fn page_token(mut self, new_value: &str) -> CommentThreadListCall<'a, S> { + self._page_token = Some(new_value.to_string()); + self + } + /// + /// Sets the *order* query property to the given value. + pub fn order(mut self, new_value: &CommentThreadOrderEnum) -> CommentThreadListCall<'a, S> { + self._order = Some(new_value.clone()); + self + } + /// Limits the returned comment threads to those with the specified moderation status. Not compatible with the 'id' filter. Valid values: published, heldForReview, likelySpam. + /// + /// Sets the *moderation status* query property to the given value. + pub fn moderation_status(mut self, new_value: &CommentThreadModerationStatusEnum) -> CommentThreadListCall<'a, S> { + self._moderation_status = Some(new_value.clone()); + self + } + /// The *maxResults* parameter specifies the maximum number of items that should be returned in the result set. + /// + /// Sets the *max results* query property to the given value. + pub fn max_results(mut self, new_value: u32) -> CommentThreadListCall<'a, S> { + self._max_results = Some(new_value); + self + } + /// Returns the comment threads with the given IDs for Stubby or Apiary. + /// + /// Append the given value to the *id* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + pub fn add_id(mut self, new_value: &str) -> CommentThreadListCall<'a, S> { + self._id.push(new_value.to_string()); + self + } + /// Returns the comment threads for all the channel comments (ie does not include comments left on videos). + /// + /// Sets the *channel id* query property to the given value. + pub fn channel_id(mut self, new_value: &str) -> CommentThreadListCall<'a, S> { + self._channel_id = Some(new_value.to_string()); + self + } + /// Returns the comment threads of all videos of the channel and the channel comments as well. + /// + /// Sets the *all threads related to channel id* query property to the given value. + pub fn all_threads_related_to_channel_id(mut self, new_value: &str) -> CommentThreadListCall<'a, S> { + self._all_threads_related_to_channel_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. + /// + /// ````text + /// It should be used to handle progress information, and to implement a certain level of resilience. + /// ```` + /// + /// Sets the *delegate* property to the given value. + pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> CommentThreadListCall<'a, S> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not be used to set any of the known parameters + /// which have their own setter method. If done anyway, the request will fail. + /// + /// # Additional Parameters + /// + /// * *$.xgafv* (query-string) - V1 error format. + /// * *access_token* (query-string) - OAuth access token. + /// * *alt* (query-string) - Data format for response. + /// * *callback* (query-string) - JSONP + /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. + /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. + /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. + /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. + /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. + /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). + /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). + pub fn param(mut self, name: T, value: T) -> CommentThreadListCall<'a, S> + where T: AsRef { + self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); + self + } + + /// Identifies the authorization scope for the method you are building. + /// + /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant + /// [`Scope::ForceSsl`]. + /// + /// The `scope` will be added to a set of scopes. This is important as one can maintain access + /// tokens for more than one scope. + /// + /// Usually there is more than one suitable scope to authorize an operation, some of which may + /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be + /// sufficient, a read-write scope will do as well. + pub fn add_scope(mut self, scope: St) -> CommentThreadListCall<'a, S> + where St: AsRef { + self._scopes.insert(String::from(scope.as_ref())); + self + } + /// Identifies the authorization scope(s) for the method you are building. + /// + /// See [`Self::add_scope()`] for details. + pub fn add_scopes(mut self, scopes: I) -> CommentThreadListCall<'a, S> + where I: IntoIterator, + St: AsRef { + self._scopes + .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); + self + } + + /// Removes all scopes, and no default scope will be used either. + /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] + /// for details). + pub fn clear_scopes(mut self) -> CommentThreadListCall<'a, S> { + self._scopes.clear(); + self + } +} + + +/// Deletes a resource. +/// +/// A builder for the *delete* method supported by a *comment* resource. +/// It is not used directly, but through a [`CommentMethods`] instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate hyper_rustls; +/// # extern crate google_youtube3 as youtube3; +/// # async fn dox() { +/// # use std::default::Default; +/// # use youtube3::{YouTube, oauth2, hyper, hyper_rustls, chrono, FieldMask}; +/// +/// # let secret: oauth2::ApplicationSecret = Default::default(); +/// # let auth = oauth2::InstalledFlowAuthenticator::builder( +/// # secret, +/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, +/// # ).build().await.unwrap(); +/// # let mut hub = YouTube::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().unwrap().https_or_http().enable_http1().build()), auth); +/// // You can configure optional parameters by calling the respective setters at will, and +/// // execute the final call using `doit()`. +/// // Values shown here are possibly random and not representative ! +/// let result = hub.comments().delete("id") +/// .doit().await; +/// # } +/// ``` +pub struct CommentDeleteCall<'a, S> + where S: 'a { + + pub(super) hub: &'a YouTube, + pub(super) _id: String, + pub(super) _delegate: Option<&'a mut dyn client::Delegate>, + pub(super) _additional_params: HashMap, + pub(super) _scopes: BTreeSet +} + +impl<'a, S> client::CallBuilder for CommentDeleteCall<'a, S> {} + +impl<'a, S> CommentDeleteCall<'a, S> +where + S: tower_service::Service + Clone + Send + Sync + 'static, + S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, + S::Future: Send + Unpin + 'static, + S::Error: Into>, +{ + + + /// Perform the operation you have build so far. + pub async fn doit(mut self) -> client::Result> { + use std::io::{Read, Seek}; + use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; + use client::{ToParts, url::Params}; + use std::borrow::Cow; + + let mut dd = client::DefaultDelegate; + let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd); + dlg.begin(client::MethodInfo { id: "youtube.comments.delete", + http_method: hyper::Method::DELETE }); + + for &field in ["id"].iter() { + if self._additional_params.contains_key(field) { + dlg.finished(false); + return Err(client::Error::FieldClash(field)); + } + } + + let mut params = Params::with_capacity(2 + self._additional_params.len()); + params.push("id", &self._id); + + params.extend(self._additional_params.iter()); + + let mut url = self.hub._base_url.clone() + "youtube/v3/comments"; + if self._scopes.is_empty() { + self._scopes.insert(Scope::ForceSsl.as_ref().to_string()); + } + + + let url = params.parse_with_url(&url); + + + + loop { + let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]).await { + Ok(token) => token, + Err(e) => { + match dlg.token(e) { + Ok(token) => token, + Err(e) => { + dlg.finished(false); + return Err(client::Error::MissingToken(e)); + } + } + } + }; + let mut req_result = { + let client = &self.hub.client; + dlg.pre_request(); + let mut req_builder = hyper::Request::builder() + .method(hyper::Method::DELETE) + .uri(url.as_str()) + .header(USER_AGENT, self.hub._user_agent.clone()); + + if let Some(token) = token.as_ref() { + req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); + } + + + let request = req_builder + .header(CONTENT_LENGTH, 0_u64) + .body(hyper::body::Body::empty()); + + client.request(request.unwrap()).await + + }; + + match req_result { + Err(err) => { + if let client::Retry::After(d) = dlg.http_error(&err) { + sleep(d).await; + continue; + } + dlg.finished(false); + return Err(client::Error::HttpError(err)) + } + Ok(mut res) => { + if !res.status().is_success() { + let res_body_string = client::get_body_as_string(res.body_mut()).await; + let (parts, _) = res.into_parts(); + let body = hyper::Body::from(res_body_string.clone()); + let restored_response = hyper::Response::from_parts(parts, body); + + let server_response = json::from_str::(&res_body_string).ok(); + + if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { + sleep(d).await; + continue; + } + + dlg.finished(false); + + return match server_response { + Some(error_value) => Err(client::Error::BadRequest(error_value)), + None => Err(client::Error::Failure(restored_response)), + } + } + let result_value = res; + + dlg.finished(true); + return Ok(result_value) + } + } + } + } + + + /// + /// 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) -> CommentDeleteCall<'a, S> { + 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. + /// + /// ````text + /// It should be used to handle progress information, and to implement a certain level of resilience. + /// ```` + /// + /// Sets the *delegate* property to the given value. + pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> CommentDeleteCall<'a, S> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not be used to set any of the known parameters + /// which have their own setter method. If done anyway, the request will fail. + /// + /// # Additional Parameters + /// + /// * *$.xgafv* (query-string) - V1 error format. + /// * *access_token* (query-string) - OAuth access token. + /// * *alt* (query-string) - Data format for response. + /// * *callback* (query-string) - JSONP + /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. + /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. + /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. + /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. + /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. + /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). + /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). + pub fn param(mut self, name: T, value: T) -> CommentDeleteCall<'a, S> + where T: AsRef { + self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); + self + } + + /// Identifies the authorization scope for the method you are building. + /// + /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant + /// [`Scope::ForceSsl`]. + /// + /// The `scope` will be added to a set of scopes. This is important as one can maintain access + /// tokens for more than one scope. + /// + /// Usually there is more than one suitable scope to authorize an operation, some of which may + /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be + /// sufficient, a read-write scope will do as well. + pub fn add_scope(mut self, scope: St) -> CommentDeleteCall<'a, S> + where St: AsRef { + self._scopes.insert(String::from(scope.as_ref())); + self + } + /// Identifies the authorization scope(s) for the method you are building. + /// + /// See [`Self::add_scope()`] for details. + pub fn add_scopes(mut self, scopes: I) -> CommentDeleteCall<'a, S> + where I: IntoIterator, + St: AsRef { + self._scopes + .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); + self + } + + /// Removes all scopes, and no default scope will be used either. + /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] + /// for details). + pub fn clear_scopes(mut self) -> CommentDeleteCall<'a, S> { + self._scopes.clear(); + self + } +} + + +/// Inserts a new resource into this collection. +/// +/// A builder for the *insert* method supported by a *comment* resource. +/// It is not used directly, but through a [`CommentMethods`] instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate hyper_rustls; +/// # extern crate google_youtube3 as youtube3; +/// use youtube3::api::Comment; +/// # async fn dox() { +/// # use std::default::Default; +/// # use youtube3::{YouTube, oauth2, hyper, hyper_rustls, chrono, FieldMask}; +/// +/// # let secret: oauth2::ApplicationSecret = Default::default(); +/// # let auth = oauth2::InstalledFlowAuthenticator::builder( +/// # secret, +/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, +/// # ).build().await.unwrap(); +/// # let mut hub = YouTube::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().unwrap().https_or_http().enable_http1().build()), auth); +/// // As the method needs a request, you would usually fill it with the desired information +/// // into the respective structure. Some of the parts shown here might not be applicable ! +/// // Values shown here are possibly random and not representative ! +/// let mut req = Comment::default(); +/// +/// // You can configure optional parameters by calling the respective setters at will, and +/// // execute the final call using `doit()`. +/// // Values shown here are possibly random and not representative ! +/// let result = hub.comments().insert(req) +/// .doit().await; +/// # } +/// ``` +pub struct CommentInsertCall<'a, S> + where S: 'a { + + pub(super) hub: &'a YouTube, + pub(super) _request: Comment, + pub(super) _part: Vec, + pub(super) _delegate: Option<&'a mut dyn client::Delegate>, + pub(super) _additional_params: HashMap, + pub(super) _scopes: BTreeSet +} + +impl<'a, S> client::CallBuilder for CommentInsertCall<'a, S> {} + +impl<'a, S> CommentInsertCall<'a, S> +where + S: tower_service::Service + Clone + Send + Sync + 'static, + S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, + S::Future: Send + Unpin + 'static, + S::Error: Into>, +{ + + + /// Perform the operation you have build so far. + pub async fn doit(mut self) -> client::Result<(hyper::Response, Comment)> { + use std::io::{Read, Seek}; + use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; + use client::{ToParts, url::Params}; + use std::borrow::Cow; + + let mut dd = client::DefaultDelegate; + let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd); + dlg.begin(client::MethodInfo { id: "youtube.comments.insert", + http_method: hyper::Method::POST }); + + for &field in ["alt", "part"].iter() { + if self._additional_params.contains_key(field) { + dlg.finished(false); + return Err(client::Error::FieldClash(field)); + } + } + + let mut params = Params::with_capacity(4 + self._additional_params.len()); + if self._part.is_empty() { + self._part.push(self._request.to_parts()); + } + if self._part.len() > 0 { + for f in self._part.iter() { + params.push("part", f); + } + } + + params.extend(self._additional_params.iter()); + + params.push("alt", "json"); + let mut url = self.hub._base_url.clone() + "youtube/v3/comments"; + if self._scopes.is_empty() { + self._scopes.insert(Scope::ForceSsl.as_ref().to_string()); + } + + + let url = params.parse_with_url(&url); + + let mut json_mime_type = mime::APPLICATION_JSON; + let mut request_value_reader = + { + let mut value = json::value::to_value(&self._request).expect("serde to work"); + client::remove_json_null_values(&mut value); + let mut dst = io::Cursor::new(Vec::with_capacity(128)); + json::to_writer(&mut dst, &value).unwrap(); + dst + }; + let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); + request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); + + + loop { + let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]).await { + Ok(token) => token, + Err(e) => { + match dlg.token(e) { + Ok(token) => token, + Err(e) => { + dlg.finished(false); + return Err(client::Error::MissingToken(e)); + } + } + } + }; + request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); + let mut req_result = { + let client = &self.hub.client; + dlg.pre_request(); + let mut req_builder = hyper::Request::builder() + .method(hyper::Method::POST) + .uri(url.as_str()) + .header(USER_AGENT, self.hub._user_agent.clone()); + + if let Some(token) = token.as_ref() { + req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); + } + + + let request = req_builder + .header(CONTENT_TYPE, json_mime_type.to_string()) + .header(CONTENT_LENGTH, request_size as u64) + .body(hyper::body::Body::from(request_value_reader.get_ref().clone())); + + client.request(request.unwrap()).await + + }; + + match req_result { + Err(err) => { + if let client::Retry::After(d) = dlg.http_error(&err) { + sleep(d).await; + continue; + } + dlg.finished(false); + return Err(client::Error::HttpError(err)) + } + Ok(mut res) => { + if !res.status().is_success() { + let res_body_string = client::get_body_as_string(res.body_mut()).await; + let (parts, _) = res.into_parts(); + let body = hyper::Body::from(res_body_string.clone()); + let restored_response = hyper::Response::from_parts(parts, body); + + let server_response = json::from_str::(&res_body_string).ok(); + + if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { + sleep(d).await; + continue; + } + + dlg.finished(false); + + return match server_response { + Some(error_value) => Err(client::Error::BadRequest(error_value)), + None => Err(client::Error::Failure(restored_response)), + } + } + let result_value = { + let res_body_string = client::get_body_as_string(res.body_mut()).await; + + match json::from_str(&res_body_string) { + Ok(decoded) => (res, decoded), + Err(err) => { + dlg.response_json_decode_error(&res_body_string, &err); + return Err(client::Error::JsonDecodeError(res_body_string, err)); + } + } + }; + + dlg.finished(true); + return Ok(result_value) + } + } + } + } + + + /// + /// Sets the *request* property to the given value. + /// + /// Even though the property as already been set when instantiating this call, + /// we provide this method for API completeness. + pub fn request(mut self, new_value: Comment) -> CommentInsertCall<'a, S> { + self._request = new_value; + self + } + /// The *part* parameter identifies the properties that the API response will include. Set the parameter value to snippet. The snippet part has a quota cost of 2 units. + /// + /// Append the given value to the *part* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + /// + /// Even though the *parts* list is automatically derived from *Resource* passed in + /// during instantiation and indicates which values you are passing, the response would contain the very same parts. + /// This may not always be desirable, as you can obtain (newly generated) parts you cannot pass in, + /// like statistics that are generated server side. Therefore you should use this method to specify + /// the parts you provide in addition to the ones you want in the response. + pub fn add_part(mut self, new_value: &str) -> CommentInsertCall<'a, S> { + self._part.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. + /// + /// ````text + /// It should be used to handle progress information, and to implement a certain level of resilience. + /// ```` + /// + /// Sets the *delegate* property to the given value. + pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> CommentInsertCall<'a, S> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not be used to set any of the known parameters + /// which have their own setter method. If done anyway, the request will fail. + /// + /// # Additional Parameters + /// + /// * *$.xgafv* (query-string) - V1 error format. + /// * *access_token* (query-string) - OAuth access token. + /// * *alt* (query-string) - Data format for response. + /// * *callback* (query-string) - JSONP + /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. + /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. + /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. + /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. + /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. + /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). + /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). + pub fn param(mut self, name: T, value: T) -> CommentInsertCall<'a, S> + where T: AsRef { + self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); + self + } + + /// Identifies the authorization scope for the method you are building. + /// + /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant + /// [`Scope::ForceSsl`]. + /// + /// The `scope` will be added to a set of scopes. This is important as one can maintain access + /// tokens for more than one scope. + /// + /// Usually there is more than one suitable scope to authorize an operation, some of which may + /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be + /// sufficient, a read-write scope will do as well. + pub fn add_scope(mut self, scope: St) -> CommentInsertCall<'a, S> + where St: AsRef { + self._scopes.insert(String::from(scope.as_ref())); + self + } + /// Identifies the authorization scope(s) for the method you are building. + /// + /// See [`Self::add_scope()`] for details. + pub fn add_scopes(mut self, scopes: I) -> CommentInsertCall<'a, S> + where I: IntoIterator, + St: AsRef { + self._scopes + .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); + self + } + + /// Removes all scopes, and no default scope will be used either. + /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] + /// for details). + pub fn clear_scopes(mut self) -> CommentInsertCall<'a, S> { + self._scopes.clear(); + self + } +} + + +/// Retrieves a list of resources, possibly filtered. +/// +/// A builder for the *list* method supported by a *comment* resource. +/// It is not used directly, but through a [`CommentMethods`] instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate hyper_rustls; +/// # extern crate google_youtube3 as youtube3; +/// # async fn dox() { +/// # use std::default::Default; +/// # use youtube3::{YouTube, oauth2, hyper, hyper_rustls, chrono, FieldMask}; +/// +/// # let secret: oauth2::ApplicationSecret = Default::default(); +/// # let auth = oauth2::InstalledFlowAuthenticator::builder( +/// # secret, +/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, +/// # ).build().await.unwrap(); +/// # let mut hub = YouTube::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().unwrap().https_or_http().enable_http1().build()), auth); +/// // You can configure optional parameters by calling the respective setters at will, and +/// // execute the final call using `doit()`. +/// // Values shown here are possibly random and not representative ! +/// let result = hub.comments().list(&vec!["tempor".into()]) +/// .text_format(&Default::default()) +/// .parent_id("aliquyam") +/// .page_token("ipsum") +/// .max_results(83) +/// .add_id("sanctus") +/// .doit().await; +/// # } +/// ``` +pub struct CommentListCall<'a, S> + where S: 'a { + + pub(super) hub: &'a YouTube, + pub(super) _part: Vec, + pub(super) _text_format: Option, + pub(super) _parent_id: Option, + pub(super) _page_token: Option, + pub(super) _max_results: Option, + pub(super) _id: Vec, + pub(super) _delegate: Option<&'a mut dyn client::Delegate>, + pub(super) _additional_params: HashMap, + pub(super) _scopes: BTreeSet +} + +impl<'a, S> client::CallBuilder for CommentListCall<'a, S> {} + +impl<'a, S> CommentListCall<'a, S> +where + S: tower_service::Service + Clone + Send + Sync + 'static, + S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, + S::Future: Send + Unpin + 'static, + S::Error: Into>, +{ + + + /// Perform the operation you have build so far. + pub async fn doit(mut self) -> client::Result<(hyper::Response, CommentListResponse)> { + use std::io::{Read, Seek}; + use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; + use client::{ToParts, url::Params}; + use std::borrow::Cow; + + let mut dd = client::DefaultDelegate; + let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd); + dlg.begin(client::MethodInfo { id: "youtube.comments.list", + http_method: hyper::Method::GET }); + + for &field in ["alt", "part", "textFormat", "parentId", "pageToken", "maxResults", "id"].iter() { + if self._additional_params.contains_key(field) { + dlg.finished(false); + return Err(client::Error::FieldClash(field)); + } + } + + let mut params = Params::with_capacity(8 + self._additional_params.len()); + if self._part.len() > 0 { + for f in self._part.iter() { + params.push("part", f); + } + } + if let Some(value) = self._text_format.as_ref() { + params.push("textFormat", value); + } + if let Some(value) = self._parent_id.as_ref() { + params.push("parentId", value); + } + if let Some(value) = self._page_token.as_ref() { + params.push("pageToken", value); + } + if let Some(value) = self._max_results.as_ref() { + params.push("maxResults", value.to_string()); + } + if self._id.len() > 0 { + for f in self._id.iter() { + params.push("id", f); + } + } + + params.extend(self._additional_params.iter()); + + params.push("alt", "json"); + let mut url = self.hub._base_url.clone() + "youtube/v3/comments"; + if self._scopes.is_empty() { + self._scopes.insert(Scope::ForceSsl.as_ref().to_string()); + } + + + let url = params.parse_with_url(&url); + + + + loop { + let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]).await { + Ok(token) => token, + Err(e) => { + match dlg.token(e) { + Ok(token) => token, + Err(e) => { + dlg.finished(false); + return Err(client::Error::MissingToken(e)); + } + } + } + }; + let mut req_result = { + let client = &self.hub.client; + dlg.pre_request(); + let mut req_builder = hyper::Request::builder() + .method(hyper::Method::GET) + .uri(url.as_str()) + .header(USER_AGENT, self.hub._user_agent.clone()); + + if let Some(token) = token.as_ref() { + req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); + } + + + let request = req_builder + .header(CONTENT_LENGTH, 0_u64) + .body(hyper::body::Body::empty()); + + client.request(request.unwrap()).await + + }; + + match req_result { + Err(err) => { + if let client::Retry::After(d) = dlg.http_error(&err) { + sleep(d).await; + continue; + } + dlg.finished(false); + return Err(client::Error::HttpError(err)) + } + Ok(mut res) => { + if !res.status().is_success() { + let res_body_string = client::get_body_as_string(res.body_mut()).await; + let (parts, _) = res.into_parts(); + let body = hyper::Body::from(res_body_string.clone()); + let restored_response = hyper::Response::from_parts(parts, body); + + let server_response = json::from_str::(&res_body_string).ok(); + + if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { + sleep(d).await; + continue; + } + + dlg.finished(false); + + return match server_response { + Some(error_value) => Err(client::Error::BadRequest(error_value)), + None => Err(client::Error::Failure(restored_response)), + } + } + let result_value = { + let res_body_string = client::get_body_as_string(res.body_mut()).await; + + match json::from_str(&res_body_string) { + Ok(decoded) => (res, decoded), + Err(err) => { + dlg.response_json_decode_error(&res_body_string, &err); + return Err(client::Error::JsonDecodeError(res_body_string, err)); + } + } + }; + + dlg.finished(true); + return Ok(result_value) + } + } + } + } + + + /// The *part* parameter specifies a comma-separated list of one or more comment resource properties that the API response will include. + /// + /// Append the given value to the *part* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + /// + /// Even though the property as already been set when instantiating this call, + /// we provide this method for API completeness. + pub fn add_part(mut self, new_value: &str) -> CommentListCall<'a, S> { + self._part.push(new_value.to_string()); + self + } + /// The requested text format for the returned comments. + /// + /// Sets the *text format* query property to the given value. + pub fn text_format(mut self, new_value: &CommentTextFormatEnum) -> CommentListCall<'a, S> { + self._text_format = Some(new_value.clone()); + self + } + /// Returns replies to the specified comment. Note, currently YouTube features only one level of replies (ie replies to top level comments). However replies to replies may be supported in the future. + /// + /// Sets the *parent id* query property to the given value. + pub fn parent_id(mut self, new_value: &str) -> CommentListCall<'a, S> { + self._parent_id = Some(new_value.to_string()); + self + } + /// The *pageToken* parameter identifies a specific page in the result set that should be returned. In an API response, the nextPageToken and prevPageToken properties identify other pages that could be retrieved. + /// + /// Sets the *page token* query property to the given value. + pub fn page_token(mut self, new_value: &str) -> CommentListCall<'a, S> { + self._page_token = Some(new_value.to_string()); + self + } + /// The *maxResults* parameter specifies the maximum number of items that should be returned in the result set. + /// + /// Sets the *max results* query property to the given value. + pub fn max_results(mut self, new_value: u32) -> CommentListCall<'a, S> { + self._max_results = Some(new_value); + self + } + /// Returns the comments with the given IDs for One Platform. + /// + /// Append the given value to the *id* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + pub fn add_id(mut self, new_value: &str) -> CommentListCall<'a, S> { + self._id.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. + /// + /// ````text + /// It should be used to handle progress information, and to implement a certain level of resilience. + /// ```` + /// + /// Sets the *delegate* property to the given value. + pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> CommentListCall<'a, S> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not be used to set any of the known parameters + /// which have their own setter method. If done anyway, the request will fail. + /// + /// # Additional Parameters + /// + /// * *$.xgafv* (query-string) - V1 error format. + /// * *access_token* (query-string) - OAuth access token. + /// * *alt* (query-string) - Data format for response. + /// * *callback* (query-string) - JSONP + /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. + /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. + /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. + /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. + /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. + /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). + /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). + pub fn param(mut self, name: T, value: T) -> CommentListCall<'a, S> + where T: AsRef { + self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); + self + } + + /// Identifies the authorization scope for the method you are building. + /// + /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant + /// [`Scope::ForceSsl`]. + /// + /// The `scope` will be added to a set of scopes. This is important as one can maintain access + /// tokens for more than one scope. + /// + /// Usually there is more than one suitable scope to authorize an operation, some of which may + /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be + /// sufficient, a read-write scope will do as well. + pub fn add_scope(mut self, scope: St) -> CommentListCall<'a, S> + where St: AsRef { + self._scopes.insert(String::from(scope.as_ref())); + self + } + /// Identifies the authorization scope(s) for the method you are building. + /// + /// See [`Self::add_scope()`] for details. + pub fn add_scopes(mut self, scopes: I) -> CommentListCall<'a, S> + where I: IntoIterator, + St: AsRef { + self._scopes + .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); + self + } + + /// Removes all scopes, and no default scope will be used either. + /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] + /// for details). + pub fn clear_scopes(mut self) -> CommentListCall<'a, S> { + self._scopes.clear(); + self + } +} + + +/// Expresses the caller's opinion that one or more comments should be flagged as spam. +/// +/// A builder for the *markAsSpam* method supported by a *comment* resource. +/// It is not used directly, but through a [`CommentMethods`] instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate hyper_rustls; +/// # extern crate google_youtube3 as youtube3; +/// # async fn dox() { +/// # use std::default::Default; +/// # use youtube3::{YouTube, oauth2, hyper, hyper_rustls, chrono, FieldMask}; +/// +/// # let secret: oauth2::ApplicationSecret = Default::default(); +/// # let auth = oauth2::InstalledFlowAuthenticator::builder( +/// # secret, +/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, +/// # ).build().await.unwrap(); +/// # let mut hub = YouTube::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().unwrap().https_or_http().enable_http1().build()), auth); +/// // You can configure optional parameters by calling the respective setters at will, and +/// // execute the final call using `doit()`. +/// // Values shown here are possibly random and not representative ! +/// let result = hub.comments().mark_as_spam(&vec!["Lorem".into()]) +/// .doit().await; +/// # } +/// ``` +pub struct CommentMarkAsSpamCall<'a, S> + where S: 'a { + + pub(super) hub: &'a YouTube, + pub(super) _id: Vec, + pub(super) _delegate: Option<&'a mut dyn client::Delegate>, + pub(super) _additional_params: HashMap, + pub(super) _scopes: BTreeSet +} + +impl<'a, S> client::CallBuilder for CommentMarkAsSpamCall<'a, S> {} + +impl<'a, S> CommentMarkAsSpamCall<'a, S> +where + S: tower_service::Service + Clone + Send + Sync + 'static, + S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, + S::Future: Send + Unpin + 'static, + S::Error: Into>, +{ + + + /// Perform the operation you have build so far. + pub async fn doit(mut self) -> client::Result> { + use std::io::{Read, Seek}; + use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; + use client::{ToParts, url::Params}; + use std::borrow::Cow; + + let mut dd = client::DefaultDelegate; + let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd); + dlg.begin(client::MethodInfo { id: "youtube.comments.markAsSpam", + http_method: hyper::Method::POST }); + + for &field in ["id"].iter() { + if self._additional_params.contains_key(field) { + dlg.finished(false); + return Err(client::Error::FieldClash(field)); + } + } + + let mut params = Params::with_capacity(2 + self._additional_params.len()); + if self._id.len() > 0 { + for f in self._id.iter() { + params.push("id", f); + } + } + + params.extend(self._additional_params.iter()); + + let mut url = self.hub._base_url.clone() + "youtube/v3/comments/markAsSpam"; + if self._scopes.is_empty() { + self._scopes.insert(Scope::ForceSsl.as_ref().to_string()); + } + + + let url = params.parse_with_url(&url); + + + + loop { + let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]).await { + Ok(token) => token, + Err(e) => { + match dlg.token(e) { + Ok(token) => token, + Err(e) => { + dlg.finished(false); + return Err(client::Error::MissingToken(e)); + } + } + } + }; + let mut req_result = { + let client = &self.hub.client; + dlg.pre_request(); + let mut req_builder = hyper::Request::builder() + .method(hyper::Method::POST) + .uri(url.as_str()) + .header(USER_AGENT, self.hub._user_agent.clone()); + + if let Some(token) = token.as_ref() { + req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); + } + + + let request = req_builder + .header(CONTENT_LENGTH, 0_u64) + .body(hyper::body::Body::empty()); + + client.request(request.unwrap()).await + + }; + + match req_result { + Err(err) => { + if let client::Retry::After(d) = dlg.http_error(&err) { + sleep(d).await; + continue; + } + dlg.finished(false); + return Err(client::Error::HttpError(err)) + } + Ok(mut res) => { + if !res.status().is_success() { + let res_body_string = client::get_body_as_string(res.body_mut()).await; + let (parts, _) = res.into_parts(); + let body = hyper::Body::from(res_body_string.clone()); + let restored_response = hyper::Response::from_parts(parts, body); + + let server_response = json::from_str::(&res_body_string).ok(); + + if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { + sleep(d).await; + continue; + } + + dlg.finished(false); + + return match server_response { + Some(error_value) => Err(client::Error::BadRequest(error_value)), + None => Err(client::Error::Failure(restored_response)), + } + } + let result_value = res; + + dlg.finished(true); + return Ok(result_value) + } + } + } + } + + + /// Flags the comments with the given IDs as spam in the caller's opinion. + /// + /// Append the given value to the *id* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + /// + /// Even though the property as already been set when instantiating this call, + /// we provide this method for API completeness. + pub fn add_id(mut self, new_value: &str) -> CommentMarkAsSpamCall<'a, S> { + self._id.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. + /// + /// ````text + /// It should be used to handle progress information, and to implement a certain level of resilience. + /// ```` + /// + /// Sets the *delegate* property to the given value. + pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> CommentMarkAsSpamCall<'a, S> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not be used to set any of the known parameters + /// which have their own setter method. If done anyway, the request will fail. + /// + /// # Additional Parameters + /// + /// * *$.xgafv* (query-string) - V1 error format. + /// * *access_token* (query-string) - OAuth access token. + /// * *alt* (query-string) - Data format for response. + /// * *callback* (query-string) - JSONP + /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. + /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. + /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. + /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. + /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. + /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). + /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). + pub fn param(mut self, name: T, value: T) -> CommentMarkAsSpamCall<'a, S> + where T: AsRef { + self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); + self + } + + /// Identifies the authorization scope for the method you are building. + /// + /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant + /// [`Scope::ForceSsl`]. + /// + /// The `scope` will be added to a set of scopes. This is important as one can maintain access + /// tokens for more than one scope. + /// + /// Usually there is more than one suitable scope to authorize an operation, some of which may + /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be + /// sufficient, a read-write scope will do as well. + pub fn add_scope(mut self, scope: St) -> CommentMarkAsSpamCall<'a, S> + where St: AsRef { + self._scopes.insert(String::from(scope.as_ref())); + self + } + /// Identifies the authorization scope(s) for the method you are building. + /// + /// See [`Self::add_scope()`] for details. + pub fn add_scopes(mut self, scopes: I) -> CommentMarkAsSpamCall<'a, S> + where I: IntoIterator, + St: AsRef { + self._scopes + .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); + self + } + + /// Removes all scopes, and no default scope will be used either. + /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] + /// for details). + pub fn clear_scopes(mut self) -> CommentMarkAsSpamCall<'a, S> { + self._scopes.clear(); + self + } +} + + +/// Sets the moderation status of one or more comments. +/// +/// A builder for the *setModerationStatus* method supported by a *comment* resource. +/// It is not used directly, but through a [`CommentMethods`] instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate hyper_rustls; +/// # extern crate google_youtube3 as youtube3; +/// # async fn dox() { +/// # use std::default::Default; +/// # use youtube3::{YouTube, oauth2, hyper, hyper_rustls, chrono, FieldMask}; +/// +/// # let secret: oauth2::ApplicationSecret = Default::default(); +/// # let auth = oauth2::InstalledFlowAuthenticator::builder( +/// # secret, +/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, +/// # ).build().await.unwrap(); +/// # let mut hub = YouTube::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().unwrap().https_or_http().enable_http1().build()), auth); +/// // You can configure optional parameters by calling the respective setters at will, and +/// // execute the final call using `doit()`. +/// // Values shown here are possibly random and not representative ! +/// let result = hub.comments().set_moderation_status(&vec!["est".into()], &Default::default()) +/// .ban_author(true) +/// .doit().await; +/// # } +/// ``` +pub struct CommentSetModerationStatusCall<'a, S> + where S: 'a { + + pub(super) hub: &'a YouTube, + pub(super) _id: Vec, + pub(super) _moderation_status: CommentModerationStatusEnum, + pub(super) _ban_author: Option, + pub(super) _delegate: Option<&'a mut dyn client::Delegate>, + pub(super) _additional_params: HashMap, + pub(super) _scopes: BTreeSet +} + +impl<'a, S> client::CallBuilder for CommentSetModerationStatusCall<'a, S> {} + +impl<'a, S> CommentSetModerationStatusCall<'a, S> +where + S: tower_service::Service + Clone + Send + Sync + 'static, + S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, + S::Future: Send + Unpin + 'static, + S::Error: Into>, +{ + + + /// Perform the operation you have build so far. + pub async fn doit(mut self) -> client::Result> { + use std::io::{Read, Seek}; + use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; + use client::{ToParts, url::Params}; + use std::borrow::Cow; + + let mut dd = client::DefaultDelegate; + let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd); + dlg.begin(client::MethodInfo { id: "youtube.comments.setModerationStatus", + http_method: hyper::Method::POST }); + + for &field in ["id", "moderationStatus", "banAuthor"].iter() { + if self._additional_params.contains_key(field) { + dlg.finished(false); + return Err(client::Error::FieldClash(field)); + } + } + + let mut params = Params::with_capacity(4 + self._additional_params.len()); + if self._id.len() > 0 { + for f in self._id.iter() { + params.push("id", f); + } + } + params.push("moderationStatus", &self._moderation_status); + if let Some(value) = self._ban_author.as_ref() { + params.push("banAuthor", value.to_string()); + } + + params.extend(self._additional_params.iter()); + + let mut url = self.hub._base_url.clone() + "youtube/v3/comments/setModerationStatus"; + if self._scopes.is_empty() { + self._scopes.insert(Scope::ForceSsl.as_ref().to_string()); + } + + + let url = params.parse_with_url(&url); + + + + loop { + let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]).await { + Ok(token) => token, + Err(e) => { + match dlg.token(e) { + Ok(token) => token, + Err(e) => { + dlg.finished(false); + return Err(client::Error::MissingToken(e)); + } + } + } + }; + let mut req_result = { + let client = &self.hub.client; + dlg.pre_request(); + let mut req_builder = hyper::Request::builder() + .method(hyper::Method::POST) + .uri(url.as_str()) + .header(USER_AGENT, self.hub._user_agent.clone()); + + if let Some(token) = token.as_ref() { + req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); + } + + + let request = req_builder + .header(CONTENT_LENGTH, 0_u64) + .body(hyper::body::Body::empty()); + + client.request(request.unwrap()).await + + }; + + match req_result { + Err(err) => { + if let client::Retry::After(d) = dlg.http_error(&err) { + sleep(d).await; + continue; + } + dlg.finished(false); + return Err(client::Error::HttpError(err)) + } + Ok(mut res) => { + if !res.status().is_success() { + let res_body_string = client::get_body_as_string(res.body_mut()).await; + let (parts, _) = res.into_parts(); + let body = hyper::Body::from(res_body_string.clone()); + let restored_response = hyper::Response::from_parts(parts, body); + + let server_response = json::from_str::(&res_body_string).ok(); + + if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { + sleep(d).await; + continue; + } + + dlg.finished(false); + + return match server_response { + Some(error_value) => Err(client::Error::BadRequest(error_value)), + None => Err(client::Error::Failure(restored_response)), + } + } + let result_value = res; + + dlg.finished(true); + return Ok(result_value) + } + } + } + } + + + /// Modifies the moderation status of the comments with the given IDs + /// + /// Append the given value to the *id* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + /// + /// Even though the property as already been set when instantiating this call, + /// we provide this method for API completeness. + pub fn add_id(mut self, new_value: &str) -> CommentSetModerationStatusCall<'a, S> { + self._id.push(new_value.to_string()); + self + } + /// Specifies the requested moderation status. Note, comments can be in statuses, which are not available through this call. For example, this call does not allow to mark a comment as 'likely spam'. Valid values: 'heldForReview', 'published' or 'rejected'. + /// + /// Sets the *moderation status* 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 moderation_status(mut self, new_value: &CommentModerationStatusEnum) -> CommentSetModerationStatusCall<'a, S> { + self._moderation_status = new_value.clone(); + self + } + /// If set to true the author of the comment gets added to the ban list. This means all future comments of the author will autmomatically be rejected. Only valid in combination with STATUS_REJECTED. + /// + /// Sets the *ban author* query property to the given value. + pub fn ban_author(mut self, new_value: bool) -> CommentSetModerationStatusCall<'a, S> { + self._ban_author = 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. + /// + /// ````text + /// It should be used to handle progress information, and to implement a certain level of resilience. + /// ```` + /// + /// Sets the *delegate* property to the given value. + pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> CommentSetModerationStatusCall<'a, S> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not be used to set any of the known parameters + /// which have their own setter method. If done anyway, the request will fail. + /// + /// # Additional Parameters + /// + /// * *$.xgafv* (query-string) - V1 error format. + /// * *access_token* (query-string) - OAuth access token. + /// * *alt* (query-string) - Data format for response. + /// * *callback* (query-string) - JSONP + /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. + /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. + /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. + /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. + /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. + /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). + /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). + pub fn param(mut self, name: T, value: T) -> CommentSetModerationStatusCall<'a, S> + where T: AsRef { + self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); + self + } + + /// Identifies the authorization scope for the method you are building. + /// + /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant + /// [`Scope::ForceSsl`]. + /// + /// The `scope` will be added to a set of scopes. This is important as one can maintain access + /// tokens for more than one scope. + /// + /// Usually there is more than one suitable scope to authorize an operation, some of which may + /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be + /// sufficient, a read-write scope will do as well. + pub fn add_scope(mut self, scope: St) -> CommentSetModerationStatusCall<'a, S> + where St: AsRef { + self._scopes.insert(String::from(scope.as_ref())); + self + } + /// Identifies the authorization scope(s) for the method you are building. + /// + /// See [`Self::add_scope()`] for details. + pub fn add_scopes(mut self, scopes: I) -> CommentSetModerationStatusCall<'a, S> + where I: IntoIterator, + St: AsRef { + self._scopes + .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); + self + } + + /// Removes all scopes, and no default scope will be used either. + /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] + /// for details). + pub fn clear_scopes(mut self) -> CommentSetModerationStatusCall<'a, S> { + self._scopes.clear(); + self + } +} + + +/// Updates an existing resource. +/// +/// A builder for the *update* method supported by a *comment* resource. +/// It is not used directly, but through a [`CommentMethods`] instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate hyper_rustls; +/// # extern crate google_youtube3 as youtube3; +/// use youtube3::api::Comment; +/// # async fn dox() { +/// # use std::default::Default; +/// # use youtube3::{YouTube, oauth2, hyper, hyper_rustls, chrono, FieldMask}; +/// +/// # let secret: oauth2::ApplicationSecret = Default::default(); +/// # let auth = oauth2::InstalledFlowAuthenticator::builder( +/// # secret, +/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, +/// # ).build().await.unwrap(); +/// # let mut hub = YouTube::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().unwrap().https_or_http().enable_http1().build()), auth); +/// // As the method needs a request, you would usually fill it with the desired information +/// // into the respective structure. Some of the parts shown here might not be applicable ! +/// // Values shown here are possibly random and not representative ! +/// let mut req = Comment::default(); +/// +/// // You can configure optional parameters by calling the respective setters at will, and +/// // execute the final call using `doit()`. +/// // Values shown here are possibly random and not representative ! +/// let result = hub.comments().update(req) +/// .doit().await; +/// # } +/// ``` +pub struct CommentUpdateCall<'a, S> + where S: 'a { + + pub(super) hub: &'a YouTube, + pub(super) _request: Comment, + pub(super) _part: Vec, + pub(super) _delegate: Option<&'a mut dyn client::Delegate>, + pub(super) _additional_params: HashMap, + pub(super) _scopes: BTreeSet +} + +impl<'a, S> client::CallBuilder for CommentUpdateCall<'a, S> {} + +impl<'a, S> CommentUpdateCall<'a, S> +where + S: tower_service::Service + Clone + Send + Sync + 'static, + S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, + S::Future: Send + Unpin + 'static, + S::Error: Into>, +{ + + + /// Perform the operation you have build so far. + pub async fn doit(mut self) -> client::Result<(hyper::Response, Comment)> { + use std::io::{Read, Seek}; + use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; + use client::{ToParts, url::Params}; + use std::borrow::Cow; + + let mut dd = client::DefaultDelegate; + let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd); + dlg.begin(client::MethodInfo { id: "youtube.comments.update", + http_method: hyper::Method::PUT }); + + for &field in ["alt", "part"].iter() { + if self._additional_params.contains_key(field) { + dlg.finished(false); + return Err(client::Error::FieldClash(field)); + } + } + + let mut params = Params::with_capacity(4 + self._additional_params.len()); + if self._part.is_empty() { + self._part.push(self._request.to_parts()); + } + if self._part.len() > 0 { + for f in self._part.iter() { + params.push("part", f); + } + } + + params.extend(self._additional_params.iter()); + + params.push("alt", "json"); + let mut url = self.hub._base_url.clone() + "youtube/v3/comments"; + if self._scopes.is_empty() { + self._scopes.insert(Scope::ForceSsl.as_ref().to_string()); + } + + + let url = params.parse_with_url(&url); + + let mut json_mime_type = mime::APPLICATION_JSON; + let mut request_value_reader = + { + let mut value = json::value::to_value(&self._request).expect("serde to work"); + client::remove_json_null_values(&mut value); + let mut dst = io::Cursor::new(Vec::with_capacity(128)); + json::to_writer(&mut dst, &value).unwrap(); + dst + }; + let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); + request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); + + + loop { + let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]).await { + Ok(token) => token, + Err(e) => { + match dlg.token(e) { + Ok(token) => token, + Err(e) => { + dlg.finished(false); + return Err(client::Error::MissingToken(e)); + } + } + } + }; + request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); + let mut req_result = { + let client = &self.hub.client; + dlg.pre_request(); + let mut req_builder = hyper::Request::builder() + .method(hyper::Method::PUT) + .uri(url.as_str()) + .header(USER_AGENT, self.hub._user_agent.clone()); + + if let Some(token) = token.as_ref() { + req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); + } + + + let request = req_builder + .header(CONTENT_TYPE, json_mime_type.to_string()) + .header(CONTENT_LENGTH, request_size as u64) + .body(hyper::body::Body::from(request_value_reader.get_ref().clone())); + + client.request(request.unwrap()).await + + }; + + match req_result { + Err(err) => { + if let client::Retry::After(d) = dlg.http_error(&err) { + sleep(d).await; + continue; + } + dlg.finished(false); + return Err(client::Error::HttpError(err)) + } + Ok(mut res) => { + if !res.status().is_success() { + let res_body_string = client::get_body_as_string(res.body_mut()).await; + let (parts, _) = res.into_parts(); + let body = hyper::Body::from(res_body_string.clone()); + let restored_response = hyper::Response::from_parts(parts, body); + + let server_response = json::from_str::(&res_body_string).ok(); + + if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { + sleep(d).await; + continue; + } + + dlg.finished(false); + + return match server_response { + Some(error_value) => Err(client::Error::BadRequest(error_value)), + None => Err(client::Error::Failure(restored_response)), + } + } + let result_value = { + let res_body_string = client::get_body_as_string(res.body_mut()).await; + + match json::from_str(&res_body_string) { + Ok(decoded) => (res, decoded), + Err(err) => { + dlg.response_json_decode_error(&res_body_string, &err); + return Err(client::Error::JsonDecodeError(res_body_string, err)); + } + } + }; + + dlg.finished(true); + return Ok(result_value) + } + } + } + } + + + /// + /// Sets the *request* property to the given value. + /// + /// Even though the property as already been set when instantiating this call, + /// we provide this method for API completeness. + pub fn request(mut self, new_value: Comment) -> CommentUpdateCall<'a, S> { + self._request = new_value; + self + } + /// The *part* parameter identifies the properties that the API response will include. You must at least include the snippet part in the parameter value since that part contains all of the properties that the API request can update. + /// + /// Append the given value to the *part* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + /// + /// Even though the *parts* list is automatically derived from *Resource* passed in + /// during instantiation and indicates which values you are passing, the response would contain the very same parts. + /// This may not always be desirable, as you can obtain (newly generated) parts you cannot pass in, + /// like statistics that are generated server side. Therefore you should use this method to specify + /// the parts you provide in addition to the ones you want in the response. + pub fn add_part(mut self, new_value: &str) -> CommentUpdateCall<'a, S> { + self._part.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. + /// + /// ````text + /// It should be used to handle progress information, and to implement a certain level of resilience. + /// ```` + /// + /// Sets the *delegate* property to the given value. + pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> CommentUpdateCall<'a, S> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not be used to set any of the known parameters + /// which have their own setter method. If done anyway, the request will fail. + /// + /// # Additional Parameters + /// + /// * *$.xgafv* (query-string) - V1 error format. + /// * *access_token* (query-string) - OAuth access token. + /// * *alt* (query-string) - Data format for response. + /// * *callback* (query-string) - JSONP + /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. + /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. + /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. + /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. + /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. + /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). + /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). + pub fn param(mut self, name: T, value: T) -> CommentUpdateCall<'a, S> + where T: AsRef { + self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); + self + } + + /// Identifies the authorization scope for the method you are building. + /// + /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant + /// [`Scope::ForceSsl`]. + /// + /// The `scope` will be added to a set of scopes. This is important as one can maintain access + /// tokens for more than one scope. + /// + /// Usually there is more than one suitable scope to authorize an operation, some of which may + /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be + /// sufficient, a read-write scope will do as well. + pub fn add_scope(mut self, scope: St) -> CommentUpdateCall<'a, S> + where St: AsRef { + self._scopes.insert(String::from(scope.as_ref())); + self + } + /// Identifies the authorization scope(s) for the method you are building. + /// + /// See [`Self::add_scope()`] for details. + pub fn add_scopes(mut self, scopes: I) -> CommentUpdateCall<'a, S> + where I: IntoIterator, + St: AsRef { + self._scopes + .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); + self + } + + /// Removes all scopes, and no default scope will be used either. + /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] + /// for details). + pub fn clear_scopes(mut self) -> CommentUpdateCall<'a, S> { + self._scopes.clear(); + self + } +} + + +/// Retrieves a list of resources, possibly filtered. +/// +/// A builder for the *list* method supported by a *i18nLanguage* resource. +/// It is not used directly, but through a [`I18nLanguageMethods`] instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate hyper_rustls; +/// # extern crate google_youtube3 as youtube3; +/// # async fn dox() { +/// # use std::default::Default; +/// # use youtube3::{YouTube, oauth2, hyper, hyper_rustls, chrono, FieldMask}; +/// +/// # let secret: oauth2::ApplicationSecret = Default::default(); +/// # let auth = oauth2::InstalledFlowAuthenticator::builder( +/// # secret, +/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, +/// # ).build().await.unwrap(); +/// # let mut hub = YouTube::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().unwrap().https_or_http().enable_http1().build()), auth); +/// // You can configure optional parameters by calling the respective setters at will, and +/// // execute the final call using `doit()`. +/// // Values shown here are possibly random and not representative ! +/// let result = hub.i18n_languages().list(&vec!["et".into()]) +/// .hl("sed") +/// .doit().await; +/// # } +/// ``` +pub struct I18nLanguageListCall<'a, S> + where S: 'a { + + pub(super) hub: &'a YouTube, + pub(super) _part: Vec, + pub(super) _hl: Option, + pub(super) _delegate: Option<&'a mut dyn client::Delegate>, + pub(super) _additional_params: HashMap, + pub(super) _scopes: BTreeSet +} + +impl<'a, S> client::CallBuilder for I18nLanguageListCall<'a, S> {} + +impl<'a, S> I18nLanguageListCall<'a, S> +where + S: tower_service::Service + Clone + Send + Sync + 'static, + S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, + S::Future: Send + Unpin + 'static, + S::Error: Into>, +{ + + + /// Perform the operation you have build so far. + pub async fn doit(mut self) -> client::Result<(hyper::Response, I18nLanguageListResponse)> { + use std::io::{Read, Seek}; + use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; + use client::{ToParts, url::Params}; + use std::borrow::Cow; + + let mut dd = client::DefaultDelegate; + let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd); + dlg.begin(client::MethodInfo { id: "youtube.i18nLanguages.list", + http_method: hyper::Method::GET }); + + for &field in ["alt", "part", "hl"].iter() { + if self._additional_params.contains_key(field) { + dlg.finished(false); + return Err(client::Error::FieldClash(field)); + } + } + + let mut params = Params::with_capacity(4 + self._additional_params.len()); + if self._part.len() > 0 { + for f in self._part.iter() { + params.push("part", f); + } + } + if let Some(value) = self._hl.as_ref() { + params.push("hl", value); + } + + params.extend(self._additional_params.iter()); + + params.push("alt", "json"); + let mut url = self.hub._base_url.clone() + "youtube/v3/i18nLanguages"; + if self._scopes.is_empty() { + self._scopes.insert(Scope::Readonly.as_ref().to_string()); + } + + + let url = params.parse_with_url(&url); + + + + loop { + let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]).await { + Ok(token) => token, + Err(e) => { + match dlg.token(e) { + Ok(token) => token, + Err(e) => { + dlg.finished(false); + return Err(client::Error::MissingToken(e)); + } + } + } + }; + let mut req_result = { + let client = &self.hub.client; + dlg.pre_request(); + let mut req_builder = hyper::Request::builder() + .method(hyper::Method::GET) + .uri(url.as_str()) + .header(USER_AGENT, self.hub._user_agent.clone()); + + if let Some(token) = token.as_ref() { + req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); + } + + + let request = req_builder + .header(CONTENT_LENGTH, 0_u64) + .body(hyper::body::Body::empty()); + + client.request(request.unwrap()).await + + }; + + match req_result { + Err(err) => { + if let client::Retry::After(d) = dlg.http_error(&err) { + sleep(d).await; + continue; + } + dlg.finished(false); + return Err(client::Error::HttpError(err)) + } + Ok(mut res) => { + if !res.status().is_success() { + let res_body_string = client::get_body_as_string(res.body_mut()).await; + let (parts, _) = res.into_parts(); + let body = hyper::Body::from(res_body_string.clone()); + let restored_response = hyper::Response::from_parts(parts, body); + + let server_response = json::from_str::(&res_body_string).ok(); + + if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { + sleep(d).await; + continue; + } + + dlg.finished(false); + + return match server_response { + Some(error_value) => Err(client::Error::BadRequest(error_value)), + None => Err(client::Error::Failure(restored_response)), + } + } + let result_value = { + let res_body_string = client::get_body_as_string(res.body_mut()).await; + + match json::from_str(&res_body_string) { + Ok(decoded) => (res, decoded), + Err(err) => { + dlg.response_json_decode_error(&res_body_string, &err); + return Err(client::Error::JsonDecodeError(res_body_string, err)); + } + } + }; + + dlg.finished(true); + return Ok(result_value) + } + } + } + } + + + /// The *part* parameter specifies the i18nLanguage resource properties that the API response will include. Set the parameter value to snippet. + /// + /// Append the given value to the *part* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + /// + /// Even though the property as already been set when instantiating this call, + /// we provide this method for API completeness. + pub fn add_part(mut self, new_value: &str) -> I18nLanguageListCall<'a, S> { + self._part.push(new_value.to_string()); + self + } + /// + /// Sets the *hl* query property to the given value. + pub fn hl(mut self, new_value: &str) -> I18nLanguageListCall<'a, S> { + self._hl = 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. + /// + /// ````text + /// It should be used to handle progress information, and to implement a certain level of resilience. + /// ```` + /// + /// Sets the *delegate* property to the given value. + pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> I18nLanguageListCall<'a, S> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not be used to set any of the known parameters + /// which have their own setter method. If done anyway, the request will fail. + /// + /// # Additional Parameters + /// + /// * *$.xgafv* (query-string) - V1 error format. + /// * *access_token* (query-string) - OAuth access token. + /// * *alt* (query-string) - Data format for response. + /// * *callback* (query-string) - JSONP + /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. + /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. + /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. + /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. + /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. + /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). + /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). + pub fn param(mut self, name: T, value: T) -> I18nLanguageListCall<'a, S> + where T: AsRef { + self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); + self + } + + /// Identifies the authorization scope for the method you are building. + /// + /// Use this method to actively specify which scope should be used, instead of 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: St) -> I18nLanguageListCall<'a, S> + where St: AsRef { + self._scopes.insert(String::from(scope.as_ref())); + self + } + /// Identifies the authorization scope(s) for the method you are building. + /// + /// See [`Self::add_scope()`] for details. + pub fn add_scopes(mut self, scopes: I) -> I18nLanguageListCall<'a, S> + where I: IntoIterator, + St: AsRef { + self._scopes + .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); + self + } + + /// Removes all scopes, and no default scope will be used either. + /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] + /// for details). + pub fn clear_scopes(mut self) -> I18nLanguageListCall<'a, S> { + self._scopes.clear(); + self + } +} + + +/// Retrieves a list of resources, possibly filtered. +/// +/// A builder for the *list* method supported by a *i18nRegion* resource. +/// It is not used directly, but through a [`I18nRegionMethods`] instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate hyper_rustls; +/// # extern crate google_youtube3 as youtube3; +/// # async fn dox() { +/// # use std::default::Default; +/// # use youtube3::{YouTube, oauth2, hyper, hyper_rustls, chrono, FieldMask}; +/// +/// # let secret: oauth2::ApplicationSecret = Default::default(); +/// # let auth = oauth2::InstalledFlowAuthenticator::builder( +/// # secret, +/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, +/// # ).build().await.unwrap(); +/// # let mut hub = YouTube::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().unwrap().https_or_http().enable_http1().build()), auth); +/// // You can configure optional parameters by calling the respective setters at will, and +/// // execute the final call using `doit()`. +/// // Values shown here are possibly random and not representative ! +/// let result = hub.i18n_regions().list(&vec!["no".into()]) +/// .hl("et") +/// .doit().await; +/// # } +/// ``` +pub struct I18nRegionListCall<'a, S> + where S: 'a { + + pub(super) hub: &'a YouTube, + pub(super) _part: Vec, + pub(super) _hl: Option, + pub(super) _delegate: Option<&'a mut dyn client::Delegate>, + pub(super) _additional_params: HashMap, + pub(super) _scopes: BTreeSet +} + +impl<'a, S> client::CallBuilder for I18nRegionListCall<'a, S> {} + +impl<'a, S> I18nRegionListCall<'a, S> +where + S: tower_service::Service + Clone + Send + Sync + 'static, + S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, + S::Future: Send + Unpin + 'static, + S::Error: Into>, +{ + + + /// Perform the operation you have build so far. + pub async fn doit(mut self) -> client::Result<(hyper::Response, I18nRegionListResponse)> { + use std::io::{Read, Seek}; + use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; + use client::{ToParts, url::Params}; + use std::borrow::Cow; + + let mut dd = client::DefaultDelegate; + let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd); + dlg.begin(client::MethodInfo { id: "youtube.i18nRegions.list", + http_method: hyper::Method::GET }); + + for &field in ["alt", "part", "hl"].iter() { + if self._additional_params.contains_key(field) { + dlg.finished(false); + return Err(client::Error::FieldClash(field)); + } + } + + let mut params = Params::with_capacity(4 + self._additional_params.len()); + if self._part.len() > 0 { + for f in self._part.iter() { + params.push("part", f); + } + } + if let Some(value) = self._hl.as_ref() { + params.push("hl", value); + } + + params.extend(self._additional_params.iter()); + + params.push("alt", "json"); + let mut url = self.hub._base_url.clone() + "youtube/v3/i18nRegions"; + if self._scopes.is_empty() { + self._scopes.insert(Scope::Readonly.as_ref().to_string()); + } + + + let url = params.parse_with_url(&url); + + + + loop { + let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]).await { + Ok(token) => token, + Err(e) => { + match dlg.token(e) { + Ok(token) => token, + Err(e) => { + dlg.finished(false); + return Err(client::Error::MissingToken(e)); + } + } + } + }; + let mut req_result = { + let client = &self.hub.client; + dlg.pre_request(); + let mut req_builder = hyper::Request::builder() + .method(hyper::Method::GET) + .uri(url.as_str()) + .header(USER_AGENT, self.hub._user_agent.clone()); + + if let Some(token) = token.as_ref() { + req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); + } + + + let request = req_builder + .header(CONTENT_LENGTH, 0_u64) + .body(hyper::body::Body::empty()); + + client.request(request.unwrap()).await + + }; + + match req_result { + Err(err) => { + if let client::Retry::After(d) = dlg.http_error(&err) { + sleep(d).await; + continue; + } + dlg.finished(false); + return Err(client::Error::HttpError(err)) + } + Ok(mut res) => { + if !res.status().is_success() { + let res_body_string = client::get_body_as_string(res.body_mut()).await; + let (parts, _) = res.into_parts(); + let body = hyper::Body::from(res_body_string.clone()); + let restored_response = hyper::Response::from_parts(parts, body); + + let server_response = json::from_str::(&res_body_string).ok(); + + if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { + sleep(d).await; + continue; + } + + dlg.finished(false); + + return match server_response { + Some(error_value) => Err(client::Error::BadRequest(error_value)), + None => Err(client::Error::Failure(restored_response)), + } + } + let result_value = { + let res_body_string = client::get_body_as_string(res.body_mut()).await; + + match json::from_str(&res_body_string) { + Ok(decoded) => (res, decoded), + Err(err) => { + dlg.response_json_decode_error(&res_body_string, &err); + return Err(client::Error::JsonDecodeError(res_body_string, err)); + } + } + }; + + dlg.finished(true); + return Ok(result_value) + } + } + } + } + + + /// The *part* parameter specifies the i18nRegion resource properties that the API response will include. Set the parameter value to snippet. + /// + /// Append the given value to the *part* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + /// + /// Even though the property as already been set when instantiating this call, + /// we provide this method for API completeness. + pub fn add_part(mut self, new_value: &str) -> I18nRegionListCall<'a, S> { + self._part.push(new_value.to_string()); + self + } + /// + /// Sets the *hl* query property to the given value. + pub fn hl(mut self, new_value: &str) -> I18nRegionListCall<'a, S> { + self._hl = 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. + /// + /// ````text + /// It should be used to handle progress information, and to implement a certain level of resilience. + /// ```` + /// + /// Sets the *delegate* property to the given value. + pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> I18nRegionListCall<'a, S> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not be used to set any of the known parameters + /// which have their own setter method. If done anyway, the request will fail. + /// + /// # Additional Parameters + /// + /// * *$.xgafv* (query-string) - V1 error format. + /// * *access_token* (query-string) - OAuth access token. + /// * *alt* (query-string) - Data format for response. + /// * *callback* (query-string) - JSONP + /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. + /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. + /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. + /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. + /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. + /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). + /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). + pub fn param(mut self, name: T, value: T) -> I18nRegionListCall<'a, S> + where T: AsRef { + self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); + self + } + + /// Identifies the authorization scope for the method you are building. + /// + /// Use this method to actively specify which scope should be used, instead of 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: St) -> I18nRegionListCall<'a, S> + where St: AsRef { + self._scopes.insert(String::from(scope.as_ref())); + self + } + /// Identifies the authorization scope(s) for the method you are building. + /// + /// See [`Self::add_scope()`] for details. + pub fn add_scopes(mut self, scopes: I) -> I18nRegionListCall<'a, S> + where I: IntoIterator, + St: AsRef { + self._scopes + .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); + self + } + + /// Removes all scopes, and no default scope will be used either. + /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] + /// for details). + pub fn clear_scopes(mut self) -> I18nRegionListCall<'a, S> { + self._scopes.clear(); + self + } +} + + +/// Bind a broadcast to a stream. +/// +/// A builder for the *bind* method supported by a *liveBroadcast* resource. +/// It is not used directly, but through a [`LiveBroadcastMethods`] instance. +/// +/// **Settable Parts** +/// +/// * *id* +/// * *snippet* +/// * *contentDetails* +/// * *status* +/// +/// # Scopes +/// +/// You will need authorization for at least one of the following scopes to make a valid call, possibly depending on *parts*: +/// +/// * *https://www.googleapis.com/auth/youtube* +/// * *https://www.googleapis.com/auth/youtube.force-ssl* +/// +/// The default scope will be `Scope::Full`. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate hyper_rustls; +/// # extern crate google_youtube3 as youtube3; +/// # async fn dox() { +/// # use std::default::Default; +/// # use youtube3::{YouTube, oauth2, hyper, hyper_rustls, chrono, FieldMask}; +/// +/// # let secret: oauth2::ApplicationSecret = Default::default(); +/// # let auth = oauth2::InstalledFlowAuthenticator::builder( +/// # secret, +/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, +/// # ).build().await.unwrap(); +/// # let mut hub = YouTube::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().unwrap().https_or_http().enable_http1().build()), auth); +/// // You can configure optional parameters by calling 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().bind("id", &vec!["sed".into()]) +/// .stream_id("no") +/// .on_behalf_of_content_owner_channel("nonumy") +/// .on_behalf_of_content_owner("At") +/// .doit().await; +/// # } +/// ``` +pub struct LiveBroadcastBindCall<'a, S> + where S: 'a { + + pub(super) hub: &'a YouTube, + pub(super) _id: String, + pub(super) _part: Vec, + pub(super) _stream_id: Option, + pub(super) _on_behalf_of_content_owner_channel: Option, + pub(super) _on_behalf_of_content_owner: Option, + pub(super) _delegate: Option<&'a mut dyn client::Delegate>, + pub(super) _additional_params: HashMap, + pub(super) _scopes: BTreeSet +} + +impl<'a, S> client::CallBuilder for LiveBroadcastBindCall<'a, S> {} + +impl<'a, S> LiveBroadcastBindCall<'a, S> +where + S: tower_service::Service + Clone + Send + Sync + 'static, + S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, + S::Future: Send + Unpin + 'static, + S::Error: Into>, +{ + + + /// Perform the operation you have build so far. + pub async fn doit(mut self) -> client::Result<(hyper::Response, LiveBroadcast)> { + use std::io::{Read, Seek}; + use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; + use client::{ToParts, url::Params}; + use std::borrow::Cow; + + let mut dd = client::DefaultDelegate; + let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd); + dlg.begin(client::MethodInfo { id: "youtube.liveBroadcasts.bind", + http_method: hyper::Method::POST }); + + for &field in ["alt", "id", "part", "streamId", "onBehalfOfContentOwnerChannel", "onBehalfOfContentOwner"].iter() { + if self._additional_params.contains_key(field) { + dlg.finished(false); + return Err(client::Error::FieldClash(field)); + } + } + + let mut params = Params::with_capacity(7 + self._additional_params.len()); + params.push("id", &self._id); + if self._part.len() > 0 { + for f in self._part.iter() { + params.push("part", f); + } + } + if let Some(value) = self._stream_id.as_ref() { + params.push("streamId", value); + } + if let Some(value) = self._on_behalf_of_content_owner_channel.as_ref() { + params.push("onBehalfOfContentOwnerChannel", value); + } + if let Some(value) = self._on_behalf_of_content_owner.as_ref() { + params.push("onBehalfOfContentOwner", value); + } + + params.extend(self._additional_params.iter()); + + params.push("alt", "json"); + let mut url = self.hub._base_url.clone() + "youtube/v3/liveBroadcasts/bind"; + if self._scopes.is_empty() { + self._scopes.insert(Scope::Full.as_ref().to_string()); + } + + + let url = params.parse_with_url(&url); + + + + loop { + let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]).await { + Ok(token) => token, + Err(e) => { + match dlg.token(e) { + Ok(token) => token, + Err(e) => { + dlg.finished(false); + return Err(client::Error::MissingToken(e)); + } + } + } + }; + let mut req_result = { + let client = &self.hub.client; + dlg.pre_request(); + let mut req_builder = hyper::Request::builder() + .method(hyper::Method::POST) + .uri(url.as_str()) + .header(USER_AGENT, self.hub._user_agent.clone()); + + if let Some(token) = token.as_ref() { + req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); + } + + + let request = req_builder + .header(CONTENT_LENGTH, 0_u64) + .body(hyper::body::Body::empty()); + + client.request(request.unwrap()).await + + }; + + match req_result { + Err(err) => { + if let client::Retry::After(d) = dlg.http_error(&err) { + sleep(d).await; + continue; + } + dlg.finished(false); + return Err(client::Error::HttpError(err)) + } + Ok(mut res) => { + if !res.status().is_success() { + let res_body_string = client::get_body_as_string(res.body_mut()).await; + let (parts, _) = res.into_parts(); + let body = hyper::Body::from(res_body_string.clone()); + let restored_response = hyper::Response::from_parts(parts, body); + + let server_response = json::from_str::(&res_body_string).ok(); + + if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { + sleep(d).await; + continue; + } + + dlg.finished(false); + + return match server_response { + Some(error_value) => Err(client::Error::BadRequest(error_value)), + None => Err(client::Error::Failure(restored_response)), + } + } + let result_value = { + let res_body_string = client::get_body_as_string(res.body_mut()).await; + + match json::from_str(&res_body_string) { + Ok(decoded) => (res, decoded), + Err(err) => { + dlg.response_json_decode_error(&res_body_string, &err); + return Err(client::Error::JsonDecodeError(res_body_string, err)); + } + } + }; + + dlg.finished(true); + return Ok(result_value) + } + } + } + } + + + /// Broadcast to bind to the stream + /// + /// 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) -> LiveBroadcastBindCall<'a, S> { + self._id = new_value.to_string(); + self + } + /// The *part* parameter specifies a comma-separated list of one or more liveBroadcast resource properties that the API response will include. The part names that you can include in the parameter value are id, snippet, contentDetails, and status. + /// + /// Append the given value to the *part* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + /// + /// Even though the property as already been set when instantiating this call, + /// we provide this method for API completeness. + /// + /// **Settable Parts** + /// + /// * *id* + /// * *snippet* + /// * *contentDetails* + /// * *status* + pub fn add_part(mut self, new_value: &str) -> LiveBroadcastBindCall<'a, S> { + self._part.push(new_value.to_string()); + self + } + /// Stream to bind, if not set unbind the current one. + /// + /// Sets the *stream id* query property to the given value. + pub fn stream_id(mut self, new_value: &str) -> LiveBroadcastBindCall<'a, S> { + self._stream_id = Some(new_value.to_string()); + self + } + /// This parameter can only be used in a properly authorized request. *Note:* This parameter is intended exclusively for YouTube content partners. The *onBehalfOfContentOwnerChannel* parameter specifies the YouTube channel ID of the channel to which a video is being added. This parameter is required when a request specifies a value for the onBehalfOfContentOwner parameter, and it can only be used in conjunction with that parameter. In addition, the request must be authorized using a CMS account that is linked to the content owner that the onBehalfOfContentOwner parameter specifies. Finally, the channel that the onBehalfOfContentOwnerChannel parameter value specifies must be linked to the content owner that the onBehalfOfContentOwner parameter specifies. This parameter is intended for YouTube content partners that own and manage many different YouTube channels. It allows content owners to authenticate once and perform actions on behalf of the channel specified in the parameter value, without having to provide authentication credentials for each separate channel. + /// + /// Sets the *on behalf of content owner channel* query property to the given value. + pub fn on_behalf_of_content_owner_channel(mut self, new_value: &str) -> LiveBroadcastBindCall<'a, S> { + self._on_behalf_of_content_owner_channel = Some(new_value.to_string()); + self + } + /// *Note:* This parameter is intended exclusively for YouTube content partners. The *onBehalfOfContentOwner* parameter indicates that the request's authorization credentials identify a YouTube CMS user who is acting on behalf of the content owner specified in the parameter value. This parameter is intended for YouTube content partners that own and manage many different YouTube channels. It allows content owners to authenticate once and get access to all their video and channel data, without having to provide authentication credentials for each individual channel. The CMS account that the user authenticates with must be linked to the specified YouTube content owner. + /// + /// Sets the *on behalf of content owner* query property to the given value. + pub fn on_behalf_of_content_owner(mut self, new_value: &str) -> LiveBroadcastBindCall<'a, S> { + self._on_behalf_of_content_owner = 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. + /// + /// ````text + /// It should be used to handle progress information, and to implement a certain level of resilience. + /// ```` + /// + /// Sets the *delegate* property to the given value. + pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> LiveBroadcastBindCall<'a, S> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not be used to set any of the known parameters + /// which have their own setter method. If done anyway, the request will fail. + /// + /// # Additional Parameters + /// + /// * *$.xgafv* (query-string) - V1 error format. + /// * *access_token* (query-string) - OAuth access token. + /// * *alt* (query-string) - Data format for response. + /// * *callback* (query-string) - JSONP + /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. + /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. + /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. + /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. + /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. + /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). + /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). + pub fn param(mut self, name: T, value: T) -> LiveBroadcastBindCall<'a, S> + where T: AsRef { + self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); + self + } + + /// Identifies the authorization scope for the method you are building. + /// + /// Use this method to actively specify which scope should be used, instead of 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: St) -> LiveBroadcastBindCall<'a, S> + where St: AsRef { + self._scopes.insert(String::from(scope.as_ref())); + self + } + /// Identifies the authorization scope(s) for the method you are building. + /// + /// See [`Self::add_scope()`] for details. + pub fn add_scopes(mut self, scopes: I) -> LiveBroadcastBindCall<'a, S> + where I: IntoIterator, + St: AsRef { + self._scopes + .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); + self + } + + /// Removes all scopes, and no default scope will be used either. + /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] + /// for details). + pub fn clear_scopes(mut self) -> LiveBroadcastBindCall<'a, S> { + self._scopes.clear(); + self + } +} + + +/// Delete a given broadcast. +/// +/// A builder for the *delete* method supported by a *liveBroadcast* resource. +/// It is not used directly, but through a [`LiveBroadcastMethods`] instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate hyper_rustls; +/// # extern crate google_youtube3 as youtube3; +/// # async fn dox() { +/// # use std::default::Default; +/// # use youtube3::{YouTube, oauth2, hyper, hyper_rustls, chrono, FieldMask}; +/// +/// # let secret: oauth2::ApplicationSecret = Default::default(); +/// # let auth = oauth2::InstalledFlowAuthenticator::builder( +/// # secret, +/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, +/// # ).build().await.unwrap(); +/// # let mut hub = YouTube::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().unwrap().https_or_http().enable_http1().build()), auth); +/// // You can configure optional parameters by calling 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().delete("id") +/// .on_behalf_of_content_owner_channel("aliquyam") +/// .on_behalf_of_content_owner("dolores") +/// .doit().await; +/// # } +/// ``` +pub struct LiveBroadcastDeleteCall<'a, S> + where S: 'a { + + pub(super) hub: &'a YouTube, + pub(super) _id: String, + pub(super) _on_behalf_of_content_owner_channel: Option, + pub(super) _on_behalf_of_content_owner: Option, + pub(super) _delegate: Option<&'a mut dyn client::Delegate>, + pub(super) _additional_params: HashMap, + pub(super) _scopes: BTreeSet +} + +impl<'a, S> client::CallBuilder for LiveBroadcastDeleteCall<'a, S> {} + +impl<'a, S> LiveBroadcastDeleteCall<'a, S> +where + S: tower_service::Service + Clone + Send + Sync + 'static, + S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, + S::Future: Send + Unpin + 'static, + S::Error: Into>, +{ + + + /// Perform the operation you have build so far. + pub async fn doit(mut self) -> client::Result> { + use std::io::{Read, Seek}; + use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; + use client::{ToParts, url::Params}; + use std::borrow::Cow; + + let mut dd = client::DefaultDelegate; + let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd); + dlg.begin(client::MethodInfo { id: "youtube.liveBroadcasts.delete", + http_method: hyper::Method::DELETE }); + + for &field in ["id", "onBehalfOfContentOwnerChannel", "onBehalfOfContentOwner"].iter() { + if self._additional_params.contains_key(field) { + dlg.finished(false); + return Err(client::Error::FieldClash(field)); + } + } + + let mut params = Params::with_capacity(4 + self._additional_params.len()); + params.push("id", &self._id); + if let Some(value) = self._on_behalf_of_content_owner_channel.as_ref() { + params.push("onBehalfOfContentOwnerChannel", value); + } + if let Some(value) = self._on_behalf_of_content_owner.as_ref() { + params.push("onBehalfOfContentOwner", value); + } + + params.extend(self._additional_params.iter()); + + let mut url = self.hub._base_url.clone() + "youtube/v3/liveBroadcasts"; + if self._scopes.is_empty() { + self._scopes.insert(Scope::Full.as_ref().to_string()); + } + + + let url = params.parse_with_url(&url); + + + + loop { + let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]).await { + Ok(token) => token, + Err(e) => { + match dlg.token(e) { + Ok(token) => token, + Err(e) => { + dlg.finished(false); + return Err(client::Error::MissingToken(e)); + } + } + } + }; + let mut req_result = { + let client = &self.hub.client; + dlg.pre_request(); + let mut req_builder = hyper::Request::builder() + .method(hyper::Method::DELETE) + .uri(url.as_str()) + .header(USER_AGENT, self.hub._user_agent.clone()); + + if let Some(token) = token.as_ref() { + req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); + } + + + let request = req_builder + .header(CONTENT_LENGTH, 0_u64) + .body(hyper::body::Body::empty()); + + client.request(request.unwrap()).await + + }; + + match req_result { + Err(err) => { + if let client::Retry::After(d) = dlg.http_error(&err) { + sleep(d).await; + continue; + } + dlg.finished(false); + return Err(client::Error::HttpError(err)) + } + Ok(mut res) => { + if !res.status().is_success() { + let res_body_string = client::get_body_as_string(res.body_mut()).await; + let (parts, _) = res.into_parts(); + let body = hyper::Body::from(res_body_string.clone()); + let restored_response = hyper::Response::from_parts(parts, body); + + let server_response = json::from_str::(&res_body_string).ok(); + + if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { + sleep(d).await; + continue; + } + + dlg.finished(false); + + return match server_response { + Some(error_value) => Err(client::Error::BadRequest(error_value)), + None => Err(client::Error::Failure(restored_response)), + } + } + let result_value = res; + + dlg.finished(true); + return Ok(result_value) + } + } + } + } + + + /// Broadcast to delete. + /// + /// 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) -> LiveBroadcastDeleteCall<'a, S> { + self._id = new_value.to_string(); + self + } + /// This parameter can only be used in a properly authorized request. *Note:* This parameter is intended exclusively for YouTube content partners. The *onBehalfOfContentOwnerChannel* parameter specifies the YouTube channel ID of the channel to which a video is being added. This parameter is required when a request specifies a value for the onBehalfOfContentOwner parameter, and it can only be used in conjunction with that parameter. In addition, the request must be authorized using a CMS account that is linked to the content owner that the onBehalfOfContentOwner parameter specifies. Finally, the channel that the onBehalfOfContentOwnerChannel parameter value specifies must be linked to the content owner that the onBehalfOfContentOwner parameter specifies. This parameter is intended for YouTube content partners that own and manage many different YouTube channels. It allows content owners to authenticate once and perform actions on behalf of the channel specified in the parameter value, without having to provide authentication credentials for each separate channel. + /// + /// Sets the *on behalf of content owner channel* query property to the given value. + pub fn on_behalf_of_content_owner_channel(mut self, new_value: &str) -> LiveBroadcastDeleteCall<'a, S> { + self._on_behalf_of_content_owner_channel = Some(new_value.to_string()); + self + } + /// *Note:* This parameter is intended exclusively for YouTube content partners. The *onBehalfOfContentOwner* parameter indicates that the request's authorization credentials identify a YouTube CMS user who is acting on behalf of the content owner specified in the parameter value. This parameter is intended for YouTube content partners that own and manage many different YouTube channels. It allows content owners to authenticate once and get access to all their video and channel data, without having to provide authentication credentials for each individual channel. The CMS account that the user authenticates with must be linked to the specified YouTube content owner. + /// + /// Sets the *on behalf of content owner* query property to the given value. + pub fn on_behalf_of_content_owner(mut self, new_value: &str) -> LiveBroadcastDeleteCall<'a, S> { + self._on_behalf_of_content_owner = 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. + /// + /// ````text + /// It should be used to handle progress information, and to implement a certain level of resilience. + /// ```` + /// + /// Sets the *delegate* property to the given value. + pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> LiveBroadcastDeleteCall<'a, S> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not be used to set any of the known parameters + /// which have their own setter method. If done anyway, the request will fail. + /// + /// # Additional Parameters + /// + /// * *$.xgafv* (query-string) - V1 error format. + /// * *access_token* (query-string) - OAuth access token. + /// * *alt* (query-string) - Data format for response. + /// * *callback* (query-string) - JSONP + /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. + /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. + /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. + /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. + /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. + /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). + /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). + pub fn param(mut self, name: T, value: T) -> LiveBroadcastDeleteCall<'a, S> + where T: AsRef { + self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); + self + } + + /// Identifies the authorization scope for the method you are building. + /// + /// Use this method to actively specify which scope should be used, instead of 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: St) -> LiveBroadcastDeleteCall<'a, S> + where St: AsRef { + self._scopes.insert(String::from(scope.as_ref())); + self + } + /// Identifies the authorization scope(s) for the method you are building. + /// + /// See [`Self::add_scope()`] for details. + pub fn add_scopes(mut self, scopes: I) -> LiveBroadcastDeleteCall<'a, S> + where I: IntoIterator, + St: AsRef { + self._scopes + .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); + self + } + + /// Removes all scopes, and no default scope will be used either. + /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] + /// for details). + pub fn clear_scopes(mut self) -> LiveBroadcastDeleteCall<'a, S> { + self._scopes.clear(); + self + } +} + + +/// Inserts a new stream for the authenticated user. +/// +/// A builder for the *insert* method supported by a *liveBroadcast* resource. +/// It is not used directly, but through a [`LiveBroadcastMethods`] instance. +/// +/// **Settable Parts** +/// +/// * *id* +/// * *snippet* +/// * *contentDetails* +/// * *status* +/// +/// # Scopes +/// +/// You will need authorization for at least one of the following scopes to make a valid call, possibly depending on *parts*: +/// +/// * *https://www.googleapis.com/auth/youtube* +/// * *https://www.googleapis.com/auth/youtube.force-ssl* +/// +/// The default scope will be `Scope::Full`. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate hyper_rustls; +/// # extern crate google_youtube3 as youtube3; +/// use youtube3::api::LiveBroadcast; +/// # async fn dox() { +/// # use std::default::Default; +/// # use youtube3::{YouTube, oauth2, hyper, hyper_rustls, chrono, FieldMask}; +/// +/// # let secret: oauth2::ApplicationSecret = Default::default(); +/// # let auth = oauth2::InstalledFlowAuthenticator::builder( +/// # secret, +/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, +/// # ).build().await.unwrap(); +/// # let mut hub = YouTube::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().unwrap().https_or_http().enable_http1().build()), auth); +/// // As the method needs a request, you would usually fill it with the desired information +/// // into the respective structure. Some of the parts shown here might not be applicable ! +/// // Values shown here are possibly random and not representative ! +/// let mut req = LiveBroadcast::default(); +/// req.content_details = Default::default(); // is LiveBroadcastContentDetails +/// req.id = Some("sadipscing".to_string()); +/// req.snippet = Default::default(); // is LiveBroadcastSnippet +/// req.status = Default::default(); // is LiveBroadcastStatus +/// +/// // You can configure optional parameters by calling 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("erat") +/// .on_behalf_of_content_owner("aliquyam") +/// .doit().await; +/// # } +/// ``` +pub struct LiveBroadcastInsertCall<'a, S> + where S: 'a { + + pub(super) hub: &'a YouTube, + pub(super) _request: LiveBroadcast, + pub(super) _part: Vec, + pub(super) _on_behalf_of_content_owner_channel: Option, + pub(super) _on_behalf_of_content_owner: Option, + pub(super) _delegate: Option<&'a mut dyn client::Delegate>, + pub(super) _additional_params: HashMap, + pub(super) _scopes: BTreeSet +} + +impl<'a, S> client::CallBuilder for LiveBroadcastInsertCall<'a, S> {} + +impl<'a, S> LiveBroadcastInsertCall<'a, S> +where + S: tower_service::Service + Clone + Send + Sync + 'static, + S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, + S::Future: Send + Unpin + 'static, + S::Error: Into>, +{ + + + /// Perform the operation you have build so far. + pub async fn doit(mut self) -> client::Result<(hyper::Response, LiveBroadcast)> { + use std::io::{Read, Seek}; + use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; + use client::{ToParts, url::Params}; + use std::borrow::Cow; + + let mut dd = client::DefaultDelegate; + let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd); + dlg.begin(client::MethodInfo { id: "youtube.liveBroadcasts.insert", + http_method: hyper::Method::POST }); + + for &field in ["alt", "part", "onBehalfOfContentOwnerChannel", "onBehalfOfContentOwner"].iter() { + if self._additional_params.contains_key(field) { + dlg.finished(false); + return Err(client::Error::FieldClash(field)); + } + } + + let mut params = Params::with_capacity(6 + self._additional_params.len()); + if self._part.is_empty() { + self._part.push(self._request.to_parts()); + } + if self._part.len() > 0 { + for f in self._part.iter() { + params.push("part", f); + } + } + if let Some(value) = self._on_behalf_of_content_owner_channel.as_ref() { + params.push("onBehalfOfContentOwnerChannel", value); + } + if let Some(value) = self._on_behalf_of_content_owner.as_ref() { + params.push("onBehalfOfContentOwner", value); + } + + params.extend(self._additional_params.iter()); + + params.push("alt", "json"); + let mut url = self.hub._base_url.clone() + "youtube/v3/liveBroadcasts"; + if self._scopes.is_empty() { + self._scopes.insert(Scope::Full.as_ref().to_string()); + } + + + let url = params.parse_with_url(&url); + + let mut json_mime_type = mime::APPLICATION_JSON; + let mut request_value_reader = + { + let mut value = json::value::to_value(&self._request).expect("serde to work"); + client::remove_json_null_values(&mut value); + let mut dst = io::Cursor::new(Vec::with_capacity(128)); + json::to_writer(&mut dst, &value).unwrap(); + dst + }; + let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); + request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); + + + loop { + let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]).await { + Ok(token) => token, + Err(e) => { + match dlg.token(e) { + Ok(token) => token, + Err(e) => { + dlg.finished(false); + return Err(client::Error::MissingToken(e)); + } + } + } + }; + request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); + let mut req_result = { + let client = &self.hub.client; + dlg.pre_request(); + let mut req_builder = hyper::Request::builder() + .method(hyper::Method::POST) + .uri(url.as_str()) + .header(USER_AGENT, self.hub._user_agent.clone()); + + if let Some(token) = token.as_ref() { + req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); + } + + + let request = req_builder + .header(CONTENT_TYPE, json_mime_type.to_string()) + .header(CONTENT_LENGTH, request_size as u64) + .body(hyper::body::Body::from(request_value_reader.get_ref().clone())); + + client.request(request.unwrap()).await + + }; + + match req_result { + Err(err) => { + if let client::Retry::After(d) = dlg.http_error(&err) { + sleep(d).await; + continue; + } + dlg.finished(false); + return Err(client::Error::HttpError(err)) + } + Ok(mut res) => { + if !res.status().is_success() { + let res_body_string = client::get_body_as_string(res.body_mut()).await; + let (parts, _) = res.into_parts(); + let body = hyper::Body::from(res_body_string.clone()); + let restored_response = hyper::Response::from_parts(parts, body); + + let server_response = json::from_str::(&res_body_string).ok(); + + if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { + sleep(d).await; + continue; + } + + dlg.finished(false); + + return match server_response { + Some(error_value) => Err(client::Error::BadRequest(error_value)), + None => Err(client::Error::Failure(restored_response)), + } + } + let result_value = { + let res_body_string = client::get_body_as_string(res.body_mut()).await; + + match json::from_str(&res_body_string) { + Ok(decoded) => (res, decoded), + Err(err) => { + dlg.response_json_decode_error(&res_body_string, &err); + return Err(client::Error::JsonDecodeError(res_body_string, err)); + } + } + }; + + dlg.finished(true); + return Ok(result_value) + } + } + } + } + + + /// + /// Sets the *request* property to the given value. + /// + /// Even though the property as already been set when instantiating this call, + /// we provide this method for API completeness. + /// + /// **Settable Parts** + /// + /// * *id* + /// * *snippet* + /// * *contentDetails* + /// * *status* + pub fn request(mut self, new_value: LiveBroadcast) -> LiveBroadcastInsertCall<'a, S> { + self._request = new_value; + self + } + /// The *part* parameter serves two purposes in this operation. It identifies the properties that the write operation will set as well as the properties that the API response will include. The part properties that you can include in the parameter value are id, snippet, contentDetails, and status. + /// + /// Append the given value to the *part* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + /// + /// Even though the *parts* list is automatically derived from *Resource* passed in + /// during instantiation and indicates which values you are passing, the response would contain the very same parts. + /// This may not always be desirable, as you can obtain (newly generated) parts you cannot pass in, + /// like statistics that are generated server side. Therefore you should use this method to specify + /// the parts you provide in addition to the ones you want in the response. + /// + /// **Settable Parts** + /// + /// * *id* + /// * *snippet* + /// * *contentDetails* + /// * *status* + pub fn add_part(mut self, new_value: &str) -> LiveBroadcastInsertCall<'a, S> { + self._part.push(new_value.to_string()); + self + } + /// This parameter can only be used in a properly authorized request. *Note:* This parameter is intended exclusively for YouTube content partners. The *onBehalfOfContentOwnerChannel* parameter specifies the YouTube channel ID of the channel to which a video is being added. This parameter is required when a request specifies a value for the onBehalfOfContentOwner parameter, and it can only be used in conjunction with that parameter. In addition, the request must be authorized using a CMS account that is linked to the content owner that the onBehalfOfContentOwner parameter specifies. Finally, the channel that the onBehalfOfContentOwnerChannel parameter value specifies must be linked to the content owner that the onBehalfOfContentOwner parameter specifies. This parameter is intended for YouTube content partners that own and manage many different YouTube channels. It allows content owners to authenticate once and perform actions on behalf of the channel specified in the parameter value, without having to provide authentication credentials for each separate channel. + /// + /// Sets the *on behalf of content owner channel* query property to the given value. + pub fn on_behalf_of_content_owner_channel(mut self, new_value: &str) -> LiveBroadcastInsertCall<'a, S> { + self._on_behalf_of_content_owner_channel = Some(new_value.to_string()); + self + } + /// *Note:* This parameter is intended exclusively for YouTube content partners. The *onBehalfOfContentOwner* parameter indicates that the request's authorization credentials identify a YouTube CMS user who is acting on behalf of the content owner specified in the parameter value. This parameter is intended for YouTube content partners that own and manage many different YouTube channels. It allows content owners to authenticate once and get access to all their video and channel data, without having to provide authentication credentials for each individual channel. The CMS account that the user authenticates with must be linked to the specified YouTube content owner. + /// + /// Sets the *on behalf of content owner* query property to the given value. + pub fn on_behalf_of_content_owner(mut self, new_value: &str) -> LiveBroadcastInsertCall<'a, S> { + self._on_behalf_of_content_owner = 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. + /// + /// ````text + /// It should be used to handle progress information, and to implement a certain level of resilience. + /// ```` + /// + /// Sets the *delegate* property to the given value. + pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> LiveBroadcastInsertCall<'a, S> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not be used to set any of the known parameters + /// which have their own setter method. If done anyway, the request will fail. + /// + /// # Additional Parameters + /// + /// * *$.xgafv* (query-string) - V1 error format. + /// * *access_token* (query-string) - OAuth access token. + /// * *alt* (query-string) - Data format for response. + /// * *callback* (query-string) - JSONP + /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. + /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. + /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. + /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. + /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. + /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). + /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). + pub fn param(mut self, name: T, value: T) -> LiveBroadcastInsertCall<'a, S> + where T: AsRef { + self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); + self + } + + /// Identifies the authorization scope for the method you are building. + /// + /// Use this method to actively specify which scope should be used, instead of 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: St) -> LiveBroadcastInsertCall<'a, S> + where St: AsRef { + self._scopes.insert(String::from(scope.as_ref())); + self + } + /// Identifies the authorization scope(s) for the method you are building. + /// + /// See [`Self::add_scope()`] for details. + pub fn add_scopes(mut self, scopes: I) -> LiveBroadcastInsertCall<'a, S> + where I: IntoIterator, + St: AsRef { + self._scopes + .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); + self + } + + /// Removes all scopes, and no default scope will be used either. + /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] + /// for details). + pub fn clear_scopes(mut self) -> LiveBroadcastInsertCall<'a, S> { + self._scopes.clear(); + self + } +} + + +/// Insert cuepoints in a broadcast +/// +/// A builder for the *insertCuepoint* method supported by a *liveBroadcast* resource. +/// It is not used directly, but through a [`LiveBroadcastMethods`] instance. +/// +/// **Settable Parts** +/// +/// * *id* +/// * *snippet* +/// * *contentDetails* +/// * *status* +/// +/// # Scopes +/// +/// You will need authorization for at least one of the following scopes to make a valid call, possibly depending on *parts*: +/// +/// * *https://www.googleapis.com/auth/youtube* +/// * *https://www.googleapis.com/auth/youtube.force-ssl* +/// * *https://www.googleapis.com/auth/youtubepartner* +/// +/// The default scope will be `Scope::Full`. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate hyper_rustls; +/// # extern crate google_youtube3 as youtube3; +/// use youtube3::api::Cuepoint; +/// # async fn dox() { +/// # use std::default::Default; +/// # use youtube3::{YouTube, oauth2, hyper, hyper_rustls, chrono, FieldMask}; +/// +/// # let secret: oauth2::ApplicationSecret = Default::default(); +/// # let auth = oauth2::InstalledFlowAuthenticator::builder( +/// # secret, +/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, +/// # ).build().await.unwrap(); +/// # let mut hub = YouTube::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().unwrap().https_or_http().enable_http1().build()), auth); +/// // As the method needs a request, you would usually fill it with the desired information +/// // into the respective structure. Some of the parts shown here might not be applicable ! +/// // Values shown here are possibly random and not representative ! +/// let mut req = Cuepoint::default(); +/// req.id = Some("amet".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_cuepoint(req) +/// .add_part("est") +/// .on_behalf_of_content_owner_channel("et") +/// .on_behalf_of_content_owner("sea") +/// .id("consetetur") +/// .doit().await; +/// # } +/// ``` +pub struct LiveBroadcastInsertCuepointCall<'a, S> + where S: 'a { + + pub(super) hub: &'a YouTube, + pub(super) _request: Cuepoint, + pub(super) _part: Vec, + pub(super) _on_behalf_of_content_owner_channel: Option, + pub(super) _on_behalf_of_content_owner: Option, + pub(super) _id: Option, + pub(super) _delegate: Option<&'a mut dyn client::Delegate>, + pub(super) _additional_params: HashMap, + pub(super) _scopes: BTreeSet +} + +impl<'a, S> client::CallBuilder for LiveBroadcastInsertCuepointCall<'a, S> {} + +impl<'a, S> LiveBroadcastInsertCuepointCall<'a, S> +where + S: tower_service::Service + Clone + Send + Sync + 'static, + S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, + S::Future: Send + Unpin + 'static, + S::Error: Into>, +{ + + + /// Perform the operation you have build so far. + pub async fn doit(mut self) -> client::Result<(hyper::Response, Cuepoint)> { + use std::io::{Read, Seek}; + use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; + use client::{ToParts, url::Params}; + use std::borrow::Cow; + + let mut dd = client::DefaultDelegate; + let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd); + dlg.begin(client::MethodInfo { id: "youtube.liveBroadcasts.insertCuepoint", + http_method: hyper::Method::POST }); + + for &field in ["alt", "part", "onBehalfOfContentOwnerChannel", "onBehalfOfContentOwner", "id"].iter() { + if self._additional_params.contains_key(field) { + dlg.finished(false); + return Err(client::Error::FieldClash(field)); + } + } + + let mut params = Params::with_capacity(7 + self._additional_params.len()); + if self._part.is_empty() { + self._part.push(self._request.to_parts()); + } + if self._part.len() > 0 { + for f in self._part.iter() { + params.push("part", f); + } + } + if let Some(value) = self._on_behalf_of_content_owner_channel.as_ref() { + params.push("onBehalfOfContentOwnerChannel", value); + } + if let Some(value) = self._on_behalf_of_content_owner.as_ref() { + params.push("onBehalfOfContentOwner", value); + } + if let Some(value) = self._id.as_ref() { + params.push("id", value); + } + + params.extend(self._additional_params.iter()); + + params.push("alt", "json"); + let mut url = self.hub._base_url.clone() + "youtube/v3/liveBroadcasts/cuepoint"; + if self._scopes.is_empty() { + self._scopes.insert(Scope::Full.as_ref().to_string()); + } + + + let url = params.parse_with_url(&url); + + let mut json_mime_type = mime::APPLICATION_JSON; + let mut request_value_reader = + { + let mut value = json::value::to_value(&self._request).expect("serde to work"); + client::remove_json_null_values(&mut value); + let mut dst = io::Cursor::new(Vec::with_capacity(128)); + json::to_writer(&mut dst, &value).unwrap(); + dst + }; + let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); + request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); + + + loop { + let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]).await { + Ok(token) => token, + Err(e) => { + match dlg.token(e) { + Ok(token) => token, + Err(e) => { + dlg.finished(false); + return Err(client::Error::MissingToken(e)); + } + } + } + }; + request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); + let mut req_result = { + let client = &self.hub.client; + dlg.pre_request(); + let mut req_builder = hyper::Request::builder() + .method(hyper::Method::POST) + .uri(url.as_str()) + .header(USER_AGENT, self.hub._user_agent.clone()); + + if let Some(token) = token.as_ref() { + req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); + } + + + let request = req_builder + .header(CONTENT_TYPE, json_mime_type.to_string()) + .header(CONTENT_LENGTH, request_size as u64) + .body(hyper::body::Body::from(request_value_reader.get_ref().clone())); + + client.request(request.unwrap()).await + + }; + + match req_result { + Err(err) => { + if let client::Retry::After(d) = dlg.http_error(&err) { + sleep(d).await; + continue; + } + dlg.finished(false); + return Err(client::Error::HttpError(err)) + } + Ok(mut res) => { + if !res.status().is_success() { + let res_body_string = client::get_body_as_string(res.body_mut()).await; + let (parts, _) = res.into_parts(); + let body = hyper::Body::from(res_body_string.clone()); + let restored_response = hyper::Response::from_parts(parts, body); + + let server_response = json::from_str::(&res_body_string).ok(); + + if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { + sleep(d).await; + continue; + } + + dlg.finished(false); + + return match server_response { + Some(error_value) => Err(client::Error::BadRequest(error_value)), + None => Err(client::Error::Failure(restored_response)), + } + } + let result_value = { + let res_body_string = client::get_body_as_string(res.body_mut()).await; + + match json::from_str(&res_body_string) { + Ok(decoded) => (res, decoded), + Err(err) => { + dlg.response_json_decode_error(&res_body_string, &err); + return Err(client::Error::JsonDecodeError(res_body_string, err)); + } + } + }; + + dlg.finished(true); + return Ok(result_value) + } + } + } + } + + + /// + /// Sets the *request* property to the given value. + /// + /// Even though the property as already been set when instantiating this call, + /// we provide this method for API completeness. + /// + /// **Settable Parts** + /// + /// * *id* + /// * *snippet* + /// * *contentDetails* + /// * *status* + pub fn request(mut self, new_value: Cuepoint) -> LiveBroadcastInsertCuepointCall<'a, S> { + self._request = new_value; + self + } + /// The *part* parameter specifies a comma-separated list of one or more liveBroadcast resource properties that the API response will include. The part names that you can include in the parameter value are id, snippet, contentDetails, and status. + /// + /// Append the given value to the *part* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + /// + /// Even though the *parts* list is automatically derived from *Resource* passed in + /// during instantiation and indicates which values you are passing, the response would contain the very same parts. + /// This may not always be desirable, as you can obtain (newly generated) parts you cannot pass in, + /// like statistics that are generated server side. Therefore you should use this method to specify + /// the parts you provide in addition to the ones you want in the response. + /// + /// **Settable Parts** + /// + /// * *id* + /// * *snippet* + /// * *contentDetails* + /// * *status* + pub fn add_part(mut self, new_value: &str) -> LiveBroadcastInsertCuepointCall<'a, S> { + self._part.push(new_value.to_string()); + self + } + /// This parameter can only be used in a properly authorized request. *Note:* This parameter is intended exclusively for YouTube content partners. The *onBehalfOfContentOwnerChannel* parameter specifies the YouTube channel ID of the channel to which a video is being added. This parameter is required when a request specifies a value for the onBehalfOfContentOwner parameter, and it can only be used in conjunction with that parameter. In addition, the request must be authorized using a CMS account that is linked to the content owner that the onBehalfOfContentOwner parameter specifies. Finally, the channel that the onBehalfOfContentOwnerChannel parameter value specifies must be linked to the content owner that the onBehalfOfContentOwner parameter specifies. This parameter is intended for YouTube content partners that own and manage many different YouTube channels. It allows content owners to authenticate once and perform actions on behalf of the channel specified in the parameter value, without having to provide authentication credentials for each separate channel. + /// + /// Sets the *on behalf of content owner channel* query property to the given value. + pub fn on_behalf_of_content_owner_channel(mut self, new_value: &str) -> LiveBroadcastInsertCuepointCall<'a, S> { + self._on_behalf_of_content_owner_channel = Some(new_value.to_string()); + self + } + /// *Note:* This parameter is intended exclusively for YouTube content partners. The *onBehalfOfContentOwner* parameter indicates that the request's authorization credentials identify a YouTube CMS user who is acting on behalf of the content owner specified in the parameter value. This parameter is intended for YouTube content partners that own and manage many different YouTube channels. It allows content owners to authenticate once and get access to all their video and channel data, without having to provide authentication credentials for each individual channel. The CMS account that the user authenticates with must be linked to the specified YouTube content owner. + /// + /// Sets the *on behalf of content owner* query property to the given value. + pub fn on_behalf_of_content_owner(mut self, new_value: &str) -> LiveBroadcastInsertCuepointCall<'a, S> { + self._on_behalf_of_content_owner = Some(new_value.to_string()); + self + } + /// Broadcast to insert ads to, or equivalently `external_video_id` for internal use. + /// + /// Sets the *id* query property to the given value. + pub fn id(mut self, new_value: &str) -> LiveBroadcastInsertCuepointCall<'a, S> { + self._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. + /// + /// ````text + /// It should be used to handle progress information, and to implement a certain level of resilience. + /// ```` + /// + /// Sets the *delegate* property to the given value. + pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> LiveBroadcastInsertCuepointCall<'a, S> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not be used to set any of the known parameters + /// which have their own setter method. If done anyway, the request will fail. + /// + /// # Additional Parameters + /// + /// * *$.xgafv* (query-string) - V1 error format. + /// * *access_token* (query-string) - OAuth access token. + /// * *alt* (query-string) - Data format for response. + /// * *callback* (query-string) - JSONP + /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. + /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. + /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. + /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. + /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. + /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). + /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). + pub fn param(mut self, name: T, value: T) -> LiveBroadcastInsertCuepointCall<'a, S> + where T: AsRef { + self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); + self + } + + /// Identifies the authorization scope for the method you are building. + /// + /// Use this method to actively specify which scope should be used, instead of 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: St) -> LiveBroadcastInsertCuepointCall<'a, S> + where St: AsRef { + self._scopes.insert(String::from(scope.as_ref())); + self + } + /// Identifies the authorization scope(s) for the method you are building. + /// + /// See [`Self::add_scope()`] for details. + pub fn add_scopes(mut self, scopes: I) -> LiveBroadcastInsertCuepointCall<'a, S> + where I: IntoIterator, + St: AsRef { + self._scopes + .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); + self + } + + /// Removes all scopes, and no default scope will be used either. + /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] + /// for details). + pub fn clear_scopes(mut self) -> LiveBroadcastInsertCuepointCall<'a, S> { + self._scopes.clear(); + self + } +} + + +/// Retrieve the list of broadcasts associated with the given channel. +/// +/// A builder for the *list* method supported by a *liveBroadcast* resource. +/// It is not used directly, but through a [`LiveBroadcastMethods`] instance. +/// +/// **Settable Parts** +/// +/// * *id* +/// * *snippet* +/// * *contentDetails* +/// * *status* +/// * *statistics* +/// +/// # Scopes +/// +/// You will need authorization for at least one of the following scopes to make a valid call, possibly depending on *parts*: +/// +/// * *https://www.googleapis.com/auth/youtube* +/// * *https://www.googleapis.com/auth/youtube.force-ssl* +/// * *https://www.googleapis.com/auth/youtube.readonly* +/// +/// The default scope will be `Scope::Readonly`. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate hyper_rustls; +/// # extern crate google_youtube3 as youtube3; +/// # async fn dox() { +/// # use std::default::Default; +/// # use youtube3::{YouTube, oauth2, hyper, hyper_rustls, chrono, FieldMask}; +/// +/// # let secret: oauth2::ApplicationSecret = Default::default(); +/// # let auth = oauth2::InstalledFlowAuthenticator::builder( +/// # secret, +/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, +/// # ).build().await.unwrap(); +/// # let mut hub = YouTube::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().unwrap().https_or_http().enable_http1().build()), auth); +/// // You can configure optional parameters by calling 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().list(&vec!["consetetur".into()]) +/// .page_token("Stet") +/// .on_behalf_of_content_owner_channel("est") +/// .on_behalf_of_content_owner("aliquyam") +/// .mine(false) +/// .max_results(81) +/// .add_id("diam") +/// .broadcast_type(&Default::default()) +/// .broadcast_status(&Default::default()) +/// .doit().await; +/// # } +/// ``` +pub struct LiveBroadcastListCall<'a, S> + where S: 'a { + + pub(super) hub: &'a YouTube, + pub(super) _part: Vec, + pub(super) _page_token: Option, + pub(super) _on_behalf_of_content_owner_channel: Option, + pub(super) _on_behalf_of_content_owner: Option, + pub(super) _mine: Option, + pub(super) _max_results: Option, + pub(super) _id: Vec, + pub(super) _broadcast_type: Option, + pub(super) _broadcast_status: Option, + pub(super) _delegate: Option<&'a mut dyn client::Delegate>, + pub(super) _additional_params: HashMap, + pub(super) _scopes: BTreeSet +} + +impl<'a, S> client::CallBuilder for LiveBroadcastListCall<'a, S> {} + +impl<'a, S> LiveBroadcastListCall<'a, S> +where + S: tower_service::Service + Clone + Send + Sync + 'static, + S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, + S::Future: Send + Unpin + 'static, + S::Error: Into>, +{ + + + /// Perform the operation you have build so far. + pub async fn doit(mut self) -> client::Result<(hyper::Response, LiveBroadcastListResponse)> { + use std::io::{Read, Seek}; + use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; + use client::{ToParts, url::Params}; + use std::borrow::Cow; + + let mut dd = client::DefaultDelegate; + let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd); + dlg.begin(client::MethodInfo { id: "youtube.liveBroadcasts.list", + http_method: hyper::Method::GET }); + + for &field in ["alt", "part", "pageToken", "onBehalfOfContentOwnerChannel", "onBehalfOfContentOwner", "mine", "maxResults", "id", "broadcastType", "broadcastStatus"].iter() { + if self._additional_params.contains_key(field) { + dlg.finished(false); + return Err(client::Error::FieldClash(field)); + } + } + + let mut params = Params::with_capacity(11 + self._additional_params.len()); + if self._part.len() > 0 { + for f in self._part.iter() { + params.push("part", f); + } + } + if let Some(value) = self._page_token.as_ref() { + params.push("pageToken", value); + } + if let Some(value) = self._on_behalf_of_content_owner_channel.as_ref() { + params.push("onBehalfOfContentOwnerChannel", value); + } + if let Some(value) = self._on_behalf_of_content_owner.as_ref() { + params.push("onBehalfOfContentOwner", value); + } + if let Some(value) = self._mine.as_ref() { + params.push("mine", value.to_string()); + } + if let Some(value) = self._max_results.as_ref() { + params.push("maxResults", value.to_string()); + } + if self._id.len() > 0 { + for f in self._id.iter() { + params.push("id", f); + } + } + if let Some(value) = self._broadcast_type.as_ref() { + params.push("broadcastType", value); + } + if let Some(value) = self._broadcast_status.as_ref() { + params.push("broadcastStatus", value); + } + + params.extend(self._additional_params.iter()); + + params.push("alt", "json"); + let mut url = self.hub._base_url.clone() + "youtube/v3/liveBroadcasts"; + if self._scopes.is_empty() { + self._scopes.insert(Scope::Readonly.as_ref().to_string()); + } + + + let url = params.parse_with_url(&url); + + + + loop { + let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]).await { + Ok(token) => token, + Err(e) => { + match dlg.token(e) { + Ok(token) => token, + Err(e) => { + dlg.finished(false); + return Err(client::Error::MissingToken(e)); + } + } + } + }; + let mut req_result = { + let client = &self.hub.client; + dlg.pre_request(); + let mut req_builder = hyper::Request::builder() + .method(hyper::Method::GET) + .uri(url.as_str()) + .header(USER_AGENT, self.hub._user_agent.clone()); + + if let Some(token) = token.as_ref() { + req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); + } + + + let request = req_builder + .header(CONTENT_LENGTH, 0_u64) + .body(hyper::body::Body::empty()); + + client.request(request.unwrap()).await + + }; + + match req_result { + Err(err) => { + if let client::Retry::After(d) = dlg.http_error(&err) { + sleep(d).await; + continue; + } + dlg.finished(false); + return Err(client::Error::HttpError(err)) + } + Ok(mut res) => { + if !res.status().is_success() { + let res_body_string = client::get_body_as_string(res.body_mut()).await; + let (parts, _) = res.into_parts(); + let body = hyper::Body::from(res_body_string.clone()); + let restored_response = hyper::Response::from_parts(parts, body); + + let server_response = json::from_str::(&res_body_string).ok(); + + if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { + sleep(d).await; + continue; + } + + dlg.finished(false); + + return match server_response { + Some(error_value) => Err(client::Error::BadRequest(error_value)), + None => Err(client::Error::Failure(restored_response)), + } + } + let result_value = { + let res_body_string = client::get_body_as_string(res.body_mut()).await; + + match json::from_str(&res_body_string) { + Ok(decoded) => (res, decoded), + Err(err) => { + dlg.response_json_decode_error(&res_body_string, &err); + return Err(client::Error::JsonDecodeError(res_body_string, err)); + } + } + }; + + dlg.finished(true); + return Ok(result_value) + } + } + } + } + + + /// The *part* parameter specifies a comma-separated list of one or more liveBroadcast resource properties that the API response will include. The part names that you can include in the parameter value are id, snippet, contentDetails, status and statistics. + /// + /// Append the given value to the *part* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + /// + /// Even though the property as already been set when instantiating this call, + /// we provide this method for API completeness. + /// + /// **Settable Parts** + /// + /// * *id* + /// * *snippet* + /// * *contentDetails* + /// * *status* + /// * *statistics* + pub fn add_part(mut self, new_value: &str) -> LiveBroadcastListCall<'a, S> { + self._part.push(new_value.to_string()); + self + } + /// The *pageToken* parameter identifies a specific page in the result set that should be returned. In an API response, the nextPageToken and prevPageToken properties identify other pages that could be retrieved. + /// + /// Sets the *page token* query property to the given value. + pub fn page_token(mut self, new_value: &str) -> LiveBroadcastListCall<'a, S> { + self._page_token = Some(new_value.to_string()); + self + } + /// This parameter can only be used in a properly authorized request. *Note:* This parameter is intended exclusively for YouTube content partners. The *onBehalfOfContentOwnerChannel* parameter specifies the YouTube channel ID of the channel to which a video is being added. This parameter is required when a request specifies a value for the onBehalfOfContentOwner parameter, and it can only be used in conjunction with that parameter. In addition, the request must be authorized using a CMS account that is linked to the content owner that the onBehalfOfContentOwner parameter specifies. Finally, the channel that the onBehalfOfContentOwnerChannel parameter value specifies must be linked to the content owner that the onBehalfOfContentOwner parameter specifies. This parameter is intended for YouTube content partners that own and manage many different YouTube channels. It allows content owners to authenticate once and perform actions on behalf of the channel specified in the parameter value, without having to provide authentication credentials for each separate channel. + /// + /// Sets the *on behalf of content owner channel* query property to the given value. + pub fn on_behalf_of_content_owner_channel(mut self, new_value: &str) -> LiveBroadcastListCall<'a, S> { + self._on_behalf_of_content_owner_channel = Some(new_value.to_string()); + self + } + /// *Note:* This parameter is intended exclusively for YouTube content partners. The *onBehalfOfContentOwner* parameter indicates that the request's authorization credentials identify a YouTube CMS user who is acting on behalf of the content owner specified in the parameter value. This parameter is intended for YouTube content partners that own and manage many different YouTube channels. It allows content owners to authenticate once and get access to all their video and channel data, without having to provide authentication credentials for each individual channel. The CMS account that the user authenticates with must be linked to the specified YouTube content owner. + /// + /// Sets the *on behalf of content owner* query property to the given value. + pub fn on_behalf_of_content_owner(mut self, new_value: &str) -> LiveBroadcastListCall<'a, S> { + self._on_behalf_of_content_owner = Some(new_value.to_string()); + self + } + /// + /// Sets the *mine* query property to the given value. + pub fn mine(mut self, new_value: bool) -> LiveBroadcastListCall<'a, S> { + self._mine = Some(new_value); + self + } + /// The *maxResults* parameter specifies the maximum number of items that should be returned in the result set. + /// + /// Sets the *max results* query property to the given value. + pub fn max_results(mut self, new_value: u32) -> LiveBroadcastListCall<'a, S> { + self._max_results = Some(new_value); + self + } + /// Return broadcasts with the given ids from Stubby or Apiary. + /// + /// Append the given value to the *id* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + pub fn add_id(mut self, new_value: &str) -> LiveBroadcastListCall<'a, S> { + self._id.push(new_value.to_string()); + self + } + /// Return only broadcasts with the selected type. + /// + /// Sets the *broadcast type* query property to the given value. + pub fn broadcast_type(mut self, new_value: &LiveBroadcastBroadcastTypeEnum) -> LiveBroadcastListCall<'a, S> { + self._broadcast_type = Some(new_value.clone()); + self + } + /// Return broadcasts with a certain status, e.g. active broadcasts. + /// + /// Sets the *broadcast status* query property to the given value. + pub fn broadcast_status(mut self, new_value: &LiveBroadcastBroadcastStatusEnum) -> LiveBroadcastListCall<'a, S> { + self._broadcast_status = Some(new_value.clone()); + self + } + /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong + /// while executing the actual API request. + /// + /// ````text + /// It should be used to handle progress information, and to implement a certain level of resilience. + /// ```` + /// + /// Sets the *delegate* property to the given value. + pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> LiveBroadcastListCall<'a, S> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not be used to set any of the known parameters + /// which have their own setter method. If done anyway, the request will fail. + /// + /// # Additional Parameters + /// + /// * *$.xgafv* (query-string) - V1 error format. + /// * *access_token* (query-string) - OAuth access token. + /// * *alt* (query-string) - Data format for response. + /// * *callback* (query-string) - JSONP + /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. + /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. + /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. + /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. + /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. + /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). + /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). + pub fn param(mut self, name: T, value: T) -> LiveBroadcastListCall<'a, S> + where T: AsRef { + self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); + self + } + + /// Identifies the authorization scope for the method you are building. + /// + /// Use this method to actively specify which scope should be used, instead of 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: St) -> LiveBroadcastListCall<'a, S> + where St: AsRef { + self._scopes.insert(String::from(scope.as_ref())); + self + } + /// Identifies the authorization scope(s) for the method you are building. + /// + /// See [`Self::add_scope()`] for details. + pub fn add_scopes(mut self, scopes: I) -> LiveBroadcastListCall<'a, S> + where I: IntoIterator, + St: AsRef { + self._scopes + .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); + self + } + + /// Removes all scopes, and no default scope will be used either. + /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] + /// for details). + pub fn clear_scopes(mut self) -> LiveBroadcastListCall<'a, S> { + self._scopes.clear(); + self + } +} + + +/// Transition a broadcast to a given status. +/// +/// A builder for the *transition* method supported by a *liveBroadcast* resource. +/// It is not used directly, but through a [`LiveBroadcastMethods`] instance. +/// +/// **Settable Parts** +/// +/// * *id* +/// * *snippet* +/// * *contentDetails* +/// * *status* +/// +/// # Scopes +/// +/// You will need authorization for at least one of the following scopes to make a valid call, possibly depending on *parts*: +/// +/// * *https://www.googleapis.com/auth/youtube* +/// * *https://www.googleapis.com/auth/youtube.force-ssl* +/// +/// The default scope will be `Scope::Full`. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate hyper_rustls; +/// # extern crate google_youtube3 as youtube3; +/// # async fn dox() { +/// # use std::default::Default; +/// # use youtube3::{YouTube, oauth2, hyper, hyper_rustls, chrono, FieldMask}; +/// +/// # let secret: oauth2::ApplicationSecret = Default::default(); +/// # let auth = oauth2::InstalledFlowAuthenticator::builder( +/// # secret, +/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, +/// # ).build().await.unwrap(); +/// # let mut hub = YouTube::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().unwrap().https_or_http().enable_http1().build()), auth); +/// // You can configure optional parameters by calling 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().transition(&Default::default(), "id", &vec!["sit".into()]) +/// .on_behalf_of_content_owner_channel("sed") +/// .on_behalf_of_content_owner("eos") +/// .doit().await; +/// # } +/// ``` +pub struct LiveBroadcastTransitionCall<'a, S> + where S: 'a { + + pub(super) hub: &'a YouTube, + pub(super) _broadcast_status: LiveBroadcastBroadcastStatusEnum, + pub(super) _id: String, + pub(super) _part: Vec, + pub(super) _on_behalf_of_content_owner_channel: Option, + pub(super) _on_behalf_of_content_owner: Option, + pub(super) _delegate: Option<&'a mut dyn client::Delegate>, + pub(super) _additional_params: HashMap, + pub(super) _scopes: BTreeSet +} + +impl<'a, S> client::CallBuilder for LiveBroadcastTransitionCall<'a, S> {} + +impl<'a, S> LiveBroadcastTransitionCall<'a, S> +where + S: tower_service::Service + Clone + Send + Sync + 'static, + S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, + S::Future: Send + Unpin + 'static, + S::Error: Into>, +{ + + + /// Perform the operation you have build so far. + pub async fn doit(mut self) -> client::Result<(hyper::Response, LiveBroadcast)> { + use std::io::{Read, Seek}; + use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; + use client::{ToParts, url::Params}; + use std::borrow::Cow; + + let mut dd = client::DefaultDelegate; + let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd); + dlg.begin(client::MethodInfo { id: "youtube.liveBroadcasts.transition", + http_method: hyper::Method::POST }); + + for &field in ["alt", "broadcastStatus", "id", "part", "onBehalfOfContentOwnerChannel", "onBehalfOfContentOwner"].iter() { + if self._additional_params.contains_key(field) { + dlg.finished(false); + return Err(client::Error::FieldClash(field)); + } + } + + let mut params = Params::with_capacity(7 + self._additional_params.len()); + params.push("broadcastStatus", &self._broadcast_status); + params.push("id", &self._id); + if self._part.len() > 0 { + for f in self._part.iter() { + params.push("part", f); + } + } + if let Some(value) = self._on_behalf_of_content_owner_channel.as_ref() { + params.push("onBehalfOfContentOwnerChannel", value); + } + if let Some(value) = self._on_behalf_of_content_owner.as_ref() { + params.push("onBehalfOfContentOwner", value); + } + + params.extend(self._additional_params.iter()); + + params.push("alt", "json"); + let mut url = self.hub._base_url.clone() + "youtube/v3/liveBroadcasts/transition"; + if self._scopes.is_empty() { + self._scopes.insert(Scope::Full.as_ref().to_string()); + } + + + let url = params.parse_with_url(&url); + + + + loop { + let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]).await { + Ok(token) => token, + Err(e) => { + match dlg.token(e) { + Ok(token) => token, + Err(e) => { + dlg.finished(false); + return Err(client::Error::MissingToken(e)); + } + } + } + }; + let mut req_result = { + let client = &self.hub.client; + dlg.pre_request(); + let mut req_builder = hyper::Request::builder() + .method(hyper::Method::POST) + .uri(url.as_str()) + .header(USER_AGENT, self.hub._user_agent.clone()); + + if let Some(token) = token.as_ref() { + req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); + } + + + let request = req_builder + .header(CONTENT_LENGTH, 0_u64) + .body(hyper::body::Body::empty()); + + client.request(request.unwrap()).await + + }; + + match req_result { + Err(err) => { + if let client::Retry::After(d) = dlg.http_error(&err) { + sleep(d).await; + continue; + } + dlg.finished(false); + return Err(client::Error::HttpError(err)) + } + Ok(mut res) => { + if !res.status().is_success() { + let res_body_string = client::get_body_as_string(res.body_mut()).await; + let (parts, _) = res.into_parts(); + let body = hyper::Body::from(res_body_string.clone()); + let restored_response = hyper::Response::from_parts(parts, body); + + let server_response = json::from_str::(&res_body_string).ok(); + + if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { + sleep(d).await; + continue; + } + + dlg.finished(false); + + return match server_response { + Some(error_value) => Err(client::Error::BadRequest(error_value)), + None => Err(client::Error::Failure(restored_response)), + } + } + let result_value = { + let res_body_string = client::get_body_as_string(res.body_mut()).await; + + match json::from_str(&res_body_string) { + Ok(decoded) => (res, decoded), + Err(err) => { + dlg.response_json_decode_error(&res_body_string, &err); + return Err(client::Error::JsonDecodeError(res_body_string, err)); + } + } + }; + + dlg.finished(true); + return Ok(result_value) + } + } + } + } + + + /// The status to which the broadcast is going to transition. + /// + /// Sets the *broadcast status* 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 broadcast_status(mut self, new_value: &LiveBroadcastBroadcastStatusEnum) -> LiveBroadcastTransitionCall<'a, S> { + self._broadcast_status = new_value.clone(); + self + } + /// Broadcast to transition. + /// + /// 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) -> LiveBroadcastTransitionCall<'a, S> { + self._id = new_value.to_string(); + self + } + /// The *part* parameter specifies a comma-separated list of one or more liveBroadcast resource properties that the API response will include. The part names that you can include in the parameter value are id, snippet, contentDetails, and status. + /// + /// Append the given value to the *part* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + /// + /// Even though the property as already been set when instantiating this call, + /// we provide this method for API completeness. + /// + /// **Settable Parts** + /// + /// * *id* + /// * *snippet* + /// * *contentDetails* + /// * *status* + pub fn add_part(mut self, new_value: &str) -> LiveBroadcastTransitionCall<'a, S> { + self._part.push(new_value.to_string()); + self + } + /// This parameter can only be used in a properly authorized request. *Note:* This parameter is intended exclusively for YouTube content partners. The *onBehalfOfContentOwnerChannel* parameter specifies the YouTube channel ID of the channel to which a video is being added. This parameter is required when a request specifies a value for the onBehalfOfContentOwner parameter, and it can only be used in conjunction with that parameter. In addition, the request must be authorized using a CMS account that is linked to the content owner that the onBehalfOfContentOwner parameter specifies. Finally, the channel that the onBehalfOfContentOwnerChannel parameter value specifies must be linked to the content owner that the onBehalfOfContentOwner parameter specifies. This parameter is intended for YouTube content partners that own and manage many different YouTube channels. It allows content owners to authenticate once and perform actions on behalf of the channel specified in the parameter value, without having to provide authentication credentials for each separate channel. + /// + /// Sets the *on behalf of content owner channel* query property to the given value. + pub fn on_behalf_of_content_owner_channel(mut self, new_value: &str) -> LiveBroadcastTransitionCall<'a, S> { + self._on_behalf_of_content_owner_channel = Some(new_value.to_string()); + self + } + /// *Note:* This parameter is intended exclusively for YouTube content partners. The *onBehalfOfContentOwner* parameter indicates that the request's authorization credentials identify a YouTube CMS user who is acting on behalf of the content owner specified in the parameter value. This parameter is intended for YouTube content partners that own and manage many different YouTube channels. It allows content owners to authenticate once and get access to all their video and channel data, without having to provide authentication credentials for each individual channel. The CMS account that the user authenticates with must be linked to the specified YouTube content owner. + /// + /// Sets the *on behalf of content owner* query property to the given value. + pub fn on_behalf_of_content_owner(mut self, new_value: &str) -> LiveBroadcastTransitionCall<'a, S> { + self._on_behalf_of_content_owner = 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. + /// + /// ````text + /// It should be used to handle progress information, and to implement a certain level of resilience. + /// ```` + /// + /// Sets the *delegate* property to the given value. + pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> LiveBroadcastTransitionCall<'a, S> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not be used to set any of the known parameters + /// which have their own setter method. If done anyway, the request will fail. + /// + /// # Additional Parameters + /// + /// * *$.xgafv* (query-string) - V1 error format. + /// * *access_token* (query-string) - OAuth access token. + /// * *alt* (query-string) - Data format for response. + /// * *callback* (query-string) - JSONP + /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. + /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. + /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. + /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. + /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. + /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). + /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). + pub fn param(mut self, name: T, value: T) -> LiveBroadcastTransitionCall<'a, S> + where T: AsRef { + self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); + self + } + + /// Identifies the authorization scope for the method you are building. + /// + /// Use this method to actively specify which scope should be used, instead of 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: St) -> LiveBroadcastTransitionCall<'a, S> + where St: AsRef { + self._scopes.insert(String::from(scope.as_ref())); + self + } + /// Identifies the authorization scope(s) for the method you are building. + /// + /// See [`Self::add_scope()`] for details. + pub fn add_scopes(mut self, scopes: I) -> LiveBroadcastTransitionCall<'a, S> + where I: IntoIterator, + St: AsRef { + self._scopes + .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); + self + } + + /// Removes all scopes, and no default scope will be used either. + /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] + /// for details). + pub fn clear_scopes(mut self) -> LiveBroadcastTransitionCall<'a, S> { + self._scopes.clear(); + self + } +} + + +/// Updates an existing broadcast for the authenticated user. +/// +/// A builder for the *update* method supported by a *liveBroadcast* resource. +/// It is not used directly, but through a [`LiveBroadcastMethods`] instance. +/// +/// **Settable Parts** +/// +/// * *id* +/// * *snippet* +/// * *contentDetails* +/// * *status* +/// +/// # Scopes +/// +/// You will need authorization for at least one of the following scopes to make a valid call, possibly depending on *parts*: +/// +/// * *https://www.googleapis.com/auth/youtube* +/// * *https://www.googleapis.com/auth/youtube.force-ssl* +/// +/// The default scope will be `Scope::Full`. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate hyper_rustls; +/// # extern crate google_youtube3 as youtube3; +/// use youtube3::api::LiveBroadcast; +/// # async fn dox() { +/// # use std::default::Default; +/// # use youtube3::{YouTube, oauth2, hyper, hyper_rustls, chrono, FieldMask}; +/// +/// # let secret: oauth2::ApplicationSecret = Default::default(); +/// # let auth = oauth2::InstalledFlowAuthenticator::builder( +/// # secret, +/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, +/// # ).build().await.unwrap(); +/// # let mut hub = YouTube::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().unwrap().https_or_http().enable_http1().build()), auth); +/// // As the method needs a request, you would usually fill it with the desired information +/// // into the respective structure. Some of the parts shown here might not be applicable ! +/// // Values shown here are possibly random and not representative ! +/// let mut req = LiveBroadcast::default(); +/// req.content_details = Default::default(); // is LiveBroadcastContentDetails +/// req.id = Some("Lorem".to_string()); +/// req.snippet = Default::default(); // is LiveBroadcastSnippet +/// req.status = Default::default(); // is LiveBroadcastStatus +/// +/// // You can configure optional parameters by calling 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().update(req) +/// .on_behalf_of_content_owner_channel("ea") +/// .on_behalf_of_content_owner("Stet") +/// .doit().await; +/// # } +/// ``` +pub struct LiveBroadcastUpdateCall<'a, S> + where S: 'a { + + pub(super) hub: &'a YouTube, + pub(super) _request: LiveBroadcast, + pub(super) _part: Vec, + pub(super) _on_behalf_of_content_owner_channel: Option, + pub(super) _on_behalf_of_content_owner: Option, + pub(super) _delegate: Option<&'a mut dyn client::Delegate>, + pub(super) _additional_params: HashMap, + pub(super) _scopes: BTreeSet +} + +impl<'a, S> client::CallBuilder for LiveBroadcastUpdateCall<'a, S> {} + +impl<'a, S> LiveBroadcastUpdateCall<'a, S> +where + S: tower_service::Service + Clone + Send + Sync + 'static, + S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, + S::Future: Send + Unpin + 'static, + S::Error: Into>, +{ + + + /// Perform the operation you have build so far. + pub async fn doit(mut self) -> client::Result<(hyper::Response, LiveBroadcast)> { + use std::io::{Read, Seek}; + use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; + use client::{ToParts, url::Params}; + use std::borrow::Cow; + + let mut dd = client::DefaultDelegate; + let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd); + dlg.begin(client::MethodInfo { id: "youtube.liveBroadcasts.update", + http_method: hyper::Method::PUT }); + + for &field in ["alt", "part", "onBehalfOfContentOwnerChannel", "onBehalfOfContentOwner"].iter() { + if self._additional_params.contains_key(field) { + dlg.finished(false); + return Err(client::Error::FieldClash(field)); + } + } + + let mut params = Params::with_capacity(6 + self._additional_params.len()); + if self._part.is_empty() { + self._part.push(self._request.to_parts()); + } + if self._part.len() > 0 { + for f in self._part.iter() { + params.push("part", f); + } + } + if let Some(value) = self._on_behalf_of_content_owner_channel.as_ref() { + params.push("onBehalfOfContentOwnerChannel", value); + } + if let Some(value) = self._on_behalf_of_content_owner.as_ref() { + params.push("onBehalfOfContentOwner", value); + } + + params.extend(self._additional_params.iter()); + + params.push("alt", "json"); + let mut url = self.hub._base_url.clone() + "youtube/v3/liveBroadcasts"; + if self._scopes.is_empty() { + self._scopes.insert(Scope::Full.as_ref().to_string()); + } + + + let url = params.parse_with_url(&url); + + let mut json_mime_type = mime::APPLICATION_JSON; + let mut request_value_reader = + { + let mut value = json::value::to_value(&self._request).expect("serde to work"); + client::remove_json_null_values(&mut value); + let mut dst = io::Cursor::new(Vec::with_capacity(128)); + json::to_writer(&mut dst, &value).unwrap(); + dst + }; + let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); + request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); + + + loop { + let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]).await { + Ok(token) => token, + Err(e) => { + match dlg.token(e) { + Ok(token) => token, + Err(e) => { + dlg.finished(false); + return Err(client::Error::MissingToken(e)); + } + } + } + }; + request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); + let mut req_result = { + let client = &self.hub.client; + dlg.pre_request(); + let mut req_builder = hyper::Request::builder() + .method(hyper::Method::PUT) + .uri(url.as_str()) + .header(USER_AGENT, self.hub._user_agent.clone()); + + if let Some(token) = token.as_ref() { + req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); + } + + + let request = req_builder + .header(CONTENT_TYPE, json_mime_type.to_string()) + .header(CONTENT_LENGTH, request_size as u64) + .body(hyper::body::Body::from(request_value_reader.get_ref().clone())); + + client.request(request.unwrap()).await + + }; + + match req_result { + Err(err) => { + if let client::Retry::After(d) = dlg.http_error(&err) { + sleep(d).await; + continue; + } + dlg.finished(false); + return Err(client::Error::HttpError(err)) + } + Ok(mut res) => { + if !res.status().is_success() { + let res_body_string = client::get_body_as_string(res.body_mut()).await; + let (parts, _) = res.into_parts(); + let body = hyper::Body::from(res_body_string.clone()); + let restored_response = hyper::Response::from_parts(parts, body); + + let server_response = json::from_str::(&res_body_string).ok(); + + if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { + sleep(d).await; + continue; + } + + dlg.finished(false); + + return match server_response { + Some(error_value) => Err(client::Error::BadRequest(error_value)), + None => Err(client::Error::Failure(restored_response)), + } + } + let result_value = { + let res_body_string = client::get_body_as_string(res.body_mut()).await; + + match json::from_str(&res_body_string) { + Ok(decoded) => (res, decoded), + Err(err) => { + dlg.response_json_decode_error(&res_body_string, &err); + return Err(client::Error::JsonDecodeError(res_body_string, err)); + } + } + }; + + dlg.finished(true); + return Ok(result_value) + } + } + } + } + + + /// + /// Sets the *request* property to the given value. + /// + /// Even though the property as already been set when instantiating this call, + /// we provide this method for API completeness. + /// + /// **Settable Parts** + /// + /// * *id* + /// * *snippet* + /// * *contentDetails* + /// * *status* + pub fn request(mut self, new_value: LiveBroadcast) -> LiveBroadcastUpdateCall<'a, S> { + self._request = new_value; + self + } + /// The *part* parameter serves two purposes in this operation. It identifies the properties that the write operation will set as well as the properties that the API response will include. The part properties that you can include in the parameter value are id, snippet, contentDetails, and status. Note that this method will override the existing values for all of the mutable properties that are contained in any parts that the parameter value specifies. For example, a broadcast's privacy status is defined in the status part. As such, if your request is updating a private or unlisted broadcast, and the request's part parameter value includes the status part, the broadcast's privacy setting will be updated to whatever value the request body specifies. If the request body does not specify a value, the existing privacy setting will be removed and the broadcast will revert to the default privacy setting. + /// + /// Append the given value to the *part* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + /// + /// Even though the *parts* list is automatically derived from *Resource* passed in + /// during instantiation and indicates which values you are passing, the response would contain the very same parts. + /// This may not always be desirable, as you can obtain (newly generated) parts you cannot pass in, + /// like statistics that are generated server side. Therefore you should use this method to specify + /// the parts you provide in addition to the ones you want in the response. + /// + /// **Settable Parts** + /// + /// * *id* + /// * *snippet* + /// * *contentDetails* + /// * *status* + pub fn add_part(mut self, new_value: &str) -> LiveBroadcastUpdateCall<'a, S> { + self._part.push(new_value.to_string()); + self + } + /// This parameter can only be used in a properly authorized request. *Note:* This parameter is intended exclusively for YouTube content partners. The *onBehalfOfContentOwnerChannel* parameter specifies the YouTube channel ID of the channel to which a video is being added. This parameter is required when a request specifies a value for the onBehalfOfContentOwner parameter, and it can only be used in conjunction with that parameter. In addition, the request must be authorized using a CMS account that is linked to the content owner that the onBehalfOfContentOwner parameter specifies. Finally, the channel that the onBehalfOfContentOwnerChannel parameter value specifies must be linked to the content owner that the onBehalfOfContentOwner parameter specifies. This parameter is intended for YouTube content partners that own and manage many different YouTube channels. It allows content owners to authenticate once and perform actions on behalf of the channel specified in the parameter value, without having to provide authentication credentials for each separate channel. + /// + /// Sets the *on behalf of content owner channel* query property to the given value. + pub fn on_behalf_of_content_owner_channel(mut self, new_value: &str) -> LiveBroadcastUpdateCall<'a, S> { + self._on_behalf_of_content_owner_channel = Some(new_value.to_string()); + self + } + /// *Note:* This parameter is intended exclusively for YouTube content partners. The *onBehalfOfContentOwner* parameter indicates that the request's authorization credentials identify a YouTube CMS user who is acting on behalf of the content owner specified in the parameter value. This parameter is intended for YouTube content partners that own and manage many different YouTube channels. It allows content owners to authenticate once and get access to all their video and channel data, without having to provide authentication credentials for each individual channel. The CMS account that the user authenticates with must be linked to the specified YouTube content owner. + /// + /// Sets the *on behalf of content owner* query property to the given value. + pub fn on_behalf_of_content_owner(mut self, new_value: &str) -> LiveBroadcastUpdateCall<'a, S> { + self._on_behalf_of_content_owner = 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. + /// + /// ````text + /// It should be used to handle progress information, and to implement a certain level of resilience. + /// ```` + /// + /// Sets the *delegate* property to the given value. + pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> LiveBroadcastUpdateCall<'a, S> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not be used to set any of the known parameters + /// which have their own setter method. If done anyway, the request will fail. + /// + /// # Additional Parameters + /// + /// * *$.xgafv* (query-string) - V1 error format. + /// * *access_token* (query-string) - OAuth access token. + /// * *alt* (query-string) - Data format for response. + /// * *callback* (query-string) - JSONP + /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. + /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. + /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. + /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. + /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. + /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). + /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). + pub fn param(mut self, name: T, value: T) -> LiveBroadcastUpdateCall<'a, S> + where T: AsRef { + self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); + self + } + + /// Identifies the authorization scope for the method you are building. + /// + /// Use this method to actively specify which scope should be used, instead of 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: St) -> LiveBroadcastUpdateCall<'a, S> + where St: AsRef { + self._scopes.insert(String::from(scope.as_ref())); + self + } + /// Identifies the authorization scope(s) for the method you are building. + /// + /// See [`Self::add_scope()`] for details. + pub fn add_scopes(mut self, scopes: I) -> LiveBroadcastUpdateCall<'a, S> + where I: IntoIterator, + St: AsRef { + self._scopes + .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); + self + } + + /// Removes all scopes, and no default scope will be used either. + /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] + /// for details). + pub fn clear_scopes(mut self) -> LiveBroadcastUpdateCall<'a, S> { + self._scopes.clear(); + self + } +} + + +/// Deletes a chat ban. +/// +/// A builder for the *delete* method supported by a *liveChatBan* resource. +/// It is not used directly, but through a [`LiveChatBanMethods`] instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate hyper_rustls; +/// # extern crate google_youtube3 as youtube3; +/// # async fn dox() { +/// # use std::default::Default; +/// # use youtube3::{YouTube, oauth2, hyper, hyper_rustls, chrono, FieldMask}; +/// +/// # let secret: oauth2::ApplicationSecret = Default::default(); +/// # let auth = oauth2::InstalledFlowAuthenticator::builder( +/// # secret, +/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, +/// # ).build().await.unwrap(); +/// # let mut hub = YouTube::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().unwrap().https_or_http().enable_http1().build()), auth); +/// // You can configure optional parameters by calling 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_chat_bans().delete("id") +/// .doit().await; +/// # } +/// ``` +pub struct LiveChatBanDeleteCall<'a, S> + where S: 'a { + + pub(super) hub: &'a YouTube, + pub(super) _id: String, + pub(super) _delegate: Option<&'a mut dyn client::Delegate>, + pub(super) _additional_params: HashMap, + pub(super) _scopes: BTreeSet +} + +impl<'a, S> client::CallBuilder for LiveChatBanDeleteCall<'a, S> {} + +impl<'a, S> LiveChatBanDeleteCall<'a, S> +where + S: tower_service::Service + Clone + Send + Sync + 'static, + S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, + S::Future: Send + Unpin + 'static, + S::Error: Into>, +{ + + + /// Perform the operation you have build so far. + pub async fn doit(mut self) -> client::Result> { + use std::io::{Read, Seek}; + use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; + use client::{ToParts, url::Params}; + use std::borrow::Cow; + + let mut dd = client::DefaultDelegate; + let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd); + dlg.begin(client::MethodInfo { id: "youtube.liveChatBans.delete", + http_method: hyper::Method::DELETE }); + + for &field in ["id"].iter() { + if self._additional_params.contains_key(field) { + dlg.finished(false); + return Err(client::Error::FieldClash(field)); + } + } + + let mut params = Params::with_capacity(2 + self._additional_params.len()); + params.push("id", &self._id); + + params.extend(self._additional_params.iter()); + + let mut url = self.hub._base_url.clone() + "youtube/v3/liveChat/bans"; + if self._scopes.is_empty() { + self._scopes.insert(Scope::Full.as_ref().to_string()); + } + + + let url = params.parse_with_url(&url); + + + + loop { + let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]).await { + Ok(token) => token, + Err(e) => { + match dlg.token(e) { + Ok(token) => token, + Err(e) => { + dlg.finished(false); + return Err(client::Error::MissingToken(e)); + } + } + } + }; + let mut req_result = { + let client = &self.hub.client; + dlg.pre_request(); + let mut req_builder = hyper::Request::builder() + .method(hyper::Method::DELETE) + .uri(url.as_str()) + .header(USER_AGENT, self.hub._user_agent.clone()); + + if let Some(token) = token.as_ref() { + req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); + } + + + let request = req_builder + .header(CONTENT_LENGTH, 0_u64) + .body(hyper::body::Body::empty()); + + client.request(request.unwrap()).await + + }; + + match req_result { + Err(err) => { + if let client::Retry::After(d) = dlg.http_error(&err) { + sleep(d).await; + continue; + } + dlg.finished(false); + return Err(client::Error::HttpError(err)) + } + Ok(mut res) => { + if !res.status().is_success() { + let res_body_string = client::get_body_as_string(res.body_mut()).await; + let (parts, _) = res.into_parts(); + let body = hyper::Body::from(res_body_string.clone()); + let restored_response = hyper::Response::from_parts(parts, body); + + let server_response = json::from_str::(&res_body_string).ok(); + + if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { + sleep(d).await; + continue; + } + + dlg.finished(false); + + return match server_response { + Some(error_value) => Err(client::Error::BadRequest(error_value)), + None => Err(client::Error::Failure(restored_response)), + } + } + let result_value = res; + + dlg.finished(true); + return Ok(result_value) + } + } + } + } + + + /// + /// 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) -> LiveChatBanDeleteCall<'a, S> { + 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. + /// + /// ````text + /// It should be used to handle progress information, and to implement a certain level of resilience. + /// ```` + /// + /// Sets the *delegate* property to the given value. + pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> LiveChatBanDeleteCall<'a, S> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not be used to set any of the known parameters + /// which have their own setter method. If done anyway, the request will fail. + /// + /// # Additional Parameters + /// + /// * *$.xgafv* (query-string) - V1 error format. + /// * *access_token* (query-string) - OAuth access token. + /// * *alt* (query-string) - Data format for response. + /// * *callback* (query-string) - JSONP + /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. + /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. + /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. + /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. + /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. + /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). + /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). + pub fn param(mut self, name: T, value: T) -> LiveChatBanDeleteCall<'a, S> + where T: AsRef { + self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); + self + } + + /// Identifies the authorization scope for the method you are building. + /// + /// Use this method to actively specify which scope should be used, instead of 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: St) -> LiveChatBanDeleteCall<'a, S> + where St: AsRef { + self._scopes.insert(String::from(scope.as_ref())); + self + } + /// Identifies the authorization scope(s) for the method you are building. + /// + /// See [`Self::add_scope()`] for details. + pub fn add_scopes(mut self, scopes: I) -> LiveChatBanDeleteCall<'a, S> + where I: IntoIterator, + St: AsRef { + self._scopes + .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); + self + } + + /// Removes all scopes, and no default scope will be used either. + /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] + /// for details). + pub fn clear_scopes(mut self) -> LiveChatBanDeleteCall<'a, S> { + self._scopes.clear(); + self + } +} + + +/// Inserts a new resource into this collection. +/// +/// A builder for the *insert* method supported by a *liveChatBan* resource. +/// It is not used directly, but through a [`LiveChatBanMethods`] instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate hyper_rustls; +/// # extern crate google_youtube3 as youtube3; +/// use youtube3::api::LiveChatBan; +/// # async fn dox() { +/// # use std::default::Default; +/// # use youtube3::{YouTube, oauth2, hyper, hyper_rustls, chrono, FieldMask}; +/// +/// # let secret: oauth2::ApplicationSecret = Default::default(); +/// # let auth = oauth2::InstalledFlowAuthenticator::builder( +/// # secret, +/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, +/// # ).build().await.unwrap(); +/// # let mut hub = YouTube::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().unwrap().https_or_http().enable_http1().build()), auth); +/// // As the method needs a request, you would usually fill it with the desired information +/// // into the respective structure. Some of the parts shown here might not be applicable ! +/// // Values shown here are possibly random and not representative ! +/// let mut req = LiveChatBan::default(); +/// +/// // You can configure optional parameters by calling 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_chat_bans().insert(req) +/// .doit().await; +/// # } +/// ``` +pub struct LiveChatBanInsertCall<'a, S> + where S: 'a { + + pub(super) hub: &'a YouTube, + pub(super) _request: LiveChatBan, + pub(super) _part: Vec, + pub(super) _delegate: Option<&'a mut dyn client::Delegate>, + pub(super) _additional_params: HashMap, + pub(super) _scopes: BTreeSet +} + +impl<'a, S> client::CallBuilder for LiveChatBanInsertCall<'a, S> {} + +impl<'a, S> LiveChatBanInsertCall<'a, S> +where + S: tower_service::Service + Clone + Send + Sync + 'static, + S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, + S::Future: Send + Unpin + 'static, + S::Error: Into>, +{ + + + /// Perform the operation you have build so far. + pub async fn doit(mut self) -> client::Result<(hyper::Response, LiveChatBan)> { + use std::io::{Read, Seek}; + use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; + use client::{ToParts, url::Params}; + use std::borrow::Cow; + + let mut dd = client::DefaultDelegate; + let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd); + dlg.begin(client::MethodInfo { id: "youtube.liveChatBans.insert", + http_method: hyper::Method::POST }); + + for &field in ["alt", "part"].iter() { + if self._additional_params.contains_key(field) { + dlg.finished(false); + return Err(client::Error::FieldClash(field)); + } + } + + let mut params = Params::with_capacity(4 + self._additional_params.len()); + if self._part.is_empty() { + self._part.push(self._request.to_parts()); + } + if self._part.len() > 0 { + for f in self._part.iter() { + params.push("part", f); + } + } + + params.extend(self._additional_params.iter()); + + params.push("alt", "json"); + let mut url = self.hub._base_url.clone() + "youtube/v3/liveChat/bans"; + if self._scopes.is_empty() { + self._scopes.insert(Scope::Full.as_ref().to_string()); + } + + + let url = params.parse_with_url(&url); + + let mut json_mime_type = mime::APPLICATION_JSON; + let mut request_value_reader = + { + let mut value = json::value::to_value(&self._request).expect("serde to work"); + client::remove_json_null_values(&mut value); + let mut dst = io::Cursor::new(Vec::with_capacity(128)); + json::to_writer(&mut dst, &value).unwrap(); + dst + }; + let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); + request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); + + + loop { + let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]).await { + Ok(token) => token, + Err(e) => { + match dlg.token(e) { + Ok(token) => token, + Err(e) => { + dlg.finished(false); + return Err(client::Error::MissingToken(e)); + } + } + } + }; + request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); + let mut req_result = { + let client = &self.hub.client; + dlg.pre_request(); + let mut req_builder = hyper::Request::builder() + .method(hyper::Method::POST) + .uri(url.as_str()) + .header(USER_AGENT, self.hub._user_agent.clone()); + + if let Some(token) = token.as_ref() { + req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); + } + + + let request = req_builder + .header(CONTENT_TYPE, json_mime_type.to_string()) + .header(CONTENT_LENGTH, request_size as u64) + .body(hyper::body::Body::from(request_value_reader.get_ref().clone())); + + client.request(request.unwrap()).await + + }; + + match req_result { + Err(err) => { + if let client::Retry::After(d) = dlg.http_error(&err) { + sleep(d).await; + continue; + } + dlg.finished(false); + return Err(client::Error::HttpError(err)) + } + Ok(mut res) => { + if !res.status().is_success() { + let res_body_string = client::get_body_as_string(res.body_mut()).await; + let (parts, _) = res.into_parts(); + let body = hyper::Body::from(res_body_string.clone()); + let restored_response = hyper::Response::from_parts(parts, body); + + let server_response = json::from_str::(&res_body_string).ok(); + + if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { + sleep(d).await; + continue; + } + + dlg.finished(false); + + return match server_response { + Some(error_value) => Err(client::Error::BadRequest(error_value)), + None => Err(client::Error::Failure(restored_response)), + } + } + let result_value = { + let res_body_string = client::get_body_as_string(res.body_mut()).await; + + match json::from_str(&res_body_string) { + Ok(decoded) => (res, decoded), + Err(err) => { + dlg.response_json_decode_error(&res_body_string, &err); + return Err(client::Error::JsonDecodeError(res_body_string, err)); + } + } + }; + + dlg.finished(true); + return Ok(result_value) + } + } + } + } + + + /// + /// Sets the *request* property to the given value. + /// + /// Even though the property as already been set when instantiating this call, + /// we provide this method for API completeness. + pub fn request(mut self, new_value: LiveChatBan) -> LiveChatBanInsertCall<'a, S> { + self._request = new_value; + self + } + /// The *part* parameter serves two purposes in this operation. It identifies the properties that the write operation will set as well as the properties that the API response returns. Set the parameter value to snippet. + /// + /// Append the given value to the *part* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + /// + /// Even though the *parts* list is automatically derived from *Resource* passed in + /// during instantiation and indicates which values you are passing, the response would contain the very same parts. + /// This may not always be desirable, as you can obtain (newly generated) parts you cannot pass in, + /// like statistics that are generated server side. Therefore you should use this method to specify + /// the parts you provide in addition to the ones you want in the response. + pub fn add_part(mut self, new_value: &str) -> LiveChatBanInsertCall<'a, S> { + self._part.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. + /// + /// ````text + /// It should be used to handle progress information, and to implement a certain level of resilience. + /// ```` + /// + /// Sets the *delegate* property to the given value. + pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> LiveChatBanInsertCall<'a, S> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not be used to set any of the known parameters + /// which have their own setter method. If done anyway, the request will fail. + /// + /// # Additional Parameters + /// + /// * *$.xgafv* (query-string) - V1 error format. + /// * *access_token* (query-string) - OAuth access token. + /// * *alt* (query-string) - Data format for response. + /// * *callback* (query-string) - JSONP + /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. + /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. + /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. + /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. + /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. + /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). + /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). + pub fn param(mut self, name: T, value: T) -> LiveChatBanInsertCall<'a, S> + where T: AsRef { + self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); + self + } + + /// Identifies the authorization scope for the method you are building. + /// + /// Use this method to actively specify which scope should be used, instead of 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: St) -> LiveChatBanInsertCall<'a, S> + where St: AsRef { + self._scopes.insert(String::from(scope.as_ref())); + self + } + /// Identifies the authorization scope(s) for the method you are building. + /// + /// See [`Self::add_scope()`] for details. + pub fn add_scopes(mut self, scopes: I) -> LiveChatBanInsertCall<'a, S> + where I: IntoIterator, + St: AsRef { + self._scopes + .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); + self + } + + /// Removes all scopes, and no default scope will be used either. + /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] + /// for details). + pub fn clear_scopes(mut self) -> LiveChatBanInsertCall<'a, S> { + self._scopes.clear(); + self + } +} + + +/// Deletes a chat message. +/// +/// A builder for the *delete* method supported by a *liveChatMessage* resource. +/// It is not used directly, but through a [`LiveChatMessageMethods`] instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate hyper_rustls; +/// # extern crate google_youtube3 as youtube3; +/// # async fn dox() { +/// # use std::default::Default; +/// # use youtube3::{YouTube, oauth2, hyper, hyper_rustls, chrono, FieldMask}; +/// +/// # let secret: oauth2::ApplicationSecret = Default::default(); +/// # let auth = oauth2::InstalledFlowAuthenticator::builder( +/// # secret, +/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, +/// # ).build().await.unwrap(); +/// # let mut hub = YouTube::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().unwrap().https_or_http().enable_http1().build()), auth); +/// // You can configure optional parameters by calling 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_chat_messages().delete("id") +/// .doit().await; +/// # } +/// ``` +pub struct LiveChatMessageDeleteCall<'a, S> + where S: 'a { + + pub(super) hub: &'a YouTube, + pub(super) _id: String, + pub(super) _delegate: Option<&'a mut dyn client::Delegate>, + pub(super) _additional_params: HashMap, + pub(super) _scopes: BTreeSet +} + +impl<'a, S> client::CallBuilder for LiveChatMessageDeleteCall<'a, S> {} + +impl<'a, S> LiveChatMessageDeleteCall<'a, S> +where + S: tower_service::Service + Clone + Send + Sync + 'static, + S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, + S::Future: Send + Unpin + 'static, + S::Error: Into>, +{ + + + /// Perform the operation you have build so far. + pub async fn doit(mut self) -> client::Result> { + use std::io::{Read, Seek}; + use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; + use client::{ToParts, url::Params}; + use std::borrow::Cow; + + let mut dd = client::DefaultDelegate; + let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd); + dlg.begin(client::MethodInfo { id: "youtube.liveChatMessages.delete", + http_method: hyper::Method::DELETE }); + + for &field in ["id"].iter() { + if self._additional_params.contains_key(field) { + dlg.finished(false); + return Err(client::Error::FieldClash(field)); + } + } + + let mut params = Params::with_capacity(2 + self._additional_params.len()); + params.push("id", &self._id); + + params.extend(self._additional_params.iter()); + + let mut url = self.hub._base_url.clone() + "youtube/v3/liveChat/messages"; + if self._scopes.is_empty() { + self._scopes.insert(Scope::Full.as_ref().to_string()); + } + + + let url = params.parse_with_url(&url); + + + + loop { + let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]).await { + Ok(token) => token, + Err(e) => { + match dlg.token(e) { + Ok(token) => token, + Err(e) => { + dlg.finished(false); + return Err(client::Error::MissingToken(e)); + } + } + } + }; + let mut req_result = { + let client = &self.hub.client; + dlg.pre_request(); + let mut req_builder = hyper::Request::builder() + .method(hyper::Method::DELETE) + .uri(url.as_str()) + .header(USER_AGENT, self.hub._user_agent.clone()); + + if let Some(token) = token.as_ref() { + req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); + } + + + let request = req_builder + .header(CONTENT_LENGTH, 0_u64) + .body(hyper::body::Body::empty()); + + client.request(request.unwrap()).await + + }; + + match req_result { + Err(err) => { + if let client::Retry::After(d) = dlg.http_error(&err) { + sleep(d).await; + continue; + } + dlg.finished(false); + return Err(client::Error::HttpError(err)) + } + Ok(mut res) => { + if !res.status().is_success() { + let res_body_string = client::get_body_as_string(res.body_mut()).await; + let (parts, _) = res.into_parts(); + let body = hyper::Body::from(res_body_string.clone()); + let restored_response = hyper::Response::from_parts(parts, body); + + let server_response = json::from_str::(&res_body_string).ok(); + + if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { + sleep(d).await; + continue; + } + + dlg.finished(false); + + return match server_response { + Some(error_value) => Err(client::Error::BadRequest(error_value)), + None => Err(client::Error::Failure(restored_response)), + } + } + let result_value = res; + + dlg.finished(true); + return Ok(result_value) + } + } + } + } + + + /// + /// 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) -> LiveChatMessageDeleteCall<'a, S> { + 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. + /// + /// ````text + /// It should be used to handle progress information, and to implement a certain level of resilience. + /// ```` + /// + /// Sets the *delegate* property to the given value. + pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> LiveChatMessageDeleteCall<'a, S> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not be used to set any of the known parameters + /// which have their own setter method. If done anyway, the request will fail. + /// + /// # Additional Parameters + /// + /// * *$.xgafv* (query-string) - V1 error format. + /// * *access_token* (query-string) - OAuth access token. + /// * *alt* (query-string) - Data format for response. + /// * *callback* (query-string) - JSONP + /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. + /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. + /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. + /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. + /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. + /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). + /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). + pub fn param(mut self, name: T, value: T) -> LiveChatMessageDeleteCall<'a, S> + where T: AsRef { + self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); + self + } + + /// Identifies the authorization scope for the method you are building. + /// + /// Use this method to actively specify which scope should be used, instead of 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: St) -> LiveChatMessageDeleteCall<'a, S> + where St: AsRef { + self._scopes.insert(String::from(scope.as_ref())); + self + } + /// Identifies the authorization scope(s) for the method you are building. + /// + /// See [`Self::add_scope()`] for details. + pub fn add_scopes(mut self, scopes: I) -> LiveChatMessageDeleteCall<'a, S> + where I: IntoIterator, + St: AsRef { + self._scopes + .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); + self + } + + /// Removes all scopes, and no default scope will be used either. + /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] + /// for details). + pub fn clear_scopes(mut self) -> LiveChatMessageDeleteCall<'a, S> { + self._scopes.clear(); + self + } +} + + +/// Inserts a new resource into this collection. +/// +/// A builder for the *insert* method supported by a *liveChatMessage* resource. +/// It is not used directly, but through a [`LiveChatMessageMethods`] instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate hyper_rustls; +/// # extern crate google_youtube3 as youtube3; +/// use youtube3::api::LiveChatMessage; +/// # async fn dox() { +/// # use std::default::Default; +/// # use youtube3::{YouTube, oauth2, hyper, hyper_rustls, chrono, FieldMask}; +/// +/// # let secret: oauth2::ApplicationSecret = Default::default(); +/// # let auth = oauth2::InstalledFlowAuthenticator::builder( +/// # secret, +/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, +/// # ).build().await.unwrap(); +/// # let mut hub = YouTube::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().unwrap().https_or_http().enable_http1().build()), auth); +/// // As the method needs a request, you would usually fill it with the desired information +/// // into the respective structure. Some of the parts shown here might not be applicable ! +/// // Values shown here are possibly random and not representative ! +/// let mut req = LiveChatMessage::default(); +/// +/// // You can configure optional parameters by calling 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_chat_messages().insert(req) +/// .doit().await; +/// # } +/// ``` +pub struct LiveChatMessageInsertCall<'a, S> + where S: 'a { + + pub(super) hub: &'a YouTube, + pub(super) _request: LiveChatMessage, + pub(super) _part: Vec, + pub(super) _delegate: Option<&'a mut dyn client::Delegate>, + pub(super) _additional_params: HashMap, + pub(super) _scopes: BTreeSet +} + +impl<'a, S> client::CallBuilder for LiveChatMessageInsertCall<'a, S> {} + +impl<'a, S> LiveChatMessageInsertCall<'a, S> +where + S: tower_service::Service + Clone + Send + Sync + 'static, + S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, + S::Future: Send + Unpin + 'static, + S::Error: Into>, +{ + + + /// Perform the operation you have build so far. + pub async fn doit(mut self) -> client::Result<(hyper::Response, LiveChatMessage)> { + use std::io::{Read, Seek}; + use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; + use client::{ToParts, url::Params}; + use std::borrow::Cow; + + let mut dd = client::DefaultDelegate; + let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd); + dlg.begin(client::MethodInfo { id: "youtube.liveChatMessages.insert", + http_method: hyper::Method::POST }); + + for &field in ["alt", "part"].iter() { + if self._additional_params.contains_key(field) { + dlg.finished(false); + return Err(client::Error::FieldClash(field)); + } + } + + let mut params = Params::with_capacity(4 + self._additional_params.len()); + if self._part.is_empty() { + self._part.push(self._request.to_parts()); + } + if self._part.len() > 0 { + for f in self._part.iter() { + params.push("part", f); + } + } + + params.extend(self._additional_params.iter()); + + params.push("alt", "json"); + let mut url = self.hub._base_url.clone() + "youtube/v3/liveChat/messages"; + if self._scopes.is_empty() { + self._scopes.insert(Scope::Full.as_ref().to_string()); + } + + + let url = params.parse_with_url(&url); + + let mut json_mime_type = mime::APPLICATION_JSON; + let mut request_value_reader = + { + let mut value = json::value::to_value(&self._request).expect("serde to work"); + client::remove_json_null_values(&mut value); + let mut dst = io::Cursor::new(Vec::with_capacity(128)); + json::to_writer(&mut dst, &value).unwrap(); + dst + }; + let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); + request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); + + + loop { + let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]).await { + Ok(token) => token, + Err(e) => { + match dlg.token(e) { + Ok(token) => token, + Err(e) => { + dlg.finished(false); + return Err(client::Error::MissingToken(e)); + } + } + } + }; + request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); + let mut req_result = { + let client = &self.hub.client; + dlg.pre_request(); + let mut req_builder = hyper::Request::builder() + .method(hyper::Method::POST) + .uri(url.as_str()) + .header(USER_AGENT, self.hub._user_agent.clone()); + + if let Some(token) = token.as_ref() { + req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); + } + + + let request = req_builder + .header(CONTENT_TYPE, json_mime_type.to_string()) + .header(CONTENT_LENGTH, request_size as u64) + .body(hyper::body::Body::from(request_value_reader.get_ref().clone())); + + client.request(request.unwrap()).await + + }; + + match req_result { + Err(err) => { + if let client::Retry::After(d) = dlg.http_error(&err) { + sleep(d).await; + continue; + } + dlg.finished(false); + return Err(client::Error::HttpError(err)) + } + Ok(mut res) => { + if !res.status().is_success() { + let res_body_string = client::get_body_as_string(res.body_mut()).await; + let (parts, _) = res.into_parts(); + let body = hyper::Body::from(res_body_string.clone()); + let restored_response = hyper::Response::from_parts(parts, body); + + let server_response = json::from_str::(&res_body_string).ok(); + + if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { + sleep(d).await; + continue; + } + + dlg.finished(false); + + return match server_response { + Some(error_value) => Err(client::Error::BadRequest(error_value)), + None => Err(client::Error::Failure(restored_response)), + } + } + let result_value = { + let res_body_string = client::get_body_as_string(res.body_mut()).await; + + match json::from_str(&res_body_string) { + Ok(decoded) => (res, decoded), + Err(err) => { + dlg.response_json_decode_error(&res_body_string, &err); + return Err(client::Error::JsonDecodeError(res_body_string, err)); + } + } + }; + + dlg.finished(true); + return Ok(result_value) + } + } + } + } + + + /// + /// Sets the *request* property to the given value. + /// + /// Even though the property as already been set when instantiating this call, + /// we provide this method for API completeness. + pub fn request(mut self, new_value: LiveChatMessage) -> LiveChatMessageInsertCall<'a, S> { + self._request = new_value; + self + } + /// The *part* parameter serves two purposes. It identifies the properties that the write operation will set as well as the properties that the API response will include. Set the parameter value to snippet. + /// + /// Append the given value to the *part* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + /// + /// Even though the *parts* list is automatically derived from *Resource* passed in + /// during instantiation and indicates which values you are passing, the response would contain the very same parts. + /// This may not always be desirable, as you can obtain (newly generated) parts you cannot pass in, + /// like statistics that are generated server side. Therefore you should use this method to specify + /// the parts you provide in addition to the ones you want in the response. + pub fn add_part(mut self, new_value: &str) -> LiveChatMessageInsertCall<'a, S> { + self._part.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. + /// + /// ````text + /// It should be used to handle progress information, and to implement a certain level of resilience. + /// ```` + /// + /// Sets the *delegate* property to the given value. + pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> LiveChatMessageInsertCall<'a, S> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not be used to set any of the known parameters + /// which have their own setter method. If done anyway, the request will fail. + /// + /// # Additional Parameters + /// + /// * *$.xgafv* (query-string) - V1 error format. + /// * *access_token* (query-string) - OAuth access token. + /// * *alt* (query-string) - Data format for response. + /// * *callback* (query-string) - JSONP + /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. + /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. + /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. + /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. + /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. + /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). + /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). + pub fn param(mut self, name: T, value: T) -> LiveChatMessageInsertCall<'a, S> + where T: AsRef { + self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); + self + } + + /// Identifies the authorization scope for the method you are building. + /// + /// Use this method to actively specify which scope should be used, instead of 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: St) -> LiveChatMessageInsertCall<'a, S> + where St: AsRef { + self._scopes.insert(String::from(scope.as_ref())); + self + } + /// Identifies the authorization scope(s) for the method you are building. + /// + /// See [`Self::add_scope()`] for details. + pub fn add_scopes(mut self, scopes: I) -> LiveChatMessageInsertCall<'a, S> + where I: IntoIterator, + St: AsRef { + self._scopes + .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); + self + } + + /// Removes all scopes, and no default scope will be used either. + /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] + /// for details). + pub fn clear_scopes(mut self) -> LiveChatMessageInsertCall<'a, S> { + self._scopes.clear(); + self + } +} + + +/// Retrieves a list of resources, possibly filtered. +/// +/// A builder for the *list* method supported by a *liveChatMessage* resource. +/// It is not used directly, but through a [`LiveChatMessageMethods`] instance. +/// +/// **Settable Parts** +/// +/// * *id* +/// * *snippet* +/// +/// # Scopes +/// +/// You will need authorization for at least one of the following scopes to make a valid call, possibly depending on *parts*: +/// +/// * *https://www.googleapis.com/auth/youtube* +/// * *https://www.googleapis.com/auth/youtube.force-ssl* +/// * *https://www.googleapis.com/auth/youtube.readonly* +/// +/// The default scope will be `Scope::Readonly`. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate hyper_rustls; +/// # extern crate google_youtube3 as youtube3; +/// # async fn dox() { +/// # use std::default::Default; +/// # use youtube3::{YouTube, oauth2, hyper, hyper_rustls, chrono, FieldMask}; +/// +/// # let secret: oauth2::ApplicationSecret = Default::default(); +/// # let auth = oauth2::InstalledFlowAuthenticator::builder( +/// # secret, +/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, +/// # ).build().await.unwrap(); +/// # let mut hub = YouTube::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().unwrap().https_or_http().enable_http1().build()), auth); +/// // You can configure optional parameters by calling 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_chat_messages().list("liveChatId", &vec!["sea".into()]) +/// .profile_image_size(27) +/// .page_token("At") +/// .max_results(17) +/// .hl("eirmod") +/// .doit().await; +/// # } +/// ``` +pub struct LiveChatMessageListCall<'a, S> + where S: 'a { + + pub(super) hub: &'a YouTube, + pub(super) _live_chat_id: String, + pub(super) _part: Vec, + pub(super) _profile_image_size: Option, + pub(super) _page_token: Option, + pub(super) _max_results: Option, + pub(super) _hl: Option, + pub(super) _delegate: Option<&'a mut dyn client::Delegate>, + pub(super) _additional_params: HashMap, + pub(super) _scopes: BTreeSet +} + +impl<'a, S> client::CallBuilder for LiveChatMessageListCall<'a, S> {} + +impl<'a, S> LiveChatMessageListCall<'a, S> +where + S: tower_service::Service + Clone + Send + Sync + 'static, + S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, + S::Future: Send + Unpin + 'static, + S::Error: Into>, +{ + + + /// Perform the operation you have build so far. + pub async fn doit(mut self) -> client::Result<(hyper::Response, LiveChatMessageListResponse)> { + use std::io::{Read, Seek}; + use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; + use client::{ToParts, url::Params}; + use std::borrow::Cow; + + let mut dd = client::DefaultDelegate; + let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd); + dlg.begin(client::MethodInfo { id: "youtube.liveChatMessages.list", + http_method: hyper::Method::GET }); + + for &field in ["alt", "liveChatId", "part", "profileImageSize", "pageToken", "maxResults", "hl"].iter() { + if self._additional_params.contains_key(field) { + dlg.finished(false); + return Err(client::Error::FieldClash(field)); + } + } + + let mut params = Params::with_capacity(8 + self._additional_params.len()); + params.push("liveChatId", &self._live_chat_id); + if self._part.len() > 0 { + for f in self._part.iter() { + params.push("part", f); + } + } + if let Some(value) = self._profile_image_size.as_ref() { + params.push("profileImageSize", value.to_string()); + } + if let Some(value) = self._page_token.as_ref() { + params.push("pageToken", value); + } + if let Some(value) = self._max_results.as_ref() { + params.push("maxResults", value.to_string()); + } + if let Some(value) = self._hl.as_ref() { + params.push("hl", value); + } + + params.extend(self._additional_params.iter()); + + params.push("alt", "json"); + let mut url = self.hub._base_url.clone() + "youtube/v3/liveChat/messages"; + if self._scopes.is_empty() { + self._scopes.insert(Scope::Readonly.as_ref().to_string()); + } + + + let url = params.parse_with_url(&url); + + + + loop { + let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]).await { + Ok(token) => token, + Err(e) => { + match dlg.token(e) { + Ok(token) => token, + Err(e) => { + dlg.finished(false); + return Err(client::Error::MissingToken(e)); + } + } + } + }; + let mut req_result = { + let client = &self.hub.client; + dlg.pre_request(); + let mut req_builder = hyper::Request::builder() + .method(hyper::Method::GET) + .uri(url.as_str()) + .header(USER_AGENT, self.hub._user_agent.clone()); + + if let Some(token) = token.as_ref() { + req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); + } + + + let request = req_builder + .header(CONTENT_LENGTH, 0_u64) + .body(hyper::body::Body::empty()); + + client.request(request.unwrap()).await + + }; + + match req_result { + Err(err) => { + if let client::Retry::After(d) = dlg.http_error(&err) { + sleep(d).await; + continue; + } + dlg.finished(false); + return Err(client::Error::HttpError(err)) + } + Ok(mut res) => { + if !res.status().is_success() { + let res_body_string = client::get_body_as_string(res.body_mut()).await; + let (parts, _) = res.into_parts(); + let body = hyper::Body::from(res_body_string.clone()); + let restored_response = hyper::Response::from_parts(parts, body); + + let server_response = json::from_str::(&res_body_string).ok(); + + if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { + sleep(d).await; + continue; + } + + dlg.finished(false); + + return match server_response { + Some(error_value) => Err(client::Error::BadRequest(error_value)), + None => Err(client::Error::Failure(restored_response)), + } + } + let result_value = { + let res_body_string = client::get_body_as_string(res.body_mut()).await; + + match json::from_str(&res_body_string) { + Ok(decoded) => (res, decoded), + Err(err) => { + dlg.response_json_decode_error(&res_body_string, &err); + return Err(client::Error::JsonDecodeError(res_body_string, err)); + } + } + }; + + dlg.finished(true); + return Ok(result_value) + } + } + } + } + + + /// The id of the live chat for which comments should be returned. + /// + /// Sets the *live chat 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 live_chat_id(mut self, new_value: &str) -> LiveChatMessageListCall<'a, S> { + self._live_chat_id = new_value.to_string(); + self + } + /// The *part* parameter specifies the liveChatComment resource parts that the API response will include. Supported values are id and snippet. + /// + /// Append the given value to the *part* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + /// + /// Even though the property as already been set when instantiating this call, + /// we provide this method for API completeness. + /// + /// **Settable Parts** + /// + /// * *id* + /// * *snippet* + pub fn add_part(mut self, new_value: &str) -> LiveChatMessageListCall<'a, S> { + self._part.push(new_value.to_string()); + self + } + /// Specifies the size of the profile image that should be returned for each user. + /// + /// Sets the *profile image size* query property to the given value. + pub fn profile_image_size(mut self, new_value: u32) -> LiveChatMessageListCall<'a, S> { + self._profile_image_size = Some(new_value); + self + } + /// The *pageToken* parameter identifies a specific page in the result set that should be returned. In an API response, the nextPageToken property identify other pages that could be retrieved. + /// + /// Sets the *page token* query property to the given value. + pub fn page_token(mut self, new_value: &str) -> LiveChatMessageListCall<'a, S> { + self._page_token = Some(new_value.to_string()); + self + } + /// The *maxResults* parameter specifies the maximum number of items that should be returned in the result set. + /// + /// Sets the *max results* query property to the given value. + pub fn max_results(mut self, new_value: u32) -> LiveChatMessageListCall<'a, S> { + self._max_results = Some(new_value); + self + } + /// Specifies the localization language in which the system messages should be returned. + /// + /// Sets the *hl* query property to the given value. + pub fn hl(mut self, new_value: &str) -> LiveChatMessageListCall<'a, S> { + self._hl = 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. + /// + /// ````text + /// It should be used to handle progress information, and to implement a certain level of resilience. + /// ```` + /// + /// Sets the *delegate* property to the given value. + pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> LiveChatMessageListCall<'a, S> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not be used to set any of the known parameters + /// which have their own setter method. If done anyway, the request will fail. + /// + /// # Additional Parameters + /// + /// * *$.xgafv* (query-string) - V1 error format. + /// * *access_token* (query-string) - OAuth access token. + /// * *alt* (query-string) - Data format for response. + /// * *callback* (query-string) - JSONP + /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. + /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. + /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. + /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. + /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. + /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). + /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). + pub fn param(mut self, name: T, value: T) -> LiveChatMessageListCall<'a, S> + where T: AsRef { + self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); + self + } + + /// Identifies the authorization scope for the method you are building. + /// + /// Use this method to actively specify which scope should be used, instead of 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: St) -> LiveChatMessageListCall<'a, S> + where St: AsRef { + self._scopes.insert(String::from(scope.as_ref())); + self + } + /// Identifies the authorization scope(s) for the method you are building. + /// + /// See [`Self::add_scope()`] for details. + pub fn add_scopes(mut self, scopes: I) -> LiveChatMessageListCall<'a, S> + where I: IntoIterator, + St: AsRef { + self._scopes + .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); + self + } + + /// Removes all scopes, and no default scope will be used either. + /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] + /// for details). + pub fn clear_scopes(mut self) -> LiveChatMessageListCall<'a, S> { + self._scopes.clear(); + self + } +} + + +/// Deletes a chat moderator. +/// +/// A builder for the *delete* method supported by a *liveChatModerator* resource. +/// It is not used directly, but through a [`LiveChatModeratorMethods`] instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate hyper_rustls; +/// # extern crate google_youtube3 as youtube3; +/// # async fn dox() { +/// # use std::default::Default; +/// # use youtube3::{YouTube, oauth2, hyper, hyper_rustls, chrono, FieldMask}; +/// +/// # let secret: oauth2::ApplicationSecret = Default::default(); +/// # let auth = oauth2::InstalledFlowAuthenticator::builder( +/// # secret, +/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, +/// # ).build().await.unwrap(); +/// # let mut hub = YouTube::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().unwrap().https_or_http().enable_http1().build()), auth); +/// // You can configure optional parameters by calling 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_chat_moderators().delete("id") +/// .doit().await; +/// # } +/// ``` +pub struct LiveChatModeratorDeleteCall<'a, S> + where S: 'a { + + pub(super) hub: &'a YouTube, + pub(super) _id: String, + pub(super) _delegate: Option<&'a mut dyn client::Delegate>, + pub(super) _additional_params: HashMap, + pub(super) _scopes: BTreeSet +} + +impl<'a, S> client::CallBuilder for LiveChatModeratorDeleteCall<'a, S> {} + +impl<'a, S> LiveChatModeratorDeleteCall<'a, S> +where + S: tower_service::Service + Clone + Send + Sync + 'static, + S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, + S::Future: Send + Unpin + 'static, + S::Error: Into>, +{ + + + /// Perform the operation you have build so far. + pub async fn doit(mut self) -> client::Result> { + use std::io::{Read, Seek}; + use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; + use client::{ToParts, url::Params}; + use std::borrow::Cow; + + let mut dd = client::DefaultDelegate; + let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd); + dlg.begin(client::MethodInfo { id: "youtube.liveChatModerators.delete", + http_method: hyper::Method::DELETE }); + + for &field in ["id"].iter() { + if self._additional_params.contains_key(field) { + dlg.finished(false); + return Err(client::Error::FieldClash(field)); + } + } + + let mut params = Params::with_capacity(2 + self._additional_params.len()); + params.push("id", &self._id); + + params.extend(self._additional_params.iter()); + + let mut url = self.hub._base_url.clone() + "youtube/v3/liveChat/moderators"; + if self._scopes.is_empty() { + self._scopes.insert(Scope::Full.as_ref().to_string()); + } + + + let url = params.parse_with_url(&url); + + + + loop { + let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]).await { + Ok(token) => token, + Err(e) => { + match dlg.token(e) { + Ok(token) => token, + Err(e) => { + dlg.finished(false); + return Err(client::Error::MissingToken(e)); + } + } + } + }; + let mut req_result = { + let client = &self.hub.client; + dlg.pre_request(); + let mut req_builder = hyper::Request::builder() + .method(hyper::Method::DELETE) + .uri(url.as_str()) + .header(USER_AGENT, self.hub._user_agent.clone()); + + if let Some(token) = token.as_ref() { + req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); + } + + + let request = req_builder + .header(CONTENT_LENGTH, 0_u64) + .body(hyper::body::Body::empty()); + + client.request(request.unwrap()).await + + }; + + match req_result { + Err(err) => { + if let client::Retry::After(d) = dlg.http_error(&err) { + sleep(d).await; + continue; + } + dlg.finished(false); + return Err(client::Error::HttpError(err)) + } + Ok(mut res) => { + if !res.status().is_success() { + let res_body_string = client::get_body_as_string(res.body_mut()).await; + let (parts, _) = res.into_parts(); + let body = hyper::Body::from(res_body_string.clone()); + let restored_response = hyper::Response::from_parts(parts, body); + + let server_response = json::from_str::(&res_body_string).ok(); + + if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { + sleep(d).await; + continue; + } + + dlg.finished(false); + + return match server_response { + Some(error_value) => Err(client::Error::BadRequest(error_value)), + None => Err(client::Error::Failure(restored_response)), + } + } + let result_value = res; + + dlg.finished(true); + return Ok(result_value) + } + } + } + } + + + /// + /// 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) -> LiveChatModeratorDeleteCall<'a, S> { + 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. + /// + /// ````text + /// It should be used to handle progress information, and to implement a certain level of resilience. + /// ```` + /// + /// Sets the *delegate* property to the given value. + pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> LiveChatModeratorDeleteCall<'a, S> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not be used to set any of the known parameters + /// which have their own setter method. If done anyway, the request will fail. + /// + /// # Additional Parameters + /// + /// * *$.xgafv* (query-string) - V1 error format. + /// * *access_token* (query-string) - OAuth access token. + /// * *alt* (query-string) - Data format for response. + /// * *callback* (query-string) - JSONP + /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. + /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. + /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. + /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. + /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. + /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). + /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). + pub fn param(mut self, name: T, value: T) -> LiveChatModeratorDeleteCall<'a, S> + where T: AsRef { + self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); + self + } + + /// Identifies the authorization scope for the method you are building. + /// + /// Use this method to actively specify which scope should be used, instead of 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: St) -> LiveChatModeratorDeleteCall<'a, S> + where St: AsRef { + self._scopes.insert(String::from(scope.as_ref())); + self + } + /// Identifies the authorization scope(s) for the method you are building. + /// + /// See [`Self::add_scope()`] for details. + pub fn add_scopes(mut self, scopes: I) -> LiveChatModeratorDeleteCall<'a, S> + where I: IntoIterator, + St: AsRef { + self._scopes + .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); + self + } + + /// Removes all scopes, and no default scope will be used either. + /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] + /// for details). + pub fn clear_scopes(mut self) -> LiveChatModeratorDeleteCall<'a, S> { + self._scopes.clear(); + self + } +} + + +/// Inserts a new resource into this collection. +/// +/// A builder for the *insert* method supported by a *liveChatModerator* resource. +/// It is not used directly, but through a [`LiveChatModeratorMethods`] instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate hyper_rustls; +/// # extern crate google_youtube3 as youtube3; +/// use youtube3::api::LiveChatModerator; +/// # async fn dox() { +/// # use std::default::Default; +/// # use youtube3::{YouTube, oauth2, hyper, hyper_rustls, chrono, FieldMask}; +/// +/// # let secret: oauth2::ApplicationSecret = Default::default(); +/// # let auth = oauth2::InstalledFlowAuthenticator::builder( +/// # secret, +/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, +/// # ).build().await.unwrap(); +/// # let mut hub = YouTube::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().unwrap().https_or_http().enable_http1().build()), auth); +/// // As the method needs a request, you would usually fill it with the desired information +/// // into the respective structure. Some of the parts shown here might not be applicable ! +/// // Values shown here are possibly random and not representative ! +/// let mut req = LiveChatModerator::default(); +/// +/// // You can configure optional parameters by calling 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_chat_moderators().insert(req) +/// .doit().await; +/// # } +/// ``` +pub struct LiveChatModeratorInsertCall<'a, S> + where S: 'a { + + pub(super) hub: &'a YouTube, + pub(super) _request: LiveChatModerator, + pub(super) _part: Vec, + pub(super) _delegate: Option<&'a mut dyn client::Delegate>, + pub(super) _additional_params: HashMap, + pub(super) _scopes: BTreeSet +} + +impl<'a, S> client::CallBuilder for LiveChatModeratorInsertCall<'a, S> {} + +impl<'a, S> LiveChatModeratorInsertCall<'a, S> +where + S: tower_service::Service + Clone + Send + Sync + 'static, + S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, + S::Future: Send + Unpin + 'static, + S::Error: Into>, +{ + + + /// Perform the operation you have build so far. + pub async fn doit(mut self) -> client::Result<(hyper::Response, LiveChatModerator)> { + use std::io::{Read, Seek}; + use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; + use client::{ToParts, url::Params}; + use std::borrow::Cow; + + let mut dd = client::DefaultDelegate; + let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd); + dlg.begin(client::MethodInfo { id: "youtube.liveChatModerators.insert", + http_method: hyper::Method::POST }); + + for &field in ["alt", "part"].iter() { + if self._additional_params.contains_key(field) { + dlg.finished(false); + return Err(client::Error::FieldClash(field)); + } + } + + let mut params = Params::with_capacity(4 + self._additional_params.len()); + if self._part.is_empty() { + self._part.push(self._request.to_parts()); + } + if self._part.len() > 0 { + for f in self._part.iter() { + params.push("part", f); + } + } + + params.extend(self._additional_params.iter()); + + params.push("alt", "json"); + let mut url = self.hub._base_url.clone() + "youtube/v3/liveChat/moderators"; + if self._scopes.is_empty() { + self._scopes.insert(Scope::Full.as_ref().to_string()); + } + + + let url = params.parse_with_url(&url); + + let mut json_mime_type = mime::APPLICATION_JSON; + let mut request_value_reader = + { + let mut value = json::value::to_value(&self._request).expect("serde to work"); + client::remove_json_null_values(&mut value); + let mut dst = io::Cursor::new(Vec::with_capacity(128)); + json::to_writer(&mut dst, &value).unwrap(); + dst + }; + let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); + request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); + + + loop { + let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]).await { + Ok(token) => token, + Err(e) => { + match dlg.token(e) { + Ok(token) => token, + Err(e) => { + dlg.finished(false); + return Err(client::Error::MissingToken(e)); + } + } + } + }; + request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); + let mut req_result = { + let client = &self.hub.client; + dlg.pre_request(); + let mut req_builder = hyper::Request::builder() + .method(hyper::Method::POST) + .uri(url.as_str()) + .header(USER_AGENT, self.hub._user_agent.clone()); + + if let Some(token) = token.as_ref() { + req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); + } + + + let request = req_builder + .header(CONTENT_TYPE, json_mime_type.to_string()) + .header(CONTENT_LENGTH, request_size as u64) + .body(hyper::body::Body::from(request_value_reader.get_ref().clone())); + + client.request(request.unwrap()).await + + }; + + match req_result { + Err(err) => { + if let client::Retry::After(d) = dlg.http_error(&err) { + sleep(d).await; + continue; + } + dlg.finished(false); + return Err(client::Error::HttpError(err)) + } + Ok(mut res) => { + if !res.status().is_success() { + let res_body_string = client::get_body_as_string(res.body_mut()).await; + let (parts, _) = res.into_parts(); + let body = hyper::Body::from(res_body_string.clone()); + let restored_response = hyper::Response::from_parts(parts, body); + + let server_response = json::from_str::(&res_body_string).ok(); + + if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { + sleep(d).await; + continue; + } + + dlg.finished(false); + + return match server_response { + Some(error_value) => Err(client::Error::BadRequest(error_value)), + None => Err(client::Error::Failure(restored_response)), + } + } + let result_value = { + let res_body_string = client::get_body_as_string(res.body_mut()).await; + + match json::from_str(&res_body_string) { + Ok(decoded) => (res, decoded), + Err(err) => { + dlg.response_json_decode_error(&res_body_string, &err); + return Err(client::Error::JsonDecodeError(res_body_string, err)); + } + } + }; + + dlg.finished(true); + return Ok(result_value) + } + } + } + } + + + /// + /// Sets the *request* property to the given value. + /// + /// Even though the property as already been set when instantiating this call, + /// we provide this method for API completeness. + pub fn request(mut self, new_value: LiveChatModerator) -> LiveChatModeratorInsertCall<'a, S> { + self._request = new_value; + self + } + /// The *part* parameter serves two purposes in this operation. It identifies the properties that the write operation will set as well as the properties that the API response returns. Set the parameter value to snippet. + /// + /// Append the given value to the *part* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + /// + /// Even though the *parts* list is automatically derived from *Resource* passed in + /// during instantiation and indicates which values you are passing, the response would contain the very same parts. + /// This may not always be desirable, as you can obtain (newly generated) parts you cannot pass in, + /// like statistics that are generated server side. Therefore you should use this method to specify + /// the parts you provide in addition to the ones you want in the response. + pub fn add_part(mut self, new_value: &str) -> LiveChatModeratorInsertCall<'a, S> { + self._part.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. + /// + /// ````text + /// It should be used to handle progress information, and to implement a certain level of resilience. + /// ```` + /// + /// Sets the *delegate* property to the given value. + pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> LiveChatModeratorInsertCall<'a, S> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not be used to set any of the known parameters + /// which have their own setter method. If done anyway, the request will fail. + /// + /// # Additional Parameters + /// + /// * *$.xgafv* (query-string) - V1 error format. + /// * *access_token* (query-string) - OAuth access token. + /// * *alt* (query-string) - Data format for response. + /// * *callback* (query-string) - JSONP + /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. + /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. + /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. + /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. + /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. + /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). + /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). + pub fn param(mut self, name: T, value: T) -> LiveChatModeratorInsertCall<'a, S> + where T: AsRef { + self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); + self + } + + /// Identifies the authorization scope for the method you are building. + /// + /// Use this method to actively specify which scope should be used, instead of 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: St) -> LiveChatModeratorInsertCall<'a, S> + where St: AsRef { + self._scopes.insert(String::from(scope.as_ref())); + self + } + /// Identifies the authorization scope(s) for the method you are building. + /// + /// See [`Self::add_scope()`] for details. + pub fn add_scopes(mut self, scopes: I) -> LiveChatModeratorInsertCall<'a, S> + where I: IntoIterator, + St: AsRef { + self._scopes + .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); + self + } + + /// Removes all scopes, and no default scope will be used either. + /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] + /// for details). + pub fn clear_scopes(mut self) -> LiveChatModeratorInsertCall<'a, S> { + self._scopes.clear(); + self + } +} + + +/// Retrieves a list of resources, possibly filtered. +/// +/// A builder for the *list* method supported by a *liveChatModerator* resource. +/// It is not used directly, but through a [`LiveChatModeratorMethods`] instance. +/// +/// **Settable Parts** +/// +/// * *id* +/// * *snippet* +/// +/// # Scopes +/// +/// You will need authorization for at least one of the following scopes to make a valid call, possibly depending on *parts*: +/// +/// * *https://www.googleapis.com/auth/youtube* +/// * *https://www.googleapis.com/auth/youtube.force-ssl* +/// * *https://www.googleapis.com/auth/youtube.readonly* +/// +/// The default scope will be `Scope::Readonly`. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate hyper_rustls; +/// # extern crate google_youtube3 as youtube3; +/// # async fn dox() { +/// # use std::default::Default; +/// # use youtube3::{YouTube, oauth2, hyper, hyper_rustls, chrono, FieldMask}; +/// +/// # let secret: oauth2::ApplicationSecret = Default::default(); +/// # let auth = oauth2::InstalledFlowAuthenticator::builder( +/// # secret, +/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, +/// # ).build().await.unwrap(); +/// # let mut hub = YouTube::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().unwrap().https_or_http().enable_http1().build()), auth); +/// // You can configure optional parameters by calling 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_chat_moderators().list("liveChatId", &vec!["amet".into()]) +/// .page_token("erat") +/// .max_results(32) +/// .doit().await; +/// # } +/// ``` +pub struct LiveChatModeratorListCall<'a, S> + where S: 'a { + + pub(super) hub: &'a YouTube, + pub(super) _live_chat_id: String, + pub(super) _part: Vec, + pub(super) _page_token: Option, + pub(super) _max_results: Option, + pub(super) _delegate: Option<&'a mut dyn client::Delegate>, + pub(super) _additional_params: HashMap, + pub(super) _scopes: BTreeSet +} + +impl<'a, S> client::CallBuilder for LiveChatModeratorListCall<'a, S> {} + +impl<'a, S> LiveChatModeratorListCall<'a, S> +where + S: tower_service::Service + Clone + Send + Sync + 'static, + S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, + S::Future: Send + Unpin + 'static, + S::Error: Into>, +{ + + + /// Perform the operation you have build so far. + pub async fn doit(mut self) -> client::Result<(hyper::Response, LiveChatModeratorListResponse)> { + use std::io::{Read, Seek}; + use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; + use client::{ToParts, url::Params}; + use std::borrow::Cow; + + let mut dd = client::DefaultDelegate; + let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd); + dlg.begin(client::MethodInfo { id: "youtube.liveChatModerators.list", + http_method: hyper::Method::GET }); + + for &field in ["alt", "liveChatId", "part", "pageToken", "maxResults"].iter() { + if self._additional_params.contains_key(field) { + dlg.finished(false); + return Err(client::Error::FieldClash(field)); + } + } + + let mut params = Params::with_capacity(6 + self._additional_params.len()); + params.push("liveChatId", &self._live_chat_id); + if self._part.len() > 0 { + for f in self._part.iter() { + params.push("part", f); + } + } + if let Some(value) = self._page_token.as_ref() { + params.push("pageToken", value); + } + if let Some(value) = self._max_results.as_ref() { + params.push("maxResults", value.to_string()); + } + + params.extend(self._additional_params.iter()); + + params.push("alt", "json"); + let mut url = self.hub._base_url.clone() + "youtube/v3/liveChat/moderators"; + if self._scopes.is_empty() { + self._scopes.insert(Scope::Readonly.as_ref().to_string()); + } + + + let url = params.parse_with_url(&url); + + + + loop { + let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]).await { + Ok(token) => token, + Err(e) => { + match dlg.token(e) { + Ok(token) => token, + Err(e) => { + dlg.finished(false); + return Err(client::Error::MissingToken(e)); + } + } + } + }; + let mut req_result = { + let client = &self.hub.client; + dlg.pre_request(); + let mut req_builder = hyper::Request::builder() + .method(hyper::Method::GET) + .uri(url.as_str()) + .header(USER_AGENT, self.hub._user_agent.clone()); + + if let Some(token) = token.as_ref() { + req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); + } + + + let request = req_builder + .header(CONTENT_LENGTH, 0_u64) + .body(hyper::body::Body::empty()); + + client.request(request.unwrap()).await + + }; + + match req_result { + Err(err) => { + if let client::Retry::After(d) = dlg.http_error(&err) { + sleep(d).await; + continue; + } + dlg.finished(false); + return Err(client::Error::HttpError(err)) + } + Ok(mut res) => { + if !res.status().is_success() { + let res_body_string = client::get_body_as_string(res.body_mut()).await; + let (parts, _) = res.into_parts(); + let body = hyper::Body::from(res_body_string.clone()); + let restored_response = hyper::Response::from_parts(parts, body); + + let server_response = json::from_str::(&res_body_string).ok(); + + if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { + sleep(d).await; + continue; + } + + dlg.finished(false); + + return match server_response { + Some(error_value) => Err(client::Error::BadRequest(error_value)), + None => Err(client::Error::Failure(restored_response)), + } + } + let result_value = { + let res_body_string = client::get_body_as_string(res.body_mut()).await; + + match json::from_str(&res_body_string) { + Ok(decoded) => (res, decoded), + Err(err) => { + dlg.response_json_decode_error(&res_body_string, &err); + return Err(client::Error::JsonDecodeError(res_body_string, err)); + } + } + }; + + dlg.finished(true); + return Ok(result_value) + } + } + } + } + + + /// The id of the live chat for which moderators should be returned. + /// + /// Sets the *live chat 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 live_chat_id(mut self, new_value: &str) -> LiveChatModeratorListCall<'a, S> { + self._live_chat_id = new_value.to_string(); + self + } + /// The *part* parameter specifies the liveChatModerator resource parts that the API response will include. Supported values are id and snippet. + /// + /// Append the given value to the *part* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + /// + /// Even though the property as already been set when instantiating this call, + /// we provide this method for API completeness. + /// + /// **Settable Parts** + /// + /// * *id* + /// * *snippet* + pub fn add_part(mut self, new_value: &str) -> LiveChatModeratorListCall<'a, S> { + self._part.push(new_value.to_string()); + self + } + /// The *pageToken* parameter identifies a specific page in the result set that should be returned. In an API response, the nextPageToken and prevPageToken properties identify other pages that could be retrieved. + /// + /// Sets the *page token* query property to the given value. + pub fn page_token(mut self, new_value: &str) -> LiveChatModeratorListCall<'a, S> { + self._page_token = Some(new_value.to_string()); + self + } + /// The *maxResults* parameter specifies the maximum number of items that should be returned in the result set. + /// + /// Sets the *max results* query property to the given value. + pub fn max_results(mut self, new_value: u32) -> LiveChatModeratorListCall<'a, S> { + 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. + /// + /// ````text + /// It should be used to handle progress information, and to implement a certain level of resilience. + /// ```` + /// + /// Sets the *delegate* property to the given value. + pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> LiveChatModeratorListCall<'a, S> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not be used to set any of the known parameters + /// which have their own setter method. If done anyway, the request will fail. + /// + /// # Additional Parameters + /// + /// * *$.xgafv* (query-string) - V1 error format. + /// * *access_token* (query-string) - OAuth access token. + /// * *alt* (query-string) - Data format for response. + /// * *callback* (query-string) - JSONP + /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. + /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. + /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. + /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. + /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. + /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). + /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). + pub fn param(mut self, name: T, value: T) -> LiveChatModeratorListCall<'a, S> + where T: AsRef { + self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); + self + } + + /// Identifies the authorization scope for the method you are building. + /// + /// Use this method to actively specify which scope should be used, instead of 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: St) -> LiveChatModeratorListCall<'a, S> + where St: AsRef { + self._scopes.insert(String::from(scope.as_ref())); + self + } + /// Identifies the authorization scope(s) for the method you are building. + /// + /// See [`Self::add_scope()`] for details. + pub fn add_scopes(mut self, scopes: I) -> LiveChatModeratorListCall<'a, S> + where I: IntoIterator, + St: AsRef { + self._scopes + .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); + self + } + + /// Removes all scopes, and no default scope will be used either. + /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] + /// for details). + pub fn clear_scopes(mut self) -> LiveChatModeratorListCall<'a, S> { + self._scopes.clear(); + self + } +} + + +/// Deletes an existing stream for the authenticated user. +/// +/// A builder for the *delete* method supported by a *liveStream* resource. +/// It is not used directly, but through a [`LiveStreamMethods`] instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate hyper_rustls; +/// # extern crate google_youtube3 as youtube3; +/// # async fn dox() { +/// # use std::default::Default; +/// # use youtube3::{YouTube, oauth2, hyper, hyper_rustls, chrono, FieldMask}; +/// +/// # let secret: oauth2::ApplicationSecret = Default::default(); +/// # let auth = oauth2::InstalledFlowAuthenticator::builder( +/// # secret, +/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, +/// # ).build().await.unwrap(); +/// # let mut hub = YouTube::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().unwrap().https_or_http().enable_http1().build()), auth); +/// // You can configure optional parameters by calling 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_streams().delete("id") +/// .on_behalf_of_content_owner_channel("accusam") +/// .on_behalf_of_content_owner("sea") +/// .doit().await; +/// # } +/// ``` +pub struct LiveStreamDeleteCall<'a, S> + where S: 'a { + + pub(super) hub: &'a YouTube, + pub(super) _id: String, + pub(super) _on_behalf_of_content_owner_channel: Option, + pub(super) _on_behalf_of_content_owner: Option, + pub(super) _delegate: Option<&'a mut dyn client::Delegate>, + pub(super) _additional_params: HashMap, + pub(super) _scopes: BTreeSet +} + +impl<'a, S> client::CallBuilder for LiveStreamDeleteCall<'a, S> {} + +impl<'a, S> LiveStreamDeleteCall<'a, S> +where + S: tower_service::Service + Clone + Send + Sync + 'static, + S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, + S::Future: Send + Unpin + 'static, + S::Error: Into>, +{ + + + /// Perform the operation you have build so far. + pub async fn doit(mut self) -> client::Result> { + use std::io::{Read, Seek}; + use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; + use client::{ToParts, url::Params}; + use std::borrow::Cow; + + let mut dd = client::DefaultDelegate; + let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd); + dlg.begin(client::MethodInfo { id: "youtube.liveStreams.delete", + http_method: hyper::Method::DELETE }); + + for &field in ["id", "onBehalfOfContentOwnerChannel", "onBehalfOfContentOwner"].iter() { + if self._additional_params.contains_key(field) { + dlg.finished(false); + return Err(client::Error::FieldClash(field)); + } + } + + let mut params = Params::with_capacity(4 + self._additional_params.len()); + params.push("id", &self._id); + if let Some(value) = self._on_behalf_of_content_owner_channel.as_ref() { + params.push("onBehalfOfContentOwnerChannel", value); + } + if let Some(value) = self._on_behalf_of_content_owner.as_ref() { + params.push("onBehalfOfContentOwner", value); + } + + params.extend(self._additional_params.iter()); + + let mut url = self.hub._base_url.clone() + "youtube/v3/liveStreams"; + if self._scopes.is_empty() { + self._scopes.insert(Scope::Full.as_ref().to_string()); + } + + + let url = params.parse_with_url(&url); + + + + loop { + let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]).await { + Ok(token) => token, + Err(e) => { + match dlg.token(e) { + Ok(token) => token, + Err(e) => { + dlg.finished(false); + return Err(client::Error::MissingToken(e)); + } + } + } + }; + let mut req_result = { + let client = &self.hub.client; + dlg.pre_request(); + let mut req_builder = hyper::Request::builder() + .method(hyper::Method::DELETE) + .uri(url.as_str()) + .header(USER_AGENT, self.hub._user_agent.clone()); + + if let Some(token) = token.as_ref() { + req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); + } + + + let request = req_builder + .header(CONTENT_LENGTH, 0_u64) + .body(hyper::body::Body::empty()); + + client.request(request.unwrap()).await + + }; + + match req_result { + Err(err) => { + if let client::Retry::After(d) = dlg.http_error(&err) { + sleep(d).await; + continue; + } + dlg.finished(false); + return Err(client::Error::HttpError(err)) + } + Ok(mut res) => { + if !res.status().is_success() { + let res_body_string = client::get_body_as_string(res.body_mut()).await; + let (parts, _) = res.into_parts(); + let body = hyper::Body::from(res_body_string.clone()); + let restored_response = hyper::Response::from_parts(parts, body); + + let server_response = json::from_str::(&res_body_string).ok(); + + if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { + sleep(d).await; + continue; + } + + dlg.finished(false); + + return match server_response { + Some(error_value) => Err(client::Error::BadRequest(error_value)), + None => Err(client::Error::Failure(restored_response)), + } + } + let result_value = res; + + dlg.finished(true); + return Ok(result_value) + } + } + } + } + + + /// + /// 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) -> LiveStreamDeleteCall<'a, S> { + self._id = new_value.to_string(); + self + } + /// This parameter can only be used in a properly authorized request. *Note:* This parameter is intended exclusively for YouTube content partners. The *onBehalfOfContentOwnerChannel* parameter specifies the YouTube channel ID of the channel to which a video is being added. This parameter is required when a request specifies a value for the onBehalfOfContentOwner parameter, and it can only be used in conjunction with that parameter. In addition, the request must be authorized using a CMS account that is linked to the content owner that the onBehalfOfContentOwner parameter specifies. Finally, the channel that the onBehalfOfContentOwnerChannel parameter value specifies must be linked to the content owner that the onBehalfOfContentOwner parameter specifies. This parameter is intended for YouTube content partners that own and manage many different YouTube channels. It allows content owners to authenticate once and perform actions on behalf of the channel specified in the parameter value, without having to provide authentication credentials for each separate channel. + /// + /// Sets the *on behalf of content owner channel* query property to the given value. + pub fn on_behalf_of_content_owner_channel(mut self, new_value: &str) -> LiveStreamDeleteCall<'a, S> { + self._on_behalf_of_content_owner_channel = Some(new_value.to_string()); + self + } + /// *Note:* This parameter is intended exclusively for YouTube content partners. The *onBehalfOfContentOwner* parameter indicates that the request's authorization credentials identify a YouTube CMS user who is acting on behalf of the content owner specified in the parameter value. This parameter is intended for YouTube content partners that own and manage many different YouTube channels. It allows content owners to authenticate once and get access to all their video and channel data, without having to provide authentication credentials for each individual channel. The CMS account that the user authenticates with must be linked to the specified YouTube content owner. + /// + /// Sets the *on behalf of content owner* query property to the given value. + pub fn on_behalf_of_content_owner(mut self, new_value: &str) -> LiveStreamDeleteCall<'a, S> { + self._on_behalf_of_content_owner = 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. + /// + /// ````text + /// It should be used to handle progress information, and to implement a certain level of resilience. + /// ```` + /// + /// Sets the *delegate* property to the given value. + pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> LiveStreamDeleteCall<'a, S> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not be used to set any of the known parameters + /// which have their own setter method. If done anyway, the request will fail. + /// + /// # Additional Parameters + /// + /// * *$.xgafv* (query-string) - V1 error format. + /// * *access_token* (query-string) - OAuth access token. + /// * *alt* (query-string) - Data format for response. + /// * *callback* (query-string) - JSONP + /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. + /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. + /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. + /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. + /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. + /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). + /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). + pub fn param(mut self, name: T, value: T) -> LiveStreamDeleteCall<'a, S> + where T: AsRef { + self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); + self + } + + /// Identifies the authorization scope for the method you are building. + /// + /// Use this method to actively specify which scope should be used, instead of 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: St) -> LiveStreamDeleteCall<'a, S> + where St: AsRef { + self._scopes.insert(String::from(scope.as_ref())); + self + } + /// Identifies the authorization scope(s) for the method you are building. + /// + /// See [`Self::add_scope()`] for details. + pub fn add_scopes(mut self, scopes: I) -> LiveStreamDeleteCall<'a, S> + where I: IntoIterator, + St: AsRef { + self._scopes + .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); + self + } + + /// Removes all scopes, and no default scope will be used either. + /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] + /// for details). + pub fn clear_scopes(mut self) -> LiveStreamDeleteCall<'a, S> { + self._scopes.clear(); + self + } +} + + +/// Inserts a new stream for the authenticated user. +/// +/// A builder for the *insert* method supported by a *liveStream* resource. +/// It is not used directly, but through a [`LiveStreamMethods`] instance. +/// +/// **Settable Parts** +/// +/// * *id* +/// * *snippet* +/// * *cdn* +/// * *content_details* +/// * *status* +/// +/// # Scopes +/// +/// You will need authorization for at least one of the following scopes to make a valid call, possibly depending on *parts*: +/// +/// * *https://www.googleapis.com/auth/youtube* +/// * *https://www.googleapis.com/auth/youtube.force-ssl* +/// +/// The default scope will be `Scope::Full`. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate hyper_rustls; +/// # extern crate google_youtube3 as youtube3; +/// use youtube3::api::LiveStream; +/// # async fn dox() { +/// # use std::default::Default; +/// # use youtube3::{YouTube, oauth2, hyper, hyper_rustls, chrono, FieldMask}; +/// +/// # let secret: oauth2::ApplicationSecret = Default::default(); +/// # let auth = oauth2::InstalledFlowAuthenticator::builder( +/// # secret, +/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, +/// # ).build().await.unwrap(); +/// # let mut hub = YouTube::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().unwrap().https_or_http().enable_http1().build()), auth); +/// // As the method needs a request, you would usually fill it with the desired information +/// // into the respective structure. Some of the parts shown here might not be applicable ! +/// // Values shown here are possibly random and not representative ! +/// let mut req = LiveStream::default(); +/// req.cdn = Default::default(); // is CdnSettings +/// req.id = Some("takimata".to_string()); +/// req.snippet = Default::default(); // is LiveStreamSnippet +/// req.status = Default::default(); // is LiveStreamStatus +/// +/// // You can configure optional parameters by calling 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_streams().insert(req) +/// .on_behalf_of_content_owner_channel("Lorem") +/// .on_behalf_of_content_owner("et") +/// .doit().await; +/// # } +/// ``` +pub struct LiveStreamInsertCall<'a, S> + where S: 'a { + + pub(super) hub: &'a YouTube, + pub(super) _request: LiveStream, + pub(super) _part: Vec, + pub(super) _on_behalf_of_content_owner_channel: Option, + pub(super) _on_behalf_of_content_owner: Option, + pub(super) _delegate: Option<&'a mut dyn client::Delegate>, + pub(super) _additional_params: HashMap, + pub(super) _scopes: BTreeSet +} + +impl<'a, S> client::CallBuilder for LiveStreamInsertCall<'a, S> {} + +impl<'a, S> LiveStreamInsertCall<'a, S> +where + S: tower_service::Service + Clone + Send + Sync + 'static, + S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, + S::Future: Send + Unpin + 'static, + S::Error: Into>, +{ + + + /// Perform the operation you have build so far. + pub async fn doit(mut self) -> client::Result<(hyper::Response, LiveStream)> { + use std::io::{Read, Seek}; + use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; + use client::{ToParts, url::Params}; + use std::borrow::Cow; + + let mut dd = client::DefaultDelegate; + let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd); + dlg.begin(client::MethodInfo { id: "youtube.liveStreams.insert", + http_method: hyper::Method::POST }); + + for &field in ["alt", "part", "onBehalfOfContentOwnerChannel", "onBehalfOfContentOwner"].iter() { + if self._additional_params.contains_key(field) { + dlg.finished(false); + return Err(client::Error::FieldClash(field)); + } + } + + let mut params = Params::with_capacity(6 + self._additional_params.len()); + if self._part.is_empty() { + self._part.push(self._request.to_parts()); + } + if self._part.len() > 0 { + for f in self._part.iter() { + params.push("part", f); + } + } + if let Some(value) = self._on_behalf_of_content_owner_channel.as_ref() { + params.push("onBehalfOfContentOwnerChannel", value); + } + if let Some(value) = self._on_behalf_of_content_owner.as_ref() { + params.push("onBehalfOfContentOwner", value); + } + + params.extend(self._additional_params.iter()); + + params.push("alt", "json"); + let mut url = self.hub._base_url.clone() + "youtube/v3/liveStreams"; + if self._scopes.is_empty() { + self._scopes.insert(Scope::Full.as_ref().to_string()); + } + + + let url = params.parse_with_url(&url); + + let mut json_mime_type = mime::APPLICATION_JSON; + let mut request_value_reader = + { + let mut value = json::value::to_value(&self._request).expect("serde to work"); + client::remove_json_null_values(&mut value); + let mut dst = io::Cursor::new(Vec::with_capacity(128)); + json::to_writer(&mut dst, &value).unwrap(); + dst + }; + let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); + request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); + + + loop { + let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]).await { + Ok(token) => token, + Err(e) => { + match dlg.token(e) { + Ok(token) => token, + Err(e) => { + dlg.finished(false); + return Err(client::Error::MissingToken(e)); + } + } + } + }; + request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); + let mut req_result = { + let client = &self.hub.client; + dlg.pre_request(); + let mut req_builder = hyper::Request::builder() + .method(hyper::Method::POST) + .uri(url.as_str()) + .header(USER_AGENT, self.hub._user_agent.clone()); + + if let Some(token) = token.as_ref() { + req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); + } + + + let request = req_builder + .header(CONTENT_TYPE, json_mime_type.to_string()) + .header(CONTENT_LENGTH, request_size as u64) + .body(hyper::body::Body::from(request_value_reader.get_ref().clone())); + + client.request(request.unwrap()).await + + }; + + match req_result { + Err(err) => { + if let client::Retry::After(d) = dlg.http_error(&err) { + sleep(d).await; + continue; + } + dlg.finished(false); + return Err(client::Error::HttpError(err)) + } + Ok(mut res) => { + if !res.status().is_success() { + let res_body_string = client::get_body_as_string(res.body_mut()).await; + let (parts, _) = res.into_parts(); + let body = hyper::Body::from(res_body_string.clone()); + let restored_response = hyper::Response::from_parts(parts, body); + + let server_response = json::from_str::(&res_body_string).ok(); + + if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { + sleep(d).await; + continue; + } + + dlg.finished(false); + + return match server_response { + Some(error_value) => Err(client::Error::BadRequest(error_value)), + None => Err(client::Error::Failure(restored_response)), + } + } + let result_value = { + let res_body_string = client::get_body_as_string(res.body_mut()).await; + + match json::from_str(&res_body_string) { + Ok(decoded) => (res, decoded), + Err(err) => { + dlg.response_json_decode_error(&res_body_string, &err); + return Err(client::Error::JsonDecodeError(res_body_string, err)); + } + } + }; + + dlg.finished(true); + return Ok(result_value) + } + } + } + } + + + /// + /// Sets the *request* property to the given value. + /// + /// Even though the property as already been set when instantiating this call, + /// we provide this method for API completeness. + /// + /// **Settable Parts** + /// + /// * *id* + /// * *snippet* + /// * *cdn* + /// * *content_details* + /// * *status* + pub fn request(mut self, new_value: LiveStream) -> LiveStreamInsertCall<'a, S> { + self._request = new_value; + self + } + /// The *part* parameter serves two purposes in this operation. It identifies the properties that the write operation will set as well as the properties that the API response will include. The part properties that you can include in the parameter value are id, snippet, cdn, content_details, and status. + /// + /// Append the given value to the *part* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + /// + /// Even though the *parts* list is automatically derived from *Resource* passed in + /// during instantiation and indicates which values you are passing, the response would contain the very same parts. + /// This may not always be desirable, as you can obtain (newly generated) parts you cannot pass in, + /// like statistics that are generated server side. Therefore you should use this method to specify + /// the parts you provide in addition to the ones you want in the response. + /// + /// **Settable Parts** + /// + /// * *id* + /// * *snippet* + /// * *cdn* + /// * *content_details* + /// * *status* + pub fn add_part(mut self, new_value: &str) -> LiveStreamInsertCall<'a, S> { + self._part.push(new_value.to_string()); + self + } + /// This parameter can only be used in a properly authorized request. *Note:* This parameter is intended exclusively for YouTube content partners. The *onBehalfOfContentOwnerChannel* parameter specifies the YouTube channel ID of the channel to which a video is being added. This parameter is required when a request specifies a value for the onBehalfOfContentOwner parameter, and it can only be used in conjunction with that parameter. In addition, the request must be authorized using a CMS account that is linked to the content owner that the onBehalfOfContentOwner parameter specifies. Finally, the channel that the onBehalfOfContentOwnerChannel parameter value specifies must be linked to the content owner that the onBehalfOfContentOwner parameter specifies. This parameter is intended for YouTube content partners that own and manage many different YouTube channels. It allows content owners to authenticate once and perform actions on behalf of the channel specified in the parameter value, without having to provide authentication credentials for each separate channel. + /// + /// Sets the *on behalf of content owner channel* query property to the given value. + pub fn on_behalf_of_content_owner_channel(mut self, new_value: &str) -> LiveStreamInsertCall<'a, S> { + self._on_behalf_of_content_owner_channel = Some(new_value.to_string()); + self + } + /// *Note:* This parameter is intended exclusively for YouTube content partners. The *onBehalfOfContentOwner* parameter indicates that the request's authorization credentials identify a YouTube CMS user who is acting on behalf of the content owner specified in the parameter value. This parameter is intended for YouTube content partners that own and manage many different YouTube channels. It allows content owners to authenticate once and get access to all their video and channel data, without having to provide authentication credentials for each individual channel. The CMS account that the user authenticates with must be linked to the specified YouTube content owner. + /// + /// Sets the *on behalf of content owner* query property to the given value. + pub fn on_behalf_of_content_owner(mut self, new_value: &str) -> LiveStreamInsertCall<'a, S> { + self._on_behalf_of_content_owner = 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. + /// + /// ````text + /// It should be used to handle progress information, and to implement a certain level of resilience. + /// ```` + /// + /// Sets the *delegate* property to the given value. + pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> LiveStreamInsertCall<'a, S> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not be used to set any of the known parameters + /// which have their own setter method. If done anyway, the request will fail. + /// + /// # Additional Parameters + /// + /// * *$.xgafv* (query-string) - V1 error format. + /// * *access_token* (query-string) - OAuth access token. + /// * *alt* (query-string) - Data format for response. + /// * *callback* (query-string) - JSONP + /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. + /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. + /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. + /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. + /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. + /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). + /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). + pub fn param(mut self, name: T, value: T) -> LiveStreamInsertCall<'a, S> + where T: AsRef { + self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); + self + } + + /// Identifies the authorization scope for the method you are building. + /// + /// Use this method to actively specify which scope should be used, instead of 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: St) -> LiveStreamInsertCall<'a, S> + where St: AsRef { + self._scopes.insert(String::from(scope.as_ref())); + self + } + /// Identifies the authorization scope(s) for the method you are building. + /// + /// See [`Self::add_scope()`] for details. + pub fn add_scopes(mut self, scopes: I) -> LiveStreamInsertCall<'a, S> + where I: IntoIterator, + St: AsRef { + self._scopes + .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); + self + } + + /// Removes all scopes, and no default scope will be used either. + /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] + /// for details). + pub fn clear_scopes(mut self) -> LiveStreamInsertCall<'a, S> { + self._scopes.clear(); + self + } +} + + +/// Retrieve the list of streams associated with the given channel. -- +/// +/// A builder for the *list* method supported by a *liveStream* resource. +/// It is not used directly, but through a [`LiveStreamMethods`] instance. +/// +/// **Settable Parts** +/// +/// * *id* +/// * *snippet* +/// * *cdn* +/// * *status* +/// +/// # Scopes +/// +/// You will need authorization for at least one of the following scopes to make a valid call, possibly depending on *parts*: +/// +/// * *https://www.googleapis.com/auth/youtube* +/// * *https://www.googleapis.com/auth/youtube.force-ssl* +/// * *https://www.googleapis.com/auth/youtube.readonly* +/// +/// The default scope will be `Scope::Readonly`. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate hyper_rustls; +/// # extern crate google_youtube3 as youtube3; +/// # async fn dox() { +/// # use std::default::Default; +/// # use youtube3::{YouTube, oauth2, hyper, hyper_rustls, chrono, FieldMask}; +/// +/// # let secret: oauth2::ApplicationSecret = Default::default(); +/// # let auth = oauth2::InstalledFlowAuthenticator::builder( +/// # secret, +/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, +/// # ).build().await.unwrap(); +/// # let mut hub = YouTube::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().unwrap().https_or_http().enable_http1().build()), auth); +/// // You can configure optional parameters by calling 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_streams().list(&vec!["At".into()]) +/// .page_token("dolor") +/// .on_behalf_of_content_owner_channel("et") +/// .on_behalf_of_content_owner("sit") +/// .mine(false) +/// .max_results(91) +/// .add_id("nonumy") +/// .doit().await; +/// # } +/// ``` +pub struct LiveStreamListCall<'a, S> + where S: 'a { + + pub(super) hub: &'a YouTube, + pub(super) _part: Vec, + pub(super) _page_token: Option, + pub(super) _on_behalf_of_content_owner_channel: Option, + pub(super) _on_behalf_of_content_owner: Option, + pub(super) _mine: Option, + pub(super) _max_results: Option, + pub(super) _id: Vec, + pub(super) _delegate: Option<&'a mut dyn client::Delegate>, + pub(super) _additional_params: HashMap, + pub(super) _scopes: BTreeSet +} + +impl<'a, S> client::CallBuilder for LiveStreamListCall<'a, S> {} + +impl<'a, S> LiveStreamListCall<'a, S> +where + S: tower_service::Service + Clone + Send + Sync + 'static, + S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, + S::Future: Send + Unpin + 'static, + S::Error: Into>, +{ + + + /// Perform the operation you have build so far. + pub async fn doit(mut self) -> client::Result<(hyper::Response, LiveStreamListResponse)> { + use std::io::{Read, Seek}; + use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; + use client::{ToParts, url::Params}; + use std::borrow::Cow; + + let mut dd = client::DefaultDelegate; + let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd); + dlg.begin(client::MethodInfo { id: "youtube.liveStreams.list", + http_method: hyper::Method::GET }); + + for &field in ["alt", "part", "pageToken", "onBehalfOfContentOwnerChannel", "onBehalfOfContentOwner", "mine", "maxResults", "id"].iter() { + if self._additional_params.contains_key(field) { + dlg.finished(false); + return Err(client::Error::FieldClash(field)); + } + } + + let mut params = Params::with_capacity(9 + self._additional_params.len()); + if self._part.len() > 0 { + for f in self._part.iter() { + params.push("part", f); + } + } + if let Some(value) = self._page_token.as_ref() { + params.push("pageToken", value); + } + if let Some(value) = self._on_behalf_of_content_owner_channel.as_ref() { + params.push("onBehalfOfContentOwnerChannel", value); + } + if let Some(value) = self._on_behalf_of_content_owner.as_ref() { + params.push("onBehalfOfContentOwner", value); + } + if let Some(value) = self._mine.as_ref() { + params.push("mine", value.to_string()); + } + if let Some(value) = self._max_results.as_ref() { + params.push("maxResults", value.to_string()); + } + if self._id.len() > 0 { + for f in self._id.iter() { + params.push("id", f); + } + } + + params.extend(self._additional_params.iter()); + + params.push("alt", "json"); + let mut url = self.hub._base_url.clone() + "youtube/v3/liveStreams"; + if self._scopes.is_empty() { + self._scopes.insert(Scope::Readonly.as_ref().to_string()); + } + + + let url = params.parse_with_url(&url); + + + + loop { + let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]).await { + Ok(token) => token, + Err(e) => { + match dlg.token(e) { + Ok(token) => token, + Err(e) => { + dlg.finished(false); + return Err(client::Error::MissingToken(e)); + } + } + } + }; + let mut req_result = { + let client = &self.hub.client; + dlg.pre_request(); + let mut req_builder = hyper::Request::builder() + .method(hyper::Method::GET) + .uri(url.as_str()) + .header(USER_AGENT, self.hub._user_agent.clone()); + + if let Some(token) = token.as_ref() { + req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); + } + + + let request = req_builder + .header(CONTENT_LENGTH, 0_u64) + .body(hyper::body::Body::empty()); + + client.request(request.unwrap()).await + + }; + + match req_result { + Err(err) => { + if let client::Retry::After(d) = dlg.http_error(&err) { + sleep(d).await; + continue; + } + dlg.finished(false); + return Err(client::Error::HttpError(err)) + } + Ok(mut res) => { + if !res.status().is_success() { + let res_body_string = client::get_body_as_string(res.body_mut()).await; + let (parts, _) = res.into_parts(); + let body = hyper::Body::from(res_body_string.clone()); + let restored_response = hyper::Response::from_parts(parts, body); + + let server_response = json::from_str::(&res_body_string).ok(); + + if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { + sleep(d).await; + continue; + } + + dlg.finished(false); + + return match server_response { + Some(error_value) => Err(client::Error::BadRequest(error_value)), + None => Err(client::Error::Failure(restored_response)), + } + } + let result_value = { + let res_body_string = client::get_body_as_string(res.body_mut()).await; + + match json::from_str(&res_body_string) { + Ok(decoded) => (res, decoded), + Err(err) => { + dlg.response_json_decode_error(&res_body_string, &err); + return Err(client::Error::JsonDecodeError(res_body_string, err)); + } + } + }; + + dlg.finished(true); + return Ok(result_value) + } + } + } + } + + + /// The *part* parameter specifies a comma-separated list of one or more liveStream resource properties that the API response will include. The part names that you can include in the parameter value are id, snippet, cdn, and status. + /// + /// Append the given value to the *part* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + /// + /// Even though the property as already been set when instantiating this call, + /// we provide this method for API completeness. + /// + /// **Settable Parts** + /// + /// * *id* + /// * *snippet* + /// * *cdn* + /// * *status* + pub fn add_part(mut self, new_value: &str) -> LiveStreamListCall<'a, S> { + self._part.push(new_value.to_string()); + self + } + /// The *pageToken* parameter identifies a specific page in the result set that should be returned. In an API response, the nextPageToken and prevPageToken properties identify other pages that could be retrieved. + /// + /// Sets the *page token* query property to the given value. + pub fn page_token(mut self, new_value: &str) -> LiveStreamListCall<'a, S> { + self._page_token = Some(new_value.to_string()); + self + } + /// This parameter can only be used in a properly authorized request. *Note:* This parameter is intended exclusively for YouTube content partners. The *onBehalfOfContentOwnerChannel* parameter specifies the YouTube channel ID of the channel to which a video is being added. This parameter is required when a request specifies a value for the onBehalfOfContentOwner parameter, and it can only be used in conjunction with that parameter. In addition, the request must be authorized using a CMS account that is linked to the content owner that the onBehalfOfContentOwner parameter specifies. Finally, the channel that the onBehalfOfContentOwnerChannel parameter value specifies must be linked to the content owner that the onBehalfOfContentOwner parameter specifies. This parameter is intended for YouTube content partners that own and manage many different YouTube channels. It allows content owners to authenticate once and perform actions on behalf of the channel specified in the parameter value, without having to provide authentication credentials for each separate channel. + /// + /// Sets the *on behalf of content owner channel* query property to the given value. + pub fn on_behalf_of_content_owner_channel(mut self, new_value: &str) -> LiveStreamListCall<'a, S> { + self._on_behalf_of_content_owner_channel = Some(new_value.to_string()); + self + } + /// *Note:* This parameter is intended exclusively for YouTube content partners. The *onBehalfOfContentOwner* parameter indicates that the request's authorization credentials identify a YouTube CMS user who is acting on behalf of the content owner specified in the parameter value. This parameter is intended for YouTube content partners that own and manage many different YouTube channels. It allows content owners to authenticate once and get access to all their video and channel data, without having to provide authentication credentials for each individual channel. The CMS account that the user authenticates with must be linked to the specified YouTube content owner. + /// + /// Sets the *on behalf of content owner* query property to the given value. + pub fn on_behalf_of_content_owner(mut self, new_value: &str) -> LiveStreamListCall<'a, S> { + self._on_behalf_of_content_owner = Some(new_value.to_string()); + self + } + /// + /// Sets the *mine* query property to the given value. + pub fn mine(mut self, new_value: bool) -> LiveStreamListCall<'a, S> { + self._mine = Some(new_value); + self + } + /// The *maxResults* parameter specifies the maximum number of items that should be returned in the result set. + /// + /// Sets the *max results* query property to the given value. + pub fn max_results(mut self, new_value: u32) -> LiveStreamListCall<'a, S> { + self._max_results = Some(new_value); + self + } + /// Return LiveStreams with the given ids from Stubby or Apiary. + /// + /// Append the given value to the *id* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + pub fn add_id(mut self, new_value: &str) -> LiveStreamListCall<'a, S> { + self._id.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. + /// + /// ````text + /// It should be used to handle progress information, and to implement a certain level of resilience. + /// ```` + /// + /// Sets the *delegate* property to the given value. + pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> LiveStreamListCall<'a, S> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not be used to set any of the known parameters + /// which have their own setter method. If done anyway, the request will fail. + /// + /// # Additional Parameters + /// + /// * *$.xgafv* (query-string) - V1 error format. + /// * *access_token* (query-string) - OAuth access token. + /// * *alt* (query-string) - Data format for response. + /// * *callback* (query-string) - JSONP + /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. + /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. + /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. + /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. + /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. + /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). + /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). + pub fn param(mut self, name: T, value: T) -> LiveStreamListCall<'a, S> + where T: AsRef { + self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); + self + } + + /// Identifies the authorization scope for the method you are building. + /// + /// Use this method to actively specify which scope should be used, instead of 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: St) -> LiveStreamListCall<'a, S> + where St: AsRef { + self._scopes.insert(String::from(scope.as_ref())); + self + } + /// Identifies the authorization scope(s) for the method you are building. + /// + /// See [`Self::add_scope()`] for details. + pub fn add_scopes(mut self, scopes: I) -> LiveStreamListCall<'a, S> + where I: IntoIterator, + St: AsRef { + self._scopes + .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); + self + } + + /// Removes all scopes, and no default scope will be used either. + /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] + /// for details). + pub fn clear_scopes(mut self) -> LiveStreamListCall<'a, S> { + self._scopes.clear(); + self + } +} + + +/// Updates an existing stream for the authenticated user. +/// +/// A builder for the *update* method supported by a *liveStream* resource. +/// It is not used directly, but through a [`LiveStreamMethods`] instance. +/// +/// **Settable Parts** +/// +/// * *id* +/// * *snippet* +/// * *cdn* +/// * *status* +/// +/// # Scopes +/// +/// You will need authorization for at least one of the following scopes to make a valid call, possibly depending on *parts*: +/// +/// * *https://www.googleapis.com/auth/youtube* +/// * *https://www.googleapis.com/auth/youtube.force-ssl* +/// +/// The default scope will be `Scope::Full`. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate hyper_rustls; +/// # extern crate google_youtube3 as youtube3; +/// use youtube3::api::LiveStream; +/// # async fn dox() { +/// # use std::default::Default; +/// # use youtube3::{YouTube, oauth2, hyper, hyper_rustls, chrono, FieldMask}; +/// +/// # let secret: oauth2::ApplicationSecret = Default::default(); +/// # let auth = oauth2::InstalledFlowAuthenticator::builder( +/// # secret, +/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, +/// # ).build().await.unwrap(); +/// # let mut hub = YouTube::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().unwrap().https_or_http().enable_http1().build()), auth); +/// // As the method needs a request, you would usually fill it with the desired information +/// // into the respective structure. Some of the parts shown here might not be applicable ! +/// // Values shown here are possibly random and not representative ! +/// let mut req = LiveStream::default(); +/// req.cdn = Default::default(); // is CdnSettings +/// req.id = Some("et".to_string()); +/// req.snippet = Default::default(); // is LiveStreamSnippet +/// req.status = Default::default(); // is LiveStreamStatus +/// +/// // You can configure optional parameters by calling 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_streams().update(req) +/// .on_behalf_of_content_owner_channel("gubergren") +/// .on_behalf_of_content_owner("justo") +/// .doit().await; +/// # } +/// ``` +pub struct LiveStreamUpdateCall<'a, S> + where S: 'a { + + pub(super) hub: &'a YouTube, + pub(super) _request: LiveStream, + pub(super) _part: Vec, + pub(super) _on_behalf_of_content_owner_channel: Option, + pub(super) _on_behalf_of_content_owner: Option, + pub(super) _delegate: Option<&'a mut dyn client::Delegate>, + pub(super) _additional_params: HashMap, + pub(super) _scopes: BTreeSet +} + +impl<'a, S> client::CallBuilder for LiveStreamUpdateCall<'a, S> {} + +impl<'a, S> LiveStreamUpdateCall<'a, S> +where + S: tower_service::Service + Clone + Send + Sync + 'static, + S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, + S::Future: Send + Unpin + 'static, + S::Error: Into>, +{ + + + /// Perform the operation you have build so far. + pub async fn doit(mut self) -> client::Result<(hyper::Response, LiveStream)> { + use std::io::{Read, Seek}; + use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; + use client::{ToParts, url::Params}; + use std::borrow::Cow; + + let mut dd = client::DefaultDelegate; + let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd); + dlg.begin(client::MethodInfo { id: "youtube.liveStreams.update", + http_method: hyper::Method::PUT }); + + for &field in ["alt", "part", "onBehalfOfContentOwnerChannel", "onBehalfOfContentOwner"].iter() { + if self._additional_params.contains_key(field) { + dlg.finished(false); + return Err(client::Error::FieldClash(field)); + } + } + + let mut params = Params::with_capacity(6 + self._additional_params.len()); + if self._part.is_empty() { + self._part.push(self._request.to_parts()); + } + if self._part.len() > 0 { + for f in self._part.iter() { + params.push("part", f); + } + } + if let Some(value) = self._on_behalf_of_content_owner_channel.as_ref() { + params.push("onBehalfOfContentOwnerChannel", value); + } + if let Some(value) = self._on_behalf_of_content_owner.as_ref() { + params.push("onBehalfOfContentOwner", value); + } + + params.extend(self._additional_params.iter()); + + params.push("alt", "json"); + let mut url = self.hub._base_url.clone() + "youtube/v3/liveStreams"; + if self._scopes.is_empty() { + self._scopes.insert(Scope::Full.as_ref().to_string()); + } + + + let url = params.parse_with_url(&url); + + let mut json_mime_type = mime::APPLICATION_JSON; + let mut request_value_reader = + { + let mut value = json::value::to_value(&self._request).expect("serde to work"); + client::remove_json_null_values(&mut value); + let mut dst = io::Cursor::new(Vec::with_capacity(128)); + json::to_writer(&mut dst, &value).unwrap(); + dst + }; + let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); + request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); + + + loop { + let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]).await { + Ok(token) => token, + Err(e) => { + match dlg.token(e) { + Ok(token) => token, + Err(e) => { + dlg.finished(false); + return Err(client::Error::MissingToken(e)); + } + } + } + }; + request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); + let mut req_result = { + let client = &self.hub.client; + dlg.pre_request(); + let mut req_builder = hyper::Request::builder() + .method(hyper::Method::PUT) + .uri(url.as_str()) + .header(USER_AGENT, self.hub._user_agent.clone()); + + if let Some(token) = token.as_ref() { + req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); + } + + + let request = req_builder + .header(CONTENT_TYPE, json_mime_type.to_string()) + .header(CONTENT_LENGTH, request_size as u64) + .body(hyper::body::Body::from(request_value_reader.get_ref().clone())); + + client.request(request.unwrap()).await + + }; + + match req_result { + Err(err) => { + if let client::Retry::After(d) = dlg.http_error(&err) { + sleep(d).await; + continue; + } + dlg.finished(false); + return Err(client::Error::HttpError(err)) + } + Ok(mut res) => { + if !res.status().is_success() { + let res_body_string = client::get_body_as_string(res.body_mut()).await; + let (parts, _) = res.into_parts(); + let body = hyper::Body::from(res_body_string.clone()); + let restored_response = hyper::Response::from_parts(parts, body); + + let server_response = json::from_str::(&res_body_string).ok(); + + if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { + sleep(d).await; + continue; + } + + dlg.finished(false); + + return match server_response { + Some(error_value) => Err(client::Error::BadRequest(error_value)), + None => Err(client::Error::Failure(restored_response)), + } + } + let result_value = { + let res_body_string = client::get_body_as_string(res.body_mut()).await; + + match json::from_str(&res_body_string) { + Ok(decoded) => (res, decoded), + Err(err) => { + dlg.response_json_decode_error(&res_body_string, &err); + return Err(client::Error::JsonDecodeError(res_body_string, err)); + } + } + }; + + dlg.finished(true); + return Ok(result_value) + } + } + } + } + + + /// + /// Sets the *request* property to the given value. + /// + /// Even though the property as already been set when instantiating this call, + /// we provide this method for API completeness. + /// + /// **Settable Parts** + /// + /// * *id* + /// * *snippet* + /// * *cdn* + /// * *status* + pub fn request(mut self, new_value: LiveStream) -> LiveStreamUpdateCall<'a, S> { + self._request = new_value; + self + } + /// The *part* parameter serves two purposes in this operation. It identifies the properties that the write operation will set as well as the properties that the API response will include. The part properties that you can include in the parameter value are id, snippet, cdn, and status. Note that this method will override the existing values for all of the mutable properties that are contained in any parts that the parameter value specifies. If the request body does not specify a value for a mutable property, the existing value for that property will be removed. + /// + /// Append the given value to the *part* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + /// + /// Even though the *parts* list is automatically derived from *Resource* passed in + /// during instantiation and indicates which values you are passing, the response would contain the very same parts. + /// This may not always be desirable, as you can obtain (newly generated) parts you cannot pass in, + /// like statistics that are generated server side. Therefore you should use this method to specify + /// the parts you provide in addition to the ones you want in the response. + /// + /// **Settable Parts** + /// + /// * *id* + /// * *snippet* + /// * *cdn* + /// * *status* + pub fn add_part(mut self, new_value: &str) -> LiveStreamUpdateCall<'a, S> { + self._part.push(new_value.to_string()); + self + } + /// This parameter can only be used in a properly authorized request. *Note:* This parameter is intended exclusively for YouTube content partners. The *onBehalfOfContentOwnerChannel* parameter specifies the YouTube channel ID of the channel to which a video is being added. This parameter is required when a request specifies a value for the onBehalfOfContentOwner parameter, and it can only be used in conjunction with that parameter. In addition, the request must be authorized using a CMS account that is linked to the content owner that the onBehalfOfContentOwner parameter specifies. Finally, the channel that the onBehalfOfContentOwnerChannel parameter value specifies must be linked to the content owner that the onBehalfOfContentOwner parameter specifies. This parameter is intended for YouTube content partners that own and manage many different YouTube channels. It allows content owners to authenticate once and perform actions on behalf of the channel specified in the parameter value, without having to provide authentication credentials for each separate channel. + /// + /// Sets the *on behalf of content owner channel* query property to the given value. + pub fn on_behalf_of_content_owner_channel(mut self, new_value: &str) -> LiveStreamUpdateCall<'a, S> { + self._on_behalf_of_content_owner_channel = Some(new_value.to_string()); + self + } + /// *Note:* This parameter is intended exclusively for YouTube content partners. The *onBehalfOfContentOwner* parameter indicates that the request's authorization credentials identify a YouTube CMS user who is acting on behalf of the content owner specified in the parameter value. This parameter is intended for YouTube content partners that own and manage many different YouTube channels. It allows content owners to authenticate once and get access to all their video and channel data, without having to provide authentication credentials for each individual channel. The CMS account that the user authenticates with must be linked to the specified YouTube content owner. + /// + /// Sets the *on behalf of content owner* query property to the given value. + pub fn on_behalf_of_content_owner(mut self, new_value: &str) -> LiveStreamUpdateCall<'a, S> { + self._on_behalf_of_content_owner = 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. + /// + /// ````text + /// It should be used to handle progress information, and to implement a certain level of resilience. + /// ```` + /// + /// Sets the *delegate* property to the given value. + pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> LiveStreamUpdateCall<'a, S> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not be used to set any of the known parameters + /// which have their own setter method. If done anyway, the request will fail. + /// + /// # Additional Parameters + /// + /// * *$.xgafv* (query-string) - V1 error format. + /// * *access_token* (query-string) - OAuth access token. + /// * *alt* (query-string) - Data format for response. + /// * *callback* (query-string) - JSONP + /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. + /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. + /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. + /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. + /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. + /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). + /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). + pub fn param(mut self, name: T, value: T) -> LiveStreamUpdateCall<'a, S> + where T: AsRef { + self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); + self + } + + /// Identifies the authorization scope for the method you are building. + /// + /// Use this method to actively specify which scope should be used, instead of 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: St) -> LiveStreamUpdateCall<'a, S> + where St: AsRef { + self._scopes.insert(String::from(scope.as_ref())); + self + } + /// Identifies the authorization scope(s) for the method you are building. + /// + /// See [`Self::add_scope()`] for details. + pub fn add_scopes(mut self, scopes: I) -> LiveStreamUpdateCall<'a, S> + where I: IntoIterator, + St: AsRef { + self._scopes + .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); + self + } + + /// Removes all scopes, and no default scope will be used either. + /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] + /// for details). + pub fn clear_scopes(mut self) -> LiveStreamUpdateCall<'a, S> { + self._scopes.clear(); + self + } +} + + +/// Retrieves a list of members that match the request criteria for a channel. +/// +/// A builder for the *list* method supported by a *member* resource. +/// It is not used directly, but through a [`MemberMethods`] instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate hyper_rustls; +/// # extern crate google_youtube3 as youtube3; +/// # async fn dox() { +/// # use std::default::Default; +/// # use youtube3::{YouTube, oauth2, hyper, hyper_rustls, chrono, FieldMask}; +/// +/// # let secret: oauth2::ApplicationSecret = Default::default(); +/// # let auth = oauth2::InstalledFlowAuthenticator::builder( +/// # secret, +/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, +/// # ).build().await.unwrap(); +/// # let mut hub = YouTube::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().unwrap().https_or_http().enable_http1().build()), auth); +/// // You can configure optional parameters by calling the respective setters at will, and +/// // execute the final call using `doit()`. +/// // Values shown here are possibly random and not representative ! +/// let result = hub.members().list(&vec!["sea".into()]) +/// .page_token("consetetur") +/// .mode(&Default::default()) +/// .max_results(3) +/// .has_access_to_level("aliquyam") +/// .filter_by_member_channel_id("eos") +/// .doit().await; +/// # } +/// ``` +pub struct MemberListCall<'a, S> + where S: 'a { + + pub(super) hub: &'a YouTube, + pub(super) _part: Vec, + pub(super) _page_token: Option, + pub(super) _mode: Option, + pub(super) _max_results: Option, + pub(super) _has_access_to_level: Option, + pub(super) _filter_by_member_channel_id: Option, + pub(super) _delegate: Option<&'a mut dyn client::Delegate>, + pub(super) _additional_params: HashMap, + pub(super) _scopes: BTreeSet +} + +impl<'a, S> client::CallBuilder for MemberListCall<'a, S> {} + +impl<'a, S> MemberListCall<'a, S> +where + S: tower_service::Service + Clone + Send + Sync + 'static, + S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, + S::Future: Send + Unpin + 'static, + S::Error: Into>, +{ + + + /// Perform the operation you have build so far. + pub async fn doit(mut self) -> client::Result<(hyper::Response, MemberListResponse)> { + use std::io::{Read, Seek}; + use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; + use client::{ToParts, url::Params}; + use std::borrow::Cow; + + let mut dd = client::DefaultDelegate; + let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd); + dlg.begin(client::MethodInfo { id: "youtube.members.list", + http_method: hyper::Method::GET }); + + for &field in ["alt", "part", "pageToken", "mode", "maxResults", "hasAccessToLevel", "filterByMemberChannelId"].iter() { + if self._additional_params.contains_key(field) { + dlg.finished(false); + return Err(client::Error::FieldClash(field)); + } + } + + let mut params = Params::with_capacity(8 + self._additional_params.len()); + if self._part.len() > 0 { + for f in self._part.iter() { + params.push("part", f); + } + } + if let Some(value) = self._page_token.as_ref() { + params.push("pageToken", value); + } + if let Some(value) = self._mode.as_ref() { + params.push("mode", value); + } + if let Some(value) = self._max_results.as_ref() { + params.push("maxResults", value.to_string()); + } + if let Some(value) = self._has_access_to_level.as_ref() { + params.push("hasAccessToLevel", value); + } + if let Some(value) = self._filter_by_member_channel_id.as_ref() { + params.push("filterByMemberChannelId", value); + } + + params.extend(self._additional_params.iter()); + + params.push("alt", "json"); + let mut url = self.hub._base_url.clone() + "youtube/v3/members"; + if self._scopes.is_empty() { + self._scopes.insert(Scope::ChannelMembershipCreator.as_ref().to_string()); + } + + + let url = params.parse_with_url(&url); + + + + loop { + let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]).await { + Ok(token) => token, + Err(e) => { + match dlg.token(e) { + Ok(token) => token, + Err(e) => { + dlg.finished(false); + return Err(client::Error::MissingToken(e)); + } + } + } + }; + let mut req_result = { + let client = &self.hub.client; + dlg.pre_request(); + let mut req_builder = hyper::Request::builder() + .method(hyper::Method::GET) + .uri(url.as_str()) + .header(USER_AGENT, self.hub._user_agent.clone()); + + if let Some(token) = token.as_ref() { + req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); + } + + + let request = req_builder + .header(CONTENT_LENGTH, 0_u64) + .body(hyper::body::Body::empty()); + + client.request(request.unwrap()).await + + }; + + match req_result { + Err(err) => { + if let client::Retry::After(d) = dlg.http_error(&err) { + sleep(d).await; + continue; + } + dlg.finished(false); + return Err(client::Error::HttpError(err)) + } + Ok(mut res) => { + if !res.status().is_success() { + let res_body_string = client::get_body_as_string(res.body_mut()).await; + let (parts, _) = res.into_parts(); + let body = hyper::Body::from(res_body_string.clone()); + let restored_response = hyper::Response::from_parts(parts, body); + + let server_response = json::from_str::(&res_body_string).ok(); + + if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { + sleep(d).await; + continue; + } + + dlg.finished(false); + + return match server_response { + Some(error_value) => Err(client::Error::BadRequest(error_value)), + None => Err(client::Error::Failure(restored_response)), + } + } + let result_value = { + let res_body_string = client::get_body_as_string(res.body_mut()).await; + + match json::from_str(&res_body_string) { + Ok(decoded) => (res, decoded), + Err(err) => { + dlg.response_json_decode_error(&res_body_string, &err); + return Err(client::Error::JsonDecodeError(res_body_string, err)); + } + } + }; + + dlg.finished(true); + return Ok(result_value) + } + } + } + } + + + /// The *part* parameter specifies the member resource parts that the API response will include. Set the parameter value to snippet. + /// + /// Append the given value to the *part* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + /// + /// Even though the property as already been set when instantiating this call, + /// we provide this method for API completeness. + pub fn add_part(mut self, new_value: &str) -> MemberListCall<'a, S> { + self._part.push(new_value.to_string()); + self + } + /// The *pageToken* parameter identifies a specific page in the result set that should be returned. In an API response, the nextPageToken and prevPageToken properties identify other pages that could be retrieved. + /// + /// Sets the *page token* query property to the given value. + pub fn page_token(mut self, new_value: &str) -> MemberListCall<'a, S> { + self._page_token = Some(new_value.to_string()); + self + } + /// Parameter that specifies which channel members to return. + /// + /// Sets the *mode* query property to the given value. + pub fn mode(mut self, new_value: &MemberModeEnum) -> MemberListCall<'a, S> { + self._mode = Some(new_value.clone()); + self + } + /// The *maxResults* parameter specifies the maximum number of items that should be returned in the result set. + /// + /// Sets the *max results* query property to the given value. + pub fn max_results(mut self, new_value: u32) -> MemberListCall<'a, S> { + self._max_results = Some(new_value); + self + } + /// Filter members in the results set to the ones that have access to a level. + /// + /// Sets the *has access to level* query property to the given value. + pub fn has_access_to_level(mut self, new_value: &str) -> MemberListCall<'a, S> { + self._has_access_to_level = Some(new_value.to_string()); + self + } + /// Comma separated list of channel IDs. Only data about members that are part of this list will be included in the response. + /// + /// Sets the *filter by member channel id* query property to the given value. + pub fn filter_by_member_channel_id(mut self, new_value: &str) -> MemberListCall<'a, S> { + self._filter_by_member_channel_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. + /// + /// ````text + /// It should be used to handle progress information, and to implement a certain level of resilience. + /// ```` + /// + /// Sets the *delegate* property to the given value. + pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> MemberListCall<'a, S> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not be used to set any of the known parameters + /// which have their own setter method. If done anyway, the request will fail. + /// + /// # Additional Parameters + /// + /// * *$.xgafv* (query-string) - V1 error format. + /// * *access_token* (query-string) - OAuth access token. + /// * *alt* (query-string) - Data format for response. + /// * *callback* (query-string) - JSONP + /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. + /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. + /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. + /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. + /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. + /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). + /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). + pub fn param(mut self, name: T, value: T) -> MemberListCall<'a, S> + where T: AsRef { + self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); + self + } + + /// Identifies the authorization scope for the method you are building. + /// + /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant + /// [`Scope::ChannelMembershipCreator`]. + /// + /// The `scope` will be added to a set of scopes. This is important as one can maintain access + /// tokens for more than one scope. + /// + /// Usually there is more than one suitable scope to authorize an operation, some of which may + /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be + /// sufficient, a read-write scope will do as well. + pub fn add_scope(mut self, scope: St) -> MemberListCall<'a, S> + where St: AsRef { + self._scopes.insert(String::from(scope.as_ref())); + self + } + /// Identifies the authorization scope(s) for the method you are building. + /// + /// See [`Self::add_scope()`] for details. + pub fn add_scopes(mut self, scopes: I) -> MemberListCall<'a, S> + where I: IntoIterator, + St: AsRef { + self._scopes + .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); + self + } + + /// Removes all scopes, and no default scope will be used either. + /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] + /// for details). + pub fn clear_scopes(mut self) -> MemberListCall<'a, S> { + self._scopes.clear(); + self + } +} + + +/// Retrieves a list of all pricing levels offered by a creator to the fans. +/// +/// A builder for the *list* method supported by a *membershipsLevel* resource. +/// It is not used directly, but through a [`MembershipsLevelMethods`] instance. +/// +/// **Settable Parts** +/// +/// * *id* +/// * *snippet* +/// +/// # Scopes +/// +/// You will need authorization for the *https://www.googleapis.com/auth/youtube.channel-memberships.creator* scope to make a valid call. +/// +/// The default scope will be `Scope::ChannelMembershipCreator`. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate hyper_rustls; +/// # extern crate google_youtube3 as youtube3; +/// # async fn dox() { +/// # use std::default::Default; +/// # use youtube3::{YouTube, oauth2, hyper, hyper_rustls, chrono, FieldMask}; +/// +/// # let secret: oauth2::ApplicationSecret = Default::default(); +/// # let auth = oauth2::InstalledFlowAuthenticator::builder( +/// # secret, +/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, +/// # ).build().await.unwrap(); +/// # let mut hub = YouTube::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().unwrap().https_or_http().enable_http1().build()), auth); +/// // You can configure optional parameters by calling the respective setters at will, and +/// // execute the final call using `doit()`. +/// // Values shown here are possibly random and not representative ! +/// let result = hub.memberships_levels().list(&vec!["At".into()]) +/// .doit().await; +/// # } +/// ``` +pub struct MembershipsLevelListCall<'a, S> + where S: 'a { + + pub(super) hub: &'a YouTube, + pub(super) _part: Vec, + pub(super) _delegate: Option<&'a mut dyn client::Delegate>, + pub(super) _additional_params: HashMap, + pub(super) _scopes: BTreeSet +} + +impl<'a, S> client::CallBuilder for MembershipsLevelListCall<'a, S> {} + +impl<'a, S> MembershipsLevelListCall<'a, S> +where + S: tower_service::Service + Clone + Send + Sync + 'static, + S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, + S::Future: Send + Unpin + 'static, + S::Error: Into>, +{ + + + /// Perform the operation you have build so far. + pub async fn doit(mut self) -> client::Result<(hyper::Response, MembershipsLevelListResponse)> { + use std::io::{Read, Seek}; + use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; + use client::{ToParts, url::Params}; + use std::borrow::Cow; + + let mut dd = client::DefaultDelegate; + let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd); + dlg.begin(client::MethodInfo { id: "youtube.membershipsLevels.list", + http_method: hyper::Method::GET }); + + for &field in ["alt", "part"].iter() { + if self._additional_params.contains_key(field) { + dlg.finished(false); + return Err(client::Error::FieldClash(field)); + } + } + + let mut params = Params::with_capacity(3 + self._additional_params.len()); + if self._part.len() > 0 { + for f in self._part.iter() { + params.push("part", f); + } + } + + params.extend(self._additional_params.iter()); + + params.push("alt", "json"); + let mut url = self.hub._base_url.clone() + "youtube/v3/membershipsLevels"; + if self._scopes.is_empty() { + self._scopes.insert(Scope::ChannelMembershipCreator.as_ref().to_string()); + } + + + let url = params.parse_with_url(&url); + + + + loop { + let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]).await { + Ok(token) => token, + Err(e) => { + match dlg.token(e) { + Ok(token) => token, + Err(e) => { + dlg.finished(false); + return Err(client::Error::MissingToken(e)); + } + } + } + }; + let mut req_result = { + let client = &self.hub.client; + dlg.pre_request(); + let mut req_builder = hyper::Request::builder() + .method(hyper::Method::GET) + .uri(url.as_str()) + .header(USER_AGENT, self.hub._user_agent.clone()); + + if let Some(token) = token.as_ref() { + req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); + } + + + let request = req_builder + .header(CONTENT_LENGTH, 0_u64) + .body(hyper::body::Body::empty()); + + client.request(request.unwrap()).await + + }; + + match req_result { + Err(err) => { + if let client::Retry::After(d) = dlg.http_error(&err) { + sleep(d).await; + continue; + } + dlg.finished(false); + return Err(client::Error::HttpError(err)) + } + Ok(mut res) => { + if !res.status().is_success() { + let res_body_string = client::get_body_as_string(res.body_mut()).await; + let (parts, _) = res.into_parts(); + let body = hyper::Body::from(res_body_string.clone()); + let restored_response = hyper::Response::from_parts(parts, body); + + let server_response = json::from_str::(&res_body_string).ok(); + + if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { + sleep(d).await; + continue; + } + + dlg.finished(false); + + return match server_response { + Some(error_value) => Err(client::Error::BadRequest(error_value)), + None => Err(client::Error::Failure(restored_response)), + } + } + let result_value = { + let res_body_string = client::get_body_as_string(res.body_mut()).await; + + match json::from_str(&res_body_string) { + Ok(decoded) => (res, decoded), + Err(err) => { + dlg.response_json_decode_error(&res_body_string, &err); + return Err(client::Error::JsonDecodeError(res_body_string, err)); + } + } + }; + + dlg.finished(true); + return Ok(result_value) + } + } + } + } + + + /// The *part* parameter specifies the membershipsLevel resource parts that the API response will include. Supported values are id and snippet. + /// + /// Append the given value to the *part* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + /// + /// Even though the property as already been set when instantiating this call, + /// we provide this method for API completeness. + /// + /// **Settable Parts** + /// + /// * *id* + /// * *snippet* + pub fn add_part(mut self, new_value: &str) -> MembershipsLevelListCall<'a, S> { + self._part.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. + /// + /// ````text + /// It should be used to handle progress information, and to implement a certain level of resilience. + /// ```` + /// + /// Sets the *delegate* property to the given value. + pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> MembershipsLevelListCall<'a, S> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not be used to set any of the known parameters + /// which have their own setter method. If done anyway, the request will fail. + /// + /// # Additional Parameters + /// + /// * *$.xgafv* (query-string) - V1 error format. + /// * *access_token* (query-string) - OAuth access token. + /// * *alt* (query-string) - Data format for response. + /// * *callback* (query-string) - JSONP + /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. + /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. + /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. + /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. + /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. + /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). + /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). + pub fn param(mut self, name: T, value: T) -> MembershipsLevelListCall<'a, S> + where T: AsRef { + self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); + self + } + + /// Identifies the authorization scope for the method you are building. + /// + /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant + /// [`Scope::ChannelMembershipCreator`]. + /// + /// The `scope` will be added to a set of scopes. This is important as one can maintain access + /// tokens for more than one scope. + /// + /// Usually there is more than one suitable scope to authorize an operation, some of which may + /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be + /// sufficient, a read-write scope will do as well. + pub fn add_scope(mut self, scope: St) -> MembershipsLevelListCall<'a, S> + where St: AsRef { + self._scopes.insert(String::from(scope.as_ref())); + self + } + /// Identifies the authorization scope(s) for the method you are building. + /// + /// See [`Self::add_scope()`] for details. + pub fn add_scopes(mut self, scopes: I) -> MembershipsLevelListCall<'a, S> + where I: IntoIterator, + St: AsRef { + self._scopes + .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); + self + } + + /// Removes all scopes, and no default scope will be used either. + /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] + /// for details). + pub fn clear_scopes(mut self) -> MembershipsLevelListCall<'a, S> { + self._scopes.clear(); + self + } +} + + +/// Deletes a resource. +/// +/// A builder for the *delete* method supported by a *playlistImage* resource. +/// It is not used directly, but through a [`PlaylistImageMethods`] instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate hyper_rustls; +/// # extern crate google_youtube3 as youtube3; +/// # async fn dox() { +/// # use std::default::Default; +/// # use youtube3::{YouTube, oauth2, hyper, hyper_rustls, chrono, FieldMask}; +/// +/// # let secret: oauth2::ApplicationSecret = Default::default(); +/// # let auth = oauth2::InstalledFlowAuthenticator::builder( +/// # secret, +/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, +/// # ).build().await.unwrap(); +/// # let mut hub = YouTube::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().unwrap().https_or_http().enable_http1().build()), auth); +/// // You can configure optional parameters by calling the respective setters at will, and +/// // execute the final call using `doit()`. +/// // Values shown here are possibly random and not representative ! +/// let result = hub.playlist_images().delete() +/// .on_behalf_of_content_owner("dolores") +/// .id("consetetur") +/// .doit().await; +/// # } +/// ``` +pub struct PlaylistImageDeleteCall<'a, S> + where S: 'a { + + pub(super) hub: &'a YouTube, + pub(super) _on_behalf_of_content_owner: Option, + pub(super) _id: Option, + pub(super) _delegate: Option<&'a mut dyn client::Delegate>, + pub(super) _additional_params: HashMap, + pub(super) _scopes: BTreeSet +} + +impl<'a, S> client::CallBuilder for PlaylistImageDeleteCall<'a, S> {} + +impl<'a, S> PlaylistImageDeleteCall<'a, S> +where + S: tower_service::Service + Clone + Send + Sync + 'static, + S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, + S::Future: Send + Unpin + 'static, + S::Error: Into>, +{ + + + /// Perform the operation you have build so far. + pub async fn doit(mut self) -> client::Result> { + use std::io::{Read, Seek}; + use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; + use client::{ToParts, url::Params}; + use std::borrow::Cow; + + let mut dd = client::DefaultDelegate; + let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd); + dlg.begin(client::MethodInfo { id: "youtube.playlistImages.delete", + http_method: hyper::Method::DELETE }); + + for &field in ["onBehalfOfContentOwner", "id"].iter() { + if self._additional_params.contains_key(field) { + dlg.finished(false); + return Err(client::Error::FieldClash(field)); + } + } + + let mut params = Params::with_capacity(3 + self._additional_params.len()); + if let Some(value) = self._on_behalf_of_content_owner.as_ref() { + params.push("onBehalfOfContentOwner", value); + } + if let Some(value) = self._id.as_ref() { + params.push("id", value); + } + + params.extend(self._additional_params.iter()); + + let mut url = self.hub._base_url.clone() + "youtube/v3/playlistImages"; + if self._scopes.is_empty() { + self._scopes.insert(Scope::Full.as_ref().to_string()); + } + + + let url = params.parse_with_url(&url); + + + + loop { + let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]).await { + Ok(token) => token, + Err(e) => { + match dlg.token(e) { + Ok(token) => token, + Err(e) => { + dlg.finished(false); + return Err(client::Error::MissingToken(e)); + } + } + } + }; + let mut req_result = { + let client = &self.hub.client; + dlg.pre_request(); + let mut req_builder = hyper::Request::builder() + .method(hyper::Method::DELETE) + .uri(url.as_str()) + .header(USER_AGENT, self.hub._user_agent.clone()); + + if let Some(token) = token.as_ref() { + req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); + } + + + let request = req_builder + .header(CONTENT_LENGTH, 0_u64) + .body(hyper::body::Body::empty()); + + client.request(request.unwrap()).await + + }; + + match req_result { + Err(err) => { + if let client::Retry::After(d) = dlg.http_error(&err) { + sleep(d).await; + continue; + } + dlg.finished(false); + return Err(client::Error::HttpError(err)) + } + Ok(mut res) => { + if !res.status().is_success() { + let res_body_string = client::get_body_as_string(res.body_mut()).await; + let (parts, _) = res.into_parts(); + let body = hyper::Body::from(res_body_string.clone()); + let restored_response = hyper::Response::from_parts(parts, body); + + let server_response = json::from_str::(&res_body_string).ok(); + + if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { + sleep(d).await; + continue; + } + + dlg.finished(false); + + return match server_response { + Some(error_value) => Err(client::Error::BadRequest(error_value)), + None => Err(client::Error::Failure(restored_response)), + } + } + let result_value = res; + + dlg.finished(true); + return Ok(result_value) + } + } + } + } + + + /// *Note:* This parameter is intended exclusively for YouTube content partners. The *onBehalfOfContentOwner* parameter indicates that the request's authorization credentials identify a YouTube CMS user who is acting on behalf of the content owner specified in the parameter value. This parameter is intended for YouTube content partners that own and manage many different YouTube channels. It allows content owners to authenticate once and get access to all their video and channel data, without having to provide authentication credentials for each individual channel. The CMS account that the user authenticates with must be linked to the specified YouTube content owner. + /// + /// Sets the *on behalf of content owner* query property to the given value. + pub fn on_behalf_of_content_owner(mut self, new_value: &str) -> PlaylistImageDeleteCall<'a, S> { + self._on_behalf_of_content_owner = Some(new_value.to_string()); + self + } + /// Id to identify this image. This is returned from by the List method. + /// + /// Sets the *id* query property to the given value. + pub fn id(mut self, new_value: &str) -> PlaylistImageDeleteCall<'a, S> { + self._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. + /// + /// ````text + /// It should be used to handle progress information, and to implement a certain level of resilience. + /// ```` + /// + /// Sets the *delegate* property to the given value. + pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> PlaylistImageDeleteCall<'a, S> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not be used to set any of the known parameters + /// which have their own setter method. If done anyway, the request will fail. + /// + /// # Additional Parameters + /// + /// * *$.xgafv* (query-string) - V1 error format. + /// * *access_token* (query-string) - OAuth access token. + /// * *alt* (query-string) - Data format for response. + /// * *callback* (query-string) - JSONP + /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. + /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. + /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. + /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. + /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. + /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). + /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). + pub fn param(mut self, name: T, value: T) -> PlaylistImageDeleteCall<'a, S> + where T: AsRef { + self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); + self + } + + /// Identifies the authorization scope for the method you are building. + /// + /// Use this method to actively specify which scope should be used, instead of 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: St) -> PlaylistImageDeleteCall<'a, S> + where St: AsRef { + self._scopes.insert(String::from(scope.as_ref())); + self + } + /// Identifies the authorization scope(s) for the method you are building. + /// + /// See [`Self::add_scope()`] for details. + pub fn add_scopes(mut self, scopes: I) -> PlaylistImageDeleteCall<'a, S> + where I: IntoIterator, + St: AsRef { + self._scopes + .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); + self + } + + /// Removes all scopes, and no default scope will be used either. + /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] + /// for details). + pub fn clear_scopes(mut self) -> PlaylistImageDeleteCall<'a, S> { + self._scopes.clear(); + self + } +} + + +/// Inserts a new resource into this collection. +/// +/// A builder for the *insert* method supported by a *playlistImage* resource. +/// It is not used directly, but through a [`PlaylistImageMethods`] instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate hyper_rustls; +/// # extern crate google_youtube3 as youtube3; +/// use youtube3::api::PlaylistImage; +/// use std::fs; +/// # async fn dox() { +/// # use std::default::Default; +/// # use youtube3::{YouTube, oauth2, hyper, hyper_rustls, chrono, FieldMask}; +/// +/// # let secret: oauth2::ApplicationSecret = Default::default(); +/// # let auth = oauth2::InstalledFlowAuthenticator::builder( +/// # secret, +/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, +/// # ).build().await.unwrap(); +/// # let mut hub = YouTube::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().unwrap().https_or_http().enable_http1().build()), auth); +/// // As the method needs a request, you would usually fill it with the desired information +/// // into the respective structure. Some of the parts shown here might not be applicable ! +/// // Values shown here are possibly random and not representative ! +/// let mut req = PlaylistImage::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.playlist_images().insert(req) +/// .add_part("gubergren") +/// .on_behalf_of_content_owner_channel("dolor") +/// .on_behalf_of_content_owner("aliquyam") +/// .upload_resumable(fs::File::open("file.ext").unwrap(), "application/octet-stream".parse().unwrap()).await; +/// # } +/// ``` +pub struct PlaylistImageInsertCall<'a, S> + where S: 'a { + + pub(super) hub: &'a YouTube, + pub(super) _request: PlaylistImage, + pub(super) _part: Vec, + pub(super) _on_behalf_of_content_owner_channel: Option, + pub(super) _on_behalf_of_content_owner: Option, + pub(super) _delegate: Option<&'a mut dyn client::Delegate>, + pub(super) _additional_params: HashMap, + pub(super) _scopes: BTreeSet +} + +impl<'a, S> client::CallBuilder for PlaylistImageInsertCall<'a, S> {} + +impl<'a, S> PlaylistImageInsertCall<'a, S> +where + S: tower_service::Service + Clone + Send + Sync + 'static, + S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, + S::Future: Send + Unpin + 'static, + S::Error: Into>, +{ + + + /// Perform the operation you have build so far. + async fn doit(mut self, mut reader: RS, reader_mime_type: mime::Mime, protocol: client::UploadProtocol) -> client::Result<(hyper::Response, PlaylistImage)> + where RS: client::ReadSeek { + use std::io::{Read, Seek}; + use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; + use client::{ToParts, url::Params}; + use std::borrow::Cow; + + let mut dd = client::DefaultDelegate; + let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd); + dlg.begin(client::MethodInfo { id: "youtube.playlistImages.insert", + http_method: hyper::Method::POST }); + + for &field in ["alt", "part", "onBehalfOfContentOwnerChannel", "onBehalfOfContentOwner"].iter() { + if self._additional_params.contains_key(field) { + dlg.finished(false); + return Err(client::Error::FieldClash(field)); + } + } + + let mut params = Params::with_capacity(6 + self._additional_params.len()); + if self._part.is_empty() { + self._part.push(self._request.to_parts()); + } + if self._part.len() > 0 { + for f in self._part.iter() { + params.push("part", f); + } + } + if let Some(value) = self._on_behalf_of_content_owner_channel.as_ref() { + params.push("onBehalfOfContentOwnerChannel", value); + } + if let Some(value) = self._on_behalf_of_content_owner.as_ref() { + params.push("onBehalfOfContentOwner", value); + } + + params.extend(self._additional_params.iter()); + + params.push("alt", "json"); + let (mut url, upload_type) = + if protocol == client::UploadProtocol::Resumable { + (self.hub._root_url.clone() + "resumable/upload/youtube/v3/playlistImages", "resumable") + } else if protocol == client::UploadProtocol::Simple { + (self.hub._root_url.clone() + "upload/youtube/v3/playlistImages", "multipart") + } else { + unreachable!() + }; + params.push("uploadType", upload_type); + if self._scopes.is_empty() { + self._scopes.insert(Scope::Full.as_ref().to_string()); + } + + + let url = params.parse_with_url(&url); + + let mut json_mime_type = mime::APPLICATION_JSON; + let mut request_value_reader = + { + let mut value = json::value::to_value(&self._request).expect("serde to work"); + client::remove_json_null_values(&mut value); + let mut dst = io::Cursor::new(Vec::with_capacity(128)); + json::to_writer(&mut dst, &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.get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]).await { + Ok(token) => token, + Err(e) => { + match dlg.token(e) { + Ok(token) => token, + Err(e) => { + dlg.finished(false); + return Err(client::Error::MissingToken(e)); + } + } + } + }; + 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; + Ok(hyper::Response::builder() + .status(hyper::StatusCode::OK) + .header("Location", upload_url.as_ref().unwrap().clone()) + .body(hyper::body::Body::empty()) + .unwrap()) + } else { + let mut mp_reader: client::MultiPartReader = Default::default(); + let (mut body_reader, content_type) = match protocol { + client::UploadProtocol::Simple => { + mp_reader.reserve_exact(2); + let size = reader.seek(io::SeekFrom::End(0)).unwrap(); + reader.seek(io::SeekFrom::Start(0)).unwrap(); + if size > 2097152 { + return Err(client::Error::UploadSizeLimitExceeded(size, 2097152)) + } + mp_reader.add_part(&mut request_value_reader, request_size, json_mime_type.clone()) + .add_part(&mut reader, size, reader_mime_type.clone()); + (&mut mp_reader as &mut (dyn io::Read + Send), client::MultiPartReader::mime_type()) + }, + _ => (&mut request_value_reader as &mut (dyn io::Read + Send), json_mime_type.clone()), + }; + let client = &self.hub.client; + dlg.pre_request(); + let mut req_builder = hyper::Request::builder() + .method(hyper::Method::POST) + .uri(url.as_str()) + .header(USER_AGENT, self.hub._user_agent.clone()); + + if let Some(token) = token.as_ref() { + req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); + } + + upload_url_from_server = true; + if protocol == client::UploadProtocol::Resumable { + req_builder = req_builder.header("X-Upload-Content-Type", format!("{}", reader_mime_type)); + } + + let mut body_reader_bytes = vec![]; + body_reader.read_to_end(&mut body_reader_bytes).unwrap(); + let request = req_builder + .header(CONTENT_TYPE, content_type.to_string()) + .body(hyper::body::Body::from(body_reader_bytes)); + + client.request(request.unwrap()).await + + } + }; + + match req_result { + Err(err) => { + if let client::Retry::After(d) = dlg.http_error(&err) { + sleep(d).await; + continue; + } + dlg.finished(false); + return Err(client::Error::HttpError(err)) + } + Ok(mut res) => { + if !res.status().is_success() { + let res_body_string = client::get_body_as_string(res.body_mut()).await; + let (parts, _) = res.into_parts(); + let body = hyper::Body::from(res_body_string.clone()); + let restored_response = hyper::Response::from_parts(parts, body); + + let server_response = json::from_str::(&res_body_string).ok(); + + if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { + sleep(d).await; + continue; + } + + dlg.finished(false); + + return match server_response { + Some(error_value) => Err(client::Error::BadRequest(error_value)), + None => Err(client::Error::Failure(restored_response)), + } + } + if protocol == client::UploadProtocol::Resumable { + let size = reader.seek(io::SeekFrom::End(0)).unwrap(); + reader.seek(io::SeekFrom::Start(0)).unwrap(); + if size > 2097152 { + return Err(client::Error::UploadSizeLimitExceeded(size, 2097152)) + } + let upload_result = { + let url_str = &res.headers().get("Location").expect("LOCATION header is part of protocol").to_str().unwrap(); + if upload_url_from_server { + dlg.store_upload_url(Some(url_str)); + } + + client::ResumableUploadHelper { + client: &self.hub.client, + delegate: dlg, + start_at: if upload_url_from_server { Some(0) } else { None }, + auth: &self.hub.auth, + user_agent: &self.hub._user_agent, + // TODO: Check this assumption + auth_header: format!("Bearer {}", token.ok_or_else(|| client::Error::MissingToken("resumable upload requires token".into()))?.as_str()), + url: url_str, + reader: &mut reader, + media_type: reader_mime_type.clone(), + content_length: size + }.upload().await + }; + match upload_result { + None => { + dlg.finished(false); + return Err(client::Error::Cancelled) + } + Some(Err(err)) => { + dlg.finished(false); + return Err(client::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(client::Error::Failure(res)) + } + } + } + } + let result_value = { + let res_body_string = client::get_body_as_string(res.body_mut()).await; + + match json::from_str(&res_body_string) { + Ok(decoded) => (res, decoded), + Err(err) => { + dlg.response_json_decode_error(&res_body_string, &err); + return Err(client::Error::JsonDecodeError(res_body_string, err)); + } + } + }; + + dlg.finished(true); + return Ok(result_value) + } + } + } + } + + /// 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(...)`. + /// + /// * *multipart*: yes + /// * *max size*: 2097152 + /// * *valid mime types*: 'image/jpeg', 'image/png' and 'application/octet-stream' + pub async fn upload_resumable(self, resumeable_stream: RS, mime_type: mime::Mime) -> client::Result<(hyper::Response, PlaylistImage)> + where RS: client::ReadSeek { + self.doit(resumeable_stream, mime_type, client::UploadProtocol::Resumable).await + } + /// Upload media all at once. + /// If the upload fails for whichever reason, all progress is lost. + /// + /// * *multipart*: yes + /// * *max size*: 2097152 + /// * *valid mime types*: 'image/jpeg', 'image/png' and 'application/octet-stream' + pub async fn upload(self, stream: RS, mime_type: mime::Mime) -> client::Result<(hyper::Response, PlaylistImage)> + where RS: client::ReadSeek { + self.doit(stream, mime_type, client::UploadProtocol::Simple).await + } + + /// + /// Sets the *request* property to the given value. + /// + /// Even though the property as already been set when instantiating this call, + /// we provide this method for API completeness. + pub fn request(mut self, new_value: PlaylistImage) -> PlaylistImageInsertCall<'a, S> { + self._request = new_value; + self + } + /// The *part* parameter specifies the properties that the API response will include. + /// + /// Append the given value to the *part* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + /// + /// Even though the *parts* list is automatically derived from *Resource* passed in + /// during instantiation and indicates which values you are passing, the response would contain the very same parts. + /// This may not always be desirable, as you can obtain (newly generated) parts you cannot pass in, + /// like statistics that are generated server side. Therefore you should use this method to specify + /// the parts you provide in addition to the ones you want in the response. + pub fn add_part(mut self, new_value: &str) -> PlaylistImageInsertCall<'a, S> { + self._part.push(new_value.to_string()); + self + } + /// This parameter can only be used in a properly authorized request. *Note:* This parameter is intended exclusively for YouTube content partners. The *onBehalfOfContentOwnerChannel* parameter specifies the YouTube channel ID of the channel to which a video is being added. This parameter is required when a request specifies a value for the onBehalfOfContentOwner parameter, and it can only be used in conjunction with that parameter. In addition, the request must be authorized using a CMS account that is linked to the content owner that the onBehalfOfContentOwner parameter specifies. Finally, the channel that the onBehalfOfContentOwnerChannel parameter value specifies must be linked to the content owner that the onBehalfOfContentOwner parameter specifies. This parameter is intended for YouTube content partners that own and manage many different YouTube channels. It allows content owners to authenticate once and perform actions on behalf of the channel specified in the parameter value, without having to provide authentication credentials for each separate channel. + /// + /// Sets the *on behalf of content owner channel* query property to the given value. + pub fn on_behalf_of_content_owner_channel(mut self, new_value: &str) -> PlaylistImageInsertCall<'a, S> { + self._on_behalf_of_content_owner_channel = Some(new_value.to_string()); + self + } + /// *Note:* This parameter is intended exclusively for YouTube content partners. The *onBehalfOfContentOwner* parameter indicates that the request's authorization credentials identify a YouTube CMS user who is acting on behalf of the content owner specified in the parameter value. This parameter is intended for YouTube content partners that own and manage many different YouTube channels. It allows content owners to authenticate once and get access to all their video and channel data, without having to provide authentication credentials for each individual channel. The CMS account that the user authenticates with must be linked to the specified YouTube content owner. + /// + /// Sets the *on behalf of content owner* query property to the given value. + pub fn on_behalf_of_content_owner(mut self, new_value: &str) -> PlaylistImageInsertCall<'a, S> { + self._on_behalf_of_content_owner = 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. + /// + /// ````text + /// It should be used to handle progress information, and to implement a certain level of resilience. + /// ```` + /// + /// Sets the *delegate* property to the given value. + pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> PlaylistImageInsertCall<'a, S> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not be used to set any of the known parameters + /// which have their own setter method. If done anyway, the request will fail. + /// + /// # Additional Parameters + /// + /// * *$.xgafv* (query-string) - V1 error format. + /// * *access_token* (query-string) - OAuth access token. + /// * *alt* (query-string) - Data format for response. + /// * *callback* (query-string) - JSONP + /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. + /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. + /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. + /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. + /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. + /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). + /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). + pub fn param(mut self, name: T, value: T) -> PlaylistImageInsertCall<'a, S> + where T: AsRef { + self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); + self + } + + /// Identifies the authorization scope for the method you are building. + /// + /// Use this method to actively specify which scope should be used, instead of 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: St) -> PlaylistImageInsertCall<'a, S> + where St: AsRef { + self._scopes.insert(String::from(scope.as_ref())); + self + } + /// Identifies the authorization scope(s) for the method you are building. + /// + /// See [`Self::add_scope()`] for details. + pub fn add_scopes(mut self, scopes: I) -> PlaylistImageInsertCall<'a, S> + where I: IntoIterator, + St: AsRef { + self._scopes + .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); + self + } + + /// Removes all scopes, and no default scope will be used either. + /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] + /// for details). + pub fn clear_scopes(mut self) -> PlaylistImageInsertCall<'a, S> { + self._scopes.clear(); + self + } +} + + +/// Retrieves a list of resources, possibly filtered. +/// +/// A builder for the *list* method supported by a *playlistImage* resource. +/// It is not used directly, but through a [`PlaylistImageMethods`] instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate hyper_rustls; +/// # extern crate google_youtube3 as youtube3; +/// # async fn dox() { +/// # use std::default::Default; +/// # use youtube3::{YouTube, oauth2, hyper, hyper_rustls, chrono, FieldMask}; +/// +/// # let secret: oauth2::ApplicationSecret = Default::default(); +/// # let auth = oauth2::InstalledFlowAuthenticator::builder( +/// # secret, +/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, +/// # ).build().await.unwrap(); +/// # let mut hub = YouTube::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().unwrap().https_or_http().enable_http1().build()), auth); +/// // You can configure optional parameters by calling the respective setters at will, and +/// // execute the final call using `doit()`. +/// // Values shown here are possibly random and not representative ! +/// let result = hub.playlist_images().list() +/// .add_part("no") +/// .parent("amet.") +/// .page_token("ipsum") +/// .on_behalf_of_content_owner_channel("Lorem") +/// .on_behalf_of_content_owner("accusam") +/// .max_results(39) +/// .doit().await; +/// # } +/// ``` +pub struct PlaylistImageListCall<'a, S> + where S: 'a { + + pub(super) hub: &'a YouTube, + pub(super) _part: Vec, + pub(super) _parent: Option, + pub(super) _page_token: Option, + pub(super) _on_behalf_of_content_owner_channel: Option, + pub(super) _on_behalf_of_content_owner: Option, + pub(super) _max_results: Option, + pub(super) _delegate: Option<&'a mut dyn client::Delegate>, + pub(super) _additional_params: HashMap, + pub(super) _scopes: BTreeSet +} + +impl<'a, S> client::CallBuilder for PlaylistImageListCall<'a, S> {} + +impl<'a, S> PlaylistImageListCall<'a, S> +where + S: tower_service::Service + Clone + Send + Sync + 'static, + S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, + S::Future: Send + Unpin + 'static, + S::Error: Into>, +{ + + + /// Perform the operation you have build so far. + pub async fn doit(mut self) -> client::Result<(hyper::Response, PlaylistImageListResponse)> { + use std::io::{Read, Seek}; + use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; + use client::{ToParts, url::Params}; + use std::borrow::Cow; + + let mut dd = client::DefaultDelegate; + let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd); + dlg.begin(client::MethodInfo { id: "youtube.playlistImages.list", + http_method: hyper::Method::GET }); + + for &field in ["alt", "part", "parent", "pageToken", "onBehalfOfContentOwnerChannel", "onBehalfOfContentOwner", "maxResults"].iter() { + if self._additional_params.contains_key(field) { + dlg.finished(false); + return Err(client::Error::FieldClash(field)); + } + } + + let mut params = Params::with_capacity(8 + self._additional_params.len()); + if self._part.len() > 0 { + for f in self._part.iter() { + params.push("part", f); + } + } + if let Some(value) = self._parent.as_ref() { + params.push("parent", value); + } + if let Some(value) = self._page_token.as_ref() { + params.push("pageToken", value); + } + if let Some(value) = self._on_behalf_of_content_owner_channel.as_ref() { + params.push("onBehalfOfContentOwnerChannel", value); + } + if let Some(value) = self._on_behalf_of_content_owner.as_ref() { + params.push("onBehalfOfContentOwner", value); + } + if let Some(value) = self._max_results.as_ref() { + params.push("maxResults", value.to_string()); + } + + params.extend(self._additional_params.iter()); + + params.push("alt", "json"); + let mut url = self.hub._base_url.clone() + "youtube/v3/playlistImages"; + if self._scopes.is_empty() { + self._scopes.insert(Scope::Readonly.as_ref().to_string()); + } + + + let url = params.parse_with_url(&url); + + + + loop { + let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]).await { + Ok(token) => token, + Err(e) => { + match dlg.token(e) { + Ok(token) => token, + Err(e) => { + dlg.finished(false); + return Err(client::Error::MissingToken(e)); + } + } + } + }; + let mut req_result = { + let client = &self.hub.client; + dlg.pre_request(); + let mut req_builder = hyper::Request::builder() + .method(hyper::Method::GET) + .uri(url.as_str()) + .header(USER_AGENT, self.hub._user_agent.clone()); + + if let Some(token) = token.as_ref() { + req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); + } + + + let request = req_builder + .header(CONTENT_LENGTH, 0_u64) + .body(hyper::body::Body::empty()); + + client.request(request.unwrap()).await + + }; + + match req_result { + Err(err) => { + if let client::Retry::After(d) = dlg.http_error(&err) { + sleep(d).await; + continue; + } + dlg.finished(false); + return Err(client::Error::HttpError(err)) + } + Ok(mut res) => { + if !res.status().is_success() { + let res_body_string = client::get_body_as_string(res.body_mut()).await; + let (parts, _) = res.into_parts(); + let body = hyper::Body::from(res_body_string.clone()); + let restored_response = hyper::Response::from_parts(parts, body); + + let server_response = json::from_str::(&res_body_string).ok(); + + if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { + sleep(d).await; + continue; + } + + dlg.finished(false); + + return match server_response { + Some(error_value) => Err(client::Error::BadRequest(error_value)), + None => Err(client::Error::Failure(restored_response)), + } + } + let result_value = { + let res_body_string = client::get_body_as_string(res.body_mut()).await; + + match json::from_str(&res_body_string) { + Ok(decoded) => (res, decoded), + Err(err) => { + dlg.response_json_decode_error(&res_body_string, &err); + return Err(client::Error::JsonDecodeError(res_body_string, err)); + } + } + }; + + dlg.finished(true); + return Ok(result_value) + } + } + } + } + + + /// The *part* parameter specifies a comma-separated list of one or more playlistImage resource properties that the API response will include. If the parameter identifies a property that contains child properties, the child properties will be included in the response. + /// + /// Append the given value to the *part* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + pub fn add_part(mut self, new_value: &str) -> PlaylistImageListCall<'a, S> { + self._part.push(new_value.to_string()); + self + } + /// Return PlaylistImages for this playlist id. + /// + /// Sets the *parent* query property to the given value. + pub fn parent(mut self, new_value: &str) -> PlaylistImageListCall<'a, S> { + self._parent = Some(new_value.to_string()); + self + } + /// The *pageToken* parameter identifies a specific page in the result set that should be returned. In an API response, the nextPageToken and prevPageToken properties identify other pages that could be retrieved. + /// + /// Sets the *page token* query property to the given value. + pub fn page_token(mut self, new_value: &str) -> PlaylistImageListCall<'a, S> { + self._page_token = Some(new_value.to_string()); + self + } + /// This parameter can only be used in a properly authorized request. *Note:* This parameter is intended exclusively for YouTube content partners. The *onBehalfOfContentOwnerChannel* parameter specifies the YouTube channel ID of the channel to which a video is being added. This parameter is required when a request specifies a value for the onBehalfOfContentOwner parameter, and it can only be used in conjunction with that parameter. In addition, the request must be authorized using a CMS account that is linked to the content owner that the onBehalfOfContentOwner parameter specifies. Finally, the channel that the onBehalfOfContentOwnerChannel parameter value specifies must be linked to the content owner that the onBehalfOfContentOwner parameter specifies. This parameter is intended for YouTube content partners that own and manage many different YouTube channels. It allows content owners to authenticate once and perform actions on behalf of the channel specified in the parameter value, without having to provide authentication credentials for each separate channel. + /// + /// Sets the *on behalf of content owner channel* query property to the given value. + pub fn on_behalf_of_content_owner_channel(mut self, new_value: &str) -> PlaylistImageListCall<'a, S> { + self._on_behalf_of_content_owner_channel = Some(new_value.to_string()); + self + } + /// *Note:* This parameter is intended exclusively for YouTube content partners. The *onBehalfOfContentOwner* parameter indicates that the request's authorization credentials identify a YouTube CMS user who is acting on behalf of the content owner specified in the parameter value. This parameter is intended for YouTube content partners that own and manage many different YouTube channels. It allows content owners to authenticate once and get access to all their video and channel data, without having to provide authentication credentials for each individual channel. The CMS account that the user authenticates with must be linked to the specified YouTube content owner. + /// + /// Sets the *on behalf of content owner* query property to the given value. + pub fn on_behalf_of_content_owner(mut self, new_value: &str) -> PlaylistImageListCall<'a, S> { + self._on_behalf_of_content_owner = Some(new_value.to_string()); + self + } + /// The *maxResults* parameter specifies the maximum number of items that should be returned in the result set. + /// + /// Sets the *max results* query property to the given value. + pub fn max_results(mut self, new_value: u32) -> PlaylistImageListCall<'a, S> { + 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. + /// + /// ````text + /// It should be used to handle progress information, and to implement a certain level of resilience. + /// ```` + /// + /// Sets the *delegate* property to the given value. + pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> PlaylistImageListCall<'a, S> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not be used to set any of the known parameters + /// which have their own setter method. If done anyway, the request will fail. + /// + /// # Additional Parameters + /// + /// * *$.xgafv* (query-string) - V1 error format. + /// * *access_token* (query-string) - OAuth access token. + /// * *alt* (query-string) - Data format for response. + /// * *callback* (query-string) - JSONP + /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. + /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. + /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. + /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. + /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. + /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). + /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). + pub fn param(mut self, name: T, value: T) -> PlaylistImageListCall<'a, S> + where T: AsRef { + self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); + self + } + + /// Identifies the authorization scope for the method you are building. + /// + /// Use this method to actively specify which scope should be used, instead of 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: St) -> PlaylistImageListCall<'a, S> + where St: AsRef { + self._scopes.insert(String::from(scope.as_ref())); + self + } + /// Identifies the authorization scope(s) for the method you are building. + /// + /// See [`Self::add_scope()`] for details. + pub fn add_scopes(mut self, scopes: I) -> PlaylistImageListCall<'a, S> + where I: IntoIterator, + St: AsRef { + self._scopes + .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); + self + } + + /// Removes all scopes, and no default scope will be used either. + /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] + /// for details). + pub fn clear_scopes(mut self) -> PlaylistImageListCall<'a, S> { + self._scopes.clear(); + self + } +} + + +/// Updates an existing resource. +/// +/// A builder for the *update* method supported by a *playlistImage* resource. +/// It is not used directly, but through a [`PlaylistImageMethods`] instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate hyper_rustls; +/// # extern crate google_youtube3 as youtube3; +/// use youtube3::api::PlaylistImage; +/// use std::fs; +/// # async fn dox() { +/// # use std::default::Default; +/// # use youtube3::{YouTube, oauth2, hyper, hyper_rustls, chrono, FieldMask}; +/// +/// # let secret: oauth2::ApplicationSecret = Default::default(); +/// # let auth = oauth2::InstalledFlowAuthenticator::builder( +/// # secret, +/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, +/// # ).build().await.unwrap(); +/// # let mut hub = YouTube::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().unwrap().https_or_http().enable_http1().build()), auth); +/// // As the method needs a request, you would usually fill it with the desired information +/// // into the respective structure. Some of the parts shown here might not be applicable ! +/// // Values shown here are possibly random and not representative ! +/// let mut req = PlaylistImage::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.playlist_images().update(req) +/// .add_part("sadipscing") +/// .on_behalf_of_content_owner("At") +/// .upload_resumable(fs::File::open("file.ext").unwrap(), "application/octet-stream".parse().unwrap()).await; +/// # } +/// ``` +pub struct PlaylistImageUpdateCall<'a, S> + where S: 'a { + + pub(super) hub: &'a YouTube, + pub(super) _request: PlaylistImage, + pub(super) _part: Vec, + pub(super) _on_behalf_of_content_owner: Option, + pub(super) _delegate: Option<&'a mut dyn client::Delegate>, + pub(super) _additional_params: HashMap, + pub(super) _scopes: BTreeSet +} + +impl<'a, S> client::CallBuilder for PlaylistImageUpdateCall<'a, S> {} + +impl<'a, S> PlaylistImageUpdateCall<'a, S> +where + S: tower_service::Service + Clone + Send + Sync + 'static, + S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, + S::Future: Send + Unpin + 'static, + S::Error: Into>, +{ + + + /// Perform the operation you have build so far. + async fn doit(mut self, mut reader: RS, reader_mime_type: mime::Mime, protocol: client::UploadProtocol) -> client::Result<(hyper::Response, PlaylistImage)> + where RS: client::ReadSeek { + use std::io::{Read, Seek}; + use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; + use client::{ToParts, url::Params}; + use std::borrow::Cow; + + let mut dd = client::DefaultDelegate; + let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd); + dlg.begin(client::MethodInfo { id: "youtube.playlistImages.update", + http_method: hyper::Method::PUT }); + + for &field in ["alt", "part", "onBehalfOfContentOwner"].iter() { + if self._additional_params.contains_key(field) { + dlg.finished(false); + return Err(client::Error::FieldClash(field)); + } + } + + let mut params = Params::with_capacity(5 + self._additional_params.len()); + if self._part.is_empty() { + self._part.push(self._request.to_parts()); + } + if self._part.len() > 0 { + for f in self._part.iter() { + params.push("part", f); + } + } + if let Some(value) = self._on_behalf_of_content_owner.as_ref() { + params.push("onBehalfOfContentOwner", value); + } + + params.extend(self._additional_params.iter()); + + params.push("alt", "json"); + let (mut url, upload_type) = + if protocol == client::UploadProtocol::Resumable { + (self.hub._root_url.clone() + "resumable/upload/youtube/v3/playlistImages", "resumable") + } else if protocol == client::UploadProtocol::Simple { + (self.hub._root_url.clone() + "upload/youtube/v3/playlistImages", "multipart") + } else { + unreachable!() + }; + params.push("uploadType", upload_type); + if self._scopes.is_empty() { + self._scopes.insert(Scope::Full.as_ref().to_string()); + } + + + let url = params.parse_with_url(&url); + + let mut json_mime_type = mime::APPLICATION_JSON; + let mut request_value_reader = + { + let mut value = json::value::to_value(&self._request).expect("serde to work"); + client::remove_json_null_values(&mut value); + let mut dst = io::Cursor::new(Vec::with_capacity(128)); + json::to_writer(&mut dst, &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.get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]).await { + Ok(token) => token, + Err(e) => { + match dlg.token(e) { + Ok(token) => token, + Err(e) => { + dlg.finished(false); + return Err(client::Error::MissingToken(e)); + } + } + } + }; + 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; + Ok(hyper::Response::builder() + .status(hyper::StatusCode::OK) + .header("Location", upload_url.as_ref().unwrap().clone()) + .body(hyper::body::Body::empty()) + .unwrap()) + } else { + let mut mp_reader: client::MultiPartReader = Default::default(); + let (mut body_reader, content_type) = match protocol { + client::UploadProtocol::Simple => { + mp_reader.reserve_exact(2); + let size = reader.seek(io::SeekFrom::End(0)).unwrap(); + reader.seek(io::SeekFrom::Start(0)).unwrap(); + if size > 2097152 { + return Err(client::Error::UploadSizeLimitExceeded(size, 2097152)) + } + mp_reader.add_part(&mut request_value_reader, request_size, json_mime_type.clone()) + .add_part(&mut reader, size, reader_mime_type.clone()); + (&mut mp_reader as &mut (dyn io::Read + Send), client::MultiPartReader::mime_type()) + }, + _ => (&mut request_value_reader as &mut (dyn io::Read + Send), json_mime_type.clone()), + }; + let client = &self.hub.client; + dlg.pre_request(); + let mut req_builder = hyper::Request::builder() + .method(hyper::Method::PUT) + .uri(url.as_str()) + .header(USER_AGENT, self.hub._user_agent.clone()); + + if let Some(token) = token.as_ref() { + req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); + } + + upload_url_from_server = true; + if protocol == client::UploadProtocol::Resumable { + req_builder = req_builder.header("X-Upload-Content-Type", format!("{}", reader_mime_type)); + } + + let mut body_reader_bytes = vec![]; + body_reader.read_to_end(&mut body_reader_bytes).unwrap(); + let request = req_builder + .header(CONTENT_TYPE, content_type.to_string()) + .body(hyper::body::Body::from(body_reader_bytes)); + + client.request(request.unwrap()).await + + } + }; + + match req_result { + Err(err) => { + if let client::Retry::After(d) = dlg.http_error(&err) { + sleep(d).await; + continue; + } + dlg.finished(false); + return Err(client::Error::HttpError(err)) + } + Ok(mut res) => { + if !res.status().is_success() { + let res_body_string = client::get_body_as_string(res.body_mut()).await; + let (parts, _) = res.into_parts(); + let body = hyper::Body::from(res_body_string.clone()); + let restored_response = hyper::Response::from_parts(parts, body); + + let server_response = json::from_str::(&res_body_string).ok(); + + if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { + sleep(d).await; + continue; + } + + dlg.finished(false); + + return match server_response { + Some(error_value) => Err(client::Error::BadRequest(error_value)), + None => Err(client::Error::Failure(restored_response)), + } + } + if protocol == client::UploadProtocol::Resumable { + let size = reader.seek(io::SeekFrom::End(0)).unwrap(); + reader.seek(io::SeekFrom::Start(0)).unwrap(); + if size > 2097152 { + return Err(client::Error::UploadSizeLimitExceeded(size, 2097152)) + } + let upload_result = { + let url_str = &res.headers().get("Location").expect("LOCATION header is part of protocol").to_str().unwrap(); + if upload_url_from_server { + dlg.store_upload_url(Some(url_str)); + } + + client::ResumableUploadHelper { + client: &self.hub.client, + delegate: dlg, + start_at: if upload_url_from_server { Some(0) } else { None }, + auth: &self.hub.auth, + user_agent: &self.hub._user_agent, + // TODO: Check this assumption + auth_header: format!("Bearer {}", token.ok_or_else(|| client::Error::MissingToken("resumable upload requires token".into()))?.as_str()), + url: url_str, + reader: &mut reader, + media_type: reader_mime_type.clone(), + content_length: size + }.upload().await + }; + match upload_result { + None => { + dlg.finished(false); + return Err(client::Error::Cancelled) + } + Some(Err(err)) => { + dlg.finished(false); + return Err(client::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(client::Error::Failure(res)) + } + } + } + } + let result_value = { + let res_body_string = client::get_body_as_string(res.body_mut()).await; + + match json::from_str(&res_body_string) { + Ok(decoded) => (res, decoded), + Err(err) => { + dlg.response_json_decode_error(&res_body_string, &err); + return Err(client::Error::JsonDecodeError(res_body_string, err)); + } + } + }; + + dlg.finished(true); + return Ok(result_value) + } + } + } + } + + /// 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(...)`. + /// + /// * *multipart*: yes + /// * *max size*: 2097152 + /// * *valid mime types*: 'image/jpeg', 'image/png' and 'application/octet-stream' + pub async fn upload_resumable(self, resumeable_stream: RS, mime_type: mime::Mime) -> client::Result<(hyper::Response, PlaylistImage)> + where RS: client::ReadSeek { + self.doit(resumeable_stream, mime_type, client::UploadProtocol::Resumable).await + } + /// Upload media all at once. + /// If the upload fails for whichever reason, all progress is lost. + /// + /// * *multipart*: yes + /// * *max size*: 2097152 + /// * *valid mime types*: 'image/jpeg', 'image/png' and 'application/octet-stream' + pub async fn upload(self, stream: RS, mime_type: mime::Mime) -> client::Result<(hyper::Response, PlaylistImage)> + where RS: client::ReadSeek { + self.doit(stream, mime_type, client::UploadProtocol::Simple).await + } + + /// + /// Sets the *request* property to the given value. + /// + /// Even though the property as already been set when instantiating this call, + /// we provide this method for API completeness. + pub fn request(mut self, new_value: PlaylistImage) -> PlaylistImageUpdateCall<'a, S> { + self._request = new_value; + self + } + /// The *part* parameter specifies the properties that the API response will include. + /// + /// Append the given value to the *part* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + /// + /// Even though the *parts* list is automatically derived from *Resource* passed in + /// during instantiation and indicates which values you are passing, the response would contain the very same parts. + /// This may not always be desirable, as you can obtain (newly generated) parts you cannot pass in, + /// like statistics that are generated server side. Therefore you should use this method to specify + /// the parts you provide in addition to the ones you want in the response. + pub fn add_part(mut self, new_value: &str) -> PlaylistImageUpdateCall<'a, S> { + self._part.push(new_value.to_string()); + self + } + /// *Note:* This parameter is intended exclusively for YouTube content partners. The *onBehalfOfContentOwner* parameter indicates that the request's authorization credentials identify a YouTube CMS user who is acting on behalf of the content owner specified in the parameter value. This parameter is intended for YouTube content partners that own and manage many different YouTube channels. It allows content owners to authenticate once and get access to all their video and channel data, without having to provide authentication credentials for each individual channel. The CMS account that the user authenticates with must be linked to the specified YouTube content owner. + /// + /// Sets the *on behalf of content owner* query property to the given value. + pub fn on_behalf_of_content_owner(mut self, new_value: &str) -> PlaylistImageUpdateCall<'a, S> { + self._on_behalf_of_content_owner = 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. + /// + /// ````text + /// It should be used to handle progress information, and to implement a certain level of resilience. + /// ```` + /// + /// Sets the *delegate* property to the given value. + pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> PlaylistImageUpdateCall<'a, S> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not be used to set any of the known parameters + /// which have their own setter method. If done anyway, the request will fail. + /// + /// # Additional Parameters + /// + /// * *$.xgafv* (query-string) - V1 error format. + /// * *access_token* (query-string) - OAuth access token. + /// * *alt* (query-string) - Data format for response. + /// * *callback* (query-string) - JSONP + /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. + /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. + /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. + /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. + /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. + /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). + /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). + pub fn param(mut self, name: T, value: T) -> PlaylistImageUpdateCall<'a, S> + where T: AsRef { + self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); + self + } + + /// Identifies the authorization scope for the method you are building. + /// + /// Use this method to actively specify which scope should be used, instead of 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: St) -> PlaylistImageUpdateCall<'a, S> + where St: AsRef { + self._scopes.insert(String::from(scope.as_ref())); + self + } + /// Identifies the authorization scope(s) for the method you are building. + /// + /// See [`Self::add_scope()`] for details. + pub fn add_scopes(mut self, scopes: I) -> PlaylistImageUpdateCall<'a, S> + where I: IntoIterator, + St: AsRef { + self._scopes + .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); + self + } + + /// Removes all scopes, and no default scope will be used either. + /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] + /// for details). + pub fn clear_scopes(mut self) -> PlaylistImageUpdateCall<'a, S> { + self._scopes.clear(); + self + } +} + + +/// Deletes a resource. +/// +/// A builder for the *delete* method supported by a *playlistItem* resource. +/// It is not used directly, but through a [`PlaylistItemMethods`] instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate hyper_rustls; +/// # extern crate google_youtube3 as youtube3; +/// # async fn dox() { +/// # use std::default::Default; +/// # use youtube3::{YouTube, oauth2, hyper, hyper_rustls, chrono, FieldMask}; +/// +/// # let secret: oauth2::ApplicationSecret = Default::default(); +/// # let auth = oauth2::InstalledFlowAuthenticator::builder( +/// # secret, +/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, +/// # ).build().await.unwrap(); +/// # let mut hub = YouTube::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().unwrap().https_or_http().enable_http1().build()), auth); +/// // You can configure optional parameters by calling the respective setters at will, and +/// // execute the final call using `doit()`. +/// // Values shown here are possibly random and not representative ! +/// let result = hub.playlist_items().delete("id") +/// .on_behalf_of_content_owner("duo") +/// .doit().await; +/// # } +/// ``` +pub struct PlaylistItemDeleteCall<'a, S> + where S: 'a { + + pub(super) hub: &'a YouTube, + pub(super) _id: String, + pub(super) _on_behalf_of_content_owner: Option, + pub(super) _delegate: Option<&'a mut dyn client::Delegate>, + pub(super) _additional_params: HashMap, + pub(super) _scopes: BTreeSet +} + +impl<'a, S> client::CallBuilder for PlaylistItemDeleteCall<'a, S> {} + +impl<'a, S> PlaylistItemDeleteCall<'a, S> +where + S: tower_service::Service + Clone + Send + Sync + 'static, + S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, + S::Future: Send + Unpin + 'static, + S::Error: Into>, +{ + + + /// Perform the operation you have build so far. + pub async fn doit(mut self) -> client::Result> { + use std::io::{Read, Seek}; + use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; + use client::{ToParts, url::Params}; + use std::borrow::Cow; + + let mut dd = client::DefaultDelegate; + let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd); + dlg.begin(client::MethodInfo { id: "youtube.playlistItems.delete", + http_method: hyper::Method::DELETE }); + + for &field in ["id", "onBehalfOfContentOwner"].iter() { + if self._additional_params.contains_key(field) { + dlg.finished(false); + return Err(client::Error::FieldClash(field)); + } + } + + let mut params = Params::with_capacity(3 + self._additional_params.len()); + params.push("id", &self._id); + if let Some(value) = self._on_behalf_of_content_owner.as_ref() { + params.push("onBehalfOfContentOwner", value); + } + + params.extend(self._additional_params.iter()); + + let mut url = self.hub._base_url.clone() + "youtube/v3/playlistItems"; + if self._scopes.is_empty() { + self._scopes.insert(Scope::Full.as_ref().to_string()); + } + + + let url = params.parse_with_url(&url); + + + + loop { + let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]).await { + Ok(token) => token, + Err(e) => { + match dlg.token(e) { + Ok(token) => token, + Err(e) => { + dlg.finished(false); + return Err(client::Error::MissingToken(e)); + } + } + } + }; + let mut req_result = { + let client = &self.hub.client; + dlg.pre_request(); + let mut req_builder = hyper::Request::builder() + .method(hyper::Method::DELETE) + .uri(url.as_str()) + .header(USER_AGENT, self.hub._user_agent.clone()); + + if let Some(token) = token.as_ref() { + req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); + } + + + let request = req_builder + .header(CONTENT_LENGTH, 0_u64) + .body(hyper::body::Body::empty()); + + client.request(request.unwrap()).await + + }; + + match req_result { + Err(err) => { + if let client::Retry::After(d) = dlg.http_error(&err) { + sleep(d).await; + continue; + } + dlg.finished(false); + return Err(client::Error::HttpError(err)) + } + Ok(mut res) => { + if !res.status().is_success() { + let res_body_string = client::get_body_as_string(res.body_mut()).await; + let (parts, _) = res.into_parts(); + let body = hyper::Body::from(res_body_string.clone()); + let restored_response = hyper::Response::from_parts(parts, body); + + let server_response = json::from_str::(&res_body_string).ok(); + + if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { + sleep(d).await; + continue; + } + + dlg.finished(false); + + return match server_response { + Some(error_value) => Err(client::Error::BadRequest(error_value)), + None => Err(client::Error::Failure(restored_response)), + } + } + let result_value = res; + + dlg.finished(true); + return Ok(result_value) + } + } + } + } + + + /// + /// 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) -> PlaylistItemDeleteCall<'a, S> { + self._id = new_value.to_string(); + self + } + /// *Note:* This parameter is intended exclusively for YouTube content partners. The *onBehalfOfContentOwner* parameter indicates that the request's authorization credentials identify a YouTube CMS user who is acting on behalf of the content owner specified in the parameter value. This parameter is intended for YouTube content partners that own and manage many different YouTube channels. It allows content owners to authenticate once and get access to all their video and channel data, without having to provide authentication credentials for each individual channel. The CMS account that the user authenticates with must be linked to the specified YouTube content owner. + /// + /// Sets the *on behalf of content owner* query property to the given value. + pub fn on_behalf_of_content_owner(mut self, new_value: &str) -> PlaylistItemDeleteCall<'a, S> { + self._on_behalf_of_content_owner = 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. + /// + /// ````text + /// It should be used to handle progress information, and to implement a certain level of resilience. + /// ```` + /// + /// Sets the *delegate* property to the given value. + pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> PlaylistItemDeleteCall<'a, S> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not be used to set any of the known parameters + /// which have their own setter method. If done anyway, the request will fail. + /// + /// # Additional Parameters + /// + /// * *$.xgafv* (query-string) - V1 error format. + /// * *access_token* (query-string) - OAuth access token. + /// * *alt* (query-string) - Data format for response. + /// * *callback* (query-string) - JSONP + /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. + /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. + /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. + /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. + /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. + /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). + /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). + pub fn param(mut self, name: T, value: T) -> PlaylistItemDeleteCall<'a, S> + where T: AsRef { + self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); + self + } + + /// Identifies the authorization scope for the method you are building. + /// + /// Use this method to actively specify which scope should be used, instead of 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: St) -> PlaylistItemDeleteCall<'a, S> + where St: AsRef { + self._scopes.insert(String::from(scope.as_ref())); + self + } + /// Identifies the authorization scope(s) for the method you are building. + /// + /// See [`Self::add_scope()`] for details. + pub fn add_scopes(mut self, scopes: I) -> PlaylistItemDeleteCall<'a, S> + where I: IntoIterator, + St: AsRef { + self._scopes + .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); + self + } + + /// Removes all scopes, and no default scope will be used either. + /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] + /// for details). + pub fn clear_scopes(mut self) -> PlaylistItemDeleteCall<'a, S> { + self._scopes.clear(); + self + } +} + + +/// Inserts a new resource into this collection. +/// +/// A builder for the *insert* method supported by a *playlistItem* resource. +/// It is not used directly, but through a [`PlaylistItemMethods`] instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate hyper_rustls; +/// # extern crate google_youtube3 as youtube3; +/// use youtube3::api::PlaylistItem; +/// # async fn dox() { +/// # use std::default::Default; +/// # use youtube3::{YouTube, oauth2, hyper, hyper_rustls, chrono, FieldMask}; +/// +/// # let secret: oauth2::ApplicationSecret = Default::default(); +/// # let auth = oauth2::InstalledFlowAuthenticator::builder( +/// # secret, +/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, +/// # ).build().await.unwrap(); +/// # let mut hub = YouTube::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().unwrap().https_or_http().enable_http1().build()), auth); +/// // As the method needs a request, you would usually fill it with the desired information +/// // into the respective structure. Some of the parts shown here might not be applicable ! +/// // Values shown here are possibly random and not representative ! +/// let mut req = PlaylistItem::default(); +/// +/// // You can configure optional parameters by calling the respective setters at will, and +/// // execute the final call using `doit()`. +/// // Values shown here are possibly random and not representative ! +/// let result = hub.playlist_items().insert(req) +/// .on_behalf_of_content_owner("sit") +/// .doit().await; +/// # } +/// ``` +pub struct PlaylistItemInsertCall<'a, S> + where S: 'a { + + pub(super) hub: &'a YouTube, + pub(super) _request: PlaylistItem, + pub(super) _part: Vec, + pub(super) _on_behalf_of_content_owner: Option, + pub(super) _delegate: Option<&'a mut dyn client::Delegate>, + pub(super) _additional_params: HashMap, + pub(super) _scopes: BTreeSet +} + +impl<'a, S> client::CallBuilder for PlaylistItemInsertCall<'a, S> {} + +impl<'a, S> PlaylistItemInsertCall<'a, S> +where + S: tower_service::Service + Clone + Send + Sync + 'static, + S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, + S::Future: Send + Unpin + 'static, + S::Error: Into>, +{ + + + /// Perform the operation you have build so far. + pub async fn doit(mut self) -> client::Result<(hyper::Response, PlaylistItem)> { + use std::io::{Read, Seek}; + use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; + use client::{ToParts, url::Params}; + use std::borrow::Cow; + + let mut dd = client::DefaultDelegate; + let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd); + dlg.begin(client::MethodInfo { id: "youtube.playlistItems.insert", + http_method: hyper::Method::POST }); + + for &field in ["alt", "part", "onBehalfOfContentOwner"].iter() { + if self._additional_params.contains_key(field) { + dlg.finished(false); + return Err(client::Error::FieldClash(field)); + } + } + + let mut params = Params::with_capacity(5 + self._additional_params.len()); + if self._part.is_empty() { + self._part.push(self._request.to_parts()); + } + if self._part.len() > 0 { + for f in self._part.iter() { + params.push("part", f); + } + } + if let Some(value) = self._on_behalf_of_content_owner.as_ref() { + params.push("onBehalfOfContentOwner", value); + } + + params.extend(self._additional_params.iter()); + + params.push("alt", "json"); + let mut url = self.hub._base_url.clone() + "youtube/v3/playlistItems"; + if self._scopes.is_empty() { + self._scopes.insert(Scope::Full.as_ref().to_string()); + } + + + let url = params.parse_with_url(&url); + + let mut json_mime_type = mime::APPLICATION_JSON; + let mut request_value_reader = + { + let mut value = json::value::to_value(&self._request).expect("serde to work"); + client::remove_json_null_values(&mut value); + let mut dst = io::Cursor::new(Vec::with_capacity(128)); + json::to_writer(&mut dst, &value).unwrap(); + dst + }; + let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); + request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); + + + loop { + let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]).await { + Ok(token) => token, + Err(e) => { + match dlg.token(e) { + Ok(token) => token, + Err(e) => { + dlg.finished(false); + return Err(client::Error::MissingToken(e)); + } + } + } + }; + request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); + let mut req_result = { + let client = &self.hub.client; + dlg.pre_request(); + let mut req_builder = hyper::Request::builder() + .method(hyper::Method::POST) + .uri(url.as_str()) + .header(USER_AGENT, self.hub._user_agent.clone()); + + if let Some(token) = token.as_ref() { + req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); + } + + + let request = req_builder + .header(CONTENT_TYPE, json_mime_type.to_string()) + .header(CONTENT_LENGTH, request_size as u64) + .body(hyper::body::Body::from(request_value_reader.get_ref().clone())); + + client.request(request.unwrap()).await + + }; + + match req_result { + Err(err) => { + if let client::Retry::After(d) = dlg.http_error(&err) { + sleep(d).await; + continue; + } + dlg.finished(false); + return Err(client::Error::HttpError(err)) + } + Ok(mut res) => { + if !res.status().is_success() { + let res_body_string = client::get_body_as_string(res.body_mut()).await; + let (parts, _) = res.into_parts(); + let body = hyper::Body::from(res_body_string.clone()); + let restored_response = hyper::Response::from_parts(parts, body); + + let server_response = json::from_str::(&res_body_string).ok(); + + if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { + sleep(d).await; + continue; + } + + dlg.finished(false); + + return match server_response { + Some(error_value) => Err(client::Error::BadRequest(error_value)), + None => Err(client::Error::Failure(restored_response)), + } + } + let result_value = { + let res_body_string = client::get_body_as_string(res.body_mut()).await; + + match json::from_str(&res_body_string) { + Ok(decoded) => (res, decoded), + Err(err) => { + dlg.response_json_decode_error(&res_body_string, &err); + return Err(client::Error::JsonDecodeError(res_body_string, err)); + } + } + }; + + dlg.finished(true); + return Ok(result_value) + } + } + } + } + + + /// + /// Sets the *request* property to the given value. + /// + /// Even though the property as already been set when instantiating this call, + /// we provide this method for API completeness. + pub fn request(mut self, new_value: PlaylistItem) -> PlaylistItemInsertCall<'a, S> { + self._request = new_value; + self + } + /// The *part* parameter serves two purposes in this operation. It identifies the properties that the write operation will set as well as the properties that the API response will include. + /// + /// Append the given value to the *part* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + /// + /// Even though the *parts* list is automatically derived from *Resource* passed in + /// during instantiation and indicates which values you are passing, the response would contain the very same parts. + /// This may not always be desirable, as you can obtain (newly generated) parts you cannot pass in, + /// like statistics that are generated server side. Therefore you should use this method to specify + /// the parts you provide in addition to the ones you want in the response. + pub fn add_part(mut self, new_value: &str) -> PlaylistItemInsertCall<'a, S> { + self._part.push(new_value.to_string()); + self + } + /// *Note:* This parameter is intended exclusively for YouTube content partners. The *onBehalfOfContentOwner* parameter indicates that the request's authorization credentials identify a YouTube CMS user who is acting on behalf of the content owner specified in the parameter value. This parameter is intended for YouTube content partners that own and manage many different YouTube channels. It allows content owners to authenticate once and get access to all their video and channel data, without having to provide authentication credentials for each individual channel. The CMS account that the user authenticates with must be linked to the specified YouTube content owner. + /// + /// Sets the *on behalf of content owner* query property to the given value. + pub fn on_behalf_of_content_owner(mut self, new_value: &str) -> PlaylistItemInsertCall<'a, S> { + self._on_behalf_of_content_owner = 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. + /// + /// ````text + /// It should be used to handle progress information, and to implement a certain level of resilience. + /// ```` + /// + /// Sets the *delegate* property to the given value. + pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> PlaylistItemInsertCall<'a, S> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not be used to set any of the known parameters + /// which have their own setter method. If done anyway, the request will fail. + /// + /// # Additional Parameters + /// + /// * *$.xgafv* (query-string) - V1 error format. + /// * *access_token* (query-string) - OAuth access token. + /// * *alt* (query-string) - Data format for response. + /// * *callback* (query-string) - JSONP + /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. + /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. + /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. + /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. + /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. + /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). + /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). + pub fn param(mut self, name: T, value: T) -> PlaylistItemInsertCall<'a, S> + where T: AsRef { + self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); + self + } + + /// Identifies the authorization scope for the method you are building. + /// + /// Use this method to actively specify which scope should be used, instead of 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: St) -> PlaylistItemInsertCall<'a, S> + where St: AsRef { + self._scopes.insert(String::from(scope.as_ref())); + self + } + /// Identifies the authorization scope(s) for the method you are building. + /// + /// See [`Self::add_scope()`] for details. + pub fn add_scopes(mut self, scopes: I) -> PlaylistItemInsertCall<'a, S> + where I: IntoIterator, + St: AsRef { + self._scopes + .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); + self + } + + /// Removes all scopes, and no default scope will be used either. + /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] + /// for details). + pub fn clear_scopes(mut self) -> PlaylistItemInsertCall<'a, S> { + self._scopes.clear(); + self + } +} + + +/// Retrieves a list of resources, possibly filtered. +/// +/// A builder for the *list* method supported by a *playlistItem* resource. +/// It is not used directly, but through a [`PlaylistItemMethods`] instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate hyper_rustls; +/// # extern crate google_youtube3 as youtube3; +/// # async fn dox() { +/// # use std::default::Default; +/// # use youtube3::{YouTube, oauth2, hyper, hyper_rustls, chrono, FieldMask}; +/// +/// # let secret: oauth2::ApplicationSecret = Default::default(); +/// # let auth = oauth2::InstalledFlowAuthenticator::builder( +/// # secret, +/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, +/// # ).build().await.unwrap(); +/// # let mut hub = YouTube::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().unwrap().https_or_http().enable_http1().build()), auth); +/// // You can configure optional parameters by calling the respective setters at will, and +/// // execute the final call using `doit()`. +/// // Values shown here are possibly random and not representative ! +/// let result = hub.playlist_items().list(&vec!["magna".into()]) +/// .video_id("et") +/// .playlist_id("rebum.") +/// .page_token("dolor") +/// .on_behalf_of_content_owner("Lorem") +/// .max_results(30) +/// .add_id("amet.") +/// .doit().await; +/// # } +/// ``` +pub struct PlaylistItemListCall<'a, S> + where S: 'a { + + pub(super) hub: &'a YouTube, + pub(super) _part: Vec, + pub(super) _video_id: Option, + pub(super) _playlist_id: Option, + pub(super) _page_token: Option, + pub(super) _on_behalf_of_content_owner: Option, + pub(super) _max_results: Option, + pub(super) _id: Vec, + pub(super) _delegate: Option<&'a mut dyn client::Delegate>, + pub(super) _additional_params: HashMap, + pub(super) _scopes: BTreeSet +} + +impl<'a, S> client::CallBuilder for PlaylistItemListCall<'a, S> {} + +impl<'a, S> PlaylistItemListCall<'a, S> +where + S: tower_service::Service + Clone + Send + Sync + 'static, + S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, + S::Future: Send + Unpin + 'static, + S::Error: Into>, +{ + + + /// Perform the operation you have build so far. + pub async fn doit(mut self) -> client::Result<(hyper::Response, PlaylistItemListResponse)> { + use std::io::{Read, Seek}; + use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; + use client::{ToParts, url::Params}; + use std::borrow::Cow; + + let mut dd = client::DefaultDelegate; + let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd); + dlg.begin(client::MethodInfo { id: "youtube.playlistItems.list", + http_method: hyper::Method::GET }); + + for &field in ["alt", "part", "videoId", "playlistId", "pageToken", "onBehalfOfContentOwner", "maxResults", "id"].iter() { + if self._additional_params.contains_key(field) { + dlg.finished(false); + return Err(client::Error::FieldClash(field)); + } + } + + let mut params = Params::with_capacity(9 + self._additional_params.len()); + if self._part.len() > 0 { + for f in self._part.iter() { + params.push("part", f); + } + } + if let Some(value) = self._video_id.as_ref() { + params.push("videoId", value); + } + if let Some(value) = self._playlist_id.as_ref() { + params.push("playlistId", value); + } + if let Some(value) = self._page_token.as_ref() { + params.push("pageToken", value); + } + if let Some(value) = self._on_behalf_of_content_owner.as_ref() { + params.push("onBehalfOfContentOwner", value); + } + if let Some(value) = self._max_results.as_ref() { + params.push("maxResults", value.to_string()); + } + if self._id.len() > 0 { + for f in self._id.iter() { + params.push("id", f); + } + } + + params.extend(self._additional_params.iter()); + + params.push("alt", "json"); + let mut url = self.hub._base_url.clone() + "youtube/v3/playlistItems"; + if self._scopes.is_empty() { + self._scopes.insert(Scope::Readonly.as_ref().to_string()); + } + + + let url = params.parse_with_url(&url); + + + + loop { + let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]).await { + Ok(token) => token, + Err(e) => { + match dlg.token(e) { + Ok(token) => token, + Err(e) => { + dlg.finished(false); + return Err(client::Error::MissingToken(e)); + } + } + } + }; + let mut req_result = { + let client = &self.hub.client; + dlg.pre_request(); + let mut req_builder = hyper::Request::builder() + .method(hyper::Method::GET) + .uri(url.as_str()) + .header(USER_AGENT, self.hub._user_agent.clone()); + + if let Some(token) = token.as_ref() { + req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); + } + + + let request = req_builder + .header(CONTENT_LENGTH, 0_u64) + .body(hyper::body::Body::empty()); + + client.request(request.unwrap()).await + + }; + + match req_result { + Err(err) => { + if let client::Retry::After(d) = dlg.http_error(&err) { + sleep(d).await; + continue; + } + dlg.finished(false); + return Err(client::Error::HttpError(err)) + } + Ok(mut res) => { + if !res.status().is_success() { + let res_body_string = client::get_body_as_string(res.body_mut()).await; + let (parts, _) = res.into_parts(); + let body = hyper::Body::from(res_body_string.clone()); + let restored_response = hyper::Response::from_parts(parts, body); + + let server_response = json::from_str::(&res_body_string).ok(); + + if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { + sleep(d).await; + continue; + } + + dlg.finished(false); + + return match server_response { + Some(error_value) => Err(client::Error::BadRequest(error_value)), + None => Err(client::Error::Failure(restored_response)), + } + } + let result_value = { + let res_body_string = client::get_body_as_string(res.body_mut()).await; + + match json::from_str(&res_body_string) { + Ok(decoded) => (res, decoded), + Err(err) => { + dlg.response_json_decode_error(&res_body_string, &err); + return Err(client::Error::JsonDecodeError(res_body_string, err)); + } + } + }; + + dlg.finished(true); + return Ok(result_value) + } + } + } + } + + + /// The *part* parameter specifies a comma-separated list of one or more playlistItem resource properties that the API response will include. If the parameter identifies a property that contains child properties, the child properties will be included in the response. For example, in a playlistItem resource, the snippet property contains numerous fields, including the title, description, position, and resourceId properties. As such, if you set *part=snippet*, the API response will contain all of those properties. + /// + /// Append the given value to the *part* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + /// + /// Even though the property as already been set when instantiating this call, + /// we provide this method for API completeness. + pub fn add_part(mut self, new_value: &str) -> PlaylistItemListCall<'a, S> { + self._part.push(new_value.to_string()); + self + } + /// Return the playlist items associated with the given video ID. + /// + /// Sets the *video id* query property to the given value. + pub fn video_id(mut self, new_value: &str) -> PlaylistItemListCall<'a, S> { + self._video_id = Some(new_value.to_string()); + self + } + /// Return the playlist items within the given playlist. + /// + /// Sets the *playlist id* query property to the given value. + pub fn playlist_id(mut self, new_value: &str) -> PlaylistItemListCall<'a, S> { + self._playlist_id = Some(new_value.to_string()); + self + } + /// The *pageToken* parameter identifies a specific page in the result set that should be returned. In an API response, the nextPageToken and prevPageToken properties identify other pages that could be retrieved. + /// + /// Sets the *page token* query property to the given value. + pub fn page_token(mut self, new_value: &str) -> PlaylistItemListCall<'a, S> { + self._page_token = Some(new_value.to_string()); + self + } + /// *Note:* This parameter is intended exclusively for YouTube content partners. The *onBehalfOfContentOwner* parameter indicates that the request's authorization credentials identify a YouTube CMS user who is acting on behalf of the content owner specified in the parameter value. This parameter is intended for YouTube content partners that own and manage many different YouTube channels. It allows content owners to authenticate once and get access to all their video and channel data, without having to provide authentication credentials for each individual channel. The CMS account that the user authenticates with must be linked to the specified YouTube content owner. + /// + /// Sets the *on behalf of content owner* query property to the given value. + pub fn on_behalf_of_content_owner(mut self, new_value: &str) -> PlaylistItemListCall<'a, S> { + self._on_behalf_of_content_owner = Some(new_value.to_string()); + self + } + /// The *maxResults* parameter specifies the maximum number of items that should be returned in the result set. + /// + /// Sets the *max results* query property to the given value. + pub fn max_results(mut self, new_value: u32) -> PlaylistItemListCall<'a, S> { + self._max_results = Some(new_value); + self + } + /// + /// Append the given value to the *id* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + pub fn add_id(mut self, new_value: &str) -> PlaylistItemListCall<'a, S> { + self._id.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. + /// + /// ````text + /// It should be used to handle progress information, and to implement a certain level of resilience. + /// ```` + /// + /// Sets the *delegate* property to the given value. + pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> PlaylistItemListCall<'a, S> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not be used to set any of the known parameters + /// which have their own setter method. If done anyway, the request will fail. + /// + /// # Additional Parameters + /// + /// * *$.xgafv* (query-string) - V1 error format. + /// * *access_token* (query-string) - OAuth access token. + /// * *alt* (query-string) - Data format for response. + /// * *callback* (query-string) - JSONP + /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. + /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. + /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. + /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. + /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. + /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). + /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). + pub fn param(mut self, name: T, value: T) -> PlaylistItemListCall<'a, S> + where T: AsRef { + self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); + self + } + + /// Identifies the authorization scope for the method you are building. + /// + /// Use this method to actively specify which scope should be used, instead of 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: St) -> PlaylistItemListCall<'a, S> + where St: AsRef { + self._scopes.insert(String::from(scope.as_ref())); + self + } + /// Identifies the authorization scope(s) for the method you are building. + /// + /// See [`Self::add_scope()`] for details. + pub fn add_scopes(mut self, scopes: I) -> PlaylistItemListCall<'a, S> + where I: IntoIterator, + St: AsRef { + self._scopes + .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); + self + } + + /// Removes all scopes, and no default scope will be used either. + /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] + /// for details). + pub fn clear_scopes(mut self) -> PlaylistItemListCall<'a, S> { + self._scopes.clear(); + self + } +} + + +/// Updates an existing resource. +/// +/// A builder for the *update* method supported by a *playlistItem* resource. +/// It is not used directly, but through a [`PlaylistItemMethods`] instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate hyper_rustls; +/// # extern crate google_youtube3 as youtube3; +/// use youtube3::api::PlaylistItem; +/// # async fn dox() { +/// # use std::default::Default; +/// # use youtube3::{YouTube, oauth2, hyper, hyper_rustls, chrono, FieldMask}; +/// +/// # let secret: oauth2::ApplicationSecret = Default::default(); +/// # let auth = oauth2::InstalledFlowAuthenticator::builder( +/// # secret, +/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, +/// # ).build().await.unwrap(); +/// # let mut hub = YouTube::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().unwrap().https_or_http().enable_http1().build()), auth); +/// // As the method needs a request, you would usually fill it with the desired information +/// // into the respective structure. Some of the parts shown here might not be applicable ! +/// // Values shown here are possibly random and not representative ! +/// let mut req = PlaylistItem::default(); +/// +/// // You can configure optional parameters by calling the respective setters at will, and +/// // execute the final call using `doit()`. +/// // Values shown here are possibly random and not representative ! +/// let result = hub.playlist_items().update(req) +/// .on_behalf_of_content_owner("no") +/// .doit().await; +/// # } +/// ``` +pub struct PlaylistItemUpdateCall<'a, S> + where S: 'a { + + pub(super) hub: &'a YouTube, + pub(super) _request: PlaylistItem, + pub(super) _part: Vec, + pub(super) _on_behalf_of_content_owner: Option, + pub(super) _delegate: Option<&'a mut dyn client::Delegate>, + pub(super) _additional_params: HashMap, + pub(super) _scopes: BTreeSet +} + +impl<'a, S> client::CallBuilder for PlaylistItemUpdateCall<'a, S> {} + +impl<'a, S> PlaylistItemUpdateCall<'a, S> +where + S: tower_service::Service + Clone + Send + Sync + 'static, + S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, + S::Future: Send + Unpin + 'static, + S::Error: Into>, +{ + + + /// Perform the operation you have build so far. + pub async fn doit(mut self) -> client::Result<(hyper::Response, PlaylistItem)> { + use std::io::{Read, Seek}; + use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; + use client::{ToParts, url::Params}; + use std::borrow::Cow; + + let mut dd = client::DefaultDelegate; + let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd); + dlg.begin(client::MethodInfo { id: "youtube.playlistItems.update", + http_method: hyper::Method::PUT }); + + for &field in ["alt", "part", "onBehalfOfContentOwner"].iter() { + if self._additional_params.contains_key(field) { + dlg.finished(false); + return Err(client::Error::FieldClash(field)); + } + } + + let mut params = Params::with_capacity(5 + self._additional_params.len()); + if self._part.is_empty() { + self._part.push(self._request.to_parts()); + } + if self._part.len() > 0 { + for f in self._part.iter() { + params.push("part", f); + } + } + if let Some(value) = self._on_behalf_of_content_owner.as_ref() { + params.push("onBehalfOfContentOwner", value); + } + + params.extend(self._additional_params.iter()); + + params.push("alt", "json"); + let mut url = self.hub._base_url.clone() + "youtube/v3/playlistItems"; + if self._scopes.is_empty() { + self._scopes.insert(Scope::Full.as_ref().to_string()); + } + + + let url = params.parse_with_url(&url); + + let mut json_mime_type = mime::APPLICATION_JSON; + let mut request_value_reader = + { + let mut value = json::value::to_value(&self._request).expect("serde to work"); + client::remove_json_null_values(&mut value); + let mut dst = io::Cursor::new(Vec::with_capacity(128)); + json::to_writer(&mut dst, &value).unwrap(); + dst + }; + let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); + request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); + + + loop { + let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]).await { + Ok(token) => token, + Err(e) => { + match dlg.token(e) { + Ok(token) => token, + Err(e) => { + dlg.finished(false); + return Err(client::Error::MissingToken(e)); + } + } + } + }; + request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); + let mut req_result = { + let client = &self.hub.client; + dlg.pre_request(); + let mut req_builder = hyper::Request::builder() + .method(hyper::Method::PUT) + .uri(url.as_str()) + .header(USER_AGENT, self.hub._user_agent.clone()); + + if let Some(token) = token.as_ref() { + req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); + } + + + let request = req_builder + .header(CONTENT_TYPE, json_mime_type.to_string()) + .header(CONTENT_LENGTH, request_size as u64) + .body(hyper::body::Body::from(request_value_reader.get_ref().clone())); + + client.request(request.unwrap()).await + + }; + + match req_result { + Err(err) => { + if let client::Retry::After(d) = dlg.http_error(&err) { + sleep(d).await; + continue; + } + dlg.finished(false); + return Err(client::Error::HttpError(err)) + } + Ok(mut res) => { + if !res.status().is_success() { + let res_body_string = client::get_body_as_string(res.body_mut()).await; + let (parts, _) = res.into_parts(); + let body = hyper::Body::from(res_body_string.clone()); + let restored_response = hyper::Response::from_parts(parts, body); + + let server_response = json::from_str::(&res_body_string).ok(); + + if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { + sleep(d).await; + continue; + } + + dlg.finished(false); + + return match server_response { + Some(error_value) => Err(client::Error::BadRequest(error_value)), + None => Err(client::Error::Failure(restored_response)), + } + } + let result_value = { + let res_body_string = client::get_body_as_string(res.body_mut()).await; + + match json::from_str(&res_body_string) { + Ok(decoded) => (res, decoded), + Err(err) => { + dlg.response_json_decode_error(&res_body_string, &err); + return Err(client::Error::JsonDecodeError(res_body_string, err)); + } + } + }; + + dlg.finished(true); + return Ok(result_value) + } + } + } + } + + + /// + /// Sets the *request* property to the given value. + /// + /// Even though the property as already been set when instantiating this call, + /// we provide this method for API completeness. + pub fn request(mut self, new_value: PlaylistItem) -> PlaylistItemUpdateCall<'a, S> { + self._request = new_value; + self + } + /// The *part* parameter serves two purposes in this operation. It identifies the properties that the write operation will set as well as the properties that the API response will include. Note that this method will override the existing values for all of the mutable properties that are contained in any parts that the parameter value specifies. For example, a playlist item can specify a start time and end time, which identify the times portion of the video that should play when users watch the video in the playlist. If your request is updating a playlist item that sets these values, and the request's part parameter value includes the contentDetails part, the playlist item's start and end times will be updated to whatever value the request body specifies. If the request body does not specify values, the existing start and end times will be removed and replaced with the default settings. + /// + /// Append the given value to the *part* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + /// + /// Even though the *parts* list is automatically derived from *Resource* passed in + /// during instantiation and indicates which values you are passing, the response would contain the very same parts. + /// This may not always be desirable, as you can obtain (newly generated) parts you cannot pass in, + /// like statistics that are generated server side. Therefore you should use this method to specify + /// the parts you provide in addition to the ones you want in the response. + pub fn add_part(mut self, new_value: &str) -> PlaylistItemUpdateCall<'a, S> { + self._part.push(new_value.to_string()); + self + } + /// *Note:* This parameter is intended exclusively for YouTube content partners. The *onBehalfOfContentOwner* parameter indicates that the request's authorization credentials identify a YouTube CMS user who is acting on behalf of the content owner specified in the parameter value. This parameter is intended for YouTube content partners that own and manage many different YouTube channels. It allows content owners to authenticate once and get access to all their video and channel data, without having to provide authentication credentials for each individual channel. The CMS account that the user authenticates with must be linked to the specified YouTube content owner. + /// + /// Sets the *on behalf of content owner* query property to the given value. + pub fn on_behalf_of_content_owner(mut self, new_value: &str) -> PlaylistItemUpdateCall<'a, S> { + self._on_behalf_of_content_owner = 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. + /// + /// ````text + /// It should be used to handle progress information, and to implement a certain level of resilience. + /// ```` + /// + /// Sets the *delegate* property to the given value. + pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> PlaylistItemUpdateCall<'a, S> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not be used to set any of the known parameters + /// which have their own setter method. If done anyway, the request will fail. + /// + /// # Additional Parameters + /// + /// * *$.xgafv* (query-string) - V1 error format. + /// * *access_token* (query-string) - OAuth access token. + /// * *alt* (query-string) - Data format for response. + /// * *callback* (query-string) - JSONP + /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. + /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. + /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. + /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. + /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. + /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). + /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). + pub fn param(mut self, name: T, value: T) -> PlaylistItemUpdateCall<'a, S> + where T: AsRef { + self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); + self + } + + /// Identifies the authorization scope for the method you are building. + /// + /// Use this method to actively specify which scope should be used, instead of 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: St) -> PlaylistItemUpdateCall<'a, S> + where St: AsRef { + self._scopes.insert(String::from(scope.as_ref())); + self + } + /// Identifies the authorization scope(s) for the method you are building. + /// + /// See [`Self::add_scope()`] for details. + pub fn add_scopes(mut self, scopes: I) -> PlaylistItemUpdateCall<'a, S> + where I: IntoIterator, + St: AsRef { + self._scopes + .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); + self + } + + /// Removes all scopes, and no default scope will be used either. + /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] + /// for details). + pub fn clear_scopes(mut self) -> PlaylistItemUpdateCall<'a, S> { + self._scopes.clear(); + self + } +} + + +/// Deletes a resource. +/// +/// A builder for the *delete* method supported by a *playlist* resource. +/// It is not used directly, but through a [`PlaylistMethods`] instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate hyper_rustls; +/// # extern crate google_youtube3 as youtube3; +/// # async fn dox() { +/// # use std::default::Default; +/// # use youtube3::{YouTube, oauth2, hyper, hyper_rustls, chrono, FieldMask}; +/// +/// # let secret: oauth2::ApplicationSecret = Default::default(); +/// # let auth = oauth2::InstalledFlowAuthenticator::builder( +/// # secret, +/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, +/// # ).build().await.unwrap(); +/// # let mut hub = YouTube::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().unwrap().https_or_http().enable_http1().build()), auth); +/// // You can configure optional parameters by calling the respective setters at will, and +/// // execute the final call using `doit()`. +/// // Values shown here are possibly random and not representative ! +/// let result = hub.playlists().delete("id") +/// .on_behalf_of_content_owner("sed") +/// .doit().await; +/// # } +/// ``` +pub struct PlaylistDeleteCall<'a, S> + where S: 'a { + + pub(super) hub: &'a YouTube, + pub(super) _id: String, + pub(super) _on_behalf_of_content_owner: Option, + pub(super) _delegate: Option<&'a mut dyn client::Delegate>, + pub(super) _additional_params: HashMap, + pub(super) _scopes: BTreeSet +} + +impl<'a, S> client::CallBuilder for PlaylistDeleteCall<'a, S> {} + +impl<'a, S> PlaylistDeleteCall<'a, S> +where + S: tower_service::Service + Clone + Send + Sync + 'static, + S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, + S::Future: Send + Unpin + 'static, + S::Error: Into>, +{ + + + /// Perform the operation you have build so far. + pub async fn doit(mut self) -> client::Result> { + use std::io::{Read, Seek}; + use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; + use client::{ToParts, url::Params}; + use std::borrow::Cow; + + let mut dd = client::DefaultDelegate; + let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd); + dlg.begin(client::MethodInfo { id: "youtube.playlists.delete", + http_method: hyper::Method::DELETE }); + + for &field in ["id", "onBehalfOfContentOwner"].iter() { + if self._additional_params.contains_key(field) { + dlg.finished(false); + return Err(client::Error::FieldClash(field)); + } + } + + let mut params = Params::with_capacity(3 + self._additional_params.len()); + params.push("id", &self._id); + if let Some(value) = self._on_behalf_of_content_owner.as_ref() { + params.push("onBehalfOfContentOwner", value); + } + + params.extend(self._additional_params.iter()); + + let mut url = self.hub._base_url.clone() + "youtube/v3/playlists"; + if self._scopes.is_empty() { + self._scopes.insert(Scope::Full.as_ref().to_string()); + } + + + let url = params.parse_with_url(&url); + + + + loop { + let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]).await { + Ok(token) => token, + Err(e) => { + match dlg.token(e) { + Ok(token) => token, + Err(e) => { + dlg.finished(false); + return Err(client::Error::MissingToken(e)); + } + } + } + }; + let mut req_result = { + let client = &self.hub.client; + dlg.pre_request(); + let mut req_builder = hyper::Request::builder() + .method(hyper::Method::DELETE) + .uri(url.as_str()) + .header(USER_AGENT, self.hub._user_agent.clone()); + + if let Some(token) = token.as_ref() { + req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); + } + + + let request = req_builder + .header(CONTENT_LENGTH, 0_u64) + .body(hyper::body::Body::empty()); + + client.request(request.unwrap()).await + + }; + + match req_result { + Err(err) => { + if let client::Retry::After(d) = dlg.http_error(&err) { + sleep(d).await; + continue; + } + dlg.finished(false); + return Err(client::Error::HttpError(err)) + } + Ok(mut res) => { + if !res.status().is_success() { + let res_body_string = client::get_body_as_string(res.body_mut()).await; + let (parts, _) = res.into_parts(); + let body = hyper::Body::from(res_body_string.clone()); + let restored_response = hyper::Response::from_parts(parts, body); + + let server_response = json::from_str::(&res_body_string).ok(); + + if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { + sleep(d).await; + continue; + } + + dlg.finished(false); + + return match server_response { + Some(error_value) => Err(client::Error::BadRequest(error_value)), + None => Err(client::Error::Failure(restored_response)), + } + } + let result_value = res; + + dlg.finished(true); + return Ok(result_value) + } + } + } + } + + + /// + /// 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) -> PlaylistDeleteCall<'a, S> { + self._id = new_value.to_string(); + self + } + /// *Note:* This parameter is intended exclusively for YouTube content partners. The *onBehalfOfContentOwner* parameter indicates that the request's authorization credentials identify a YouTube CMS user who is acting on behalf of the content owner specified in the parameter value. This parameter is intended for YouTube content partners that own and manage many different YouTube channels. It allows content owners to authenticate once and get access to all their video and channel data, without having to provide authentication credentials for each individual channel. The CMS account that the user authenticates with must be linked to the specified YouTube content owner. + /// + /// Sets the *on behalf of content owner* query property to the given value. + pub fn on_behalf_of_content_owner(mut self, new_value: &str) -> PlaylistDeleteCall<'a, S> { + self._on_behalf_of_content_owner = 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. + /// + /// ````text + /// It should be used to handle progress information, and to implement a certain level of resilience. + /// ```` + /// + /// Sets the *delegate* property to the given value. + pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> PlaylistDeleteCall<'a, S> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not be used to set any of the known parameters + /// which have their own setter method. If done anyway, the request will fail. + /// + /// # Additional Parameters + /// + /// * *$.xgafv* (query-string) - V1 error format. + /// * *access_token* (query-string) - OAuth access token. + /// * *alt* (query-string) - Data format for response. + /// * *callback* (query-string) - JSONP + /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. + /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. + /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. + /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. + /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. + /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). + /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). + pub fn param(mut self, name: T, value: T) -> PlaylistDeleteCall<'a, S> + where T: AsRef { + self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); + self + } + + /// Identifies the authorization scope for the method you are building. + /// + /// Use this method to actively specify which scope should be used, instead of 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: St) -> PlaylistDeleteCall<'a, S> + where St: AsRef { + self._scopes.insert(String::from(scope.as_ref())); + self + } + /// Identifies the authorization scope(s) for the method you are building. + /// + /// See [`Self::add_scope()`] for details. + pub fn add_scopes(mut self, scopes: I) -> PlaylistDeleteCall<'a, S> + where I: IntoIterator, + St: AsRef { + self._scopes + .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); + self + } + + /// Removes all scopes, and no default scope will be used either. + /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] + /// for details). + pub fn clear_scopes(mut self) -> PlaylistDeleteCall<'a, S> { + self._scopes.clear(); + self + } +} + + +/// Inserts a new resource into this collection. +/// +/// A builder for the *insert* method supported by a *playlist* resource. +/// It is not used directly, but through a [`PlaylistMethods`] instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate hyper_rustls; +/// # extern crate google_youtube3 as youtube3; +/// use youtube3::api::Playlist; +/// # async fn dox() { +/// # use std::default::Default; +/// # use youtube3::{YouTube, oauth2, hyper, hyper_rustls, chrono, FieldMask}; +/// +/// # let secret: oauth2::ApplicationSecret = Default::default(); +/// # let auth = oauth2::InstalledFlowAuthenticator::builder( +/// # secret, +/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, +/// # ).build().await.unwrap(); +/// # let mut hub = YouTube::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().unwrap().https_or_http().enable_http1().build()), auth); +/// // As the method needs a request, you would usually fill it with the desired information +/// // into the respective structure. Some of the parts shown here might not be applicable ! +/// // Values shown here are possibly random and not representative ! +/// let mut req = Playlist::default(); +/// +/// // You can configure optional parameters by calling the respective setters at will, and +/// // execute the final call using `doit()`. +/// // Values shown here are possibly random and not representative ! +/// let result = hub.playlists().insert(req) +/// .on_behalf_of_content_owner_channel("kasd") +/// .on_behalf_of_content_owner("Lorem") +/// .doit().await; +/// # } +/// ``` +pub struct PlaylistInsertCall<'a, S> + where S: 'a { + + pub(super) hub: &'a YouTube, + pub(super) _request: Playlist, + pub(super) _part: Vec, + pub(super) _on_behalf_of_content_owner_channel: Option, + pub(super) _on_behalf_of_content_owner: Option, + pub(super) _delegate: Option<&'a mut dyn client::Delegate>, + pub(super) _additional_params: HashMap, + pub(super) _scopes: BTreeSet +} + +impl<'a, S> client::CallBuilder for PlaylistInsertCall<'a, S> {} + +impl<'a, S> PlaylistInsertCall<'a, S> +where + S: tower_service::Service + Clone + Send + Sync + 'static, + S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, + S::Future: Send + Unpin + 'static, + S::Error: Into>, +{ + + + /// Perform the operation you have build so far. + pub async fn doit(mut self) -> client::Result<(hyper::Response, Playlist)> { + use std::io::{Read, Seek}; + use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; + use client::{ToParts, url::Params}; + use std::borrow::Cow; + + let mut dd = client::DefaultDelegate; + let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd); + dlg.begin(client::MethodInfo { id: "youtube.playlists.insert", + http_method: hyper::Method::POST }); + + for &field in ["alt", "part", "onBehalfOfContentOwnerChannel", "onBehalfOfContentOwner"].iter() { + if self._additional_params.contains_key(field) { + dlg.finished(false); + return Err(client::Error::FieldClash(field)); + } + } + + let mut params = Params::with_capacity(6 + self._additional_params.len()); + if self._part.is_empty() { + self._part.push(self._request.to_parts()); + } + if self._part.len() > 0 { + for f in self._part.iter() { + params.push("part", f); + } + } + if let Some(value) = self._on_behalf_of_content_owner_channel.as_ref() { + params.push("onBehalfOfContentOwnerChannel", value); + } + if let Some(value) = self._on_behalf_of_content_owner.as_ref() { + params.push("onBehalfOfContentOwner", value); + } + + params.extend(self._additional_params.iter()); + + params.push("alt", "json"); + let mut url = self.hub._base_url.clone() + "youtube/v3/playlists"; + if self._scopes.is_empty() { + self._scopes.insert(Scope::Full.as_ref().to_string()); + } + + + let url = params.parse_with_url(&url); + + let mut json_mime_type = mime::APPLICATION_JSON; + let mut request_value_reader = + { + let mut value = json::value::to_value(&self._request).expect("serde to work"); + client::remove_json_null_values(&mut value); + let mut dst = io::Cursor::new(Vec::with_capacity(128)); + json::to_writer(&mut dst, &value).unwrap(); + dst + }; + let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); + request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); + + + loop { + let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]).await { + Ok(token) => token, + Err(e) => { + match dlg.token(e) { + Ok(token) => token, + Err(e) => { + dlg.finished(false); + return Err(client::Error::MissingToken(e)); + } + } + } + }; + request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); + let mut req_result = { + let client = &self.hub.client; + dlg.pre_request(); + let mut req_builder = hyper::Request::builder() + .method(hyper::Method::POST) + .uri(url.as_str()) + .header(USER_AGENT, self.hub._user_agent.clone()); + + if let Some(token) = token.as_ref() { + req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); + } + + + let request = req_builder + .header(CONTENT_TYPE, json_mime_type.to_string()) + .header(CONTENT_LENGTH, request_size as u64) + .body(hyper::body::Body::from(request_value_reader.get_ref().clone())); + + client.request(request.unwrap()).await + + }; + + match req_result { + Err(err) => { + if let client::Retry::After(d) = dlg.http_error(&err) { + sleep(d).await; + continue; + } + dlg.finished(false); + return Err(client::Error::HttpError(err)) + } + Ok(mut res) => { + if !res.status().is_success() { + let res_body_string = client::get_body_as_string(res.body_mut()).await; + let (parts, _) = res.into_parts(); + let body = hyper::Body::from(res_body_string.clone()); + let restored_response = hyper::Response::from_parts(parts, body); + + let server_response = json::from_str::(&res_body_string).ok(); + + if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { + sleep(d).await; + continue; + } + + dlg.finished(false); + + return match server_response { + Some(error_value) => Err(client::Error::BadRequest(error_value)), + None => Err(client::Error::Failure(restored_response)), + } + } + let result_value = { + let res_body_string = client::get_body_as_string(res.body_mut()).await; + + match json::from_str(&res_body_string) { + Ok(decoded) => (res, decoded), + Err(err) => { + dlg.response_json_decode_error(&res_body_string, &err); + return Err(client::Error::JsonDecodeError(res_body_string, err)); + } + } + }; + + dlg.finished(true); + return Ok(result_value) + } + } + } + } + + + /// + /// Sets the *request* property to the given value. + /// + /// Even though the property as already been set when instantiating this call, + /// we provide this method for API completeness. + pub fn request(mut self, new_value: Playlist) -> PlaylistInsertCall<'a, S> { + self._request = new_value; + self + } + /// The *part* parameter serves two purposes in this operation. It identifies the properties that the write operation will set as well as the properties that the API response will include. + /// + /// Append the given value to the *part* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + /// + /// Even though the *parts* list is automatically derived from *Resource* passed in + /// during instantiation and indicates which values you are passing, the response would contain the very same parts. + /// This may not always be desirable, as you can obtain (newly generated) parts you cannot pass in, + /// like statistics that are generated server side. Therefore you should use this method to specify + /// the parts you provide in addition to the ones you want in the response. + pub fn add_part(mut self, new_value: &str) -> PlaylistInsertCall<'a, S> { + self._part.push(new_value.to_string()); + self + } + /// This parameter can only be used in a properly authorized request. *Note:* This parameter is intended exclusively for YouTube content partners. The *onBehalfOfContentOwnerChannel* parameter specifies the YouTube channel ID of the channel to which a video is being added. This parameter is required when a request specifies a value for the onBehalfOfContentOwner parameter, and it can only be used in conjunction with that parameter. In addition, the request must be authorized using a CMS account that is linked to the content owner that the onBehalfOfContentOwner parameter specifies. Finally, the channel that the onBehalfOfContentOwnerChannel parameter value specifies must be linked to the content owner that the onBehalfOfContentOwner parameter specifies. This parameter is intended for YouTube content partners that own and manage many different YouTube channels. It allows content owners to authenticate once and perform actions on behalf of the channel specified in the parameter value, without having to provide authentication credentials for each separate channel. + /// + /// Sets the *on behalf of content owner channel* query property to the given value. + pub fn on_behalf_of_content_owner_channel(mut self, new_value: &str) -> PlaylistInsertCall<'a, S> { + self._on_behalf_of_content_owner_channel = Some(new_value.to_string()); + self + } + /// *Note:* This parameter is intended exclusively for YouTube content partners. The *onBehalfOfContentOwner* parameter indicates that the request's authorization credentials identify a YouTube CMS user who is acting on behalf of the content owner specified in the parameter value. This parameter is intended for YouTube content partners that own and manage many different YouTube channels. It allows content owners to authenticate once and get access to all their video and channel data, without having to provide authentication credentials for each individual channel. The CMS account that the user authenticates with must be linked to the specified YouTube content owner. + /// + /// Sets the *on behalf of content owner* query property to the given value. + pub fn on_behalf_of_content_owner(mut self, new_value: &str) -> PlaylistInsertCall<'a, S> { + self._on_behalf_of_content_owner = 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. + /// + /// ````text + /// It should be used to handle progress information, and to implement a certain level of resilience. + /// ```` + /// + /// Sets the *delegate* property to the given value. + pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> PlaylistInsertCall<'a, S> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not be used to set any of the known parameters + /// which have their own setter method. If done anyway, the request will fail. + /// + /// # Additional Parameters + /// + /// * *$.xgafv* (query-string) - V1 error format. + /// * *access_token* (query-string) - OAuth access token. + /// * *alt* (query-string) - Data format for response. + /// * *callback* (query-string) - JSONP + /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. + /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. + /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. + /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. + /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. + /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). + /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). + pub fn param(mut self, name: T, value: T) -> PlaylistInsertCall<'a, S> + where T: AsRef { + self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); + self + } + + /// Identifies the authorization scope for the method you are building. + /// + /// Use this method to actively specify which scope should be used, instead of 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: St) -> PlaylistInsertCall<'a, S> + where St: AsRef { + self._scopes.insert(String::from(scope.as_ref())); + self + } + /// Identifies the authorization scope(s) for the method you are building. + /// + /// See [`Self::add_scope()`] for details. + pub fn add_scopes(mut self, scopes: I) -> PlaylistInsertCall<'a, S> + where I: IntoIterator, + St: AsRef { + self._scopes + .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); + self + } + + /// Removes all scopes, and no default scope will be used either. + /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] + /// for details). + pub fn clear_scopes(mut self) -> PlaylistInsertCall<'a, S> { + self._scopes.clear(); + self + } +} + + +/// Retrieves a list of resources, possibly filtered. +/// +/// A builder for the *list* method supported by a *playlist* resource. +/// It is not used directly, but through a [`PlaylistMethods`] instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate hyper_rustls; +/// # extern crate google_youtube3 as youtube3; +/// # async fn dox() { +/// # use std::default::Default; +/// # use youtube3::{YouTube, oauth2, hyper, hyper_rustls, chrono, FieldMask}; +/// +/// # let secret: oauth2::ApplicationSecret = Default::default(); +/// # let auth = oauth2::InstalledFlowAuthenticator::builder( +/// # secret, +/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, +/// # ).build().await.unwrap(); +/// # let mut hub = YouTube::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().unwrap().https_or_http().enable_http1().build()), auth); +/// // You can configure optional parameters by calling the respective setters at will, and +/// // execute the final call using `doit()`. +/// // Values shown here are possibly random and not representative ! +/// let result = hub.playlists().list(&vec!["sanctus".into()]) +/// .page_token("nonumy") +/// .on_behalf_of_content_owner_channel("rebum.") +/// .on_behalf_of_content_owner("tempor") +/// .mine(true) +/// .max_results(17) +/// .add_id("amet") +/// .hl("ut") +/// .channel_id("At") +/// .doit().await; +/// # } +/// ``` +pub struct PlaylistListCall<'a, S> + where S: 'a { + + pub(super) hub: &'a YouTube, + pub(super) _part: Vec, + pub(super) _page_token: Option, + pub(super) _on_behalf_of_content_owner_channel: Option, + pub(super) _on_behalf_of_content_owner: Option, + pub(super) _mine: Option, + pub(super) _max_results: Option, + pub(super) _id: Vec, + pub(super) _hl: Option, + pub(super) _channel_id: Option, + pub(super) _delegate: Option<&'a mut dyn client::Delegate>, + pub(super) _additional_params: HashMap, + pub(super) _scopes: BTreeSet +} + +impl<'a, S> client::CallBuilder for PlaylistListCall<'a, S> {} + +impl<'a, S> PlaylistListCall<'a, S> +where + S: tower_service::Service + Clone + Send + Sync + 'static, + S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, + S::Future: Send + Unpin + 'static, + S::Error: Into>, +{ + + + /// Perform the operation you have build so far. + pub async fn doit(mut self) -> client::Result<(hyper::Response, PlaylistListResponse)> { + use std::io::{Read, Seek}; + use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; + use client::{ToParts, url::Params}; + use std::borrow::Cow; + + let mut dd = client::DefaultDelegate; + let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd); + dlg.begin(client::MethodInfo { id: "youtube.playlists.list", + http_method: hyper::Method::GET }); + + for &field in ["alt", "part", "pageToken", "onBehalfOfContentOwnerChannel", "onBehalfOfContentOwner", "mine", "maxResults", "id", "hl", "channelId"].iter() { + if self._additional_params.contains_key(field) { + dlg.finished(false); + return Err(client::Error::FieldClash(field)); + } + } + + let mut params = Params::with_capacity(11 + self._additional_params.len()); + if self._part.len() > 0 { + for f in self._part.iter() { + params.push("part", f); + } + } + if let Some(value) = self._page_token.as_ref() { + params.push("pageToken", value); + } + if let Some(value) = self._on_behalf_of_content_owner_channel.as_ref() { + params.push("onBehalfOfContentOwnerChannel", value); + } + if let Some(value) = self._on_behalf_of_content_owner.as_ref() { + params.push("onBehalfOfContentOwner", value); + } + if let Some(value) = self._mine.as_ref() { + params.push("mine", value.to_string()); + } + if let Some(value) = self._max_results.as_ref() { + params.push("maxResults", value.to_string()); + } + if self._id.len() > 0 { + for f in self._id.iter() { + params.push("id", f); + } + } + if let Some(value) = self._hl.as_ref() { + params.push("hl", value); + } + if let Some(value) = self._channel_id.as_ref() { + params.push("channelId", value); + } + + params.extend(self._additional_params.iter()); + + params.push("alt", "json"); + let mut url = self.hub._base_url.clone() + "youtube/v3/playlists"; + if self._scopes.is_empty() { + self._scopes.insert(Scope::Readonly.as_ref().to_string()); + } + + + let url = params.parse_with_url(&url); + + + + loop { + let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]).await { + Ok(token) => token, + Err(e) => { + match dlg.token(e) { + Ok(token) => token, + Err(e) => { + dlg.finished(false); + return Err(client::Error::MissingToken(e)); + } + } + } + }; + let mut req_result = { + let client = &self.hub.client; + dlg.pre_request(); + let mut req_builder = hyper::Request::builder() + .method(hyper::Method::GET) + .uri(url.as_str()) + .header(USER_AGENT, self.hub._user_agent.clone()); + + if let Some(token) = token.as_ref() { + req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); + } + + + let request = req_builder + .header(CONTENT_LENGTH, 0_u64) + .body(hyper::body::Body::empty()); + + client.request(request.unwrap()).await + + }; + + match req_result { + Err(err) => { + if let client::Retry::After(d) = dlg.http_error(&err) { + sleep(d).await; + continue; + } + dlg.finished(false); + return Err(client::Error::HttpError(err)) + } + Ok(mut res) => { + if !res.status().is_success() { + let res_body_string = client::get_body_as_string(res.body_mut()).await; + let (parts, _) = res.into_parts(); + let body = hyper::Body::from(res_body_string.clone()); + let restored_response = hyper::Response::from_parts(parts, body); + + let server_response = json::from_str::(&res_body_string).ok(); + + if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { + sleep(d).await; + continue; + } + + dlg.finished(false); + + return match server_response { + Some(error_value) => Err(client::Error::BadRequest(error_value)), + None => Err(client::Error::Failure(restored_response)), + } + } + let result_value = { + let res_body_string = client::get_body_as_string(res.body_mut()).await; + + match json::from_str(&res_body_string) { + Ok(decoded) => (res, decoded), + Err(err) => { + dlg.response_json_decode_error(&res_body_string, &err); + return Err(client::Error::JsonDecodeError(res_body_string, err)); + } + } + }; + + dlg.finished(true); + return Ok(result_value) + } + } + } + } + + + /// The *part* parameter specifies a comma-separated list of one or more playlist resource properties that the API response will include. If the parameter identifies a property that contains child properties, the child properties will be included in the response. For example, in a playlist resource, the snippet property contains properties like author, title, description, tags, and timeCreated. As such, if you set *part=snippet*, the API response will contain all of those properties. + /// + /// Append the given value to the *part* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + /// + /// Even though the property as already been set when instantiating this call, + /// we provide this method for API completeness. + pub fn add_part(mut self, new_value: &str) -> PlaylistListCall<'a, S> { + self._part.push(new_value.to_string()); + self + } + /// The *pageToken* parameter identifies a specific page in the result set that should be returned. In an API response, the nextPageToken and prevPageToken properties identify other pages that could be retrieved. + /// + /// Sets the *page token* query property to the given value. + pub fn page_token(mut self, new_value: &str) -> PlaylistListCall<'a, S> { + self._page_token = Some(new_value.to_string()); + self + } + /// This parameter can only be used in a properly authorized request. *Note:* This parameter is intended exclusively for YouTube content partners. The *onBehalfOfContentOwnerChannel* parameter specifies the YouTube channel ID of the channel to which a video is being added. This parameter is required when a request specifies a value for the onBehalfOfContentOwner parameter, and it can only be used in conjunction with that parameter. In addition, the request must be authorized using a CMS account that is linked to the content owner that the onBehalfOfContentOwner parameter specifies. Finally, the channel that the onBehalfOfContentOwnerChannel parameter value specifies must be linked to the content owner that the onBehalfOfContentOwner parameter specifies. This parameter is intended for YouTube content partners that own and manage many different YouTube channels. It allows content owners to authenticate once and perform actions on behalf of the channel specified in the parameter value, without having to provide authentication credentials for each separate channel. + /// + /// Sets the *on behalf of content owner channel* query property to the given value. + pub fn on_behalf_of_content_owner_channel(mut self, new_value: &str) -> PlaylistListCall<'a, S> { + self._on_behalf_of_content_owner_channel = Some(new_value.to_string()); + self + } + /// *Note:* This parameter is intended exclusively for YouTube content partners. The *onBehalfOfContentOwner* parameter indicates that the request's authorization credentials identify a YouTube CMS user who is acting on behalf of the content owner specified in the parameter value. This parameter is intended for YouTube content partners that own and manage many different YouTube channels. It allows content owners to authenticate once and get access to all their video and channel data, without having to provide authentication credentials for each individual channel. The CMS account that the user authenticates with must be linked to the specified YouTube content owner. + /// + /// Sets the *on behalf of content owner* query property to the given value. + pub fn on_behalf_of_content_owner(mut self, new_value: &str) -> PlaylistListCall<'a, S> { + self._on_behalf_of_content_owner = Some(new_value.to_string()); + self + } + /// Return the playlists owned by the authenticated user. + /// + /// Sets the *mine* query property to the given value. + pub fn mine(mut self, new_value: bool) -> PlaylistListCall<'a, S> { + self._mine = Some(new_value); + self + } + /// The *maxResults* parameter specifies the maximum number of items that should be returned in the result set. + /// + /// Sets the *max results* query property to the given value. + pub fn max_results(mut self, new_value: u32) -> PlaylistListCall<'a, S> { + self._max_results = Some(new_value); + self + } + /// Return the playlists with the given IDs for Stubby or Apiary. + /// + /// Append the given value to the *id* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + pub fn add_id(mut self, new_value: &str) -> PlaylistListCall<'a, S> { + self._id.push(new_value.to_string()); + self + } + /// Return content in specified language + /// + /// Sets the *hl* query property to the given value. + pub fn hl(mut self, new_value: &str) -> PlaylistListCall<'a, S> { + self._hl = Some(new_value.to_string()); + self + } + /// Return the playlists owned by the specified channel ID. + /// + /// Sets the *channel id* query property to the given value. + pub fn channel_id(mut self, new_value: &str) -> PlaylistListCall<'a, S> { + self._channel_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. + /// + /// ````text + /// It should be used to handle progress information, and to implement a certain level of resilience. + /// ```` + /// + /// Sets the *delegate* property to the given value. + pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> PlaylistListCall<'a, S> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not be used to set any of the known parameters + /// which have their own setter method. If done anyway, the request will fail. + /// + /// # Additional Parameters + /// + /// * *$.xgafv* (query-string) - V1 error format. + /// * *access_token* (query-string) - OAuth access token. + /// * *alt* (query-string) - Data format for response. + /// * *callback* (query-string) - JSONP + /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. + /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. + /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. + /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. + /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. + /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). + /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). + pub fn param(mut self, name: T, value: T) -> PlaylistListCall<'a, S> + where T: AsRef { + self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); + self + } + + /// Identifies the authorization scope for the method you are building. + /// + /// Use this method to actively specify which scope should be used, instead of 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: St) -> PlaylistListCall<'a, S> + where St: AsRef { + self._scopes.insert(String::from(scope.as_ref())); + self + } + /// Identifies the authorization scope(s) for the method you are building. + /// + /// See [`Self::add_scope()`] for details. + pub fn add_scopes(mut self, scopes: I) -> PlaylistListCall<'a, S> + where I: IntoIterator, + St: AsRef { + self._scopes + .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); + self + } + + /// Removes all scopes, and no default scope will be used either. + /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] + /// for details). + pub fn clear_scopes(mut self) -> PlaylistListCall<'a, S> { + self._scopes.clear(); + self + } +} + + +/// Updates an existing resource. +/// +/// A builder for the *update* method supported by a *playlist* resource. +/// It is not used directly, but through a [`PlaylistMethods`] instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate hyper_rustls; +/// # extern crate google_youtube3 as youtube3; +/// use youtube3::api::Playlist; +/// # async fn dox() { +/// # use std::default::Default; +/// # use youtube3::{YouTube, oauth2, hyper, hyper_rustls, chrono, FieldMask}; +/// +/// # let secret: oauth2::ApplicationSecret = Default::default(); +/// # let auth = oauth2::InstalledFlowAuthenticator::builder( +/// # secret, +/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, +/// # ).build().await.unwrap(); +/// # let mut hub = YouTube::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().unwrap().https_or_http().enable_http1().build()), auth); +/// // As the method needs a request, you would usually fill it with the desired information +/// // into the respective structure. Some of the parts shown here might not be applicable ! +/// // Values shown here are possibly random and not representative ! +/// let mut req = Playlist::default(); +/// +/// // You can configure optional parameters by calling the respective setters at will, and +/// // execute the final call using `doit()`. +/// // Values shown here are possibly random and not representative ! +/// let result = hub.playlists().update(req) +/// .on_behalf_of_content_owner("sit") +/// .doit().await; +/// # } +/// ``` +pub struct PlaylistUpdateCall<'a, S> + where S: 'a { + + pub(super) hub: &'a YouTube, + pub(super) _request: Playlist, + pub(super) _part: Vec, + pub(super) _on_behalf_of_content_owner: Option, + pub(super) _delegate: Option<&'a mut dyn client::Delegate>, + pub(super) _additional_params: HashMap, + pub(super) _scopes: BTreeSet +} + +impl<'a, S> client::CallBuilder for PlaylistUpdateCall<'a, S> {} + +impl<'a, S> PlaylistUpdateCall<'a, S> +where + S: tower_service::Service + Clone + Send + Sync + 'static, + S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, + S::Future: Send + Unpin + 'static, + S::Error: Into>, +{ + + + /// Perform the operation you have build so far. + pub async fn doit(mut self) -> client::Result<(hyper::Response, Playlist)> { + use std::io::{Read, Seek}; + use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; + use client::{ToParts, url::Params}; + use std::borrow::Cow; + + let mut dd = client::DefaultDelegate; + let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd); + dlg.begin(client::MethodInfo { id: "youtube.playlists.update", + http_method: hyper::Method::PUT }); + + for &field in ["alt", "part", "onBehalfOfContentOwner"].iter() { + if self._additional_params.contains_key(field) { + dlg.finished(false); + return Err(client::Error::FieldClash(field)); + } + } + + let mut params = Params::with_capacity(5 + self._additional_params.len()); + if self._part.is_empty() { + self._part.push(self._request.to_parts()); + } + if self._part.len() > 0 { + for f in self._part.iter() { + params.push("part", f); + } + } + if let Some(value) = self._on_behalf_of_content_owner.as_ref() { + params.push("onBehalfOfContentOwner", value); + } + + params.extend(self._additional_params.iter()); + + params.push("alt", "json"); + let mut url = self.hub._base_url.clone() + "youtube/v3/playlists"; + if self._scopes.is_empty() { + self._scopes.insert(Scope::Full.as_ref().to_string()); + } + + + let url = params.parse_with_url(&url); + + let mut json_mime_type = mime::APPLICATION_JSON; + let mut request_value_reader = + { + let mut value = json::value::to_value(&self._request).expect("serde to work"); + client::remove_json_null_values(&mut value); + let mut dst = io::Cursor::new(Vec::with_capacity(128)); + json::to_writer(&mut dst, &value).unwrap(); + dst + }; + let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); + request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); + + + loop { + let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]).await { + Ok(token) => token, + Err(e) => { + match dlg.token(e) { + Ok(token) => token, + Err(e) => { + dlg.finished(false); + return Err(client::Error::MissingToken(e)); + } + } + } + }; + request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); + let mut req_result = { + let client = &self.hub.client; + dlg.pre_request(); + let mut req_builder = hyper::Request::builder() + .method(hyper::Method::PUT) + .uri(url.as_str()) + .header(USER_AGENT, self.hub._user_agent.clone()); + + if let Some(token) = token.as_ref() { + req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); + } + + + let request = req_builder + .header(CONTENT_TYPE, json_mime_type.to_string()) + .header(CONTENT_LENGTH, request_size as u64) + .body(hyper::body::Body::from(request_value_reader.get_ref().clone())); + + client.request(request.unwrap()).await + + }; + + match req_result { + Err(err) => { + if let client::Retry::After(d) = dlg.http_error(&err) { + sleep(d).await; + continue; + } + dlg.finished(false); + return Err(client::Error::HttpError(err)) + } + Ok(mut res) => { + if !res.status().is_success() { + let res_body_string = client::get_body_as_string(res.body_mut()).await; + let (parts, _) = res.into_parts(); + let body = hyper::Body::from(res_body_string.clone()); + let restored_response = hyper::Response::from_parts(parts, body); + + let server_response = json::from_str::(&res_body_string).ok(); + + if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { + sleep(d).await; + continue; + } + + dlg.finished(false); + + return match server_response { + Some(error_value) => Err(client::Error::BadRequest(error_value)), + None => Err(client::Error::Failure(restored_response)), + } + } + let result_value = { + let res_body_string = client::get_body_as_string(res.body_mut()).await; + + match json::from_str(&res_body_string) { + Ok(decoded) => (res, decoded), + Err(err) => { + dlg.response_json_decode_error(&res_body_string, &err); + return Err(client::Error::JsonDecodeError(res_body_string, err)); + } + } + }; + + dlg.finished(true); + return Ok(result_value) + } + } + } + } + + + /// + /// Sets the *request* property to the given value. + /// + /// Even though the property as already been set when instantiating this call, + /// we provide this method for API completeness. + pub fn request(mut self, new_value: Playlist) -> PlaylistUpdateCall<'a, S> { + self._request = new_value; + self + } + /// The *part* parameter serves two purposes in this operation. It identifies the properties that the write operation will set as well as the properties that the API response will include. Note that this method will override the existing values for mutable properties that are contained in any parts that the request body specifies. For example, a playlist's description is contained in the snippet part, which must be included in the request body. If the request does not specify a value for the snippet.description property, the playlist's existing description will be deleted. + /// + /// Append the given value to the *part* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + /// + /// Even though the *parts* list is automatically derived from *Resource* passed in + /// during instantiation and indicates which values you are passing, the response would contain the very same parts. + /// This may not always be desirable, as you can obtain (newly generated) parts you cannot pass in, + /// like statistics that are generated server side. Therefore you should use this method to specify + /// the parts you provide in addition to the ones you want in the response. + pub fn add_part(mut self, new_value: &str) -> PlaylistUpdateCall<'a, S> { + self._part.push(new_value.to_string()); + self + } + /// *Note:* This parameter is intended exclusively for YouTube content partners. The *onBehalfOfContentOwner* parameter indicates that the request's authorization credentials identify a YouTube CMS user who is acting on behalf of the content owner specified in the parameter value. This parameter is intended for YouTube content partners that own and manage many different YouTube channels. It allows content owners to authenticate once and get access to all their video and channel data, without having to provide authentication credentials for each individual channel. The CMS account that the user authenticates with must be linked to the specified YouTube content owner. + /// + /// Sets the *on behalf of content owner* query property to the given value. + pub fn on_behalf_of_content_owner(mut self, new_value: &str) -> PlaylistUpdateCall<'a, S> { + self._on_behalf_of_content_owner = 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. + /// + /// ````text + /// It should be used to handle progress information, and to implement a certain level of resilience. + /// ```` + /// + /// Sets the *delegate* property to the given value. + pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> PlaylistUpdateCall<'a, S> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not be used to set any of the known parameters + /// which have their own setter method. If done anyway, the request will fail. + /// + /// # Additional Parameters + /// + /// * *$.xgafv* (query-string) - V1 error format. + /// * *access_token* (query-string) - OAuth access token. + /// * *alt* (query-string) - Data format for response. + /// * *callback* (query-string) - JSONP + /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. + /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. + /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. + /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. + /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. + /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). + /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). + pub fn param(mut self, name: T, value: T) -> PlaylistUpdateCall<'a, S> + where T: AsRef { + self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); + self + } + + /// Identifies the authorization scope for the method you are building. + /// + /// Use this method to actively specify which scope should be used, instead of 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: St) -> PlaylistUpdateCall<'a, S> + where St: AsRef { + self._scopes.insert(String::from(scope.as_ref())); + self + } + /// Identifies the authorization scope(s) for the method you are building. + /// + /// See [`Self::add_scope()`] for details. + pub fn add_scopes(mut self, scopes: I) -> PlaylistUpdateCall<'a, S> + where I: IntoIterator, + St: AsRef { + self._scopes + .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); + self + } + + /// Removes all scopes, and no default scope will be used either. + /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] + /// for details). + pub fn clear_scopes(mut self) -> PlaylistUpdateCall<'a, S> { + self._scopes.clear(); + self + } +} + + +/// Retrieves a list of search resources +/// +/// A builder for the *list* method supported by a *search* resource. +/// It is not used directly, but through a [`SearchMethods`] instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate hyper_rustls; +/// # extern crate google_youtube3 as youtube3; +/// # async fn dox() { +/// # use std::default::Default; +/// # use youtube3::{YouTube, oauth2, hyper, hyper_rustls, chrono, FieldMask}; +/// +/// # let secret: oauth2::ApplicationSecret = Default::default(); +/// # let auth = oauth2::InstalledFlowAuthenticator::builder( +/// # secret, +/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, +/// # ).build().await.unwrap(); +/// # let mut hub = YouTube::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().unwrap().https_or_http().enable_http1().build()), auth); +/// // You can configure optional parameters by calling the respective setters at will, and +/// // execute the final call using `doit()`. +/// // Values shown here are possibly random and not representative ! +/// let result = hub.search().list(&vec!["vero".into()]) +/// .video_type(&Default::default()) +/// .video_syndicated(&Default::default()) +/// .video_paid_product_placement(&Default::default()) +/// .video_license(&Default::default()) +/// .video_embeddable(&Default::default()) +/// .video_duration(&Default::default()) +/// .video_dimension(&Default::default()) +/// .video_definition(&Default::default()) +/// .video_category_id("duo") +/// .video_caption(&Default::default()) +/// .add_type("sadipscing") +/// .topic_id("ut") +/// .safe_search(&Default::default()) +/// .relevance_language("rebum.") +/// .region_code("duo") +/// .q("kasd") +/// .published_before(chrono::Utc::now()) +/// .published_after(chrono::Utc::now()) +/// .page_token("sadipscing") +/// .order(&Default::default()) +/// .on_behalf_of_content_owner("tempor") +/// .max_results(91) +/// .location_radius("et") +/// .location("Lorem") +/// .for_mine(true) +/// .for_developer(true) +/// .for_content_owner(false) +/// .event_type(&Default::default()) +/// .channel_type(&Default::default()) +/// .channel_id("clita") +/// .doit().await; +/// # } +/// ``` +pub struct SearchListCall<'a, S> + where S: 'a { + + pub(super) hub: &'a YouTube, + pub(super) _part: Vec, + pub(super) _video_type: Option, + pub(super) _video_syndicated: Option, + pub(super) _video_paid_product_placement: Option, + pub(super) _video_license: Option, + pub(super) _video_embeddable: Option, + pub(super) _video_duration: Option, + pub(super) _video_dimension: Option, + pub(super) _video_definition: Option, + pub(super) _video_category_id: Option, + pub(super) _video_caption: Option, + pub(super) _type_: Vec, + pub(super) _topic_id: Option, + pub(super) _safe_search: Option, + pub(super) _relevance_language: Option, + pub(super) _region_code: Option, + pub(super) _q: Option, + pub(super) _published_before: Option>, + pub(super) _published_after: Option>, + pub(super) _page_token: Option, + pub(super) _order: Option, + pub(super) _on_behalf_of_content_owner: Option, + pub(super) _max_results: Option, + pub(super) _location_radius: Option, + pub(super) _location: Option, + pub(super) _for_mine: Option, + pub(super) _for_developer: Option, + pub(super) _for_content_owner: Option, + pub(super) _event_type: Option, + pub(super) _channel_type: Option, + pub(super) _channel_id: Option, + pub(super) _delegate: Option<&'a mut dyn client::Delegate>, + pub(super) _additional_params: HashMap, + pub(super) _scopes: BTreeSet +} + +impl<'a, S> client::CallBuilder for SearchListCall<'a, S> {} + +impl<'a, S> SearchListCall<'a, S> +where + S: tower_service::Service + Clone + Send + Sync + 'static, + S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, + S::Future: Send + Unpin + 'static, + S::Error: Into>, +{ + + + /// Perform the operation you have build so far. + pub async fn doit(mut self) -> client::Result<(hyper::Response, SearchListResponse)> { + use std::io::{Read, Seek}; + use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; + use client::{ToParts, url::Params}; + use std::borrow::Cow; + + let mut dd = client::DefaultDelegate; + let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd); + dlg.begin(client::MethodInfo { id: "youtube.search.list", + http_method: hyper::Method::GET }); + + for &field in ["alt", "part", "videoType", "videoSyndicated", "videoPaidProductPlacement", "videoLicense", "videoEmbeddable", "videoDuration", "videoDimension", "videoDefinition", "videoCategoryId", "videoCaption", "type", "topicId", "safeSearch", "relevanceLanguage", "regionCode", "q", "publishedBefore", "publishedAfter", "pageToken", "order", "onBehalfOfContentOwner", "maxResults", "locationRadius", "location", "forMine", "forDeveloper", "forContentOwner", "eventType", "channelType", "channelId"].iter() { + if self._additional_params.contains_key(field) { + dlg.finished(false); + return Err(client::Error::FieldClash(field)); + } + } + + let mut params = Params::with_capacity(33 + self._additional_params.len()); + if self._part.len() > 0 { + for f in self._part.iter() { + params.push("part", f); + } + } + if let Some(value) = self._video_type.as_ref() { + params.push("videoType", value); + } + if let Some(value) = self._video_syndicated.as_ref() { + params.push("videoSyndicated", value); + } + if let Some(value) = self._video_paid_product_placement.as_ref() { + params.push("videoPaidProductPlacement", value); + } + if let Some(value) = self._video_license.as_ref() { + params.push("videoLicense", value); + } + if let Some(value) = self._video_embeddable.as_ref() { + params.push("videoEmbeddable", value); + } + if let Some(value) = self._video_duration.as_ref() { + params.push("videoDuration", value); + } + if let Some(value) = self._video_dimension.as_ref() { + params.push("videoDimension", value); + } + if let Some(value) = self._video_definition.as_ref() { + params.push("videoDefinition", value); + } + if let Some(value) = self._video_category_id.as_ref() { + params.push("videoCategoryId", value); + } + if let Some(value) = self._video_caption.as_ref() { + params.push("videoCaption", value); + } + if self._type_.len() > 0 { + for f in self._type_.iter() { + params.push("type", f); + } + } + if let Some(value) = self._topic_id.as_ref() { + params.push("topicId", value); + } + if let Some(value) = self._safe_search.as_ref() { + params.push("safeSearch", value); + } + if let Some(value) = self._relevance_language.as_ref() { + params.push("relevanceLanguage", value); + } + if let Some(value) = self._region_code.as_ref() { + params.push("regionCode", value); + } + if let Some(value) = self._q.as_ref() { + params.push("q", value); + } + if let Some(value) = self._published_before.as_ref() { + params.push("publishedBefore", ::client::serde::datetime_to_string(&value)); + } + if let Some(value) = self._published_after.as_ref() { + params.push("publishedAfter", ::client::serde::datetime_to_string(&value)); + } + if let Some(value) = self._page_token.as_ref() { + params.push("pageToken", value); + } + if let Some(value) = self._order.as_ref() { + params.push("order", value); + } + if let Some(value) = self._on_behalf_of_content_owner.as_ref() { + params.push("onBehalfOfContentOwner", value); + } + if let Some(value) = self._max_results.as_ref() { + params.push("maxResults", value.to_string()); + } + if let Some(value) = self._location_radius.as_ref() { + params.push("locationRadius", value); + } + if let Some(value) = self._location.as_ref() { + params.push("location", value); + } + if let Some(value) = self._for_mine.as_ref() { + params.push("forMine", value.to_string()); + } + if let Some(value) = self._for_developer.as_ref() { + params.push("forDeveloper", value.to_string()); + } + if let Some(value) = self._for_content_owner.as_ref() { + params.push("forContentOwner", value.to_string()); + } + if let Some(value) = self._event_type.as_ref() { + params.push("eventType", value); + } + if let Some(value) = self._channel_type.as_ref() { + params.push("channelType", value); + } + if let Some(value) = self._channel_id.as_ref() { + params.push("channelId", value); + } + + params.extend(self._additional_params.iter()); + + params.push("alt", "json"); + let mut url = self.hub._base_url.clone() + "youtube/v3/search"; + if self._scopes.is_empty() { + self._scopes.insert(Scope::Readonly.as_ref().to_string()); + } + + + let url = params.parse_with_url(&url); + + + + loop { + let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]).await { + Ok(token) => token, + Err(e) => { + match dlg.token(e) { + Ok(token) => token, + Err(e) => { + dlg.finished(false); + return Err(client::Error::MissingToken(e)); + } + } + } + }; + let mut req_result = { + let client = &self.hub.client; + dlg.pre_request(); + let mut req_builder = hyper::Request::builder() + .method(hyper::Method::GET) + .uri(url.as_str()) + .header(USER_AGENT, self.hub._user_agent.clone()); + + if let Some(token) = token.as_ref() { + req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); + } + + + let request = req_builder + .header(CONTENT_LENGTH, 0_u64) + .body(hyper::body::Body::empty()); + + client.request(request.unwrap()).await + + }; + + match req_result { + Err(err) => { + if let client::Retry::After(d) = dlg.http_error(&err) { + sleep(d).await; + continue; + } + dlg.finished(false); + return Err(client::Error::HttpError(err)) + } + Ok(mut res) => { + if !res.status().is_success() { + let res_body_string = client::get_body_as_string(res.body_mut()).await; + let (parts, _) = res.into_parts(); + let body = hyper::Body::from(res_body_string.clone()); + let restored_response = hyper::Response::from_parts(parts, body); + + let server_response = json::from_str::(&res_body_string).ok(); + + if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { + sleep(d).await; + continue; + } + + dlg.finished(false); + + return match server_response { + Some(error_value) => Err(client::Error::BadRequest(error_value)), + None => Err(client::Error::Failure(restored_response)), + } + } + let result_value = { + let res_body_string = client::get_body_as_string(res.body_mut()).await; + + match json::from_str(&res_body_string) { + Ok(decoded) => (res, decoded), + Err(err) => { + dlg.response_json_decode_error(&res_body_string, &err); + return Err(client::Error::JsonDecodeError(res_body_string, err)); + } + } + }; + + dlg.finished(true); + return Ok(result_value) + } + } + } + } + + + /// The *part* parameter specifies a comma-separated list of one or more search resource properties that the API response will include. Set the parameter value to snippet. + /// + /// Append the given value to the *part* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + /// + /// Even though the property as already been set when instantiating this call, + /// we provide this method for API completeness. + pub fn add_part(mut self, new_value: &str) -> SearchListCall<'a, S> { + self._part.push(new_value.to_string()); + self + } + /// Filter on videos of a specific type. + /// + /// Sets the *video type* query property to the given value. + pub fn video_type(mut self, new_value: &SearchVideoTypeEnum) -> SearchListCall<'a, S> { + self._video_type = Some(new_value.clone()); + self + } + /// Filter on syndicated videos. + /// + /// Sets the *video syndicated* query property to the given value. + pub fn video_syndicated(mut self, new_value: &SearchVideoSyndicatedEnum) -> SearchListCall<'a, S> { + self._video_syndicated = Some(new_value.clone()); + self + } + /// + /// Sets the *video paid product placement* query property to the given value. + pub fn video_paid_product_placement(mut self, new_value: &SearchVideoPaidProductPlacementEnum) -> SearchListCall<'a, S> { + self._video_paid_product_placement = Some(new_value.clone()); + self + } + /// Filter on the license of the videos. + /// + /// Sets the *video license* query property to the given value. + pub fn video_license(mut self, new_value: &SearchVideoLicenseEnum) -> SearchListCall<'a, S> { + self._video_license = Some(new_value.clone()); + self + } + /// Filter on embeddable videos. + /// + /// Sets the *video embeddable* query property to the given value. + pub fn video_embeddable(mut self, new_value: &SearchVideoEmbeddableEnum) -> SearchListCall<'a, S> { + self._video_embeddable = Some(new_value.clone()); + self + } + /// Filter on the duration of the videos. + /// + /// Sets the *video duration* query property to the given value. + pub fn video_duration(mut self, new_value: &SearchVideoDurationEnum) -> SearchListCall<'a, S> { + self._video_duration = Some(new_value.clone()); + self + } + /// Filter on 3d videos. + /// + /// Sets the *video dimension* query property to the given value. + pub fn video_dimension(mut self, new_value: &SearchVideoDimensionEnum) -> SearchListCall<'a, S> { + self._video_dimension = Some(new_value.clone()); + self + } + /// Filter on the definition of the videos. + /// + /// Sets the *video definition* query property to the given value. + pub fn video_definition(mut self, new_value: &SearchVideoDefinitionEnum) -> SearchListCall<'a, S> { + self._video_definition = Some(new_value.clone()); + self + } + /// Filter on videos in a specific category. + /// + /// Sets the *video category id* query property to the given value. + pub fn video_category_id(mut self, new_value: &str) -> SearchListCall<'a, S> { + self._video_category_id = Some(new_value.to_string()); + self + } + /// Filter on the presence of captions on the videos. + /// + /// Sets the *video caption* query property to the given value. + pub fn video_caption(mut self, new_value: &SearchVideoCaptionEnum) -> SearchListCall<'a, S> { + self._video_caption = Some(new_value.clone()); + self + } + /// Restrict results to a particular set of resource types from One Platform. + /// + /// 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) -> SearchListCall<'a, S> { + self._type_.push(new_value.to_string()); + self + } + /// Restrict results to a particular topic. + /// + /// Sets the *topic id* query property to the given value. + pub fn topic_id(mut self, new_value: &str) -> SearchListCall<'a, S> { + self._topic_id = Some(new_value.to_string()); + self + } + /// Indicates whether the search results should include restricted content as well as standard content. + /// + /// Sets the *safe search* query property to the given value. + pub fn safe_search(mut self, new_value: &SearchSafeSearchEnum) -> SearchListCall<'a, S> { + self._safe_search = Some(new_value.clone()); + self + } + /// Return results relevant to this language. + /// + /// Sets the *relevance language* query property to the given value. + pub fn relevance_language(mut self, new_value: &str) -> SearchListCall<'a, S> { + self._relevance_language = Some(new_value.to_string()); + self + } + /// Display the content as seen by viewers in this country. + /// + /// Sets the *region code* query property to the given value. + pub fn region_code(mut self, new_value: &str) -> SearchListCall<'a, S> { + self._region_code = Some(new_value.to_string()); + self + } + /// Textual search terms to match. + /// + /// Sets the *q* query property to the given value. + pub fn q(mut self, new_value: &str) -> SearchListCall<'a, S> { + self._q = Some(new_value.to_string()); + self + } + /// Filter on resources published before this date. + /// + /// Sets the *published before* query property to the given value. + pub fn published_before(mut self, new_value: client::chrono::DateTime) -> SearchListCall<'a, S> { + self._published_before = Some(new_value); + self + } + /// Filter on resources published after this date. + /// + /// Sets the *published after* query property to the given value. + pub fn published_after(mut self, new_value: client::chrono::DateTime) -> SearchListCall<'a, S> { + self._published_after = Some(new_value); + self + } + /// The *pageToken* parameter identifies a specific page in the result set that should be returned. In an API response, the nextPageToken and prevPageToken properties identify other pages that could be retrieved. + /// + /// Sets the *page token* query property to the given value. + pub fn page_token(mut self, new_value: &str) -> SearchListCall<'a, S> { + self._page_token = Some(new_value.to_string()); + self + } + /// Sort order of the results. + /// + /// Sets the *order* query property to the given value. + pub fn order(mut self, new_value: &SearchOrderEnum) -> SearchListCall<'a, S> { + self._order = Some(new_value.clone()); + self + } + /// *Note:* This parameter is intended exclusively for YouTube content partners. The *onBehalfOfContentOwner* parameter indicates that the request's authorization credentials identify a YouTube CMS user who is acting on behalf of the content owner specified in the parameter value. This parameter is intended for YouTube content partners that own and manage many different YouTube channels. It allows content owners to authenticate once and get access to all their video and channel data, without having to provide authentication credentials for each individual channel. The CMS account that the user authenticates with must be linked to the specified YouTube content owner. + /// + /// Sets the *on behalf of content owner* query property to the given value. + pub fn on_behalf_of_content_owner(mut self, new_value: &str) -> SearchListCall<'a, S> { + self._on_behalf_of_content_owner = Some(new_value.to_string()); + self + } + /// The *maxResults* parameter specifies the maximum number of items that should be returned in the result set. + /// + /// Sets the *max results* query property to the given value. + pub fn max_results(mut self, new_value: u32) -> SearchListCall<'a, S> { + self._max_results = Some(new_value); + self + } + /// Filter on distance from the location (specified above). + /// + /// Sets the *location radius* query property to the given value. + pub fn location_radius(mut self, new_value: &str) -> SearchListCall<'a, S> { + self._location_radius = Some(new_value.to_string()); + self + } + /// Filter on location of the video + /// + /// Sets the *location* query property to the given value. + pub fn location(mut self, new_value: &str) -> SearchListCall<'a, S> { + self._location = Some(new_value.to_string()); + self + } + /// Search for the private videos of the authenticated user. + /// + /// Sets the *for mine* query property to the given value. + pub fn for_mine(mut self, new_value: bool) -> SearchListCall<'a, S> { + self._for_mine = Some(new_value); + self + } + /// Restrict the search to only retrieve videos uploaded using the project id of the authenticated user. + /// + /// Sets the *for developer* query property to the given value. + pub fn for_developer(mut self, new_value: bool) -> SearchListCall<'a, S> { + self._for_developer = Some(new_value); + self + } + /// Search owned by a content owner. + /// + /// Sets the *for content owner* query property to the given value. + pub fn for_content_owner(mut self, new_value: bool) -> SearchListCall<'a, S> { + self._for_content_owner = Some(new_value); + self + } + /// Filter on the livestream status of the videos. + /// + /// Sets the *event type* query property to the given value. + pub fn event_type(mut self, new_value: &SearchEventTypeEnum) -> SearchListCall<'a, S> { + self._event_type = Some(new_value.clone()); + self + } + /// Add a filter on the channel search. + /// + /// Sets the *channel type* query property to the given value. + pub fn channel_type(mut self, new_value: &SearchChannelTypeEnum) -> SearchListCall<'a, S> { + self._channel_type = Some(new_value.clone()); + self + } + /// Filter on resources belonging to this channelId. + /// + /// Sets the *channel id* query property to the given value. + pub fn channel_id(mut self, new_value: &str) -> SearchListCall<'a, S> { + self._channel_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. + /// + /// ````text + /// It should be used to handle progress information, and to implement a certain level of resilience. + /// ```` + /// + /// Sets the *delegate* property to the given value. + pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> SearchListCall<'a, S> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not be used to set any of the known parameters + /// which have their own setter method. If done anyway, the request will fail. + /// + /// # Additional Parameters + /// + /// * *$.xgafv* (query-string) - V1 error format. + /// * *access_token* (query-string) - OAuth access token. + /// * *alt* (query-string) - Data format for response. + /// * *callback* (query-string) - JSONP + /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. + /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. + /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. + /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. + /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. + /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). + /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). + pub fn param(mut self, name: T, value: T) -> SearchListCall<'a, S> + where T: AsRef { + self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); + self + } + + /// Identifies the authorization scope for the method you are building. + /// + /// Use this method to actively specify which scope should be used, instead of 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: St) -> SearchListCall<'a, S> + where St: AsRef { + self._scopes.insert(String::from(scope.as_ref())); + self + } + /// Identifies the authorization scope(s) for the method you are building. + /// + /// See [`Self::add_scope()`] for details. + pub fn add_scopes(mut self, scopes: I) -> SearchListCall<'a, S> + where I: IntoIterator, + St: AsRef { + self._scopes + .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); + self + } + + /// Removes all scopes, and no default scope will be used either. + /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] + /// for details). + pub fn clear_scopes(mut self) -> SearchListCall<'a, S> { + self._scopes.clear(); + self + } +} + + +/// Deletes a resource. +/// +/// A builder for the *delete* method supported by a *subscription* resource. +/// It is not used directly, but through a [`SubscriptionMethods`] instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate hyper_rustls; +/// # extern crate google_youtube3 as youtube3; +/// # async fn dox() { +/// # use std::default::Default; +/// # use youtube3::{YouTube, oauth2, hyper, hyper_rustls, chrono, FieldMask}; +/// +/// # let secret: oauth2::ApplicationSecret = Default::default(); +/// # let auth = oauth2::InstalledFlowAuthenticator::builder( +/// # secret, +/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, +/// # ).build().await.unwrap(); +/// # let mut hub = YouTube::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().unwrap().https_or_http().enable_http1().build()), auth); +/// // You can configure optional parameters by calling the respective setters at will, and +/// // execute the final call using `doit()`. +/// // Values shown here are possibly random and not representative ! +/// let result = hub.subscriptions().delete("id") +/// .doit().await; +/// # } +/// ``` +pub struct SubscriptionDeleteCall<'a, S> + where S: 'a { + + pub(super) hub: &'a YouTube, + pub(super) _id: String, + pub(super) _delegate: Option<&'a mut dyn client::Delegate>, + pub(super) _additional_params: HashMap, + pub(super) _scopes: BTreeSet +} + +impl<'a, S> client::CallBuilder for SubscriptionDeleteCall<'a, S> {} + +impl<'a, S> SubscriptionDeleteCall<'a, S> +where + S: tower_service::Service + Clone + Send + Sync + 'static, + S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, + S::Future: Send + Unpin + 'static, + S::Error: Into>, +{ + + + /// Perform the operation you have build so far. + pub async fn doit(mut self) -> client::Result> { + use std::io::{Read, Seek}; + use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; + use client::{ToParts, url::Params}; + use std::borrow::Cow; + + let mut dd = client::DefaultDelegate; + let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd); + dlg.begin(client::MethodInfo { id: "youtube.subscriptions.delete", + http_method: hyper::Method::DELETE }); + + for &field in ["id"].iter() { + if self._additional_params.contains_key(field) { + dlg.finished(false); + return Err(client::Error::FieldClash(field)); + } + } + + let mut params = Params::with_capacity(2 + self._additional_params.len()); + params.push("id", &self._id); + + params.extend(self._additional_params.iter()); + + let mut url = self.hub._base_url.clone() + "youtube/v3/subscriptions"; + if self._scopes.is_empty() { + self._scopes.insert(Scope::Full.as_ref().to_string()); + } + + + let url = params.parse_with_url(&url); + + + + loop { + let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]).await { + Ok(token) => token, + Err(e) => { + match dlg.token(e) { + Ok(token) => token, + Err(e) => { + dlg.finished(false); + return Err(client::Error::MissingToken(e)); + } + } + } + }; + let mut req_result = { + let client = &self.hub.client; + dlg.pre_request(); + let mut req_builder = hyper::Request::builder() + .method(hyper::Method::DELETE) + .uri(url.as_str()) + .header(USER_AGENT, self.hub._user_agent.clone()); + + if let Some(token) = token.as_ref() { + req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); + } + + + let request = req_builder + .header(CONTENT_LENGTH, 0_u64) + .body(hyper::body::Body::empty()); + + client.request(request.unwrap()).await + + }; + + match req_result { + Err(err) => { + if let client::Retry::After(d) = dlg.http_error(&err) { + sleep(d).await; + continue; + } + dlg.finished(false); + return Err(client::Error::HttpError(err)) + } + Ok(mut res) => { + if !res.status().is_success() { + let res_body_string = client::get_body_as_string(res.body_mut()).await; + let (parts, _) = res.into_parts(); + let body = hyper::Body::from(res_body_string.clone()); + let restored_response = hyper::Response::from_parts(parts, body); + + let server_response = json::from_str::(&res_body_string).ok(); + + if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { + sleep(d).await; + continue; + } + + dlg.finished(false); + + return match server_response { + Some(error_value) => Err(client::Error::BadRequest(error_value)), + None => Err(client::Error::Failure(restored_response)), + } + } + let result_value = res; + + dlg.finished(true); + return Ok(result_value) + } + } + } + } + + + /// + /// 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) -> SubscriptionDeleteCall<'a, S> { + 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. + /// + /// ````text + /// It should be used to handle progress information, and to implement a certain level of resilience. + /// ```` + /// + /// Sets the *delegate* property to the given value. + pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> SubscriptionDeleteCall<'a, S> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not be used to set any of the known parameters + /// which have their own setter method. If done anyway, the request will fail. + /// + /// # Additional Parameters + /// + /// * *$.xgafv* (query-string) - V1 error format. + /// * *access_token* (query-string) - OAuth access token. + /// * *alt* (query-string) - Data format for response. + /// * *callback* (query-string) - JSONP + /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. + /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. + /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. + /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. + /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. + /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). + /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). + pub fn param(mut self, name: T, value: T) -> SubscriptionDeleteCall<'a, S> + where T: AsRef { + self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); + self + } + + /// Identifies the authorization scope for the method you are building. + /// + /// Use this method to actively specify which scope should be used, instead of 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: St) -> SubscriptionDeleteCall<'a, S> + where St: AsRef { + self._scopes.insert(String::from(scope.as_ref())); + self + } + /// Identifies the authorization scope(s) for the method you are building. + /// + /// See [`Self::add_scope()`] for details. + pub fn add_scopes(mut self, scopes: I) -> SubscriptionDeleteCall<'a, S> + where I: IntoIterator, + St: AsRef { + self._scopes + .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); + self + } + + /// Removes all scopes, and no default scope will be used either. + /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] + /// for details). + pub fn clear_scopes(mut self) -> SubscriptionDeleteCall<'a, S> { + self._scopes.clear(); + self + } +} + + +/// Inserts a new resource into this collection. +/// +/// A builder for the *insert* method supported by a *subscription* resource. +/// It is not used directly, but through a [`SubscriptionMethods`] instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate hyper_rustls; +/// # extern crate google_youtube3 as youtube3; +/// use youtube3::api::Subscription; +/// # async fn dox() { +/// # use std::default::Default; +/// # use youtube3::{YouTube, oauth2, hyper, hyper_rustls, chrono, FieldMask}; +/// +/// # let secret: oauth2::ApplicationSecret = Default::default(); +/// # let auth = oauth2::InstalledFlowAuthenticator::builder( +/// # secret, +/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, +/// # ).build().await.unwrap(); +/// # let mut hub = YouTube::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().unwrap().https_or_http().enable_http1().build()), auth); +/// // As the method needs a request, you would usually fill it with the desired information +/// // into the respective structure. Some of the parts shown here might not be applicable ! +/// // Values shown here are possibly random and not representative ! +/// let mut req = Subscription::default(); +/// +/// // You can configure optional parameters by calling the respective setters at will, and +/// // execute the final call using `doit()`. +/// // Values shown here are possibly random and not representative ! +/// let result = hub.subscriptions().insert(req) +/// .doit().await; +/// # } +/// ``` +pub struct SubscriptionInsertCall<'a, S> + where S: 'a { + + pub(super) hub: &'a YouTube, + pub(super) _request: Subscription, + pub(super) _part: Vec, + pub(super) _delegate: Option<&'a mut dyn client::Delegate>, + pub(super) _additional_params: HashMap, + pub(super) _scopes: BTreeSet +} + +impl<'a, S> client::CallBuilder for SubscriptionInsertCall<'a, S> {} + +impl<'a, S> SubscriptionInsertCall<'a, S> +where + S: tower_service::Service + Clone + Send + Sync + 'static, + S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, + S::Future: Send + Unpin + 'static, + S::Error: Into>, +{ + + + /// Perform the operation you have build so far. + pub async fn doit(mut self) -> client::Result<(hyper::Response, Subscription)> { + use std::io::{Read, Seek}; + use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; + use client::{ToParts, url::Params}; + use std::borrow::Cow; + + let mut dd = client::DefaultDelegate; + let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd); + dlg.begin(client::MethodInfo { id: "youtube.subscriptions.insert", + http_method: hyper::Method::POST }); + + for &field in ["alt", "part"].iter() { + if self._additional_params.contains_key(field) { + dlg.finished(false); + return Err(client::Error::FieldClash(field)); + } + } + + let mut params = Params::with_capacity(4 + self._additional_params.len()); + if self._part.is_empty() { + self._part.push(self._request.to_parts()); + } + if self._part.len() > 0 { + for f in self._part.iter() { + params.push("part", f); + } + } + + params.extend(self._additional_params.iter()); + + params.push("alt", "json"); + let mut url = self.hub._base_url.clone() + "youtube/v3/subscriptions"; + if self._scopes.is_empty() { + self._scopes.insert(Scope::Full.as_ref().to_string()); + } + + + let url = params.parse_with_url(&url); + + let mut json_mime_type = mime::APPLICATION_JSON; + let mut request_value_reader = + { + let mut value = json::value::to_value(&self._request).expect("serde to work"); + client::remove_json_null_values(&mut value); + let mut dst = io::Cursor::new(Vec::with_capacity(128)); + json::to_writer(&mut dst, &value).unwrap(); + dst + }; + let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); + request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); + + + loop { + let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]).await { + Ok(token) => token, + Err(e) => { + match dlg.token(e) { + Ok(token) => token, + Err(e) => { + dlg.finished(false); + return Err(client::Error::MissingToken(e)); + } + } + } + }; + request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); + let mut req_result = { + let client = &self.hub.client; + dlg.pre_request(); + let mut req_builder = hyper::Request::builder() + .method(hyper::Method::POST) + .uri(url.as_str()) + .header(USER_AGENT, self.hub._user_agent.clone()); + + if let Some(token) = token.as_ref() { + req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); + } + + + let request = req_builder + .header(CONTENT_TYPE, json_mime_type.to_string()) + .header(CONTENT_LENGTH, request_size as u64) + .body(hyper::body::Body::from(request_value_reader.get_ref().clone())); + + client.request(request.unwrap()).await + + }; + + match req_result { + Err(err) => { + if let client::Retry::After(d) = dlg.http_error(&err) { + sleep(d).await; + continue; + } + dlg.finished(false); + return Err(client::Error::HttpError(err)) + } + Ok(mut res) => { + if !res.status().is_success() { + let res_body_string = client::get_body_as_string(res.body_mut()).await; + let (parts, _) = res.into_parts(); + let body = hyper::Body::from(res_body_string.clone()); + let restored_response = hyper::Response::from_parts(parts, body); + + let server_response = json::from_str::(&res_body_string).ok(); + + if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { + sleep(d).await; + continue; + } + + dlg.finished(false); + + return match server_response { + Some(error_value) => Err(client::Error::BadRequest(error_value)), + None => Err(client::Error::Failure(restored_response)), + } + } + let result_value = { + let res_body_string = client::get_body_as_string(res.body_mut()).await; + + match json::from_str(&res_body_string) { + Ok(decoded) => (res, decoded), + Err(err) => { + dlg.response_json_decode_error(&res_body_string, &err); + return Err(client::Error::JsonDecodeError(res_body_string, err)); + } + } + }; + + dlg.finished(true); + return Ok(result_value) + } + } + } + } + + + /// + /// Sets the *request* property to the given value. + /// + /// Even though the property as already been set when instantiating this call, + /// we provide this method for API completeness. + pub fn request(mut self, new_value: Subscription) -> SubscriptionInsertCall<'a, S> { + self._request = new_value; + self + } + /// The *part* parameter serves two purposes in this operation. It identifies the properties that the write operation will set as well as the properties that the API response will include. + /// + /// Append the given value to the *part* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + /// + /// Even though the *parts* list is automatically derived from *Resource* passed in + /// during instantiation and indicates which values you are passing, the response would contain the very same parts. + /// This may not always be desirable, as you can obtain (newly generated) parts you cannot pass in, + /// like statistics that are generated server side. Therefore you should use this method to specify + /// the parts you provide in addition to the ones you want in the response. + pub fn add_part(mut self, new_value: &str) -> SubscriptionInsertCall<'a, S> { + self._part.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. + /// + /// ````text + /// It should be used to handle progress information, and to implement a certain level of resilience. + /// ```` + /// + /// Sets the *delegate* property to the given value. + pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> SubscriptionInsertCall<'a, S> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not be used to set any of the known parameters + /// which have their own setter method. If done anyway, the request will fail. + /// + /// # Additional Parameters + /// + /// * *$.xgafv* (query-string) - V1 error format. + /// * *access_token* (query-string) - OAuth access token. + /// * *alt* (query-string) - Data format for response. + /// * *callback* (query-string) - JSONP + /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. + /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. + /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. + /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. + /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. + /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). + /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). + pub fn param(mut self, name: T, value: T) -> SubscriptionInsertCall<'a, S> + where T: AsRef { + self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); + self + } + + /// Identifies the authorization scope for the method you are building. + /// + /// Use this method to actively specify which scope should be used, instead of 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: St) -> SubscriptionInsertCall<'a, S> + where St: AsRef { + self._scopes.insert(String::from(scope.as_ref())); + self + } + /// Identifies the authorization scope(s) for the method you are building. + /// + /// See [`Self::add_scope()`] for details. + pub fn add_scopes(mut self, scopes: I) -> SubscriptionInsertCall<'a, S> + where I: IntoIterator, + St: AsRef { + self._scopes + .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); + self + } + + /// Removes all scopes, and no default scope will be used either. + /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] + /// for details). + pub fn clear_scopes(mut self) -> SubscriptionInsertCall<'a, S> { + self._scopes.clear(); + self + } +} + + +/// Retrieves a list of resources, possibly filtered. +/// +/// A builder for the *list* method supported by a *subscription* resource. +/// It is not used directly, but through a [`SubscriptionMethods`] instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate hyper_rustls; +/// # extern crate google_youtube3 as youtube3; +/// # async fn dox() { +/// # use std::default::Default; +/// # use youtube3::{YouTube, oauth2, hyper, hyper_rustls, chrono, FieldMask}; +/// +/// # let secret: oauth2::ApplicationSecret = Default::default(); +/// # let auth = oauth2::InstalledFlowAuthenticator::builder( +/// # secret, +/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, +/// # ).build().await.unwrap(); +/// # let mut hub = YouTube::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().unwrap().https_or_http().enable_http1().build()), auth); +/// // You can configure optional parameters by calling the respective setters at will, and +/// // execute the final call using `doit()`. +/// // Values shown here are possibly random and not representative ! +/// let result = hub.subscriptions().list(&vec!["aliquyam".into()]) +/// .page_token("ut") +/// .order(&Default::default()) +/// .on_behalf_of_content_owner_channel("sit") +/// .on_behalf_of_content_owner("vero") +/// .my_subscribers(false) +/// .my_recent_subscribers(true) +/// .mine(true) +/// .max_results(2) +/// .add_id("aliquyam") +/// .for_channel_id("magna") +/// .channel_id("diam") +/// .doit().await; +/// # } +/// ``` +pub struct SubscriptionListCall<'a, S> + where S: 'a { + + pub(super) hub: &'a YouTube, + pub(super) _part: Vec, + pub(super) _page_token: Option, + pub(super) _order: Option, + pub(super) _on_behalf_of_content_owner_channel: Option, + pub(super) _on_behalf_of_content_owner: Option, + pub(super) _my_subscribers: Option, + pub(super) _my_recent_subscribers: Option, + pub(super) _mine: Option, + pub(super) _max_results: Option, + pub(super) _id: Vec, + pub(super) _for_channel_id: Option, + pub(super) _channel_id: Option, + pub(super) _delegate: Option<&'a mut dyn client::Delegate>, + pub(super) _additional_params: HashMap, + pub(super) _scopes: BTreeSet +} + +impl<'a, S> client::CallBuilder for SubscriptionListCall<'a, S> {} + +impl<'a, S> SubscriptionListCall<'a, S> +where + S: tower_service::Service + Clone + Send + Sync + 'static, + S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, + S::Future: Send + Unpin + 'static, + S::Error: Into>, +{ + + + /// Perform the operation you have build so far. + pub async fn doit(mut self) -> client::Result<(hyper::Response, SubscriptionListResponse)> { + use std::io::{Read, Seek}; + use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; + use client::{ToParts, url::Params}; + use std::borrow::Cow; + + let mut dd = client::DefaultDelegate; + let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd); + dlg.begin(client::MethodInfo { id: "youtube.subscriptions.list", + http_method: hyper::Method::GET }); + + 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(client::Error::FieldClash(field)); + } + } + + let mut params = Params::with_capacity(14 + self._additional_params.len()); + if self._part.len() > 0 { + for f in self._part.iter() { + params.push("part", f); + } + } + if let Some(value) = self._page_token.as_ref() { + params.push("pageToken", value); + } + if let Some(value) = self._order.as_ref() { + params.push("order", value); + } + if let Some(value) = self._on_behalf_of_content_owner_channel.as_ref() { + params.push("onBehalfOfContentOwnerChannel", value); + } + if let Some(value) = self._on_behalf_of_content_owner.as_ref() { + params.push("onBehalfOfContentOwner", value); + } + if let Some(value) = self._my_subscribers.as_ref() { + params.push("mySubscribers", value.to_string()); + } + if let Some(value) = self._my_recent_subscribers.as_ref() { + params.push("myRecentSubscribers", value.to_string()); + } + if let Some(value) = self._mine.as_ref() { + params.push("mine", value.to_string()); + } + if let Some(value) = self._max_results.as_ref() { + params.push("maxResults", value.to_string()); + } + if self._id.len() > 0 { + for f in self._id.iter() { + params.push("id", f); + } + } + if let Some(value) = self._for_channel_id.as_ref() { + params.push("forChannelId", value); + } + if let Some(value) = self._channel_id.as_ref() { + params.push("channelId", value); + } + + params.extend(self._additional_params.iter()); + + params.push("alt", "json"); + let mut url = self.hub._base_url.clone() + "youtube/v3/subscriptions"; + if self._scopes.is_empty() { + self._scopes.insert(Scope::Readonly.as_ref().to_string()); + } + + + let url = params.parse_with_url(&url); + + + + loop { + let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]).await { + Ok(token) => token, + Err(e) => { + match dlg.token(e) { + Ok(token) => token, + Err(e) => { + dlg.finished(false); + return Err(client::Error::MissingToken(e)); + } + } + } + }; + let mut req_result = { + let client = &self.hub.client; + dlg.pre_request(); + let mut req_builder = hyper::Request::builder() + .method(hyper::Method::GET) + .uri(url.as_str()) + .header(USER_AGENT, self.hub._user_agent.clone()); + + if let Some(token) = token.as_ref() { + req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); + } + + + let request = req_builder + .header(CONTENT_LENGTH, 0_u64) + .body(hyper::body::Body::empty()); + + client.request(request.unwrap()).await + + }; + + match req_result { + Err(err) => { + if let client::Retry::After(d) = dlg.http_error(&err) { + sleep(d).await; + continue; + } + dlg.finished(false); + return Err(client::Error::HttpError(err)) + } + Ok(mut res) => { + if !res.status().is_success() { + let res_body_string = client::get_body_as_string(res.body_mut()).await; + let (parts, _) = res.into_parts(); + let body = hyper::Body::from(res_body_string.clone()); + let restored_response = hyper::Response::from_parts(parts, body); + + let server_response = json::from_str::(&res_body_string).ok(); + + if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { + sleep(d).await; + continue; + } + + dlg.finished(false); + + return match server_response { + Some(error_value) => Err(client::Error::BadRequest(error_value)), + None => Err(client::Error::Failure(restored_response)), + } + } + let result_value = { + let res_body_string = client::get_body_as_string(res.body_mut()).await; + + match json::from_str(&res_body_string) { + Ok(decoded) => (res, decoded), + Err(err) => { + dlg.response_json_decode_error(&res_body_string, &err); + return Err(client::Error::JsonDecodeError(res_body_string, err)); + } + } + }; + + dlg.finished(true); + return Ok(result_value) + } + } + } + } + + + /// The *part* parameter specifies a comma-separated list of one or more subscription resource properties that the API response will include. If the parameter identifies a property that contains child properties, the child properties will be included in the response. For example, in a subscription resource, the snippet property contains other properties, such as a display title for the subscription. If you set *part=snippet*, the API response will also contain all of those nested properties. + /// + /// Append the given value to the *part* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + /// + /// Even though the property as already been set when instantiating this call, + /// we provide this method for API completeness. + pub fn add_part(mut self, new_value: &str) -> SubscriptionListCall<'a, S> { + self._part.push(new_value.to_string()); + self + } + /// The *pageToken* parameter identifies a specific page in the result set that should be returned. In an API response, the nextPageToken and prevPageToken properties identify other pages that could be retrieved. + /// + /// Sets the *page token* query property to the given value. + pub fn page_token(mut self, new_value: &str) -> SubscriptionListCall<'a, S> { + self._page_token = Some(new_value.to_string()); + self + } + /// The order of the returned subscriptions + /// + /// Sets the *order* query property to the given value. + pub fn order(mut self, new_value: &SubscriptionOrderEnum) -> SubscriptionListCall<'a, S> { + self._order = Some(new_value.clone()); + self + } + /// This parameter can only be used in a properly authorized request. *Note:* This parameter is intended exclusively for YouTube content partners. The *onBehalfOfContentOwnerChannel* parameter specifies the YouTube channel ID of the channel to which a video is being added. This parameter is required when a request specifies a value for the onBehalfOfContentOwner parameter, and it can only be used in conjunction with that parameter. In addition, the request must be authorized using a CMS account that is linked to the content owner that the onBehalfOfContentOwner parameter specifies. Finally, the channel that the onBehalfOfContentOwnerChannel parameter value specifies must be linked to the content owner that the onBehalfOfContentOwner parameter specifies. This parameter is intended for YouTube content partners that own and manage many different YouTube channels. It allows content owners to authenticate once and perform actions on behalf of the channel specified in the parameter value, without having to provide authentication credentials for each separate channel. + /// + /// Sets the *on behalf of content owner channel* query property to the given value. + pub fn on_behalf_of_content_owner_channel(mut self, new_value: &str) -> SubscriptionListCall<'a, S> { + self._on_behalf_of_content_owner_channel = Some(new_value.to_string()); + self + } + /// *Note:* This parameter is intended exclusively for YouTube content partners. The *onBehalfOfContentOwner* parameter indicates that the request's authorization credentials identify a YouTube CMS user who is acting on behalf of the content owner specified in the parameter value. This parameter is intended for YouTube content partners that own and manage many different YouTube channels. It allows content owners to authenticate once and get access to all their video and channel data, without having to provide authentication credentials for each individual channel. The CMS account that the user authenticates with must be linked to the specified YouTube content owner. + /// + /// Sets the *on behalf of content owner* query property to the given value. + pub fn on_behalf_of_content_owner(mut self, new_value: &str) -> SubscriptionListCall<'a, S> { + self._on_behalf_of_content_owner = Some(new_value.to_string()); + self + } + /// Return the subscribers of the given channel owner. + /// + /// Sets the *my subscribers* query property to the given value. + pub fn my_subscribers(mut self, new_value: bool) -> SubscriptionListCall<'a, S> { + self._my_subscribers = Some(new_value); + self + } + /// + /// Sets the *my recent subscribers* query property to the given value. + pub fn my_recent_subscribers(mut self, new_value: bool) -> SubscriptionListCall<'a, S> { + self._my_recent_subscribers = Some(new_value); + self + } + /// Flag for returning the subscriptions of the authenticated user. + /// + /// Sets the *mine* query property to the given value. + pub fn mine(mut self, new_value: bool) -> SubscriptionListCall<'a, S> { + self._mine = Some(new_value); + self + } + /// The *maxResults* parameter specifies the maximum number of items that should be returned in the result set. + /// + /// Sets the *max results* query property to the given value. + pub fn max_results(mut self, new_value: u32) -> SubscriptionListCall<'a, S> { + self._max_results = Some(new_value); + self + } + /// Return the subscriptions with the given IDs for Stubby or Apiary. + /// + /// Append the given value to the *id* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + pub fn add_id(mut self, new_value: &str) -> SubscriptionListCall<'a, S> { + self._id.push(new_value.to_string()); + self + } + /// Return the subscriptions to the subset of these channels that the authenticated user is subscribed to. + /// + /// Sets the *for channel id* query property to the given value. + pub fn for_channel_id(mut self, new_value: &str) -> SubscriptionListCall<'a, S> { + self._for_channel_id = Some(new_value.to_string()); + self + } + /// Return the subscriptions of the given channel owner. + /// + /// Sets the *channel id* query property to the given value. + pub fn channel_id(mut self, new_value: &str) -> SubscriptionListCall<'a, S> { + self._channel_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. + /// + /// ````text + /// It should be used to handle progress information, and to implement a certain level of resilience. + /// ```` + /// + /// Sets the *delegate* property to the given value. + pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> SubscriptionListCall<'a, S> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not be used to set any of the known parameters + /// which have their own setter method. If done anyway, the request will fail. + /// + /// # Additional Parameters + /// + /// * *$.xgafv* (query-string) - V1 error format. + /// * *access_token* (query-string) - OAuth access token. + /// * *alt* (query-string) - Data format for response. + /// * *callback* (query-string) - JSONP + /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. + /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. + /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. + /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. + /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. + /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). + /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). + pub fn param(mut self, name: T, value: T) -> SubscriptionListCall<'a, S> + where T: AsRef { + self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); + self + } + + /// Identifies the authorization scope for the method you are building. + /// + /// Use this method to actively specify which scope should be used, instead of 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: St) -> SubscriptionListCall<'a, S> + where St: AsRef { + self._scopes.insert(String::from(scope.as_ref())); + self + } + /// Identifies the authorization scope(s) for the method you are building. + /// + /// See [`Self::add_scope()`] for details. + pub fn add_scopes(mut self, scopes: I) -> SubscriptionListCall<'a, S> + where I: IntoIterator, + St: AsRef { + self._scopes + .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); + self + } + + /// Removes all scopes, and no default scope will be used either. + /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] + /// for details). + pub fn clear_scopes(mut self) -> SubscriptionListCall<'a, S> { + self._scopes.clear(); + self + } +} + + +/// Retrieves a list of resources, possibly filtered. +/// +/// A builder for the *list* method supported by a *superChatEvent* resource. +/// It is not used directly, but through a [`SuperChatEventMethods`] instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate hyper_rustls; +/// # extern crate google_youtube3 as youtube3; +/// # async fn dox() { +/// # use std::default::Default; +/// # use youtube3::{YouTube, oauth2, hyper, hyper_rustls, chrono, FieldMask}; +/// +/// # let secret: oauth2::ApplicationSecret = Default::default(); +/// # let auth = oauth2::InstalledFlowAuthenticator::builder( +/// # secret, +/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, +/// # ).build().await.unwrap(); +/// # let mut hub = YouTube::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().unwrap().https_or_http().enable_http1().build()), auth); +/// // You can configure optional parameters by calling the respective setters at will, and +/// // execute the final call using `doit()`. +/// // Values shown here are possibly random and not representative ! +/// let result = hub.super_chat_events().list(&vec!["nonumy".into()]) +/// .page_token("et") +/// .max_results(93) +/// .hl("accusam") +/// .doit().await; +/// # } +/// ``` +pub struct SuperChatEventListCall<'a, S> + where S: 'a { + + pub(super) hub: &'a YouTube, + pub(super) _part: Vec, + pub(super) _page_token: Option, + pub(super) _max_results: Option, + pub(super) _hl: Option, + pub(super) _delegate: Option<&'a mut dyn client::Delegate>, + pub(super) _additional_params: HashMap, + pub(super) _scopes: BTreeSet +} + +impl<'a, S> client::CallBuilder for SuperChatEventListCall<'a, S> {} + +impl<'a, S> SuperChatEventListCall<'a, S> +where + S: tower_service::Service + Clone + Send + Sync + 'static, + S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, + S::Future: Send + Unpin + 'static, + S::Error: Into>, +{ + + + /// Perform the operation you have build so far. + pub async fn doit(mut self) -> client::Result<(hyper::Response, SuperChatEventListResponse)> { + use std::io::{Read, Seek}; + use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; + use client::{ToParts, url::Params}; + use std::borrow::Cow; + + let mut dd = client::DefaultDelegate; + let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd); + dlg.begin(client::MethodInfo { id: "youtube.superChatEvents.list", + http_method: hyper::Method::GET }); + + for &field in ["alt", "part", "pageToken", "maxResults", "hl"].iter() { + if self._additional_params.contains_key(field) { + dlg.finished(false); + return Err(client::Error::FieldClash(field)); + } + } + + let mut params = Params::with_capacity(6 + self._additional_params.len()); + if self._part.len() > 0 { + for f in self._part.iter() { + params.push("part", f); + } + } + if let Some(value) = self._page_token.as_ref() { + params.push("pageToken", value); + } + if let Some(value) = self._max_results.as_ref() { + params.push("maxResults", value.to_string()); + } + if let Some(value) = self._hl.as_ref() { + params.push("hl", value); + } + + params.extend(self._additional_params.iter()); + + params.push("alt", "json"); + let mut url = self.hub._base_url.clone() + "youtube/v3/superChatEvents"; + if self._scopes.is_empty() { + self._scopes.insert(Scope::Readonly.as_ref().to_string()); + } + + + let url = params.parse_with_url(&url); + + + + loop { + let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]).await { + Ok(token) => token, + Err(e) => { + match dlg.token(e) { + Ok(token) => token, + Err(e) => { + dlg.finished(false); + return Err(client::Error::MissingToken(e)); + } + } + } + }; + let mut req_result = { + let client = &self.hub.client; + dlg.pre_request(); + let mut req_builder = hyper::Request::builder() + .method(hyper::Method::GET) + .uri(url.as_str()) + .header(USER_AGENT, self.hub._user_agent.clone()); + + if let Some(token) = token.as_ref() { + req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); + } + + + let request = req_builder + .header(CONTENT_LENGTH, 0_u64) + .body(hyper::body::Body::empty()); + + client.request(request.unwrap()).await + + }; + + match req_result { + Err(err) => { + if let client::Retry::After(d) = dlg.http_error(&err) { + sleep(d).await; + continue; + } + dlg.finished(false); + return Err(client::Error::HttpError(err)) + } + Ok(mut res) => { + if !res.status().is_success() { + let res_body_string = client::get_body_as_string(res.body_mut()).await; + let (parts, _) = res.into_parts(); + let body = hyper::Body::from(res_body_string.clone()); + let restored_response = hyper::Response::from_parts(parts, body); + + let server_response = json::from_str::(&res_body_string).ok(); + + if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { + sleep(d).await; + continue; + } + + dlg.finished(false); + + return match server_response { + Some(error_value) => Err(client::Error::BadRequest(error_value)), + None => Err(client::Error::Failure(restored_response)), + } + } + let result_value = { + let res_body_string = client::get_body_as_string(res.body_mut()).await; + + match json::from_str(&res_body_string) { + Ok(decoded) => (res, decoded), + Err(err) => { + dlg.response_json_decode_error(&res_body_string, &err); + return Err(client::Error::JsonDecodeError(res_body_string, err)); + } + } + }; + + dlg.finished(true); + return Ok(result_value) + } + } + } + } + + + /// The *part* parameter specifies the superChatEvent resource parts that the API response will include. This parameter is currently not supported. + /// + /// Append the given value to the *part* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + /// + /// Even though the property as already been set when instantiating this call, + /// we provide this method for API completeness. + pub fn add_part(mut self, new_value: &str) -> SuperChatEventListCall<'a, S> { + self._part.push(new_value.to_string()); + self + } + /// The *pageToken* parameter identifies a specific page in the result set that should be returned. In an API response, the nextPageToken and prevPageToken properties identify other pages that could be retrieved. + /// + /// Sets the *page token* query property to the given value. + pub fn page_token(mut self, new_value: &str) -> SuperChatEventListCall<'a, S> { + self._page_token = Some(new_value.to_string()); + self + } + /// The *maxResults* parameter specifies the maximum number of items that should be returned in the result set. + /// + /// Sets the *max results* query property to the given value. + pub fn max_results(mut self, new_value: u32) -> SuperChatEventListCall<'a, S> { + self._max_results = Some(new_value); + self + } + /// Return rendered funding amounts in specified language. + /// + /// Sets the *hl* query property to the given value. + pub fn hl(mut self, new_value: &str) -> SuperChatEventListCall<'a, S> { + self._hl = 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. + /// + /// ````text + /// It should be used to handle progress information, and to implement a certain level of resilience. + /// ```` + /// + /// Sets the *delegate* property to the given value. + pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> SuperChatEventListCall<'a, S> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not be used to set any of the known parameters + /// which have their own setter method. If done anyway, the request will fail. + /// + /// # Additional Parameters + /// + /// * *$.xgafv* (query-string) - V1 error format. + /// * *access_token* (query-string) - OAuth access token. + /// * *alt* (query-string) - Data format for response. + /// * *callback* (query-string) - JSONP + /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. + /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. + /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. + /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. + /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. + /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). + /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). + pub fn param(mut self, name: T, value: T) -> SuperChatEventListCall<'a, S> + where T: AsRef { + self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); + self + } + + /// Identifies the authorization scope for the method you are building. + /// + /// Use this method to actively specify which scope should be used, instead of 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: St) -> SuperChatEventListCall<'a, S> + where St: AsRef { + self._scopes.insert(String::from(scope.as_ref())); + self + } + /// Identifies the authorization scope(s) for the method you are building. + /// + /// See [`Self::add_scope()`] for details. + pub fn add_scopes(mut self, scopes: I) -> SuperChatEventListCall<'a, S> + where I: IntoIterator, + St: AsRef { + self._scopes + .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); + self + } + + /// Removes all scopes, and no default scope will be used either. + /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] + /// for details). + pub fn clear_scopes(mut self) -> SuperChatEventListCall<'a, S> { + self._scopes.clear(); + self + } +} + + +/// POST method. +/// +/// A builder for the *insert* method supported by a *test* resource. +/// It is not used directly, but through a [`TestMethods`] instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate hyper_rustls; +/// # extern crate google_youtube3 as youtube3; +/// use youtube3::api::TestItem; +/// # async fn dox() { +/// # use std::default::Default; +/// # use youtube3::{YouTube, oauth2, hyper, hyper_rustls, chrono, FieldMask}; +/// +/// # let secret: oauth2::ApplicationSecret = Default::default(); +/// # let auth = oauth2::InstalledFlowAuthenticator::builder( +/// # secret, +/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, +/// # ).build().await.unwrap(); +/// # let mut hub = YouTube::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().unwrap().https_or_http().enable_http1().build()), auth); +/// // As the method needs a request, you would usually fill it with the desired information +/// // into the respective structure. Some of the parts shown here might not be applicable ! +/// // Values shown here are possibly random and not representative ! +/// let mut req = TestItem::default(); +/// +/// // You can configure optional parameters by calling the respective setters at will, and +/// // execute the final call using `doit()`. +/// // Values shown here are possibly random and not representative ! +/// let result = hub.tests().insert(req) +/// .external_channel_id("tempor") +/// .doit().await; +/// # } +/// ``` +pub struct TestInsertCall<'a, S> + where S: 'a { + + pub(super) hub: &'a YouTube, + pub(super) _request: TestItem, + pub(super) _part: Vec, + pub(super) _external_channel_id: Option, + pub(super) _delegate: Option<&'a mut dyn client::Delegate>, + pub(super) _additional_params: HashMap, + pub(super) _scopes: BTreeSet +} + +impl<'a, S> client::CallBuilder for TestInsertCall<'a, S> {} + +impl<'a, S> TestInsertCall<'a, S> +where + S: tower_service::Service + Clone + Send + Sync + 'static, + S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, + S::Future: Send + Unpin + 'static, + S::Error: Into>, +{ + + + /// Perform the operation you have build so far. + pub async fn doit(mut self) -> client::Result<(hyper::Response, TestItem)> { + use std::io::{Read, Seek}; + use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; + use client::{ToParts, url::Params}; + use std::borrow::Cow; + + let mut dd = client::DefaultDelegate; + let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd); + dlg.begin(client::MethodInfo { id: "youtube.tests.insert", + http_method: hyper::Method::POST }); + + for &field in ["alt", "part", "externalChannelId"].iter() { + if self._additional_params.contains_key(field) { + dlg.finished(false); + return Err(client::Error::FieldClash(field)); + } + } + + let mut params = Params::with_capacity(5 + self._additional_params.len()); + if self._part.is_empty() { + self._part.push(self._request.to_parts()); + } + if self._part.len() > 0 { + for f in self._part.iter() { + params.push("part", f); + } + } + if let Some(value) = self._external_channel_id.as_ref() { + params.push("externalChannelId", value); + } + + params.extend(self._additional_params.iter()); + + params.push("alt", "json"); + let mut url = self.hub._base_url.clone() + "youtube/v3/tests"; + if self._scopes.is_empty() { + self._scopes.insert(Scope::Readonly.as_ref().to_string()); + } + + + let url = params.parse_with_url(&url); + + let mut json_mime_type = mime::APPLICATION_JSON; + let mut request_value_reader = + { + let mut value = json::value::to_value(&self._request).expect("serde to work"); + client::remove_json_null_values(&mut value); + let mut dst = io::Cursor::new(Vec::with_capacity(128)); + json::to_writer(&mut dst, &value).unwrap(); + dst + }; + let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); + request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); + + + loop { + let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]).await { + Ok(token) => token, + Err(e) => { + match dlg.token(e) { + Ok(token) => token, + Err(e) => { + dlg.finished(false); + return Err(client::Error::MissingToken(e)); + } + } + } + }; + request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); + let mut req_result = { + let client = &self.hub.client; + dlg.pre_request(); + let mut req_builder = hyper::Request::builder() + .method(hyper::Method::POST) + .uri(url.as_str()) + .header(USER_AGENT, self.hub._user_agent.clone()); + + if let Some(token) = token.as_ref() { + req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); + } + + + let request = req_builder + .header(CONTENT_TYPE, json_mime_type.to_string()) + .header(CONTENT_LENGTH, request_size as u64) + .body(hyper::body::Body::from(request_value_reader.get_ref().clone())); + + client.request(request.unwrap()).await + + }; + + match req_result { + Err(err) => { + if let client::Retry::After(d) = dlg.http_error(&err) { + sleep(d).await; + continue; + } + dlg.finished(false); + return Err(client::Error::HttpError(err)) + } + Ok(mut res) => { + if !res.status().is_success() { + let res_body_string = client::get_body_as_string(res.body_mut()).await; + let (parts, _) = res.into_parts(); + let body = hyper::Body::from(res_body_string.clone()); + let restored_response = hyper::Response::from_parts(parts, body); + + let server_response = json::from_str::(&res_body_string).ok(); + + if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { + sleep(d).await; + continue; + } + + dlg.finished(false); + + return match server_response { + Some(error_value) => Err(client::Error::BadRequest(error_value)), + None => Err(client::Error::Failure(restored_response)), + } + } + let result_value = { + let res_body_string = client::get_body_as_string(res.body_mut()).await; + + match json::from_str(&res_body_string) { + Ok(decoded) => (res, decoded), + Err(err) => { + dlg.response_json_decode_error(&res_body_string, &err); + return Err(client::Error::JsonDecodeError(res_body_string, err)); + } + } + }; + + dlg.finished(true); + return Ok(result_value) + } + } + } + } + + + /// + /// Sets the *request* property to the given value. + /// + /// Even though the property as already been set when instantiating this call, + /// we provide this method for API completeness. + pub fn request(mut self, new_value: TestItem) -> TestInsertCall<'a, S> { + self._request = new_value; + self + } + /// + /// Append the given value to the *part* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + /// + /// Even though the *parts* list is automatically derived from *Resource* passed in + /// during instantiation and indicates which values you are passing, the response would contain the very same parts. + /// This may not always be desirable, as you can obtain (newly generated) parts you cannot pass in, + /// like statistics that are generated server side. Therefore you should use this method to specify + /// the parts you provide in addition to the ones you want in the response. + pub fn add_part(mut self, new_value: &str) -> TestInsertCall<'a, S> { + self._part.push(new_value.to_string()); + self + } + /// + /// Sets the *external channel id* query property to the given value. + pub fn external_channel_id(mut self, new_value: &str) -> TestInsertCall<'a, S> { + self._external_channel_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. + /// + /// ````text + /// It should be used to handle progress information, and to implement a certain level of resilience. + /// ```` + /// + /// Sets the *delegate* property to the given value. + pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> TestInsertCall<'a, S> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not be used to set any of the known parameters + /// which have their own setter method. If done anyway, the request will fail. + /// + /// # Additional Parameters + /// + /// * *$.xgafv* (query-string) - V1 error format. + /// * *access_token* (query-string) - OAuth access token. + /// * *alt* (query-string) - Data format for response. + /// * *callback* (query-string) - JSONP + /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. + /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. + /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. + /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. + /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. + /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). + /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). + pub fn param(mut self, name: T, value: T) -> TestInsertCall<'a, S> + where T: AsRef { + self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); + self + } + + /// Identifies the authorization scope for the method you are building. + /// + /// Use this method to actively specify which scope should be used, instead of 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: St) -> TestInsertCall<'a, S> + where St: AsRef { + self._scopes.insert(String::from(scope.as_ref())); + self + } + /// Identifies the authorization scope(s) for the method you are building. + /// + /// See [`Self::add_scope()`] for details. + pub fn add_scopes(mut self, scopes: I) -> TestInsertCall<'a, S> + where I: IntoIterator, + St: AsRef { + self._scopes + .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); + self + } + + /// Removes all scopes, and no default scope will be used either. + /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] + /// for details). + pub fn clear_scopes(mut self) -> TestInsertCall<'a, S> { + self._scopes.clear(); + self + } +} + + +/// Deletes a resource. +/// +/// A builder for the *delete* method supported by a *thirdPartyLink* resource. +/// It is not used directly, but through a [`ThirdPartyLinkMethods`] instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate hyper_rustls; +/// # extern crate google_youtube3 as youtube3; +/// # async fn dox() { +/// # use std::default::Default; +/// # use youtube3::{YouTube, oauth2, hyper, hyper_rustls, chrono, FieldMask}; +/// +/// # let secret: oauth2::ApplicationSecret = Default::default(); +/// # let auth = oauth2::InstalledFlowAuthenticator::builder( +/// # secret, +/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, +/// # ).build().await.unwrap(); +/// # let mut hub = YouTube::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().unwrap().https_or_http().enable_http1().build()), auth); +/// // You can configure optional parameters by calling the respective setters at will, and +/// // execute the final call using `doit()`. +/// // Values shown here are possibly random and not representative ! +/// let result = hub.third_party_links().delete("linkingToken", &Default::default()) +/// .add_part("est") +/// .external_channel_id("takimata") +/// .doit().await; +/// # } +/// ``` +pub struct ThirdPartyLinkDeleteCall<'a, S> + where S: 'a { + + pub(super) hub: &'a YouTube, + pub(super) _linking_token: String, + pub(super) _type_: ThirdPartyLinkTypeEnum, + pub(super) _part: Vec, + pub(super) _external_channel_id: Option, + pub(super) _delegate: Option<&'a mut dyn client::Delegate>, + pub(super) _additional_params: HashMap, +} + +impl<'a, S> client::CallBuilder for ThirdPartyLinkDeleteCall<'a, S> {} + +impl<'a, S> ThirdPartyLinkDeleteCall<'a, S> +where + S: tower_service::Service + Clone + Send + Sync + 'static, + S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, + S::Future: Send + Unpin + 'static, + S::Error: Into>, +{ + + + /// Perform the operation you have build so far. + pub async fn doit(mut self) -> client::Result> { + use std::io::{Read, Seek}; + use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; + use client::{ToParts, url::Params}; + use std::borrow::Cow; + + let mut dd = client::DefaultDelegate; + let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd); + dlg.begin(client::MethodInfo { id: "youtube.thirdPartyLinks.delete", + http_method: hyper::Method::DELETE }); + + for &field in ["linkingToken", "type", "part", "externalChannelId"].iter() { + if self._additional_params.contains_key(field) { + dlg.finished(false); + return Err(client::Error::FieldClash(field)); + } + } + + let mut params = Params::with_capacity(5 + self._additional_params.len()); + params.push("linkingToken", &self._linking_token); + params.push("type", &self._type_); + if self._part.len() > 0 { + for f in self._part.iter() { + params.push("part", f); + } + } + if let Some(value) = self._external_channel_id.as_ref() { + params.push("externalChannelId", value); + } + + params.extend(self._additional_params.iter()); + + let mut url = self.hub._base_url.clone() + "youtube/v3/thirdPartyLinks"; + + match dlg.api_key() { + Some(value) => params.push("key", value), + None => { + dlg.finished(false); + return Err(client::Error::MissingAPIKey) + } + } + + + let url = params.parse_with_url(&url); + + + + loop { + let mut req_result = { + let client = &self.hub.client; + dlg.pre_request(); + let mut req_builder = hyper::Request::builder() + .method(hyper::Method::DELETE) + .uri(url.as_str()) + .header(USER_AGENT, self.hub._user_agent.clone()); + + + + let request = req_builder + .header(CONTENT_LENGTH, 0_u64) + .body(hyper::body::Body::empty()); + + client.request(request.unwrap()).await + + }; + + match req_result { + Err(err) => { + if let client::Retry::After(d) = dlg.http_error(&err) { + sleep(d).await; + continue; + } + dlg.finished(false); + return Err(client::Error::HttpError(err)) + } + Ok(mut res) => { + if !res.status().is_success() { + let res_body_string = client::get_body_as_string(res.body_mut()).await; + let (parts, _) = res.into_parts(); + let body = hyper::Body::from(res_body_string.clone()); + let restored_response = hyper::Response::from_parts(parts, body); + + let server_response = json::from_str::(&res_body_string).ok(); + + if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { + sleep(d).await; + continue; + } + + dlg.finished(false); + + return match server_response { + Some(error_value) => Err(client::Error::BadRequest(error_value)), + None => Err(client::Error::Failure(restored_response)), + } + } + let result_value = res; + + dlg.finished(true); + return Ok(result_value) + } + } + } + } + + + /// Delete the partner links with the given linking token. + /// + /// Sets the *linking token* 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 linking_token(mut self, new_value: &str) -> ThirdPartyLinkDeleteCall<'a, S> { + self._linking_token = new_value.to_string(); + self + } + /// Type of the link to be deleted. + /// + /// Sets the *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 type_(mut self, new_value: &ThirdPartyLinkTypeEnum) -> ThirdPartyLinkDeleteCall<'a, S> { + self._type_ = new_value.clone(); + self + } + /// Do not use. Required for compatibility. + /// + /// Append the given value to the *part* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + pub fn add_part(mut self, new_value: &str) -> ThirdPartyLinkDeleteCall<'a, S> { + self._part.push(new_value.to_string()); + self + } + /// Channel ID to which changes should be applied, for delegation. + /// + /// Sets the *external channel id* query property to the given value. + pub fn external_channel_id(mut self, new_value: &str) -> ThirdPartyLinkDeleteCall<'a, S> { + self._external_channel_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. + /// + /// ````text + /// It should be used to handle progress information, and to implement a certain level of resilience. + /// ```` + /// + /// Sets the *delegate* property to the given value. + pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> ThirdPartyLinkDeleteCall<'a, S> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not be used to set any of the known parameters + /// which have their own setter method. If done anyway, the request will fail. + /// + /// # Additional Parameters + /// + /// * *$.xgafv* (query-string) - V1 error format. + /// * *access_token* (query-string) - OAuth access token. + /// * *alt* (query-string) - Data format for response. + /// * *callback* (query-string) - JSONP + /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. + /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. + /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. + /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. + /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. + /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). + /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). + pub fn param(mut self, name: T, value: T) -> ThirdPartyLinkDeleteCall<'a, S> + where T: AsRef { + self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); + self + } + +} + + +/// Inserts a new resource into this collection. +/// +/// A builder for the *insert* method supported by a *thirdPartyLink* resource. +/// It is not used directly, but through a [`ThirdPartyLinkMethods`] instance. +/// +/// **Settable Parts** +/// +/// * *linkingToken* +/// * *status* +/// * *snippet* +/// +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate hyper_rustls; +/// # extern crate google_youtube3 as youtube3; +/// use youtube3::api::ThirdPartyLink; +/// # async fn dox() { +/// # use std::default::Default; +/// # use youtube3::{YouTube, oauth2, hyper, hyper_rustls, chrono, FieldMask}; +/// +/// # let secret: oauth2::ApplicationSecret = Default::default(); +/// # let auth = oauth2::InstalledFlowAuthenticator::builder( +/// # secret, +/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, +/// # ).build().await.unwrap(); +/// # let mut hub = YouTube::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().unwrap().https_or_http().enable_http1().build()), auth); +/// // As the method needs a request, you would usually fill it with the desired information +/// // into the respective structure. Some of the parts shown here might not be applicable ! +/// // Values shown here are possibly random and not representative ! +/// let mut req = ThirdPartyLink::default(); +/// req.linking_token = Some("dolor".to_string()); +/// req.snippet = Default::default(); // is ThirdPartyLinkSnippet +/// req.status = Default::default(); // is ThirdPartyLinkStatus +/// +/// // You can configure optional parameters by calling the respective setters at will, and +/// // execute the final call using `doit()`. +/// // Values shown here are possibly random and not representative ! +/// let result = hub.third_party_links().insert(req) +/// .external_channel_id("diam") +/// .doit().await; +/// # } +/// ``` +pub struct ThirdPartyLinkInsertCall<'a, S> + where S: 'a { + + pub(super) hub: &'a YouTube, + pub(super) _request: ThirdPartyLink, + pub(super) _part: Vec, + pub(super) _external_channel_id: Option, + pub(super) _delegate: Option<&'a mut dyn client::Delegate>, + pub(super) _additional_params: HashMap, +} + +impl<'a, S> client::CallBuilder for ThirdPartyLinkInsertCall<'a, S> {} + +impl<'a, S> ThirdPartyLinkInsertCall<'a, S> +where + S: tower_service::Service + Clone + Send + Sync + 'static, + S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, + S::Future: Send + Unpin + 'static, + S::Error: Into>, +{ + + + /// Perform the operation you have build so far. + pub async fn doit(mut self) -> client::Result<(hyper::Response, ThirdPartyLink)> { + use std::io::{Read, Seek}; + use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; + use client::{ToParts, url::Params}; + use std::borrow::Cow; + + let mut dd = client::DefaultDelegate; + let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd); + dlg.begin(client::MethodInfo { id: "youtube.thirdPartyLinks.insert", + http_method: hyper::Method::POST }); + + for &field in ["alt", "part", "externalChannelId"].iter() { + if self._additional_params.contains_key(field) { + dlg.finished(false); + return Err(client::Error::FieldClash(field)); + } + } + + let mut params = Params::with_capacity(5 + self._additional_params.len()); + if self._part.is_empty() { + self._part.push(self._request.to_parts()); + } + if self._part.len() > 0 { + for f in self._part.iter() { + params.push("part", f); + } + } + if let Some(value) = self._external_channel_id.as_ref() { + params.push("externalChannelId", value); + } + + params.extend(self._additional_params.iter()); + + params.push("alt", "json"); + let mut url = self.hub._base_url.clone() + "youtube/v3/thirdPartyLinks"; + + match dlg.api_key() { + Some(value) => params.push("key", value), + None => { + dlg.finished(false); + return Err(client::Error::MissingAPIKey) + } + } + + + let url = params.parse_with_url(&url); + + let mut json_mime_type = mime::APPLICATION_JSON; + let mut request_value_reader = + { + let mut value = json::value::to_value(&self._request).expect("serde to work"); + client::remove_json_null_values(&mut value); + let mut dst = io::Cursor::new(Vec::with_capacity(128)); + json::to_writer(&mut dst, &value).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 client = &self.hub.client; + dlg.pre_request(); + let mut req_builder = hyper::Request::builder() + .method(hyper::Method::POST) + .uri(url.as_str()) + .header(USER_AGENT, self.hub._user_agent.clone()); + + + + let request = req_builder + .header(CONTENT_TYPE, json_mime_type.to_string()) + .header(CONTENT_LENGTH, request_size as u64) + .body(hyper::body::Body::from(request_value_reader.get_ref().clone())); + + client.request(request.unwrap()).await + + }; + + match req_result { + Err(err) => { + if let client::Retry::After(d) = dlg.http_error(&err) { + sleep(d).await; + continue; + } + dlg.finished(false); + return Err(client::Error::HttpError(err)) + } + Ok(mut res) => { + if !res.status().is_success() { + let res_body_string = client::get_body_as_string(res.body_mut()).await; + let (parts, _) = res.into_parts(); + let body = hyper::Body::from(res_body_string.clone()); + let restored_response = hyper::Response::from_parts(parts, body); + + let server_response = json::from_str::(&res_body_string).ok(); + + if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { + sleep(d).await; + continue; + } + + dlg.finished(false); + + return match server_response { + Some(error_value) => Err(client::Error::BadRequest(error_value)), + None => Err(client::Error::Failure(restored_response)), + } + } + let result_value = { + let res_body_string = client::get_body_as_string(res.body_mut()).await; + + match json::from_str(&res_body_string) { + Ok(decoded) => (res, decoded), + Err(err) => { + dlg.response_json_decode_error(&res_body_string, &err); + return Err(client::Error::JsonDecodeError(res_body_string, err)); + } + } + }; + + dlg.finished(true); + return Ok(result_value) + } + } + } + } + + + /// + /// Sets the *request* property to the given value. + /// + /// Even though the property as already been set when instantiating this call, + /// we provide this method for API completeness. + /// + /// **Settable Parts** + /// + /// * *linkingToken* + /// * *status* + /// * *snippet* + pub fn request(mut self, new_value: ThirdPartyLink) -> ThirdPartyLinkInsertCall<'a, S> { + self._request = new_value; + self + } + /// The *part* parameter specifies the thirdPartyLink resource parts that the API request and response will include. Supported values are linkingToken, status, and snippet. + /// + /// Append the given value to the *part* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + /// + /// Even though the *parts* list is automatically derived from *Resource* passed in + /// during instantiation and indicates which values you are passing, the response would contain the very same parts. + /// This may not always be desirable, as you can obtain (newly generated) parts you cannot pass in, + /// like statistics that are generated server side. Therefore you should use this method to specify + /// the parts you provide in addition to the ones you want in the response. + /// + /// **Settable Parts** + /// + /// * *linkingToken* + /// * *status* + /// * *snippet* + pub fn add_part(mut self, new_value: &str) -> ThirdPartyLinkInsertCall<'a, S> { + self._part.push(new_value.to_string()); + self + } + /// Channel ID to which changes should be applied, for delegation. + /// + /// Sets the *external channel id* query property to the given value. + pub fn external_channel_id(mut self, new_value: &str) -> ThirdPartyLinkInsertCall<'a, S> { + self._external_channel_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. + /// + /// ````text + /// It should be used to handle progress information, and to implement a certain level of resilience. + /// ```` + /// + /// Sets the *delegate* property to the given value. + pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> ThirdPartyLinkInsertCall<'a, S> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not be used to set any of the known parameters + /// which have their own setter method. If done anyway, the request will fail. + /// + /// # Additional Parameters + /// + /// * *$.xgafv* (query-string) - V1 error format. + /// * *access_token* (query-string) - OAuth access token. + /// * *alt* (query-string) - Data format for response. + /// * *callback* (query-string) - JSONP + /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. + /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. + /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. + /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. + /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. + /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). + /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). + pub fn param(mut self, name: T, value: T) -> ThirdPartyLinkInsertCall<'a, S> + where T: AsRef { + self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); + self + } + +} + + +/// Retrieves a list of resources, possibly filtered. +/// +/// A builder for the *list* method supported by a *thirdPartyLink* resource. +/// It is not used directly, but through a [`ThirdPartyLinkMethods`] instance. +/// +/// **Settable Parts** +/// +/// * *linkingToken* +/// * *status* +/// * *snippet* +/// +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate hyper_rustls; +/// # extern crate google_youtube3 as youtube3; +/// # async fn dox() { +/// # use std::default::Default; +/// # use youtube3::{YouTube, oauth2, hyper, hyper_rustls, chrono, FieldMask}; +/// +/// # let secret: oauth2::ApplicationSecret = Default::default(); +/// # let auth = oauth2::InstalledFlowAuthenticator::builder( +/// # secret, +/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, +/// # ).build().await.unwrap(); +/// # let mut hub = YouTube::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().unwrap().https_or_http().enable_http1().build()), auth); +/// // You can configure optional parameters by calling the respective setters at will, and +/// // execute the final call using `doit()`. +/// // Values shown here are possibly random and not representative ! +/// let result = hub.third_party_links().list(&vec!["At".into()]) +/// .type_(&Default::default()) +/// .linking_token("erat") +/// .external_channel_id("justo") +/// .doit().await; +/// # } +/// ``` +pub struct ThirdPartyLinkListCall<'a, S> + where S: 'a { + + pub(super) hub: &'a YouTube, + pub(super) _part: Vec, + pub(super) _type_: Option, + pub(super) _linking_token: Option, + pub(super) _external_channel_id: Option, + pub(super) _delegate: Option<&'a mut dyn client::Delegate>, + pub(super) _additional_params: HashMap, +} + +impl<'a, S> client::CallBuilder for ThirdPartyLinkListCall<'a, S> {} + +impl<'a, S> ThirdPartyLinkListCall<'a, S> +where + S: tower_service::Service + Clone + Send + Sync + 'static, + S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, + S::Future: Send + Unpin + 'static, + S::Error: Into>, +{ + + + /// Perform the operation you have build so far. + pub async fn doit(mut self) -> client::Result<(hyper::Response, ThirdPartyLinkListResponse)> { + use std::io::{Read, Seek}; + use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; + use client::{ToParts, url::Params}; + use std::borrow::Cow; + + let mut dd = client::DefaultDelegate; + let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd); + dlg.begin(client::MethodInfo { id: "youtube.thirdPartyLinks.list", + http_method: hyper::Method::GET }); + + for &field in ["alt", "part", "type", "linkingToken", "externalChannelId"].iter() { + if self._additional_params.contains_key(field) { + dlg.finished(false); + return Err(client::Error::FieldClash(field)); + } + } + + let mut params = Params::with_capacity(6 + self._additional_params.len()); + if self._part.len() > 0 { + for f in self._part.iter() { + params.push("part", f); + } + } + if let Some(value) = self._type_.as_ref() { + params.push("type", value); + } + if let Some(value) = self._linking_token.as_ref() { + params.push("linkingToken", value); + } + if let Some(value) = self._external_channel_id.as_ref() { + params.push("externalChannelId", value); + } + + params.extend(self._additional_params.iter()); + + params.push("alt", "json"); + let mut url = self.hub._base_url.clone() + "youtube/v3/thirdPartyLinks"; + + match dlg.api_key() { + Some(value) => params.push("key", value), + None => { + dlg.finished(false); + return Err(client::Error::MissingAPIKey) + } + } + + + let url = params.parse_with_url(&url); + + + + loop { + let mut req_result = { + let client = &self.hub.client; + dlg.pre_request(); + let mut req_builder = hyper::Request::builder() + .method(hyper::Method::GET) + .uri(url.as_str()) + .header(USER_AGENT, self.hub._user_agent.clone()); + + + + let request = req_builder + .header(CONTENT_LENGTH, 0_u64) + .body(hyper::body::Body::empty()); + + client.request(request.unwrap()).await + + }; + + match req_result { + Err(err) => { + if let client::Retry::After(d) = dlg.http_error(&err) { + sleep(d).await; + continue; + } + dlg.finished(false); + return Err(client::Error::HttpError(err)) + } + Ok(mut res) => { + if !res.status().is_success() { + let res_body_string = client::get_body_as_string(res.body_mut()).await; + let (parts, _) = res.into_parts(); + let body = hyper::Body::from(res_body_string.clone()); + let restored_response = hyper::Response::from_parts(parts, body); + + let server_response = json::from_str::(&res_body_string).ok(); + + if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { + sleep(d).await; + continue; + } + + dlg.finished(false); + + return match server_response { + Some(error_value) => Err(client::Error::BadRequest(error_value)), + None => Err(client::Error::Failure(restored_response)), + } + } + let result_value = { + let res_body_string = client::get_body_as_string(res.body_mut()).await; + + match json::from_str(&res_body_string) { + Ok(decoded) => (res, decoded), + Err(err) => { + dlg.response_json_decode_error(&res_body_string, &err); + return Err(client::Error::JsonDecodeError(res_body_string, err)); + } + } + }; + + dlg.finished(true); + return Ok(result_value) + } + } + } + } + + + /// The *part* parameter specifies the thirdPartyLink resource parts that the API response will include. Supported values are linkingToken, status, and snippet. + /// + /// Append the given value to the *part* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + /// + /// Even though the property as already been set when instantiating this call, + /// we provide this method for API completeness. + /// + /// **Settable Parts** + /// + /// * *linkingToken* + /// * *status* + /// * *snippet* + pub fn add_part(mut self, new_value: &str) -> ThirdPartyLinkListCall<'a, S> { + self._part.push(new_value.to_string()); + self + } + /// Get a third party link of the given type. + /// + /// Sets the *type* query property to the given value. + pub fn type_(mut self, new_value: &ThirdPartyLinkTypeEnum) -> ThirdPartyLinkListCall<'a, S> { + self._type_ = Some(new_value.clone()); + self + } + /// Get a third party link with the given linking token. + /// + /// Sets the *linking token* query property to the given value. + pub fn linking_token(mut self, new_value: &str) -> ThirdPartyLinkListCall<'a, S> { + self._linking_token = Some(new_value.to_string()); + self + } + /// Channel ID to which changes should be applied, for delegation. + /// + /// Sets the *external channel id* query property to the given value. + pub fn external_channel_id(mut self, new_value: &str) -> ThirdPartyLinkListCall<'a, S> { + self._external_channel_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. + /// + /// ````text + /// It should be used to handle progress information, and to implement a certain level of resilience. + /// ```` + /// + /// Sets the *delegate* property to the given value. + pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> ThirdPartyLinkListCall<'a, S> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not be used to set any of the known parameters + /// which have their own setter method. If done anyway, the request will fail. + /// + /// # Additional Parameters + /// + /// * *$.xgafv* (query-string) - V1 error format. + /// * *access_token* (query-string) - OAuth access token. + /// * *alt* (query-string) - Data format for response. + /// * *callback* (query-string) - JSONP + /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. + /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. + /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. + /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. + /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. + /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). + /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). + pub fn param(mut self, name: T, value: T) -> ThirdPartyLinkListCall<'a, S> + where T: AsRef { + self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); + self + } + +} + + +/// Updates an existing resource. +/// +/// A builder for the *update* method supported by a *thirdPartyLink* resource. +/// It is not used directly, but through a [`ThirdPartyLinkMethods`] instance. +/// +/// **Settable Parts** +/// +/// * *linkingToken* +/// * *status* +/// * *snippet* +/// +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate hyper_rustls; +/// # extern crate google_youtube3 as youtube3; +/// use youtube3::api::ThirdPartyLink; +/// # async fn dox() { +/// # use std::default::Default; +/// # use youtube3::{YouTube, oauth2, hyper, hyper_rustls, chrono, FieldMask}; +/// +/// # let secret: oauth2::ApplicationSecret = Default::default(); +/// # let auth = oauth2::InstalledFlowAuthenticator::builder( +/// # secret, +/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, +/// # ).build().await.unwrap(); +/// # let mut hub = YouTube::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().unwrap().https_or_http().enable_http1().build()), auth); +/// // As the method needs a request, you would usually fill it with the desired information +/// // into the respective structure. Some of the parts shown here might not be applicable ! +/// // Values shown here are possibly random and not representative ! +/// let mut req = ThirdPartyLink::default(); +/// req.linking_token = Some("ipsum".to_string()); +/// req.snippet = Default::default(); // is ThirdPartyLinkSnippet +/// req.status = Default::default(); // is ThirdPartyLinkStatus +/// +/// // You can configure optional parameters by calling the respective setters at will, and +/// // execute the final call using `doit()`. +/// // Values shown here are possibly random and not representative ! +/// let result = hub.third_party_links().update(req) +/// .external_channel_id("accusam") +/// .doit().await; +/// # } +/// ``` +pub struct ThirdPartyLinkUpdateCall<'a, S> + where S: 'a { + + pub(super) hub: &'a YouTube, + pub(super) _request: ThirdPartyLink, + pub(super) _part: Vec, + pub(super) _external_channel_id: Option, + pub(super) _delegate: Option<&'a mut dyn client::Delegate>, + pub(super) _additional_params: HashMap, +} + +impl<'a, S> client::CallBuilder for ThirdPartyLinkUpdateCall<'a, S> {} + +impl<'a, S> ThirdPartyLinkUpdateCall<'a, S> +where + S: tower_service::Service + Clone + Send + Sync + 'static, + S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, + S::Future: Send + Unpin + 'static, + S::Error: Into>, +{ + + + /// Perform the operation you have build so far. + pub async fn doit(mut self) -> client::Result<(hyper::Response, ThirdPartyLink)> { + use std::io::{Read, Seek}; + use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; + use client::{ToParts, url::Params}; + use std::borrow::Cow; + + let mut dd = client::DefaultDelegate; + let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd); + dlg.begin(client::MethodInfo { id: "youtube.thirdPartyLinks.update", + http_method: hyper::Method::PUT }); + + for &field in ["alt", "part", "externalChannelId"].iter() { + if self._additional_params.contains_key(field) { + dlg.finished(false); + return Err(client::Error::FieldClash(field)); + } + } + + let mut params = Params::with_capacity(5 + self._additional_params.len()); + if self._part.is_empty() { + self._part.push(self._request.to_parts()); + } + if self._part.len() > 0 { + for f in self._part.iter() { + params.push("part", f); + } + } + if let Some(value) = self._external_channel_id.as_ref() { + params.push("externalChannelId", value); + } + + params.extend(self._additional_params.iter()); + + params.push("alt", "json"); + let mut url = self.hub._base_url.clone() + "youtube/v3/thirdPartyLinks"; + + match dlg.api_key() { + Some(value) => params.push("key", value), + None => { + dlg.finished(false); + return Err(client::Error::MissingAPIKey) + } + } + + + let url = params.parse_with_url(&url); + + let mut json_mime_type = mime::APPLICATION_JSON; + let mut request_value_reader = + { + let mut value = json::value::to_value(&self._request).expect("serde to work"); + client::remove_json_null_values(&mut value); + let mut dst = io::Cursor::new(Vec::with_capacity(128)); + json::to_writer(&mut dst, &value).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 client = &self.hub.client; + dlg.pre_request(); + let mut req_builder = hyper::Request::builder() + .method(hyper::Method::PUT) + .uri(url.as_str()) + .header(USER_AGENT, self.hub._user_agent.clone()); + + + + let request = req_builder + .header(CONTENT_TYPE, json_mime_type.to_string()) + .header(CONTENT_LENGTH, request_size as u64) + .body(hyper::body::Body::from(request_value_reader.get_ref().clone())); + + client.request(request.unwrap()).await + + }; + + match req_result { + Err(err) => { + if let client::Retry::After(d) = dlg.http_error(&err) { + sleep(d).await; + continue; + } + dlg.finished(false); + return Err(client::Error::HttpError(err)) + } + Ok(mut res) => { + if !res.status().is_success() { + let res_body_string = client::get_body_as_string(res.body_mut()).await; + let (parts, _) = res.into_parts(); + let body = hyper::Body::from(res_body_string.clone()); + let restored_response = hyper::Response::from_parts(parts, body); + + let server_response = json::from_str::(&res_body_string).ok(); + + if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { + sleep(d).await; + continue; + } + + dlg.finished(false); + + return match server_response { + Some(error_value) => Err(client::Error::BadRequest(error_value)), + None => Err(client::Error::Failure(restored_response)), + } + } + let result_value = { + let res_body_string = client::get_body_as_string(res.body_mut()).await; + + match json::from_str(&res_body_string) { + Ok(decoded) => (res, decoded), + Err(err) => { + dlg.response_json_decode_error(&res_body_string, &err); + return Err(client::Error::JsonDecodeError(res_body_string, err)); + } + } + }; + + dlg.finished(true); + return Ok(result_value) + } + } + } + } + + + /// + /// Sets the *request* property to the given value. + /// + /// Even though the property as already been set when instantiating this call, + /// we provide this method for API completeness. + /// + /// **Settable Parts** + /// + /// * *linkingToken* + /// * *status* + /// * *snippet* + pub fn request(mut self, new_value: ThirdPartyLink) -> ThirdPartyLinkUpdateCall<'a, S> { + self._request = new_value; + self + } + /// The *part* parameter specifies the thirdPartyLink resource parts that the API request and response will include. Supported values are linkingToken, status, and snippet. + /// + /// Append the given value to the *part* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + /// + /// Even though the *parts* list is automatically derived from *Resource* passed in + /// during instantiation and indicates which values you are passing, the response would contain the very same parts. + /// This may not always be desirable, as you can obtain (newly generated) parts you cannot pass in, + /// like statistics that are generated server side. Therefore you should use this method to specify + /// the parts you provide in addition to the ones you want in the response. + /// + /// **Settable Parts** + /// + /// * *linkingToken* + /// * *status* + /// * *snippet* + pub fn add_part(mut self, new_value: &str) -> ThirdPartyLinkUpdateCall<'a, S> { + self._part.push(new_value.to_string()); + self + } + /// Channel ID to which changes should be applied, for delegation. + /// + /// Sets the *external channel id* query property to the given value. + pub fn external_channel_id(mut self, new_value: &str) -> ThirdPartyLinkUpdateCall<'a, S> { + self._external_channel_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. + /// + /// ````text + /// It should be used to handle progress information, and to implement a certain level of resilience. + /// ```` + /// + /// Sets the *delegate* property to the given value. + pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> ThirdPartyLinkUpdateCall<'a, S> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not be used to set any of the known parameters + /// which have their own setter method. If done anyway, the request will fail. + /// + /// # Additional Parameters + /// + /// * *$.xgafv* (query-string) - V1 error format. + /// * *access_token* (query-string) - OAuth access token. + /// * *alt* (query-string) - Data format for response. + /// * *callback* (query-string) - JSONP + /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. + /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. + /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. + /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. + /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. + /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). + /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). + pub fn param(mut self, name: T, value: T) -> ThirdPartyLinkUpdateCall<'a, S> + where T: AsRef { + self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); + self + } + +} + + +/// As this is not an insert in a strict sense (it supports uploading/setting of a thumbnail for multiple videos, which doesn't result in creation of a single resource), I use a custom verb here. +/// +/// A builder for the *set* method supported by a *thumbnail* resource. +/// It is not used directly, but through a [`ThumbnailMethods`] instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate hyper_rustls; +/// # extern crate google_youtube3 as youtube3; +/// use std::fs; +/// # async fn dox() { +/// # use std::default::Default; +/// # use youtube3::{YouTube, oauth2, hyper, hyper_rustls, chrono, FieldMask}; +/// +/// # let secret: oauth2::ApplicationSecret = Default::default(); +/// # let auth = oauth2::InstalledFlowAuthenticator::builder( +/// # secret, +/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, +/// # ).build().await.unwrap(); +/// # let mut hub = YouTube::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().unwrap().https_or_http().enable_http1().build()), 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.thumbnails().set("videoId") +/// .on_behalf_of_content_owner("consetetur") +/// .upload_resumable(fs::File::open("file.ext").unwrap(), "application/octet-stream".parse().unwrap()).await; +/// # } +/// ``` +pub struct ThumbnailSetCall<'a, S> + where S: 'a { + + pub(super) hub: &'a YouTube, + pub(super) _video_id: String, + pub(super) _on_behalf_of_content_owner: Option, + pub(super) _delegate: Option<&'a mut dyn client::Delegate>, + pub(super) _additional_params: HashMap, + pub(super) _scopes: BTreeSet +} + +impl<'a, S> client::CallBuilder for ThumbnailSetCall<'a, S> {} + +impl<'a, S> ThumbnailSetCall<'a, S> +where + S: tower_service::Service + Clone + Send + Sync + 'static, + S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, + S::Future: Send + Unpin + 'static, + S::Error: Into>, +{ + + + /// Perform the operation you have build so far. + async fn doit(mut self, mut reader: RS, reader_mime_type: mime::Mime, protocol: client::UploadProtocol) -> client::Result<(hyper::Response, ThumbnailSetResponse)> + where RS: client::ReadSeek { + use std::io::{Read, Seek}; + use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; + use client::{ToParts, url::Params}; + use std::borrow::Cow; + + let mut dd = client::DefaultDelegate; + let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd); + dlg.begin(client::MethodInfo { id: "youtube.thumbnails.set", + http_method: hyper::Method::POST }); + + for &field in ["alt", "videoId", "onBehalfOfContentOwner"].iter() { + if self._additional_params.contains_key(field) { + dlg.finished(false); + return Err(client::Error::FieldClash(field)); + } + } + + let mut params = Params::with_capacity(4 + self._additional_params.len()); + params.push("videoId", &self._video_id); + if let Some(value) = self._on_behalf_of_content_owner.as_ref() { + params.push("onBehalfOfContentOwner", value); + } + + params.extend(self._additional_params.iter()); + + params.push("alt", "json"); + let (mut url, upload_type) = + if protocol == client::UploadProtocol::Resumable { + (self.hub._root_url.clone() + "resumable/upload/youtube/v3/thumbnails/set", "resumable") + } else if protocol == client::UploadProtocol::Simple { + (self.hub._root_url.clone() + "upload/youtube/v3/thumbnails/set", "multipart") + } else { + unreachable!() + }; + params.push("uploadType", upload_type); + if self._scopes.is_empty() { + self._scopes.insert(Scope::Full.as_ref().to_string()); + } + + + let url = params.parse_with_url(&url); + + + 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.get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]).await { + Ok(token) => token, + Err(e) => { + match dlg.token(e) { + Ok(token) => token, + Err(e) => { + dlg.finished(false); + return Err(client::Error::MissingToken(e)); + } + } + } + }; + 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; + Ok(hyper::Response::builder() + .status(hyper::StatusCode::OK) + .header("Location", upload_url.as_ref().unwrap().clone()) + .body(hyper::body::Body::empty()) + .unwrap()) + } else { + let client = &self.hub.client; + dlg.pre_request(); + let mut req_builder = hyper::Request::builder() + .method(hyper::Method::POST) + .uri(url.as_str()) + .header(USER_AGENT, self.hub._user_agent.clone()); + + if let Some(token) = token.as_ref() { + req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); + } + + upload_url_from_server = true; + if protocol == client::UploadProtocol::Resumable { + req_builder = req_builder.header("X-Upload-Content-Type", format!("{}", reader_mime_type)); + } + + let request = if protocol == client::UploadProtocol::Simple { + let size = reader.seek(io::SeekFrom::End(0)).unwrap(); + reader.seek(io::SeekFrom::Start(0)).unwrap(); + if size > 2097152 { + return Err(client::Error::UploadSizeLimitExceeded(size, 2097152)) + } + let mut bytes = Vec::with_capacity(size as usize); + reader.read_to_end(&mut bytes)?; + req_builder.header(CONTENT_TYPE, reader_mime_type.to_string()) + .header(CONTENT_LENGTH, size) + .body(hyper::body::Body::from(bytes)) + } else { + req_builder.body(hyper::body::Body::from(Vec::new())) + }; + + client.request(request.unwrap()).await + + } + }; + + match req_result { + Err(err) => { + if let client::Retry::After(d) = dlg.http_error(&err) { + sleep(d).await; + continue; + } + dlg.finished(false); + return Err(client::Error::HttpError(err)) + } + Ok(mut res) => { + if !res.status().is_success() { + let res_body_string = client::get_body_as_string(res.body_mut()).await; + let (parts, _) = res.into_parts(); + let body = hyper::Body::from(res_body_string.clone()); + let restored_response = hyper::Response::from_parts(parts, body); + + let server_response = json::from_str::(&res_body_string).ok(); + + if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { + sleep(d).await; + continue; + } + + dlg.finished(false); + + return match server_response { + Some(error_value) => Err(client::Error::BadRequest(error_value)), + None => Err(client::Error::Failure(restored_response)), + } + } + if protocol == client::UploadProtocol::Resumable { + let size = reader.seek(io::SeekFrom::End(0)).unwrap(); + reader.seek(io::SeekFrom::Start(0)).unwrap(); + if size > 2097152 { + return Err(client::Error::UploadSizeLimitExceeded(size, 2097152)) + } + let upload_result = { + let url_str = &res.headers().get("Location").expect("LOCATION header is part of protocol").to_str().unwrap(); + if upload_url_from_server { + dlg.store_upload_url(Some(url_str)); + } + + client::ResumableUploadHelper { + client: &self.hub.client, + delegate: dlg, + start_at: if upload_url_from_server { Some(0) } else { None }, + auth: &self.hub.auth, + user_agent: &self.hub._user_agent, + // TODO: Check this assumption + auth_header: format!("Bearer {}", token.ok_or_else(|| client::Error::MissingToken("resumable upload requires token".into()))?.as_str()), + url: url_str, + reader: &mut reader, + media_type: reader_mime_type.clone(), + content_length: size + }.upload().await + }; + match upload_result { + None => { + dlg.finished(false); + return Err(client::Error::Cancelled) + } + Some(Err(err)) => { + dlg.finished(false); + return Err(client::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(client::Error::Failure(res)) + } + } + } + } + let result_value = { + let res_body_string = client::get_body_as_string(res.body_mut()).await; + + match json::from_str(&res_body_string) { + Ok(decoded) => (res, decoded), + Err(err) => { + dlg.response_json_decode_error(&res_body_string, &err); + return Err(client::Error::JsonDecodeError(res_body_string, err)); + } + } + }; + + dlg.finished(true); + return Ok(result_value) + } + } + } + } + + /// 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(...)`. + /// + /// * *multipart*: yes + /// * *max size*: 2097152 + /// * *valid mime types*: 'image/jpeg', 'image/png' and 'application/octet-stream' + pub async fn upload_resumable(self, resumeable_stream: RS, mime_type: mime::Mime) -> client::Result<(hyper::Response, ThumbnailSetResponse)> + where RS: client::ReadSeek { + self.doit(resumeable_stream, mime_type, client::UploadProtocol::Resumable).await + } + /// Upload media all at once. + /// If the upload fails for whichever reason, all progress is lost. + /// + /// * *multipart*: yes + /// * *max size*: 2097152 + /// * *valid mime types*: 'image/jpeg', 'image/png' and 'application/octet-stream' + pub async fn upload(self, stream: RS, mime_type: mime::Mime) -> client::Result<(hyper::Response, ThumbnailSetResponse)> + where RS: client::ReadSeek { + self.doit(stream, mime_type, client::UploadProtocol::Simple).await + } + + /// Returns the Thumbnail with the given video IDs for Stubby or Apiary. + /// + /// Sets the *video 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 video_id(mut self, new_value: &str) -> ThumbnailSetCall<'a, S> { + self._video_id = new_value.to_string(); + self + } + /// *Note:* This parameter is intended exclusively for YouTube content partners. The *onBehalfOfContentOwner* parameter indicates that the request's authorization credentials identify a YouTube CMS user who is acting on behalf of the content owner specified in the parameter value. This parameter is intended for YouTube content partners that own and manage many different YouTube channels. It allows content owners to authenticate once and get access to all their video and channel data, without having to provide authentication credentials for each individual channel. The actual CMS account that the user authenticates with must be linked to the specified YouTube content owner. + /// + /// Sets the *on behalf of content owner* query property to the given value. + pub fn on_behalf_of_content_owner(mut self, new_value: &str) -> ThumbnailSetCall<'a, S> { + self._on_behalf_of_content_owner = 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. + /// + /// ````text + /// It should be used to handle progress information, and to implement a certain level of resilience. + /// ```` + /// + /// Sets the *delegate* property to the given value. + pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> ThumbnailSetCall<'a, S> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not be used to set any of the known parameters + /// which have their own setter method. If done anyway, the request will fail. + /// + /// # Additional Parameters + /// + /// * *$.xgafv* (query-string) - V1 error format. + /// * *access_token* (query-string) - OAuth access token. + /// * *alt* (query-string) - Data format for response. + /// * *callback* (query-string) - JSONP + /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. + /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. + /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. + /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. + /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. + /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). + /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). + pub fn param(mut self, name: T, value: T) -> ThumbnailSetCall<'a, S> + where T: AsRef { + self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); + self + } + + /// Identifies the authorization scope for the method you are building. + /// + /// Use this method to actively specify which scope should be used, instead of 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: St) -> ThumbnailSetCall<'a, S> + where St: AsRef { + self._scopes.insert(String::from(scope.as_ref())); + self + } + /// Identifies the authorization scope(s) for the method you are building. + /// + /// See [`Self::add_scope()`] for details. + pub fn add_scopes(mut self, scopes: I) -> ThumbnailSetCall<'a, S> + where I: IntoIterator, + St: AsRef { + self._scopes + .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); + self + } + + /// Removes all scopes, and no default scope will be used either. + /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] + /// for details). + pub fn clear_scopes(mut self) -> ThumbnailSetCall<'a, S> { + self._scopes.clear(); + self + } +} + + +/// Retrieves a list of resources, possibly filtered. +/// +/// A builder for the *list* method supported by a *videoAbuseReportReason* resource. +/// It is not used directly, but through a [`VideoAbuseReportReasonMethods`] instance. +/// +/// **Settable Parts** +/// +/// * *id* +/// * *snippet* +/// +/// # Scopes +/// +/// You will need authorization for at least one of the following scopes to make a valid call, possibly depending on *parts*: +/// +/// * *https://www.googleapis.com/auth/youtube* +/// * *https://www.googleapis.com/auth/youtube.force-ssl* +/// * *https://www.googleapis.com/auth/youtube.readonly* +/// +/// The default scope will be `Scope::Readonly`. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate hyper_rustls; +/// # extern crate google_youtube3 as youtube3; +/// # async fn dox() { +/// # use std::default::Default; +/// # use youtube3::{YouTube, oauth2, hyper, hyper_rustls, chrono, FieldMask}; +/// +/// # let secret: oauth2::ApplicationSecret = Default::default(); +/// # let auth = oauth2::InstalledFlowAuthenticator::builder( +/// # secret, +/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, +/// # ).build().await.unwrap(); +/// # let mut hub = YouTube::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().unwrap().https_or_http().enable_http1().build()), auth); +/// // You can configure optional parameters by calling the respective setters at will, and +/// // execute the final call using `doit()`. +/// // Values shown here are possibly random and not representative ! +/// let result = hub.video_abuse_report_reasons().list(&vec!["no".into()]) +/// .hl("justo") +/// .doit().await; +/// # } +/// ``` +pub struct VideoAbuseReportReasonListCall<'a, S> + where S: 'a { + + pub(super) hub: &'a YouTube, + pub(super) _part: Vec, + pub(super) _hl: Option, + pub(super) _delegate: Option<&'a mut dyn client::Delegate>, + pub(super) _additional_params: HashMap, + pub(super) _scopes: BTreeSet +} + +impl<'a, S> client::CallBuilder for VideoAbuseReportReasonListCall<'a, S> {} + +impl<'a, S> VideoAbuseReportReasonListCall<'a, S> +where + S: tower_service::Service + Clone + Send + Sync + 'static, + S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, + S::Future: Send + Unpin + 'static, + S::Error: Into>, +{ + + + /// Perform the operation you have build so far. + pub async fn doit(mut self) -> client::Result<(hyper::Response, VideoAbuseReportReasonListResponse)> { + use std::io::{Read, Seek}; + use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; + use client::{ToParts, url::Params}; + use std::borrow::Cow; + + let mut dd = client::DefaultDelegate; + let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd); + dlg.begin(client::MethodInfo { id: "youtube.videoAbuseReportReasons.list", + http_method: hyper::Method::GET }); + + for &field in ["alt", "part", "hl"].iter() { + if self._additional_params.contains_key(field) { + dlg.finished(false); + return Err(client::Error::FieldClash(field)); + } + } + + let mut params = Params::with_capacity(4 + self._additional_params.len()); + if self._part.len() > 0 { + for f in self._part.iter() { + params.push("part", f); + } + } + if let Some(value) = self._hl.as_ref() { + params.push("hl", value); + } + + params.extend(self._additional_params.iter()); + + params.push("alt", "json"); + let mut url = self.hub._base_url.clone() + "youtube/v3/videoAbuseReportReasons"; + if self._scopes.is_empty() { + self._scopes.insert(Scope::Readonly.as_ref().to_string()); + } + + + let url = params.parse_with_url(&url); + + + + loop { + let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]).await { + Ok(token) => token, + Err(e) => { + match dlg.token(e) { + Ok(token) => token, + Err(e) => { + dlg.finished(false); + return Err(client::Error::MissingToken(e)); + } + } + } + }; + let mut req_result = { + let client = &self.hub.client; + dlg.pre_request(); + let mut req_builder = hyper::Request::builder() + .method(hyper::Method::GET) + .uri(url.as_str()) + .header(USER_AGENT, self.hub._user_agent.clone()); + + if let Some(token) = token.as_ref() { + req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); + } + + + let request = req_builder + .header(CONTENT_LENGTH, 0_u64) + .body(hyper::body::Body::empty()); + + client.request(request.unwrap()).await + + }; + + match req_result { + Err(err) => { + if let client::Retry::After(d) = dlg.http_error(&err) { + sleep(d).await; + continue; + } + dlg.finished(false); + return Err(client::Error::HttpError(err)) + } + Ok(mut res) => { + if !res.status().is_success() { + let res_body_string = client::get_body_as_string(res.body_mut()).await; + let (parts, _) = res.into_parts(); + let body = hyper::Body::from(res_body_string.clone()); + let restored_response = hyper::Response::from_parts(parts, body); + + let server_response = json::from_str::(&res_body_string).ok(); + + if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { + sleep(d).await; + continue; + } + + dlg.finished(false); + + return match server_response { + Some(error_value) => Err(client::Error::BadRequest(error_value)), + None => Err(client::Error::Failure(restored_response)), + } + } + let result_value = { + let res_body_string = client::get_body_as_string(res.body_mut()).await; + + match json::from_str(&res_body_string) { + Ok(decoded) => (res, decoded), + Err(err) => { + dlg.response_json_decode_error(&res_body_string, &err); + return Err(client::Error::JsonDecodeError(res_body_string, err)); + } + } + }; + + dlg.finished(true); + return Ok(result_value) + } + } + } + } + + + /// The *part* parameter specifies the videoCategory resource parts that the API response will include. Supported values are id and snippet. + /// + /// Append the given value to the *part* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + /// + /// Even though the property as already been set when instantiating this call, + /// we provide this method for API completeness. + /// + /// **Settable Parts** + /// + /// * *id* + /// * *snippet* + pub fn add_part(mut self, new_value: &str) -> VideoAbuseReportReasonListCall<'a, S> { + self._part.push(new_value.to_string()); + self + } + /// + /// Sets the *hl* query property to the given value. + pub fn hl(mut self, new_value: &str) -> VideoAbuseReportReasonListCall<'a, S> { + self._hl = 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. + /// + /// ````text + /// It should be used to handle progress information, and to implement a certain level of resilience. + /// ```` + /// + /// Sets the *delegate* property to the given value. + pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> VideoAbuseReportReasonListCall<'a, S> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not be used to set any of the known parameters + /// which have their own setter method. If done anyway, the request will fail. + /// + /// # Additional Parameters + /// + /// * *$.xgafv* (query-string) - V1 error format. + /// * *access_token* (query-string) - OAuth access token. + /// * *alt* (query-string) - Data format for response. + /// * *callback* (query-string) - JSONP + /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. + /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. + /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. + /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. + /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. + /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). + /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). + pub fn param(mut self, name: T, value: T) -> VideoAbuseReportReasonListCall<'a, S> + where T: AsRef { + self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); + self + } + + /// Identifies the authorization scope for the method you are building. + /// + /// Use this method to actively specify which scope should be used, instead of 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: St) -> VideoAbuseReportReasonListCall<'a, S> + where St: AsRef { + self._scopes.insert(String::from(scope.as_ref())); + self + } + /// Identifies the authorization scope(s) for the method you are building. + /// + /// See [`Self::add_scope()`] for details. + pub fn add_scopes(mut self, scopes: I) -> VideoAbuseReportReasonListCall<'a, S> + where I: IntoIterator, + St: AsRef { + self._scopes + .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); + self + } + + /// Removes all scopes, and no default scope will be used either. + /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] + /// for details). + pub fn clear_scopes(mut self) -> VideoAbuseReportReasonListCall<'a, S> { + self._scopes.clear(); + self + } +} + + +/// Retrieves a list of resources, possibly filtered. +/// +/// A builder for the *list* method supported by a *videoCategory* resource. +/// It is not used directly, but through a [`VideoCategoryMethods`] instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate hyper_rustls; +/// # extern crate google_youtube3 as youtube3; +/// # async fn dox() { +/// # use std::default::Default; +/// # use youtube3::{YouTube, oauth2, hyper, hyper_rustls, chrono, FieldMask}; +/// +/// # let secret: oauth2::ApplicationSecret = Default::default(); +/// # let auth = oauth2::InstalledFlowAuthenticator::builder( +/// # secret, +/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, +/// # ).build().await.unwrap(); +/// # let mut hub = YouTube::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().unwrap().https_or_http().enable_http1().build()), auth); +/// // You can configure optional parameters by calling the respective setters at will, and +/// // execute the final call using `doit()`. +/// // Values shown here are possibly random and not representative ! +/// let result = hub.video_categories().list(&vec!["sadipscing".into()]) +/// .region_code("diam") +/// .add_id("sea") +/// .hl("ipsum") +/// .doit().await; +/// # } +/// ``` +pub struct VideoCategoryListCall<'a, S> + where S: 'a { + + pub(super) hub: &'a YouTube, + pub(super) _part: Vec, + pub(super) _region_code: Option, + pub(super) _id: Vec, + pub(super) _hl: Option, + pub(super) _delegate: Option<&'a mut dyn client::Delegate>, + pub(super) _additional_params: HashMap, + pub(super) _scopes: BTreeSet +} + +impl<'a, S> client::CallBuilder for VideoCategoryListCall<'a, S> {} + +impl<'a, S> VideoCategoryListCall<'a, S> +where + S: tower_service::Service + Clone + Send + Sync + 'static, + S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, + S::Future: Send + Unpin + 'static, + S::Error: Into>, +{ + + + /// Perform the operation you have build so far. + pub async fn doit(mut self) -> client::Result<(hyper::Response, VideoCategoryListResponse)> { + use std::io::{Read, Seek}; + use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; + use client::{ToParts, url::Params}; + use std::borrow::Cow; + + let mut dd = client::DefaultDelegate; + let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd); + dlg.begin(client::MethodInfo { id: "youtube.videoCategories.list", + http_method: hyper::Method::GET }); + + for &field in ["alt", "part", "regionCode", "id", "hl"].iter() { + if self._additional_params.contains_key(field) { + dlg.finished(false); + return Err(client::Error::FieldClash(field)); + } + } + + let mut params = Params::with_capacity(6 + self._additional_params.len()); + if self._part.len() > 0 { + for f in self._part.iter() { + params.push("part", f); + } + } + if let Some(value) = self._region_code.as_ref() { + params.push("regionCode", value); + } + if self._id.len() > 0 { + for f in self._id.iter() { + params.push("id", f); + } + } + if let Some(value) = self._hl.as_ref() { + params.push("hl", value); + } + + params.extend(self._additional_params.iter()); + + params.push("alt", "json"); + let mut url = self.hub._base_url.clone() + "youtube/v3/videoCategories"; + if self._scopes.is_empty() { + self._scopes.insert(Scope::Readonly.as_ref().to_string()); + } + + + let url = params.parse_with_url(&url); + + + + loop { + let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]).await { + Ok(token) => token, + Err(e) => { + match dlg.token(e) { + Ok(token) => token, + Err(e) => { + dlg.finished(false); + return Err(client::Error::MissingToken(e)); + } + } + } + }; + let mut req_result = { + let client = &self.hub.client; + dlg.pre_request(); + let mut req_builder = hyper::Request::builder() + .method(hyper::Method::GET) + .uri(url.as_str()) + .header(USER_AGENT, self.hub._user_agent.clone()); + + if let Some(token) = token.as_ref() { + req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); + } + + + let request = req_builder + .header(CONTENT_LENGTH, 0_u64) + .body(hyper::body::Body::empty()); + + client.request(request.unwrap()).await + + }; + + match req_result { + Err(err) => { + if let client::Retry::After(d) = dlg.http_error(&err) { + sleep(d).await; + continue; + } + dlg.finished(false); + return Err(client::Error::HttpError(err)) + } + Ok(mut res) => { + if !res.status().is_success() { + let res_body_string = client::get_body_as_string(res.body_mut()).await; + let (parts, _) = res.into_parts(); + let body = hyper::Body::from(res_body_string.clone()); + let restored_response = hyper::Response::from_parts(parts, body); + + let server_response = json::from_str::(&res_body_string).ok(); + + if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { + sleep(d).await; + continue; + } + + dlg.finished(false); + + return match server_response { + Some(error_value) => Err(client::Error::BadRequest(error_value)), + None => Err(client::Error::Failure(restored_response)), + } + } + let result_value = { + let res_body_string = client::get_body_as_string(res.body_mut()).await; + + match json::from_str(&res_body_string) { + Ok(decoded) => (res, decoded), + Err(err) => { + dlg.response_json_decode_error(&res_body_string, &err); + return Err(client::Error::JsonDecodeError(res_body_string, err)); + } + } + }; + + dlg.finished(true); + return Ok(result_value) + } + } + } + } + + + /// The *part* parameter specifies the videoCategory resource properties that the API response will include. Set the parameter value to snippet. + /// + /// Append the given value to the *part* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + /// + /// Even though the property as already been set when instantiating this call, + /// we provide this method for API completeness. + pub fn add_part(mut self, new_value: &str) -> VideoCategoryListCall<'a, S> { + self._part.push(new_value.to_string()); + self + } + /// + /// Sets the *region code* query property to the given value. + pub fn region_code(mut self, new_value: &str) -> VideoCategoryListCall<'a, S> { + self._region_code = Some(new_value.to_string()); + self + } + /// Returns the video categories with the given IDs for Stubby or Apiary. + /// + /// Append the given value to the *id* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + pub fn add_id(mut self, new_value: &str) -> VideoCategoryListCall<'a, S> { + self._id.push(new_value.to_string()); + self + } + /// + /// Sets the *hl* query property to the given value. + pub fn hl(mut self, new_value: &str) -> VideoCategoryListCall<'a, S> { + self._hl = 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. + /// + /// ````text + /// It should be used to handle progress information, and to implement a certain level of resilience. + /// ```` + /// + /// Sets the *delegate* property to the given value. + pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> VideoCategoryListCall<'a, S> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not be used to set any of the known parameters + /// which have their own setter method. If done anyway, the request will fail. + /// + /// # Additional Parameters + /// + /// * *$.xgafv* (query-string) - V1 error format. + /// * *access_token* (query-string) - OAuth access token. + /// * *alt* (query-string) - Data format for response. + /// * *callback* (query-string) - JSONP + /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. + /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. + /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. + /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. + /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. + /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). + /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). + pub fn param(mut self, name: T, value: T) -> VideoCategoryListCall<'a, S> + where T: AsRef { + self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); + self + } + + /// Identifies the authorization scope for the method you are building. + /// + /// Use this method to actively specify which scope should be used, instead of 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: St) -> VideoCategoryListCall<'a, S> + where St: AsRef { + self._scopes.insert(String::from(scope.as_ref())); + self + } + /// Identifies the authorization scope(s) for the method you are building. + /// + /// See [`Self::add_scope()`] for details. + pub fn add_scopes(mut self, scopes: I) -> VideoCategoryListCall<'a, S> + where I: IntoIterator, + St: AsRef { + self._scopes + .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); + self + } + + /// Removes all scopes, and no default scope will be used either. + /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] + /// for details). + pub fn clear_scopes(mut self) -> VideoCategoryListCall<'a, S> { + self._scopes.clear(); + self + } +} + + +/// Deletes a resource. +/// +/// A builder for the *delete* method supported by a *video* resource. +/// It is not used directly, but through a [`VideoMethods`] instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate hyper_rustls; +/// # extern crate google_youtube3 as youtube3; +/// # async fn dox() { +/// # use std::default::Default; +/// # use youtube3::{YouTube, oauth2, hyper, hyper_rustls, chrono, FieldMask}; +/// +/// # let secret: oauth2::ApplicationSecret = Default::default(); +/// # let auth = oauth2::InstalledFlowAuthenticator::builder( +/// # secret, +/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, +/// # ).build().await.unwrap(); +/// # let mut hub = YouTube::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().unwrap().https_or_http().enable_http1().build()), auth); +/// // You can configure optional parameters by calling the respective setters at will, and +/// // execute the final call using `doit()`. +/// // Values shown here are possibly random and not representative ! +/// let result = hub.videos().delete("id") +/// .on_behalf_of_content_owner("gubergren") +/// .doit().await; +/// # } +/// ``` +pub struct VideoDeleteCall<'a, S> + where S: 'a { + + pub(super) hub: &'a YouTube, + pub(super) _id: String, + pub(super) _on_behalf_of_content_owner: Option, + pub(super) _delegate: Option<&'a mut dyn client::Delegate>, + pub(super) _additional_params: HashMap, + pub(super) _scopes: BTreeSet +} + +impl<'a, S> client::CallBuilder for VideoDeleteCall<'a, S> {} + +impl<'a, S> VideoDeleteCall<'a, S> +where + S: tower_service::Service + Clone + Send + Sync + 'static, + S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, + S::Future: Send + Unpin + 'static, + S::Error: Into>, +{ + + + /// Perform the operation you have build so far. + pub async fn doit(mut self) -> client::Result> { + use std::io::{Read, Seek}; + use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; + use client::{ToParts, url::Params}; + use std::borrow::Cow; + + let mut dd = client::DefaultDelegate; + let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd); + dlg.begin(client::MethodInfo { id: "youtube.videos.delete", + http_method: hyper::Method::DELETE }); + + for &field in ["id", "onBehalfOfContentOwner"].iter() { + if self._additional_params.contains_key(field) { + dlg.finished(false); + return Err(client::Error::FieldClash(field)); + } + } + + let mut params = Params::with_capacity(3 + self._additional_params.len()); + params.push("id", &self._id); + if let Some(value) = self._on_behalf_of_content_owner.as_ref() { + params.push("onBehalfOfContentOwner", value); + } + + params.extend(self._additional_params.iter()); + + let mut url = self.hub._base_url.clone() + "youtube/v3/videos"; + if self._scopes.is_empty() { + self._scopes.insert(Scope::Full.as_ref().to_string()); + } + + + let url = params.parse_with_url(&url); + + + + loop { + let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]).await { + Ok(token) => token, + Err(e) => { + match dlg.token(e) { + Ok(token) => token, + Err(e) => { + dlg.finished(false); + return Err(client::Error::MissingToken(e)); + } + } + } + }; + let mut req_result = { + let client = &self.hub.client; + dlg.pre_request(); + let mut req_builder = hyper::Request::builder() + .method(hyper::Method::DELETE) + .uri(url.as_str()) + .header(USER_AGENT, self.hub._user_agent.clone()); + + if let Some(token) = token.as_ref() { + req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); + } + + + let request = req_builder + .header(CONTENT_LENGTH, 0_u64) + .body(hyper::body::Body::empty()); + + client.request(request.unwrap()).await + + }; + + match req_result { + Err(err) => { + if let client::Retry::After(d) = dlg.http_error(&err) { + sleep(d).await; + continue; + } + dlg.finished(false); + return Err(client::Error::HttpError(err)) + } + Ok(mut res) => { + if !res.status().is_success() { + let res_body_string = client::get_body_as_string(res.body_mut()).await; + let (parts, _) = res.into_parts(); + let body = hyper::Body::from(res_body_string.clone()); + let restored_response = hyper::Response::from_parts(parts, body); + + let server_response = json::from_str::(&res_body_string).ok(); + + if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { + sleep(d).await; + continue; + } + + dlg.finished(false); + + return match server_response { + Some(error_value) => Err(client::Error::BadRequest(error_value)), + None => Err(client::Error::Failure(restored_response)), + } + } + let result_value = res; + + dlg.finished(true); + return Ok(result_value) + } + } + } + } + + + /// + /// 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) -> VideoDeleteCall<'a, S> { + self._id = new_value.to_string(); + self + } + /// *Note:* This parameter is intended exclusively for YouTube content partners. The *onBehalfOfContentOwner* parameter indicates that the request's authorization credentials identify a YouTube CMS user who is acting on behalf of the content owner specified in the parameter value. This parameter is intended for YouTube content partners that own and manage many different YouTube channels. It allows content owners to authenticate once and get access to all their video and channel data, without having to provide authentication credentials for each individual channel. The actual CMS account that the user authenticates with must be linked to the specified YouTube content owner. + /// + /// Sets the *on behalf of content owner* query property to the given value. + pub fn on_behalf_of_content_owner(mut self, new_value: &str) -> VideoDeleteCall<'a, S> { + self._on_behalf_of_content_owner = 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. + /// + /// ````text + /// It should be used to handle progress information, and to implement a certain level of resilience. + /// ```` + /// + /// Sets the *delegate* property to the given value. + pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> VideoDeleteCall<'a, S> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not be used to set any of the known parameters + /// which have their own setter method. If done anyway, the request will fail. + /// + /// # Additional Parameters + /// + /// * *$.xgafv* (query-string) - V1 error format. + /// * *access_token* (query-string) - OAuth access token. + /// * *alt* (query-string) - Data format for response. + /// * *callback* (query-string) - JSONP + /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. + /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. + /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. + /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. + /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. + /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). + /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). + pub fn param(mut self, name: T, value: T) -> VideoDeleteCall<'a, S> + where T: AsRef { + self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); + self + } + + /// Identifies the authorization scope for the method you are building. + /// + /// Use this method to actively specify which scope should be used, instead of 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: St) -> VideoDeleteCall<'a, S> + where St: AsRef { + self._scopes.insert(String::from(scope.as_ref())); + self + } + /// Identifies the authorization scope(s) for the method you are building. + /// + /// See [`Self::add_scope()`] for details. + pub fn add_scopes(mut self, scopes: I) -> VideoDeleteCall<'a, S> + where I: IntoIterator, + St: AsRef { + self._scopes + .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); + self + } + + /// Removes all scopes, and no default scope will be used either. + /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] + /// for details). + pub fn clear_scopes(mut self) -> VideoDeleteCall<'a, S> { + self._scopes.clear(); + self + } +} + + +/// Retrieves the ratings that the authorized user gave to a list of specified videos. +/// +/// A builder for the *getRating* method supported by a *video* resource. +/// It is not used directly, but through a [`VideoMethods`] instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate hyper_rustls; +/// # extern crate google_youtube3 as youtube3; +/// # async fn dox() { +/// # use std::default::Default; +/// # use youtube3::{YouTube, oauth2, hyper, hyper_rustls, chrono, FieldMask}; +/// +/// # let secret: oauth2::ApplicationSecret = Default::default(); +/// # let auth = oauth2::InstalledFlowAuthenticator::builder( +/// # secret, +/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, +/// # ).build().await.unwrap(); +/// # let mut hub = YouTube::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().unwrap().https_or_http().enable_http1().build()), auth); +/// // You can configure optional parameters by calling the respective setters at will, and +/// // execute the final call using `doit()`. +/// // Values shown here are possibly random and not representative ! +/// let result = hub.videos().get_rating(&vec!["ipsum".into()]) +/// .on_behalf_of_content_owner("no") +/// .doit().await; +/// # } +/// ``` +pub struct VideoGetRatingCall<'a, S> + where S: 'a { + + pub(super) hub: &'a YouTube, + pub(super) _id: Vec, + pub(super) _on_behalf_of_content_owner: Option, + pub(super) _delegate: Option<&'a mut dyn client::Delegate>, + pub(super) _additional_params: HashMap, + pub(super) _scopes: BTreeSet +} + +impl<'a, S> client::CallBuilder for VideoGetRatingCall<'a, S> {} + +impl<'a, S> VideoGetRatingCall<'a, S> +where + S: tower_service::Service + Clone + Send + Sync + 'static, + S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, + S::Future: Send + Unpin + 'static, + S::Error: Into>, +{ + + + /// Perform the operation you have build so far. + pub async fn doit(mut self) -> client::Result<(hyper::Response, VideoGetRatingResponse)> { + use std::io::{Read, Seek}; + use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; + use client::{ToParts, url::Params}; + use std::borrow::Cow; + + let mut dd = client::DefaultDelegate; + let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd); + dlg.begin(client::MethodInfo { id: "youtube.videos.getRating", + http_method: hyper::Method::GET }); + + for &field in ["alt", "id", "onBehalfOfContentOwner"].iter() { + if self._additional_params.contains_key(field) { + dlg.finished(false); + return Err(client::Error::FieldClash(field)); + } + } + + let mut params = Params::with_capacity(4 + self._additional_params.len()); + if self._id.len() > 0 { + for f in self._id.iter() { + params.push("id", f); + } + } + if let Some(value) = self._on_behalf_of_content_owner.as_ref() { + params.push("onBehalfOfContentOwner", value); + } + + params.extend(self._additional_params.iter()); + + params.push("alt", "json"); + let mut url = self.hub._base_url.clone() + "youtube/v3/videos/getRating"; + if self._scopes.is_empty() { + self._scopes.insert(Scope::Full.as_ref().to_string()); + } + + + let url = params.parse_with_url(&url); + + + + loop { + let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]).await { + Ok(token) => token, + Err(e) => { + match dlg.token(e) { + Ok(token) => token, + Err(e) => { + dlg.finished(false); + return Err(client::Error::MissingToken(e)); + } + } + } + }; + let mut req_result = { + let client = &self.hub.client; + dlg.pre_request(); + let mut req_builder = hyper::Request::builder() + .method(hyper::Method::GET) + .uri(url.as_str()) + .header(USER_AGENT, self.hub._user_agent.clone()); + + if let Some(token) = token.as_ref() { + req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); + } + + + let request = req_builder + .header(CONTENT_LENGTH, 0_u64) + .body(hyper::body::Body::empty()); + + client.request(request.unwrap()).await + + }; + + match req_result { + Err(err) => { + if let client::Retry::After(d) = dlg.http_error(&err) { + sleep(d).await; + continue; + } + dlg.finished(false); + return Err(client::Error::HttpError(err)) + } + Ok(mut res) => { + if !res.status().is_success() { + let res_body_string = client::get_body_as_string(res.body_mut()).await; + let (parts, _) = res.into_parts(); + let body = hyper::Body::from(res_body_string.clone()); + let restored_response = hyper::Response::from_parts(parts, body); + + let server_response = json::from_str::(&res_body_string).ok(); + + if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { + sleep(d).await; + continue; + } + + dlg.finished(false); + + return match server_response { + Some(error_value) => Err(client::Error::BadRequest(error_value)), + None => Err(client::Error::Failure(restored_response)), + } + } + let result_value = { + let res_body_string = client::get_body_as_string(res.body_mut()).await; + + match json::from_str(&res_body_string) { + Ok(decoded) => (res, decoded), + Err(err) => { + dlg.response_json_decode_error(&res_body_string, &err); + return Err(client::Error::JsonDecodeError(res_body_string, err)); + } + } + }; + + dlg.finished(true); + return Ok(result_value) + } + } + } + } + + + /// + /// Append the given value to the *id* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + /// + /// Even though the property as already been set when instantiating this call, + /// we provide this method for API completeness. + pub fn add_id(mut self, new_value: &str) -> VideoGetRatingCall<'a, S> { + self._id.push(new_value.to_string()); + self + } + /// *Note:* This parameter is intended exclusively for YouTube content partners. The *onBehalfOfContentOwner* parameter indicates that the request's authorization credentials identify a YouTube CMS user who is acting on behalf of the content owner specified in the parameter value. This parameter is intended for YouTube content partners that own and manage many different YouTube channels. It allows content owners to authenticate once and get access to all their video and channel data, without having to provide authentication credentials for each individual channel. The CMS account that the user authenticates with must be linked to the specified YouTube content owner. + /// + /// Sets the *on behalf of content owner* query property to the given value. + pub fn on_behalf_of_content_owner(mut self, new_value: &str) -> VideoGetRatingCall<'a, S> { + self._on_behalf_of_content_owner = 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. + /// + /// ````text + /// It should be used to handle progress information, and to implement a certain level of resilience. + /// ```` + /// + /// Sets the *delegate* property to the given value. + pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> VideoGetRatingCall<'a, S> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not be used to set any of the known parameters + /// which have their own setter method. If done anyway, the request will fail. + /// + /// # Additional Parameters + /// + /// * *$.xgafv* (query-string) - V1 error format. + /// * *access_token* (query-string) - OAuth access token. + /// * *alt* (query-string) - Data format for response. + /// * *callback* (query-string) - JSONP + /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. + /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. + /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. + /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. + /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. + /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). + /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). + pub fn param(mut self, name: T, value: T) -> VideoGetRatingCall<'a, S> + where T: AsRef { + self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); + self + } + + /// Identifies the authorization scope for the method you are building. + /// + /// Use this method to actively specify which scope should be used, instead of 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: St) -> VideoGetRatingCall<'a, S> + where St: AsRef { + self._scopes.insert(String::from(scope.as_ref())); + self + } + /// Identifies the authorization scope(s) for the method you are building. + /// + /// See [`Self::add_scope()`] for details. + pub fn add_scopes(mut self, scopes: I) -> VideoGetRatingCall<'a, S> + where I: IntoIterator, + St: AsRef { + self._scopes + .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); + self + } + + /// Removes all scopes, and no default scope will be used either. + /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] + /// for details). + pub fn clear_scopes(mut self) -> VideoGetRatingCall<'a, S> { + self._scopes.clear(); + self + } +} + + +/// Inserts a new resource into this collection. +/// +/// A builder for the *insert* method supported by a *video* resource. +/// It is not used directly, but through a [`VideoMethods`] instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate hyper_rustls; +/// # extern crate google_youtube3 as youtube3; +/// use youtube3::api::Video; +/// use std::fs; +/// # async fn dox() { +/// # use std::default::Default; +/// # use youtube3::{YouTube, oauth2, hyper, hyper_rustls, chrono, FieldMask}; +/// +/// # let secret: oauth2::ApplicationSecret = Default::default(); +/// # let auth = oauth2::InstalledFlowAuthenticator::builder( +/// # secret, +/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, +/// # ).build().await.unwrap(); +/// # let mut hub = YouTube::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().unwrap().https_or_http().enable_http1().build()), auth); +/// // As the method needs a request, you would usually fill it with the desired information +/// // into the respective structure. Some of the parts shown here might not be applicable ! +/// // Values shown here are possibly random and not representative ! +/// let mut req = Video::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.videos().insert(req) +/// .stabilize(false) +/// .on_behalf_of_content_owner_channel("kasd") +/// .on_behalf_of_content_owner("amet") +/// .notify_subscribers(true) +/// .auto_levels(false) +/// .upload(fs::File::open("file.ext").unwrap(), "application/octet-stream".parse().unwrap()).await; +/// # } +/// ``` +pub struct VideoInsertCall<'a, S> + where S: 'a { + + pub(super) hub: &'a YouTube, + pub(super) _request: Video, + pub(super) _part: Vec, + pub(super) _stabilize: Option, + pub(super) _on_behalf_of_content_owner_channel: Option, + pub(super) _on_behalf_of_content_owner: Option, + pub(super) _notify_subscribers: Option, + pub(super) _auto_levels: Option, + pub(super) _delegate: Option<&'a mut dyn client::Delegate>, + pub(super) _additional_params: HashMap, + pub(super) _scopes: BTreeSet +} + +impl<'a, S> client::CallBuilder for VideoInsertCall<'a, S> {} + +impl<'a, S> VideoInsertCall<'a, S> +where + S: tower_service::Service + Clone + Send + Sync + 'static, + S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, + S::Future: Send + Unpin + 'static, + S::Error: Into>, +{ + + + /// Perform the operation you have build so far. + async fn doit(mut self, mut reader: RS, reader_mime_type: mime::Mime, protocol: client::UploadProtocol) -> client::Result<(hyper::Response, Video)> + where RS: client::ReadSeek { + use std::io::{Read, Seek}; + use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; + use client::{ToParts, url::Params}; + use std::borrow::Cow; + + let mut dd = client::DefaultDelegate; + let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd); + dlg.begin(client::MethodInfo { id: "youtube.videos.insert", + http_method: hyper::Method::POST }); + + for &field in ["alt", "part", "stabilize", "onBehalfOfContentOwnerChannel", "onBehalfOfContentOwner", "notifySubscribers", "autoLevels"].iter() { + if self._additional_params.contains_key(field) { + dlg.finished(false); + return Err(client::Error::FieldClash(field)); + } + } + + let mut params = Params::with_capacity(9 + self._additional_params.len()); + if self._part.is_empty() { + self._part.push(self._request.to_parts()); + } + if self._part.len() > 0 { + for f in self._part.iter() { + params.push("part", f); + } + } + if let Some(value) = self._stabilize.as_ref() { + params.push("stabilize", value.to_string()); + } + if let Some(value) = self._on_behalf_of_content_owner_channel.as_ref() { + params.push("onBehalfOfContentOwnerChannel", value); + } + if let Some(value) = self._on_behalf_of_content_owner.as_ref() { + params.push("onBehalfOfContentOwner", value); + } + if let Some(value) = self._notify_subscribers.as_ref() { + params.push("notifySubscribers", value.to_string()); + } + if let Some(value) = self._auto_levels.as_ref() { + params.push("autoLevels", value.to_string()); + } + + params.extend(self._additional_params.iter()); + + params.push("alt", "json"); + let (mut url, upload_type) = + if protocol == client::UploadProtocol::Resumable { + (self.hub._root_url.clone() + "resumable/upload/youtube/v3/videos", "resumable") + } else if protocol == client::UploadProtocol::Simple { + (self.hub._root_url.clone() + "upload/youtube/v3/videos", "multipart") + } else { + unreachable!() + }; + params.push("uploadType", upload_type); + if self._scopes.is_empty() { + self._scopes.insert(Scope::Full.as_ref().to_string()); + } + + + let url = params.parse_with_url(&url); + + let mut json_mime_type = mime::APPLICATION_JSON; + let mut request_value_reader = + { + let mut value = json::value::to_value(&self._request).expect("serde to work"); + client::remove_json_null_values(&mut value); + let mut dst = io::Cursor::new(Vec::with_capacity(128)); + json::to_writer(&mut dst, &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.get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]).await { + Ok(token) => token, + Err(e) => { + match dlg.token(e) { + Ok(token) => token, + Err(e) => { + dlg.finished(false); + return Err(client::Error::MissingToken(e)); + } + } + } + }; + 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; + Ok(hyper::Response::builder() + .status(hyper::StatusCode::OK) + .header("Location", upload_url.as_ref().unwrap().clone()) + .body(hyper::body::Body::empty()) + .unwrap()) + } else { + let mut mp_reader: client::MultiPartReader = Default::default(); + let (mut body_reader, content_type) = match protocol { + client::UploadProtocol::Simple => { + mp_reader.reserve_exact(2); + let size = reader.seek(io::SeekFrom::End(0)).unwrap(); + reader.seek(io::SeekFrom::Start(0)).unwrap(); + if size > 274877906944 { + return Err(client::Error::UploadSizeLimitExceeded(size, 274877906944)) + } + mp_reader.add_part(&mut request_value_reader, request_size, json_mime_type.clone()) + .add_part(&mut reader, size, reader_mime_type.clone()); + (&mut mp_reader as &mut (dyn io::Read + Send), client::MultiPartReader::mime_type()) + }, + _ => (&mut request_value_reader as &mut (dyn io::Read + Send), json_mime_type.clone()), + }; + let client = &self.hub.client; + dlg.pre_request(); + let mut req_builder = hyper::Request::builder() + .method(hyper::Method::POST) + .uri(url.as_str()) + .header(USER_AGENT, self.hub._user_agent.clone()); + + if let Some(token) = token.as_ref() { + req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); + } + + upload_url_from_server = true; + if protocol == client::UploadProtocol::Resumable { + req_builder = req_builder.header("X-Upload-Content-Type", format!("{}", reader_mime_type)); + } + + let mut body_reader_bytes = vec![]; + body_reader.read_to_end(&mut body_reader_bytes).unwrap(); + let request = req_builder + .header(CONTENT_TYPE, content_type.to_string()) + .body(hyper::body::Body::from(body_reader_bytes)); + + client.request(request.unwrap()).await + + } + }; + + match req_result { + Err(err) => { + if let client::Retry::After(d) = dlg.http_error(&err) { + sleep(d).await; + continue; + } + dlg.finished(false); + return Err(client::Error::HttpError(err)) + } + Ok(mut res) => { + if !res.status().is_success() { + let res_body_string = client::get_body_as_string(res.body_mut()).await; + let (parts, _) = res.into_parts(); + let body = hyper::Body::from(res_body_string.clone()); + let restored_response = hyper::Response::from_parts(parts, body); + + let server_response = json::from_str::(&res_body_string).ok(); + + if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { + sleep(d).await; + continue; + } + + dlg.finished(false); + + return match server_response { + Some(error_value) => Err(client::Error::BadRequest(error_value)), + None => Err(client::Error::Failure(restored_response)), + } + } + if protocol == client::UploadProtocol::Resumable { + let size = reader.seek(io::SeekFrom::End(0)).unwrap(); + reader.seek(io::SeekFrom::Start(0)).unwrap(); + if size > 274877906944 { + return Err(client::Error::UploadSizeLimitExceeded(size, 274877906944)) + } + let upload_result = { + let url_str = &res.headers().get("Location").expect("LOCATION header is part of protocol").to_str().unwrap(); + if upload_url_from_server { + dlg.store_upload_url(Some(url_str)); + } + + client::ResumableUploadHelper { + client: &self.hub.client, + delegate: dlg, + start_at: if upload_url_from_server { Some(0) } else { None }, + auth: &self.hub.auth, + user_agent: &self.hub._user_agent, + // TODO: Check this assumption + auth_header: format!("Bearer {}", token.ok_or_else(|| client::Error::MissingToken("resumable upload requires token".into()))?.as_str()), + url: url_str, + reader: &mut reader, + media_type: reader_mime_type.clone(), + content_length: size + }.upload().await + }; + match upload_result { + None => { + dlg.finished(false); + return Err(client::Error::Cancelled) + } + Some(Err(err)) => { + dlg.finished(false); + return Err(client::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(client::Error::Failure(res)) + } + } + } + } + let result_value = { + let res_body_string = client::get_body_as_string(res.body_mut()).await; + + match json::from_str(&res_body_string) { + Ok(decoded) => (res, decoded), + Err(err) => { + dlg.response_json_decode_error(&res_body_string, &err); + return Err(client::Error::JsonDecodeError(res_body_string, err)); + } + } + }; + + dlg.finished(true); + return Ok(result_value) + } + } + } + } + + /// 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(...)`. + /// + /// * *multipart*: yes + /// * *max size*: 274877906944 + /// * *valid mime types*: 'video/*' and 'application/octet-stream' + pub async fn upload_resumable(self, resumeable_stream: RS, mime_type: mime::Mime) -> client::Result<(hyper::Response, Video)> + where RS: client::ReadSeek { + self.doit(resumeable_stream, mime_type, client::UploadProtocol::Resumable).await + } + /// Upload media all at once. + /// If the upload fails for whichever reason, all progress is lost. + /// + /// * *multipart*: yes + /// * *max size*: 274877906944 + /// * *valid mime types*: 'video/*' and 'application/octet-stream' + pub async fn upload(self, stream: RS, mime_type: mime::Mime) -> client::Result<(hyper::Response, Video)> + where RS: client::ReadSeek { + self.doit(stream, mime_type, client::UploadProtocol::Simple).await + } + + /// + /// Sets the *request* property to the given value. + /// + /// Even though the property as already been set when instantiating this call, + /// we provide this method for API completeness. + pub fn request(mut self, new_value: Video) -> VideoInsertCall<'a, S> { + self._request = new_value; + self + } + /// The *part* parameter serves two purposes in this operation. It identifies the properties that the write operation will set as well as the properties that the API response will include. Note that not all parts contain properties that can be set when inserting or updating a video. For example, the statistics object encapsulates statistics that YouTube calculates for a video and does not contain values that you can set or modify. If the parameter value specifies a part that does not contain mutable values, that part will still be included in the API response. + /// + /// Append the given value to the *part* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + /// + /// Even though the *parts* list is automatically derived from *Resource* passed in + /// during instantiation and indicates which values you are passing, the response would contain the very same parts. + /// This may not always be desirable, as you can obtain (newly generated) parts you cannot pass in, + /// like statistics that are generated server side. Therefore you should use this method to specify + /// the parts you provide in addition to the ones you want in the response. + pub fn add_part(mut self, new_value: &str) -> VideoInsertCall<'a, S> { + self._part.push(new_value.to_string()); + self + } + /// Should stabilize be applied to the upload. + /// + /// Sets the *stabilize* query property to the given value. + pub fn stabilize(mut self, new_value: bool) -> VideoInsertCall<'a, S> { + self._stabilize = Some(new_value); + self + } + /// This parameter can only be used in a properly authorized request. *Note:* This parameter is intended exclusively for YouTube content partners. The *onBehalfOfContentOwnerChannel* parameter specifies the YouTube channel ID of the channel to which a video is being added. This parameter is required when a request specifies a value for the onBehalfOfContentOwner parameter, and it can only be used in conjunction with that parameter. In addition, the request must be authorized using a CMS account that is linked to the content owner that the onBehalfOfContentOwner parameter specifies. Finally, the channel that the onBehalfOfContentOwnerChannel parameter value specifies must be linked to the content owner that the onBehalfOfContentOwner parameter specifies. This parameter is intended for YouTube content partners that own and manage many different YouTube channels. It allows content owners to authenticate once and perform actions on behalf of the channel specified in the parameter value, without having to provide authentication credentials for each separate channel. + /// + /// Sets the *on behalf of content owner channel* query property to the given value. + pub fn on_behalf_of_content_owner_channel(mut self, new_value: &str) -> VideoInsertCall<'a, S> { + self._on_behalf_of_content_owner_channel = Some(new_value.to_string()); + self + } + /// *Note:* This parameter is intended exclusively for YouTube content partners. The *onBehalfOfContentOwner* parameter indicates that the request's authorization credentials identify a YouTube CMS user who is acting on behalf of the content owner specified in the parameter value. This parameter is intended for YouTube content partners that own and manage many different YouTube channels. It allows content owners to authenticate once and get access to all their video and channel data, without having to provide authentication credentials for each individual channel. The CMS account that the user authenticates with must be linked to the specified YouTube content owner. + /// + /// Sets the *on behalf of content owner* query property to the given value. + pub fn on_behalf_of_content_owner(mut self, new_value: &str) -> VideoInsertCall<'a, S> { + self._on_behalf_of_content_owner = Some(new_value.to_string()); + self + } + /// Notify the channel subscribers about the new video. As default, the notification is enabled. + /// + /// Sets the *notify subscribers* query property to the given value. + pub fn notify_subscribers(mut self, new_value: bool) -> VideoInsertCall<'a, S> { + self._notify_subscribers = Some(new_value); + self + } + /// Should auto-levels be applied to the upload. + /// + /// Sets the *auto levels* query property to the given value. + pub fn auto_levels(mut self, new_value: bool) -> VideoInsertCall<'a, S> { + self._auto_levels = 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. + /// + /// ````text + /// It should be used to handle progress information, and to implement a certain level of resilience. + /// ```` + /// + /// Sets the *delegate* property to the given value. + pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> VideoInsertCall<'a, S> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not be used to set any of the known parameters + /// which have their own setter method. If done anyway, the request will fail. + /// + /// # Additional Parameters + /// + /// * *$.xgafv* (query-string) - V1 error format. + /// * *access_token* (query-string) - OAuth access token. + /// * *alt* (query-string) - Data format for response. + /// * *callback* (query-string) - JSONP + /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. + /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. + /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. + /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. + /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. + /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). + /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). + pub fn param(mut self, name: T, value: T) -> VideoInsertCall<'a, S> + where T: AsRef { + self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); + self + } + + /// Identifies the authorization scope for the method you are building. + /// + /// Use this method to actively specify which scope should be used, instead of 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: St) -> VideoInsertCall<'a, S> + where St: AsRef { + self._scopes.insert(String::from(scope.as_ref())); + self + } + /// Identifies the authorization scope(s) for the method you are building. + /// + /// See [`Self::add_scope()`] for details. + pub fn add_scopes(mut self, scopes: I) -> VideoInsertCall<'a, S> + where I: IntoIterator, + St: AsRef { + self._scopes + .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); + self + } + + /// Removes all scopes, and no default scope will be used either. + /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] + /// for details). + pub fn clear_scopes(mut self) -> VideoInsertCall<'a, S> { + self._scopes.clear(); + self + } +} + + +/// Retrieves a list of resources, possibly filtered. +/// +/// A builder for the *list* method supported by a *video* resource. +/// It is not used directly, but through a [`VideoMethods`] instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate hyper_rustls; +/// # extern crate google_youtube3 as youtube3; +/// # async fn dox() { +/// # use std::default::Default; +/// # use youtube3::{YouTube, oauth2, hyper, hyper_rustls, chrono, FieldMask}; +/// +/// # let secret: oauth2::ApplicationSecret = Default::default(); +/// # let auth = oauth2::InstalledFlowAuthenticator::builder( +/// # secret, +/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, +/// # ).build().await.unwrap(); +/// # let mut hub = YouTube::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().unwrap().https_or_http().enable_http1().build()), auth); +/// // You can configure optional parameters by calling the respective setters at will, and +/// // execute the final call using `doit()`. +/// // Values shown here are possibly random and not representative ! +/// let result = hub.videos().list(&vec!["sed".into()]) +/// .video_category_id("nonumy") +/// .region_code("sea") +/// .page_token("ipsum") +/// .on_behalf_of_content_owner("kasd") +/// .my_rating(&Default::default()) +/// .max_width(-21) +/// .max_results(84) +/// .max_height(-77) +/// .locale("erat") +/// .add_id("clita") +/// .hl("vero") +/// .chart(&Default::default()) +/// .doit().await; +/// # } +/// ``` +pub struct VideoListCall<'a, S> + where S: 'a { + + pub(super) hub: &'a YouTube, + pub(super) _part: Vec, + pub(super) _video_category_id: Option, + pub(super) _region_code: Option, + pub(super) _page_token: Option, + pub(super) _on_behalf_of_content_owner: Option, + pub(super) _my_rating: Option, + pub(super) _max_width: Option, + pub(super) _max_results: Option, + pub(super) _max_height: Option, + pub(super) _locale: Option, + pub(super) _id: Vec, + pub(super) _hl: Option, + pub(super) _chart: Option, + pub(super) _delegate: Option<&'a mut dyn client::Delegate>, + pub(super) _additional_params: HashMap, + pub(super) _scopes: BTreeSet +} + +impl<'a, S> client::CallBuilder for VideoListCall<'a, S> {} + +impl<'a, S> VideoListCall<'a, S> +where + S: tower_service::Service + Clone + Send + Sync + 'static, + S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, + S::Future: Send + Unpin + 'static, + S::Error: Into>, +{ + + + /// Perform the operation you have build so far. + pub async fn doit(mut self) -> client::Result<(hyper::Response, VideoListResponse)> { + use std::io::{Read, Seek}; + use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; + use client::{ToParts, url::Params}; + use std::borrow::Cow; + + let mut dd = client::DefaultDelegate; + let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd); + dlg.begin(client::MethodInfo { id: "youtube.videos.list", + http_method: hyper::Method::GET }); + + for &field in ["alt", "part", "videoCategoryId", "regionCode", "pageToken", "onBehalfOfContentOwner", "myRating", "maxWidth", "maxResults", "maxHeight", "locale", "id", "hl", "chart"].iter() { + if self._additional_params.contains_key(field) { + dlg.finished(false); + return Err(client::Error::FieldClash(field)); + } + } + + let mut params = Params::with_capacity(15 + self._additional_params.len()); + if self._part.len() > 0 { + for f in self._part.iter() { + params.push("part", f); + } + } + if let Some(value) = self._video_category_id.as_ref() { + params.push("videoCategoryId", value); + } + if let Some(value) = self._region_code.as_ref() { + params.push("regionCode", value); + } + if let Some(value) = self._page_token.as_ref() { + params.push("pageToken", value); + } + if let Some(value) = self._on_behalf_of_content_owner.as_ref() { + params.push("onBehalfOfContentOwner", value); + } + if let Some(value) = self._my_rating.as_ref() { + params.push("myRating", value); + } + if let Some(value) = self._max_width.as_ref() { + params.push("maxWidth", value.to_string()); + } + if let Some(value) = self._max_results.as_ref() { + params.push("maxResults", value.to_string()); + } + if let Some(value) = self._max_height.as_ref() { + params.push("maxHeight", value.to_string()); + } + if let Some(value) = self._locale.as_ref() { + params.push("locale", value); + } + if self._id.len() > 0 { + for f in self._id.iter() { + params.push("id", f); + } + } + if let Some(value) = self._hl.as_ref() { + params.push("hl", value); + } + if let Some(value) = self._chart.as_ref() { + params.push("chart", value); + } + + params.extend(self._additional_params.iter()); + + params.push("alt", "json"); + let mut url = self.hub._base_url.clone() + "youtube/v3/videos"; + if self._scopes.is_empty() { + self._scopes.insert(Scope::Readonly.as_ref().to_string()); + } + + + let url = params.parse_with_url(&url); + + + + loop { + let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]).await { + Ok(token) => token, + Err(e) => { + match dlg.token(e) { + Ok(token) => token, + Err(e) => { + dlg.finished(false); + return Err(client::Error::MissingToken(e)); + } + } + } + }; + let mut req_result = { + let client = &self.hub.client; + dlg.pre_request(); + let mut req_builder = hyper::Request::builder() + .method(hyper::Method::GET) + .uri(url.as_str()) + .header(USER_AGENT, self.hub._user_agent.clone()); + + if let Some(token) = token.as_ref() { + req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); + } + + + let request = req_builder + .header(CONTENT_LENGTH, 0_u64) + .body(hyper::body::Body::empty()); + + client.request(request.unwrap()).await + + }; + + match req_result { + Err(err) => { + if let client::Retry::After(d) = dlg.http_error(&err) { + sleep(d).await; + continue; + } + dlg.finished(false); + return Err(client::Error::HttpError(err)) + } + Ok(mut res) => { + if !res.status().is_success() { + let res_body_string = client::get_body_as_string(res.body_mut()).await; + let (parts, _) = res.into_parts(); + let body = hyper::Body::from(res_body_string.clone()); + let restored_response = hyper::Response::from_parts(parts, body); + + let server_response = json::from_str::(&res_body_string).ok(); + + if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { + sleep(d).await; + continue; + } + + dlg.finished(false); + + return match server_response { + Some(error_value) => Err(client::Error::BadRequest(error_value)), + None => Err(client::Error::Failure(restored_response)), + } + } + let result_value = { + let res_body_string = client::get_body_as_string(res.body_mut()).await; + + match json::from_str(&res_body_string) { + Ok(decoded) => (res, decoded), + Err(err) => { + dlg.response_json_decode_error(&res_body_string, &err); + return Err(client::Error::JsonDecodeError(res_body_string, err)); + } + } + }; + + dlg.finished(true); + return Ok(result_value) + } + } + } + } + + + /// The *part* parameter specifies a comma-separated list of one or more video resource properties that the API response will include. If the parameter identifies a property that contains child properties, the child properties will be included in the response. For example, in a video resource, the snippet property contains the channelId, title, description, tags, and categoryId properties. As such, if you set *part=snippet*, the API response will contain all of those properties. + /// + /// Append the given value to the *part* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + /// + /// Even though the property as already been set when instantiating this call, + /// we provide this method for API completeness. + pub fn add_part(mut self, new_value: &str) -> VideoListCall<'a, S> { + self._part.push(new_value.to_string()); + self + } + /// Use chart that is specific to the specified video category + /// + /// Sets the *video category id* query property to the given value. + pub fn video_category_id(mut self, new_value: &str) -> VideoListCall<'a, S> { + self._video_category_id = Some(new_value.to_string()); + self + } + /// Use a chart that is specific to the specified region + /// + /// Sets the *region code* query property to the given value. + pub fn region_code(mut self, new_value: &str) -> VideoListCall<'a, S> { + self._region_code = Some(new_value.to_string()); + self + } + /// The *pageToken* parameter identifies a specific page in the result set that should be returned. In an API response, the nextPageToken and prevPageToken properties identify other pages that could be retrieved. *Note:* This parameter is supported for use in conjunction with the myRating and chart parameters, but it is not supported for use in conjunction with the id parameter. + /// + /// Sets the *page token* query property to the given value. + pub fn page_token(mut self, new_value: &str) -> VideoListCall<'a, S> { + self._page_token = Some(new_value.to_string()); + self + } + /// *Note:* This parameter is intended exclusively for YouTube content partners. The *onBehalfOfContentOwner* parameter indicates that the request's authorization credentials identify a YouTube CMS user who is acting on behalf of the content owner specified in the parameter value. This parameter is intended for YouTube content partners that own and manage many different YouTube channels. It allows content owners to authenticate once and get access to all their video and channel data, without having to provide authentication credentials for each individual channel. The CMS account that the user authenticates with must be linked to the specified YouTube content owner. + /// + /// Sets the *on behalf of content owner* query property to the given value. + pub fn on_behalf_of_content_owner(mut self, new_value: &str) -> VideoListCall<'a, S> { + self._on_behalf_of_content_owner = Some(new_value.to_string()); + self + } + /// Return videos liked/disliked by the authenticated user. Does not support RateType.RATED_TYPE_NONE. + /// + /// Sets the *my rating* query property to the given value. + pub fn my_rating(mut self, new_value: &VideoMyRatingEnum) -> VideoListCall<'a, S> { + self._my_rating = Some(new_value.clone()); + self + } + /// Return the player with maximum height specified in + /// + /// Sets the *max width* query property to the given value. + pub fn max_width(mut self, new_value: i32) -> VideoListCall<'a, S> { + self._max_width = Some(new_value); + self + } + /// The *maxResults* parameter specifies the maximum number of items that should be returned in the result set. *Note:* This parameter is supported for use in conjunction with the myRating and chart parameters, but it is not supported for use in conjunction with the id parameter. + /// + /// Sets the *max results* query property to the given value. + pub fn max_results(mut self, new_value: u32) -> VideoListCall<'a, S> { + self._max_results = Some(new_value); + self + } + /// + /// Sets the *max height* query property to the given value. + pub fn max_height(mut self, new_value: i32) -> VideoListCall<'a, S> { + self._max_height = Some(new_value); + self + } + /// + /// Sets the *locale* query property to the given value. + pub fn locale(mut self, new_value: &str) -> VideoListCall<'a, S> { + self._locale = Some(new_value.to_string()); + self + } + /// Return videos with the given ids. + /// + /// Append the given value to the *id* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + pub fn add_id(mut self, new_value: &str) -> VideoListCall<'a, S> { + self._id.push(new_value.to_string()); + self + } + /// Stands for "host language". Specifies the localization language of the metadata to be filled into snippet.localized. The field is filled with the default metadata if there is no localization in the specified language. The parameter value must be a language code included in the list returned by the i18nLanguages.list method (e.g. en_US, es_MX). + /// + /// Sets the *hl* query property to the given value. + pub fn hl(mut self, new_value: &str) -> VideoListCall<'a, S> { + self._hl = Some(new_value.to_string()); + self + } + /// Return the videos that are in the specified chart. + /// + /// Sets the *chart* query property to the given value. + pub fn chart(mut self, new_value: &VideoChartEnum) -> VideoListCall<'a, S> { + self._chart = Some(new_value.clone()); + self + } + /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong + /// while executing the actual API request. + /// + /// ````text + /// It should be used to handle progress information, and to implement a certain level of resilience. + /// ```` + /// + /// Sets the *delegate* property to the given value. + pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> VideoListCall<'a, S> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not be used to set any of the known parameters + /// which have their own setter method. If done anyway, the request will fail. + /// + /// # Additional Parameters + /// + /// * *$.xgafv* (query-string) - V1 error format. + /// * *access_token* (query-string) - OAuth access token. + /// * *alt* (query-string) - Data format for response. + /// * *callback* (query-string) - JSONP + /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. + /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. + /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. + /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. + /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. + /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). + /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). + pub fn param(mut self, name: T, value: T) -> VideoListCall<'a, S> + where T: AsRef { + self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); + self + } + + /// Identifies the authorization scope for the method you are building. + /// + /// Use this method to actively specify which scope should be used, instead of 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: St) -> VideoListCall<'a, S> + where St: AsRef { + self._scopes.insert(String::from(scope.as_ref())); + self + } + /// Identifies the authorization scope(s) for the method you are building. + /// + /// See [`Self::add_scope()`] for details. + pub fn add_scopes(mut self, scopes: I) -> VideoListCall<'a, S> + where I: IntoIterator, + St: AsRef { + self._scopes + .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); + self + } + + /// Removes all scopes, and no default scope will be used either. + /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] + /// for details). + pub fn clear_scopes(mut self) -> VideoListCall<'a, S> { + self._scopes.clear(); + self + } +} + + +/// Adds a like or dislike rating to a video or removes a rating from a video. +/// +/// A builder for the *rate* method supported by a *video* resource. +/// It is not used directly, but through a [`VideoMethods`] instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate hyper_rustls; +/// # extern crate google_youtube3 as youtube3; +/// # async fn dox() { +/// # use std::default::Default; +/// # use youtube3::{YouTube, oauth2, hyper, hyper_rustls, chrono, FieldMask}; +/// +/// # let secret: oauth2::ApplicationSecret = Default::default(); +/// # let auth = oauth2::InstalledFlowAuthenticator::builder( +/// # secret, +/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, +/// # ).build().await.unwrap(); +/// # let mut hub = YouTube::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().unwrap().https_or_http().enable_http1().build()), auth); +/// // You can configure optional parameters by calling the respective setters at will, and +/// // execute the final call using `doit()`. +/// // Values shown here are possibly random and not representative ! +/// let result = hub.videos().rate("id", &Default::default()) +/// .doit().await; +/// # } +/// ``` +pub struct VideoRateCall<'a, S> + where S: 'a { + + pub(super) hub: &'a YouTube, + pub(super) _id: String, + pub(super) _rating: VideoRatingEnum, + pub(super) _delegate: Option<&'a mut dyn client::Delegate>, + pub(super) _additional_params: HashMap, + pub(super) _scopes: BTreeSet +} + +impl<'a, S> client::CallBuilder for VideoRateCall<'a, S> {} + +impl<'a, S> VideoRateCall<'a, S> +where + S: tower_service::Service + Clone + Send + Sync + 'static, + S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, + S::Future: Send + Unpin + 'static, + S::Error: Into>, +{ + + + /// Perform the operation you have build so far. + pub async fn doit(mut self) -> client::Result> { + use std::io::{Read, Seek}; + use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; + use client::{ToParts, url::Params}; + use std::borrow::Cow; + + let mut dd = client::DefaultDelegate; + let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd); + dlg.begin(client::MethodInfo { id: "youtube.videos.rate", + http_method: hyper::Method::POST }); + + for &field in ["id", "rating"].iter() { + if self._additional_params.contains_key(field) { + dlg.finished(false); + return Err(client::Error::FieldClash(field)); + } + } + + let mut params = Params::with_capacity(3 + self._additional_params.len()); + params.push("id", &self._id); + params.push("rating", &self._rating); + + params.extend(self._additional_params.iter()); + + let mut url = self.hub._base_url.clone() + "youtube/v3/videos/rate"; + if self._scopes.is_empty() { + self._scopes.insert(Scope::Full.as_ref().to_string()); + } + + + let url = params.parse_with_url(&url); + + + + loop { + let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]).await { + Ok(token) => token, + Err(e) => { + match dlg.token(e) { + Ok(token) => token, + Err(e) => { + dlg.finished(false); + return Err(client::Error::MissingToken(e)); + } + } + } + }; + let mut req_result = { + let client = &self.hub.client; + dlg.pre_request(); + let mut req_builder = hyper::Request::builder() + .method(hyper::Method::POST) + .uri(url.as_str()) + .header(USER_AGENT, self.hub._user_agent.clone()); + + if let Some(token) = token.as_ref() { + req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); + } + + + let request = req_builder + .header(CONTENT_LENGTH, 0_u64) + .body(hyper::body::Body::empty()); + + client.request(request.unwrap()).await + + }; + + match req_result { + Err(err) => { + if let client::Retry::After(d) = dlg.http_error(&err) { + sleep(d).await; + continue; + } + dlg.finished(false); + return Err(client::Error::HttpError(err)) + } + Ok(mut res) => { + if !res.status().is_success() { + let res_body_string = client::get_body_as_string(res.body_mut()).await; + let (parts, _) = res.into_parts(); + let body = hyper::Body::from(res_body_string.clone()); + let restored_response = hyper::Response::from_parts(parts, body); + + let server_response = json::from_str::(&res_body_string).ok(); + + if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { + sleep(d).await; + continue; + } + + dlg.finished(false); + + return match server_response { + Some(error_value) => Err(client::Error::BadRequest(error_value)), + None => Err(client::Error::Failure(restored_response)), + } + } + let result_value = res; + + dlg.finished(true); + return Ok(result_value) + } + } + } + } + + + /// + /// 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) -> VideoRateCall<'a, S> { + self._id = new_value.to_string(); + self + } + /// + /// Sets the *rating* 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 rating(mut self, new_value: &VideoRatingEnum) -> VideoRateCall<'a, S> { + self._rating = new_value.clone(); + self + } + /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong + /// while executing the actual API request. + /// + /// ````text + /// It should be used to handle progress information, and to implement a certain level of resilience. + /// ```` + /// + /// Sets the *delegate* property to the given value. + pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> VideoRateCall<'a, S> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not be used to set any of the known parameters + /// which have their own setter method. If done anyway, the request will fail. + /// + /// # Additional Parameters + /// + /// * *$.xgafv* (query-string) - V1 error format. + /// * *access_token* (query-string) - OAuth access token. + /// * *alt* (query-string) - Data format for response. + /// * *callback* (query-string) - JSONP + /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. + /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. + /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. + /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. + /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. + /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). + /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). + pub fn param(mut self, name: T, value: T) -> VideoRateCall<'a, S> + where T: AsRef { + self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); + self + } + + /// Identifies the authorization scope for the method you are building. + /// + /// Use this method to actively specify which scope should be used, instead of 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: St) -> VideoRateCall<'a, S> + where St: AsRef { + self._scopes.insert(String::from(scope.as_ref())); + self + } + /// Identifies the authorization scope(s) for the method you are building. + /// + /// See [`Self::add_scope()`] for details. + pub fn add_scopes(mut self, scopes: I) -> VideoRateCall<'a, S> + where I: IntoIterator, + St: AsRef { + self._scopes + .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); + self + } + + /// Removes all scopes, and no default scope will be used either. + /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] + /// for details). + pub fn clear_scopes(mut self) -> VideoRateCall<'a, S> { + self._scopes.clear(); + self + } +} + + +/// Report abuse for a video. +/// +/// A builder for the *reportAbuse* method supported by a *video* resource. +/// It is not used directly, but through a [`VideoMethods`] instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate hyper_rustls; +/// # extern crate google_youtube3 as youtube3; +/// use youtube3::api::VideoAbuseReport; +/// # async fn dox() { +/// # use std::default::Default; +/// # use youtube3::{YouTube, oauth2, hyper, hyper_rustls, chrono, FieldMask}; +/// +/// # let secret: oauth2::ApplicationSecret = Default::default(); +/// # let auth = oauth2::InstalledFlowAuthenticator::builder( +/// # secret, +/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, +/// # ).build().await.unwrap(); +/// # let mut hub = YouTube::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().unwrap().https_or_http().enable_http1().build()), auth); +/// // As the method needs a request, you would usually fill it with the desired information +/// // into the respective structure. Some of the parts shown here might not be applicable ! +/// // Values shown here are possibly random and not representative ! +/// let mut req = VideoAbuseReport::default(); +/// +/// // You can configure optional parameters by calling the respective setters at will, and +/// // execute the final call using `doit()`. +/// // Values shown here are possibly random and not representative ! +/// let result = hub.videos().report_abuse(req) +/// .on_behalf_of_content_owner("nonumy") +/// .doit().await; +/// # } +/// ``` +pub struct VideoReportAbuseCall<'a, S> + where S: 'a { + + pub(super) hub: &'a YouTube, + pub(super) _request: VideoAbuseReport, + pub(super) _on_behalf_of_content_owner: Option, + pub(super) _delegate: Option<&'a mut dyn client::Delegate>, + pub(super) _additional_params: HashMap, + pub(super) _scopes: BTreeSet +} + +impl<'a, S> client::CallBuilder for VideoReportAbuseCall<'a, S> {} + +impl<'a, S> VideoReportAbuseCall<'a, S> +where + S: tower_service::Service + Clone + Send + Sync + 'static, + S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, + S::Future: Send + Unpin + 'static, + S::Error: Into>, +{ + + + /// Perform the operation you have build so far. + pub async fn doit(mut self) -> client::Result> { + use std::io::{Read, Seek}; + use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; + use client::{ToParts, url::Params}; + use std::borrow::Cow; + + let mut dd = client::DefaultDelegate; + let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd); + dlg.begin(client::MethodInfo { id: "youtube.videos.reportAbuse", + http_method: hyper::Method::POST }); + + for &field in ["onBehalfOfContentOwner"].iter() { + if self._additional_params.contains_key(field) { + dlg.finished(false); + return Err(client::Error::FieldClash(field)); + } + } + + let mut params = Params::with_capacity(3 + self._additional_params.len()); + if let Some(value) = self._on_behalf_of_content_owner.as_ref() { + params.push("onBehalfOfContentOwner", value); + } + + params.extend(self._additional_params.iter()); + + let mut url = self.hub._base_url.clone() + "youtube/v3/videos/reportAbuse"; + if self._scopes.is_empty() { + self._scopes.insert(Scope::Full.as_ref().to_string()); + } + + + let url = params.parse_with_url(&url); + + let mut json_mime_type = mime::APPLICATION_JSON; + let mut request_value_reader = + { + let mut value = json::value::to_value(&self._request).expect("serde to work"); + client::remove_json_null_values(&mut value); + let mut dst = io::Cursor::new(Vec::with_capacity(128)); + json::to_writer(&mut dst, &value).unwrap(); + dst + }; + let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); + request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); + + + loop { + let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]).await { + Ok(token) => token, + Err(e) => { + match dlg.token(e) { + Ok(token) => token, + Err(e) => { + dlg.finished(false); + return Err(client::Error::MissingToken(e)); + } + } + } + }; + request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); + let mut req_result = { + let client = &self.hub.client; + dlg.pre_request(); + let mut req_builder = hyper::Request::builder() + .method(hyper::Method::POST) + .uri(url.as_str()) + .header(USER_AGENT, self.hub._user_agent.clone()); + + if let Some(token) = token.as_ref() { + req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); + } + + + let request = req_builder + .header(CONTENT_TYPE, json_mime_type.to_string()) + .header(CONTENT_LENGTH, request_size as u64) + .body(hyper::body::Body::from(request_value_reader.get_ref().clone())); + + client.request(request.unwrap()).await + + }; + + match req_result { + Err(err) => { + if let client::Retry::After(d) = dlg.http_error(&err) { + sleep(d).await; + continue; + } + dlg.finished(false); + return Err(client::Error::HttpError(err)) + } + Ok(mut res) => { + if !res.status().is_success() { + let res_body_string = client::get_body_as_string(res.body_mut()).await; + let (parts, _) = res.into_parts(); + let body = hyper::Body::from(res_body_string.clone()); + let restored_response = hyper::Response::from_parts(parts, body); + + let server_response = json::from_str::(&res_body_string).ok(); + + if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { + sleep(d).await; + continue; + } + + dlg.finished(false); + + return match server_response { + Some(error_value) => Err(client::Error::BadRequest(error_value)), + None => Err(client::Error::Failure(restored_response)), + } + } + 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: VideoAbuseReport) -> VideoReportAbuseCall<'a, S> { + self._request = new_value; + self + } + /// *Note:* This parameter is intended exclusively for YouTube content partners. The *onBehalfOfContentOwner* parameter indicates that the request's authorization credentials identify a YouTube CMS user who is acting on behalf of the content owner specified in the parameter value. This parameter is intended for YouTube content partners that own and manage many different YouTube channels. It allows content owners to authenticate once and get access to all their video and channel data, without having to provide authentication credentials for each individual channel. The CMS account that the user authenticates with must be linked to the specified YouTube content owner. + /// + /// Sets the *on behalf of content owner* query property to the given value. + pub fn on_behalf_of_content_owner(mut self, new_value: &str) -> VideoReportAbuseCall<'a, S> { + self._on_behalf_of_content_owner = 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. + /// + /// ````text + /// It should be used to handle progress information, and to implement a certain level of resilience. + /// ```` + /// + /// Sets the *delegate* property to the given value. + pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> VideoReportAbuseCall<'a, S> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not be used to set any of the known parameters + /// which have their own setter method. If done anyway, the request will fail. + /// + /// # Additional Parameters + /// + /// * *$.xgafv* (query-string) - V1 error format. + /// * *access_token* (query-string) - OAuth access token. + /// * *alt* (query-string) - Data format for response. + /// * *callback* (query-string) - JSONP + /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. + /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. + /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. + /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. + /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. + /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). + /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). + pub fn param(mut self, name: T, value: T) -> VideoReportAbuseCall<'a, S> + where T: AsRef { + self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); + self + } + + /// Identifies the authorization scope for the method you are building. + /// + /// Use this method to actively specify which scope should be used, instead of 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: St) -> VideoReportAbuseCall<'a, S> + where St: AsRef { + self._scopes.insert(String::from(scope.as_ref())); + self + } + /// Identifies the authorization scope(s) for the method you are building. + /// + /// See [`Self::add_scope()`] for details. + pub fn add_scopes(mut self, scopes: I) -> VideoReportAbuseCall<'a, S> + where I: IntoIterator, + St: AsRef { + self._scopes + .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); + self + } + + /// Removes all scopes, and no default scope will be used either. + /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] + /// for details). + pub fn clear_scopes(mut self) -> VideoReportAbuseCall<'a, S> { + self._scopes.clear(); + self + } +} + + +/// Updates an existing resource. +/// +/// A builder for the *update* method supported by a *video* resource. +/// It is not used directly, but through a [`VideoMethods`] instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate hyper_rustls; +/// # extern crate google_youtube3 as youtube3; +/// use youtube3::api::Video; +/// # async fn dox() { +/// # use std::default::Default; +/// # use youtube3::{YouTube, oauth2, hyper, hyper_rustls, chrono, FieldMask}; +/// +/// # let secret: oauth2::ApplicationSecret = Default::default(); +/// # let auth = oauth2::InstalledFlowAuthenticator::builder( +/// # secret, +/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, +/// # ).build().await.unwrap(); +/// # let mut hub = YouTube::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().unwrap().https_or_http().enable_http1().build()), auth); +/// // As the method needs a request, you would usually fill it with the desired information +/// // into the respective structure. Some of the parts shown here might not be applicable ! +/// // Values shown here are possibly random and not representative ! +/// let mut req = Video::default(); +/// +/// // You can configure optional parameters by calling the respective setters at will, and +/// // execute the final call using `doit()`. +/// // Values shown here are possibly random and not representative ! +/// let result = hub.videos().update(req) +/// .on_behalf_of_content_owner("erat") +/// .doit().await; +/// # } +/// ``` +pub struct VideoUpdateCall<'a, S> + where S: 'a { + + pub(super) hub: &'a YouTube, + pub(super) _request: Video, + pub(super) _part: Vec, + pub(super) _on_behalf_of_content_owner: Option, + pub(super) _delegate: Option<&'a mut dyn client::Delegate>, + pub(super) _additional_params: HashMap, + pub(super) _scopes: BTreeSet +} + +impl<'a, S> client::CallBuilder for VideoUpdateCall<'a, S> {} + +impl<'a, S> VideoUpdateCall<'a, S> +where + S: tower_service::Service + Clone + Send + Sync + 'static, + S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, + S::Future: Send + Unpin + 'static, + S::Error: Into>, +{ + + + /// Perform the operation you have build so far. + pub async fn doit(mut self) -> client::Result<(hyper::Response, Video)> { + use std::io::{Read, Seek}; + use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; + use client::{ToParts, url::Params}; + use std::borrow::Cow; + + let mut dd = client::DefaultDelegate; + let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd); + dlg.begin(client::MethodInfo { id: "youtube.videos.update", + http_method: hyper::Method::PUT }); + + for &field in ["alt", "part", "onBehalfOfContentOwner"].iter() { + if self._additional_params.contains_key(field) { + dlg.finished(false); + return Err(client::Error::FieldClash(field)); + } + } + + let mut params = Params::with_capacity(5 + self._additional_params.len()); + if self._part.is_empty() { + self._part.push(self._request.to_parts()); + } + if self._part.len() > 0 { + for f in self._part.iter() { + params.push("part", f); + } + } + if let Some(value) = self._on_behalf_of_content_owner.as_ref() { + params.push("onBehalfOfContentOwner", value); + } + + params.extend(self._additional_params.iter()); + + params.push("alt", "json"); + let mut url = self.hub._base_url.clone() + "youtube/v3/videos"; + if self._scopes.is_empty() { + self._scopes.insert(Scope::Full.as_ref().to_string()); + } + + + let url = params.parse_with_url(&url); + + let mut json_mime_type = mime::APPLICATION_JSON; + let mut request_value_reader = + { + let mut value = json::value::to_value(&self._request).expect("serde to work"); + client::remove_json_null_values(&mut value); + let mut dst = io::Cursor::new(Vec::with_capacity(128)); + json::to_writer(&mut dst, &value).unwrap(); + dst + }; + let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap(); + request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); + + + loop { + let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]).await { + Ok(token) => token, + Err(e) => { + match dlg.token(e) { + Ok(token) => token, + Err(e) => { + dlg.finished(false); + return Err(client::Error::MissingToken(e)); + } + } + } + }; + request_value_reader.seek(io::SeekFrom::Start(0)).unwrap(); + let mut req_result = { + let client = &self.hub.client; + dlg.pre_request(); + let mut req_builder = hyper::Request::builder() + .method(hyper::Method::PUT) + .uri(url.as_str()) + .header(USER_AGENT, self.hub._user_agent.clone()); + + if let Some(token) = token.as_ref() { + req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); + } + + + let request = req_builder + .header(CONTENT_TYPE, json_mime_type.to_string()) + .header(CONTENT_LENGTH, request_size as u64) + .body(hyper::body::Body::from(request_value_reader.get_ref().clone())); + + client.request(request.unwrap()).await + + }; + + match req_result { + Err(err) => { + if let client::Retry::After(d) = dlg.http_error(&err) { + sleep(d).await; + continue; + } + dlg.finished(false); + return Err(client::Error::HttpError(err)) + } + Ok(mut res) => { + if !res.status().is_success() { + let res_body_string = client::get_body_as_string(res.body_mut()).await; + let (parts, _) = res.into_parts(); + let body = hyper::Body::from(res_body_string.clone()); + let restored_response = hyper::Response::from_parts(parts, body); + + let server_response = json::from_str::(&res_body_string).ok(); + + if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { + sleep(d).await; + continue; + } + + dlg.finished(false); + + return match server_response { + Some(error_value) => Err(client::Error::BadRequest(error_value)), + None => Err(client::Error::Failure(restored_response)), + } + } + let result_value = { + let res_body_string = client::get_body_as_string(res.body_mut()).await; + + match json::from_str(&res_body_string) { + Ok(decoded) => (res, decoded), + Err(err) => { + dlg.response_json_decode_error(&res_body_string, &err); + return Err(client::Error::JsonDecodeError(res_body_string, err)); + } + } + }; + + dlg.finished(true); + return Ok(result_value) + } + } + } + } + + + /// + /// Sets the *request* property to the given value. + /// + /// Even though the property as already been set when instantiating this call, + /// we provide this method for API completeness. + pub fn request(mut self, new_value: Video) -> VideoUpdateCall<'a, S> { + self._request = new_value; + self + } + /// The *part* parameter serves two purposes in this operation. It identifies the properties that the write operation will set as well as the properties that the API response will include. Note that this method will override the existing values for all of the mutable properties that are contained in any parts that the parameter value specifies. For example, a video's privacy setting is contained in the status part. As such, if your request is updating a private video, and the request's part parameter value includes the status part, the video's privacy setting will be updated to whatever value the request body specifies. If the request body does not specify a value, the existing privacy setting will be removed and the video will revert to the default privacy setting. In addition, not all parts contain properties that can be set when inserting or updating a video. For example, the statistics object encapsulates statistics that YouTube calculates for a video and does not contain values that you can set or modify. If the parameter value specifies a part that does not contain mutable values, that part will still be included in the API response. + /// + /// Append the given value to the *part* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + /// + /// Even though the *parts* list is automatically derived from *Resource* passed in + /// during instantiation and indicates which values you are passing, the response would contain the very same parts. + /// This may not always be desirable, as you can obtain (newly generated) parts you cannot pass in, + /// like statistics that are generated server side. Therefore you should use this method to specify + /// the parts you provide in addition to the ones you want in the response. + pub fn add_part(mut self, new_value: &str) -> VideoUpdateCall<'a, S> { + self._part.push(new_value.to_string()); + self + } + /// *Note:* This parameter is intended exclusively for YouTube content partners. The *onBehalfOfContentOwner* parameter indicates that the request's authorization credentials identify a YouTube CMS user who is acting on behalf of the content owner specified in the parameter value. This parameter is intended for YouTube content partners that own and manage many different YouTube channels. It allows content owners to authenticate once and get access to all their video and channel data, without having to provide authentication credentials for each individual channel. The actual CMS account that the user authenticates with must be linked to the specified YouTube content owner. + /// + /// Sets the *on behalf of content owner* query property to the given value. + pub fn on_behalf_of_content_owner(mut self, new_value: &str) -> VideoUpdateCall<'a, S> { + self._on_behalf_of_content_owner = 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. + /// + /// ````text + /// It should be used to handle progress information, and to implement a certain level of resilience. + /// ```` + /// + /// Sets the *delegate* property to the given value. + pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> VideoUpdateCall<'a, S> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not be used to set any of the known parameters + /// which have their own setter method. If done anyway, the request will fail. + /// + /// # Additional Parameters + /// + /// * *$.xgafv* (query-string) - V1 error format. + /// * *access_token* (query-string) - OAuth access token. + /// * *alt* (query-string) - Data format for response. + /// * *callback* (query-string) - JSONP + /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. + /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. + /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. + /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. + /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. + /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). + /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). + pub fn param(mut self, name: T, value: T) -> VideoUpdateCall<'a, S> + where T: AsRef { + self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); + self + } + + /// Identifies the authorization scope for the method you are building. + /// + /// Use this method to actively specify which scope should be used, instead of 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: St) -> VideoUpdateCall<'a, S> + where St: AsRef { + self._scopes.insert(String::from(scope.as_ref())); + self + } + /// Identifies the authorization scope(s) for the method you are building. + /// + /// See [`Self::add_scope()`] for details. + pub fn add_scopes(mut self, scopes: I) -> VideoUpdateCall<'a, S> + where I: IntoIterator, + St: AsRef { + self._scopes + .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); + self + } + + /// Removes all scopes, and no default scope will be used either. + /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] + /// for details). + pub fn clear_scopes(mut self) -> VideoUpdateCall<'a, S> { + self._scopes.clear(); + self + } +} + + +/// Allows upload of watermark image and setting it for a channel. +/// +/// A builder for the *set* method supported by a *watermark* resource. +/// It is not used directly, but through a [`WatermarkMethods`] instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate hyper_rustls; +/// # extern crate google_youtube3 as youtube3; +/// use youtube3::api::InvideoBranding; +/// use std::fs; +/// # async fn dox() { +/// # use std::default::Default; +/// # use youtube3::{YouTube, oauth2, hyper, hyper_rustls, chrono, FieldMask}; +/// +/// # let secret: oauth2::ApplicationSecret = Default::default(); +/// # let auth = oauth2::InstalledFlowAuthenticator::builder( +/// # secret, +/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, +/// # ).build().await.unwrap(); +/// # let mut hub = YouTube::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().unwrap().https_or_http().enable_http1().build()), auth); +/// // As the method needs a request, you would usually fill it with the desired information +/// // into the respective structure. Some of the parts shown here might not be applicable ! +/// // Values shown here are possibly random and not representative ! +/// let mut req = InvideoBranding::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.watermarks().set(req, "channelId") +/// .on_behalf_of_content_owner("dolores") +/// .upload_resumable(fs::File::open("file.ext").unwrap(), "application/octet-stream".parse().unwrap()).await; +/// # } +/// ``` +pub struct WatermarkSetCall<'a, S> + where S: 'a { + + pub(super) hub: &'a YouTube, + pub(super) _request: InvideoBranding, + pub(super) _channel_id: String, + pub(super) _on_behalf_of_content_owner: Option, + pub(super) _delegate: Option<&'a mut dyn client::Delegate>, + pub(super) _additional_params: HashMap, + pub(super) _scopes: BTreeSet +} + +impl<'a, S> client::CallBuilder for WatermarkSetCall<'a, S> {} + +impl<'a, S> WatermarkSetCall<'a, S> +where + S: tower_service::Service + Clone + Send + Sync + 'static, + S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, + S::Future: Send + Unpin + 'static, + S::Error: Into>, +{ + + + /// Perform the operation you have build so far. + async fn doit(mut self, mut reader: RS, reader_mime_type: mime::Mime, protocol: client::UploadProtocol) -> client::Result> + where RS: client::ReadSeek { + use std::io::{Read, Seek}; + use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; + use client::{ToParts, url::Params}; + use std::borrow::Cow; + + let mut dd = client::DefaultDelegate; + let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd); + dlg.begin(client::MethodInfo { id: "youtube.watermarks.set", + http_method: hyper::Method::POST }); + + for &field in ["channelId", "onBehalfOfContentOwner"].iter() { + if self._additional_params.contains_key(field) { + dlg.finished(false); + return Err(client::Error::FieldClash(field)); + } + } + + let mut params = Params::with_capacity(4 + self._additional_params.len()); + params.push("channelId", &self._channel_id); + if let Some(value) = self._on_behalf_of_content_owner.as_ref() { + params.push("onBehalfOfContentOwner", value); + } + + params.extend(self._additional_params.iter()); + + let (mut url, upload_type) = + if protocol == client::UploadProtocol::Resumable { + (self.hub._root_url.clone() + "resumable/upload/youtube/v3/watermarks/set", "resumable") + } else if protocol == client::UploadProtocol::Simple { + (self.hub._root_url.clone() + "upload/youtube/v3/watermarks/set", "multipart") + } else { + unreachable!() + }; + params.push("uploadType", upload_type); + if self._scopes.is_empty() { + self._scopes.insert(Scope::Full.as_ref().to_string()); + } + + + let url = params.parse_with_url(&url); + + let mut json_mime_type = mime::APPLICATION_JSON; + let mut request_value_reader = + { + let mut value = json::value::to_value(&self._request).expect("serde to work"); + client::remove_json_null_values(&mut value); + let mut dst = io::Cursor::new(Vec::with_capacity(128)); + json::to_writer(&mut dst, &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.get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]).await { + Ok(token) => token, + Err(e) => { + match dlg.token(e) { + Ok(token) => token, + Err(e) => { + dlg.finished(false); + return Err(client::Error::MissingToken(e)); + } + } + } + }; + 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; + Ok(hyper::Response::builder() + .status(hyper::StatusCode::OK) + .header("Location", upload_url.as_ref().unwrap().clone()) + .body(hyper::body::Body::empty()) + .unwrap()) + } else { + let mut mp_reader: client::MultiPartReader = Default::default(); + let (mut body_reader, content_type) = match protocol { + client::UploadProtocol::Simple => { + mp_reader.reserve_exact(2); + let size = reader.seek(io::SeekFrom::End(0)).unwrap(); + reader.seek(io::SeekFrom::Start(0)).unwrap(); + if size > 10485760 { + return Err(client::Error::UploadSizeLimitExceeded(size, 10485760)) + } + mp_reader.add_part(&mut request_value_reader, request_size, json_mime_type.clone()) + .add_part(&mut reader, size, reader_mime_type.clone()); + (&mut mp_reader as &mut (dyn io::Read + Send), client::MultiPartReader::mime_type()) + }, + _ => (&mut request_value_reader as &mut (dyn io::Read + Send), json_mime_type.clone()), + }; + let client = &self.hub.client; + dlg.pre_request(); + let mut req_builder = hyper::Request::builder() + .method(hyper::Method::POST) + .uri(url.as_str()) + .header(USER_AGENT, self.hub._user_agent.clone()); + + if let Some(token) = token.as_ref() { + req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); + } + + upload_url_from_server = true; + if protocol == client::UploadProtocol::Resumable { + req_builder = req_builder.header("X-Upload-Content-Type", format!("{}", reader_mime_type)); + } + + let mut body_reader_bytes = vec![]; + body_reader.read_to_end(&mut body_reader_bytes).unwrap(); + let request = req_builder + .header(CONTENT_TYPE, content_type.to_string()) + .body(hyper::body::Body::from(body_reader_bytes)); + + client.request(request.unwrap()).await + + } + }; + + match req_result { + Err(err) => { + if let client::Retry::After(d) = dlg.http_error(&err) { + sleep(d).await; + continue; + } + dlg.finished(false); + return Err(client::Error::HttpError(err)) + } + Ok(mut res) => { + if !res.status().is_success() { + let res_body_string = client::get_body_as_string(res.body_mut()).await; + let (parts, _) = res.into_parts(); + let body = hyper::Body::from(res_body_string.clone()); + let restored_response = hyper::Response::from_parts(parts, body); + + let server_response = json::from_str::(&res_body_string).ok(); + + if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { + sleep(d).await; + continue; + } + + dlg.finished(false); + + return match server_response { + Some(error_value) => Err(client::Error::BadRequest(error_value)), + None => Err(client::Error::Failure(restored_response)), + } + } + if protocol == client::UploadProtocol::Resumable { + let size = reader.seek(io::SeekFrom::End(0)).unwrap(); + reader.seek(io::SeekFrom::Start(0)).unwrap(); + if size > 10485760 { + return Err(client::Error::UploadSizeLimitExceeded(size, 10485760)) + } + let upload_result = { + let url_str = &res.headers().get("Location").expect("LOCATION header is part of protocol").to_str().unwrap(); + if upload_url_from_server { + dlg.store_upload_url(Some(url_str)); + } + + client::ResumableUploadHelper { + client: &self.hub.client, + delegate: dlg, + start_at: if upload_url_from_server { Some(0) } else { None }, + auth: &self.hub.auth, + user_agent: &self.hub._user_agent, + // TODO: Check this assumption + auth_header: format!("Bearer {}", token.ok_or_else(|| client::Error::MissingToken("resumable upload requires token".into()))?.as_str()), + url: url_str, + reader: &mut reader, + media_type: reader_mime_type.clone(), + content_length: size + }.upload().await + }; + match upload_result { + None => { + dlg.finished(false); + return Err(client::Error::Cancelled) + } + Some(Err(err)) => { + dlg.finished(false); + return Err(client::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(client::Error::Failure(res)) + } + } + } + } + let result_value = res; + + dlg.finished(true); + return Ok(result_value) + } + } + } + } + + /// 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(...)`. + /// + /// * *multipart*: yes + /// * *max size*: 10485760 + /// * *valid mime types*: 'image/jpeg', 'image/png' and 'application/octet-stream' + pub async fn upload_resumable(self, resumeable_stream: RS, mime_type: mime::Mime) -> client::Result> + where RS: client::ReadSeek { + self.doit(resumeable_stream, mime_type, client::UploadProtocol::Resumable).await + } + /// Upload media all at once. + /// If the upload fails for whichever reason, all progress is lost. + /// + /// * *multipart*: yes + /// * *max size*: 10485760 + /// * *valid mime types*: 'image/jpeg', 'image/png' and 'application/octet-stream' + pub async fn upload(self, stream: RS, mime_type: mime::Mime) -> client::Result> + where RS: client::ReadSeek { + self.doit(stream, mime_type, client::UploadProtocol::Simple).await + } + + /// + /// Sets the *request* property to the given value. + /// + /// Even though the property as already been set when instantiating this call, + /// we provide this method for API completeness. + pub fn request(mut self, new_value: InvideoBranding) -> WatermarkSetCall<'a, S> { + self._request = new_value; + self + } + /// + /// Sets the *channel 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 channel_id(mut self, new_value: &str) -> WatermarkSetCall<'a, S> { + self._channel_id = new_value.to_string(); + self + } + /// *Note:* This parameter is intended exclusively for YouTube content partners. The *onBehalfOfContentOwner* parameter indicates that the request's authorization credentials identify a YouTube CMS user who is acting on behalf of the content owner specified in the parameter value. This parameter is intended for YouTube content partners that own and manage many different YouTube channels. It allows content owners to authenticate once and get access to all their video and channel data, without having to provide authentication credentials for each individual channel. The CMS account that the user authenticates with must be linked to the specified YouTube content owner. + /// + /// Sets the *on behalf of content owner* query property to the given value. + pub fn on_behalf_of_content_owner(mut self, new_value: &str) -> WatermarkSetCall<'a, S> { + self._on_behalf_of_content_owner = 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. + /// + /// ````text + /// It should be used to handle progress information, and to implement a certain level of resilience. + /// ```` + /// + /// Sets the *delegate* property to the given value. + pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> WatermarkSetCall<'a, S> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not be used to set any of the known parameters + /// which have their own setter method. If done anyway, the request will fail. + /// + /// # Additional Parameters + /// + /// * *$.xgafv* (query-string) - V1 error format. + /// * *access_token* (query-string) - OAuth access token. + /// * *alt* (query-string) - Data format for response. + /// * *callback* (query-string) - JSONP + /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. + /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. + /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. + /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. + /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. + /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). + /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). + pub fn param(mut self, name: T, value: T) -> WatermarkSetCall<'a, S> + where T: AsRef { + self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); + self + } + + /// Identifies the authorization scope for the method you are building. + /// + /// Use this method to actively specify which scope should be used, instead of 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: St) -> WatermarkSetCall<'a, S> + where St: AsRef { + self._scopes.insert(String::from(scope.as_ref())); + self + } + /// Identifies the authorization scope(s) for the method you are building. + /// + /// See [`Self::add_scope()`] for details. + pub fn add_scopes(mut self, scopes: I) -> WatermarkSetCall<'a, S> + where I: IntoIterator, + St: AsRef { + self._scopes + .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); + self + } + + /// Removes all scopes, and no default scope will be used either. + /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] + /// for details). + pub fn clear_scopes(mut self) -> WatermarkSetCall<'a, S> { + self._scopes.clear(); + self + } +} + + +/// Allows removal of channel watermark. +/// +/// A builder for the *unset* method supported by a *watermark* resource. +/// It is not used directly, but through a [`WatermarkMethods`] instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate hyper_rustls; +/// # extern crate google_youtube3 as youtube3; +/// # async fn dox() { +/// # use std::default::Default; +/// # use youtube3::{YouTube, oauth2, hyper, hyper_rustls, chrono, FieldMask}; +/// +/// # let secret: oauth2::ApplicationSecret = Default::default(); +/// # let auth = oauth2::InstalledFlowAuthenticator::builder( +/// # secret, +/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, +/// # ).build().await.unwrap(); +/// # let mut hub = YouTube::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().unwrap().https_or_http().enable_http1().build()), auth); +/// // You can configure optional parameters by calling the respective setters at will, and +/// // execute the final call using `doit()`. +/// // Values shown here are possibly random and not representative ! +/// let result = hub.watermarks().unset("channelId") +/// .on_behalf_of_content_owner("voluptua.") +/// .doit().await; +/// # } +/// ``` +pub struct WatermarkUnsetCall<'a, S> + where S: 'a { + + pub(super) hub: &'a YouTube, + pub(super) _channel_id: String, + pub(super) _on_behalf_of_content_owner: Option, + pub(super) _delegate: Option<&'a mut dyn client::Delegate>, + pub(super) _additional_params: HashMap, + pub(super) _scopes: BTreeSet +} + +impl<'a, S> client::CallBuilder for WatermarkUnsetCall<'a, S> {} + +impl<'a, S> WatermarkUnsetCall<'a, S> +where + S: tower_service::Service + Clone + Send + Sync + 'static, + S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, + S::Future: Send + Unpin + 'static, + S::Error: Into>, +{ + + + /// Perform the operation you have build so far. + pub async fn doit(mut self) -> client::Result> { + use std::io::{Read, Seek}; + use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; + use client::{ToParts, url::Params}; + use std::borrow::Cow; + + let mut dd = client::DefaultDelegate; + let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd); + dlg.begin(client::MethodInfo { id: "youtube.watermarks.unset", + http_method: hyper::Method::POST }); + + for &field in ["channelId", "onBehalfOfContentOwner"].iter() { + if self._additional_params.contains_key(field) { + dlg.finished(false); + return Err(client::Error::FieldClash(field)); + } + } + + let mut params = Params::with_capacity(3 + self._additional_params.len()); + params.push("channelId", &self._channel_id); + if let Some(value) = self._on_behalf_of_content_owner.as_ref() { + params.push("onBehalfOfContentOwner", value); + } + + params.extend(self._additional_params.iter()); + + let mut url = self.hub._base_url.clone() + "youtube/v3/watermarks/unset"; + if self._scopes.is_empty() { + self._scopes.insert(Scope::Full.as_ref().to_string()); + } + + + let url = params.parse_with_url(&url); + + + + loop { + let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::>()[..]).await { + Ok(token) => token, + Err(e) => { + match dlg.token(e) { + Ok(token) => token, + Err(e) => { + dlg.finished(false); + return Err(client::Error::MissingToken(e)); + } + } + } + }; + let mut req_result = { + let client = &self.hub.client; + dlg.pre_request(); + let mut req_builder = hyper::Request::builder() + .method(hyper::Method::POST) + .uri(url.as_str()) + .header(USER_AGENT, self.hub._user_agent.clone()); + + if let Some(token) = token.as_ref() { + req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token)); + } + + + let request = req_builder + .header(CONTENT_LENGTH, 0_u64) + .body(hyper::body::Body::empty()); + + client.request(request.unwrap()).await + + }; + + match req_result { + Err(err) => { + if let client::Retry::After(d) = dlg.http_error(&err) { + sleep(d).await; + continue; + } + dlg.finished(false); + return Err(client::Error::HttpError(err)) + } + Ok(mut res) => { + if !res.status().is_success() { + let res_body_string = client::get_body_as_string(res.body_mut()).await; + let (parts, _) = res.into_parts(); + let body = hyper::Body::from(res_body_string.clone()); + let restored_response = hyper::Response::from_parts(parts, body); + + let server_response = json::from_str::(&res_body_string).ok(); + + if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { + sleep(d).await; + continue; + } + + dlg.finished(false); + + return match server_response { + Some(error_value) => Err(client::Error::BadRequest(error_value)), + None => Err(client::Error::Failure(restored_response)), + } + } + let result_value = res; + + dlg.finished(true); + return Ok(result_value) + } + } + } + } + + + /// + /// Sets the *channel 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 channel_id(mut self, new_value: &str) -> WatermarkUnsetCall<'a, S> { + self._channel_id = new_value.to_string(); + self + } + /// *Note:* This parameter is intended exclusively for YouTube content partners. The *onBehalfOfContentOwner* parameter indicates that the request's authorization credentials identify a YouTube CMS user who is acting on behalf of the content owner specified in the parameter value. This parameter is intended for YouTube content partners that own and manage many different YouTube channels. It allows content owners to authenticate once and get access to all their video and channel data, without having to provide authentication credentials for each individual channel. The CMS account that the user authenticates with must be linked to the specified YouTube content owner. + /// + /// Sets the *on behalf of content owner* query property to the given value. + pub fn on_behalf_of_content_owner(mut self, new_value: &str) -> WatermarkUnsetCall<'a, S> { + self._on_behalf_of_content_owner = 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. + /// + /// ````text + /// It should be used to handle progress information, and to implement a certain level of resilience. + /// ```` + /// + /// Sets the *delegate* property to the given value. + pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> WatermarkUnsetCall<'a, S> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not be used to set any of the known parameters + /// which have their own setter method. If done anyway, the request will fail. + /// + /// # Additional Parameters + /// + /// * *$.xgafv* (query-string) - V1 error format. + /// * *access_token* (query-string) - OAuth access token. + /// * *alt* (query-string) - Data format for response. + /// * *callback* (query-string) - JSONP + /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. + /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. + /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. + /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. + /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. + /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). + /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). + pub fn param(mut self, name: T, value: T) -> WatermarkUnsetCall<'a, S> + where T: AsRef { + self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); + self + } + + /// Identifies the authorization scope for the method you are building. + /// + /// Use this method to actively specify which scope should be used, instead of 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: St) -> WatermarkUnsetCall<'a, S> + where St: AsRef { + self._scopes.insert(String::from(scope.as_ref())); + self + } + /// Identifies the authorization scope(s) for the method you are building. + /// + /// See [`Self::add_scope()`] for details. + pub fn add_scopes(mut self, scopes: I) -> WatermarkUnsetCall<'a, S> + where I: IntoIterator, + St: AsRef { + self._scopes + .extend(scopes.into_iter().map(|s| String::from(s.as_ref()))); + self + } + + /// Removes all scopes, and no default scope will be used either. + /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`] + /// for details). + pub fn clear_scopes(mut self) -> WatermarkUnsetCall<'a, S> { + self._scopes.clear(); + self + } +} + + +/// Updates an existing resource. +/// +/// A builder for the *v3.updateCommentThreads* method supported by a *youtube* resource. +/// It is not used directly, but through a [`YoutubeMethods`] instance. +/// +/// # Example +/// +/// Instantiate a resource method builder +/// +/// ```test_harness,no_run +/// # extern crate hyper; +/// # extern crate hyper_rustls; +/// # extern crate google_youtube3 as youtube3; +/// use youtube3::api::CommentThread; +/// # async fn dox() { +/// # use std::default::Default; +/// # use youtube3::{YouTube, oauth2, hyper, hyper_rustls, chrono, FieldMask}; +/// +/// # let secret: oauth2::ApplicationSecret = Default::default(); +/// # let auth = oauth2::InstalledFlowAuthenticator::builder( +/// # secret, +/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect, +/// # ).build().await.unwrap(); +/// # let mut hub = YouTube::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().unwrap().https_or_http().enable_http1().build()), auth); +/// // As the method needs a request, you would usually fill it with the desired information +/// // into the respective structure. Some of the parts shown here might not be applicable ! +/// // Values shown here are possibly random and not representative ! +/// let mut req = CommentThread::default(); +/// +/// // You can configure optional parameters by calling the respective setters at will, and +/// // execute the final call using `doit()`. +/// // Values shown here are possibly random and not representative ! +/// let result = hub.youtube().v3_update_comment_threads(req) +/// .add_part("eos") +/// .doit().await; +/// # } +/// ``` +pub struct YoutubeV3UpdateCommentThreadCall<'a, S> + where S: 'a { + + pub(super) hub: &'a YouTube, + pub(super) _request: CommentThread, + pub(super) _part: Vec, + pub(super) _delegate: Option<&'a mut dyn client::Delegate>, + pub(super) _additional_params: HashMap, +} + +impl<'a, S> client::CallBuilder for YoutubeV3UpdateCommentThreadCall<'a, S> {} + +impl<'a, S> YoutubeV3UpdateCommentThreadCall<'a, S> +where + S: tower_service::Service + Clone + Send + Sync + 'static, + S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static, + S::Future: Send + Unpin + 'static, + S::Error: Into>, +{ + + + /// Perform the operation you have build so far. + pub async fn doit(mut self) -> client::Result<(hyper::Response, CommentThread)> { + use std::io::{Read, Seek}; + use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION}; + use client::{ToParts, url::Params}; + use std::borrow::Cow; + + let mut dd = client::DefaultDelegate; + let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd); + dlg.begin(client::MethodInfo { id: "youtube.youtube.v3.updateCommentThreads", + http_method: hyper::Method::PUT }); + + for &field in ["alt", "part"].iter() { + if self._additional_params.contains_key(field) { + dlg.finished(false); + return Err(client::Error::FieldClash(field)); + } + } + + let mut params = Params::with_capacity(4 + self._additional_params.len()); + if self._part.is_empty() { + self._part.push(self._request.to_parts()); + } + if self._part.len() > 0 { + for f in self._part.iter() { + params.push("part", f); + } + } + + params.extend(self._additional_params.iter()); + + params.push("alt", "json"); + let mut url = self.hub._base_url.clone() + "youtube/v3/commentThreads"; + + match dlg.api_key() { + Some(value) => params.push("key", value), + None => { + dlg.finished(false); + return Err(client::Error::MissingAPIKey) + } + } + + + let url = params.parse_with_url(&url); + + let mut json_mime_type = mime::APPLICATION_JSON; + let mut request_value_reader = + { + let mut value = json::value::to_value(&self._request).expect("serde to work"); + client::remove_json_null_values(&mut value); + let mut dst = io::Cursor::new(Vec::with_capacity(128)); + json::to_writer(&mut dst, &value).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 client = &self.hub.client; + dlg.pre_request(); + let mut req_builder = hyper::Request::builder() + .method(hyper::Method::PUT) + .uri(url.as_str()) + .header(USER_AGENT, self.hub._user_agent.clone()); + + + + let request = req_builder + .header(CONTENT_TYPE, json_mime_type.to_string()) + .header(CONTENT_LENGTH, request_size as u64) + .body(hyper::body::Body::from(request_value_reader.get_ref().clone())); + + client.request(request.unwrap()).await + + }; + + match req_result { + Err(err) => { + if let client::Retry::After(d) = dlg.http_error(&err) { + sleep(d).await; + continue; + } + dlg.finished(false); + return Err(client::Error::HttpError(err)) + } + Ok(mut res) => { + if !res.status().is_success() { + let res_body_string = client::get_body_as_string(res.body_mut()).await; + let (parts, _) = res.into_parts(); + let body = hyper::Body::from(res_body_string.clone()); + let restored_response = hyper::Response::from_parts(parts, body); + + let server_response = json::from_str::(&res_body_string).ok(); + + if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) { + sleep(d).await; + continue; + } + + dlg.finished(false); + + return match server_response { + Some(error_value) => Err(client::Error::BadRequest(error_value)), + None => Err(client::Error::Failure(restored_response)), + } + } + let result_value = { + let res_body_string = client::get_body_as_string(res.body_mut()).await; + + match json::from_str(&res_body_string) { + Ok(decoded) => (res, decoded), + Err(err) => { + dlg.response_json_decode_error(&res_body_string, &err); + return Err(client::Error::JsonDecodeError(res_body_string, err)); + } + } + }; + + dlg.finished(true); + return Ok(result_value) + } + } + } + } + + + /// + /// Sets the *request* property to the given value. + /// + /// Even though the property as already been set when instantiating this call, + /// we provide this method for API completeness. + pub fn request(mut self, new_value: CommentThread) -> YoutubeV3UpdateCommentThreadCall<'a, S> { + self._request = new_value; + self + } + /// The *part* parameter specifies a comma-separated list of commentThread resource properties that the API response will include. You must at least include the snippet part in the parameter value since that part contains all of the properties that the API request can update. + /// + /// Append the given value to the *part* query property. + /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters. + /// + /// Even though the *parts* list is automatically derived from *Resource* passed in + /// during instantiation and indicates which values you are passing, the response would contain the very same parts. + /// This may not always be desirable, as you can obtain (newly generated) parts you cannot pass in, + /// like statistics that are generated server side. Therefore you should use this method to specify + /// the parts you provide in addition to the ones you want in the response. + pub fn add_part(mut self, new_value: &str) -> YoutubeV3UpdateCommentThreadCall<'a, S> { + self._part.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. + /// + /// ````text + /// It should be used to handle progress information, and to implement a certain level of resilience. + /// ```` + /// + /// Sets the *delegate* property to the given value. + pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> YoutubeV3UpdateCommentThreadCall<'a, S> { + self._delegate = Some(new_value); + self + } + + /// Set any additional parameter of the query string used in the request. + /// It should be used to set parameters which are not yet available through their own + /// setters. + /// + /// Please note that this method must not be used to set any of the known parameters + /// which have their own setter method. If done anyway, the request will fail. + /// + /// # Additional Parameters + /// + /// * *$.xgafv* (query-string) - V1 error format. + /// * *access_token* (query-string) - OAuth access token. + /// * *alt* (query-string) - Data format for response. + /// * *callback* (query-string) - JSONP + /// * *fields* (query-string) - Selector specifying which fields to include in a partial response. + /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. + /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user. + /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks. + /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. + /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart"). + /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart"). + pub fn param(mut self, name: T, value: T) -> YoutubeV3UpdateCommentThreadCall<'a, S> + where T: AsRef { + self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string()); + self + } + +} + + diff --git a/gen/youtube3/src/api/enums.rs b/gen/youtube3/src/api/enums.rs new file mode 100644 index 0000000000..910ddb0186 --- /dev/null +++ b/gen/youtube3/src/api/enums.rs @@ -0,0 +1,12279 @@ +use super::*; + + + +#[derive(Clone, Copy, Eq, Hash, Debug, PartialEq, Serialize, Deserialize)] +/// The type of call-to-action, a message to the user indicating action that can be taken. +pub enum ActivityContentDetailsPromotedItemCtaTypeEnum { + + /// "ctaTypeUnspecified" + #[serde(rename="ctaTypeUnspecified")] + CtaTypeUnspecified, + + /// "visitAdvertiserSite" + #[serde(rename="visitAdvertiserSite")] + VisitAdvertiserSite, +} + +impl AsRef for ActivityContentDetailsPromotedItemCtaTypeEnum { + fn as_ref(&self) -> &str { + match *self { + ActivityContentDetailsPromotedItemCtaTypeEnum::CtaTypeUnspecified => "ctaTypeUnspecified", + ActivityContentDetailsPromotedItemCtaTypeEnum::VisitAdvertiserSite => "visitAdvertiserSite", + } + } +} + +impl std::convert::TryFrom< &str> for ActivityContentDetailsPromotedItemCtaTypeEnum { + type Error = (); + fn try_from(value: &str) -> Result { + match value { + "ctaTypeUnspecified" => Ok(ActivityContentDetailsPromotedItemCtaTypeEnum::CtaTypeUnspecified), + "visitAdvertiserSite" => Ok(ActivityContentDetailsPromotedItemCtaTypeEnum::VisitAdvertiserSite), + _=> Err(()), + } + } +} + +impl<'a> Into> for &'a ActivityContentDetailsPromotedItemCtaTypeEnum { + fn into(self) -> std::borrow::Cow<'a, str> { + self.as_ref().into() + } +} + + +#[derive(Clone, Copy, Eq, Hash, Debug, PartialEq, Serialize, Deserialize)] +/// The reason that the resource is recommended to the user. +pub enum ActivityContentDetailsRecommendationReasonEnum { + + /// "reasonUnspecified" + #[serde(rename="reasonUnspecified")] + ReasonUnspecified, + + /// "videoFavorited" + #[serde(rename="videoFavorited")] + VideoFavorited, + + /// "videoLiked" + #[serde(rename="videoLiked")] + VideoLiked, + + /// "videoWatched" + #[serde(rename="videoWatched")] + VideoWatched, +} + +impl AsRef for ActivityContentDetailsRecommendationReasonEnum { + fn as_ref(&self) -> &str { + match *self { + ActivityContentDetailsRecommendationReasonEnum::ReasonUnspecified => "reasonUnspecified", + ActivityContentDetailsRecommendationReasonEnum::VideoFavorited => "videoFavorited", + ActivityContentDetailsRecommendationReasonEnum::VideoLiked => "videoLiked", + ActivityContentDetailsRecommendationReasonEnum::VideoWatched => "videoWatched", + } + } +} + +impl std::convert::TryFrom< &str> for ActivityContentDetailsRecommendationReasonEnum { + type Error = (); + fn try_from(value: &str) -> Result { + match value { + "reasonUnspecified" => Ok(ActivityContentDetailsRecommendationReasonEnum::ReasonUnspecified), + "videoFavorited" => Ok(ActivityContentDetailsRecommendationReasonEnum::VideoFavorited), + "videoLiked" => Ok(ActivityContentDetailsRecommendationReasonEnum::VideoLiked), + "videoWatched" => Ok(ActivityContentDetailsRecommendationReasonEnum::VideoWatched), + _=> Err(()), + } + } +} + +impl<'a> Into> for &'a ActivityContentDetailsRecommendationReasonEnum { + fn into(self) -> std::borrow::Cow<'a, str> { + self.as_ref().into() + } +} + + +#[derive(Clone, Copy, Eq, Hash, Debug, PartialEq, Serialize, Deserialize)] +/// The name of the social network. +pub enum ActivityContentDetailsSocialTypeEnum { + + /// "unspecified" + #[serde(rename="unspecified")] + Unspecified, + + /// "googlePlus" + #[serde(rename="googlePlus")] + GooglePlus, + + /// "facebook" + #[serde(rename="facebook")] + Facebook, + + /// "twitter" + #[serde(rename="twitter")] + Twitter, +} + +impl AsRef for ActivityContentDetailsSocialTypeEnum { + fn as_ref(&self) -> &str { + match *self { + ActivityContentDetailsSocialTypeEnum::Unspecified => "unspecified", + ActivityContentDetailsSocialTypeEnum::GooglePlus => "googlePlus", + ActivityContentDetailsSocialTypeEnum::Facebook => "facebook", + ActivityContentDetailsSocialTypeEnum::Twitter => "twitter", + } + } +} + +impl std::convert::TryFrom< &str> for ActivityContentDetailsSocialTypeEnum { + type Error = (); + fn try_from(value: &str) -> Result { + match value { + "unspecified" => Ok(ActivityContentDetailsSocialTypeEnum::Unspecified), + "googlePlus" => Ok(ActivityContentDetailsSocialTypeEnum::GooglePlus), + "facebook" => Ok(ActivityContentDetailsSocialTypeEnum::Facebook), + "twitter" => Ok(ActivityContentDetailsSocialTypeEnum::Twitter), + _=> Err(()), + } + } +} + +impl<'a> Into> for &'a ActivityContentDetailsSocialTypeEnum { + fn into(self) -> std::borrow::Cow<'a, str> { + self.as_ref().into() + } +} + + +#[derive(Clone, Copy, Eq, Hash, Debug, PartialEq, Serialize, Deserialize)] +/// The type of activity that the resource describes. +pub enum ActivitySnippetTypeEnum { + + /// "typeUnspecified" + #[serde(rename="typeUnspecified")] + TypeUnspecified, + + /// "upload" + #[serde(rename="upload")] + Upload, + + /// "like" + #[serde(rename="like")] + Like, + + /// "favorite" + #[serde(rename="favorite")] + Favorite, + + /// "comment" + #[serde(rename="comment")] + Comment, + + /// "subscription" + #[serde(rename="subscription")] + Subscription, + + /// "playlistItem" + #[serde(rename="playlistItem")] + PlaylistItem, + + /// "recommendation" + #[serde(rename="recommendation")] + Recommendation, + + /// "bulletin" + #[serde(rename="bulletin")] + Bulletin, + + /// "social" + #[serde(rename="social")] + Social, + + /// "channelItem" + #[serde(rename="channelItem")] + ChannelItem, + + /// "promotedItem" + #[serde(rename="promotedItem")] + PromotedItem, +} + +impl AsRef for ActivitySnippetTypeEnum { + fn as_ref(&self) -> &str { + match *self { + ActivitySnippetTypeEnum::TypeUnspecified => "typeUnspecified", + ActivitySnippetTypeEnum::Upload => "upload", + ActivitySnippetTypeEnum::Like => "like", + ActivitySnippetTypeEnum::Favorite => "favorite", + ActivitySnippetTypeEnum::Comment => "comment", + ActivitySnippetTypeEnum::Subscription => "subscription", + ActivitySnippetTypeEnum::PlaylistItem => "playlistItem", + ActivitySnippetTypeEnum::Recommendation => "recommendation", + ActivitySnippetTypeEnum::Bulletin => "bulletin", + ActivitySnippetTypeEnum::Social => "social", + ActivitySnippetTypeEnum::ChannelItem => "channelItem", + ActivitySnippetTypeEnum::PromotedItem => "promotedItem", + } + } +} + +impl std::convert::TryFrom< &str> for ActivitySnippetTypeEnum { + type Error = (); + fn try_from(value: &str) -> Result { + match value { + "typeUnspecified" => Ok(ActivitySnippetTypeEnum::TypeUnspecified), + "upload" => Ok(ActivitySnippetTypeEnum::Upload), + "like" => Ok(ActivitySnippetTypeEnum::Like), + "favorite" => Ok(ActivitySnippetTypeEnum::Favorite), + "comment" => Ok(ActivitySnippetTypeEnum::Comment), + "subscription" => Ok(ActivitySnippetTypeEnum::Subscription), + "playlistItem" => Ok(ActivitySnippetTypeEnum::PlaylistItem), + "recommendation" => Ok(ActivitySnippetTypeEnum::Recommendation), + "bulletin" => Ok(ActivitySnippetTypeEnum::Bulletin), + "social" => Ok(ActivitySnippetTypeEnum::Social), + "channelItem" => Ok(ActivitySnippetTypeEnum::ChannelItem), + "promotedItem" => Ok(ActivitySnippetTypeEnum::PromotedItem), + _=> Err(()), + } + } +} + +impl<'a> Into> for &'a ActivitySnippetTypeEnum { + fn into(self) -> std::borrow::Cow<'a, str> { + self.as_ref().into() + } +} + + +#[derive(Clone, Copy, Eq, Hash, Debug, PartialEq, Serialize, Deserialize)] +/// The type of audio track associated with the caption track. +pub enum CaptionSnippetAudioTrackTypeEnum { + + /// "unknown" + #[serde(rename="unknown")] + Unknown, + + /// "primary" + #[serde(rename="primary")] + Primary, + + /// "commentary" + #[serde(rename="commentary")] + Commentary, + + /// "descriptive" + #[serde(rename="descriptive")] + Descriptive, +} + +impl AsRef for CaptionSnippetAudioTrackTypeEnum { + fn as_ref(&self) -> &str { + match *self { + CaptionSnippetAudioTrackTypeEnum::Unknown => "unknown", + CaptionSnippetAudioTrackTypeEnum::Primary => "primary", + CaptionSnippetAudioTrackTypeEnum::Commentary => "commentary", + CaptionSnippetAudioTrackTypeEnum::Descriptive => "descriptive", + } + } +} + +impl std::convert::TryFrom< &str> for CaptionSnippetAudioTrackTypeEnum { + type Error = (); + fn try_from(value: &str) -> Result { + match value { + "unknown" => Ok(CaptionSnippetAudioTrackTypeEnum::Unknown), + "primary" => Ok(CaptionSnippetAudioTrackTypeEnum::Primary), + "commentary" => Ok(CaptionSnippetAudioTrackTypeEnum::Commentary), + "descriptive" => Ok(CaptionSnippetAudioTrackTypeEnum::Descriptive), + _=> Err(()), + } + } +} + +impl<'a> Into> for &'a CaptionSnippetAudioTrackTypeEnum { + fn into(self) -> std::borrow::Cow<'a, str> { + self.as_ref().into() + } +} + + +#[derive(Clone, Copy, Eq, Hash, Debug, PartialEq, Serialize, Deserialize)] +/// The reason that YouTube failed to process the caption track. This property is only present if the state property's value is failed. +pub enum CaptionSnippetFailureReasonEnum { + + /// "unknownFormat" + #[serde(rename="unknownFormat")] + UnknownFormat, + + /// "unsupportedFormat" + #[serde(rename="unsupportedFormat")] + UnsupportedFormat, + + /// "processingFailed" + #[serde(rename="processingFailed")] + ProcessingFailed, +} + +impl AsRef for CaptionSnippetFailureReasonEnum { + fn as_ref(&self) -> &str { + match *self { + CaptionSnippetFailureReasonEnum::UnknownFormat => "unknownFormat", + CaptionSnippetFailureReasonEnum::UnsupportedFormat => "unsupportedFormat", + CaptionSnippetFailureReasonEnum::ProcessingFailed => "processingFailed", + } + } +} + +impl std::convert::TryFrom< &str> for CaptionSnippetFailureReasonEnum { + type Error = (); + fn try_from(value: &str) -> Result { + match value { + "unknownFormat" => Ok(CaptionSnippetFailureReasonEnum::UnknownFormat), + "unsupportedFormat" => Ok(CaptionSnippetFailureReasonEnum::UnsupportedFormat), + "processingFailed" => Ok(CaptionSnippetFailureReasonEnum::ProcessingFailed), + _=> Err(()), + } + } +} + +impl<'a> Into> for &'a CaptionSnippetFailureReasonEnum { + fn into(self) -> std::borrow::Cow<'a, str> { + self.as_ref().into() + } +} + + +#[derive(Clone, Copy, Eq, Hash, Debug, PartialEq, Serialize, Deserialize)] +/// The caption track's status. +pub enum CaptionSnippetStatusEnum { + + /// "serving" + #[serde(rename="serving")] + Serving, + + /// "syncing" + #[serde(rename="syncing")] + Syncing, + + /// "failed" + #[serde(rename="failed")] + Failed, +} + +impl AsRef for CaptionSnippetStatusEnum { + fn as_ref(&self) -> &str { + match *self { + CaptionSnippetStatusEnum::Serving => "serving", + CaptionSnippetStatusEnum::Syncing => "syncing", + CaptionSnippetStatusEnum::Failed => "failed", + } + } +} + +impl std::convert::TryFrom< &str> for CaptionSnippetStatusEnum { + type Error = (); + fn try_from(value: &str) -> Result { + match value { + "serving" => Ok(CaptionSnippetStatusEnum::Serving), + "syncing" => Ok(CaptionSnippetStatusEnum::Syncing), + "failed" => Ok(CaptionSnippetStatusEnum::Failed), + _=> Err(()), + } + } +} + +impl<'a> Into> for &'a CaptionSnippetStatusEnum { + fn into(self) -> std::borrow::Cow<'a, str> { + self.as_ref().into() + } +} + + +#[derive(Clone, Copy, Eq, Hash, Debug, PartialEq, Serialize, Deserialize)] +/// The caption track's type. +pub enum CaptionSnippetTrackKindEnum { + + /// "standard" + #[serde(rename="standard")] + Standard, + + /// "ASR" + #[serde(rename="ASR")] + ASR, + + /// "forced" + #[serde(rename="forced")] + Forced, +} + +impl AsRef for CaptionSnippetTrackKindEnum { + fn as_ref(&self) -> &str { + match *self { + CaptionSnippetTrackKindEnum::Standard => "standard", + CaptionSnippetTrackKindEnum::ASR => "ASR", + CaptionSnippetTrackKindEnum::Forced => "forced", + } + } +} + +impl std::convert::TryFrom< &str> for CaptionSnippetTrackKindEnum { + type Error = (); + fn try_from(value: &str) -> Result { + match value { + "standard" => Ok(CaptionSnippetTrackKindEnum::Standard), + "ASR" => Ok(CaptionSnippetTrackKindEnum::ASR), + "forced" => Ok(CaptionSnippetTrackKindEnum::Forced), + _=> Err(()), + } + } +} + +impl<'a> Into> for &'a CaptionSnippetTrackKindEnum { + fn into(self) -> std::borrow::Cow<'a, str> { + self.as_ref().into() + } +} + + +#[derive(Clone, Copy, Eq, Hash, Debug, PartialEq, Serialize, Deserialize)] +/// The frame rate of the inbound video data. +pub enum CdnSettingFrameRateEnum { + + /// "30fps" + #[serde(rename="30fps")] + _30fps, + + /// "60fps" + #[serde(rename="60fps")] + _60fps, + + /// "variable" + #[serde(rename="variable")] + Variable, +} + +impl AsRef for CdnSettingFrameRateEnum { + fn as_ref(&self) -> &str { + match *self { + CdnSettingFrameRateEnum::_30fps => "30fps", + CdnSettingFrameRateEnum::_60fps => "60fps", + CdnSettingFrameRateEnum::Variable => "variable", + } + } +} + +impl std::convert::TryFrom< &str> for CdnSettingFrameRateEnum { + type Error = (); + fn try_from(value: &str) -> Result { + match value { + "30fps" => Ok(CdnSettingFrameRateEnum::_30fps), + "60fps" => Ok(CdnSettingFrameRateEnum::_60fps), + "variable" => Ok(CdnSettingFrameRateEnum::Variable), + _=> Err(()), + } + } +} + +impl<'a> Into> for &'a CdnSettingFrameRateEnum { + fn into(self) -> std::borrow::Cow<'a, str> { + self.as_ref().into() + } +} + + +#[derive(Clone, Copy, Eq, Hash, Debug, PartialEq, Serialize, Deserialize)] +/// The method or protocol used to transmit the video stream. +pub enum CdnSettingIngestionTypeEnum { + + /// "rtmp" + #[serde(rename="rtmp")] + Rtmp, + + /// "dash" + #[serde(rename="dash")] + Dash, + + /// "webrtc" + #[serde(rename="webrtc")] + Webrtc, + + /// "hls" + #[serde(rename="hls")] + Hls, +} + +impl AsRef for CdnSettingIngestionTypeEnum { + fn as_ref(&self) -> &str { + match *self { + CdnSettingIngestionTypeEnum::Rtmp => "rtmp", + CdnSettingIngestionTypeEnum::Dash => "dash", + CdnSettingIngestionTypeEnum::Webrtc => "webrtc", + CdnSettingIngestionTypeEnum::Hls => "hls", + } + } +} + +impl std::convert::TryFrom< &str> for CdnSettingIngestionTypeEnum { + type Error = (); + fn try_from(value: &str) -> Result { + match value { + "rtmp" => Ok(CdnSettingIngestionTypeEnum::Rtmp), + "dash" => Ok(CdnSettingIngestionTypeEnum::Dash), + "webrtc" => Ok(CdnSettingIngestionTypeEnum::Webrtc), + "hls" => Ok(CdnSettingIngestionTypeEnum::Hls), + _=> Err(()), + } + } +} + +impl<'a> Into> for &'a CdnSettingIngestionTypeEnum { + fn into(self) -> std::borrow::Cow<'a, str> { + self.as_ref().into() + } +} + + +#[derive(Clone, Copy, Eq, Hash, Debug, PartialEq, Serialize, Deserialize)] +/// The resolution of the inbound video data. +pub enum CdnSettingResolutionEnum { + + /// "240p" + #[serde(rename="240p")] + _240p, + + /// "360p" + #[serde(rename="360p")] + _360p, + + /// "480p" + #[serde(rename="480p")] + _480p, + + /// "720p" + #[serde(rename="720p")] + _720p, + + /// "1080p" + #[serde(rename="1080p")] + _1080p, + + /// "1440p" + #[serde(rename="1440p")] + _1440p, + + /// "2160p" + #[serde(rename="2160p")] + _2160p, + + /// "variable" + #[serde(rename="variable")] + Variable, +} + +impl AsRef for CdnSettingResolutionEnum { + fn as_ref(&self) -> &str { + match *self { + CdnSettingResolutionEnum::_240p => "240p", + CdnSettingResolutionEnum::_360p => "360p", + CdnSettingResolutionEnum::_480p => "480p", + CdnSettingResolutionEnum::_720p => "720p", + CdnSettingResolutionEnum::_1080p => "1080p", + CdnSettingResolutionEnum::_1440p => "1440p", + CdnSettingResolutionEnum::_2160p => "2160p", + CdnSettingResolutionEnum::Variable => "variable", + } + } +} + +impl std::convert::TryFrom< &str> for CdnSettingResolutionEnum { + type Error = (); + fn try_from(value: &str) -> Result { + match value { + "240p" => Ok(CdnSettingResolutionEnum::_240p), + "360p" => Ok(CdnSettingResolutionEnum::_360p), + "480p" => Ok(CdnSettingResolutionEnum::_480p), + "720p" => Ok(CdnSettingResolutionEnum::_720p), + "1080p" => Ok(CdnSettingResolutionEnum::_1080p), + "1440p" => Ok(CdnSettingResolutionEnum::_1440p), + "2160p" => Ok(CdnSettingResolutionEnum::_2160p), + "variable" => Ok(CdnSettingResolutionEnum::Variable), + _=> Err(()), + } + } +} + +impl<'a> Into> for &'a CdnSettingResolutionEnum { + fn into(self) -> std::borrow::Cow<'a, str> { + self.as_ref().into() + } +} + + +#[derive(Clone, Copy, Eq, Hash, Debug, PartialEq, Serialize, Deserialize)] +/// Defines the context of the ping. +pub enum ChannelConversionPingContextEnum { + + /// "subscribe" + #[serde(rename="subscribe")] + Subscribe, + + /// "unsubscribe" + #[serde(rename="unsubscribe")] + Unsubscribe, + + /// "cview" + #[serde(rename="cview")] + Cview, +} + +impl AsRef for ChannelConversionPingContextEnum { + fn as_ref(&self) -> &str { + match *self { + ChannelConversionPingContextEnum::Subscribe => "subscribe", + ChannelConversionPingContextEnum::Unsubscribe => "unsubscribe", + ChannelConversionPingContextEnum::Cview => "cview", + } + } +} + +impl std::convert::TryFrom< &str> for ChannelConversionPingContextEnum { + type Error = (); + fn try_from(value: &str) -> Result { + match value { + "subscribe" => Ok(ChannelConversionPingContextEnum::Subscribe), + "unsubscribe" => Ok(ChannelConversionPingContextEnum::Unsubscribe), + "cview" => Ok(ChannelConversionPingContextEnum::Cview), + _=> Err(()), + } + } +} + +impl<'a> Into> for &'a ChannelConversionPingContextEnum { + fn into(self) -> std::borrow::Cow<'a, str> { + self.as_ref().into() + } +} + + +#[derive(Clone, Copy, Eq, Hash, Debug, PartialEq, Serialize, Deserialize)] +/// The style of the channel section. +pub enum ChannelSectionSnippetStyleEnum { + + /// "channelsectionStyleUnspecified" + #[serde(rename="channelsectionStyleUnspecified")] + ChannelsectionStyleUnspecified, + + /// "horizontalRow" + #[serde(rename="horizontalRow")] + HorizontalRow, + + /// "verticalList" + #[serde(rename="verticalList")] + VerticalList, +} + +impl AsRef for ChannelSectionSnippetStyleEnum { + fn as_ref(&self) -> &str { + match *self { + ChannelSectionSnippetStyleEnum::ChannelsectionStyleUnspecified => "channelsectionStyleUnspecified", + ChannelSectionSnippetStyleEnum::HorizontalRow => "horizontalRow", + ChannelSectionSnippetStyleEnum::VerticalList => "verticalList", + } + } +} + +impl std::convert::TryFrom< &str> for ChannelSectionSnippetStyleEnum { + type Error = (); + fn try_from(value: &str) -> Result { + match value { + "channelsectionStyleUnspecified" => Ok(ChannelSectionSnippetStyleEnum::ChannelsectionStyleUnspecified), + "horizontalRow" => Ok(ChannelSectionSnippetStyleEnum::HorizontalRow), + "verticalList" => Ok(ChannelSectionSnippetStyleEnum::VerticalList), + _=> Err(()), + } + } +} + +impl<'a> Into> for &'a ChannelSectionSnippetStyleEnum { + fn into(self) -> std::borrow::Cow<'a, str> { + self.as_ref().into() + } +} + + +#[derive(Clone, Copy, Eq, Hash, Debug, PartialEq, Serialize, Deserialize)] +/// The type of the channel section. +pub enum ChannelSectionSnippetTypeEnum { + + /// "channelsectionTypeUndefined" + #[serde(rename="channelsectionTypeUndefined")] + ChannelsectionTypeUndefined, + + /// "singlePlaylist" + #[serde(rename="singlePlaylist")] + SinglePlaylist, + + /// "multiplePlaylists" + #[serde(rename="multiplePlaylists")] + MultiplePlaylists, + + /// "popularUploads" + #[serde(rename="popularUploads")] + PopularUploads, + + /// "recentUploads" + #[serde(rename="recentUploads")] + RecentUploads, + + /// "likes" + #[serde(rename="likes")] + Likes, + + /// "allPlaylists" + #[serde(rename="allPlaylists")] + AllPlaylists, + + /// "likedPlaylists" + #[serde(rename="likedPlaylists")] + LikedPlaylists, + + /// "recentPosts" + #[serde(rename="recentPosts")] + RecentPosts, + + /// "recentActivity" + #[serde(rename="recentActivity")] + RecentActivity, + + /// "liveEvents" + #[serde(rename="liveEvents")] + LiveEvents, + + /// "upcomingEvents" + #[serde(rename="upcomingEvents")] + UpcomingEvents, + + /// "completedEvents" + #[serde(rename="completedEvents")] + CompletedEvents, + + /// "multipleChannels" + #[serde(rename="multipleChannels")] + MultipleChannels, + + /// "postedVideos" + #[serde(rename="postedVideos")] + PostedVideos, + + /// "postedPlaylists" + #[serde(rename="postedPlaylists")] + PostedPlaylists, + + /// "subscriptions" + #[serde(rename="subscriptions")] + Subscriptions, +} + +impl AsRef for ChannelSectionSnippetTypeEnum { + fn as_ref(&self) -> &str { + match *self { + ChannelSectionSnippetTypeEnum::ChannelsectionTypeUndefined => "channelsectionTypeUndefined", + ChannelSectionSnippetTypeEnum::SinglePlaylist => "singlePlaylist", + ChannelSectionSnippetTypeEnum::MultiplePlaylists => "multiplePlaylists", + ChannelSectionSnippetTypeEnum::PopularUploads => "popularUploads", + ChannelSectionSnippetTypeEnum::RecentUploads => "recentUploads", + ChannelSectionSnippetTypeEnum::Likes => "likes", + ChannelSectionSnippetTypeEnum::AllPlaylists => "allPlaylists", + ChannelSectionSnippetTypeEnum::LikedPlaylists => "likedPlaylists", + ChannelSectionSnippetTypeEnum::RecentPosts => "recentPosts", + ChannelSectionSnippetTypeEnum::RecentActivity => "recentActivity", + ChannelSectionSnippetTypeEnum::LiveEvents => "liveEvents", + ChannelSectionSnippetTypeEnum::UpcomingEvents => "upcomingEvents", + ChannelSectionSnippetTypeEnum::CompletedEvents => "completedEvents", + ChannelSectionSnippetTypeEnum::MultipleChannels => "multipleChannels", + ChannelSectionSnippetTypeEnum::PostedVideos => "postedVideos", + ChannelSectionSnippetTypeEnum::PostedPlaylists => "postedPlaylists", + ChannelSectionSnippetTypeEnum::Subscriptions => "subscriptions", + } + } +} + +impl std::convert::TryFrom< &str> for ChannelSectionSnippetTypeEnum { + type Error = (); + fn try_from(value: &str) -> Result { + match value { + "channelsectionTypeUndefined" => Ok(ChannelSectionSnippetTypeEnum::ChannelsectionTypeUndefined), + "singlePlaylist" => Ok(ChannelSectionSnippetTypeEnum::SinglePlaylist), + "multiplePlaylists" => Ok(ChannelSectionSnippetTypeEnum::MultiplePlaylists), + "popularUploads" => Ok(ChannelSectionSnippetTypeEnum::PopularUploads), + "recentUploads" => Ok(ChannelSectionSnippetTypeEnum::RecentUploads), + "likes" => Ok(ChannelSectionSnippetTypeEnum::Likes), + "allPlaylists" => Ok(ChannelSectionSnippetTypeEnum::AllPlaylists), + "likedPlaylists" => Ok(ChannelSectionSnippetTypeEnum::LikedPlaylists), + "recentPosts" => Ok(ChannelSectionSnippetTypeEnum::RecentPosts), + "recentActivity" => Ok(ChannelSectionSnippetTypeEnum::RecentActivity), + "liveEvents" => Ok(ChannelSectionSnippetTypeEnum::LiveEvents), + "upcomingEvents" => Ok(ChannelSectionSnippetTypeEnum::UpcomingEvents), + "completedEvents" => Ok(ChannelSectionSnippetTypeEnum::CompletedEvents), + "multipleChannels" => Ok(ChannelSectionSnippetTypeEnum::MultipleChannels), + "postedVideos" => Ok(ChannelSectionSnippetTypeEnum::PostedVideos), + "postedPlaylists" => Ok(ChannelSectionSnippetTypeEnum::PostedPlaylists), + "subscriptions" => Ok(ChannelSectionSnippetTypeEnum::Subscriptions), + _=> Err(()), + } + } +} + +impl<'a> Into> for &'a ChannelSectionSnippetTypeEnum { + fn into(self) -> std::borrow::Cow<'a, str> { + self.as_ref().into() + } +} + + +#[derive(Clone, Copy, Eq, Hash, Debug, PartialEq, Serialize, Deserialize)] +/// The long uploads status of this channel. See https://support.google.com/youtube/answer/71673 for more information. +pub enum ChannelStatusLongUploadsStatusEnum { + + /// "longUploadsUnspecified" + #[serde(rename="longUploadsUnspecified")] + LongUploadsUnspecified, + + /// "allowed" + #[serde(rename="allowed")] + Allowed, + + /// "eligible" + #[serde(rename="eligible")] + Eligible, + + /// "disallowed" + #[serde(rename="disallowed")] + Disallowed, +} + +impl AsRef for ChannelStatusLongUploadsStatusEnum { + fn as_ref(&self) -> &str { + match *self { + ChannelStatusLongUploadsStatusEnum::LongUploadsUnspecified => "longUploadsUnspecified", + ChannelStatusLongUploadsStatusEnum::Allowed => "allowed", + ChannelStatusLongUploadsStatusEnum::Eligible => "eligible", + ChannelStatusLongUploadsStatusEnum::Disallowed => "disallowed", + } + } +} + +impl std::convert::TryFrom< &str> for ChannelStatusLongUploadsStatusEnum { + type Error = (); + fn try_from(value: &str) -> Result { + match value { + "longUploadsUnspecified" => Ok(ChannelStatusLongUploadsStatusEnum::LongUploadsUnspecified), + "allowed" => Ok(ChannelStatusLongUploadsStatusEnum::Allowed), + "eligible" => Ok(ChannelStatusLongUploadsStatusEnum::Eligible), + "disallowed" => Ok(ChannelStatusLongUploadsStatusEnum::Disallowed), + _=> Err(()), + } + } +} + +impl<'a> Into> for &'a ChannelStatusLongUploadsStatusEnum { + fn into(self) -> std::borrow::Cow<'a, str> { + self.as_ref().into() + } +} + + +#[derive(Clone, Copy, Eq, Hash, Debug, PartialEq, Serialize, Deserialize)] +/// Privacy status of the channel. +pub enum ChannelStatusPrivacyStatusEnum { + + /// "public" + #[serde(rename="public")] + Public, + + /// "unlisted" + #[serde(rename="unlisted")] + Unlisted, + + /// "private" + #[serde(rename="private")] + Private, +} + +impl AsRef for ChannelStatusPrivacyStatusEnum { + fn as_ref(&self) -> &str { + match *self { + ChannelStatusPrivacyStatusEnum::Public => "public", + ChannelStatusPrivacyStatusEnum::Unlisted => "unlisted", + ChannelStatusPrivacyStatusEnum::Private => "private", + } + } +} + +impl std::convert::TryFrom< &str> for ChannelStatusPrivacyStatusEnum { + type Error = (); + fn try_from(value: &str) -> Result { + match value { + "public" => Ok(ChannelStatusPrivacyStatusEnum::Public), + "unlisted" => Ok(ChannelStatusPrivacyStatusEnum::Unlisted), + "private" => Ok(ChannelStatusPrivacyStatusEnum::Private), + _=> Err(()), + } + } +} + +impl<'a> Into> for &'a ChannelStatusPrivacyStatusEnum { + fn into(self) -> std::borrow::Cow<'a, str> { + self.as_ref().into() + } +} + + +#[derive(Clone, Copy, Eq, Hash, Debug, PartialEq, Serialize, Deserialize)] +/// The current billing profile status. +pub enum ChannelToStoreLinkDetailsBillingDetailBillingStatusEnum { + + /// "billingStatusUnspecified" + #[serde(rename="billingStatusUnspecified")] + BillingStatusUnspecified, + + /// "billingStatusPending" + #[serde(rename="billingStatusPending")] + BillingStatusPending, + + /// "billingStatusActive" + #[serde(rename="billingStatusActive")] + BillingStatusActive, + + /// "billingStatusInactive" + #[serde(rename="billingStatusInactive")] + BillingStatusInactive, +} + +impl AsRef for ChannelToStoreLinkDetailsBillingDetailBillingStatusEnum { + fn as_ref(&self) -> &str { + match *self { + ChannelToStoreLinkDetailsBillingDetailBillingStatusEnum::BillingStatusUnspecified => "billingStatusUnspecified", + ChannelToStoreLinkDetailsBillingDetailBillingStatusEnum::BillingStatusPending => "billingStatusPending", + ChannelToStoreLinkDetailsBillingDetailBillingStatusEnum::BillingStatusActive => "billingStatusActive", + ChannelToStoreLinkDetailsBillingDetailBillingStatusEnum::BillingStatusInactive => "billingStatusInactive", + } + } +} + +impl std::convert::TryFrom< &str> for ChannelToStoreLinkDetailsBillingDetailBillingStatusEnum { + type Error = (); + fn try_from(value: &str) -> Result { + match value { + "billingStatusUnspecified" => Ok(ChannelToStoreLinkDetailsBillingDetailBillingStatusEnum::BillingStatusUnspecified), + "billingStatusPending" => Ok(ChannelToStoreLinkDetailsBillingDetailBillingStatusEnum::BillingStatusPending), + "billingStatusActive" => Ok(ChannelToStoreLinkDetailsBillingDetailBillingStatusEnum::BillingStatusActive), + "billingStatusInactive" => Ok(ChannelToStoreLinkDetailsBillingDetailBillingStatusEnum::BillingStatusInactive), + _=> Err(()), + } + } +} + +impl<'a> Into> for &'a ChannelToStoreLinkDetailsBillingDetailBillingStatusEnum { + fn into(self) -> std::borrow::Cow<'a, str> { + self.as_ref().into() + } +} + + +#[derive(Clone, Copy, Eq, Hash, Debug, PartialEq, Serialize, Deserialize)] +/// The comment's moderation status. Will not be set if the comments were requested through the id filter. +pub enum CommentSnippetModerationStatusEnum { + + + /// The comment is available for public display. + /// + /// "published" + #[serde(rename="published")] + Published, + + + /// The comment is awaiting review by a moderator. + /// + /// "heldForReview" + #[serde(rename="heldForReview")] + HeldForReview, + + /// "likelySpam" + #[serde(rename="likelySpam")] + LikelySpam, + + + /// The comment is unfit for display. + /// + /// "rejected" + #[serde(rename="rejected")] + Rejected, +} + +impl AsRef for CommentSnippetModerationStatusEnum { + fn as_ref(&self) -> &str { + match *self { + CommentSnippetModerationStatusEnum::Published => "published", + CommentSnippetModerationStatusEnum::HeldForReview => "heldForReview", + CommentSnippetModerationStatusEnum::LikelySpam => "likelySpam", + CommentSnippetModerationStatusEnum::Rejected => "rejected", + } + } +} + +impl std::convert::TryFrom< &str> for CommentSnippetModerationStatusEnum { + type Error = (); + fn try_from(value: &str) -> Result { + match value { + "published" => Ok(CommentSnippetModerationStatusEnum::Published), + "heldForReview" => Ok(CommentSnippetModerationStatusEnum::HeldForReview), + "likelySpam" => Ok(CommentSnippetModerationStatusEnum::LikelySpam), + "rejected" => Ok(CommentSnippetModerationStatusEnum::Rejected), + _=> Err(()), + } + } +} + +impl<'a> Into> for &'a CommentSnippetModerationStatusEnum { + fn into(self) -> std::borrow::Cow<'a, str> { + self.as_ref().into() + } +} + + +#[derive(Clone, Copy, Eq, Hash, Debug, PartialEq, Serialize, Deserialize)] +/// The rating the viewer has given to this comment. For the time being this will never return RATE_TYPE_DISLIKE and instead return RATE_TYPE_NONE. This may change in the future. +pub enum CommentSnippetViewerRatingEnum { + + /// "none" + #[serde(rename="none")] + None, + + + /// The entity is liked. + /// + /// "like" + #[serde(rename="like")] + Like, + + + /// The entity is disliked. + /// + /// "dislike" + #[serde(rename="dislike")] + Dislike, +} + +impl AsRef for CommentSnippetViewerRatingEnum { + fn as_ref(&self) -> &str { + match *self { + CommentSnippetViewerRatingEnum::None => "none", + CommentSnippetViewerRatingEnum::Like => "like", + CommentSnippetViewerRatingEnum::Dislike => "dislike", + } + } +} + +impl std::convert::TryFrom< &str> for CommentSnippetViewerRatingEnum { + type Error = (); + fn try_from(value: &str) -> Result { + match value { + "none" => Ok(CommentSnippetViewerRatingEnum::None), + "like" => Ok(CommentSnippetViewerRatingEnum::Like), + "dislike" => Ok(CommentSnippetViewerRatingEnum::Dislike), + _=> Err(()), + } + } +} + +impl<'a> Into> for &'a CommentSnippetViewerRatingEnum { + fn into(self) -> std::borrow::Cow<'a, str> { + self.as_ref().into() + } +} + + +#[derive(Clone, Copy, Eq, Hash, Debug, PartialEq, Serialize, Deserialize)] +/// The video's Australian Classification Board (ACB) or Australian Communications and Media Authority (ACMA) rating. ACMA ratings are used to classify children's television programming. +pub enum ContentRatingAcbRatingEnum { + + /// "acbUnspecified" + #[serde(rename="acbUnspecified")] + AcbUnspecified, + + + /// E + /// + /// "acbE" + #[serde(rename="acbE")] + AcbE, + + + /// Programs that have been given a P classification by the Australian Communications and Media Authority. These programs are intended for preschool children. + /// + /// "acbP" + #[serde(rename="acbP")] + AcbP, + + + /// Programs that have been given a C classification by the Australian Communications and Media Authority. These programs are intended for children (other than preschool children) who are younger than 14 years of age. + /// + /// "acbC" + #[serde(rename="acbC")] + AcbC, + + + /// G + /// + /// "acbG" + #[serde(rename="acbG")] + AcbG, + + + /// PG + /// + /// "acbPg" + #[serde(rename="acbPg")] + AcbPg, + + + /// M + /// + /// "acbM" + #[serde(rename="acbM")] + AcbM, + + + /// MA15+ + /// + /// "acbMa15plus" + #[serde(rename="acbMa15plus")] + AcbMa15plus, + + + /// R18+ + /// + /// "acbR18plus" + #[serde(rename="acbR18plus")] + AcbR18plus, + + /// "acbUnrated" + #[serde(rename="acbUnrated")] + AcbUnrated, +} + +impl AsRef for ContentRatingAcbRatingEnum { + fn as_ref(&self) -> &str { + match *self { + ContentRatingAcbRatingEnum::AcbUnspecified => "acbUnspecified", + ContentRatingAcbRatingEnum::AcbE => "acbE", + ContentRatingAcbRatingEnum::AcbP => "acbP", + ContentRatingAcbRatingEnum::AcbC => "acbC", + ContentRatingAcbRatingEnum::AcbG => "acbG", + ContentRatingAcbRatingEnum::AcbPg => "acbPg", + ContentRatingAcbRatingEnum::AcbM => "acbM", + ContentRatingAcbRatingEnum::AcbMa15plus => "acbMa15plus", + ContentRatingAcbRatingEnum::AcbR18plus => "acbR18plus", + ContentRatingAcbRatingEnum::AcbUnrated => "acbUnrated", + } + } +} + +impl std::convert::TryFrom< &str> for ContentRatingAcbRatingEnum { + type Error = (); + fn try_from(value: &str) -> Result { + match value { + "acbUnspecified" => Ok(ContentRatingAcbRatingEnum::AcbUnspecified), + "acbE" => Ok(ContentRatingAcbRatingEnum::AcbE), + "acbP" => Ok(ContentRatingAcbRatingEnum::AcbP), + "acbC" => Ok(ContentRatingAcbRatingEnum::AcbC), + "acbG" => Ok(ContentRatingAcbRatingEnum::AcbG), + "acbPg" => Ok(ContentRatingAcbRatingEnum::AcbPg), + "acbM" => Ok(ContentRatingAcbRatingEnum::AcbM), + "acbMa15plus" => Ok(ContentRatingAcbRatingEnum::AcbMa15plus), + "acbR18plus" => Ok(ContentRatingAcbRatingEnum::AcbR18plus), + "acbUnrated" => Ok(ContentRatingAcbRatingEnum::AcbUnrated), + _=> Err(()), + } + } +} + +impl<'a> Into> for &'a ContentRatingAcbRatingEnum { + fn into(self) -> std::borrow::Cow<'a, str> { + self.as_ref().into() + } +} + + +#[derive(Clone, Copy, Eq, Hash, Debug, PartialEq, Serialize, Deserialize)] +/// The video's rating from Italy's Autorità per le Garanzie nelle Comunicazioni (AGCOM). +pub enum ContentRatingAgcomRatingEnum { + + /// "agcomUnspecified" + #[serde(rename="agcomUnspecified")] + AgcomUnspecified, + + + /// T + /// + /// "agcomT" + #[serde(rename="agcomT")] + AgcomT, + + + /// VM14 + /// + /// "agcomVm14" + #[serde(rename="agcomVm14")] + AgcomVm14, + + + /// VM18 + /// + /// "agcomVm18" + #[serde(rename="agcomVm18")] + AgcomVm18, + + /// "agcomUnrated" + #[serde(rename="agcomUnrated")] + AgcomUnrated, +} + +impl AsRef for ContentRatingAgcomRatingEnum { + fn as_ref(&self) -> &str { + match *self { + ContentRatingAgcomRatingEnum::AgcomUnspecified => "agcomUnspecified", + ContentRatingAgcomRatingEnum::AgcomT => "agcomT", + ContentRatingAgcomRatingEnum::AgcomVm14 => "agcomVm14", + ContentRatingAgcomRatingEnum::AgcomVm18 => "agcomVm18", + ContentRatingAgcomRatingEnum::AgcomUnrated => "agcomUnrated", + } + } +} + +impl std::convert::TryFrom< &str> for ContentRatingAgcomRatingEnum { + type Error = (); + fn try_from(value: &str) -> Result { + match value { + "agcomUnspecified" => Ok(ContentRatingAgcomRatingEnum::AgcomUnspecified), + "agcomT" => Ok(ContentRatingAgcomRatingEnum::AgcomT), + "agcomVm14" => Ok(ContentRatingAgcomRatingEnum::AgcomVm14), + "agcomVm18" => Ok(ContentRatingAgcomRatingEnum::AgcomVm18), + "agcomUnrated" => Ok(ContentRatingAgcomRatingEnum::AgcomUnrated), + _=> Err(()), + } + } +} + +impl<'a> Into> for &'a ContentRatingAgcomRatingEnum { + fn into(self) -> std::borrow::Cow<'a, str> { + self.as_ref().into() + } +} + + +#[derive(Clone, Copy, Eq, Hash, Debug, PartialEq, Serialize, Deserialize)] +/// The video's Anatel (Asociación Nacional de Televisión) rating for Chilean television. +pub enum ContentRatingAnatelRatingEnum { + + /// "anatelUnspecified" + #[serde(rename="anatelUnspecified")] + AnatelUnspecified, + + + /// F + /// + /// "anatelF" + #[serde(rename="anatelF")] + AnatelF, + + + /// I + /// + /// "anatelI" + #[serde(rename="anatelI")] + AnatelI, + + + /// I-7 + /// + /// "anatelI7" + #[serde(rename="anatelI7")] + AnatelI7, + + + /// I-10 + /// + /// "anatelI10" + #[serde(rename="anatelI10")] + AnatelI10, + + + /// I-12 + /// + /// "anatelI12" + #[serde(rename="anatelI12")] + AnatelI12, + + + /// R + /// + /// "anatelR" + #[serde(rename="anatelR")] + AnatelR, + + + /// A + /// + /// "anatelA" + #[serde(rename="anatelA")] + AnatelA, + + /// "anatelUnrated" + #[serde(rename="anatelUnrated")] + AnatelUnrated, +} + +impl AsRef for ContentRatingAnatelRatingEnum { + fn as_ref(&self) -> &str { + match *self { + ContentRatingAnatelRatingEnum::AnatelUnspecified => "anatelUnspecified", + ContentRatingAnatelRatingEnum::AnatelF => "anatelF", + ContentRatingAnatelRatingEnum::AnatelI => "anatelI", + ContentRatingAnatelRatingEnum::AnatelI7 => "anatelI7", + ContentRatingAnatelRatingEnum::AnatelI10 => "anatelI10", + ContentRatingAnatelRatingEnum::AnatelI12 => "anatelI12", + ContentRatingAnatelRatingEnum::AnatelR => "anatelR", + ContentRatingAnatelRatingEnum::AnatelA => "anatelA", + ContentRatingAnatelRatingEnum::AnatelUnrated => "anatelUnrated", + } + } +} + +impl std::convert::TryFrom< &str> for ContentRatingAnatelRatingEnum { + type Error = (); + fn try_from(value: &str) -> Result { + match value { + "anatelUnspecified" => Ok(ContentRatingAnatelRatingEnum::AnatelUnspecified), + "anatelF" => Ok(ContentRatingAnatelRatingEnum::AnatelF), + "anatelI" => Ok(ContentRatingAnatelRatingEnum::AnatelI), + "anatelI7" => Ok(ContentRatingAnatelRatingEnum::AnatelI7), + "anatelI10" => Ok(ContentRatingAnatelRatingEnum::AnatelI10), + "anatelI12" => Ok(ContentRatingAnatelRatingEnum::AnatelI12), + "anatelR" => Ok(ContentRatingAnatelRatingEnum::AnatelR), + "anatelA" => Ok(ContentRatingAnatelRatingEnum::AnatelA), + "anatelUnrated" => Ok(ContentRatingAnatelRatingEnum::AnatelUnrated), + _=> Err(()), + } + } +} + +impl<'a> Into> for &'a ContentRatingAnatelRatingEnum { + fn into(self) -> std::borrow::Cow<'a, str> { + self.as_ref().into() + } +} + + +#[derive(Clone, Copy, Eq, Hash, Debug, PartialEq, Serialize, Deserialize)] +/// The video's British Board of Film Classification (BBFC) rating. +pub enum ContentRatingBbfcRatingEnum { + + /// "bbfcUnspecified" + #[serde(rename="bbfcUnspecified")] + BbfcUnspecified, + + + /// U + /// + /// "bbfcU" + #[serde(rename="bbfcU")] + BbfcU, + + + /// PG + /// + /// "bbfcPg" + #[serde(rename="bbfcPg")] + BbfcPg, + + + /// 12A + /// + /// "bbfc12a" + #[serde(rename="bbfc12a")] + Bbfc12a, + + + /// 12 + /// + /// "bbfc12" + #[serde(rename="bbfc12")] + Bbfc12, + + + /// 15 + /// + /// "bbfc15" + #[serde(rename="bbfc15")] + Bbfc15, + + + /// 18 + /// + /// "bbfc18" + #[serde(rename="bbfc18")] + Bbfc18, + + + /// R18 + /// + /// "bbfcR18" + #[serde(rename="bbfcR18")] + BbfcR18, + + /// "bbfcUnrated" + #[serde(rename="bbfcUnrated")] + BbfcUnrated, +} + +impl AsRef for ContentRatingBbfcRatingEnum { + fn as_ref(&self) -> &str { + match *self { + ContentRatingBbfcRatingEnum::BbfcUnspecified => "bbfcUnspecified", + ContentRatingBbfcRatingEnum::BbfcU => "bbfcU", + ContentRatingBbfcRatingEnum::BbfcPg => "bbfcPg", + ContentRatingBbfcRatingEnum::Bbfc12a => "bbfc12a", + ContentRatingBbfcRatingEnum::Bbfc12 => "bbfc12", + ContentRatingBbfcRatingEnum::Bbfc15 => "bbfc15", + ContentRatingBbfcRatingEnum::Bbfc18 => "bbfc18", + ContentRatingBbfcRatingEnum::BbfcR18 => "bbfcR18", + ContentRatingBbfcRatingEnum::BbfcUnrated => "bbfcUnrated", + } + } +} + +impl std::convert::TryFrom< &str> for ContentRatingBbfcRatingEnum { + type Error = (); + fn try_from(value: &str) -> Result { + match value { + "bbfcUnspecified" => Ok(ContentRatingBbfcRatingEnum::BbfcUnspecified), + "bbfcU" => Ok(ContentRatingBbfcRatingEnum::BbfcU), + "bbfcPg" => Ok(ContentRatingBbfcRatingEnum::BbfcPg), + "bbfc12a" => Ok(ContentRatingBbfcRatingEnum::Bbfc12a), + "bbfc12" => Ok(ContentRatingBbfcRatingEnum::Bbfc12), + "bbfc15" => Ok(ContentRatingBbfcRatingEnum::Bbfc15), + "bbfc18" => Ok(ContentRatingBbfcRatingEnum::Bbfc18), + "bbfcR18" => Ok(ContentRatingBbfcRatingEnum::BbfcR18), + "bbfcUnrated" => Ok(ContentRatingBbfcRatingEnum::BbfcUnrated), + _=> Err(()), + } + } +} + +impl<'a> Into> for &'a ContentRatingBbfcRatingEnum { + fn into(self) -> std::borrow::Cow<'a, str> { + self.as_ref().into() + } +} + + +#[derive(Clone, Copy, Eq, Hash, Debug, PartialEq, Serialize, Deserialize)] +/// The video's rating from Thailand's Board of Film and Video Censors. +pub enum ContentRatingBfvcRatingEnum { + + /// "bfvcUnspecified" + #[serde(rename="bfvcUnspecified")] + BfvcUnspecified, + + + /// G + /// + /// "bfvcG" + #[serde(rename="bfvcG")] + BfvcG, + + + /// E + /// + /// "bfvcE" + #[serde(rename="bfvcE")] + BfvcE, + + + /// 13 + /// + /// "bfvc13" + #[serde(rename="bfvc13")] + Bfvc13, + + + /// 15 + /// + /// "bfvc15" + #[serde(rename="bfvc15")] + Bfvc15, + + + /// 18 + /// + /// "bfvc18" + #[serde(rename="bfvc18")] + Bfvc18, + + + /// 20 + /// + /// "bfvc20" + #[serde(rename="bfvc20")] + Bfvc20, + + + /// B + /// + /// "bfvcB" + #[serde(rename="bfvcB")] + BfvcB, + + /// "bfvcUnrated" + #[serde(rename="bfvcUnrated")] + BfvcUnrated, +} + +impl AsRef for ContentRatingBfvcRatingEnum { + fn as_ref(&self) -> &str { + match *self { + ContentRatingBfvcRatingEnum::BfvcUnspecified => "bfvcUnspecified", + ContentRatingBfvcRatingEnum::BfvcG => "bfvcG", + ContentRatingBfvcRatingEnum::BfvcE => "bfvcE", + ContentRatingBfvcRatingEnum::Bfvc13 => "bfvc13", + ContentRatingBfvcRatingEnum::Bfvc15 => "bfvc15", + ContentRatingBfvcRatingEnum::Bfvc18 => "bfvc18", + ContentRatingBfvcRatingEnum::Bfvc20 => "bfvc20", + ContentRatingBfvcRatingEnum::BfvcB => "bfvcB", + ContentRatingBfvcRatingEnum::BfvcUnrated => "bfvcUnrated", + } + } +} + +impl std::convert::TryFrom< &str> for ContentRatingBfvcRatingEnum { + type Error = (); + fn try_from(value: &str) -> Result { + match value { + "bfvcUnspecified" => Ok(ContentRatingBfvcRatingEnum::BfvcUnspecified), + "bfvcG" => Ok(ContentRatingBfvcRatingEnum::BfvcG), + "bfvcE" => Ok(ContentRatingBfvcRatingEnum::BfvcE), + "bfvc13" => Ok(ContentRatingBfvcRatingEnum::Bfvc13), + "bfvc15" => Ok(ContentRatingBfvcRatingEnum::Bfvc15), + "bfvc18" => Ok(ContentRatingBfvcRatingEnum::Bfvc18), + "bfvc20" => Ok(ContentRatingBfvcRatingEnum::Bfvc20), + "bfvcB" => Ok(ContentRatingBfvcRatingEnum::BfvcB), + "bfvcUnrated" => Ok(ContentRatingBfvcRatingEnum::BfvcUnrated), + _=> Err(()), + } + } +} + +impl<'a> Into> for &'a ContentRatingBfvcRatingEnum { + fn into(self) -> std::borrow::Cow<'a, str> { + self.as_ref().into() + } +} + + +#[derive(Clone, Copy, Eq, Hash, Debug, PartialEq, Serialize, Deserialize)] +/// The video's rating from the Austrian Board of Media Classification (Bundesministerium für Unterricht, Kunst und Kultur). +pub enum ContentRatingBmukkRatingEnum { + + /// "bmukkUnspecified" + #[serde(rename="bmukkUnspecified")] + BmukkUnspecified, + + + /// Unrestricted + /// + /// "bmukkAa" + #[serde(rename="bmukkAa")] + BmukkAa, + + + /// 6+ + /// + /// "bmukk6" + #[serde(rename="bmukk6")] + Bmukk6, + + + /// 8+ + /// + /// "bmukk8" + #[serde(rename="bmukk8")] + Bmukk8, + + + /// 10+ + /// + /// "bmukk10" + #[serde(rename="bmukk10")] + Bmukk10, + + + /// 12+ + /// + /// "bmukk12" + #[serde(rename="bmukk12")] + Bmukk12, + + + /// 14+ + /// + /// "bmukk14" + #[serde(rename="bmukk14")] + Bmukk14, + + + /// 16+ + /// + /// "bmukk16" + #[serde(rename="bmukk16")] + Bmukk16, + + /// "bmukkUnrated" + #[serde(rename="bmukkUnrated")] + BmukkUnrated, +} + +impl AsRef for ContentRatingBmukkRatingEnum { + fn as_ref(&self) -> &str { + match *self { + ContentRatingBmukkRatingEnum::BmukkUnspecified => "bmukkUnspecified", + ContentRatingBmukkRatingEnum::BmukkAa => "bmukkAa", + ContentRatingBmukkRatingEnum::Bmukk6 => "bmukk6", + ContentRatingBmukkRatingEnum::Bmukk8 => "bmukk8", + ContentRatingBmukkRatingEnum::Bmukk10 => "bmukk10", + ContentRatingBmukkRatingEnum::Bmukk12 => "bmukk12", + ContentRatingBmukkRatingEnum::Bmukk14 => "bmukk14", + ContentRatingBmukkRatingEnum::Bmukk16 => "bmukk16", + ContentRatingBmukkRatingEnum::BmukkUnrated => "bmukkUnrated", + } + } +} + +impl std::convert::TryFrom< &str> for ContentRatingBmukkRatingEnum { + type Error = (); + fn try_from(value: &str) -> Result { + match value { + "bmukkUnspecified" => Ok(ContentRatingBmukkRatingEnum::BmukkUnspecified), + "bmukkAa" => Ok(ContentRatingBmukkRatingEnum::BmukkAa), + "bmukk6" => Ok(ContentRatingBmukkRatingEnum::Bmukk6), + "bmukk8" => Ok(ContentRatingBmukkRatingEnum::Bmukk8), + "bmukk10" => Ok(ContentRatingBmukkRatingEnum::Bmukk10), + "bmukk12" => Ok(ContentRatingBmukkRatingEnum::Bmukk12), + "bmukk14" => Ok(ContentRatingBmukkRatingEnum::Bmukk14), + "bmukk16" => Ok(ContentRatingBmukkRatingEnum::Bmukk16), + "bmukkUnrated" => Ok(ContentRatingBmukkRatingEnum::BmukkUnrated), + _=> Err(()), + } + } +} + +impl<'a> Into> for &'a ContentRatingBmukkRatingEnum { + fn into(self) -> std::borrow::Cow<'a, str> { + self.as_ref().into() + } +} + + +#[derive(Clone, Copy, Eq, Hash, Debug, PartialEq, Serialize, Deserialize)] +/// Rating system for Canadian TV - Canadian TV Classification System The video's rating from the Canadian Radio-Television and Telecommunications Commission (CRTC) for Canadian English-language broadcasts. For more information, see the Canadian Broadcast Standards Council website. +pub enum ContentRatingCatvRatingEnum { + + /// "catvUnspecified" + #[serde(rename="catvUnspecified")] + CatvUnspecified, + + + /// C + /// + /// "catvC" + #[serde(rename="catvC")] + CatvC, + + + /// C8 + /// + /// "catvC8" + #[serde(rename="catvC8")] + CatvC8, + + + /// G + /// + /// "catvG" + #[serde(rename="catvG")] + CatvG, + + + /// PG + /// + /// "catvPg" + #[serde(rename="catvPg")] + CatvPg, + + + /// 14+ + /// + /// "catv14plus" + #[serde(rename="catv14plus")] + Catv14plus, + + + /// 18+ + /// + /// "catv18plus" + #[serde(rename="catv18plus")] + Catv18plus, + + /// "catvUnrated" + #[serde(rename="catvUnrated")] + CatvUnrated, + + /// "catvE" + #[serde(rename="catvE")] + CatvE, +} + +impl AsRef for ContentRatingCatvRatingEnum { + fn as_ref(&self) -> &str { + match *self { + ContentRatingCatvRatingEnum::CatvUnspecified => "catvUnspecified", + ContentRatingCatvRatingEnum::CatvC => "catvC", + ContentRatingCatvRatingEnum::CatvC8 => "catvC8", + ContentRatingCatvRatingEnum::CatvG => "catvG", + ContentRatingCatvRatingEnum::CatvPg => "catvPg", + ContentRatingCatvRatingEnum::Catv14plus => "catv14plus", + ContentRatingCatvRatingEnum::Catv18plus => "catv18plus", + ContentRatingCatvRatingEnum::CatvUnrated => "catvUnrated", + ContentRatingCatvRatingEnum::CatvE => "catvE", + } + } +} + +impl std::convert::TryFrom< &str> for ContentRatingCatvRatingEnum { + type Error = (); + fn try_from(value: &str) -> Result { + match value { + "catvUnspecified" => Ok(ContentRatingCatvRatingEnum::CatvUnspecified), + "catvC" => Ok(ContentRatingCatvRatingEnum::CatvC), + "catvC8" => Ok(ContentRatingCatvRatingEnum::CatvC8), + "catvG" => Ok(ContentRatingCatvRatingEnum::CatvG), + "catvPg" => Ok(ContentRatingCatvRatingEnum::CatvPg), + "catv14plus" => Ok(ContentRatingCatvRatingEnum::Catv14plus), + "catv18plus" => Ok(ContentRatingCatvRatingEnum::Catv18plus), + "catvUnrated" => Ok(ContentRatingCatvRatingEnum::CatvUnrated), + "catvE" => Ok(ContentRatingCatvRatingEnum::CatvE), + _=> Err(()), + } + } +} + +impl<'a> Into> for &'a ContentRatingCatvRatingEnum { + fn into(self) -> std::borrow::Cow<'a, str> { + self.as_ref().into() + } +} + + +#[derive(Clone, Copy, Eq, Hash, Debug, PartialEq, Serialize, Deserialize)] +/// The video's rating from the Canadian Radio-Television and Telecommunications Commission (CRTC) for Canadian French-language broadcasts. For more information, see the Canadian Broadcast Standards Council website. +pub enum ContentRatingCatvfrRatingEnum { + + /// "catvfrUnspecified" + #[serde(rename="catvfrUnspecified")] + CatvfrUnspecified, + + + /// G + /// + /// "catvfrG" + #[serde(rename="catvfrG")] + CatvfrG, + + + /// 8+ + /// + /// "catvfr8plus" + #[serde(rename="catvfr8plus")] + Catvfr8plus, + + + /// 13+ + /// + /// "catvfr13plus" + #[serde(rename="catvfr13plus")] + Catvfr13plus, + + + /// 16+ + /// + /// "catvfr16plus" + #[serde(rename="catvfr16plus")] + Catvfr16plus, + + + /// 18+ + /// + /// "catvfr18plus" + #[serde(rename="catvfr18plus")] + Catvfr18plus, + + /// "catvfrUnrated" + #[serde(rename="catvfrUnrated")] + CatvfrUnrated, + + /// "catvfrE" + #[serde(rename="catvfrE")] + CatvfrE, +} + +impl AsRef for ContentRatingCatvfrRatingEnum { + fn as_ref(&self) -> &str { + match *self { + ContentRatingCatvfrRatingEnum::CatvfrUnspecified => "catvfrUnspecified", + ContentRatingCatvfrRatingEnum::CatvfrG => "catvfrG", + ContentRatingCatvfrRatingEnum::Catvfr8plus => "catvfr8plus", + ContentRatingCatvfrRatingEnum::Catvfr13plus => "catvfr13plus", + ContentRatingCatvfrRatingEnum::Catvfr16plus => "catvfr16plus", + ContentRatingCatvfrRatingEnum::Catvfr18plus => "catvfr18plus", + ContentRatingCatvfrRatingEnum::CatvfrUnrated => "catvfrUnrated", + ContentRatingCatvfrRatingEnum::CatvfrE => "catvfrE", + } + } +} + +impl std::convert::TryFrom< &str> for ContentRatingCatvfrRatingEnum { + type Error = (); + fn try_from(value: &str) -> Result { + match value { + "catvfrUnspecified" => Ok(ContentRatingCatvfrRatingEnum::CatvfrUnspecified), + "catvfrG" => Ok(ContentRatingCatvfrRatingEnum::CatvfrG), + "catvfr8plus" => Ok(ContentRatingCatvfrRatingEnum::Catvfr8plus), + "catvfr13plus" => Ok(ContentRatingCatvfrRatingEnum::Catvfr13plus), + "catvfr16plus" => Ok(ContentRatingCatvfrRatingEnum::Catvfr16plus), + "catvfr18plus" => Ok(ContentRatingCatvfrRatingEnum::Catvfr18plus), + "catvfrUnrated" => Ok(ContentRatingCatvfrRatingEnum::CatvfrUnrated), + "catvfrE" => Ok(ContentRatingCatvfrRatingEnum::CatvfrE), + _=> Err(()), + } + } +} + +impl<'a> Into> for &'a ContentRatingCatvfrRatingEnum { + fn into(self) -> std::borrow::Cow<'a, str> { + self.as_ref().into() + } +} + + +#[derive(Clone, Copy, Eq, Hash, Debug, PartialEq, Serialize, Deserialize)] +/// The video's Central Board of Film Certification (CBFC - India) rating. +pub enum ContentRatingCbfcRatingEnum { + + /// "cbfcUnspecified" + #[serde(rename="cbfcUnspecified")] + CbfcUnspecified, + + + /// U + /// + /// "cbfcU" + #[serde(rename="cbfcU")] + CbfcU, + + + /// U/A + /// + /// "cbfcUA" + #[serde(rename="cbfcUA")] + CbfcUA, + + + /// U/A 7+ + /// + /// "cbfcUA7plus" + #[serde(rename="cbfcUA7plus")] + CbfcUA7plus, + + + /// U/A 13+ + /// + /// "cbfcUA13plus" + #[serde(rename="cbfcUA13plus")] + CbfcUA13plus, + + + /// U/A 16+ + /// + /// "cbfcUA16plus" + #[serde(rename="cbfcUA16plus")] + CbfcUA16plus, + + + /// A + /// + /// "cbfcA" + #[serde(rename="cbfcA")] + CbfcA, + + + /// S + /// + /// "cbfcS" + #[serde(rename="cbfcS")] + CbfcS, + + /// "cbfcUnrated" + #[serde(rename="cbfcUnrated")] + CbfcUnrated, +} + +impl AsRef for ContentRatingCbfcRatingEnum { + fn as_ref(&self) -> &str { + match *self { + ContentRatingCbfcRatingEnum::CbfcUnspecified => "cbfcUnspecified", + ContentRatingCbfcRatingEnum::CbfcU => "cbfcU", + ContentRatingCbfcRatingEnum::CbfcUA => "cbfcUA", + ContentRatingCbfcRatingEnum::CbfcUA7plus => "cbfcUA7plus", + ContentRatingCbfcRatingEnum::CbfcUA13plus => "cbfcUA13plus", + ContentRatingCbfcRatingEnum::CbfcUA16plus => "cbfcUA16plus", + ContentRatingCbfcRatingEnum::CbfcA => "cbfcA", + ContentRatingCbfcRatingEnum::CbfcS => "cbfcS", + ContentRatingCbfcRatingEnum::CbfcUnrated => "cbfcUnrated", + } + } +} + +impl std::convert::TryFrom< &str> for ContentRatingCbfcRatingEnum { + type Error = (); + fn try_from(value: &str) -> Result { + match value { + "cbfcUnspecified" => Ok(ContentRatingCbfcRatingEnum::CbfcUnspecified), + "cbfcU" => Ok(ContentRatingCbfcRatingEnum::CbfcU), + "cbfcUA" => Ok(ContentRatingCbfcRatingEnum::CbfcUA), + "cbfcUA7plus" => Ok(ContentRatingCbfcRatingEnum::CbfcUA7plus), + "cbfcUA13plus" => Ok(ContentRatingCbfcRatingEnum::CbfcUA13plus), + "cbfcUA16plus" => Ok(ContentRatingCbfcRatingEnum::CbfcUA16plus), + "cbfcA" => Ok(ContentRatingCbfcRatingEnum::CbfcA), + "cbfcS" => Ok(ContentRatingCbfcRatingEnum::CbfcS), + "cbfcUnrated" => Ok(ContentRatingCbfcRatingEnum::CbfcUnrated), + _=> Err(()), + } + } +} + +impl<'a> Into> for &'a ContentRatingCbfcRatingEnum { + fn into(self) -> std::borrow::Cow<'a, str> { + self.as_ref().into() + } +} + + +#[derive(Clone, Copy, Eq, Hash, Debug, PartialEq, Serialize, Deserialize)] +/// The video's Consejo de Calificación Cinematográfica (Chile) rating. +pub enum ContentRatingCccRatingEnum { + + /// "cccUnspecified" + #[serde(rename="cccUnspecified")] + CccUnspecified, + + + /// Todo espectador + /// + /// "cccTe" + #[serde(rename="cccTe")] + CccTe, + + + /// 6+ - Inconveniente para menores de 7 años + /// + /// "ccc6" + #[serde(rename="ccc6")] + Ccc6, + + + /// 14+ + /// + /// "ccc14" + #[serde(rename="ccc14")] + Ccc14, + + + /// 18+ + /// + /// "ccc18" + #[serde(rename="ccc18")] + Ccc18, + + + /// 18+ - contenido excesivamente violento + /// + /// "ccc18v" + #[serde(rename="ccc18v")] + Ccc18v, + + + /// 18+ - contenido pornográfico + /// + /// "ccc18s" + #[serde(rename="ccc18s")] + Ccc18s, + + /// "cccUnrated" + #[serde(rename="cccUnrated")] + CccUnrated, +} + +impl AsRef for ContentRatingCccRatingEnum { + fn as_ref(&self) -> &str { + match *self { + ContentRatingCccRatingEnum::CccUnspecified => "cccUnspecified", + ContentRatingCccRatingEnum::CccTe => "cccTe", + ContentRatingCccRatingEnum::Ccc6 => "ccc6", + ContentRatingCccRatingEnum::Ccc14 => "ccc14", + ContentRatingCccRatingEnum::Ccc18 => "ccc18", + ContentRatingCccRatingEnum::Ccc18v => "ccc18v", + ContentRatingCccRatingEnum::Ccc18s => "ccc18s", + ContentRatingCccRatingEnum::CccUnrated => "cccUnrated", + } + } +} + +impl std::convert::TryFrom< &str> for ContentRatingCccRatingEnum { + type Error = (); + fn try_from(value: &str) -> Result { + match value { + "cccUnspecified" => Ok(ContentRatingCccRatingEnum::CccUnspecified), + "cccTe" => Ok(ContentRatingCccRatingEnum::CccTe), + "ccc6" => Ok(ContentRatingCccRatingEnum::Ccc6), + "ccc14" => Ok(ContentRatingCccRatingEnum::Ccc14), + "ccc18" => Ok(ContentRatingCccRatingEnum::Ccc18), + "ccc18v" => Ok(ContentRatingCccRatingEnum::Ccc18v), + "ccc18s" => Ok(ContentRatingCccRatingEnum::Ccc18s), + "cccUnrated" => Ok(ContentRatingCccRatingEnum::CccUnrated), + _=> Err(()), + } + } +} + +impl<'a> Into> for &'a ContentRatingCccRatingEnum { + fn into(self) -> std::borrow::Cow<'a, str> { + self.as_ref().into() + } +} + + +#[derive(Clone, Copy, Eq, Hash, Debug, PartialEq, Serialize, Deserialize)] +/// The video's rating from Portugal's Comissão de Classificação de Espect´culos. +pub enum ContentRatingCceRatingEnum { + + /// "cceUnspecified" + #[serde(rename="cceUnspecified")] + CceUnspecified, + + + /// 4 + /// + /// "cceM4" + #[serde(rename="cceM4")] + CceM4, + + + /// 6 + /// + /// "cceM6" + #[serde(rename="cceM6")] + CceM6, + + + /// 12 + /// + /// "cceM12" + #[serde(rename="cceM12")] + CceM12, + + + /// 16 + /// + /// "cceM16" + #[serde(rename="cceM16")] + CceM16, + + + /// 18 + /// + /// "cceM18" + #[serde(rename="cceM18")] + CceM18, + + /// "cceUnrated" + #[serde(rename="cceUnrated")] + CceUnrated, + + + /// 14 + /// + /// "cceM14" + #[serde(rename="cceM14")] + CceM14, +} + +impl AsRef for ContentRatingCceRatingEnum { + fn as_ref(&self) -> &str { + match *self { + ContentRatingCceRatingEnum::CceUnspecified => "cceUnspecified", + ContentRatingCceRatingEnum::CceM4 => "cceM4", + ContentRatingCceRatingEnum::CceM6 => "cceM6", + ContentRatingCceRatingEnum::CceM12 => "cceM12", + ContentRatingCceRatingEnum::CceM16 => "cceM16", + ContentRatingCceRatingEnum::CceM18 => "cceM18", + ContentRatingCceRatingEnum::CceUnrated => "cceUnrated", + ContentRatingCceRatingEnum::CceM14 => "cceM14", + } + } +} + +impl std::convert::TryFrom< &str> for ContentRatingCceRatingEnum { + type Error = (); + fn try_from(value: &str) -> Result { + match value { + "cceUnspecified" => Ok(ContentRatingCceRatingEnum::CceUnspecified), + "cceM4" => Ok(ContentRatingCceRatingEnum::CceM4), + "cceM6" => Ok(ContentRatingCceRatingEnum::CceM6), + "cceM12" => Ok(ContentRatingCceRatingEnum::CceM12), + "cceM16" => Ok(ContentRatingCceRatingEnum::CceM16), + "cceM18" => Ok(ContentRatingCceRatingEnum::CceM18), + "cceUnrated" => Ok(ContentRatingCceRatingEnum::CceUnrated), + "cceM14" => Ok(ContentRatingCceRatingEnum::CceM14), + _=> Err(()), + } + } +} + +impl<'a> Into> for &'a ContentRatingCceRatingEnum { + fn into(self) -> std::borrow::Cow<'a, str> { + self.as_ref().into() + } +} + + +#[derive(Clone, Copy, Eq, Hash, Debug, PartialEq, Serialize, Deserialize)] +/// The video's rating in Switzerland. +pub enum ContentRatingChfilmRatingEnum { + + /// "chfilmUnspecified" + #[serde(rename="chfilmUnspecified")] + ChfilmUnspecified, + + + /// 0 + /// + /// "chfilm0" + #[serde(rename="chfilm0")] + Chfilm0, + + + /// 6 + /// + /// "chfilm6" + #[serde(rename="chfilm6")] + Chfilm6, + + + /// 12 + /// + /// "chfilm12" + #[serde(rename="chfilm12")] + Chfilm12, + + + /// 16 + /// + /// "chfilm16" + #[serde(rename="chfilm16")] + Chfilm16, + + + /// 18 + /// + /// "chfilm18" + #[serde(rename="chfilm18")] + Chfilm18, + + /// "chfilmUnrated" + #[serde(rename="chfilmUnrated")] + ChfilmUnrated, +} + +impl AsRef for ContentRatingChfilmRatingEnum { + fn as_ref(&self) -> &str { + match *self { + ContentRatingChfilmRatingEnum::ChfilmUnspecified => "chfilmUnspecified", + ContentRatingChfilmRatingEnum::Chfilm0 => "chfilm0", + ContentRatingChfilmRatingEnum::Chfilm6 => "chfilm6", + ContentRatingChfilmRatingEnum::Chfilm12 => "chfilm12", + ContentRatingChfilmRatingEnum::Chfilm16 => "chfilm16", + ContentRatingChfilmRatingEnum::Chfilm18 => "chfilm18", + ContentRatingChfilmRatingEnum::ChfilmUnrated => "chfilmUnrated", + } + } +} + +impl std::convert::TryFrom< &str> for ContentRatingChfilmRatingEnum { + type Error = (); + fn try_from(value: &str) -> Result { + match value { + "chfilmUnspecified" => Ok(ContentRatingChfilmRatingEnum::ChfilmUnspecified), + "chfilm0" => Ok(ContentRatingChfilmRatingEnum::Chfilm0), + "chfilm6" => Ok(ContentRatingChfilmRatingEnum::Chfilm6), + "chfilm12" => Ok(ContentRatingChfilmRatingEnum::Chfilm12), + "chfilm16" => Ok(ContentRatingChfilmRatingEnum::Chfilm16), + "chfilm18" => Ok(ContentRatingChfilmRatingEnum::Chfilm18), + "chfilmUnrated" => Ok(ContentRatingChfilmRatingEnum::ChfilmUnrated), + _=> Err(()), + } + } +} + +impl<'a> Into> for &'a ContentRatingChfilmRatingEnum { + fn into(self) -> std::borrow::Cow<'a, str> { + self.as_ref().into() + } +} + + +#[derive(Clone, Copy, Eq, Hash, Debug, PartialEq, Serialize, Deserialize)] +/// The video's Canadian Home Video Rating System (CHVRS) rating. +pub enum ContentRatingChvrsRatingEnum { + + /// "chvrsUnspecified" + #[serde(rename="chvrsUnspecified")] + ChvrsUnspecified, + + + /// G + /// + /// "chvrsG" + #[serde(rename="chvrsG")] + ChvrsG, + + + /// PG + /// + /// "chvrsPg" + #[serde(rename="chvrsPg")] + ChvrsPg, + + + /// 14A + /// + /// "chvrs14a" + #[serde(rename="chvrs14a")] + Chvrs14a, + + + /// 18A + /// + /// "chvrs18a" + #[serde(rename="chvrs18a")] + Chvrs18a, + + + /// R + /// + /// "chvrsR" + #[serde(rename="chvrsR")] + ChvrsR, + + + /// E + /// + /// "chvrsE" + #[serde(rename="chvrsE")] + ChvrsE, + + /// "chvrsUnrated" + #[serde(rename="chvrsUnrated")] + ChvrsUnrated, +} + +impl AsRef for ContentRatingChvrsRatingEnum { + fn as_ref(&self) -> &str { + match *self { + ContentRatingChvrsRatingEnum::ChvrsUnspecified => "chvrsUnspecified", + ContentRatingChvrsRatingEnum::ChvrsG => "chvrsG", + ContentRatingChvrsRatingEnum::ChvrsPg => "chvrsPg", + ContentRatingChvrsRatingEnum::Chvrs14a => "chvrs14a", + ContentRatingChvrsRatingEnum::Chvrs18a => "chvrs18a", + ContentRatingChvrsRatingEnum::ChvrsR => "chvrsR", + ContentRatingChvrsRatingEnum::ChvrsE => "chvrsE", + ContentRatingChvrsRatingEnum::ChvrsUnrated => "chvrsUnrated", + } + } +} + +impl std::convert::TryFrom< &str> for ContentRatingChvrsRatingEnum { + type Error = (); + fn try_from(value: &str) -> Result { + match value { + "chvrsUnspecified" => Ok(ContentRatingChvrsRatingEnum::ChvrsUnspecified), + "chvrsG" => Ok(ContentRatingChvrsRatingEnum::ChvrsG), + "chvrsPg" => Ok(ContentRatingChvrsRatingEnum::ChvrsPg), + "chvrs14a" => Ok(ContentRatingChvrsRatingEnum::Chvrs14a), + "chvrs18a" => Ok(ContentRatingChvrsRatingEnum::Chvrs18a), + "chvrsR" => Ok(ContentRatingChvrsRatingEnum::ChvrsR), + "chvrsE" => Ok(ContentRatingChvrsRatingEnum::ChvrsE), + "chvrsUnrated" => Ok(ContentRatingChvrsRatingEnum::ChvrsUnrated), + _=> Err(()), + } + } +} + +impl<'a> Into> for &'a ContentRatingChvrsRatingEnum { + fn into(self) -> std::borrow::Cow<'a, str> { + self.as_ref().into() + } +} + + +#[derive(Clone, Copy, Eq, Hash, Debug, PartialEq, Serialize, Deserialize)] +/// The video's rating from the Commission de Contrôle des Films (Belgium). +pub enum ContentRatingCicfRatingEnum { + + /// "cicfUnspecified" + #[serde(rename="cicfUnspecified")] + CicfUnspecified, + + + /// E + /// + /// "cicfE" + #[serde(rename="cicfE")] + CicfE, + + + /// KT/EA + /// + /// "cicfKtEa" + #[serde(rename="cicfKtEa")] + CicfKtEa, + + + /// KNT/ENA + /// + /// "cicfKntEna" + #[serde(rename="cicfKntEna")] + CicfKntEna, + + /// "cicfUnrated" + #[serde(rename="cicfUnrated")] + CicfUnrated, +} + +impl AsRef for ContentRatingCicfRatingEnum { + fn as_ref(&self) -> &str { + match *self { + ContentRatingCicfRatingEnum::CicfUnspecified => "cicfUnspecified", + ContentRatingCicfRatingEnum::CicfE => "cicfE", + ContentRatingCicfRatingEnum::CicfKtEa => "cicfKtEa", + ContentRatingCicfRatingEnum::CicfKntEna => "cicfKntEna", + ContentRatingCicfRatingEnum::CicfUnrated => "cicfUnrated", + } + } +} + +impl std::convert::TryFrom< &str> for ContentRatingCicfRatingEnum { + type Error = (); + fn try_from(value: &str) -> Result { + match value { + "cicfUnspecified" => Ok(ContentRatingCicfRatingEnum::CicfUnspecified), + "cicfE" => Ok(ContentRatingCicfRatingEnum::CicfE), + "cicfKtEa" => Ok(ContentRatingCicfRatingEnum::CicfKtEa), + "cicfKntEna" => Ok(ContentRatingCicfRatingEnum::CicfKntEna), + "cicfUnrated" => Ok(ContentRatingCicfRatingEnum::CicfUnrated), + _=> Err(()), + } + } +} + +impl<'a> Into> for &'a ContentRatingCicfRatingEnum { + fn into(self) -> std::borrow::Cow<'a, str> { + self.as_ref().into() + } +} + + +#[derive(Clone, Copy, Eq, Hash, Debug, PartialEq, Serialize, Deserialize)] +/// The video's rating from Romania's CONSILIUL NATIONAL AL AUDIOVIZUALULUI (CNA). +pub enum ContentRatingCnaRatingEnum { + + /// "cnaUnspecified" + #[serde(rename="cnaUnspecified")] + CnaUnspecified, + + + /// AP + /// + /// "cnaAp" + #[serde(rename="cnaAp")] + CnaAp, + + + /// 12 + /// + /// "cna12" + #[serde(rename="cna12")] + Cna12, + + + /// 15 + /// + /// "cna15" + #[serde(rename="cna15")] + Cna15, + + + /// 18 + /// + /// "cna18" + #[serde(rename="cna18")] + Cna18, + + + /// 18+ + /// + /// "cna18plus" + #[serde(rename="cna18plus")] + Cna18plus, + + /// "cnaUnrated" + #[serde(rename="cnaUnrated")] + CnaUnrated, +} + +impl AsRef for ContentRatingCnaRatingEnum { + fn as_ref(&self) -> &str { + match *self { + ContentRatingCnaRatingEnum::CnaUnspecified => "cnaUnspecified", + ContentRatingCnaRatingEnum::CnaAp => "cnaAp", + ContentRatingCnaRatingEnum::Cna12 => "cna12", + ContentRatingCnaRatingEnum::Cna15 => "cna15", + ContentRatingCnaRatingEnum::Cna18 => "cna18", + ContentRatingCnaRatingEnum::Cna18plus => "cna18plus", + ContentRatingCnaRatingEnum::CnaUnrated => "cnaUnrated", + } + } +} + +impl std::convert::TryFrom< &str> for ContentRatingCnaRatingEnum { + type Error = (); + fn try_from(value: &str) -> Result { + match value { + "cnaUnspecified" => Ok(ContentRatingCnaRatingEnum::CnaUnspecified), + "cnaAp" => Ok(ContentRatingCnaRatingEnum::CnaAp), + "cna12" => Ok(ContentRatingCnaRatingEnum::Cna12), + "cna15" => Ok(ContentRatingCnaRatingEnum::Cna15), + "cna18" => Ok(ContentRatingCnaRatingEnum::Cna18), + "cna18plus" => Ok(ContentRatingCnaRatingEnum::Cna18plus), + "cnaUnrated" => Ok(ContentRatingCnaRatingEnum::CnaUnrated), + _=> Err(()), + } + } +} + +impl<'a> Into> for &'a ContentRatingCnaRatingEnum { + fn into(self) -> std::borrow::Cow<'a, str> { + self.as_ref().into() + } +} + + +#[derive(Clone, Copy, Eq, Hash, Debug, PartialEq, Serialize, Deserialize)] +/// Rating system in France - Commission de classification cinematographique +pub enum ContentRatingCncRatingEnum { + + /// "cncUnspecified" + #[serde(rename="cncUnspecified")] + CncUnspecified, + + + /// T + /// + /// "cncT" + #[serde(rename="cncT")] + CncT, + + + /// 10 + /// + /// "cnc10" + #[serde(rename="cnc10")] + Cnc10, + + + /// 12 + /// + /// "cnc12" + #[serde(rename="cnc12")] + Cnc12, + + + /// 16 + /// + /// "cnc16" + #[serde(rename="cnc16")] + Cnc16, + + + /// 18 + /// + /// "cnc18" + #[serde(rename="cnc18")] + Cnc18, + + + /// E + /// + /// "cncE" + #[serde(rename="cncE")] + CncE, + + + /// interdiction + /// + /// "cncInterdiction" + #[serde(rename="cncInterdiction")] + CncInterdiction, + + /// "cncUnrated" + #[serde(rename="cncUnrated")] + CncUnrated, +} + +impl AsRef for ContentRatingCncRatingEnum { + fn as_ref(&self) -> &str { + match *self { + ContentRatingCncRatingEnum::CncUnspecified => "cncUnspecified", + ContentRatingCncRatingEnum::CncT => "cncT", + ContentRatingCncRatingEnum::Cnc10 => "cnc10", + ContentRatingCncRatingEnum::Cnc12 => "cnc12", + ContentRatingCncRatingEnum::Cnc16 => "cnc16", + ContentRatingCncRatingEnum::Cnc18 => "cnc18", + ContentRatingCncRatingEnum::CncE => "cncE", + ContentRatingCncRatingEnum::CncInterdiction => "cncInterdiction", + ContentRatingCncRatingEnum::CncUnrated => "cncUnrated", + } + } +} + +impl std::convert::TryFrom< &str> for ContentRatingCncRatingEnum { + type Error = (); + fn try_from(value: &str) -> Result { + match value { + "cncUnspecified" => Ok(ContentRatingCncRatingEnum::CncUnspecified), + "cncT" => Ok(ContentRatingCncRatingEnum::CncT), + "cnc10" => Ok(ContentRatingCncRatingEnum::Cnc10), + "cnc12" => Ok(ContentRatingCncRatingEnum::Cnc12), + "cnc16" => Ok(ContentRatingCncRatingEnum::Cnc16), + "cnc18" => Ok(ContentRatingCncRatingEnum::Cnc18), + "cncE" => Ok(ContentRatingCncRatingEnum::CncE), + "cncInterdiction" => Ok(ContentRatingCncRatingEnum::CncInterdiction), + "cncUnrated" => Ok(ContentRatingCncRatingEnum::CncUnrated), + _=> Err(()), + } + } +} + +impl<'a> Into> for &'a ContentRatingCncRatingEnum { + fn into(self) -> std::borrow::Cow<'a, str> { + self.as_ref().into() + } +} + + +#[derive(Clone, Copy, Eq, Hash, Debug, PartialEq, Serialize, Deserialize)] +/// The video's rating from France's Conseil supérieur de l’audiovisuel, which rates broadcast content. +pub enum ContentRatingCsaRatingEnum { + + /// "csaUnspecified" + #[serde(rename="csaUnspecified")] + CsaUnspecified, + + + /// T + /// + /// "csaT" + #[serde(rename="csaT")] + CsaT, + + + /// 10 + /// + /// "csa10" + #[serde(rename="csa10")] + Csa10, + + + /// 12 + /// + /// "csa12" + #[serde(rename="csa12")] + Csa12, + + + /// 16 + /// + /// "csa16" + #[serde(rename="csa16")] + Csa16, + + + /// 18 + /// + /// "csa18" + #[serde(rename="csa18")] + Csa18, + + + /// Interdiction + /// + /// "csaInterdiction" + #[serde(rename="csaInterdiction")] + CsaInterdiction, + + /// "csaUnrated" + #[serde(rename="csaUnrated")] + CsaUnrated, +} + +impl AsRef for ContentRatingCsaRatingEnum { + fn as_ref(&self) -> &str { + match *self { + ContentRatingCsaRatingEnum::CsaUnspecified => "csaUnspecified", + ContentRatingCsaRatingEnum::CsaT => "csaT", + ContentRatingCsaRatingEnum::Csa10 => "csa10", + ContentRatingCsaRatingEnum::Csa12 => "csa12", + ContentRatingCsaRatingEnum::Csa16 => "csa16", + ContentRatingCsaRatingEnum::Csa18 => "csa18", + ContentRatingCsaRatingEnum::CsaInterdiction => "csaInterdiction", + ContentRatingCsaRatingEnum::CsaUnrated => "csaUnrated", + } + } +} + +impl std::convert::TryFrom< &str> for ContentRatingCsaRatingEnum { + type Error = (); + fn try_from(value: &str) -> Result { + match value { + "csaUnspecified" => Ok(ContentRatingCsaRatingEnum::CsaUnspecified), + "csaT" => Ok(ContentRatingCsaRatingEnum::CsaT), + "csa10" => Ok(ContentRatingCsaRatingEnum::Csa10), + "csa12" => Ok(ContentRatingCsaRatingEnum::Csa12), + "csa16" => Ok(ContentRatingCsaRatingEnum::Csa16), + "csa18" => Ok(ContentRatingCsaRatingEnum::Csa18), + "csaInterdiction" => Ok(ContentRatingCsaRatingEnum::CsaInterdiction), + "csaUnrated" => Ok(ContentRatingCsaRatingEnum::CsaUnrated), + _=> Err(()), + } + } +} + +impl<'a> Into> for &'a ContentRatingCsaRatingEnum { + fn into(self) -> std::borrow::Cow<'a, str> { + self.as_ref().into() + } +} + + +#[derive(Clone, Copy, Eq, Hash, Debug, PartialEq, Serialize, Deserialize)] +/// The video's rating from Luxembourg's Commission de surveillance de la classification des films (CSCF). +pub enum ContentRatingCscfRatingEnum { + + /// "cscfUnspecified" + #[serde(rename="cscfUnspecified")] + CscfUnspecified, + + + /// AL + /// + /// "cscfAl" + #[serde(rename="cscfAl")] + CscfAl, + + + /// A + /// + /// "cscfA" + #[serde(rename="cscfA")] + CscfA, + + + /// 6 + /// + /// "cscf6" + #[serde(rename="cscf6")] + Cscf6, + + + /// 9 + /// + /// "cscf9" + #[serde(rename="cscf9")] + Cscf9, + + + /// 12 + /// + /// "cscf12" + #[serde(rename="cscf12")] + Cscf12, + + + /// 16 + /// + /// "cscf16" + #[serde(rename="cscf16")] + Cscf16, + + + /// 18 + /// + /// "cscf18" + #[serde(rename="cscf18")] + Cscf18, + + /// "cscfUnrated" + #[serde(rename="cscfUnrated")] + CscfUnrated, +} + +impl AsRef for ContentRatingCscfRatingEnum { + fn as_ref(&self) -> &str { + match *self { + ContentRatingCscfRatingEnum::CscfUnspecified => "cscfUnspecified", + ContentRatingCscfRatingEnum::CscfAl => "cscfAl", + ContentRatingCscfRatingEnum::CscfA => "cscfA", + ContentRatingCscfRatingEnum::Cscf6 => "cscf6", + ContentRatingCscfRatingEnum::Cscf9 => "cscf9", + ContentRatingCscfRatingEnum::Cscf12 => "cscf12", + ContentRatingCscfRatingEnum::Cscf16 => "cscf16", + ContentRatingCscfRatingEnum::Cscf18 => "cscf18", + ContentRatingCscfRatingEnum::CscfUnrated => "cscfUnrated", + } + } +} + +impl std::convert::TryFrom< &str> for ContentRatingCscfRatingEnum { + type Error = (); + fn try_from(value: &str) -> Result { + match value { + "cscfUnspecified" => Ok(ContentRatingCscfRatingEnum::CscfUnspecified), + "cscfAl" => Ok(ContentRatingCscfRatingEnum::CscfAl), + "cscfA" => Ok(ContentRatingCscfRatingEnum::CscfA), + "cscf6" => Ok(ContentRatingCscfRatingEnum::Cscf6), + "cscf9" => Ok(ContentRatingCscfRatingEnum::Cscf9), + "cscf12" => Ok(ContentRatingCscfRatingEnum::Cscf12), + "cscf16" => Ok(ContentRatingCscfRatingEnum::Cscf16), + "cscf18" => Ok(ContentRatingCscfRatingEnum::Cscf18), + "cscfUnrated" => Ok(ContentRatingCscfRatingEnum::CscfUnrated), + _=> Err(()), + } + } +} + +impl<'a> Into> for &'a ContentRatingCscfRatingEnum { + fn into(self) -> std::borrow::Cow<'a, str> { + self.as_ref().into() + } +} + + +#[derive(Clone, Copy, Eq, Hash, Debug, PartialEq, Serialize, Deserialize)] +/// The video's rating in the Czech Republic. +pub enum ContentRatingCzfilmRatingEnum { + + /// "czfilmUnspecified" + #[serde(rename="czfilmUnspecified")] + CzfilmUnspecified, + + + /// U + /// + /// "czfilmU" + #[serde(rename="czfilmU")] + CzfilmU, + + + /// 12 + /// + /// "czfilm12" + #[serde(rename="czfilm12")] + Czfilm12, + + + /// 14 + /// + /// "czfilm14" + #[serde(rename="czfilm14")] + Czfilm14, + + + /// 18 + /// + /// "czfilm18" + #[serde(rename="czfilm18")] + Czfilm18, + + /// "czfilmUnrated" + #[serde(rename="czfilmUnrated")] + CzfilmUnrated, +} + +impl AsRef for ContentRatingCzfilmRatingEnum { + fn as_ref(&self) -> &str { + match *self { + ContentRatingCzfilmRatingEnum::CzfilmUnspecified => "czfilmUnspecified", + ContentRatingCzfilmRatingEnum::CzfilmU => "czfilmU", + ContentRatingCzfilmRatingEnum::Czfilm12 => "czfilm12", + ContentRatingCzfilmRatingEnum::Czfilm14 => "czfilm14", + ContentRatingCzfilmRatingEnum::Czfilm18 => "czfilm18", + ContentRatingCzfilmRatingEnum::CzfilmUnrated => "czfilmUnrated", + } + } +} + +impl std::convert::TryFrom< &str> for ContentRatingCzfilmRatingEnum { + type Error = (); + fn try_from(value: &str) -> Result { + match value { + "czfilmUnspecified" => Ok(ContentRatingCzfilmRatingEnum::CzfilmUnspecified), + "czfilmU" => Ok(ContentRatingCzfilmRatingEnum::CzfilmU), + "czfilm12" => Ok(ContentRatingCzfilmRatingEnum::Czfilm12), + "czfilm14" => Ok(ContentRatingCzfilmRatingEnum::Czfilm14), + "czfilm18" => Ok(ContentRatingCzfilmRatingEnum::Czfilm18), + "czfilmUnrated" => Ok(ContentRatingCzfilmRatingEnum::CzfilmUnrated), + _=> Err(()), + } + } +} + +impl<'a> Into> for &'a ContentRatingCzfilmRatingEnum { + fn into(self) -> std::borrow::Cow<'a, str> { + self.as_ref().into() + } +} + + +#[derive(Clone, Copy, Eq, Hash, Debug, PartialEq, Serialize, Deserialize)] +/// The video's Departamento de Justiça, Classificação, Qualificação e Títulos (DJCQT - Brazil) rating. +pub enum ContentRatingDjctqRatingEnum { + + /// "djctqUnspecified" + #[serde(rename="djctqUnspecified")] + DjctqUnspecified, + + + /// L + /// + /// "djctqL" + #[serde(rename="djctqL")] + DjctqL, + + + /// 10 + /// + /// "djctq10" + #[serde(rename="djctq10")] + Djctq10, + + + /// 12 + /// + /// "djctq12" + #[serde(rename="djctq12")] + Djctq12, + + + /// 14 + /// + /// "djctq14" + #[serde(rename="djctq14")] + Djctq14, + + + /// 16 + /// + /// "djctq16" + #[serde(rename="djctq16")] + Djctq16, + + + /// 18 + /// + /// "djctq18" + #[serde(rename="djctq18")] + Djctq18, + + /// "djctqEr" + #[serde(rename="djctqEr")] + DjctqEr, + + /// "djctqL10" + #[serde(rename="djctqL10")] + DjctqL10, + + /// "djctqL12" + #[serde(rename="djctqL12")] + DjctqL12, + + /// "djctqL14" + #[serde(rename="djctqL14")] + DjctqL14, + + /// "djctqL16" + #[serde(rename="djctqL16")] + DjctqL16, + + /// "djctqL18" + #[serde(rename="djctqL18")] + DjctqL18, + + /// "djctq1012" + #[serde(rename="djctq1012")] + Djctq1012, + + /// "djctq1014" + #[serde(rename="djctq1014")] + Djctq1014, + + /// "djctq1016" + #[serde(rename="djctq1016")] + Djctq1016, + + /// "djctq1018" + #[serde(rename="djctq1018")] + Djctq1018, + + /// "djctq1214" + #[serde(rename="djctq1214")] + Djctq1214, + + /// "djctq1216" + #[serde(rename="djctq1216")] + Djctq1216, + + /// "djctq1218" + #[serde(rename="djctq1218")] + Djctq1218, + + /// "djctq1416" + #[serde(rename="djctq1416")] + Djctq1416, + + /// "djctq1418" + #[serde(rename="djctq1418")] + Djctq1418, + + /// "djctq1618" + #[serde(rename="djctq1618")] + Djctq1618, + + /// "djctqUnrated" + #[serde(rename="djctqUnrated")] + DjctqUnrated, +} + +impl AsRef for ContentRatingDjctqRatingEnum { + fn as_ref(&self) -> &str { + match *self { + ContentRatingDjctqRatingEnum::DjctqUnspecified => "djctqUnspecified", + ContentRatingDjctqRatingEnum::DjctqL => "djctqL", + ContentRatingDjctqRatingEnum::Djctq10 => "djctq10", + ContentRatingDjctqRatingEnum::Djctq12 => "djctq12", + ContentRatingDjctqRatingEnum::Djctq14 => "djctq14", + ContentRatingDjctqRatingEnum::Djctq16 => "djctq16", + ContentRatingDjctqRatingEnum::Djctq18 => "djctq18", + ContentRatingDjctqRatingEnum::DjctqEr => "djctqEr", + ContentRatingDjctqRatingEnum::DjctqL10 => "djctqL10", + ContentRatingDjctqRatingEnum::DjctqL12 => "djctqL12", + ContentRatingDjctqRatingEnum::DjctqL14 => "djctqL14", + ContentRatingDjctqRatingEnum::DjctqL16 => "djctqL16", + ContentRatingDjctqRatingEnum::DjctqL18 => "djctqL18", + ContentRatingDjctqRatingEnum::Djctq1012 => "djctq1012", + ContentRatingDjctqRatingEnum::Djctq1014 => "djctq1014", + ContentRatingDjctqRatingEnum::Djctq1016 => "djctq1016", + ContentRatingDjctqRatingEnum::Djctq1018 => "djctq1018", + ContentRatingDjctqRatingEnum::Djctq1214 => "djctq1214", + ContentRatingDjctqRatingEnum::Djctq1216 => "djctq1216", + ContentRatingDjctqRatingEnum::Djctq1218 => "djctq1218", + ContentRatingDjctqRatingEnum::Djctq1416 => "djctq1416", + ContentRatingDjctqRatingEnum::Djctq1418 => "djctq1418", + ContentRatingDjctqRatingEnum::Djctq1618 => "djctq1618", + ContentRatingDjctqRatingEnum::DjctqUnrated => "djctqUnrated", + } + } +} + +impl std::convert::TryFrom< &str> for ContentRatingDjctqRatingEnum { + type Error = (); + fn try_from(value: &str) -> Result { + match value { + "djctqUnspecified" => Ok(ContentRatingDjctqRatingEnum::DjctqUnspecified), + "djctqL" => Ok(ContentRatingDjctqRatingEnum::DjctqL), + "djctq10" => Ok(ContentRatingDjctqRatingEnum::Djctq10), + "djctq12" => Ok(ContentRatingDjctqRatingEnum::Djctq12), + "djctq14" => Ok(ContentRatingDjctqRatingEnum::Djctq14), + "djctq16" => Ok(ContentRatingDjctqRatingEnum::Djctq16), + "djctq18" => Ok(ContentRatingDjctqRatingEnum::Djctq18), + "djctqEr" => Ok(ContentRatingDjctqRatingEnum::DjctqEr), + "djctqL10" => Ok(ContentRatingDjctqRatingEnum::DjctqL10), + "djctqL12" => Ok(ContentRatingDjctqRatingEnum::DjctqL12), + "djctqL14" => Ok(ContentRatingDjctqRatingEnum::DjctqL14), + "djctqL16" => Ok(ContentRatingDjctqRatingEnum::DjctqL16), + "djctqL18" => Ok(ContentRatingDjctqRatingEnum::DjctqL18), + "djctq1012" => Ok(ContentRatingDjctqRatingEnum::Djctq1012), + "djctq1014" => Ok(ContentRatingDjctqRatingEnum::Djctq1014), + "djctq1016" => Ok(ContentRatingDjctqRatingEnum::Djctq1016), + "djctq1018" => Ok(ContentRatingDjctqRatingEnum::Djctq1018), + "djctq1214" => Ok(ContentRatingDjctqRatingEnum::Djctq1214), + "djctq1216" => Ok(ContentRatingDjctqRatingEnum::Djctq1216), + "djctq1218" => Ok(ContentRatingDjctqRatingEnum::Djctq1218), + "djctq1416" => Ok(ContentRatingDjctqRatingEnum::Djctq1416), + "djctq1418" => Ok(ContentRatingDjctqRatingEnum::Djctq1418), + "djctq1618" => Ok(ContentRatingDjctqRatingEnum::Djctq1618), + "djctqUnrated" => Ok(ContentRatingDjctqRatingEnum::DjctqUnrated), + _=> Err(()), + } + } +} + +impl<'a> Into> for &'a ContentRatingDjctqRatingEnum { + fn into(self) -> std::borrow::Cow<'a, str> { + self.as_ref().into() + } +} + + +#[derive(Clone, Copy, Eq, Hash, Debug, PartialEq, Serialize, Deserialize)] +pub enum ContentRatingDjctqRatingReasonsEnum { + + /// "djctqRatingReasonUnspecified" + #[serde(rename="djctqRatingReasonUnspecified")] + DjctqRatingReasonUnspecified, + + + /// Brazil rating content descriptors. See http://go/brazilratings section F. Violência (Violence) + /// + /// "djctqViolence" + #[serde(rename="djctqViolence")] + DjctqViolence, + + + /// Violência extrema (Extreme violence) + /// + /// "djctqExtremeViolence" + #[serde(rename="djctqExtremeViolence")] + DjctqExtremeViolence, + + + /// Conteúdo sexual (Sexual content) + /// + /// "djctqSexualContent" + #[serde(rename="djctqSexualContent")] + DjctqSexualContent, + + + /// Nudez (Nudity) + /// + /// "djctqNudity" + #[serde(rename="djctqNudity")] + DjctqNudity, + + + /// Sexo (Sex) + /// + /// "djctqSex" + #[serde(rename="djctqSex")] + DjctqSex, + + + /// Sexo Explícito (Explicit sex) + /// + /// "djctqExplicitSex" + #[serde(rename="djctqExplicitSex")] + DjctqExplicitSex, + + + /// Drogas (Drugs) + /// + /// "djctqDrugs" + #[serde(rename="djctqDrugs")] + DjctqDrugs, + + + /// Drogas Lícitas (Legal drugs) + /// + /// "djctqLegalDrugs" + #[serde(rename="djctqLegalDrugs")] + DjctqLegalDrugs, + + + /// Drogas Ilícitas (Illegal drugs) + /// + /// "djctqIllegalDrugs" + #[serde(rename="djctqIllegalDrugs")] + DjctqIllegalDrugs, + + + /// Linguagem Imprópria (Inappropriate language) + /// + /// "djctqInappropriateLanguage" + #[serde(rename="djctqInappropriateLanguage")] + DjctqInappropriateLanguage, + + + /// Atos Criminosos (Criminal Acts) + /// + /// "djctqCriminalActs" + #[serde(rename="djctqCriminalActs")] + DjctqCriminalActs, + + + /// Conteúdo Impactante (Impacting content) + /// + /// "djctqImpactingContent" + #[serde(rename="djctqImpactingContent")] + DjctqImpactingContent, +} + +impl AsRef for ContentRatingDjctqRatingReasonsEnum { + fn as_ref(&self) -> &str { + match *self { + ContentRatingDjctqRatingReasonsEnum::DjctqRatingReasonUnspecified => "djctqRatingReasonUnspecified", + ContentRatingDjctqRatingReasonsEnum::DjctqViolence => "djctqViolence", + ContentRatingDjctqRatingReasonsEnum::DjctqExtremeViolence => "djctqExtremeViolence", + ContentRatingDjctqRatingReasonsEnum::DjctqSexualContent => "djctqSexualContent", + ContentRatingDjctqRatingReasonsEnum::DjctqNudity => "djctqNudity", + ContentRatingDjctqRatingReasonsEnum::DjctqSex => "djctqSex", + ContentRatingDjctqRatingReasonsEnum::DjctqExplicitSex => "djctqExplicitSex", + ContentRatingDjctqRatingReasonsEnum::DjctqDrugs => "djctqDrugs", + ContentRatingDjctqRatingReasonsEnum::DjctqLegalDrugs => "djctqLegalDrugs", + ContentRatingDjctqRatingReasonsEnum::DjctqIllegalDrugs => "djctqIllegalDrugs", + ContentRatingDjctqRatingReasonsEnum::DjctqInappropriateLanguage => "djctqInappropriateLanguage", + ContentRatingDjctqRatingReasonsEnum::DjctqCriminalActs => "djctqCriminalActs", + ContentRatingDjctqRatingReasonsEnum::DjctqImpactingContent => "djctqImpactingContent", + } + } +} + +impl std::convert::TryFrom< &str> for ContentRatingDjctqRatingReasonsEnum { + type Error = (); + fn try_from(value: &str) -> Result { + match value { + "djctqRatingReasonUnspecified" => Ok(ContentRatingDjctqRatingReasonsEnum::DjctqRatingReasonUnspecified), + "djctqViolence" => Ok(ContentRatingDjctqRatingReasonsEnum::DjctqViolence), + "djctqExtremeViolence" => Ok(ContentRatingDjctqRatingReasonsEnum::DjctqExtremeViolence), + "djctqSexualContent" => Ok(ContentRatingDjctqRatingReasonsEnum::DjctqSexualContent), + "djctqNudity" => Ok(ContentRatingDjctqRatingReasonsEnum::DjctqNudity), + "djctqSex" => Ok(ContentRatingDjctqRatingReasonsEnum::DjctqSex), + "djctqExplicitSex" => Ok(ContentRatingDjctqRatingReasonsEnum::DjctqExplicitSex), + "djctqDrugs" => Ok(ContentRatingDjctqRatingReasonsEnum::DjctqDrugs), + "djctqLegalDrugs" => Ok(ContentRatingDjctqRatingReasonsEnum::DjctqLegalDrugs), + "djctqIllegalDrugs" => Ok(ContentRatingDjctqRatingReasonsEnum::DjctqIllegalDrugs), + "djctqInappropriateLanguage" => Ok(ContentRatingDjctqRatingReasonsEnum::DjctqInappropriateLanguage), + "djctqCriminalActs" => Ok(ContentRatingDjctqRatingReasonsEnum::DjctqCriminalActs), + "djctqImpactingContent" => Ok(ContentRatingDjctqRatingReasonsEnum::DjctqImpactingContent), + _=> Err(()), + } + } +} + +impl<'a> Into> for &'a ContentRatingDjctqRatingReasonsEnum { + fn into(self) -> std::borrow::Cow<'a, str> { + self.as_ref().into() + } +} + + +#[derive(Clone, Copy, Eq, Hash, Debug, PartialEq, Serialize, Deserialize)] +/// Rating system in Turkey - Evaluation and Classification Board of the Ministry of Culture and Tourism +pub enum ContentRatingEcbmctRatingEnum { + + /// "ecbmctUnspecified" + #[serde(rename="ecbmctUnspecified")] + EcbmctUnspecified, + + + /// G + /// + /// "ecbmctG" + #[serde(rename="ecbmctG")] + EcbmctG, + + + /// 7A + /// + /// "ecbmct7a" + #[serde(rename="ecbmct7a")] + Ecbmct7a, + + + /// 7+ + /// + /// "ecbmct7plus" + #[serde(rename="ecbmct7plus")] + Ecbmct7plus, + + + /// 13A + /// + /// "ecbmct13a" + #[serde(rename="ecbmct13a")] + Ecbmct13a, + + + /// 13+ + /// + /// "ecbmct13plus" + #[serde(rename="ecbmct13plus")] + Ecbmct13plus, + + + /// 15A + /// + /// "ecbmct15a" + #[serde(rename="ecbmct15a")] + Ecbmct15a, + + + /// 15+ + /// + /// "ecbmct15plus" + #[serde(rename="ecbmct15plus")] + Ecbmct15plus, + + + /// 18+ + /// + /// "ecbmct18plus" + #[serde(rename="ecbmct18plus")] + Ecbmct18plus, + + /// "ecbmctUnrated" + #[serde(rename="ecbmctUnrated")] + EcbmctUnrated, +} + +impl AsRef for ContentRatingEcbmctRatingEnum { + fn as_ref(&self) -> &str { + match *self { + ContentRatingEcbmctRatingEnum::EcbmctUnspecified => "ecbmctUnspecified", + ContentRatingEcbmctRatingEnum::EcbmctG => "ecbmctG", + ContentRatingEcbmctRatingEnum::Ecbmct7a => "ecbmct7a", + ContentRatingEcbmctRatingEnum::Ecbmct7plus => "ecbmct7plus", + ContentRatingEcbmctRatingEnum::Ecbmct13a => "ecbmct13a", + ContentRatingEcbmctRatingEnum::Ecbmct13plus => "ecbmct13plus", + ContentRatingEcbmctRatingEnum::Ecbmct15a => "ecbmct15a", + ContentRatingEcbmctRatingEnum::Ecbmct15plus => "ecbmct15plus", + ContentRatingEcbmctRatingEnum::Ecbmct18plus => "ecbmct18plus", + ContentRatingEcbmctRatingEnum::EcbmctUnrated => "ecbmctUnrated", + } + } +} + +impl std::convert::TryFrom< &str> for ContentRatingEcbmctRatingEnum { + type Error = (); + fn try_from(value: &str) -> Result { + match value { + "ecbmctUnspecified" => Ok(ContentRatingEcbmctRatingEnum::EcbmctUnspecified), + "ecbmctG" => Ok(ContentRatingEcbmctRatingEnum::EcbmctG), + "ecbmct7a" => Ok(ContentRatingEcbmctRatingEnum::Ecbmct7a), + "ecbmct7plus" => Ok(ContentRatingEcbmctRatingEnum::Ecbmct7plus), + "ecbmct13a" => Ok(ContentRatingEcbmctRatingEnum::Ecbmct13a), + "ecbmct13plus" => Ok(ContentRatingEcbmctRatingEnum::Ecbmct13plus), + "ecbmct15a" => Ok(ContentRatingEcbmctRatingEnum::Ecbmct15a), + "ecbmct15plus" => Ok(ContentRatingEcbmctRatingEnum::Ecbmct15plus), + "ecbmct18plus" => Ok(ContentRatingEcbmctRatingEnum::Ecbmct18plus), + "ecbmctUnrated" => Ok(ContentRatingEcbmctRatingEnum::EcbmctUnrated), + _=> Err(()), + } + } +} + +impl<'a> Into> for &'a ContentRatingEcbmctRatingEnum { + fn into(self) -> std::borrow::Cow<'a, str> { + self.as_ref().into() + } +} + + +#[derive(Clone, Copy, Eq, Hash, Debug, PartialEq, Serialize, Deserialize)] +/// The video's rating in Estonia. +pub enum ContentRatingEefilmRatingEnum { + + /// "eefilmUnspecified" + #[serde(rename="eefilmUnspecified")] + EefilmUnspecified, + + + /// Pere + /// + /// "eefilmPere" + #[serde(rename="eefilmPere")] + EefilmPere, + + + /// L + /// + /// "eefilmL" + #[serde(rename="eefilmL")] + EefilmL, + + + /// MS-6 + /// + /// "eefilmMs6" + #[serde(rename="eefilmMs6")] + EefilmMs6, + + + /// K-6 + /// + /// "eefilmK6" + #[serde(rename="eefilmK6")] + EefilmK6, + + + /// MS-12 + /// + /// "eefilmMs12" + #[serde(rename="eefilmMs12")] + EefilmMs12, + + + /// K-12 + /// + /// "eefilmK12" + #[serde(rename="eefilmK12")] + EefilmK12, + + + /// K-14 + /// + /// "eefilmK14" + #[serde(rename="eefilmK14")] + EefilmK14, + + + /// K-16 + /// + /// "eefilmK16" + #[serde(rename="eefilmK16")] + EefilmK16, + + /// "eefilmUnrated" + #[serde(rename="eefilmUnrated")] + EefilmUnrated, +} + +impl AsRef for ContentRatingEefilmRatingEnum { + fn as_ref(&self) -> &str { + match *self { + ContentRatingEefilmRatingEnum::EefilmUnspecified => "eefilmUnspecified", + ContentRatingEefilmRatingEnum::EefilmPere => "eefilmPere", + ContentRatingEefilmRatingEnum::EefilmL => "eefilmL", + ContentRatingEefilmRatingEnum::EefilmMs6 => "eefilmMs6", + ContentRatingEefilmRatingEnum::EefilmK6 => "eefilmK6", + ContentRatingEefilmRatingEnum::EefilmMs12 => "eefilmMs12", + ContentRatingEefilmRatingEnum::EefilmK12 => "eefilmK12", + ContentRatingEefilmRatingEnum::EefilmK14 => "eefilmK14", + ContentRatingEefilmRatingEnum::EefilmK16 => "eefilmK16", + ContentRatingEefilmRatingEnum::EefilmUnrated => "eefilmUnrated", + } + } +} + +impl std::convert::TryFrom< &str> for ContentRatingEefilmRatingEnum { + type Error = (); + fn try_from(value: &str) -> Result { + match value { + "eefilmUnspecified" => Ok(ContentRatingEefilmRatingEnum::EefilmUnspecified), + "eefilmPere" => Ok(ContentRatingEefilmRatingEnum::EefilmPere), + "eefilmL" => Ok(ContentRatingEefilmRatingEnum::EefilmL), + "eefilmMs6" => Ok(ContentRatingEefilmRatingEnum::EefilmMs6), + "eefilmK6" => Ok(ContentRatingEefilmRatingEnum::EefilmK6), + "eefilmMs12" => Ok(ContentRatingEefilmRatingEnum::EefilmMs12), + "eefilmK12" => Ok(ContentRatingEefilmRatingEnum::EefilmK12), + "eefilmK14" => Ok(ContentRatingEefilmRatingEnum::EefilmK14), + "eefilmK16" => Ok(ContentRatingEefilmRatingEnum::EefilmK16), + "eefilmUnrated" => Ok(ContentRatingEefilmRatingEnum::EefilmUnrated), + _=> Err(()), + } + } +} + +impl<'a> Into> for &'a ContentRatingEefilmRatingEnum { + fn into(self) -> std::borrow::Cow<'a, str> { + self.as_ref().into() + } +} + + +#[derive(Clone, Copy, Eq, Hash, Debug, PartialEq, Serialize, Deserialize)] +/// The video's rating in Egypt. +pub enum ContentRatingEgfilmRatingEnum { + + /// "egfilmUnspecified" + #[serde(rename="egfilmUnspecified")] + EgfilmUnspecified, + + + /// GN + /// + /// "egfilmGn" + #[serde(rename="egfilmGn")] + EgfilmGn, + + + /// 18 + /// + /// "egfilm18" + #[serde(rename="egfilm18")] + Egfilm18, + + + /// BN + /// + /// "egfilmBn" + #[serde(rename="egfilmBn")] + EgfilmBn, + + /// "egfilmUnrated" + #[serde(rename="egfilmUnrated")] + EgfilmUnrated, +} + +impl AsRef for ContentRatingEgfilmRatingEnum { + fn as_ref(&self) -> &str { + match *self { + ContentRatingEgfilmRatingEnum::EgfilmUnspecified => "egfilmUnspecified", + ContentRatingEgfilmRatingEnum::EgfilmGn => "egfilmGn", + ContentRatingEgfilmRatingEnum::Egfilm18 => "egfilm18", + ContentRatingEgfilmRatingEnum::EgfilmBn => "egfilmBn", + ContentRatingEgfilmRatingEnum::EgfilmUnrated => "egfilmUnrated", + } + } +} + +impl std::convert::TryFrom< &str> for ContentRatingEgfilmRatingEnum { + type Error = (); + fn try_from(value: &str) -> Result { + match value { + "egfilmUnspecified" => Ok(ContentRatingEgfilmRatingEnum::EgfilmUnspecified), + "egfilmGn" => Ok(ContentRatingEgfilmRatingEnum::EgfilmGn), + "egfilm18" => Ok(ContentRatingEgfilmRatingEnum::Egfilm18), + "egfilmBn" => Ok(ContentRatingEgfilmRatingEnum::EgfilmBn), + "egfilmUnrated" => Ok(ContentRatingEgfilmRatingEnum::EgfilmUnrated), + _=> Err(()), + } + } +} + +impl<'a> Into> for &'a ContentRatingEgfilmRatingEnum { + fn into(self) -> std::borrow::Cow<'a, str> { + self.as_ref().into() + } +} + + +#[derive(Clone, Copy, Eq, Hash, Debug, PartialEq, Serialize, Deserialize)] +/// The video's Eirin (映倫) rating. Eirin is the Japanese rating system. +pub enum ContentRatingEirinRatingEnum { + + /// "eirinUnspecified" + #[serde(rename="eirinUnspecified")] + EirinUnspecified, + + + /// G + /// + /// "eirinG" + #[serde(rename="eirinG")] + EirinG, + + + /// PG-12 + /// + /// "eirinPg12" + #[serde(rename="eirinPg12")] + EirinPg12, + + + /// R15+ + /// + /// "eirinR15plus" + #[serde(rename="eirinR15plus")] + EirinR15plus, + + + /// R18+ + /// + /// "eirinR18plus" + #[serde(rename="eirinR18plus")] + EirinR18plus, + + /// "eirinUnrated" + #[serde(rename="eirinUnrated")] + EirinUnrated, +} + +impl AsRef for ContentRatingEirinRatingEnum { + fn as_ref(&self) -> &str { + match *self { + ContentRatingEirinRatingEnum::EirinUnspecified => "eirinUnspecified", + ContentRatingEirinRatingEnum::EirinG => "eirinG", + ContentRatingEirinRatingEnum::EirinPg12 => "eirinPg12", + ContentRatingEirinRatingEnum::EirinR15plus => "eirinR15plus", + ContentRatingEirinRatingEnum::EirinR18plus => "eirinR18plus", + ContentRatingEirinRatingEnum::EirinUnrated => "eirinUnrated", + } + } +} + +impl std::convert::TryFrom< &str> for ContentRatingEirinRatingEnum { + type Error = (); + fn try_from(value: &str) -> Result { + match value { + "eirinUnspecified" => Ok(ContentRatingEirinRatingEnum::EirinUnspecified), + "eirinG" => Ok(ContentRatingEirinRatingEnum::EirinG), + "eirinPg12" => Ok(ContentRatingEirinRatingEnum::EirinPg12), + "eirinR15plus" => Ok(ContentRatingEirinRatingEnum::EirinR15plus), + "eirinR18plus" => Ok(ContentRatingEirinRatingEnum::EirinR18plus), + "eirinUnrated" => Ok(ContentRatingEirinRatingEnum::EirinUnrated), + _=> Err(()), + } + } +} + +impl<'a> Into> for &'a ContentRatingEirinRatingEnum { + fn into(self) -> std::borrow::Cow<'a, str> { + self.as_ref().into() + } +} + + +#[derive(Clone, Copy, Eq, Hash, Debug, PartialEq, Serialize, Deserialize)] +/// The video's rating from Malaysia's Film Censorship Board. +pub enum ContentRatingFcbmRatingEnum { + + /// "fcbmUnspecified" + #[serde(rename="fcbmUnspecified")] + FcbmUnspecified, + + + /// U + /// + /// "fcbmU" + #[serde(rename="fcbmU")] + FcbmU, + + + /// PG13 + /// + /// "fcbmPg13" + #[serde(rename="fcbmPg13")] + FcbmPg13, + + + /// P13 + /// + /// "fcbmP13" + #[serde(rename="fcbmP13")] + FcbmP13, + + + /// 18 + /// + /// "fcbm18" + #[serde(rename="fcbm18")] + Fcbm18, + + + /// 18SX + /// + /// "fcbm18sx" + #[serde(rename="fcbm18sx")] + Fcbm18sx, + + + /// 18PA + /// + /// "fcbm18pa" + #[serde(rename="fcbm18pa")] + Fcbm18pa, + + + /// 18SG + /// + /// "fcbm18sg" + #[serde(rename="fcbm18sg")] + Fcbm18sg, + + + /// 18PL + /// + /// "fcbm18pl" + #[serde(rename="fcbm18pl")] + Fcbm18pl, + + /// "fcbmUnrated" + #[serde(rename="fcbmUnrated")] + FcbmUnrated, +} + +impl AsRef for ContentRatingFcbmRatingEnum { + fn as_ref(&self) -> &str { + match *self { + ContentRatingFcbmRatingEnum::FcbmUnspecified => "fcbmUnspecified", + ContentRatingFcbmRatingEnum::FcbmU => "fcbmU", + ContentRatingFcbmRatingEnum::FcbmPg13 => "fcbmPg13", + ContentRatingFcbmRatingEnum::FcbmP13 => "fcbmP13", + ContentRatingFcbmRatingEnum::Fcbm18 => "fcbm18", + ContentRatingFcbmRatingEnum::Fcbm18sx => "fcbm18sx", + ContentRatingFcbmRatingEnum::Fcbm18pa => "fcbm18pa", + ContentRatingFcbmRatingEnum::Fcbm18sg => "fcbm18sg", + ContentRatingFcbmRatingEnum::Fcbm18pl => "fcbm18pl", + ContentRatingFcbmRatingEnum::FcbmUnrated => "fcbmUnrated", + } + } +} + +impl std::convert::TryFrom< &str> for ContentRatingFcbmRatingEnum { + type Error = (); + fn try_from(value: &str) -> Result { + match value { + "fcbmUnspecified" => Ok(ContentRatingFcbmRatingEnum::FcbmUnspecified), + "fcbmU" => Ok(ContentRatingFcbmRatingEnum::FcbmU), + "fcbmPg13" => Ok(ContentRatingFcbmRatingEnum::FcbmPg13), + "fcbmP13" => Ok(ContentRatingFcbmRatingEnum::FcbmP13), + "fcbm18" => Ok(ContentRatingFcbmRatingEnum::Fcbm18), + "fcbm18sx" => Ok(ContentRatingFcbmRatingEnum::Fcbm18sx), + "fcbm18pa" => Ok(ContentRatingFcbmRatingEnum::Fcbm18pa), + "fcbm18sg" => Ok(ContentRatingFcbmRatingEnum::Fcbm18sg), + "fcbm18pl" => Ok(ContentRatingFcbmRatingEnum::Fcbm18pl), + "fcbmUnrated" => Ok(ContentRatingFcbmRatingEnum::FcbmUnrated), + _=> Err(()), + } + } +} + +impl<'a> Into> for &'a ContentRatingFcbmRatingEnum { + fn into(self) -> std::borrow::Cow<'a, str> { + self.as_ref().into() + } +} + + +#[derive(Clone, Copy, Eq, Hash, Debug, PartialEq, Serialize, Deserialize)] +/// The video's rating from Hong Kong's Office for Film, Newspaper and Article Administration. +pub enum ContentRatingFcoRatingEnum { + + /// "fcoUnspecified" + #[serde(rename="fcoUnspecified")] + FcoUnspecified, + + + /// I + /// + /// "fcoI" + #[serde(rename="fcoI")] + FcoI, + + + /// IIA + /// + /// "fcoIia" + #[serde(rename="fcoIia")] + FcoIia, + + + /// IIB + /// + /// "fcoIib" + #[serde(rename="fcoIib")] + FcoIib, + + + /// II + /// + /// "fcoIi" + #[serde(rename="fcoIi")] + FcoIi, + + + /// III + /// + /// "fcoIii" + #[serde(rename="fcoIii")] + FcoIii, + + /// "fcoUnrated" + #[serde(rename="fcoUnrated")] + FcoUnrated, +} + +impl AsRef for ContentRatingFcoRatingEnum { + fn as_ref(&self) -> &str { + match *self { + ContentRatingFcoRatingEnum::FcoUnspecified => "fcoUnspecified", + ContentRatingFcoRatingEnum::FcoI => "fcoI", + ContentRatingFcoRatingEnum::FcoIia => "fcoIia", + ContentRatingFcoRatingEnum::FcoIib => "fcoIib", + ContentRatingFcoRatingEnum::FcoIi => "fcoIi", + ContentRatingFcoRatingEnum::FcoIii => "fcoIii", + ContentRatingFcoRatingEnum::FcoUnrated => "fcoUnrated", + } + } +} + +impl std::convert::TryFrom< &str> for ContentRatingFcoRatingEnum { + type Error = (); + fn try_from(value: &str) -> Result { + match value { + "fcoUnspecified" => Ok(ContentRatingFcoRatingEnum::FcoUnspecified), + "fcoI" => Ok(ContentRatingFcoRatingEnum::FcoI), + "fcoIia" => Ok(ContentRatingFcoRatingEnum::FcoIia), + "fcoIib" => Ok(ContentRatingFcoRatingEnum::FcoIib), + "fcoIi" => Ok(ContentRatingFcoRatingEnum::FcoIi), + "fcoIii" => Ok(ContentRatingFcoRatingEnum::FcoIii), + "fcoUnrated" => Ok(ContentRatingFcoRatingEnum::FcoUnrated), + _=> Err(()), + } + } +} + +impl<'a> Into> for &'a ContentRatingFcoRatingEnum { + fn into(self) -> std::borrow::Cow<'a, str> { + self.as_ref().into() + } +} + + +#[derive(Clone, Copy, Eq, Hash, Debug, PartialEq, Serialize, Deserialize)] +/// This property has been deprecated. Use the contentDetails.contentRating.cncRating instead. +pub enum ContentRatingFmocRatingEnum { + + /// "fmocUnspecified" + #[serde(rename="fmocUnspecified")] + FmocUnspecified, + + + /// U + /// + /// "fmocU" + #[serde(rename="fmocU")] + FmocU, + + + /// 10 + /// + /// "fmoc10" + #[serde(rename="fmoc10")] + Fmoc10, + + + /// 12 + /// + /// "fmoc12" + #[serde(rename="fmoc12")] + Fmoc12, + + + /// 16 + /// + /// "fmoc16" + #[serde(rename="fmoc16")] + Fmoc16, + + + /// 18 + /// + /// "fmoc18" + #[serde(rename="fmoc18")] + Fmoc18, + + + /// E + /// + /// "fmocE" + #[serde(rename="fmocE")] + FmocE, + + /// "fmocUnrated" + #[serde(rename="fmocUnrated")] + FmocUnrated, +} + +impl AsRef for ContentRatingFmocRatingEnum { + fn as_ref(&self) -> &str { + match *self { + ContentRatingFmocRatingEnum::FmocUnspecified => "fmocUnspecified", + ContentRatingFmocRatingEnum::FmocU => "fmocU", + ContentRatingFmocRatingEnum::Fmoc10 => "fmoc10", + ContentRatingFmocRatingEnum::Fmoc12 => "fmoc12", + ContentRatingFmocRatingEnum::Fmoc16 => "fmoc16", + ContentRatingFmocRatingEnum::Fmoc18 => "fmoc18", + ContentRatingFmocRatingEnum::FmocE => "fmocE", + ContentRatingFmocRatingEnum::FmocUnrated => "fmocUnrated", + } + } +} + +impl std::convert::TryFrom< &str> for ContentRatingFmocRatingEnum { + type Error = (); + fn try_from(value: &str) -> Result { + match value { + "fmocUnspecified" => Ok(ContentRatingFmocRatingEnum::FmocUnspecified), + "fmocU" => Ok(ContentRatingFmocRatingEnum::FmocU), + "fmoc10" => Ok(ContentRatingFmocRatingEnum::Fmoc10), + "fmoc12" => Ok(ContentRatingFmocRatingEnum::Fmoc12), + "fmoc16" => Ok(ContentRatingFmocRatingEnum::Fmoc16), + "fmoc18" => Ok(ContentRatingFmocRatingEnum::Fmoc18), + "fmocE" => Ok(ContentRatingFmocRatingEnum::FmocE), + "fmocUnrated" => Ok(ContentRatingFmocRatingEnum::FmocUnrated), + _=> Err(()), + } + } +} + +impl<'a> Into> for &'a ContentRatingFmocRatingEnum { + fn into(self) -> std::borrow::Cow<'a, str> { + self.as_ref().into() + } +} + + +#[derive(Clone, Copy, Eq, Hash, Debug, PartialEq, Serialize, Deserialize)] +/// The video's rating from South Africa's Film and Publication Board. +pub enum ContentRatingFpbRatingEnum { + + /// "fpbUnspecified" + #[serde(rename="fpbUnspecified")] + FpbUnspecified, + + + /// A + /// + /// "fpbA" + #[serde(rename="fpbA")] + FpbA, + + + /// PG + /// + /// "fpbPg" + #[serde(rename="fpbPg")] + FpbPg, + + + /// 7-9PG + /// + /// "fpb79Pg" + #[serde(rename="fpb79Pg")] + Fpb79Pg, + + + /// 10-12PG + /// + /// "fpb1012Pg" + #[serde(rename="fpb1012Pg")] + Fpb1012Pg, + + + /// 13 + /// + /// "fpb13" + #[serde(rename="fpb13")] + Fpb13, + + + /// 16 + /// + /// "fpb16" + #[serde(rename="fpb16")] + Fpb16, + + + /// 18 + /// + /// "fpb18" + #[serde(rename="fpb18")] + Fpb18, + + + /// X18 + /// + /// "fpbX18" + #[serde(rename="fpbX18")] + FpbX18, + + + /// XX + /// + /// "fpbXx" + #[serde(rename="fpbXx")] + FpbXx, + + /// "fpbUnrated" + #[serde(rename="fpbUnrated")] + FpbUnrated, + + + /// 10 + /// + /// "fpb10" + #[serde(rename="fpb10")] + Fpb10, +} + +impl AsRef for ContentRatingFpbRatingEnum { + fn as_ref(&self) -> &str { + match *self { + ContentRatingFpbRatingEnum::FpbUnspecified => "fpbUnspecified", + ContentRatingFpbRatingEnum::FpbA => "fpbA", + ContentRatingFpbRatingEnum::FpbPg => "fpbPg", + ContentRatingFpbRatingEnum::Fpb79Pg => "fpb79Pg", + ContentRatingFpbRatingEnum::Fpb1012Pg => "fpb1012Pg", + ContentRatingFpbRatingEnum::Fpb13 => "fpb13", + ContentRatingFpbRatingEnum::Fpb16 => "fpb16", + ContentRatingFpbRatingEnum::Fpb18 => "fpb18", + ContentRatingFpbRatingEnum::FpbX18 => "fpbX18", + ContentRatingFpbRatingEnum::FpbXx => "fpbXx", + ContentRatingFpbRatingEnum::FpbUnrated => "fpbUnrated", + ContentRatingFpbRatingEnum::Fpb10 => "fpb10", + } + } +} + +impl std::convert::TryFrom< &str> for ContentRatingFpbRatingEnum { + type Error = (); + fn try_from(value: &str) -> Result { + match value { + "fpbUnspecified" => Ok(ContentRatingFpbRatingEnum::FpbUnspecified), + "fpbA" => Ok(ContentRatingFpbRatingEnum::FpbA), + "fpbPg" => Ok(ContentRatingFpbRatingEnum::FpbPg), + "fpb79Pg" => Ok(ContentRatingFpbRatingEnum::Fpb79Pg), + "fpb1012Pg" => Ok(ContentRatingFpbRatingEnum::Fpb1012Pg), + "fpb13" => Ok(ContentRatingFpbRatingEnum::Fpb13), + "fpb16" => Ok(ContentRatingFpbRatingEnum::Fpb16), + "fpb18" => Ok(ContentRatingFpbRatingEnum::Fpb18), + "fpbX18" => Ok(ContentRatingFpbRatingEnum::FpbX18), + "fpbXx" => Ok(ContentRatingFpbRatingEnum::FpbXx), + "fpbUnrated" => Ok(ContentRatingFpbRatingEnum::FpbUnrated), + "fpb10" => Ok(ContentRatingFpbRatingEnum::Fpb10), + _=> Err(()), + } + } +} + +impl<'a> Into> for &'a ContentRatingFpbRatingEnum { + fn into(self) -> std::borrow::Cow<'a, str> { + self.as_ref().into() + } +} + + +#[derive(Clone, Copy, Eq, Hash, Debug, PartialEq, Serialize, Deserialize)] +pub enum ContentRatingFpbRatingReasonsEnum { + + /// "fpbRatingReasonUnspecified" + #[serde(rename="fpbRatingReasonUnspecified")] + FpbRatingReasonUnspecified, + + + /// South Africa rating content descriptors. + /// + /// "fpbBlasphemy" + #[serde(rename="fpbBlasphemy")] + FpbBlasphemy, + + /// "fpbLanguage" + #[serde(rename="fpbLanguage")] + FpbLanguage, + + /// "fpbNudity" + #[serde(rename="fpbNudity")] + FpbNudity, + + /// "fpbPrejudice" + #[serde(rename="fpbPrejudice")] + FpbPrejudice, + + /// "fpbSex" + #[serde(rename="fpbSex")] + FpbSex, + + /// "fpbViolence" + #[serde(rename="fpbViolence")] + FpbViolence, + + /// "fpbDrugs" + #[serde(rename="fpbDrugs")] + FpbDrugs, + + /// "fpbSexualViolence" + #[serde(rename="fpbSexualViolence")] + FpbSexualViolence, + + /// "fpbHorror" + #[serde(rename="fpbHorror")] + FpbHorror, + + /// "fpbCriminalTechniques" + #[serde(rename="fpbCriminalTechniques")] + FpbCriminalTechniques, + + /// "fpbImitativeActsTechniques" + #[serde(rename="fpbImitativeActsTechniques")] + FpbImitativeActsTechniques, +} + +impl AsRef for ContentRatingFpbRatingReasonsEnum { + fn as_ref(&self) -> &str { + match *self { + ContentRatingFpbRatingReasonsEnum::FpbRatingReasonUnspecified => "fpbRatingReasonUnspecified", + ContentRatingFpbRatingReasonsEnum::FpbBlasphemy => "fpbBlasphemy", + ContentRatingFpbRatingReasonsEnum::FpbLanguage => "fpbLanguage", + ContentRatingFpbRatingReasonsEnum::FpbNudity => "fpbNudity", + ContentRatingFpbRatingReasonsEnum::FpbPrejudice => "fpbPrejudice", + ContentRatingFpbRatingReasonsEnum::FpbSex => "fpbSex", + ContentRatingFpbRatingReasonsEnum::FpbViolence => "fpbViolence", + ContentRatingFpbRatingReasonsEnum::FpbDrugs => "fpbDrugs", + ContentRatingFpbRatingReasonsEnum::FpbSexualViolence => "fpbSexualViolence", + ContentRatingFpbRatingReasonsEnum::FpbHorror => "fpbHorror", + ContentRatingFpbRatingReasonsEnum::FpbCriminalTechniques => "fpbCriminalTechniques", + ContentRatingFpbRatingReasonsEnum::FpbImitativeActsTechniques => "fpbImitativeActsTechniques", + } + } +} + +impl std::convert::TryFrom< &str> for ContentRatingFpbRatingReasonsEnum { + type Error = (); + fn try_from(value: &str) -> Result { + match value { + "fpbRatingReasonUnspecified" => Ok(ContentRatingFpbRatingReasonsEnum::FpbRatingReasonUnspecified), + "fpbBlasphemy" => Ok(ContentRatingFpbRatingReasonsEnum::FpbBlasphemy), + "fpbLanguage" => Ok(ContentRatingFpbRatingReasonsEnum::FpbLanguage), + "fpbNudity" => Ok(ContentRatingFpbRatingReasonsEnum::FpbNudity), + "fpbPrejudice" => Ok(ContentRatingFpbRatingReasonsEnum::FpbPrejudice), + "fpbSex" => Ok(ContentRatingFpbRatingReasonsEnum::FpbSex), + "fpbViolence" => Ok(ContentRatingFpbRatingReasonsEnum::FpbViolence), + "fpbDrugs" => Ok(ContentRatingFpbRatingReasonsEnum::FpbDrugs), + "fpbSexualViolence" => Ok(ContentRatingFpbRatingReasonsEnum::FpbSexualViolence), + "fpbHorror" => Ok(ContentRatingFpbRatingReasonsEnum::FpbHorror), + "fpbCriminalTechniques" => Ok(ContentRatingFpbRatingReasonsEnum::FpbCriminalTechniques), + "fpbImitativeActsTechniques" => Ok(ContentRatingFpbRatingReasonsEnum::FpbImitativeActsTechniques), + _=> Err(()), + } + } +} + +impl<'a> Into> for &'a ContentRatingFpbRatingReasonsEnum { + fn into(self) -> std::borrow::Cow<'a, str> { + self.as_ref().into() + } +} + + +#[derive(Clone, Copy, Eq, Hash, Debug, PartialEq, Serialize, Deserialize)] +/// The video's Freiwillige Selbstkontrolle der Filmwirtschaft (FSK - Germany) rating. +pub enum ContentRatingFskRatingEnum { + + /// "fskUnspecified" + #[serde(rename="fskUnspecified")] + FskUnspecified, + + + /// FSK 0 + /// + /// "fsk0" + #[serde(rename="fsk0")] + Fsk0, + + + /// FSK 6 + /// + /// "fsk6" + #[serde(rename="fsk6")] + Fsk6, + + + /// FSK 12 + /// + /// "fsk12" + #[serde(rename="fsk12")] + Fsk12, + + + /// FSK 16 + /// + /// "fsk16" + #[serde(rename="fsk16")] + Fsk16, + + + /// FSK 18 + /// + /// "fsk18" + #[serde(rename="fsk18")] + Fsk18, + + /// "fskUnrated" + #[serde(rename="fskUnrated")] + FskUnrated, +} + +impl AsRef for ContentRatingFskRatingEnum { + fn as_ref(&self) -> &str { + match *self { + ContentRatingFskRatingEnum::FskUnspecified => "fskUnspecified", + ContentRatingFskRatingEnum::Fsk0 => "fsk0", + ContentRatingFskRatingEnum::Fsk6 => "fsk6", + ContentRatingFskRatingEnum::Fsk12 => "fsk12", + ContentRatingFskRatingEnum::Fsk16 => "fsk16", + ContentRatingFskRatingEnum::Fsk18 => "fsk18", + ContentRatingFskRatingEnum::FskUnrated => "fskUnrated", + } + } +} + +impl std::convert::TryFrom< &str> for ContentRatingFskRatingEnum { + type Error = (); + fn try_from(value: &str) -> Result { + match value { + "fskUnspecified" => Ok(ContentRatingFskRatingEnum::FskUnspecified), + "fsk0" => Ok(ContentRatingFskRatingEnum::Fsk0), + "fsk6" => Ok(ContentRatingFskRatingEnum::Fsk6), + "fsk12" => Ok(ContentRatingFskRatingEnum::Fsk12), + "fsk16" => Ok(ContentRatingFskRatingEnum::Fsk16), + "fsk18" => Ok(ContentRatingFskRatingEnum::Fsk18), + "fskUnrated" => Ok(ContentRatingFskRatingEnum::FskUnrated), + _=> Err(()), + } + } +} + +impl<'a> Into> for &'a ContentRatingFskRatingEnum { + fn into(self) -> std::borrow::Cow<'a, str> { + self.as_ref().into() + } +} + + +#[derive(Clone, Copy, Eq, Hash, Debug, PartialEq, Serialize, Deserialize)] +/// The video's rating in Greece. +pub enum ContentRatingGrfilmRatingEnum { + + /// "grfilmUnspecified" + #[serde(rename="grfilmUnspecified")] + GrfilmUnspecified, + + + /// K + /// + /// "grfilmK" + #[serde(rename="grfilmK")] + GrfilmK, + + + /// E + /// + /// "grfilmE" + #[serde(rename="grfilmE")] + GrfilmE, + + + /// K-12 + /// + /// "grfilmK12" + #[serde(rename="grfilmK12")] + GrfilmK12, + + + /// K-13 + /// + /// "grfilmK13" + #[serde(rename="grfilmK13")] + GrfilmK13, + + + /// K-15 + /// + /// "grfilmK15" + #[serde(rename="grfilmK15")] + GrfilmK15, + + + /// K-17 + /// + /// "grfilmK17" + #[serde(rename="grfilmK17")] + GrfilmK17, + + + /// K-18 + /// + /// "grfilmK18" + #[serde(rename="grfilmK18")] + GrfilmK18, + + /// "grfilmUnrated" + #[serde(rename="grfilmUnrated")] + GrfilmUnrated, +} + +impl AsRef for ContentRatingGrfilmRatingEnum { + fn as_ref(&self) -> &str { + match *self { + ContentRatingGrfilmRatingEnum::GrfilmUnspecified => "grfilmUnspecified", + ContentRatingGrfilmRatingEnum::GrfilmK => "grfilmK", + ContentRatingGrfilmRatingEnum::GrfilmE => "grfilmE", + ContentRatingGrfilmRatingEnum::GrfilmK12 => "grfilmK12", + ContentRatingGrfilmRatingEnum::GrfilmK13 => "grfilmK13", + ContentRatingGrfilmRatingEnum::GrfilmK15 => "grfilmK15", + ContentRatingGrfilmRatingEnum::GrfilmK17 => "grfilmK17", + ContentRatingGrfilmRatingEnum::GrfilmK18 => "grfilmK18", + ContentRatingGrfilmRatingEnum::GrfilmUnrated => "grfilmUnrated", + } + } +} + +impl std::convert::TryFrom< &str> for ContentRatingGrfilmRatingEnum { + type Error = (); + fn try_from(value: &str) -> Result { + match value { + "grfilmUnspecified" => Ok(ContentRatingGrfilmRatingEnum::GrfilmUnspecified), + "grfilmK" => Ok(ContentRatingGrfilmRatingEnum::GrfilmK), + "grfilmE" => Ok(ContentRatingGrfilmRatingEnum::GrfilmE), + "grfilmK12" => Ok(ContentRatingGrfilmRatingEnum::GrfilmK12), + "grfilmK13" => Ok(ContentRatingGrfilmRatingEnum::GrfilmK13), + "grfilmK15" => Ok(ContentRatingGrfilmRatingEnum::GrfilmK15), + "grfilmK17" => Ok(ContentRatingGrfilmRatingEnum::GrfilmK17), + "grfilmK18" => Ok(ContentRatingGrfilmRatingEnum::GrfilmK18), + "grfilmUnrated" => Ok(ContentRatingGrfilmRatingEnum::GrfilmUnrated), + _=> Err(()), + } + } +} + +impl<'a> Into> for &'a ContentRatingGrfilmRatingEnum { + fn into(self) -> std::borrow::Cow<'a, str> { + self.as_ref().into() + } +} + + +#[derive(Clone, Copy, Eq, Hash, Debug, PartialEq, Serialize, Deserialize)] +/// The video's Instituto de la Cinematografía y de las Artes Audiovisuales (ICAA - Spain) rating. +pub enum ContentRatingIcaaRatingEnum { + + /// "icaaUnspecified" + #[serde(rename="icaaUnspecified")] + IcaaUnspecified, + + + /// APTA + /// + /// "icaaApta" + #[serde(rename="icaaApta")] + IcaaApta, + + + /// 7 + /// + /// "icaa7" + #[serde(rename="icaa7")] + Icaa7, + + + /// 12 + /// + /// "icaa12" + #[serde(rename="icaa12")] + Icaa12, + + + /// 13 + /// + /// "icaa13" + #[serde(rename="icaa13")] + Icaa13, + + + /// 16 + /// + /// "icaa16" + #[serde(rename="icaa16")] + Icaa16, + + + /// 18 + /// + /// "icaa18" + #[serde(rename="icaa18")] + Icaa18, + + + /// X + /// + /// "icaaX" + #[serde(rename="icaaX")] + IcaaX, + + /// "icaaUnrated" + #[serde(rename="icaaUnrated")] + IcaaUnrated, +} + +impl AsRef for ContentRatingIcaaRatingEnum { + fn as_ref(&self) -> &str { + match *self { + ContentRatingIcaaRatingEnum::IcaaUnspecified => "icaaUnspecified", + ContentRatingIcaaRatingEnum::IcaaApta => "icaaApta", + ContentRatingIcaaRatingEnum::Icaa7 => "icaa7", + ContentRatingIcaaRatingEnum::Icaa12 => "icaa12", + ContentRatingIcaaRatingEnum::Icaa13 => "icaa13", + ContentRatingIcaaRatingEnum::Icaa16 => "icaa16", + ContentRatingIcaaRatingEnum::Icaa18 => "icaa18", + ContentRatingIcaaRatingEnum::IcaaX => "icaaX", + ContentRatingIcaaRatingEnum::IcaaUnrated => "icaaUnrated", + } + } +} + +impl std::convert::TryFrom< &str> for ContentRatingIcaaRatingEnum { + type Error = (); + fn try_from(value: &str) -> Result { + match value { + "icaaUnspecified" => Ok(ContentRatingIcaaRatingEnum::IcaaUnspecified), + "icaaApta" => Ok(ContentRatingIcaaRatingEnum::IcaaApta), + "icaa7" => Ok(ContentRatingIcaaRatingEnum::Icaa7), + "icaa12" => Ok(ContentRatingIcaaRatingEnum::Icaa12), + "icaa13" => Ok(ContentRatingIcaaRatingEnum::Icaa13), + "icaa16" => Ok(ContentRatingIcaaRatingEnum::Icaa16), + "icaa18" => Ok(ContentRatingIcaaRatingEnum::Icaa18), + "icaaX" => Ok(ContentRatingIcaaRatingEnum::IcaaX), + "icaaUnrated" => Ok(ContentRatingIcaaRatingEnum::IcaaUnrated), + _=> Err(()), + } + } +} + +impl<'a> Into> for &'a ContentRatingIcaaRatingEnum { + fn into(self) -> std::borrow::Cow<'a, str> { + self.as_ref().into() + } +} + + +#[derive(Clone, Copy, Eq, Hash, Debug, PartialEq, Serialize, Deserialize)] +/// The video's Irish Film Classification Office (IFCO - Ireland) rating. See the IFCO website for more information. +pub enum ContentRatingIfcoRatingEnum { + + /// "ifcoUnspecified" + #[serde(rename="ifcoUnspecified")] + IfcoUnspecified, + + + /// G + /// + /// "ifcoG" + #[serde(rename="ifcoG")] + IfcoG, + + + /// PG + /// + /// "ifcoPg" + #[serde(rename="ifcoPg")] + IfcoPg, + + + /// 12 + /// + /// "ifco12" + #[serde(rename="ifco12")] + Ifco12, + + + /// 12A + /// + /// "ifco12a" + #[serde(rename="ifco12a")] + Ifco12a, + + + /// 15 + /// + /// "ifco15" + #[serde(rename="ifco15")] + Ifco15, + + + /// 15A + /// + /// "ifco15a" + #[serde(rename="ifco15a")] + Ifco15a, + + + /// 16 + /// + /// "ifco16" + #[serde(rename="ifco16")] + Ifco16, + + + /// 18 + /// + /// "ifco18" + #[serde(rename="ifco18")] + Ifco18, + + /// "ifcoUnrated" + #[serde(rename="ifcoUnrated")] + IfcoUnrated, +} + +impl AsRef for ContentRatingIfcoRatingEnum { + fn as_ref(&self) -> &str { + match *self { + ContentRatingIfcoRatingEnum::IfcoUnspecified => "ifcoUnspecified", + ContentRatingIfcoRatingEnum::IfcoG => "ifcoG", + ContentRatingIfcoRatingEnum::IfcoPg => "ifcoPg", + ContentRatingIfcoRatingEnum::Ifco12 => "ifco12", + ContentRatingIfcoRatingEnum::Ifco12a => "ifco12a", + ContentRatingIfcoRatingEnum::Ifco15 => "ifco15", + ContentRatingIfcoRatingEnum::Ifco15a => "ifco15a", + ContentRatingIfcoRatingEnum::Ifco16 => "ifco16", + ContentRatingIfcoRatingEnum::Ifco18 => "ifco18", + ContentRatingIfcoRatingEnum::IfcoUnrated => "ifcoUnrated", + } + } +} + +impl std::convert::TryFrom< &str> for ContentRatingIfcoRatingEnum { + type Error = (); + fn try_from(value: &str) -> Result { + match value { + "ifcoUnspecified" => Ok(ContentRatingIfcoRatingEnum::IfcoUnspecified), + "ifcoG" => Ok(ContentRatingIfcoRatingEnum::IfcoG), + "ifcoPg" => Ok(ContentRatingIfcoRatingEnum::IfcoPg), + "ifco12" => Ok(ContentRatingIfcoRatingEnum::Ifco12), + "ifco12a" => Ok(ContentRatingIfcoRatingEnum::Ifco12a), + "ifco15" => Ok(ContentRatingIfcoRatingEnum::Ifco15), + "ifco15a" => Ok(ContentRatingIfcoRatingEnum::Ifco15a), + "ifco16" => Ok(ContentRatingIfcoRatingEnum::Ifco16), + "ifco18" => Ok(ContentRatingIfcoRatingEnum::Ifco18), + "ifcoUnrated" => Ok(ContentRatingIfcoRatingEnum::IfcoUnrated), + _=> Err(()), + } + } +} + +impl<'a> Into> for &'a ContentRatingIfcoRatingEnum { + fn into(self) -> std::borrow::Cow<'a, str> { + self.as_ref().into() + } +} + + +#[derive(Clone, Copy, Eq, Hash, Debug, PartialEq, Serialize, Deserialize)] +/// The video's rating in Israel. +pub enum ContentRatingIlfilmRatingEnum { + + /// "ilfilmUnspecified" + #[serde(rename="ilfilmUnspecified")] + IlfilmUnspecified, + + + /// AA + /// + /// "ilfilmAa" + #[serde(rename="ilfilmAa")] + IlfilmAa, + + + /// 12 + /// + /// "ilfilm12" + #[serde(rename="ilfilm12")] + Ilfilm12, + + + /// 14 + /// + /// "ilfilm14" + #[serde(rename="ilfilm14")] + Ilfilm14, + + + /// 16 + /// + /// "ilfilm16" + #[serde(rename="ilfilm16")] + Ilfilm16, + + + /// 18 + /// + /// "ilfilm18" + #[serde(rename="ilfilm18")] + Ilfilm18, + + /// "ilfilmUnrated" + #[serde(rename="ilfilmUnrated")] + IlfilmUnrated, +} + +impl AsRef for ContentRatingIlfilmRatingEnum { + fn as_ref(&self) -> &str { + match *self { + ContentRatingIlfilmRatingEnum::IlfilmUnspecified => "ilfilmUnspecified", + ContentRatingIlfilmRatingEnum::IlfilmAa => "ilfilmAa", + ContentRatingIlfilmRatingEnum::Ilfilm12 => "ilfilm12", + ContentRatingIlfilmRatingEnum::Ilfilm14 => "ilfilm14", + ContentRatingIlfilmRatingEnum::Ilfilm16 => "ilfilm16", + ContentRatingIlfilmRatingEnum::Ilfilm18 => "ilfilm18", + ContentRatingIlfilmRatingEnum::IlfilmUnrated => "ilfilmUnrated", + } + } +} + +impl std::convert::TryFrom< &str> for ContentRatingIlfilmRatingEnum { + type Error = (); + fn try_from(value: &str) -> Result { + match value { + "ilfilmUnspecified" => Ok(ContentRatingIlfilmRatingEnum::IlfilmUnspecified), + "ilfilmAa" => Ok(ContentRatingIlfilmRatingEnum::IlfilmAa), + "ilfilm12" => Ok(ContentRatingIlfilmRatingEnum::Ilfilm12), + "ilfilm14" => Ok(ContentRatingIlfilmRatingEnum::Ilfilm14), + "ilfilm16" => Ok(ContentRatingIlfilmRatingEnum::Ilfilm16), + "ilfilm18" => Ok(ContentRatingIlfilmRatingEnum::Ilfilm18), + "ilfilmUnrated" => Ok(ContentRatingIlfilmRatingEnum::IlfilmUnrated), + _=> Err(()), + } + } +} + +impl<'a> Into> for &'a ContentRatingIlfilmRatingEnum { + fn into(self) -> std::borrow::Cow<'a, str> { + self.as_ref().into() + } +} + + +#[derive(Clone, Copy, Eq, Hash, Debug, PartialEq, Serialize, Deserialize)] +/// The video's INCAA (Instituto Nacional de Cine y Artes Audiovisuales - Argentina) rating. +pub enum ContentRatingIncaaRatingEnum { + + /// "incaaUnspecified" + #[serde(rename="incaaUnspecified")] + IncaaUnspecified, + + + /// ATP (Apta para todo publico) + /// + /// "incaaAtp" + #[serde(rename="incaaAtp")] + IncaaAtp, + + + /// 13 (Solo apta para mayores de 13 años) + /// + /// "incaaSam13" + #[serde(rename="incaaSam13")] + IncaaSam13, + + + /// 16 (Solo apta para mayores de 16 años) + /// + /// "incaaSam16" + #[serde(rename="incaaSam16")] + IncaaSam16, + + + /// 18 (Solo apta para mayores de 18 años) + /// + /// "incaaSam18" + #[serde(rename="incaaSam18")] + IncaaSam18, + + + /// X (Solo apta para mayores de 18 años, de exhibición condicionada) + /// + /// "incaaC" + #[serde(rename="incaaC")] + IncaaC, + + /// "incaaUnrated" + #[serde(rename="incaaUnrated")] + IncaaUnrated, +} + +impl AsRef for ContentRatingIncaaRatingEnum { + fn as_ref(&self) -> &str { + match *self { + ContentRatingIncaaRatingEnum::IncaaUnspecified => "incaaUnspecified", + ContentRatingIncaaRatingEnum::IncaaAtp => "incaaAtp", + ContentRatingIncaaRatingEnum::IncaaSam13 => "incaaSam13", + ContentRatingIncaaRatingEnum::IncaaSam16 => "incaaSam16", + ContentRatingIncaaRatingEnum::IncaaSam18 => "incaaSam18", + ContentRatingIncaaRatingEnum::IncaaC => "incaaC", + ContentRatingIncaaRatingEnum::IncaaUnrated => "incaaUnrated", + } + } +} + +impl std::convert::TryFrom< &str> for ContentRatingIncaaRatingEnum { + type Error = (); + fn try_from(value: &str) -> Result { + match value { + "incaaUnspecified" => Ok(ContentRatingIncaaRatingEnum::IncaaUnspecified), + "incaaAtp" => Ok(ContentRatingIncaaRatingEnum::IncaaAtp), + "incaaSam13" => Ok(ContentRatingIncaaRatingEnum::IncaaSam13), + "incaaSam16" => Ok(ContentRatingIncaaRatingEnum::IncaaSam16), + "incaaSam18" => Ok(ContentRatingIncaaRatingEnum::IncaaSam18), + "incaaC" => Ok(ContentRatingIncaaRatingEnum::IncaaC), + "incaaUnrated" => Ok(ContentRatingIncaaRatingEnum::IncaaUnrated), + _=> Err(()), + } + } +} + +impl<'a> Into> for &'a ContentRatingIncaaRatingEnum { + fn into(self) -> std::borrow::Cow<'a, str> { + self.as_ref().into() + } +} + + +#[derive(Clone, Copy, Eq, Hash, Debug, PartialEq, Serialize, Deserialize)] +/// The video's rating from the Kenya Film Classification Board. +pub enum ContentRatingKfcbRatingEnum { + + /// "kfcbUnspecified" + #[serde(rename="kfcbUnspecified")] + KfcbUnspecified, + + + /// GE + /// + /// "kfcbG" + #[serde(rename="kfcbG")] + KfcbG, + + + /// PG + /// + /// "kfcbPg" + #[serde(rename="kfcbPg")] + KfcbPg, + + + /// 16 + /// + /// "kfcb16plus" + #[serde(rename="kfcb16plus")] + Kfcb16plus, + + + /// 18 + /// + /// "kfcbR" + #[serde(rename="kfcbR")] + KfcbR, + + /// "kfcbUnrated" + #[serde(rename="kfcbUnrated")] + KfcbUnrated, +} + +impl AsRef for ContentRatingKfcbRatingEnum { + fn as_ref(&self) -> &str { + match *self { + ContentRatingKfcbRatingEnum::KfcbUnspecified => "kfcbUnspecified", + ContentRatingKfcbRatingEnum::KfcbG => "kfcbG", + ContentRatingKfcbRatingEnum::KfcbPg => "kfcbPg", + ContentRatingKfcbRatingEnum::Kfcb16plus => "kfcb16plus", + ContentRatingKfcbRatingEnum::KfcbR => "kfcbR", + ContentRatingKfcbRatingEnum::KfcbUnrated => "kfcbUnrated", + } + } +} + +impl std::convert::TryFrom< &str> for ContentRatingKfcbRatingEnum { + type Error = (); + fn try_from(value: &str) -> Result { + match value { + "kfcbUnspecified" => Ok(ContentRatingKfcbRatingEnum::KfcbUnspecified), + "kfcbG" => Ok(ContentRatingKfcbRatingEnum::KfcbG), + "kfcbPg" => Ok(ContentRatingKfcbRatingEnum::KfcbPg), + "kfcb16plus" => Ok(ContentRatingKfcbRatingEnum::Kfcb16plus), + "kfcbR" => Ok(ContentRatingKfcbRatingEnum::KfcbR), + "kfcbUnrated" => Ok(ContentRatingKfcbRatingEnum::KfcbUnrated), + _=> Err(()), + } + } +} + +impl<'a> Into> for &'a ContentRatingKfcbRatingEnum { + fn into(self) -> std::borrow::Cow<'a, str> { + self.as_ref().into() + } +} + + +#[derive(Clone, Copy, Eq, Hash, Debug, PartialEq, Serialize, Deserialize)] +/// The video's NICAM/Kijkwijzer rating from the Nederlands Instituut voor de Classificatie van Audiovisuele Media (Netherlands). +pub enum ContentRatingKijkwijzerRatingEnum { + + /// "kijkwijzerUnspecified" + #[serde(rename="kijkwijzerUnspecified")] + KijkwijzerUnspecified, + + + /// AL + /// + /// "kijkwijzerAl" + #[serde(rename="kijkwijzerAl")] + KijkwijzerAl, + + + /// 6 + /// + /// "kijkwijzer6" + #[serde(rename="kijkwijzer6")] + Kijkwijzer6, + + + /// 9 + /// + /// "kijkwijzer9" + #[serde(rename="kijkwijzer9")] + Kijkwijzer9, + + + /// 12 + /// + /// "kijkwijzer12" + #[serde(rename="kijkwijzer12")] + Kijkwijzer12, + + + /// 16 + /// + /// "kijkwijzer16" + #[serde(rename="kijkwijzer16")] + Kijkwijzer16, + + /// "kijkwijzer18" + #[serde(rename="kijkwijzer18")] + Kijkwijzer18, + + /// "kijkwijzerUnrated" + #[serde(rename="kijkwijzerUnrated")] + KijkwijzerUnrated, +} + +impl AsRef for ContentRatingKijkwijzerRatingEnum { + fn as_ref(&self) -> &str { + match *self { + ContentRatingKijkwijzerRatingEnum::KijkwijzerUnspecified => "kijkwijzerUnspecified", + ContentRatingKijkwijzerRatingEnum::KijkwijzerAl => "kijkwijzerAl", + ContentRatingKijkwijzerRatingEnum::Kijkwijzer6 => "kijkwijzer6", + ContentRatingKijkwijzerRatingEnum::Kijkwijzer9 => "kijkwijzer9", + ContentRatingKijkwijzerRatingEnum::Kijkwijzer12 => "kijkwijzer12", + ContentRatingKijkwijzerRatingEnum::Kijkwijzer16 => "kijkwijzer16", + ContentRatingKijkwijzerRatingEnum::Kijkwijzer18 => "kijkwijzer18", + ContentRatingKijkwijzerRatingEnum::KijkwijzerUnrated => "kijkwijzerUnrated", + } + } +} + +impl std::convert::TryFrom< &str> for ContentRatingKijkwijzerRatingEnum { + type Error = (); + fn try_from(value: &str) -> Result { + match value { + "kijkwijzerUnspecified" => Ok(ContentRatingKijkwijzerRatingEnum::KijkwijzerUnspecified), + "kijkwijzerAl" => Ok(ContentRatingKijkwijzerRatingEnum::KijkwijzerAl), + "kijkwijzer6" => Ok(ContentRatingKijkwijzerRatingEnum::Kijkwijzer6), + "kijkwijzer9" => Ok(ContentRatingKijkwijzerRatingEnum::Kijkwijzer9), + "kijkwijzer12" => Ok(ContentRatingKijkwijzerRatingEnum::Kijkwijzer12), + "kijkwijzer16" => Ok(ContentRatingKijkwijzerRatingEnum::Kijkwijzer16), + "kijkwijzer18" => Ok(ContentRatingKijkwijzerRatingEnum::Kijkwijzer18), + "kijkwijzerUnrated" => Ok(ContentRatingKijkwijzerRatingEnum::KijkwijzerUnrated), + _=> Err(()), + } + } +} + +impl<'a> Into> for &'a ContentRatingKijkwijzerRatingEnum { + fn into(self) -> std::borrow::Cow<'a, str> { + self.as_ref().into() + } +} + + +#[derive(Clone, Copy, Eq, Hash, Debug, PartialEq, Serialize, Deserialize)] +/// The video's Korea Media Rating Board (영상물등급위원회) rating. The KMRB rates videos in South Korea. +pub enum ContentRatingKmrbRatingEnum { + + /// "kmrbUnspecified" + #[serde(rename="kmrbUnspecified")] + KmrbUnspecified, + + + /// 전체관람가 + /// + /// "kmrbAll" + #[serde(rename="kmrbAll")] + KmrbAll, + + + /// 12세 이상 관람가 + /// + /// "kmrb12plus" + #[serde(rename="kmrb12plus")] + Kmrb12plus, + + + /// 15세 이상 관람가 + /// + /// "kmrb15plus" + #[serde(rename="kmrb15plus")] + Kmrb15plus, + + /// "kmrbTeenr" + #[serde(rename="kmrbTeenr")] + KmrbTeenr, + + + /// 청소년 관람불가 + /// + /// "kmrbR" + #[serde(rename="kmrbR")] + KmrbR, + + /// "kmrbUnrated" + #[serde(rename="kmrbUnrated")] + KmrbUnrated, +} + +impl AsRef for ContentRatingKmrbRatingEnum { + fn as_ref(&self) -> &str { + match *self { + ContentRatingKmrbRatingEnum::KmrbUnspecified => "kmrbUnspecified", + ContentRatingKmrbRatingEnum::KmrbAll => "kmrbAll", + ContentRatingKmrbRatingEnum::Kmrb12plus => "kmrb12plus", + ContentRatingKmrbRatingEnum::Kmrb15plus => "kmrb15plus", + ContentRatingKmrbRatingEnum::KmrbTeenr => "kmrbTeenr", + ContentRatingKmrbRatingEnum::KmrbR => "kmrbR", + ContentRatingKmrbRatingEnum::KmrbUnrated => "kmrbUnrated", + } + } +} + +impl std::convert::TryFrom< &str> for ContentRatingKmrbRatingEnum { + type Error = (); + fn try_from(value: &str) -> Result { + match value { + "kmrbUnspecified" => Ok(ContentRatingKmrbRatingEnum::KmrbUnspecified), + "kmrbAll" => Ok(ContentRatingKmrbRatingEnum::KmrbAll), + "kmrb12plus" => Ok(ContentRatingKmrbRatingEnum::Kmrb12plus), + "kmrb15plus" => Ok(ContentRatingKmrbRatingEnum::Kmrb15plus), + "kmrbTeenr" => Ok(ContentRatingKmrbRatingEnum::KmrbTeenr), + "kmrbR" => Ok(ContentRatingKmrbRatingEnum::KmrbR), + "kmrbUnrated" => Ok(ContentRatingKmrbRatingEnum::KmrbUnrated), + _=> Err(()), + } + } +} + +impl<'a> Into> for &'a ContentRatingKmrbRatingEnum { + fn into(self) -> std::borrow::Cow<'a, str> { + self.as_ref().into() + } +} + + +#[derive(Clone, Copy, Eq, Hash, Debug, PartialEq, Serialize, Deserialize)] +/// The video's rating from Indonesia's Lembaga Sensor Film. +pub enum ContentRatingLsfRatingEnum { + + /// "lsfUnspecified" + #[serde(rename="lsfUnspecified")] + LsfUnspecified, + + + /// SU + /// + /// "lsfSu" + #[serde(rename="lsfSu")] + LsfSu, + + + /// A + /// + /// "lsfA" + #[serde(rename="lsfA")] + LsfA, + + + /// BO + /// + /// "lsfBo" + #[serde(rename="lsfBo")] + LsfBo, + + + /// 13 + /// + /// "lsf13" + #[serde(rename="lsf13")] + Lsf13, + + + /// R + /// + /// "lsfR" + #[serde(rename="lsfR")] + LsfR, + + + /// 17 + /// + /// "lsf17" + #[serde(rename="lsf17")] + Lsf17, + + + /// D + /// + /// "lsfD" + #[serde(rename="lsfD")] + LsfD, + + + /// 21 + /// + /// "lsf21" + #[serde(rename="lsf21")] + Lsf21, + + /// "lsfUnrated" + #[serde(rename="lsfUnrated")] + LsfUnrated, +} + +impl AsRef for ContentRatingLsfRatingEnum { + fn as_ref(&self) -> &str { + match *self { + ContentRatingLsfRatingEnum::LsfUnspecified => "lsfUnspecified", + ContentRatingLsfRatingEnum::LsfSu => "lsfSu", + ContentRatingLsfRatingEnum::LsfA => "lsfA", + ContentRatingLsfRatingEnum::LsfBo => "lsfBo", + ContentRatingLsfRatingEnum::Lsf13 => "lsf13", + ContentRatingLsfRatingEnum::LsfR => "lsfR", + ContentRatingLsfRatingEnum::Lsf17 => "lsf17", + ContentRatingLsfRatingEnum::LsfD => "lsfD", + ContentRatingLsfRatingEnum::Lsf21 => "lsf21", + ContentRatingLsfRatingEnum::LsfUnrated => "lsfUnrated", + } + } +} + +impl std::convert::TryFrom< &str> for ContentRatingLsfRatingEnum { + type Error = (); + fn try_from(value: &str) -> Result { + match value { + "lsfUnspecified" => Ok(ContentRatingLsfRatingEnum::LsfUnspecified), + "lsfSu" => Ok(ContentRatingLsfRatingEnum::LsfSu), + "lsfA" => Ok(ContentRatingLsfRatingEnum::LsfA), + "lsfBo" => Ok(ContentRatingLsfRatingEnum::LsfBo), + "lsf13" => Ok(ContentRatingLsfRatingEnum::Lsf13), + "lsfR" => Ok(ContentRatingLsfRatingEnum::LsfR), + "lsf17" => Ok(ContentRatingLsfRatingEnum::Lsf17), + "lsfD" => Ok(ContentRatingLsfRatingEnum::LsfD), + "lsf21" => Ok(ContentRatingLsfRatingEnum::Lsf21), + "lsfUnrated" => Ok(ContentRatingLsfRatingEnum::LsfUnrated), + _=> Err(()), + } + } +} + +impl<'a> Into> for &'a ContentRatingLsfRatingEnum { + fn into(self) -> std::borrow::Cow<'a, str> { + self.as_ref().into() + } +} + + +#[derive(Clone, Copy, Eq, Hash, Debug, PartialEq, Serialize, Deserialize)] +/// The video's rating from Malta's Film Age-Classification Board. +pub enum ContentRatingMccaaRatingEnum { + + /// "mccaaUnspecified" + #[serde(rename="mccaaUnspecified")] + MccaaUnspecified, + + + /// U + /// + /// "mccaaU" + #[serde(rename="mccaaU")] + MccaaU, + + + /// PG + /// + /// "mccaaPg" + #[serde(rename="mccaaPg")] + MccaaPg, + + + /// 12A + /// + /// "mccaa12a" + #[serde(rename="mccaa12a")] + Mccaa12a, + + + /// 12 + /// + /// "mccaa12" + #[serde(rename="mccaa12")] + Mccaa12, + + + /// 14 - this rating was removed from the new classification structure introduced in 2013. + /// + /// "mccaa14" + #[serde(rename="mccaa14")] + Mccaa14, + + + /// 15 + /// + /// "mccaa15" + #[serde(rename="mccaa15")] + Mccaa15, + + + /// 16 - this rating was removed from the new classification structure introduced in 2013. + /// + /// "mccaa16" + #[serde(rename="mccaa16")] + Mccaa16, + + + /// 18 + /// + /// "mccaa18" + #[serde(rename="mccaa18")] + Mccaa18, + + /// "mccaaUnrated" + #[serde(rename="mccaaUnrated")] + MccaaUnrated, +} + +impl AsRef for ContentRatingMccaaRatingEnum { + fn as_ref(&self) -> &str { + match *self { + ContentRatingMccaaRatingEnum::MccaaUnspecified => "mccaaUnspecified", + ContentRatingMccaaRatingEnum::MccaaU => "mccaaU", + ContentRatingMccaaRatingEnum::MccaaPg => "mccaaPg", + ContentRatingMccaaRatingEnum::Mccaa12a => "mccaa12a", + ContentRatingMccaaRatingEnum::Mccaa12 => "mccaa12", + ContentRatingMccaaRatingEnum::Mccaa14 => "mccaa14", + ContentRatingMccaaRatingEnum::Mccaa15 => "mccaa15", + ContentRatingMccaaRatingEnum::Mccaa16 => "mccaa16", + ContentRatingMccaaRatingEnum::Mccaa18 => "mccaa18", + ContentRatingMccaaRatingEnum::MccaaUnrated => "mccaaUnrated", + } + } +} + +impl std::convert::TryFrom< &str> for ContentRatingMccaaRatingEnum { + type Error = (); + fn try_from(value: &str) -> Result { + match value { + "mccaaUnspecified" => Ok(ContentRatingMccaaRatingEnum::MccaaUnspecified), + "mccaaU" => Ok(ContentRatingMccaaRatingEnum::MccaaU), + "mccaaPg" => Ok(ContentRatingMccaaRatingEnum::MccaaPg), + "mccaa12a" => Ok(ContentRatingMccaaRatingEnum::Mccaa12a), + "mccaa12" => Ok(ContentRatingMccaaRatingEnum::Mccaa12), + "mccaa14" => Ok(ContentRatingMccaaRatingEnum::Mccaa14), + "mccaa15" => Ok(ContentRatingMccaaRatingEnum::Mccaa15), + "mccaa16" => Ok(ContentRatingMccaaRatingEnum::Mccaa16), + "mccaa18" => Ok(ContentRatingMccaaRatingEnum::Mccaa18), + "mccaaUnrated" => Ok(ContentRatingMccaaRatingEnum::MccaaUnrated), + _=> Err(()), + } + } +} + +impl<'a> Into> for &'a ContentRatingMccaaRatingEnum { + fn into(self) -> std::borrow::Cow<'a, str> { + self.as_ref().into() + } +} + + +#[derive(Clone, Copy, Eq, Hash, Debug, PartialEq, Serialize, Deserialize)] +/// The video's rating from the Danish Film Institute's (Det Danske Filminstitut) Media Council for Children and Young People. +pub enum ContentRatingMccypRatingEnum { + + /// "mccypUnspecified" + #[serde(rename="mccypUnspecified")] + MccypUnspecified, + + + /// A + /// + /// "mccypA" + #[serde(rename="mccypA")] + MccypA, + + + /// 7 + /// + /// "mccyp7" + #[serde(rename="mccyp7")] + Mccyp7, + + + /// 11 + /// + /// "mccyp11" + #[serde(rename="mccyp11")] + Mccyp11, + + + /// 15 + /// + /// "mccyp15" + #[serde(rename="mccyp15")] + Mccyp15, + + /// "mccypUnrated" + #[serde(rename="mccypUnrated")] + MccypUnrated, +} + +impl AsRef for ContentRatingMccypRatingEnum { + fn as_ref(&self) -> &str { + match *self { + ContentRatingMccypRatingEnum::MccypUnspecified => "mccypUnspecified", + ContentRatingMccypRatingEnum::MccypA => "mccypA", + ContentRatingMccypRatingEnum::Mccyp7 => "mccyp7", + ContentRatingMccypRatingEnum::Mccyp11 => "mccyp11", + ContentRatingMccypRatingEnum::Mccyp15 => "mccyp15", + ContentRatingMccypRatingEnum::MccypUnrated => "mccypUnrated", + } + } +} + +impl std::convert::TryFrom< &str> for ContentRatingMccypRatingEnum { + type Error = (); + fn try_from(value: &str) -> Result { + match value { + "mccypUnspecified" => Ok(ContentRatingMccypRatingEnum::MccypUnspecified), + "mccypA" => Ok(ContentRatingMccypRatingEnum::MccypA), + "mccyp7" => Ok(ContentRatingMccypRatingEnum::Mccyp7), + "mccyp11" => Ok(ContentRatingMccypRatingEnum::Mccyp11), + "mccyp15" => Ok(ContentRatingMccypRatingEnum::Mccyp15), + "mccypUnrated" => Ok(ContentRatingMccypRatingEnum::MccypUnrated), + _=> Err(()), + } + } +} + +impl<'a> Into> for &'a ContentRatingMccypRatingEnum { + fn into(self) -> std::borrow::Cow<'a, str> { + self.as_ref().into() + } +} + + +#[derive(Clone, Copy, Eq, Hash, Debug, PartialEq, Serialize, Deserialize)] +/// The video's rating system for Vietnam - MCST +pub enum ContentRatingMcstRatingEnum { + + /// "mcstUnspecified" + #[serde(rename="mcstUnspecified")] + McstUnspecified, + + + /// P + /// + /// "mcstP" + #[serde(rename="mcstP")] + McstP, + + + /// 0 + /// + /// "mcst0" + #[serde(rename="mcst0")] + Mcst0, + + + /// C13 + /// + /// "mcstC13" + #[serde(rename="mcstC13")] + McstC13, + + + /// C16 + /// + /// "mcstC16" + #[serde(rename="mcstC16")] + McstC16, + + + /// 16+ + /// + /// "mcst16plus" + #[serde(rename="mcst16plus")] + Mcst16plus, + + + /// C18 + /// + /// "mcstC18" + #[serde(rename="mcstC18")] + McstC18, + + + /// MCST_G_PG + /// + /// "mcstGPg" + #[serde(rename="mcstGPg")] + McstGPg, + + /// "mcstUnrated" + #[serde(rename="mcstUnrated")] + McstUnrated, +} + +impl AsRef for ContentRatingMcstRatingEnum { + fn as_ref(&self) -> &str { + match *self { + ContentRatingMcstRatingEnum::McstUnspecified => "mcstUnspecified", + ContentRatingMcstRatingEnum::McstP => "mcstP", + ContentRatingMcstRatingEnum::Mcst0 => "mcst0", + ContentRatingMcstRatingEnum::McstC13 => "mcstC13", + ContentRatingMcstRatingEnum::McstC16 => "mcstC16", + ContentRatingMcstRatingEnum::Mcst16plus => "mcst16plus", + ContentRatingMcstRatingEnum::McstC18 => "mcstC18", + ContentRatingMcstRatingEnum::McstGPg => "mcstGPg", + ContentRatingMcstRatingEnum::McstUnrated => "mcstUnrated", + } + } +} + +impl std::convert::TryFrom< &str> for ContentRatingMcstRatingEnum { + type Error = (); + fn try_from(value: &str) -> Result { + match value { + "mcstUnspecified" => Ok(ContentRatingMcstRatingEnum::McstUnspecified), + "mcstP" => Ok(ContentRatingMcstRatingEnum::McstP), + "mcst0" => Ok(ContentRatingMcstRatingEnum::Mcst0), + "mcstC13" => Ok(ContentRatingMcstRatingEnum::McstC13), + "mcstC16" => Ok(ContentRatingMcstRatingEnum::McstC16), + "mcst16plus" => Ok(ContentRatingMcstRatingEnum::Mcst16plus), + "mcstC18" => Ok(ContentRatingMcstRatingEnum::McstC18), + "mcstGPg" => Ok(ContentRatingMcstRatingEnum::McstGPg), + "mcstUnrated" => Ok(ContentRatingMcstRatingEnum::McstUnrated), + _=> Err(()), + } + } +} + +impl<'a> Into> for &'a ContentRatingMcstRatingEnum { + fn into(self) -> std::borrow::Cow<'a, str> { + self.as_ref().into() + } +} + + +#[derive(Clone, Copy, Eq, Hash, Debug, PartialEq, Serialize, Deserialize)] +/// The video's rating from Singapore's Media Development Authority (MDA) and, specifically, it's Board of Film Censors (BFC). +pub enum ContentRatingMdaRatingEnum { + + /// "mdaUnspecified" + #[serde(rename="mdaUnspecified")] + MdaUnspecified, + + + /// G + /// + /// "mdaG" + #[serde(rename="mdaG")] + MdaG, + + + /// PG + /// + /// "mdaPg" + #[serde(rename="mdaPg")] + MdaPg, + + + /// PG13 + /// + /// "mdaPg13" + #[serde(rename="mdaPg13")] + MdaPg13, + + + /// NC16 + /// + /// "mdaNc16" + #[serde(rename="mdaNc16")] + MdaNc16, + + + /// M18 + /// + /// "mdaM18" + #[serde(rename="mdaM18")] + MdaM18, + + + /// R21 + /// + /// "mdaR21" + #[serde(rename="mdaR21")] + MdaR21, + + /// "mdaUnrated" + #[serde(rename="mdaUnrated")] + MdaUnrated, +} + +impl AsRef for ContentRatingMdaRatingEnum { + fn as_ref(&self) -> &str { + match *self { + ContentRatingMdaRatingEnum::MdaUnspecified => "mdaUnspecified", + ContentRatingMdaRatingEnum::MdaG => "mdaG", + ContentRatingMdaRatingEnum::MdaPg => "mdaPg", + ContentRatingMdaRatingEnum::MdaPg13 => "mdaPg13", + ContentRatingMdaRatingEnum::MdaNc16 => "mdaNc16", + ContentRatingMdaRatingEnum::MdaM18 => "mdaM18", + ContentRatingMdaRatingEnum::MdaR21 => "mdaR21", + ContentRatingMdaRatingEnum::MdaUnrated => "mdaUnrated", + } + } +} + +impl std::convert::TryFrom< &str> for ContentRatingMdaRatingEnum { + type Error = (); + fn try_from(value: &str) -> Result { + match value { + "mdaUnspecified" => Ok(ContentRatingMdaRatingEnum::MdaUnspecified), + "mdaG" => Ok(ContentRatingMdaRatingEnum::MdaG), + "mdaPg" => Ok(ContentRatingMdaRatingEnum::MdaPg), + "mdaPg13" => Ok(ContentRatingMdaRatingEnum::MdaPg13), + "mdaNc16" => Ok(ContentRatingMdaRatingEnum::MdaNc16), + "mdaM18" => Ok(ContentRatingMdaRatingEnum::MdaM18), + "mdaR21" => Ok(ContentRatingMdaRatingEnum::MdaR21), + "mdaUnrated" => Ok(ContentRatingMdaRatingEnum::MdaUnrated), + _=> Err(()), + } + } +} + +impl<'a> Into> for &'a ContentRatingMdaRatingEnum { + fn into(self) -> std::borrow::Cow<'a, str> { + self.as_ref().into() + } +} + + +#[derive(Clone, Copy, Eq, Hash, Debug, PartialEq, Serialize, Deserialize)] +/// The video's rating from Medietilsynet, the Norwegian Media Authority. +pub enum ContentRatingMedietilsynetRatingEnum { + + /// "medietilsynetUnspecified" + #[serde(rename="medietilsynetUnspecified")] + MedietilsynetUnspecified, + + + /// A + /// + /// "medietilsynetA" + #[serde(rename="medietilsynetA")] + MedietilsynetA, + + + /// 6 + /// + /// "medietilsynet6" + #[serde(rename="medietilsynet6")] + Medietilsynet6, + + + /// 7 + /// + /// "medietilsynet7" + #[serde(rename="medietilsynet7")] + Medietilsynet7, + + + /// 9 + /// + /// "medietilsynet9" + #[serde(rename="medietilsynet9")] + Medietilsynet9, + + + /// 11 + /// + /// "medietilsynet11" + #[serde(rename="medietilsynet11")] + Medietilsynet11, + + + /// 12 + /// + /// "medietilsynet12" + #[serde(rename="medietilsynet12")] + Medietilsynet12, + + + /// 15 + /// + /// "medietilsynet15" + #[serde(rename="medietilsynet15")] + Medietilsynet15, + + + /// 18 + /// + /// "medietilsynet18" + #[serde(rename="medietilsynet18")] + Medietilsynet18, + + /// "medietilsynetUnrated" + #[serde(rename="medietilsynetUnrated")] + MedietilsynetUnrated, +} + +impl AsRef for ContentRatingMedietilsynetRatingEnum { + fn as_ref(&self) -> &str { + match *self { + ContentRatingMedietilsynetRatingEnum::MedietilsynetUnspecified => "medietilsynetUnspecified", + ContentRatingMedietilsynetRatingEnum::MedietilsynetA => "medietilsynetA", + ContentRatingMedietilsynetRatingEnum::Medietilsynet6 => "medietilsynet6", + ContentRatingMedietilsynetRatingEnum::Medietilsynet7 => "medietilsynet7", + ContentRatingMedietilsynetRatingEnum::Medietilsynet9 => "medietilsynet9", + ContentRatingMedietilsynetRatingEnum::Medietilsynet11 => "medietilsynet11", + ContentRatingMedietilsynetRatingEnum::Medietilsynet12 => "medietilsynet12", + ContentRatingMedietilsynetRatingEnum::Medietilsynet15 => "medietilsynet15", + ContentRatingMedietilsynetRatingEnum::Medietilsynet18 => "medietilsynet18", + ContentRatingMedietilsynetRatingEnum::MedietilsynetUnrated => "medietilsynetUnrated", + } + } +} + +impl std::convert::TryFrom< &str> for ContentRatingMedietilsynetRatingEnum { + type Error = (); + fn try_from(value: &str) -> Result { + match value { + "medietilsynetUnspecified" => Ok(ContentRatingMedietilsynetRatingEnum::MedietilsynetUnspecified), + "medietilsynetA" => Ok(ContentRatingMedietilsynetRatingEnum::MedietilsynetA), + "medietilsynet6" => Ok(ContentRatingMedietilsynetRatingEnum::Medietilsynet6), + "medietilsynet7" => Ok(ContentRatingMedietilsynetRatingEnum::Medietilsynet7), + "medietilsynet9" => Ok(ContentRatingMedietilsynetRatingEnum::Medietilsynet9), + "medietilsynet11" => Ok(ContentRatingMedietilsynetRatingEnum::Medietilsynet11), + "medietilsynet12" => Ok(ContentRatingMedietilsynetRatingEnum::Medietilsynet12), + "medietilsynet15" => Ok(ContentRatingMedietilsynetRatingEnum::Medietilsynet15), + "medietilsynet18" => Ok(ContentRatingMedietilsynetRatingEnum::Medietilsynet18), + "medietilsynetUnrated" => Ok(ContentRatingMedietilsynetRatingEnum::MedietilsynetUnrated), + _=> Err(()), + } + } +} + +impl<'a> Into> for &'a ContentRatingMedietilsynetRatingEnum { + fn into(self) -> std::borrow::Cow<'a, str> { + self.as_ref().into() + } +} + + +#[derive(Clone, Copy, Eq, Hash, Debug, PartialEq, Serialize, Deserialize)] +/// The video's rating from Finland's Kansallinen Audiovisuaalinen Instituutti (National Audiovisual Institute). +pub enum ContentRatingMekuRatingEnum { + + /// "mekuUnspecified" + #[serde(rename="mekuUnspecified")] + MekuUnspecified, + + + /// S + /// + /// "mekuS" + #[serde(rename="mekuS")] + MekuS, + + + /// 7 + /// + /// "meku7" + #[serde(rename="meku7")] + Meku7, + + + /// 12 + /// + /// "meku12" + #[serde(rename="meku12")] + Meku12, + + + /// 16 + /// + /// "meku16" + #[serde(rename="meku16")] + Meku16, + + + /// 18 + /// + /// "meku18" + #[serde(rename="meku18")] + Meku18, + + /// "mekuUnrated" + #[serde(rename="mekuUnrated")] + MekuUnrated, +} + +impl AsRef for ContentRatingMekuRatingEnum { + fn as_ref(&self) -> &str { + match *self { + ContentRatingMekuRatingEnum::MekuUnspecified => "mekuUnspecified", + ContentRatingMekuRatingEnum::MekuS => "mekuS", + ContentRatingMekuRatingEnum::Meku7 => "meku7", + ContentRatingMekuRatingEnum::Meku12 => "meku12", + ContentRatingMekuRatingEnum::Meku16 => "meku16", + ContentRatingMekuRatingEnum::Meku18 => "meku18", + ContentRatingMekuRatingEnum::MekuUnrated => "mekuUnrated", + } + } +} + +impl std::convert::TryFrom< &str> for ContentRatingMekuRatingEnum { + type Error = (); + fn try_from(value: &str) -> Result { + match value { + "mekuUnspecified" => Ok(ContentRatingMekuRatingEnum::MekuUnspecified), + "mekuS" => Ok(ContentRatingMekuRatingEnum::MekuS), + "meku7" => Ok(ContentRatingMekuRatingEnum::Meku7), + "meku12" => Ok(ContentRatingMekuRatingEnum::Meku12), + "meku16" => Ok(ContentRatingMekuRatingEnum::Meku16), + "meku18" => Ok(ContentRatingMekuRatingEnum::Meku18), + "mekuUnrated" => Ok(ContentRatingMekuRatingEnum::MekuUnrated), + _=> Err(()), + } + } +} + +impl<'a> Into> for &'a ContentRatingMekuRatingEnum { + fn into(self) -> std::borrow::Cow<'a, str> { + self.as_ref().into() + } +} + + +#[derive(Clone, Copy, Eq, Hash, Debug, PartialEq, Serialize, Deserialize)] +/// The rating system for MENA countries, a clone of MPAA. It is needed to prevent titles go live w/o additional QC check, since some of them can be inappropriate for the countries at all. See b/33408548 for more details. +pub enum ContentRatingMenaMpaaRatingEnum { + + /// "menaMpaaUnspecified" + #[serde(rename="menaMpaaUnspecified")] + MenaMpaaUnspecified, + + + /// G + /// + /// "menaMpaaG" + #[serde(rename="menaMpaaG")] + MenaMpaaG, + + + /// PG + /// + /// "menaMpaaPg" + #[serde(rename="menaMpaaPg")] + MenaMpaaPg, + + + /// PG-13 + /// + /// "menaMpaaPg13" + #[serde(rename="menaMpaaPg13")] + MenaMpaaPg13, + + + /// R + /// + /// "menaMpaaR" + #[serde(rename="menaMpaaR")] + MenaMpaaR, + + + /// To keep the same enum values as MPAA's items have, skip NC_17. + /// + /// "menaMpaaUnrated" + #[serde(rename="menaMpaaUnrated")] + MenaMpaaUnrated, +} + +impl AsRef for ContentRatingMenaMpaaRatingEnum { + fn as_ref(&self) -> &str { + match *self { + ContentRatingMenaMpaaRatingEnum::MenaMpaaUnspecified => "menaMpaaUnspecified", + ContentRatingMenaMpaaRatingEnum::MenaMpaaG => "menaMpaaG", + ContentRatingMenaMpaaRatingEnum::MenaMpaaPg => "menaMpaaPg", + ContentRatingMenaMpaaRatingEnum::MenaMpaaPg13 => "menaMpaaPg13", + ContentRatingMenaMpaaRatingEnum::MenaMpaaR => "menaMpaaR", + ContentRatingMenaMpaaRatingEnum::MenaMpaaUnrated => "menaMpaaUnrated", + } + } +} + +impl std::convert::TryFrom< &str> for ContentRatingMenaMpaaRatingEnum { + type Error = (); + fn try_from(value: &str) -> Result { + match value { + "menaMpaaUnspecified" => Ok(ContentRatingMenaMpaaRatingEnum::MenaMpaaUnspecified), + "menaMpaaG" => Ok(ContentRatingMenaMpaaRatingEnum::MenaMpaaG), + "menaMpaaPg" => Ok(ContentRatingMenaMpaaRatingEnum::MenaMpaaPg), + "menaMpaaPg13" => Ok(ContentRatingMenaMpaaRatingEnum::MenaMpaaPg13), + "menaMpaaR" => Ok(ContentRatingMenaMpaaRatingEnum::MenaMpaaR), + "menaMpaaUnrated" => Ok(ContentRatingMenaMpaaRatingEnum::MenaMpaaUnrated), + _=> Err(()), + } + } +} + +impl<'a> Into> for &'a ContentRatingMenaMpaaRatingEnum { + fn into(self) -> std::borrow::Cow<'a, str> { + self.as_ref().into() + } +} + + +#[derive(Clone, Copy, Eq, Hash, Debug, PartialEq, Serialize, Deserialize)] +/// The video's rating from the Ministero dei Beni e delle Attività Culturali e del Turismo (Italy). +pub enum ContentRatingMibacRatingEnum { + + /// "mibacUnspecified" + #[serde(rename="mibacUnspecified")] + MibacUnspecified, + + /// "mibacT" + #[serde(rename="mibacT")] + MibacT, + + /// "mibacVap" + #[serde(rename="mibacVap")] + MibacVap, + + /// "mibacVm6" + #[serde(rename="mibacVm6")] + MibacVm6, + + /// "mibacVm12" + #[serde(rename="mibacVm12")] + MibacVm12, + + /// "mibacVm14" + #[serde(rename="mibacVm14")] + MibacVm14, + + /// "mibacVm16" + #[serde(rename="mibacVm16")] + MibacVm16, + + /// "mibacVm18" + #[serde(rename="mibacVm18")] + MibacVm18, + + /// "mibacUnrated" + #[serde(rename="mibacUnrated")] + MibacUnrated, +} + +impl AsRef for ContentRatingMibacRatingEnum { + fn as_ref(&self) -> &str { + match *self { + ContentRatingMibacRatingEnum::MibacUnspecified => "mibacUnspecified", + ContentRatingMibacRatingEnum::MibacT => "mibacT", + ContentRatingMibacRatingEnum::MibacVap => "mibacVap", + ContentRatingMibacRatingEnum::MibacVm6 => "mibacVm6", + ContentRatingMibacRatingEnum::MibacVm12 => "mibacVm12", + ContentRatingMibacRatingEnum::MibacVm14 => "mibacVm14", + ContentRatingMibacRatingEnum::MibacVm16 => "mibacVm16", + ContentRatingMibacRatingEnum::MibacVm18 => "mibacVm18", + ContentRatingMibacRatingEnum::MibacUnrated => "mibacUnrated", + } + } +} + +impl std::convert::TryFrom< &str> for ContentRatingMibacRatingEnum { + type Error = (); + fn try_from(value: &str) -> Result { + match value { + "mibacUnspecified" => Ok(ContentRatingMibacRatingEnum::MibacUnspecified), + "mibacT" => Ok(ContentRatingMibacRatingEnum::MibacT), + "mibacVap" => Ok(ContentRatingMibacRatingEnum::MibacVap), + "mibacVm6" => Ok(ContentRatingMibacRatingEnum::MibacVm6), + "mibacVm12" => Ok(ContentRatingMibacRatingEnum::MibacVm12), + "mibacVm14" => Ok(ContentRatingMibacRatingEnum::MibacVm14), + "mibacVm16" => Ok(ContentRatingMibacRatingEnum::MibacVm16), + "mibacVm18" => Ok(ContentRatingMibacRatingEnum::MibacVm18), + "mibacUnrated" => Ok(ContentRatingMibacRatingEnum::MibacUnrated), + _=> Err(()), + } + } +} + +impl<'a> Into> for &'a ContentRatingMibacRatingEnum { + fn into(self) -> std::borrow::Cow<'a, str> { + self.as_ref().into() + } +} + + +#[derive(Clone, Copy, Eq, Hash, Debug, PartialEq, Serialize, Deserialize)] +/// The video's Ministerio de Cultura (Colombia) rating. +pub enum ContentRatingMocRatingEnum { + + /// "mocUnspecified" + #[serde(rename="mocUnspecified")] + MocUnspecified, + + + /// E + /// + /// "mocE" + #[serde(rename="mocE")] + MocE, + + + /// T + /// + /// "mocT" + #[serde(rename="mocT")] + MocT, + + + /// 7 + /// + /// "moc7" + #[serde(rename="moc7")] + Moc7, + + + /// 12 + /// + /// "moc12" + #[serde(rename="moc12")] + Moc12, + + + /// 15 + /// + /// "moc15" + #[serde(rename="moc15")] + Moc15, + + + /// 18 + /// + /// "moc18" + #[serde(rename="moc18")] + Moc18, + + + /// X + /// + /// "mocX" + #[serde(rename="mocX")] + MocX, + + + /// Banned + /// + /// "mocBanned" + #[serde(rename="mocBanned")] + MocBanned, + + /// "mocUnrated" + #[serde(rename="mocUnrated")] + MocUnrated, +} + +impl AsRef for ContentRatingMocRatingEnum { + fn as_ref(&self) -> &str { + match *self { + ContentRatingMocRatingEnum::MocUnspecified => "mocUnspecified", + ContentRatingMocRatingEnum::MocE => "mocE", + ContentRatingMocRatingEnum::MocT => "mocT", + ContentRatingMocRatingEnum::Moc7 => "moc7", + ContentRatingMocRatingEnum::Moc12 => "moc12", + ContentRatingMocRatingEnum::Moc15 => "moc15", + ContentRatingMocRatingEnum::Moc18 => "moc18", + ContentRatingMocRatingEnum::MocX => "mocX", + ContentRatingMocRatingEnum::MocBanned => "mocBanned", + ContentRatingMocRatingEnum::MocUnrated => "mocUnrated", + } + } +} + +impl std::convert::TryFrom< &str> for ContentRatingMocRatingEnum { + type Error = (); + fn try_from(value: &str) -> Result { + match value { + "mocUnspecified" => Ok(ContentRatingMocRatingEnum::MocUnspecified), + "mocE" => Ok(ContentRatingMocRatingEnum::MocE), + "mocT" => Ok(ContentRatingMocRatingEnum::MocT), + "moc7" => Ok(ContentRatingMocRatingEnum::Moc7), + "moc12" => Ok(ContentRatingMocRatingEnum::Moc12), + "moc15" => Ok(ContentRatingMocRatingEnum::Moc15), + "moc18" => Ok(ContentRatingMocRatingEnum::Moc18), + "mocX" => Ok(ContentRatingMocRatingEnum::MocX), + "mocBanned" => Ok(ContentRatingMocRatingEnum::MocBanned), + "mocUnrated" => Ok(ContentRatingMocRatingEnum::MocUnrated), + _=> Err(()), + } + } +} + +impl<'a> Into> for &'a ContentRatingMocRatingEnum { + fn into(self) -> std::borrow::Cow<'a, str> { + self.as_ref().into() + } +} + + +#[derive(Clone, Copy, Eq, Hash, Debug, PartialEq, Serialize, Deserialize)] +/// The video's rating from Taiwan's Ministry of Culture (文化部). +pub enum ContentRatingMoctwRatingEnum { + + /// "moctwUnspecified" + #[serde(rename="moctwUnspecified")] + MoctwUnspecified, + + + /// G + /// + /// "moctwG" + #[serde(rename="moctwG")] + MoctwG, + + + /// P + /// + /// "moctwP" + #[serde(rename="moctwP")] + MoctwP, + + + /// PG + /// + /// "moctwPg" + #[serde(rename="moctwPg")] + MoctwPg, + + + /// R + /// + /// "moctwR" + #[serde(rename="moctwR")] + MoctwR, + + /// "moctwUnrated" + #[serde(rename="moctwUnrated")] + MoctwUnrated, + + + /// R-12 + /// + /// "moctwR12" + #[serde(rename="moctwR12")] + MoctwR12, + + + /// R-15 + /// + /// "moctwR15" + #[serde(rename="moctwR15")] + MoctwR15, +} + +impl AsRef for ContentRatingMoctwRatingEnum { + fn as_ref(&self) -> &str { + match *self { + ContentRatingMoctwRatingEnum::MoctwUnspecified => "moctwUnspecified", + ContentRatingMoctwRatingEnum::MoctwG => "moctwG", + ContentRatingMoctwRatingEnum::MoctwP => "moctwP", + ContentRatingMoctwRatingEnum::MoctwPg => "moctwPg", + ContentRatingMoctwRatingEnum::MoctwR => "moctwR", + ContentRatingMoctwRatingEnum::MoctwUnrated => "moctwUnrated", + ContentRatingMoctwRatingEnum::MoctwR12 => "moctwR12", + ContentRatingMoctwRatingEnum::MoctwR15 => "moctwR15", + } + } +} + +impl std::convert::TryFrom< &str> for ContentRatingMoctwRatingEnum { + type Error = (); + fn try_from(value: &str) -> Result { + match value { + "moctwUnspecified" => Ok(ContentRatingMoctwRatingEnum::MoctwUnspecified), + "moctwG" => Ok(ContentRatingMoctwRatingEnum::MoctwG), + "moctwP" => Ok(ContentRatingMoctwRatingEnum::MoctwP), + "moctwPg" => Ok(ContentRatingMoctwRatingEnum::MoctwPg), + "moctwR" => Ok(ContentRatingMoctwRatingEnum::MoctwR), + "moctwUnrated" => Ok(ContentRatingMoctwRatingEnum::MoctwUnrated), + "moctwR12" => Ok(ContentRatingMoctwRatingEnum::MoctwR12), + "moctwR15" => Ok(ContentRatingMoctwRatingEnum::MoctwR15), + _=> Err(()), + } + } +} + +impl<'a> Into> for &'a ContentRatingMoctwRatingEnum { + fn into(self) -> std::borrow::Cow<'a, str> { + self.as_ref().into() + } +} + + +#[derive(Clone, Copy, Eq, Hash, Debug, PartialEq, Serialize, Deserialize)] +/// The video's Motion Picture Association of America (MPAA) rating. +pub enum ContentRatingMpaaRatingEnum { + + /// "mpaaUnspecified" + #[serde(rename="mpaaUnspecified")] + MpaaUnspecified, + + + /// G + /// + /// "mpaaG" + #[serde(rename="mpaaG")] + MpaaG, + + + /// PG + /// + /// "mpaaPg" + #[serde(rename="mpaaPg")] + MpaaPg, + + + /// PG-13 + /// + /// "mpaaPg13" + #[serde(rename="mpaaPg13")] + MpaaPg13, + + + /// R + /// + /// "mpaaR" + #[serde(rename="mpaaR")] + MpaaR, + + + /// NC-17 + /// + /// "mpaaNc17" + #[serde(rename="mpaaNc17")] + MpaaNc17, + + + /// ! X + /// + /// "mpaaX" + #[serde(rename="mpaaX")] + MpaaX, + + /// "mpaaUnrated" + #[serde(rename="mpaaUnrated")] + MpaaUnrated, +} + +impl AsRef for ContentRatingMpaaRatingEnum { + fn as_ref(&self) -> &str { + match *self { + ContentRatingMpaaRatingEnum::MpaaUnspecified => "mpaaUnspecified", + ContentRatingMpaaRatingEnum::MpaaG => "mpaaG", + ContentRatingMpaaRatingEnum::MpaaPg => "mpaaPg", + ContentRatingMpaaRatingEnum::MpaaPg13 => "mpaaPg13", + ContentRatingMpaaRatingEnum::MpaaR => "mpaaR", + ContentRatingMpaaRatingEnum::MpaaNc17 => "mpaaNc17", + ContentRatingMpaaRatingEnum::MpaaX => "mpaaX", + ContentRatingMpaaRatingEnum::MpaaUnrated => "mpaaUnrated", + } + } +} + +impl std::convert::TryFrom< &str> for ContentRatingMpaaRatingEnum { + type Error = (); + fn try_from(value: &str) -> Result { + match value { + "mpaaUnspecified" => Ok(ContentRatingMpaaRatingEnum::MpaaUnspecified), + "mpaaG" => Ok(ContentRatingMpaaRatingEnum::MpaaG), + "mpaaPg" => Ok(ContentRatingMpaaRatingEnum::MpaaPg), + "mpaaPg13" => Ok(ContentRatingMpaaRatingEnum::MpaaPg13), + "mpaaR" => Ok(ContentRatingMpaaRatingEnum::MpaaR), + "mpaaNc17" => Ok(ContentRatingMpaaRatingEnum::MpaaNc17), + "mpaaX" => Ok(ContentRatingMpaaRatingEnum::MpaaX), + "mpaaUnrated" => Ok(ContentRatingMpaaRatingEnum::MpaaUnrated), + _=> Err(()), + } + } +} + +impl<'a> Into> for &'a ContentRatingMpaaRatingEnum { + fn into(self) -> std::borrow::Cow<'a, str> { + self.as_ref().into() + } +} + + +#[derive(Clone, Copy, Eq, Hash, Debug, PartialEq, Serialize, Deserialize)] +/// The rating system for trailer, DVD, and Ad in the US. See http://movielabs.com/md/ratings/v2.3/html/US_MPAAT_Ratings.html. +pub enum ContentRatingMpaatRatingEnum { + + /// "mpaatUnspecified" + #[serde(rename="mpaatUnspecified")] + MpaatUnspecified, + + + /// GB + /// + /// "mpaatGb" + #[serde(rename="mpaatGb")] + MpaatGb, + + + /// RB + /// + /// "mpaatRb" + #[serde(rename="mpaatRb")] + MpaatRb, +} + +impl AsRef for ContentRatingMpaatRatingEnum { + fn as_ref(&self) -> &str { + match *self { + ContentRatingMpaatRatingEnum::MpaatUnspecified => "mpaatUnspecified", + ContentRatingMpaatRatingEnum::MpaatGb => "mpaatGb", + ContentRatingMpaatRatingEnum::MpaatRb => "mpaatRb", + } + } +} + +impl std::convert::TryFrom< &str> for ContentRatingMpaatRatingEnum { + type Error = (); + fn try_from(value: &str) -> Result { + match value { + "mpaatUnspecified" => Ok(ContentRatingMpaatRatingEnum::MpaatUnspecified), + "mpaatGb" => Ok(ContentRatingMpaatRatingEnum::MpaatGb), + "mpaatRb" => Ok(ContentRatingMpaatRatingEnum::MpaatRb), + _=> Err(()), + } + } +} + +impl<'a> Into> for &'a ContentRatingMpaatRatingEnum { + fn into(self) -> std::borrow::Cow<'a, str> { + self.as_ref().into() + } +} + + +#[derive(Clone, Copy, Eq, Hash, Debug, PartialEq, Serialize, Deserialize)] +/// The video's rating from the Movie and Television Review and Classification Board (Philippines). +pub enum ContentRatingMtrcbRatingEnum { + + /// "mtrcbUnspecified" + #[serde(rename="mtrcbUnspecified")] + MtrcbUnspecified, + + + /// G + /// + /// "mtrcbG" + #[serde(rename="mtrcbG")] + MtrcbG, + + + /// PG + /// + /// "mtrcbPg" + #[serde(rename="mtrcbPg")] + MtrcbPg, + + + /// R-13 + /// + /// "mtrcbR13" + #[serde(rename="mtrcbR13")] + MtrcbR13, + + + /// R-16 + /// + /// "mtrcbR16" + #[serde(rename="mtrcbR16")] + MtrcbR16, + + + /// R-18 + /// + /// "mtrcbR18" + #[serde(rename="mtrcbR18")] + MtrcbR18, + + + /// X + /// + /// "mtrcbX" + #[serde(rename="mtrcbX")] + MtrcbX, + + /// "mtrcbUnrated" + #[serde(rename="mtrcbUnrated")] + MtrcbUnrated, +} + +impl AsRef for ContentRatingMtrcbRatingEnum { + fn as_ref(&self) -> &str { + match *self { + ContentRatingMtrcbRatingEnum::MtrcbUnspecified => "mtrcbUnspecified", + ContentRatingMtrcbRatingEnum::MtrcbG => "mtrcbG", + ContentRatingMtrcbRatingEnum::MtrcbPg => "mtrcbPg", + ContentRatingMtrcbRatingEnum::MtrcbR13 => "mtrcbR13", + ContentRatingMtrcbRatingEnum::MtrcbR16 => "mtrcbR16", + ContentRatingMtrcbRatingEnum::MtrcbR18 => "mtrcbR18", + ContentRatingMtrcbRatingEnum::MtrcbX => "mtrcbX", + ContentRatingMtrcbRatingEnum::MtrcbUnrated => "mtrcbUnrated", + } + } +} + +impl std::convert::TryFrom< &str> for ContentRatingMtrcbRatingEnum { + type Error = (); + fn try_from(value: &str) -> Result { + match value { + "mtrcbUnspecified" => Ok(ContentRatingMtrcbRatingEnum::MtrcbUnspecified), + "mtrcbG" => Ok(ContentRatingMtrcbRatingEnum::MtrcbG), + "mtrcbPg" => Ok(ContentRatingMtrcbRatingEnum::MtrcbPg), + "mtrcbR13" => Ok(ContentRatingMtrcbRatingEnum::MtrcbR13), + "mtrcbR16" => Ok(ContentRatingMtrcbRatingEnum::MtrcbR16), + "mtrcbR18" => Ok(ContentRatingMtrcbRatingEnum::MtrcbR18), + "mtrcbX" => Ok(ContentRatingMtrcbRatingEnum::MtrcbX), + "mtrcbUnrated" => Ok(ContentRatingMtrcbRatingEnum::MtrcbUnrated), + _=> Err(()), + } + } +} + +impl<'a> Into> for &'a ContentRatingMtrcbRatingEnum { + fn into(self) -> std::borrow::Cow<'a, str> { + self.as_ref().into() + } +} + + +#[derive(Clone, Copy, Eq, Hash, Debug, PartialEq, Serialize, Deserialize)] +/// The video's rating from the Maldives National Bureau of Classification. +pub enum ContentRatingNbcRatingEnum { + + /// "nbcUnspecified" + #[serde(rename="nbcUnspecified")] + NbcUnspecified, + + + /// G + /// + /// "nbcG" + #[serde(rename="nbcG")] + NbcG, + + + /// PG + /// + /// "nbcPg" + #[serde(rename="nbcPg")] + NbcPg, + + + /// 12+ + /// + /// "nbc12plus" + #[serde(rename="nbc12plus")] + Nbc12plus, + + + /// 15+ + /// + /// "nbc15plus" + #[serde(rename="nbc15plus")] + Nbc15plus, + + + /// 18+ + /// + /// "nbc18plus" + #[serde(rename="nbc18plus")] + Nbc18plus, + + + /// 18+R + /// + /// "nbc18plusr" + #[serde(rename="nbc18plusr")] + Nbc18plusr, + + + /// PU + /// + /// "nbcPu" + #[serde(rename="nbcPu")] + NbcPu, + + /// "nbcUnrated" + #[serde(rename="nbcUnrated")] + NbcUnrated, +} + +impl AsRef for ContentRatingNbcRatingEnum { + fn as_ref(&self) -> &str { + match *self { + ContentRatingNbcRatingEnum::NbcUnspecified => "nbcUnspecified", + ContentRatingNbcRatingEnum::NbcG => "nbcG", + ContentRatingNbcRatingEnum::NbcPg => "nbcPg", + ContentRatingNbcRatingEnum::Nbc12plus => "nbc12plus", + ContentRatingNbcRatingEnum::Nbc15plus => "nbc15plus", + ContentRatingNbcRatingEnum::Nbc18plus => "nbc18plus", + ContentRatingNbcRatingEnum::Nbc18plusr => "nbc18plusr", + ContentRatingNbcRatingEnum::NbcPu => "nbcPu", + ContentRatingNbcRatingEnum::NbcUnrated => "nbcUnrated", + } + } +} + +impl std::convert::TryFrom< &str> for ContentRatingNbcRatingEnum { + type Error = (); + fn try_from(value: &str) -> Result { + match value { + "nbcUnspecified" => Ok(ContentRatingNbcRatingEnum::NbcUnspecified), + "nbcG" => Ok(ContentRatingNbcRatingEnum::NbcG), + "nbcPg" => Ok(ContentRatingNbcRatingEnum::NbcPg), + "nbc12plus" => Ok(ContentRatingNbcRatingEnum::Nbc12plus), + "nbc15plus" => Ok(ContentRatingNbcRatingEnum::Nbc15plus), + "nbc18plus" => Ok(ContentRatingNbcRatingEnum::Nbc18plus), + "nbc18plusr" => Ok(ContentRatingNbcRatingEnum::Nbc18plusr), + "nbcPu" => Ok(ContentRatingNbcRatingEnum::NbcPu), + "nbcUnrated" => Ok(ContentRatingNbcRatingEnum::NbcUnrated), + _=> Err(()), + } + } +} + +impl<'a> Into> for &'a ContentRatingNbcRatingEnum { + fn into(self) -> std::borrow::Cow<'a, str> { + self.as_ref().into() + } +} + + +#[derive(Clone, Copy, Eq, Hash, Debug, PartialEq, Serialize, Deserialize)] +/// The video's rating in Poland. +pub enum ContentRatingNbcplRatingEnum { + + /// "nbcplUnspecified" + #[serde(rename="nbcplUnspecified")] + NbcplUnspecified, + + /// "nbcplI" + #[serde(rename="nbcplI")] + NbcplI, + + /// "nbcplIi" + #[serde(rename="nbcplIi")] + NbcplIi, + + /// "nbcplIii" + #[serde(rename="nbcplIii")] + NbcplIii, + + /// "nbcplIv" + #[serde(rename="nbcplIv")] + NbcplIv, + + /// "nbcpl18plus" + #[serde(rename="nbcpl18plus")] + Nbcpl18plus, + + /// "nbcplUnrated" + #[serde(rename="nbcplUnrated")] + NbcplUnrated, +} + +impl AsRef for ContentRatingNbcplRatingEnum { + fn as_ref(&self) -> &str { + match *self { + ContentRatingNbcplRatingEnum::NbcplUnspecified => "nbcplUnspecified", + ContentRatingNbcplRatingEnum::NbcplI => "nbcplI", + ContentRatingNbcplRatingEnum::NbcplIi => "nbcplIi", + ContentRatingNbcplRatingEnum::NbcplIii => "nbcplIii", + ContentRatingNbcplRatingEnum::NbcplIv => "nbcplIv", + ContentRatingNbcplRatingEnum::Nbcpl18plus => "nbcpl18plus", + ContentRatingNbcplRatingEnum::NbcplUnrated => "nbcplUnrated", + } + } +} + +impl std::convert::TryFrom< &str> for ContentRatingNbcplRatingEnum { + type Error = (); + fn try_from(value: &str) -> Result { + match value { + "nbcplUnspecified" => Ok(ContentRatingNbcplRatingEnum::NbcplUnspecified), + "nbcplI" => Ok(ContentRatingNbcplRatingEnum::NbcplI), + "nbcplIi" => Ok(ContentRatingNbcplRatingEnum::NbcplIi), + "nbcplIii" => Ok(ContentRatingNbcplRatingEnum::NbcplIii), + "nbcplIv" => Ok(ContentRatingNbcplRatingEnum::NbcplIv), + "nbcpl18plus" => Ok(ContentRatingNbcplRatingEnum::Nbcpl18plus), + "nbcplUnrated" => Ok(ContentRatingNbcplRatingEnum::NbcplUnrated), + _=> Err(()), + } + } +} + +impl<'a> Into> for &'a ContentRatingNbcplRatingEnum { + fn into(self) -> std::borrow::Cow<'a, str> { + self.as_ref().into() + } +} + + +#[derive(Clone, Copy, Eq, Hash, Debug, PartialEq, Serialize, Deserialize)] +/// The video's rating from the Bulgarian National Film Center. +pub enum ContentRatingNfrcRatingEnum { + + /// "nfrcUnspecified" + #[serde(rename="nfrcUnspecified")] + NfrcUnspecified, + + + /// A + /// + /// "nfrcA" + #[serde(rename="nfrcA")] + NfrcA, + + + /// B + /// + /// "nfrcB" + #[serde(rename="nfrcB")] + NfrcB, + + + /// C + /// + /// "nfrcC" + #[serde(rename="nfrcC")] + NfrcC, + + + /// D + /// + /// "nfrcD" + #[serde(rename="nfrcD")] + NfrcD, + + + /// X + /// + /// "nfrcX" + #[serde(rename="nfrcX")] + NfrcX, + + /// "nfrcUnrated" + #[serde(rename="nfrcUnrated")] + NfrcUnrated, +} + +impl AsRef for ContentRatingNfrcRatingEnum { + fn as_ref(&self) -> &str { + match *self { + ContentRatingNfrcRatingEnum::NfrcUnspecified => "nfrcUnspecified", + ContentRatingNfrcRatingEnum::NfrcA => "nfrcA", + ContentRatingNfrcRatingEnum::NfrcB => "nfrcB", + ContentRatingNfrcRatingEnum::NfrcC => "nfrcC", + ContentRatingNfrcRatingEnum::NfrcD => "nfrcD", + ContentRatingNfrcRatingEnum::NfrcX => "nfrcX", + ContentRatingNfrcRatingEnum::NfrcUnrated => "nfrcUnrated", + } + } +} + +impl std::convert::TryFrom< &str> for ContentRatingNfrcRatingEnum { + type Error = (); + fn try_from(value: &str) -> Result { + match value { + "nfrcUnspecified" => Ok(ContentRatingNfrcRatingEnum::NfrcUnspecified), + "nfrcA" => Ok(ContentRatingNfrcRatingEnum::NfrcA), + "nfrcB" => Ok(ContentRatingNfrcRatingEnum::NfrcB), + "nfrcC" => Ok(ContentRatingNfrcRatingEnum::NfrcC), + "nfrcD" => Ok(ContentRatingNfrcRatingEnum::NfrcD), + "nfrcX" => Ok(ContentRatingNfrcRatingEnum::NfrcX), + "nfrcUnrated" => Ok(ContentRatingNfrcRatingEnum::NfrcUnrated), + _=> Err(()), + } + } +} + +impl<'a> Into> for &'a ContentRatingNfrcRatingEnum { + fn into(self) -> std::borrow::Cow<'a, str> { + self.as_ref().into() + } +} + + +#[derive(Clone, Copy, Eq, Hash, Debug, PartialEq, Serialize, Deserialize)] +/// The video's rating from Nigeria's National Film and Video Censors Board. +pub enum ContentRatingNfvcbRatingEnum { + + /// "nfvcbUnspecified" + #[serde(rename="nfvcbUnspecified")] + NfvcbUnspecified, + + + /// G + /// + /// "nfvcbG" + #[serde(rename="nfvcbG")] + NfvcbG, + + + /// PG + /// + /// "nfvcbPg" + #[serde(rename="nfvcbPg")] + NfvcbPg, + + + /// 12 + /// + /// "nfvcb12" + #[serde(rename="nfvcb12")] + Nfvcb12, + + + /// 12A + /// + /// "nfvcb12a" + #[serde(rename="nfvcb12a")] + Nfvcb12a, + + + /// 15 + /// + /// "nfvcb15" + #[serde(rename="nfvcb15")] + Nfvcb15, + + + /// 18 + /// + /// "nfvcb18" + #[serde(rename="nfvcb18")] + Nfvcb18, + + + /// RE + /// + /// "nfvcbRe" + #[serde(rename="nfvcbRe")] + NfvcbRe, + + /// "nfvcbUnrated" + #[serde(rename="nfvcbUnrated")] + NfvcbUnrated, +} + +impl AsRef for ContentRatingNfvcbRatingEnum { + fn as_ref(&self) -> &str { + match *self { + ContentRatingNfvcbRatingEnum::NfvcbUnspecified => "nfvcbUnspecified", + ContentRatingNfvcbRatingEnum::NfvcbG => "nfvcbG", + ContentRatingNfvcbRatingEnum::NfvcbPg => "nfvcbPg", + ContentRatingNfvcbRatingEnum::Nfvcb12 => "nfvcb12", + ContentRatingNfvcbRatingEnum::Nfvcb12a => "nfvcb12a", + ContentRatingNfvcbRatingEnum::Nfvcb15 => "nfvcb15", + ContentRatingNfvcbRatingEnum::Nfvcb18 => "nfvcb18", + ContentRatingNfvcbRatingEnum::NfvcbRe => "nfvcbRe", + ContentRatingNfvcbRatingEnum::NfvcbUnrated => "nfvcbUnrated", + } + } +} + +impl std::convert::TryFrom< &str> for ContentRatingNfvcbRatingEnum { + type Error = (); + fn try_from(value: &str) -> Result { + match value { + "nfvcbUnspecified" => Ok(ContentRatingNfvcbRatingEnum::NfvcbUnspecified), + "nfvcbG" => Ok(ContentRatingNfvcbRatingEnum::NfvcbG), + "nfvcbPg" => Ok(ContentRatingNfvcbRatingEnum::NfvcbPg), + "nfvcb12" => Ok(ContentRatingNfvcbRatingEnum::Nfvcb12), + "nfvcb12a" => Ok(ContentRatingNfvcbRatingEnum::Nfvcb12a), + "nfvcb15" => Ok(ContentRatingNfvcbRatingEnum::Nfvcb15), + "nfvcb18" => Ok(ContentRatingNfvcbRatingEnum::Nfvcb18), + "nfvcbRe" => Ok(ContentRatingNfvcbRatingEnum::NfvcbRe), + "nfvcbUnrated" => Ok(ContentRatingNfvcbRatingEnum::NfvcbUnrated), + _=> Err(()), + } + } +} + +impl<'a> Into> for &'a ContentRatingNfvcbRatingEnum { + fn into(self) -> std::borrow::Cow<'a, str> { + self.as_ref().into() + } +} + + +#[derive(Clone, Copy, Eq, Hash, Debug, PartialEq, Serialize, Deserialize)] +/// The video's rating from the Nacionãlais Kino centrs (National Film Centre of Latvia). +pub enum ContentRatingNkclvRatingEnum { + + /// "nkclvUnspecified" + #[serde(rename="nkclvUnspecified")] + NkclvUnspecified, + + + /// U + /// + /// "nkclvU" + #[serde(rename="nkclvU")] + NkclvU, + + + /// 7+ + /// + /// "nkclv7plus" + #[serde(rename="nkclv7plus")] + Nkclv7plus, + + + /// 12+ + /// + /// "nkclv12plus" + #[serde(rename="nkclv12plus")] + Nkclv12plus, + + + /// ! 16+ + /// + /// "nkclv16plus" + #[serde(rename="nkclv16plus")] + Nkclv16plus, + + + /// 18+ + /// + /// "nkclv18plus" + #[serde(rename="nkclv18plus")] + Nkclv18plus, + + /// "nkclvUnrated" + #[serde(rename="nkclvUnrated")] + NkclvUnrated, +} + +impl AsRef for ContentRatingNkclvRatingEnum { + fn as_ref(&self) -> &str { + match *self { + ContentRatingNkclvRatingEnum::NkclvUnspecified => "nkclvUnspecified", + ContentRatingNkclvRatingEnum::NkclvU => "nkclvU", + ContentRatingNkclvRatingEnum::Nkclv7plus => "nkclv7plus", + ContentRatingNkclvRatingEnum::Nkclv12plus => "nkclv12plus", + ContentRatingNkclvRatingEnum::Nkclv16plus => "nkclv16plus", + ContentRatingNkclvRatingEnum::Nkclv18plus => "nkclv18plus", + ContentRatingNkclvRatingEnum::NkclvUnrated => "nkclvUnrated", + } + } +} + +impl std::convert::TryFrom< &str> for ContentRatingNkclvRatingEnum { + type Error = (); + fn try_from(value: &str) -> Result { + match value { + "nkclvUnspecified" => Ok(ContentRatingNkclvRatingEnum::NkclvUnspecified), + "nkclvU" => Ok(ContentRatingNkclvRatingEnum::NkclvU), + "nkclv7plus" => Ok(ContentRatingNkclvRatingEnum::Nkclv7plus), + "nkclv12plus" => Ok(ContentRatingNkclvRatingEnum::Nkclv12plus), + "nkclv16plus" => Ok(ContentRatingNkclvRatingEnum::Nkclv16plus), + "nkclv18plus" => Ok(ContentRatingNkclvRatingEnum::Nkclv18plus), + "nkclvUnrated" => Ok(ContentRatingNkclvRatingEnum::NkclvUnrated), + _=> Err(()), + } + } +} + +impl<'a> Into> for &'a ContentRatingNkclvRatingEnum { + fn into(self) -> std::borrow::Cow<'a, str> { + self.as_ref().into() + } +} + + +#[derive(Clone, Copy, Eq, Hash, Debug, PartialEq, Serialize, Deserialize)] +/// The National Media Council ratings system for United Arab Emirates. +pub enum ContentRatingNmcRatingEnum { + + /// "nmcUnspecified" + #[serde(rename="nmcUnspecified")] + NmcUnspecified, + + + /// G + /// + /// "nmcG" + #[serde(rename="nmcG")] + NmcG, + + + /// PG + /// + /// "nmcPg" + #[serde(rename="nmcPg")] + NmcPg, + + + /// PG-13 + /// + /// "nmcPg13" + #[serde(rename="nmcPg13")] + NmcPg13, + + + /// PG-15 + /// + /// "nmcPg15" + #[serde(rename="nmcPg15")] + NmcPg15, + + + /// 15+ + /// + /// "nmc15plus" + #[serde(rename="nmc15plus")] + Nmc15plus, + + + /// 18+ + /// + /// "nmc18plus" + #[serde(rename="nmc18plus")] + Nmc18plus, + + + /// 18TC + /// + /// "nmc18tc" + #[serde(rename="nmc18tc")] + Nmc18tc, + + /// "nmcUnrated" + #[serde(rename="nmcUnrated")] + NmcUnrated, +} + +impl AsRef for ContentRatingNmcRatingEnum { + fn as_ref(&self) -> &str { + match *self { + ContentRatingNmcRatingEnum::NmcUnspecified => "nmcUnspecified", + ContentRatingNmcRatingEnum::NmcG => "nmcG", + ContentRatingNmcRatingEnum::NmcPg => "nmcPg", + ContentRatingNmcRatingEnum::NmcPg13 => "nmcPg13", + ContentRatingNmcRatingEnum::NmcPg15 => "nmcPg15", + ContentRatingNmcRatingEnum::Nmc15plus => "nmc15plus", + ContentRatingNmcRatingEnum::Nmc18plus => "nmc18plus", + ContentRatingNmcRatingEnum::Nmc18tc => "nmc18tc", + ContentRatingNmcRatingEnum::NmcUnrated => "nmcUnrated", + } + } +} + +impl std::convert::TryFrom< &str> for ContentRatingNmcRatingEnum { + type Error = (); + fn try_from(value: &str) -> Result { + match value { + "nmcUnspecified" => Ok(ContentRatingNmcRatingEnum::NmcUnspecified), + "nmcG" => Ok(ContentRatingNmcRatingEnum::NmcG), + "nmcPg" => Ok(ContentRatingNmcRatingEnum::NmcPg), + "nmcPg13" => Ok(ContentRatingNmcRatingEnum::NmcPg13), + "nmcPg15" => Ok(ContentRatingNmcRatingEnum::NmcPg15), + "nmc15plus" => Ok(ContentRatingNmcRatingEnum::Nmc15plus), + "nmc18plus" => Ok(ContentRatingNmcRatingEnum::Nmc18plus), + "nmc18tc" => Ok(ContentRatingNmcRatingEnum::Nmc18tc), + "nmcUnrated" => Ok(ContentRatingNmcRatingEnum::NmcUnrated), + _=> Err(()), + } + } +} + +impl<'a> Into> for &'a ContentRatingNmcRatingEnum { + fn into(self) -> std::borrow::Cow<'a, str> { + self.as_ref().into() + } +} + + +#[derive(Clone, Copy, Eq, Hash, Debug, PartialEq, Serialize, Deserialize)] +/// The video's Office of Film and Literature Classification (OFLC - New Zealand) rating. +pub enum ContentRatingOflcRatingEnum { + + /// "oflcUnspecified" + #[serde(rename="oflcUnspecified")] + OflcUnspecified, + + + /// G + /// + /// "oflcG" + #[serde(rename="oflcG")] + OflcG, + + + /// PG + /// + /// "oflcPg" + #[serde(rename="oflcPg")] + OflcPg, + + + /// M + /// + /// "oflcM" + #[serde(rename="oflcM")] + OflcM, + + + /// R13 + /// + /// "oflcR13" + #[serde(rename="oflcR13")] + OflcR13, + + + /// R15 + /// + /// "oflcR15" + #[serde(rename="oflcR15")] + OflcR15, + + + /// R16 + /// + /// "oflcR16" + #[serde(rename="oflcR16")] + OflcR16, + + + /// R18 + /// + /// "oflcR18" + #[serde(rename="oflcR18")] + OflcR18, + + /// "oflcUnrated" + #[serde(rename="oflcUnrated")] + OflcUnrated, + + + /// RP13 + /// + /// "oflcRp13" + #[serde(rename="oflcRp13")] + OflcRp13, + + + /// RP16 + /// + /// "oflcRp16" + #[serde(rename="oflcRp16")] + OflcRp16, + + + /// RP18 + /// + /// "oflcRp18" + #[serde(rename="oflcRp18")] + OflcRp18, +} + +impl AsRef for ContentRatingOflcRatingEnum { + fn as_ref(&self) -> &str { + match *self { + ContentRatingOflcRatingEnum::OflcUnspecified => "oflcUnspecified", + ContentRatingOflcRatingEnum::OflcG => "oflcG", + ContentRatingOflcRatingEnum::OflcPg => "oflcPg", + ContentRatingOflcRatingEnum::OflcM => "oflcM", + ContentRatingOflcRatingEnum::OflcR13 => "oflcR13", + ContentRatingOflcRatingEnum::OflcR15 => "oflcR15", + ContentRatingOflcRatingEnum::OflcR16 => "oflcR16", + ContentRatingOflcRatingEnum::OflcR18 => "oflcR18", + ContentRatingOflcRatingEnum::OflcUnrated => "oflcUnrated", + ContentRatingOflcRatingEnum::OflcRp13 => "oflcRp13", + ContentRatingOflcRatingEnum::OflcRp16 => "oflcRp16", + ContentRatingOflcRatingEnum::OflcRp18 => "oflcRp18", + } + } +} + +impl std::convert::TryFrom< &str> for ContentRatingOflcRatingEnum { + type Error = (); + fn try_from(value: &str) -> Result { + match value { + "oflcUnspecified" => Ok(ContentRatingOflcRatingEnum::OflcUnspecified), + "oflcG" => Ok(ContentRatingOflcRatingEnum::OflcG), + "oflcPg" => Ok(ContentRatingOflcRatingEnum::OflcPg), + "oflcM" => Ok(ContentRatingOflcRatingEnum::OflcM), + "oflcR13" => Ok(ContentRatingOflcRatingEnum::OflcR13), + "oflcR15" => Ok(ContentRatingOflcRatingEnum::OflcR15), + "oflcR16" => Ok(ContentRatingOflcRatingEnum::OflcR16), + "oflcR18" => Ok(ContentRatingOflcRatingEnum::OflcR18), + "oflcUnrated" => Ok(ContentRatingOflcRatingEnum::OflcUnrated), + "oflcRp13" => Ok(ContentRatingOflcRatingEnum::OflcRp13), + "oflcRp16" => Ok(ContentRatingOflcRatingEnum::OflcRp16), + "oflcRp18" => Ok(ContentRatingOflcRatingEnum::OflcRp18), + _=> Err(()), + } + } +} + +impl<'a> Into> for &'a ContentRatingOflcRatingEnum { + fn into(self) -> std::borrow::Cow<'a, str> { + self.as_ref().into() + } +} + + +#[derive(Clone, Copy, Eq, Hash, Debug, PartialEq, Serialize, Deserialize)] +/// The video's rating in Peru. +pub enum ContentRatingPefilmRatingEnum { + + /// "pefilmUnspecified" + #[serde(rename="pefilmUnspecified")] + PefilmUnspecified, + + + /// PT + /// + /// "pefilmPt" + #[serde(rename="pefilmPt")] + PefilmPt, + + + /// PG + /// + /// "pefilmPg" + #[serde(rename="pefilmPg")] + PefilmPg, + + + /// 14 + /// + /// "pefilm14" + #[serde(rename="pefilm14")] + Pefilm14, + + + /// 18 + /// + /// "pefilm18" + #[serde(rename="pefilm18")] + Pefilm18, + + /// "pefilmUnrated" + #[serde(rename="pefilmUnrated")] + PefilmUnrated, +} + +impl AsRef for ContentRatingPefilmRatingEnum { + fn as_ref(&self) -> &str { + match *self { + ContentRatingPefilmRatingEnum::PefilmUnspecified => "pefilmUnspecified", + ContentRatingPefilmRatingEnum::PefilmPt => "pefilmPt", + ContentRatingPefilmRatingEnum::PefilmPg => "pefilmPg", + ContentRatingPefilmRatingEnum::Pefilm14 => "pefilm14", + ContentRatingPefilmRatingEnum::Pefilm18 => "pefilm18", + ContentRatingPefilmRatingEnum::PefilmUnrated => "pefilmUnrated", + } + } +} + +impl std::convert::TryFrom< &str> for ContentRatingPefilmRatingEnum { + type Error = (); + fn try_from(value: &str) -> Result { + match value { + "pefilmUnspecified" => Ok(ContentRatingPefilmRatingEnum::PefilmUnspecified), + "pefilmPt" => Ok(ContentRatingPefilmRatingEnum::PefilmPt), + "pefilmPg" => Ok(ContentRatingPefilmRatingEnum::PefilmPg), + "pefilm14" => Ok(ContentRatingPefilmRatingEnum::Pefilm14), + "pefilm18" => Ok(ContentRatingPefilmRatingEnum::Pefilm18), + "pefilmUnrated" => Ok(ContentRatingPefilmRatingEnum::PefilmUnrated), + _=> Err(()), + } + } +} + +impl<'a> Into> for &'a ContentRatingPefilmRatingEnum { + fn into(self) -> std::borrow::Cow<'a, str> { + self.as_ref().into() + } +} + + +#[derive(Clone, Copy, Eq, Hash, Debug, PartialEq, Serialize, Deserialize)] +/// The video's rating from the Hungarian Nemzeti Filmiroda, the Rating Committee of the National Office of Film. +pub enum ContentRatingRcnofRatingEnum { + + /// "rcnofUnspecified" + #[serde(rename="rcnofUnspecified")] + RcnofUnspecified, + + /// "rcnofI" + #[serde(rename="rcnofI")] + RcnofI, + + /// "rcnofIi" + #[serde(rename="rcnofIi")] + RcnofIi, + + /// "rcnofIii" + #[serde(rename="rcnofIii")] + RcnofIii, + + /// "rcnofIv" + #[serde(rename="rcnofIv")] + RcnofIv, + + /// "rcnofV" + #[serde(rename="rcnofV")] + RcnofV, + + /// "rcnofVi" + #[serde(rename="rcnofVi")] + RcnofVi, + + /// "rcnofUnrated" + #[serde(rename="rcnofUnrated")] + RcnofUnrated, +} + +impl AsRef for ContentRatingRcnofRatingEnum { + fn as_ref(&self) -> &str { + match *self { + ContentRatingRcnofRatingEnum::RcnofUnspecified => "rcnofUnspecified", + ContentRatingRcnofRatingEnum::RcnofI => "rcnofI", + ContentRatingRcnofRatingEnum::RcnofIi => "rcnofIi", + ContentRatingRcnofRatingEnum::RcnofIii => "rcnofIii", + ContentRatingRcnofRatingEnum::RcnofIv => "rcnofIv", + ContentRatingRcnofRatingEnum::RcnofV => "rcnofV", + ContentRatingRcnofRatingEnum::RcnofVi => "rcnofVi", + ContentRatingRcnofRatingEnum::RcnofUnrated => "rcnofUnrated", + } + } +} + +impl std::convert::TryFrom< &str> for ContentRatingRcnofRatingEnum { + type Error = (); + fn try_from(value: &str) -> Result { + match value { + "rcnofUnspecified" => Ok(ContentRatingRcnofRatingEnum::RcnofUnspecified), + "rcnofI" => Ok(ContentRatingRcnofRatingEnum::RcnofI), + "rcnofIi" => Ok(ContentRatingRcnofRatingEnum::RcnofIi), + "rcnofIii" => Ok(ContentRatingRcnofRatingEnum::RcnofIii), + "rcnofIv" => Ok(ContentRatingRcnofRatingEnum::RcnofIv), + "rcnofV" => Ok(ContentRatingRcnofRatingEnum::RcnofV), + "rcnofVi" => Ok(ContentRatingRcnofRatingEnum::RcnofVi), + "rcnofUnrated" => Ok(ContentRatingRcnofRatingEnum::RcnofUnrated), + _=> Err(()), + } + } +} + +impl<'a> Into> for &'a ContentRatingRcnofRatingEnum { + fn into(self) -> std::borrow::Cow<'a, str> { + self.as_ref().into() + } +} + + +#[derive(Clone, Copy, Eq, Hash, Debug, PartialEq, Serialize, Deserialize)] +/// The video's rating in Venezuela. +pub enum ContentRatingResorteviolenciaRatingEnum { + + /// "resorteviolenciaUnspecified" + #[serde(rename="resorteviolenciaUnspecified")] + ResorteviolenciaUnspecified, + + + /// A + /// + /// "resorteviolenciaA" + #[serde(rename="resorteviolenciaA")] + ResorteviolenciaA, + + + /// B + /// + /// "resorteviolenciaB" + #[serde(rename="resorteviolenciaB")] + ResorteviolenciaB, + + + /// C + /// + /// "resorteviolenciaC" + #[serde(rename="resorteviolenciaC")] + ResorteviolenciaC, + + + /// D + /// + /// "resorteviolenciaD" + #[serde(rename="resorteviolenciaD")] + ResorteviolenciaD, + + + /// E + /// + /// "resorteviolenciaE" + #[serde(rename="resorteviolenciaE")] + ResorteviolenciaE, + + /// "resorteviolenciaUnrated" + #[serde(rename="resorteviolenciaUnrated")] + ResorteviolenciaUnrated, +} + +impl AsRef for ContentRatingResorteviolenciaRatingEnum { + fn as_ref(&self) -> &str { + match *self { + ContentRatingResorteviolenciaRatingEnum::ResorteviolenciaUnspecified => "resorteviolenciaUnspecified", + ContentRatingResorteviolenciaRatingEnum::ResorteviolenciaA => "resorteviolenciaA", + ContentRatingResorteviolenciaRatingEnum::ResorteviolenciaB => "resorteviolenciaB", + ContentRatingResorteviolenciaRatingEnum::ResorteviolenciaC => "resorteviolenciaC", + ContentRatingResorteviolenciaRatingEnum::ResorteviolenciaD => "resorteviolenciaD", + ContentRatingResorteviolenciaRatingEnum::ResorteviolenciaE => "resorteviolenciaE", + ContentRatingResorteviolenciaRatingEnum::ResorteviolenciaUnrated => "resorteviolenciaUnrated", + } + } +} + +impl std::convert::TryFrom< &str> for ContentRatingResorteviolenciaRatingEnum { + type Error = (); + fn try_from(value: &str) -> Result { + match value { + "resorteviolenciaUnspecified" => Ok(ContentRatingResorteviolenciaRatingEnum::ResorteviolenciaUnspecified), + "resorteviolenciaA" => Ok(ContentRatingResorteviolenciaRatingEnum::ResorteviolenciaA), + "resorteviolenciaB" => Ok(ContentRatingResorteviolenciaRatingEnum::ResorteviolenciaB), + "resorteviolenciaC" => Ok(ContentRatingResorteviolenciaRatingEnum::ResorteviolenciaC), + "resorteviolenciaD" => Ok(ContentRatingResorteviolenciaRatingEnum::ResorteviolenciaD), + "resorteviolenciaE" => Ok(ContentRatingResorteviolenciaRatingEnum::ResorteviolenciaE), + "resorteviolenciaUnrated" => Ok(ContentRatingResorteviolenciaRatingEnum::ResorteviolenciaUnrated), + _=> Err(()), + } + } +} + +impl<'a> Into> for &'a ContentRatingResorteviolenciaRatingEnum { + fn into(self) -> std::borrow::Cow<'a, str> { + self.as_ref().into() + } +} + + +#[derive(Clone, Copy, Eq, Hash, Debug, PartialEq, Serialize, Deserialize)] +/// The video's General Directorate of Radio, Television and Cinematography (Mexico) rating. +pub enum ContentRatingRtcRatingEnum { + + /// "rtcUnspecified" + #[serde(rename="rtcUnspecified")] + RtcUnspecified, + + + /// AA + /// + /// "rtcAa" + #[serde(rename="rtcAa")] + RtcAa, + + + /// A + /// + /// "rtcA" + #[serde(rename="rtcA")] + RtcA, + + + /// B + /// + /// "rtcB" + #[serde(rename="rtcB")] + RtcB, + + + /// B15 + /// + /// "rtcB15" + #[serde(rename="rtcB15")] + RtcB15, + + + /// C + /// + /// "rtcC" + #[serde(rename="rtcC")] + RtcC, + + + /// D + /// + /// "rtcD" + #[serde(rename="rtcD")] + RtcD, + + /// "rtcUnrated" + #[serde(rename="rtcUnrated")] + RtcUnrated, +} + +impl AsRef for ContentRatingRtcRatingEnum { + fn as_ref(&self) -> &str { + match *self { + ContentRatingRtcRatingEnum::RtcUnspecified => "rtcUnspecified", + ContentRatingRtcRatingEnum::RtcAa => "rtcAa", + ContentRatingRtcRatingEnum::RtcA => "rtcA", + ContentRatingRtcRatingEnum::RtcB => "rtcB", + ContentRatingRtcRatingEnum::RtcB15 => "rtcB15", + ContentRatingRtcRatingEnum::RtcC => "rtcC", + ContentRatingRtcRatingEnum::RtcD => "rtcD", + ContentRatingRtcRatingEnum::RtcUnrated => "rtcUnrated", + } + } +} + +impl std::convert::TryFrom< &str> for ContentRatingRtcRatingEnum { + type Error = (); + fn try_from(value: &str) -> Result { + match value { + "rtcUnspecified" => Ok(ContentRatingRtcRatingEnum::RtcUnspecified), + "rtcAa" => Ok(ContentRatingRtcRatingEnum::RtcAa), + "rtcA" => Ok(ContentRatingRtcRatingEnum::RtcA), + "rtcB" => Ok(ContentRatingRtcRatingEnum::RtcB), + "rtcB15" => Ok(ContentRatingRtcRatingEnum::RtcB15), + "rtcC" => Ok(ContentRatingRtcRatingEnum::RtcC), + "rtcD" => Ok(ContentRatingRtcRatingEnum::RtcD), + "rtcUnrated" => Ok(ContentRatingRtcRatingEnum::RtcUnrated), + _=> Err(()), + } + } +} + +impl<'a> Into> for &'a ContentRatingRtcRatingEnum { + fn into(self) -> std::borrow::Cow<'a, str> { + self.as_ref().into() + } +} + + +#[derive(Clone, Copy, Eq, Hash, Debug, PartialEq, Serialize, Deserialize)] +/// The video's rating from Ireland's Raidió Teilifís Éireann. +pub enum ContentRatingRteRatingEnum { + + /// "rteUnspecified" + #[serde(rename="rteUnspecified")] + RteUnspecified, + + + /// GA + /// + /// "rteGa" + #[serde(rename="rteGa")] + RteGa, + + + /// CH + /// + /// "rteCh" + #[serde(rename="rteCh")] + RteCh, + + + /// PS + /// + /// "rtePs" + #[serde(rename="rtePs")] + RtePs, + + + /// MA + /// + /// "rteMa" + #[serde(rename="rteMa")] + RteMa, + + /// "rteUnrated" + #[serde(rename="rteUnrated")] + RteUnrated, +} + +impl AsRef for ContentRatingRteRatingEnum { + fn as_ref(&self) -> &str { + match *self { + ContentRatingRteRatingEnum::RteUnspecified => "rteUnspecified", + ContentRatingRteRatingEnum::RteGa => "rteGa", + ContentRatingRteRatingEnum::RteCh => "rteCh", + ContentRatingRteRatingEnum::RtePs => "rtePs", + ContentRatingRteRatingEnum::RteMa => "rteMa", + ContentRatingRteRatingEnum::RteUnrated => "rteUnrated", + } + } +} + +impl std::convert::TryFrom< &str> for ContentRatingRteRatingEnum { + type Error = (); + fn try_from(value: &str) -> Result { + match value { + "rteUnspecified" => Ok(ContentRatingRteRatingEnum::RteUnspecified), + "rteGa" => Ok(ContentRatingRteRatingEnum::RteGa), + "rteCh" => Ok(ContentRatingRteRatingEnum::RteCh), + "rtePs" => Ok(ContentRatingRteRatingEnum::RtePs), + "rteMa" => Ok(ContentRatingRteRatingEnum::RteMa), + "rteUnrated" => Ok(ContentRatingRteRatingEnum::RteUnrated), + _=> Err(()), + } + } +} + +impl<'a> Into> for &'a ContentRatingRteRatingEnum { + fn into(self) -> std::borrow::Cow<'a, str> { + self.as_ref().into() + } +} + + +#[derive(Clone, Copy, Eq, Hash, Debug, PartialEq, Serialize, Deserialize)] +/// The video's National Film Registry of the Russian Federation (MKRF - Russia) rating. +pub enum ContentRatingRussiaRatingEnum { + + /// "russiaUnspecified" + #[serde(rename="russiaUnspecified")] + RussiaUnspecified, + + + /// 0+ + /// + /// "russia0" + #[serde(rename="russia0")] + Russia0, + + + /// 6+ + /// + /// "russia6" + #[serde(rename="russia6")] + Russia6, + + + /// 12+ + /// + /// "russia12" + #[serde(rename="russia12")] + Russia12, + + + /// 16+ + /// + /// "russia16" + #[serde(rename="russia16")] + Russia16, + + + /// 18+ + /// + /// "russia18" + #[serde(rename="russia18")] + Russia18, + + /// "russiaUnrated" + #[serde(rename="russiaUnrated")] + RussiaUnrated, +} + +impl AsRef for ContentRatingRussiaRatingEnum { + fn as_ref(&self) -> &str { + match *self { + ContentRatingRussiaRatingEnum::RussiaUnspecified => "russiaUnspecified", + ContentRatingRussiaRatingEnum::Russia0 => "russia0", + ContentRatingRussiaRatingEnum::Russia6 => "russia6", + ContentRatingRussiaRatingEnum::Russia12 => "russia12", + ContentRatingRussiaRatingEnum::Russia16 => "russia16", + ContentRatingRussiaRatingEnum::Russia18 => "russia18", + ContentRatingRussiaRatingEnum::RussiaUnrated => "russiaUnrated", + } + } +} + +impl std::convert::TryFrom< &str> for ContentRatingRussiaRatingEnum { + type Error = (); + fn try_from(value: &str) -> Result { + match value { + "russiaUnspecified" => Ok(ContentRatingRussiaRatingEnum::RussiaUnspecified), + "russia0" => Ok(ContentRatingRussiaRatingEnum::Russia0), + "russia6" => Ok(ContentRatingRussiaRatingEnum::Russia6), + "russia12" => Ok(ContentRatingRussiaRatingEnum::Russia12), + "russia16" => Ok(ContentRatingRussiaRatingEnum::Russia16), + "russia18" => Ok(ContentRatingRussiaRatingEnum::Russia18), + "russiaUnrated" => Ok(ContentRatingRussiaRatingEnum::RussiaUnrated), + _=> Err(()), + } + } +} + +impl<'a> Into> for &'a ContentRatingRussiaRatingEnum { + fn into(self) -> std::borrow::Cow<'a, str> { + self.as_ref().into() + } +} + + +#[derive(Clone, Copy, Eq, Hash, Debug, PartialEq, Serialize, Deserialize)] +/// The video's rating in Slovakia. +pub enum ContentRatingSkfilmRatingEnum { + + /// "skfilmUnspecified" + #[serde(rename="skfilmUnspecified")] + SkfilmUnspecified, + + + /// G + /// + /// "skfilmG" + #[serde(rename="skfilmG")] + SkfilmG, + + + /// P2 + /// + /// "skfilmP2" + #[serde(rename="skfilmP2")] + SkfilmP2, + + + /// P5 + /// + /// "skfilmP5" + #[serde(rename="skfilmP5")] + SkfilmP5, + + + /// P8 + /// + /// "skfilmP8" + #[serde(rename="skfilmP8")] + SkfilmP8, + + /// "skfilmUnrated" + #[serde(rename="skfilmUnrated")] + SkfilmUnrated, +} + +impl AsRef for ContentRatingSkfilmRatingEnum { + fn as_ref(&self) -> &str { + match *self { + ContentRatingSkfilmRatingEnum::SkfilmUnspecified => "skfilmUnspecified", + ContentRatingSkfilmRatingEnum::SkfilmG => "skfilmG", + ContentRatingSkfilmRatingEnum::SkfilmP2 => "skfilmP2", + ContentRatingSkfilmRatingEnum::SkfilmP5 => "skfilmP5", + ContentRatingSkfilmRatingEnum::SkfilmP8 => "skfilmP8", + ContentRatingSkfilmRatingEnum::SkfilmUnrated => "skfilmUnrated", + } + } +} + +impl std::convert::TryFrom< &str> for ContentRatingSkfilmRatingEnum { + type Error = (); + fn try_from(value: &str) -> Result { + match value { + "skfilmUnspecified" => Ok(ContentRatingSkfilmRatingEnum::SkfilmUnspecified), + "skfilmG" => Ok(ContentRatingSkfilmRatingEnum::SkfilmG), + "skfilmP2" => Ok(ContentRatingSkfilmRatingEnum::SkfilmP2), + "skfilmP5" => Ok(ContentRatingSkfilmRatingEnum::SkfilmP5), + "skfilmP8" => Ok(ContentRatingSkfilmRatingEnum::SkfilmP8), + "skfilmUnrated" => Ok(ContentRatingSkfilmRatingEnum::SkfilmUnrated), + _=> Err(()), + } + } +} + +impl<'a> Into> for &'a ContentRatingSkfilmRatingEnum { + fn into(self) -> std::borrow::Cow<'a, str> { + self.as_ref().into() + } +} + + +#[derive(Clone, Copy, Eq, Hash, Debug, PartialEq, Serialize, Deserialize)] +/// The video's rating in Iceland. +pub enum ContentRatingSmaisRatingEnum { + + /// "smaisUnspecified" + #[serde(rename="smaisUnspecified")] + SmaisUnspecified, + + + /// L + /// + /// "smaisL" + #[serde(rename="smaisL")] + SmaisL, + + + /// 7 + /// + /// "smais7" + #[serde(rename="smais7")] + Smais7, + + + /// 12 + /// + /// "smais12" + #[serde(rename="smais12")] + Smais12, + + + /// 14 + /// + /// "smais14" + #[serde(rename="smais14")] + Smais14, + + + /// 16 + /// + /// "smais16" + #[serde(rename="smais16")] + Smais16, + + + /// 18 + /// + /// "smais18" + #[serde(rename="smais18")] + Smais18, + + /// "smaisUnrated" + #[serde(rename="smaisUnrated")] + SmaisUnrated, +} + +impl AsRef for ContentRatingSmaisRatingEnum { + fn as_ref(&self) -> &str { + match *self { + ContentRatingSmaisRatingEnum::SmaisUnspecified => "smaisUnspecified", + ContentRatingSmaisRatingEnum::SmaisL => "smaisL", + ContentRatingSmaisRatingEnum::Smais7 => "smais7", + ContentRatingSmaisRatingEnum::Smais12 => "smais12", + ContentRatingSmaisRatingEnum::Smais14 => "smais14", + ContentRatingSmaisRatingEnum::Smais16 => "smais16", + ContentRatingSmaisRatingEnum::Smais18 => "smais18", + ContentRatingSmaisRatingEnum::SmaisUnrated => "smaisUnrated", + } + } +} + +impl std::convert::TryFrom< &str> for ContentRatingSmaisRatingEnum { + type Error = (); + fn try_from(value: &str) -> Result { + match value { + "smaisUnspecified" => Ok(ContentRatingSmaisRatingEnum::SmaisUnspecified), + "smaisL" => Ok(ContentRatingSmaisRatingEnum::SmaisL), + "smais7" => Ok(ContentRatingSmaisRatingEnum::Smais7), + "smais12" => Ok(ContentRatingSmaisRatingEnum::Smais12), + "smais14" => Ok(ContentRatingSmaisRatingEnum::Smais14), + "smais16" => Ok(ContentRatingSmaisRatingEnum::Smais16), + "smais18" => Ok(ContentRatingSmaisRatingEnum::Smais18), + "smaisUnrated" => Ok(ContentRatingSmaisRatingEnum::SmaisUnrated), + _=> Err(()), + } + } +} + +impl<'a> Into> for &'a ContentRatingSmaisRatingEnum { + fn into(self) -> std::borrow::Cow<'a, str> { + self.as_ref().into() + } +} + + +#[derive(Clone, Copy, Eq, Hash, Debug, PartialEq, Serialize, Deserialize)] +/// The video's rating from Statens medieråd (Sweden's National Media Council). +pub enum ContentRatingSmsaRatingEnum { + + /// "smsaUnspecified" + #[serde(rename="smsaUnspecified")] + SmsaUnspecified, + + + /// All ages + /// + /// "smsaA" + #[serde(rename="smsaA")] + SmsaA, + + + /// 7 + /// + /// "smsa7" + #[serde(rename="smsa7")] + Smsa7, + + + /// 11 + /// + /// "smsa11" + #[serde(rename="smsa11")] + Smsa11, + + + /// 15 + /// + /// "smsa15" + #[serde(rename="smsa15")] + Smsa15, + + /// "smsaUnrated" + #[serde(rename="smsaUnrated")] + SmsaUnrated, +} + +impl AsRef for ContentRatingSmsaRatingEnum { + fn as_ref(&self) -> &str { + match *self { + ContentRatingSmsaRatingEnum::SmsaUnspecified => "smsaUnspecified", + ContentRatingSmsaRatingEnum::SmsaA => "smsaA", + ContentRatingSmsaRatingEnum::Smsa7 => "smsa7", + ContentRatingSmsaRatingEnum::Smsa11 => "smsa11", + ContentRatingSmsaRatingEnum::Smsa15 => "smsa15", + ContentRatingSmsaRatingEnum::SmsaUnrated => "smsaUnrated", + } + } +} + +impl std::convert::TryFrom< &str> for ContentRatingSmsaRatingEnum { + type Error = (); + fn try_from(value: &str) -> Result { + match value { + "smsaUnspecified" => Ok(ContentRatingSmsaRatingEnum::SmsaUnspecified), + "smsaA" => Ok(ContentRatingSmsaRatingEnum::SmsaA), + "smsa7" => Ok(ContentRatingSmsaRatingEnum::Smsa7), + "smsa11" => Ok(ContentRatingSmsaRatingEnum::Smsa11), + "smsa15" => Ok(ContentRatingSmsaRatingEnum::Smsa15), + "smsaUnrated" => Ok(ContentRatingSmsaRatingEnum::SmsaUnrated), + _=> Err(()), + } + } +} + +impl<'a> Into> for &'a ContentRatingSmsaRatingEnum { + fn into(self) -> std::borrow::Cow<'a, str> { + self.as_ref().into() + } +} + + +#[derive(Clone, Copy, Eq, Hash, Debug, PartialEq, Serialize, Deserialize)] +/// The video's TV Parental Guidelines (TVPG) rating. +pub enum ContentRatingTvpgRatingEnum { + + /// "tvpgUnspecified" + #[serde(rename="tvpgUnspecified")] + TvpgUnspecified, + + + /// TV-Y + /// + /// "tvpgY" + #[serde(rename="tvpgY")] + TvpgY, + + + /// TV-Y7 + /// + /// "tvpgY7" + #[serde(rename="tvpgY7")] + TvpgY7, + + + /// TV-Y7-FV + /// + /// "tvpgY7Fv" + #[serde(rename="tvpgY7Fv")] + TvpgY7Fv, + + + /// TV-G + /// + /// "tvpgG" + #[serde(rename="tvpgG")] + TvpgG, + + + /// TV-PG + /// + /// "tvpgPg" + #[serde(rename="tvpgPg")] + TvpgPg, + + + /// TV-14 + /// + /// "pg14" + #[serde(rename="pg14")] + Pg14, + + + /// TV-MA + /// + /// "tvpgMa" + #[serde(rename="tvpgMa")] + TvpgMa, + + /// "tvpgUnrated" + #[serde(rename="tvpgUnrated")] + TvpgUnrated, +} + +impl AsRef for ContentRatingTvpgRatingEnum { + fn as_ref(&self) -> &str { + match *self { + ContentRatingTvpgRatingEnum::TvpgUnspecified => "tvpgUnspecified", + ContentRatingTvpgRatingEnum::TvpgY => "tvpgY", + ContentRatingTvpgRatingEnum::TvpgY7 => "tvpgY7", + ContentRatingTvpgRatingEnum::TvpgY7Fv => "tvpgY7Fv", + ContentRatingTvpgRatingEnum::TvpgG => "tvpgG", + ContentRatingTvpgRatingEnum::TvpgPg => "tvpgPg", + ContentRatingTvpgRatingEnum::Pg14 => "pg14", + ContentRatingTvpgRatingEnum::TvpgMa => "tvpgMa", + ContentRatingTvpgRatingEnum::TvpgUnrated => "tvpgUnrated", + } + } +} + +impl std::convert::TryFrom< &str> for ContentRatingTvpgRatingEnum { + type Error = (); + fn try_from(value: &str) -> Result { + match value { + "tvpgUnspecified" => Ok(ContentRatingTvpgRatingEnum::TvpgUnspecified), + "tvpgY" => Ok(ContentRatingTvpgRatingEnum::TvpgY), + "tvpgY7" => Ok(ContentRatingTvpgRatingEnum::TvpgY7), + "tvpgY7Fv" => Ok(ContentRatingTvpgRatingEnum::TvpgY7Fv), + "tvpgG" => Ok(ContentRatingTvpgRatingEnum::TvpgG), + "tvpgPg" => Ok(ContentRatingTvpgRatingEnum::TvpgPg), + "pg14" => Ok(ContentRatingTvpgRatingEnum::Pg14), + "tvpgMa" => Ok(ContentRatingTvpgRatingEnum::TvpgMa), + "tvpgUnrated" => Ok(ContentRatingTvpgRatingEnum::TvpgUnrated), + _=> Err(()), + } + } +} + +impl<'a> Into> for &'a ContentRatingTvpgRatingEnum { + fn into(self) -> std::borrow::Cow<'a, str> { + self.as_ref().into() + } +} + + +#[derive(Clone, Copy, Eq, Hash, Debug, PartialEq, Serialize, Deserialize)] +/// A rating that YouTube uses to identify age-restricted content. +pub enum ContentRatingYtRatingEnum { + + /// "ytUnspecified" + #[serde(rename="ytUnspecified")] + YtUnspecified, + + /// "ytAgeRestricted" + #[serde(rename="ytAgeRestricted")] + YtAgeRestricted, +} + +impl AsRef for ContentRatingYtRatingEnum { + fn as_ref(&self) -> &str { + match *self { + ContentRatingYtRatingEnum::YtUnspecified => "ytUnspecified", + ContentRatingYtRatingEnum::YtAgeRestricted => "ytAgeRestricted", + } + } +} + +impl std::convert::TryFrom< &str> for ContentRatingYtRatingEnum { + type Error = (); + fn try_from(value: &str) -> Result { + match value { + "ytUnspecified" => Ok(ContentRatingYtRatingEnum::YtUnspecified), + "ytAgeRestricted" => Ok(ContentRatingYtRatingEnum::YtAgeRestricted), + _=> Err(()), + } + } +} + +impl<'a> Into> for &'a ContentRatingYtRatingEnum { + fn into(self) -> std::borrow::Cow<'a, str> { + self.as_ref().into() + } +} + + +#[derive(Clone, Copy, Eq, Hash, Debug, PartialEq, Serialize, Deserialize)] +pub enum CuepointCueTypeEnum { + + /// "cueTypeUnspecified" + #[serde(rename="cueTypeUnspecified")] + CueTypeUnspecified, + + /// "cueTypeAd" + #[serde(rename="cueTypeAd")] + CueTypeAd, +} + +impl AsRef for CuepointCueTypeEnum { + fn as_ref(&self) -> &str { + match *self { + CuepointCueTypeEnum::CueTypeUnspecified => "cueTypeUnspecified", + CuepointCueTypeEnum::CueTypeAd => "cueTypeAd", + } + } +} + +impl std::convert::TryFrom< &str> for CuepointCueTypeEnum { + type Error = (); + fn try_from(value: &str) -> Result { + match value { + "cueTypeUnspecified" => Ok(CuepointCueTypeEnum::CueTypeUnspecified), + "cueTypeAd" => Ok(CuepointCueTypeEnum::CueTypeAd), + _=> Err(()), + } + } +} + +impl<'a> Into> for &'a CuepointCueTypeEnum { + fn into(self) -> std::borrow::Cow<'a, str> { + self.as_ref().into() + } +} + + +#[derive(Clone, Copy, Eq, Hash, Debug, PartialEq, Serialize, Deserialize)] +/// The strategy to use when scheduling cuepoints. +pub enum CuepointScheduleScheduleStrategyEnum { + + /// "scheduleStrategyUnspecified" + #[serde(rename="scheduleStrategyUnspecified")] + ScheduleStrategyUnspecified, + + + /// Strategy to schedule cuepoints at one time for all viewers. + /// + /// "concurrent" + #[serde(rename="concurrent")] + Concurrent, + + + /// Strategy to schedule cuepoints at an increased rate to allow viewers to receive cuepoints when eligible. See go/lcr-non-concurrent-ads for more details. + /// + /// "nonConcurrent" + #[serde(rename="nonConcurrent")] + NonConcurrent, +} + +impl AsRef for CuepointScheduleScheduleStrategyEnum { + fn as_ref(&self) -> &str { + match *self { + CuepointScheduleScheduleStrategyEnum::ScheduleStrategyUnspecified => "scheduleStrategyUnspecified", + CuepointScheduleScheduleStrategyEnum::Concurrent => "concurrent", + CuepointScheduleScheduleStrategyEnum::NonConcurrent => "nonConcurrent", + } + } +} + +impl std::convert::TryFrom< &str> for CuepointScheduleScheduleStrategyEnum { + type Error = (); + fn try_from(value: &str) -> Result { + match value { + "scheduleStrategyUnspecified" => Ok(CuepointScheduleScheduleStrategyEnum::ScheduleStrategyUnspecified), + "concurrent" => Ok(CuepointScheduleScheduleStrategyEnum::Concurrent), + "nonConcurrent" => Ok(CuepointScheduleScheduleStrategyEnum::NonConcurrent), + _=> Err(()), + } + } +} + +impl<'a> Into> for &'a CuepointScheduleScheduleStrategyEnum { + fn into(self) -> std::borrow::Cow<'a, str> { + self.as_ref().into() + } +} + + +#[derive(Clone, Copy, Eq, Hash, Debug, PartialEq, Serialize, Deserialize)] +/// Describes in which corner of the video the visual widget will appear. +pub enum InvideoPositionCornerPositionEnum { + + /// "topLeft" + #[serde(rename="topLeft")] + TopLeft, + + /// "topRight" + #[serde(rename="topRight")] + TopRight, + + /// "bottomLeft" + #[serde(rename="bottomLeft")] + BottomLeft, + + /// "bottomRight" + #[serde(rename="bottomRight")] + BottomRight, +} + +impl AsRef for InvideoPositionCornerPositionEnum { + fn as_ref(&self) -> &str { + match *self { + InvideoPositionCornerPositionEnum::TopLeft => "topLeft", + InvideoPositionCornerPositionEnum::TopRight => "topRight", + InvideoPositionCornerPositionEnum::BottomLeft => "bottomLeft", + InvideoPositionCornerPositionEnum::BottomRight => "bottomRight", + } + } +} + +impl std::convert::TryFrom< &str> for InvideoPositionCornerPositionEnum { + type Error = (); + fn try_from(value: &str) -> Result { + match value { + "topLeft" => Ok(InvideoPositionCornerPositionEnum::TopLeft), + "topRight" => Ok(InvideoPositionCornerPositionEnum::TopRight), + "bottomLeft" => Ok(InvideoPositionCornerPositionEnum::BottomLeft), + "bottomRight" => Ok(InvideoPositionCornerPositionEnum::BottomRight), + _=> Err(()), + } + } +} + +impl<'a> Into> for &'a InvideoPositionCornerPositionEnum { + fn into(self) -> std::borrow::Cow<'a, str> { + self.as_ref().into() + } +} + + +#[derive(Clone, Copy, Eq, Hash, Debug, PartialEq, Serialize, Deserialize)] +/// Defines the position type. +pub enum InvideoPositionTypeEnum { + + /// "corner" + #[serde(rename="corner")] + Corner, +} + +impl AsRef for InvideoPositionTypeEnum { + fn as_ref(&self) -> &str { + match *self { + InvideoPositionTypeEnum::Corner => "corner", + } + } +} + +impl std::convert::TryFrom< &str> for InvideoPositionTypeEnum { + type Error = (); + fn try_from(value: &str) -> Result { + match value { + "corner" => Ok(InvideoPositionTypeEnum::Corner), + _=> Err(()), + } + } +} + +impl<'a> Into> for &'a InvideoPositionTypeEnum { + fn into(self) -> std::borrow::Cow<'a, str> { + self.as_ref().into() + } +} + + +#[derive(Clone, Copy, Eq, Hash, Debug, PartialEq, Serialize, Deserialize)] +/// Describes a timing type. If the value is offsetFromStart, then the offsetMs field represents an offset from the start of the video. If the value is offsetFromEnd, then the offsetMs field represents an offset from the end of the video. +pub enum InvideoTimingTypeEnum { + + /// "offsetFromStart" + #[serde(rename="offsetFromStart")] + OffsetFromStart, + + /// "offsetFromEnd" + #[serde(rename="offsetFromEnd")] + OffsetFromEnd, +} + +impl AsRef for InvideoTimingTypeEnum { + fn as_ref(&self) -> &str { + match *self { + InvideoTimingTypeEnum::OffsetFromStart => "offsetFromStart", + InvideoTimingTypeEnum::OffsetFromEnd => "offsetFromEnd", + } + } +} + +impl std::convert::TryFrom< &str> for InvideoTimingTypeEnum { + type Error = (); + fn try_from(value: &str) -> Result { + match value { + "offsetFromStart" => Ok(InvideoTimingTypeEnum::OffsetFromStart), + "offsetFromEnd" => Ok(InvideoTimingTypeEnum::OffsetFromEnd), + _=> Err(()), + } + } +} + +impl<'a> Into> for &'a InvideoTimingTypeEnum { + fn into(self) -> std::borrow::Cow<'a, str> { + self.as_ref().into() + } +} + + +#[derive(Clone, Copy, Eq, Hash, Debug, PartialEq, Serialize, Deserialize)] +pub enum LiveBroadcastContentDetailClosedCaptionsTypeEnum { + + /// "closedCaptionsTypeUnspecified" + #[serde(rename="closedCaptionsTypeUnspecified")] + ClosedCaptionsTypeUnspecified, + + /// "closedCaptionsDisabled" + #[serde(rename="closedCaptionsDisabled")] + ClosedCaptionsDisabled, + + /// "closedCaptionsHttpPost" + #[serde(rename="closedCaptionsHttpPost")] + ClosedCaptionsHttpPost, + + /// "closedCaptionsEmbedded" + #[serde(rename="closedCaptionsEmbedded")] + ClosedCaptionsEmbedded, +} + +impl AsRef for LiveBroadcastContentDetailClosedCaptionsTypeEnum { + fn as_ref(&self) -> &str { + match *self { + LiveBroadcastContentDetailClosedCaptionsTypeEnum::ClosedCaptionsTypeUnspecified => "closedCaptionsTypeUnspecified", + LiveBroadcastContentDetailClosedCaptionsTypeEnum::ClosedCaptionsDisabled => "closedCaptionsDisabled", + LiveBroadcastContentDetailClosedCaptionsTypeEnum::ClosedCaptionsHttpPost => "closedCaptionsHttpPost", + LiveBroadcastContentDetailClosedCaptionsTypeEnum::ClosedCaptionsEmbedded => "closedCaptionsEmbedded", + } + } +} + +impl std::convert::TryFrom< &str> for LiveBroadcastContentDetailClosedCaptionsTypeEnum { + type Error = (); + fn try_from(value: &str) -> Result { + match value { + "closedCaptionsTypeUnspecified" => Ok(LiveBroadcastContentDetailClosedCaptionsTypeEnum::ClosedCaptionsTypeUnspecified), + "closedCaptionsDisabled" => Ok(LiveBroadcastContentDetailClosedCaptionsTypeEnum::ClosedCaptionsDisabled), + "closedCaptionsHttpPost" => Ok(LiveBroadcastContentDetailClosedCaptionsTypeEnum::ClosedCaptionsHttpPost), + "closedCaptionsEmbedded" => Ok(LiveBroadcastContentDetailClosedCaptionsTypeEnum::ClosedCaptionsEmbedded), + _=> Err(()), + } + } +} + +impl<'a> Into> for &'a LiveBroadcastContentDetailClosedCaptionsTypeEnum { + fn into(self) -> std::borrow::Cow<'a, str> { + self.as_ref().into() + } +} + + +#[derive(Clone, Copy, Eq, Hash, Debug, PartialEq, Serialize, Deserialize)] +/// If both this and enable_low_latency are set, they must match. LATENCY_NORMAL should match enable_low_latency=false LATENCY_LOW should match enable_low_latency=true LATENCY_ULTRA_LOW should have enable_low_latency omitted. +pub enum LiveBroadcastContentDetailLatencyPreferenceEnum { + + /// "latencyPreferenceUnspecified" + #[serde(rename="latencyPreferenceUnspecified")] + LatencyPreferenceUnspecified, + + + /// Best for: highest quality viewer playbacks and higher resolutions. + /// + /// "normal" + #[serde(rename="normal")] + Normal, + + + /// Best for: near real-time interaction, with minimal playback buffering. + /// + /// "low" + #[serde(rename="low")] + Low, + + + /// Best for: real-time interaction Does not support: Closed captions, 1440p, and 4k resolutions + /// + /// "ultraLow" + #[serde(rename="ultraLow")] + UltraLow, +} + +impl AsRef for LiveBroadcastContentDetailLatencyPreferenceEnum { + fn as_ref(&self) -> &str { + match *self { + LiveBroadcastContentDetailLatencyPreferenceEnum::LatencyPreferenceUnspecified => "latencyPreferenceUnspecified", + LiveBroadcastContentDetailLatencyPreferenceEnum::Normal => "normal", + LiveBroadcastContentDetailLatencyPreferenceEnum::Low => "low", + LiveBroadcastContentDetailLatencyPreferenceEnum::UltraLow => "ultraLow", + } + } +} + +impl std::convert::TryFrom< &str> for LiveBroadcastContentDetailLatencyPreferenceEnum { + type Error = (); + fn try_from(value: &str) -> Result { + match value { + "latencyPreferenceUnspecified" => Ok(LiveBroadcastContentDetailLatencyPreferenceEnum::LatencyPreferenceUnspecified), + "normal" => Ok(LiveBroadcastContentDetailLatencyPreferenceEnum::Normal), + "low" => Ok(LiveBroadcastContentDetailLatencyPreferenceEnum::Low), + "ultraLow" => Ok(LiveBroadcastContentDetailLatencyPreferenceEnum::UltraLow), + _=> Err(()), + } + } +} + +impl<'a> Into> for &'a LiveBroadcastContentDetailLatencyPreferenceEnum { + fn into(self) -> std::borrow::Cow<'a, str> { + self.as_ref().into() + } +} + + +#[derive(Clone, Copy, Eq, Hash, Debug, PartialEq, Serialize, Deserialize)] +/// The projection format of this broadcast. This defaults to rectangular. +pub enum LiveBroadcastContentDetailProjectionEnum { + + /// "projectionUnspecified" + #[serde(rename="projectionUnspecified")] + ProjectionUnspecified, + + /// "rectangular" + #[serde(rename="rectangular")] + Rectangular, + + /// "360" + #[serde(rename="360")] + _360, + + /// "mesh" + #[serde(rename="mesh")] + Mesh, +} + +impl AsRef for LiveBroadcastContentDetailProjectionEnum { + fn as_ref(&self) -> &str { + match *self { + LiveBroadcastContentDetailProjectionEnum::ProjectionUnspecified => "projectionUnspecified", + LiveBroadcastContentDetailProjectionEnum::Rectangular => "rectangular", + LiveBroadcastContentDetailProjectionEnum::_360 => "360", + LiveBroadcastContentDetailProjectionEnum::Mesh => "mesh", + } + } +} + +impl std::convert::TryFrom< &str> for LiveBroadcastContentDetailProjectionEnum { + type Error = (); + fn try_from(value: &str) -> Result { + match value { + "projectionUnspecified" => Ok(LiveBroadcastContentDetailProjectionEnum::ProjectionUnspecified), + "rectangular" => Ok(LiveBroadcastContentDetailProjectionEnum::Rectangular), + "360" => Ok(LiveBroadcastContentDetailProjectionEnum::_360), + "mesh" => Ok(LiveBroadcastContentDetailProjectionEnum::Mesh), + _=> Err(()), + } + } +} + +impl<'a> Into> for &'a LiveBroadcastContentDetailProjectionEnum { + fn into(self) -> std::borrow::Cow<'a, str> { + self.as_ref().into() + } +} + + +#[derive(Clone, Copy, Eq, Hash, Debug, PartialEq, Serialize, Deserialize)] +/// The 3D stereo layout of this broadcast. This defaults to mono. +pub enum LiveBroadcastContentDetailStereoLayoutEnum { + + /// "stereoLayoutUnspecified" + #[serde(rename="stereoLayoutUnspecified")] + StereoLayoutUnspecified, + + /// "mono" + #[serde(rename="mono")] + Mono, + + /// "leftRight" + #[serde(rename="leftRight")] + LeftRight, + + /// "topBottom" + #[serde(rename="topBottom")] + TopBottom, +} + +impl AsRef for LiveBroadcastContentDetailStereoLayoutEnum { + fn as_ref(&self) -> &str { + match *self { + LiveBroadcastContentDetailStereoLayoutEnum::StereoLayoutUnspecified => "stereoLayoutUnspecified", + LiveBroadcastContentDetailStereoLayoutEnum::Mono => "mono", + LiveBroadcastContentDetailStereoLayoutEnum::LeftRight => "leftRight", + LiveBroadcastContentDetailStereoLayoutEnum::TopBottom => "topBottom", + } + } +} + +impl std::convert::TryFrom< &str> for LiveBroadcastContentDetailStereoLayoutEnum { + type Error = (); + fn try_from(value: &str) -> Result { + match value { + "stereoLayoutUnspecified" => Ok(LiveBroadcastContentDetailStereoLayoutEnum::StereoLayoutUnspecified), + "mono" => Ok(LiveBroadcastContentDetailStereoLayoutEnum::Mono), + "leftRight" => Ok(LiveBroadcastContentDetailStereoLayoutEnum::LeftRight), + "topBottom" => Ok(LiveBroadcastContentDetailStereoLayoutEnum::TopBottom), + _=> Err(()), + } + } +} + +impl<'a> Into> for &'a LiveBroadcastContentDetailStereoLayoutEnum { + fn into(self) -> std::borrow::Cow<'a, str> { + self.as_ref().into() + } +} + + +#[derive(Clone, Copy, Eq, Hash, Debug, PartialEq, Serialize, Deserialize)] +/// The broadcast's status. The status can be updated using the API's liveBroadcasts.transition method. +pub enum LiveBroadcastStatusLifeCycleStatusEnum { + + + /// No value or the value is unknown. + /// + /// "lifeCycleStatusUnspecified" + #[serde(rename="lifeCycleStatusUnspecified")] + LifeCycleStatusUnspecified, + + + /// Incomplete settings, but otherwise valid + /// + /// "created" + #[serde(rename="created")] + Created, + + + /// Complete settings + /// + /// "ready" + #[serde(rename="ready")] + Ready, + + + /// Visible only to partner, may need special UI treatment + /// + /// "testing" + #[serde(rename="testing")] + Testing, + + + /// Viper is recording; this means the "clock" is running + /// + /// "live" + #[serde(rename="live")] + Live, + + + /// The broadcast is finished. + /// + /// "complete" + #[serde(rename="complete")] + Complete, + + + /// This broadcast was removed by admin action + /// + /// "revoked" + #[serde(rename="revoked")] + Revoked, + + + /// Transition into TESTING has been requested + /// + /// "testStarting" + #[serde(rename="testStarting")] + TestStarting, + + + /// Transition into LIVE has been requested + /// + /// "liveStarting" + #[serde(rename="liveStarting")] + LiveStarting, +} + +impl AsRef for LiveBroadcastStatusLifeCycleStatusEnum { + fn as_ref(&self) -> &str { + match *self { + LiveBroadcastStatusLifeCycleStatusEnum::LifeCycleStatusUnspecified => "lifeCycleStatusUnspecified", + LiveBroadcastStatusLifeCycleStatusEnum::Created => "created", + LiveBroadcastStatusLifeCycleStatusEnum::Ready => "ready", + LiveBroadcastStatusLifeCycleStatusEnum::Testing => "testing", + LiveBroadcastStatusLifeCycleStatusEnum::Live => "live", + LiveBroadcastStatusLifeCycleStatusEnum::Complete => "complete", + LiveBroadcastStatusLifeCycleStatusEnum::Revoked => "revoked", + LiveBroadcastStatusLifeCycleStatusEnum::TestStarting => "testStarting", + LiveBroadcastStatusLifeCycleStatusEnum::LiveStarting => "liveStarting", + } + } +} + +impl std::convert::TryFrom< &str> for LiveBroadcastStatusLifeCycleStatusEnum { + type Error = (); + fn try_from(value: &str) -> Result { + match value { + "lifeCycleStatusUnspecified" => Ok(LiveBroadcastStatusLifeCycleStatusEnum::LifeCycleStatusUnspecified), + "created" => Ok(LiveBroadcastStatusLifeCycleStatusEnum::Created), + "ready" => Ok(LiveBroadcastStatusLifeCycleStatusEnum::Ready), + "testing" => Ok(LiveBroadcastStatusLifeCycleStatusEnum::Testing), + "live" => Ok(LiveBroadcastStatusLifeCycleStatusEnum::Live), + "complete" => Ok(LiveBroadcastStatusLifeCycleStatusEnum::Complete), + "revoked" => Ok(LiveBroadcastStatusLifeCycleStatusEnum::Revoked), + "testStarting" => Ok(LiveBroadcastStatusLifeCycleStatusEnum::TestStarting), + "liveStarting" => Ok(LiveBroadcastStatusLifeCycleStatusEnum::LiveStarting), + _=> Err(()), + } + } +} + +impl<'a> Into> for &'a LiveBroadcastStatusLifeCycleStatusEnum { + fn into(self) -> std::borrow::Cow<'a, str> { + self.as_ref().into() + } +} + + +#[derive(Clone, Copy, Eq, Hash, Debug, PartialEq, Serialize, Deserialize)] +/// Priority of the live broadcast event (internal state). +pub enum LiveBroadcastStatusLiveBroadcastPriorityEnum { + + /// "liveBroadcastPriorityUnspecified" + #[serde(rename="liveBroadcastPriorityUnspecified")] + LiveBroadcastPriorityUnspecified, + + + /// Low priority broadcast: for low view count HoAs or other low priority broadcasts. + /// + /// "low" + #[serde(rename="low")] + Low, + + + /// Normal priority broadcast: for regular HoAs and broadcasts. + /// + /// "normal" + #[serde(rename="normal")] + Normal, + + + /// High priority broadcast: for high profile HoAs, like PixelCorp ones. + /// + /// "high" + #[serde(rename="high")] + High, +} + +impl AsRef for LiveBroadcastStatusLiveBroadcastPriorityEnum { + fn as_ref(&self) -> &str { + match *self { + LiveBroadcastStatusLiveBroadcastPriorityEnum::LiveBroadcastPriorityUnspecified => "liveBroadcastPriorityUnspecified", + LiveBroadcastStatusLiveBroadcastPriorityEnum::Low => "low", + LiveBroadcastStatusLiveBroadcastPriorityEnum::Normal => "normal", + LiveBroadcastStatusLiveBroadcastPriorityEnum::High => "high", + } + } +} + +impl std::convert::TryFrom< &str> for LiveBroadcastStatusLiveBroadcastPriorityEnum { + type Error = (); + fn try_from(value: &str) -> Result { + match value { + "liveBroadcastPriorityUnspecified" => Ok(LiveBroadcastStatusLiveBroadcastPriorityEnum::LiveBroadcastPriorityUnspecified), + "low" => Ok(LiveBroadcastStatusLiveBroadcastPriorityEnum::Low), + "normal" => Ok(LiveBroadcastStatusLiveBroadcastPriorityEnum::Normal), + "high" => Ok(LiveBroadcastStatusLiveBroadcastPriorityEnum::High), + _=> Err(()), + } + } +} + +impl<'a> Into> for &'a LiveBroadcastStatusLiveBroadcastPriorityEnum { + fn into(self) -> std::borrow::Cow<'a, str> { + self.as_ref().into() + } +} + + +#[derive(Clone, Copy, Eq, Hash, Debug, PartialEq, Serialize, Deserialize)] +/// The broadcast's privacy status. Note that the broadcast represents exactly one YouTube video, so the privacy settings are identical to those supported for videos. In addition, you can set this field by modifying the broadcast resource or by setting the privacyStatus field of the corresponding video resource. +pub enum LiveBroadcastStatusPrivacyStatusEnum { + + /// "public" + #[serde(rename="public")] + Public, + + /// "unlisted" + #[serde(rename="unlisted")] + Unlisted, + + /// "private" + #[serde(rename="private")] + Private, +} + +impl AsRef for LiveBroadcastStatusPrivacyStatusEnum { + fn as_ref(&self) -> &str { + match *self { + LiveBroadcastStatusPrivacyStatusEnum::Public => "public", + LiveBroadcastStatusPrivacyStatusEnum::Unlisted => "unlisted", + LiveBroadcastStatusPrivacyStatusEnum::Private => "private", + } + } +} + +impl std::convert::TryFrom< &str> for LiveBroadcastStatusPrivacyStatusEnum { + type Error = (); + fn try_from(value: &str) -> Result { + match value { + "public" => Ok(LiveBroadcastStatusPrivacyStatusEnum::Public), + "unlisted" => Ok(LiveBroadcastStatusPrivacyStatusEnum::Unlisted), + "private" => Ok(LiveBroadcastStatusPrivacyStatusEnum::Private), + _=> Err(()), + } + } +} + +impl<'a> Into> for &'a LiveBroadcastStatusPrivacyStatusEnum { + fn into(self) -> std::borrow::Cow<'a, str> { + self.as_ref().into() + } +} + + +#[derive(Clone, Copy, Eq, Hash, Debug, PartialEq, Serialize, Deserialize)] +/// The broadcast's recording status. +pub enum LiveBroadcastStatusRecordingStatusEnum { + + + /// No value or the value is unknown. + /// + /// "liveBroadcastRecordingStatusUnspecified" + #[serde(rename="liveBroadcastRecordingStatusUnspecified")] + LiveBroadcastRecordingStatusUnspecified, + + + /// The recording has not yet been started. + /// + /// "notRecording" + #[serde(rename="notRecording")] + NotRecording, + + + /// The recording is currently on. + /// + /// "recording" + #[serde(rename="recording")] + Recording, + + + /// The recording is completed, and cannot be started again. + /// + /// "recorded" + #[serde(rename="recorded")] + Recorded, +} + +impl AsRef for LiveBroadcastStatusRecordingStatusEnum { + fn as_ref(&self) -> &str { + match *self { + LiveBroadcastStatusRecordingStatusEnum::LiveBroadcastRecordingStatusUnspecified => "liveBroadcastRecordingStatusUnspecified", + LiveBroadcastStatusRecordingStatusEnum::NotRecording => "notRecording", + LiveBroadcastStatusRecordingStatusEnum::Recording => "recording", + LiveBroadcastStatusRecordingStatusEnum::Recorded => "recorded", + } + } +} + +impl std::convert::TryFrom< &str> for LiveBroadcastStatusRecordingStatusEnum { + type Error = (); + fn try_from(value: &str) -> Result { + match value { + "liveBroadcastRecordingStatusUnspecified" => Ok(LiveBroadcastStatusRecordingStatusEnum::LiveBroadcastRecordingStatusUnspecified), + "notRecording" => Ok(LiveBroadcastStatusRecordingStatusEnum::NotRecording), + "recording" => Ok(LiveBroadcastStatusRecordingStatusEnum::Recording), + "recorded" => Ok(LiveBroadcastStatusRecordingStatusEnum::Recorded), + _=> Err(()), + } + } +} + +impl<'a> Into> for &'a LiveBroadcastStatusRecordingStatusEnum { + fn into(self) -> std::borrow::Cow<'a, str> { + self.as_ref().into() + } +} + + +#[derive(Clone, Copy, Eq, Hash, Debug, PartialEq, Serialize, Deserialize)] +/// The type of ban. +pub enum LiveChatBanSnippetTypeEnum { + + + /// An invalid ban type. + /// + /// "liveChatBanTypeUnspecified" + #[serde(rename="liveChatBanTypeUnspecified")] + LiveChatBanTypeUnspecified, + + + /// A permanent ban. + /// + /// "permanent" + #[serde(rename="permanent")] + Permanent, + + + /// A temporary ban. + /// + /// "temporary" + #[serde(rename="temporary")] + Temporary, +} + +impl AsRef for LiveChatBanSnippetTypeEnum { + fn as_ref(&self) -> &str { + match *self { + LiveChatBanSnippetTypeEnum::LiveChatBanTypeUnspecified => "liveChatBanTypeUnspecified", + LiveChatBanSnippetTypeEnum::Permanent => "permanent", + LiveChatBanSnippetTypeEnum::Temporary => "temporary", + } + } +} + +impl std::convert::TryFrom< &str> for LiveChatBanSnippetTypeEnum { + type Error = (); + fn try_from(value: &str) -> Result { + match value { + "liveChatBanTypeUnspecified" => Ok(LiveChatBanSnippetTypeEnum::LiveChatBanTypeUnspecified), + "permanent" => Ok(LiveChatBanSnippetTypeEnum::Permanent), + "temporary" => Ok(LiveChatBanSnippetTypeEnum::Temporary), + _=> Err(()), + } + } +} + +impl<'a> Into> for &'a LiveChatBanSnippetTypeEnum { + fn into(self) -> std::borrow::Cow<'a, str> { + self.as_ref().into() + } +} + + +#[derive(Clone, Copy, Eq, Hash, Debug, PartialEq, Serialize, Deserialize)] +/// The type of message, this will always be present, it determines the contents of the message as well as which fields will be present. +pub enum LiveChatMessageSnippetTypeEnum { + + /// "invalidType" + #[serde(rename="invalidType")] + InvalidType, + + /// "textMessageEvent" + #[serde(rename="textMessageEvent")] + TextMessageEvent, + + /// "tombstone" + #[serde(rename="tombstone")] + Tombstone, + + /// "fanFundingEvent" + #[serde(rename="fanFundingEvent")] + FanFundingEvent, + + /// "chatEndedEvent" + #[serde(rename="chatEndedEvent")] + ChatEndedEvent, + + /// "sponsorOnlyModeStartedEvent" + #[serde(rename="sponsorOnlyModeStartedEvent")] + SponsorOnlyModeStartedEvent, + + /// "sponsorOnlyModeEndedEvent" + #[serde(rename="sponsorOnlyModeEndedEvent")] + SponsorOnlyModeEndedEvent, + + /// "newSponsorEvent" + #[serde(rename="newSponsorEvent")] + NewSponsorEvent, + + /// "memberMilestoneChatEvent" + #[serde(rename="memberMilestoneChatEvent")] + MemberMilestoneChatEvent, + + /// "membershipGiftingEvent" + #[serde(rename="membershipGiftingEvent")] + MembershipGiftingEvent, + + /// "giftMembershipReceivedEvent" + #[serde(rename="giftMembershipReceivedEvent")] + GiftMembershipReceivedEvent, + + /// "messageDeletedEvent" + #[serde(rename="messageDeletedEvent")] + MessageDeletedEvent, + + /// "messageRetractedEvent" + #[serde(rename="messageRetractedEvent")] + MessageRetractedEvent, + + /// "userBannedEvent" + #[serde(rename="userBannedEvent")] + UserBannedEvent, + + /// "superChatEvent" + #[serde(rename="superChatEvent")] + SuperChatEvent, + + /// "superStickerEvent" + #[serde(rename="superStickerEvent")] + SuperStickerEvent, + + /// "pollEvent" + #[serde(rename="pollEvent")] + PollEvent, +} + +impl AsRef for LiveChatMessageSnippetTypeEnum { + fn as_ref(&self) -> &str { + match *self { + LiveChatMessageSnippetTypeEnum::InvalidType => "invalidType", + LiveChatMessageSnippetTypeEnum::TextMessageEvent => "textMessageEvent", + LiveChatMessageSnippetTypeEnum::Tombstone => "tombstone", + LiveChatMessageSnippetTypeEnum::FanFundingEvent => "fanFundingEvent", + LiveChatMessageSnippetTypeEnum::ChatEndedEvent => "chatEndedEvent", + LiveChatMessageSnippetTypeEnum::SponsorOnlyModeStartedEvent => "sponsorOnlyModeStartedEvent", + LiveChatMessageSnippetTypeEnum::SponsorOnlyModeEndedEvent => "sponsorOnlyModeEndedEvent", + LiveChatMessageSnippetTypeEnum::NewSponsorEvent => "newSponsorEvent", + LiveChatMessageSnippetTypeEnum::MemberMilestoneChatEvent => "memberMilestoneChatEvent", + LiveChatMessageSnippetTypeEnum::MembershipGiftingEvent => "membershipGiftingEvent", + LiveChatMessageSnippetTypeEnum::GiftMembershipReceivedEvent => "giftMembershipReceivedEvent", + LiveChatMessageSnippetTypeEnum::MessageDeletedEvent => "messageDeletedEvent", + LiveChatMessageSnippetTypeEnum::MessageRetractedEvent => "messageRetractedEvent", + LiveChatMessageSnippetTypeEnum::UserBannedEvent => "userBannedEvent", + LiveChatMessageSnippetTypeEnum::SuperChatEvent => "superChatEvent", + LiveChatMessageSnippetTypeEnum::SuperStickerEvent => "superStickerEvent", + LiveChatMessageSnippetTypeEnum::PollEvent => "pollEvent", + } + } +} + +impl std::convert::TryFrom< &str> for LiveChatMessageSnippetTypeEnum { + type Error = (); + fn try_from(value: &str) -> Result { + match value { + "invalidType" => Ok(LiveChatMessageSnippetTypeEnum::InvalidType), + "textMessageEvent" => Ok(LiveChatMessageSnippetTypeEnum::TextMessageEvent), + "tombstone" => Ok(LiveChatMessageSnippetTypeEnum::Tombstone), + "fanFundingEvent" => Ok(LiveChatMessageSnippetTypeEnum::FanFundingEvent), + "chatEndedEvent" => Ok(LiveChatMessageSnippetTypeEnum::ChatEndedEvent), + "sponsorOnlyModeStartedEvent" => Ok(LiveChatMessageSnippetTypeEnum::SponsorOnlyModeStartedEvent), + "sponsorOnlyModeEndedEvent" => Ok(LiveChatMessageSnippetTypeEnum::SponsorOnlyModeEndedEvent), + "newSponsorEvent" => Ok(LiveChatMessageSnippetTypeEnum::NewSponsorEvent), + "memberMilestoneChatEvent" => Ok(LiveChatMessageSnippetTypeEnum::MemberMilestoneChatEvent), + "membershipGiftingEvent" => Ok(LiveChatMessageSnippetTypeEnum::MembershipGiftingEvent), + "giftMembershipReceivedEvent" => Ok(LiveChatMessageSnippetTypeEnum::GiftMembershipReceivedEvent), + "messageDeletedEvent" => Ok(LiveChatMessageSnippetTypeEnum::MessageDeletedEvent), + "messageRetractedEvent" => Ok(LiveChatMessageSnippetTypeEnum::MessageRetractedEvent), + "userBannedEvent" => Ok(LiveChatMessageSnippetTypeEnum::UserBannedEvent), + "superChatEvent" => Ok(LiveChatMessageSnippetTypeEnum::SuperChatEvent), + "superStickerEvent" => Ok(LiveChatMessageSnippetTypeEnum::SuperStickerEvent), + "pollEvent" => Ok(LiveChatMessageSnippetTypeEnum::PollEvent), + _=> Err(()), + } + } +} + +impl<'a> Into> for &'a LiveChatMessageSnippetTypeEnum { + fn into(self) -> std::borrow::Cow<'a, str> { + self.as_ref().into() + } +} + + +#[derive(Clone, Copy, Eq, Hash, Debug, PartialEq, Serialize, Deserialize)] +pub enum LiveChatPollDetailStatusEnum { + + /// "unknown" + #[serde(rename="unknown")] + Unknown, + + /// "active" + #[serde(rename="active")] + Active, + + /// "closed" + #[serde(rename="closed")] + Closed, +} + +impl AsRef for LiveChatPollDetailStatusEnum { + fn as_ref(&self) -> &str { + match *self { + LiveChatPollDetailStatusEnum::Unknown => "unknown", + LiveChatPollDetailStatusEnum::Active => "active", + LiveChatPollDetailStatusEnum::Closed => "closed", + } + } +} + +impl std::convert::TryFrom< &str> for LiveChatPollDetailStatusEnum { + type Error = (); + fn try_from(value: &str) -> Result { + match value { + "unknown" => Ok(LiveChatPollDetailStatusEnum::Unknown), + "active" => Ok(LiveChatPollDetailStatusEnum::Active), + "closed" => Ok(LiveChatPollDetailStatusEnum::Closed), + _=> Err(()), + } + } +} + +impl<'a> Into> for &'a LiveChatPollDetailStatusEnum { + fn into(self) -> std::borrow::Cow<'a, str> { + self.as_ref().into() + } +} + + +#[derive(Clone, Copy, Eq, Hash, Debug, PartialEq, Serialize, Deserialize)] +/// The type of ban. +pub enum LiveChatUserBannedMessageDetailBanTypeEnum { + + /// "permanent" + #[serde(rename="permanent")] + Permanent, + + /// "temporary" + #[serde(rename="temporary")] + Temporary, +} + +impl AsRef for LiveChatUserBannedMessageDetailBanTypeEnum { + fn as_ref(&self) -> &str { + match *self { + LiveChatUserBannedMessageDetailBanTypeEnum::Permanent => "permanent", + LiveChatUserBannedMessageDetailBanTypeEnum::Temporary => "temporary", + } + } +} + +impl std::convert::TryFrom< &str> for LiveChatUserBannedMessageDetailBanTypeEnum { + type Error = (); + fn try_from(value: &str) -> Result { + match value { + "permanent" => Ok(LiveChatUserBannedMessageDetailBanTypeEnum::Permanent), + "temporary" => Ok(LiveChatUserBannedMessageDetailBanTypeEnum::Temporary), + _=> Err(()), + } + } +} + +impl<'a> Into> for &'a LiveChatUserBannedMessageDetailBanTypeEnum { + fn into(self) -> std::borrow::Cow<'a, str> { + self.as_ref().into() + } +} + + +#[derive(Clone, Copy, Eq, Hash, Debug, PartialEq, Serialize, Deserialize)] +/// How severe this issue is to the stream. +pub enum LiveStreamConfigurationIssueSeverityEnum { + + /// "info" + #[serde(rename="info")] + Info, + + /// "warning" + #[serde(rename="warning")] + Warning, + + /// "error" + #[serde(rename="error")] + Error, +} + +impl AsRef for LiveStreamConfigurationIssueSeverityEnum { + fn as_ref(&self) -> &str { + match *self { + LiveStreamConfigurationIssueSeverityEnum::Info => "info", + LiveStreamConfigurationIssueSeverityEnum::Warning => "warning", + LiveStreamConfigurationIssueSeverityEnum::Error => "error", + } + } +} + +impl std::convert::TryFrom< &str> for LiveStreamConfigurationIssueSeverityEnum { + type Error = (); + fn try_from(value: &str) -> Result { + match value { + "info" => Ok(LiveStreamConfigurationIssueSeverityEnum::Info), + "warning" => Ok(LiveStreamConfigurationIssueSeverityEnum::Warning), + "error" => Ok(LiveStreamConfigurationIssueSeverityEnum::Error), + _=> Err(()), + } + } +} + +impl<'a> Into> for &'a LiveStreamConfigurationIssueSeverityEnum { + fn into(self) -> std::borrow::Cow<'a, str> { + self.as_ref().into() + } +} + + +#[derive(Clone, Copy, Eq, Hash, Debug, PartialEq, Serialize, Deserialize)] +/// The kind of error happening. +pub enum LiveStreamConfigurationIssueTypeEnum { + + /// "gopSizeOver" + #[serde(rename="gopSizeOver")] + GopSizeOver, + + /// "gopSizeLong" + #[serde(rename="gopSizeLong")] + GopSizeLong, + + /// "gopSizeShort" + #[serde(rename="gopSizeShort")] + GopSizeShort, + + /// "openGop" + #[serde(rename="openGop")] + OpenGop, + + /// "badContainer" + #[serde(rename="badContainer")] + BadContainer, + + /// "audioBitrateHigh" + #[serde(rename="audioBitrateHigh")] + AudioBitrateHigh, + + /// "audioBitrateLow" + #[serde(rename="audioBitrateLow")] + AudioBitrateLow, + + /// "audioSampleRate" + #[serde(rename="audioSampleRate")] + AudioSampleRate, + + /// "bitrateHigh" + #[serde(rename="bitrateHigh")] + BitrateHigh, + + /// "bitrateLow" + #[serde(rename="bitrateLow")] + BitrateLow, + + /// "audioCodec" + #[serde(rename="audioCodec")] + AudioCodec, + + /// "videoCodec" + #[serde(rename="videoCodec")] + VideoCodec, + + /// "noAudioStream" + #[serde(rename="noAudioStream")] + NoAudioStream, + + /// "noVideoStream" + #[serde(rename="noVideoStream")] + NoVideoStream, + + /// "multipleVideoStreams" + #[serde(rename="multipleVideoStreams")] + MultipleVideoStreams, + + /// "multipleAudioStreams" + #[serde(rename="multipleAudioStreams")] + MultipleAudioStreams, + + /// "audioTooManyChannels" + #[serde(rename="audioTooManyChannels")] + AudioTooManyChannels, + + /// "interlacedVideo" + #[serde(rename="interlacedVideo")] + InterlacedVideo, + + /// "frameRateHigh" + #[serde(rename="frameRateHigh")] + FrameRateHigh, + + /// "resolutionMismatch" + #[serde(rename="resolutionMismatch")] + ResolutionMismatch, + + /// "videoCodecMismatch" + #[serde(rename="videoCodecMismatch")] + VideoCodecMismatch, + + /// "videoInterlaceMismatch" + #[serde(rename="videoInterlaceMismatch")] + VideoInterlaceMismatch, + + /// "videoProfileMismatch" + #[serde(rename="videoProfileMismatch")] + VideoProfileMismatch, + + /// "videoBitrateMismatch" + #[serde(rename="videoBitrateMismatch")] + VideoBitrateMismatch, + + /// "framerateMismatch" + #[serde(rename="framerateMismatch")] + FramerateMismatch, + + /// "gopMismatch" + #[serde(rename="gopMismatch")] + GopMismatch, + + /// "audioSampleRateMismatch" + #[serde(rename="audioSampleRateMismatch")] + AudioSampleRateMismatch, + + /// "audioStereoMismatch" + #[serde(rename="audioStereoMismatch")] + AudioStereoMismatch, + + /// "audioCodecMismatch" + #[serde(rename="audioCodecMismatch")] + AudioCodecMismatch, + + /// "audioBitrateMismatch" + #[serde(rename="audioBitrateMismatch")] + AudioBitrateMismatch, + + /// "videoResolutionSuboptimal" + #[serde(rename="videoResolutionSuboptimal")] + VideoResolutionSuboptimal, + + /// "videoResolutionUnsupported" + #[serde(rename="videoResolutionUnsupported")] + VideoResolutionUnsupported, + + /// "videoIngestionStarved" + #[serde(rename="videoIngestionStarved")] + VideoIngestionStarved, + + /// "videoIngestionFasterThanRealtime" + #[serde(rename="videoIngestionFasterThanRealtime")] + VideoIngestionFasterThanRealtime, +} + +impl AsRef for LiveStreamConfigurationIssueTypeEnum { + fn as_ref(&self) -> &str { + match *self { + LiveStreamConfigurationIssueTypeEnum::GopSizeOver => "gopSizeOver", + LiveStreamConfigurationIssueTypeEnum::GopSizeLong => "gopSizeLong", + LiveStreamConfigurationIssueTypeEnum::GopSizeShort => "gopSizeShort", + LiveStreamConfigurationIssueTypeEnum::OpenGop => "openGop", + LiveStreamConfigurationIssueTypeEnum::BadContainer => "badContainer", + LiveStreamConfigurationIssueTypeEnum::AudioBitrateHigh => "audioBitrateHigh", + LiveStreamConfigurationIssueTypeEnum::AudioBitrateLow => "audioBitrateLow", + LiveStreamConfigurationIssueTypeEnum::AudioSampleRate => "audioSampleRate", + LiveStreamConfigurationIssueTypeEnum::BitrateHigh => "bitrateHigh", + LiveStreamConfigurationIssueTypeEnum::BitrateLow => "bitrateLow", + LiveStreamConfigurationIssueTypeEnum::AudioCodec => "audioCodec", + LiveStreamConfigurationIssueTypeEnum::VideoCodec => "videoCodec", + LiveStreamConfigurationIssueTypeEnum::NoAudioStream => "noAudioStream", + LiveStreamConfigurationIssueTypeEnum::NoVideoStream => "noVideoStream", + LiveStreamConfigurationIssueTypeEnum::MultipleVideoStreams => "multipleVideoStreams", + LiveStreamConfigurationIssueTypeEnum::MultipleAudioStreams => "multipleAudioStreams", + LiveStreamConfigurationIssueTypeEnum::AudioTooManyChannels => "audioTooManyChannels", + LiveStreamConfigurationIssueTypeEnum::InterlacedVideo => "interlacedVideo", + LiveStreamConfigurationIssueTypeEnum::FrameRateHigh => "frameRateHigh", + LiveStreamConfigurationIssueTypeEnum::ResolutionMismatch => "resolutionMismatch", + LiveStreamConfigurationIssueTypeEnum::VideoCodecMismatch => "videoCodecMismatch", + LiveStreamConfigurationIssueTypeEnum::VideoInterlaceMismatch => "videoInterlaceMismatch", + LiveStreamConfigurationIssueTypeEnum::VideoProfileMismatch => "videoProfileMismatch", + LiveStreamConfigurationIssueTypeEnum::VideoBitrateMismatch => "videoBitrateMismatch", + LiveStreamConfigurationIssueTypeEnum::FramerateMismatch => "framerateMismatch", + LiveStreamConfigurationIssueTypeEnum::GopMismatch => "gopMismatch", + LiveStreamConfigurationIssueTypeEnum::AudioSampleRateMismatch => "audioSampleRateMismatch", + LiveStreamConfigurationIssueTypeEnum::AudioStereoMismatch => "audioStereoMismatch", + LiveStreamConfigurationIssueTypeEnum::AudioCodecMismatch => "audioCodecMismatch", + LiveStreamConfigurationIssueTypeEnum::AudioBitrateMismatch => "audioBitrateMismatch", + LiveStreamConfigurationIssueTypeEnum::VideoResolutionSuboptimal => "videoResolutionSuboptimal", + LiveStreamConfigurationIssueTypeEnum::VideoResolutionUnsupported => "videoResolutionUnsupported", + LiveStreamConfigurationIssueTypeEnum::VideoIngestionStarved => "videoIngestionStarved", + LiveStreamConfigurationIssueTypeEnum::VideoIngestionFasterThanRealtime => "videoIngestionFasterThanRealtime", + } + } +} + +impl std::convert::TryFrom< &str> for LiveStreamConfigurationIssueTypeEnum { + type Error = (); + fn try_from(value: &str) -> Result { + match value { + "gopSizeOver" => Ok(LiveStreamConfigurationIssueTypeEnum::GopSizeOver), + "gopSizeLong" => Ok(LiveStreamConfigurationIssueTypeEnum::GopSizeLong), + "gopSizeShort" => Ok(LiveStreamConfigurationIssueTypeEnum::GopSizeShort), + "openGop" => Ok(LiveStreamConfigurationIssueTypeEnum::OpenGop), + "badContainer" => Ok(LiveStreamConfigurationIssueTypeEnum::BadContainer), + "audioBitrateHigh" => Ok(LiveStreamConfigurationIssueTypeEnum::AudioBitrateHigh), + "audioBitrateLow" => Ok(LiveStreamConfigurationIssueTypeEnum::AudioBitrateLow), + "audioSampleRate" => Ok(LiveStreamConfigurationIssueTypeEnum::AudioSampleRate), + "bitrateHigh" => Ok(LiveStreamConfigurationIssueTypeEnum::BitrateHigh), + "bitrateLow" => Ok(LiveStreamConfigurationIssueTypeEnum::BitrateLow), + "audioCodec" => Ok(LiveStreamConfigurationIssueTypeEnum::AudioCodec), + "videoCodec" => Ok(LiveStreamConfigurationIssueTypeEnum::VideoCodec), + "noAudioStream" => Ok(LiveStreamConfigurationIssueTypeEnum::NoAudioStream), + "noVideoStream" => Ok(LiveStreamConfigurationIssueTypeEnum::NoVideoStream), + "multipleVideoStreams" => Ok(LiveStreamConfigurationIssueTypeEnum::MultipleVideoStreams), + "multipleAudioStreams" => Ok(LiveStreamConfigurationIssueTypeEnum::MultipleAudioStreams), + "audioTooManyChannels" => Ok(LiveStreamConfigurationIssueTypeEnum::AudioTooManyChannels), + "interlacedVideo" => Ok(LiveStreamConfigurationIssueTypeEnum::InterlacedVideo), + "frameRateHigh" => Ok(LiveStreamConfigurationIssueTypeEnum::FrameRateHigh), + "resolutionMismatch" => Ok(LiveStreamConfigurationIssueTypeEnum::ResolutionMismatch), + "videoCodecMismatch" => Ok(LiveStreamConfigurationIssueTypeEnum::VideoCodecMismatch), + "videoInterlaceMismatch" => Ok(LiveStreamConfigurationIssueTypeEnum::VideoInterlaceMismatch), + "videoProfileMismatch" => Ok(LiveStreamConfigurationIssueTypeEnum::VideoProfileMismatch), + "videoBitrateMismatch" => Ok(LiveStreamConfigurationIssueTypeEnum::VideoBitrateMismatch), + "framerateMismatch" => Ok(LiveStreamConfigurationIssueTypeEnum::FramerateMismatch), + "gopMismatch" => Ok(LiveStreamConfigurationIssueTypeEnum::GopMismatch), + "audioSampleRateMismatch" => Ok(LiveStreamConfigurationIssueTypeEnum::AudioSampleRateMismatch), + "audioStereoMismatch" => Ok(LiveStreamConfigurationIssueTypeEnum::AudioStereoMismatch), + "audioCodecMismatch" => Ok(LiveStreamConfigurationIssueTypeEnum::AudioCodecMismatch), + "audioBitrateMismatch" => Ok(LiveStreamConfigurationIssueTypeEnum::AudioBitrateMismatch), + "videoResolutionSuboptimal" => Ok(LiveStreamConfigurationIssueTypeEnum::VideoResolutionSuboptimal), + "videoResolutionUnsupported" => Ok(LiveStreamConfigurationIssueTypeEnum::VideoResolutionUnsupported), + "videoIngestionStarved" => Ok(LiveStreamConfigurationIssueTypeEnum::VideoIngestionStarved), + "videoIngestionFasterThanRealtime" => Ok(LiveStreamConfigurationIssueTypeEnum::VideoIngestionFasterThanRealtime), + _=> Err(()), + } + } +} + +impl<'a> Into> for &'a LiveStreamConfigurationIssueTypeEnum { + fn into(self) -> std::borrow::Cow<'a, str> { + self.as_ref().into() + } +} + + +#[derive(Clone, Copy, Eq, Hash, Debug, PartialEq, Serialize, Deserialize)] +/// The status code of this stream +pub enum LiveStreamHealthStatusStatusEnum { + + /// "good" + #[serde(rename="good")] + Good, + + /// "ok" + #[serde(rename="ok")] + Ok, + + /// "bad" + #[serde(rename="bad")] + Bad, + + /// "noData" + #[serde(rename="noData")] + NoData, + + /// "revoked" + #[serde(rename="revoked")] + Revoked, +} + +impl AsRef for LiveStreamHealthStatusStatusEnum { + fn as_ref(&self) -> &str { + match *self { + LiveStreamHealthStatusStatusEnum::Good => "good", + LiveStreamHealthStatusStatusEnum::Ok => "ok", + LiveStreamHealthStatusStatusEnum::Bad => "bad", + LiveStreamHealthStatusStatusEnum::NoData => "noData", + LiveStreamHealthStatusStatusEnum::Revoked => "revoked", + } + } +} + +impl std::convert::TryFrom< &str> for LiveStreamHealthStatusStatusEnum { + type Error = (); + fn try_from(value: &str) -> Result { + match value { + "good" => Ok(LiveStreamHealthStatusStatusEnum::Good), + "ok" => Ok(LiveStreamHealthStatusStatusEnum::Ok), + "bad" => Ok(LiveStreamHealthStatusStatusEnum::Bad), + "noData" => Ok(LiveStreamHealthStatusStatusEnum::NoData), + "revoked" => Ok(LiveStreamHealthStatusStatusEnum::Revoked), + _=> Err(()), + } + } +} + +impl<'a> Into> for &'a LiveStreamHealthStatusStatusEnum { + fn into(self) -> std::borrow::Cow<'a, str> { + self.as_ref().into() + } +} + + +#[derive(Clone, Copy, Eq, Hash, Debug, PartialEq, Serialize, Deserialize)] +pub enum LiveStreamStatusStreamStatusEnum { + + /// "created" + #[serde(rename="created")] + Created, + + /// "ready" + #[serde(rename="ready")] + Ready, + + /// "active" + #[serde(rename="active")] + Active, + + /// "inactive" + #[serde(rename="inactive")] + Inactive, + + /// "error" + #[serde(rename="error")] + Error, +} + +impl AsRef for LiveStreamStatusStreamStatusEnum { + fn as_ref(&self) -> &str { + match *self { + LiveStreamStatusStreamStatusEnum::Created => "created", + LiveStreamStatusStreamStatusEnum::Ready => "ready", + LiveStreamStatusStreamStatusEnum::Active => "active", + LiveStreamStatusStreamStatusEnum::Inactive => "inactive", + LiveStreamStatusStreamStatusEnum::Error => "error", + } + } +} + +impl std::convert::TryFrom< &str> for LiveStreamStatusStreamStatusEnum { + type Error = (); + fn try_from(value: &str) -> Result { + match value { + "created" => Ok(LiveStreamStatusStreamStatusEnum::Created), + "ready" => Ok(LiveStreamStatusStreamStatusEnum::Ready), + "active" => Ok(LiveStreamStatusStreamStatusEnum::Active), + "inactive" => Ok(LiveStreamStatusStreamStatusEnum::Inactive), + "error" => Ok(LiveStreamStatusStreamStatusEnum::Error), + _=> Err(()), + } + } +} + +impl<'a> Into> for &'a LiveStreamStatusStreamStatusEnum { + fn into(self) -> std::borrow::Cow<'a, str> { + self.as_ref().into() + } +} + + +#[derive(Clone, Copy, Eq, Hash, Debug, PartialEq, Serialize, Deserialize)] +/// The image type. +pub enum PlaylistImageSnippetTypeEnum { + + + /// The main image that will be used for this playlist. + /// + /// "hero" + #[serde(rename="hero")] + Hero, +} + +impl AsRef for PlaylistImageSnippetTypeEnum { + fn as_ref(&self) -> &str { + match *self { + PlaylistImageSnippetTypeEnum::Hero => "hero", + } + } +} + +impl std::convert::TryFrom< &str> for PlaylistImageSnippetTypeEnum { + type Error = (); + fn try_from(value: &str) -> Result { + match value { + "hero" => Ok(PlaylistImageSnippetTypeEnum::Hero), + _=> Err(()), + } + } +} + +impl<'a> Into> for &'a PlaylistImageSnippetTypeEnum { + fn into(self) -> std::borrow::Cow<'a, str> { + self.as_ref().into() + } +} + + +#[derive(Clone, Copy, Eq, Hash, Debug, PartialEq, Serialize, Deserialize)] +/// This resource's privacy status. +pub enum PlaylistItemStatusPrivacyStatusEnum { + + /// "public" + #[serde(rename="public")] + Public, + + /// "unlisted" + #[serde(rename="unlisted")] + Unlisted, + + /// "private" + #[serde(rename="private")] + Private, +} + +impl AsRef for PlaylistItemStatusPrivacyStatusEnum { + fn as_ref(&self) -> &str { + match *self { + PlaylistItemStatusPrivacyStatusEnum::Public => "public", + PlaylistItemStatusPrivacyStatusEnum::Unlisted => "unlisted", + PlaylistItemStatusPrivacyStatusEnum::Private => "private", + } + } +} + +impl std::convert::TryFrom< &str> for PlaylistItemStatusPrivacyStatusEnum { + type Error = (); + fn try_from(value: &str) -> Result { + match value { + "public" => Ok(PlaylistItemStatusPrivacyStatusEnum::Public), + "unlisted" => Ok(PlaylistItemStatusPrivacyStatusEnum::Unlisted), + "private" => Ok(PlaylistItemStatusPrivacyStatusEnum::Private), + _=> Err(()), + } + } +} + +impl<'a> Into> for &'a PlaylistItemStatusPrivacyStatusEnum { + fn into(self) -> std::borrow::Cow<'a, str> { + self.as_ref().into() + } +} + + +#[derive(Clone, Copy, Eq, Hash, Debug, PartialEq, Serialize, Deserialize)] +/// The playlist's privacy status. +pub enum PlaylistStatusPrivacyStatusEnum { + + /// "public" + #[serde(rename="public")] + Public, + + /// "unlisted" + #[serde(rename="unlisted")] + Unlisted, + + /// "private" + #[serde(rename="private")] + Private, +} + +impl AsRef for PlaylistStatusPrivacyStatusEnum { + fn as_ref(&self) -> &str { + match *self { + PlaylistStatusPrivacyStatusEnum::Public => "public", + PlaylistStatusPrivacyStatusEnum::Unlisted => "unlisted", + PlaylistStatusPrivacyStatusEnum::Private => "private", + } + } +} + +impl std::convert::TryFrom< &str> for PlaylistStatusPrivacyStatusEnum { + type Error = (); + fn try_from(value: &str) -> Result { + match value { + "public" => Ok(PlaylistStatusPrivacyStatusEnum::Public), + "unlisted" => Ok(PlaylistStatusPrivacyStatusEnum::Unlisted), + "private" => Ok(PlaylistStatusPrivacyStatusEnum::Private), + _=> Err(()), + } + } +} + +impl<'a> Into> for &'a PlaylistStatusPrivacyStatusEnum { + fn into(self) -> std::borrow::Cow<'a, str> { + self.as_ref().into() + } +} + + +#[derive(Clone, Copy, Eq, Hash, Debug, PartialEq, Serialize, Deserialize)] +/// It indicates if the resource (video or channel) has upcoming/active live broadcast content. Or it's "none" if there is not any upcoming/active live broadcasts. +pub enum SearchResultSnippetLiveBroadcastContentEnum { + + /// "none" + #[serde(rename="none")] + None, + + + /// The live broadcast is upcoming. + /// + /// "upcoming" + #[serde(rename="upcoming")] + Upcoming, + + + /// The live broadcast is active. + /// + /// "live" + #[serde(rename="live")] + Live, + + + /// The live broadcast has been completed. + /// + /// "completed" + #[serde(rename="completed")] + Completed, +} + +impl AsRef for SearchResultSnippetLiveBroadcastContentEnum { + fn as_ref(&self) -> &str { + match *self { + SearchResultSnippetLiveBroadcastContentEnum::None => "none", + SearchResultSnippetLiveBroadcastContentEnum::Upcoming => "upcoming", + SearchResultSnippetLiveBroadcastContentEnum::Live => "live", + SearchResultSnippetLiveBroadcastContentEnum::Completed => "completed", + } + } +} + +impl std::convert::TryFrom< &str> for SearchResultSnippetLiveBroadcastContentEnum { + type Error = (); + fn try_from(value: &str) -> Result { + match value { + "none" => Ok(SearchResultSnippetLiveBroadcastContentEnum::None), + "upcoming" => Ok(SearchResultSnippetLiveBroadcastContentEnum::Upcoming), + "live" => Ok(SearchResultSnippetLiveBroadcastContentEnum::Live), + "completed" => Ok(SearchResultSnippetLiveBroadcastContentEnum::Completed), + _=> Err(()), + } + } +} + +impl<'a> Into> for &'a SearchResultSnippetLiveBroadcastContentEnum { + fn into(self) -> std::borrow::Cow<'a, str> { + self.as_ref().into() + } +} + + +#[derive(Clone, Copy, Eq, Hash, Debug, PartialEq, Serialize, Deserialize)] +/// The type of activity this subscription is for (only uploads, everything). +pub enum SubscriptionContentDetailActivityTypeEnum { + + /// "subscriptionActivityTypeUnspecified" + #[serde(rename="subscriptionActivityTypeUnspecified")] + SubscriptionActivityTypeUnspecified, + + /// "all" + #[serde(rename="all")] + All, + + /// "uploads" + #[serde(rename="uploads")] + Uploads, +} + +impl AsRef for SubscriptionContentDetailActivityTypeEnum { + fn as_ref(&self) -> &str { + match *self { + SubscriptionContentDetailActivityTypeEnum::SubscriptionActivityTypeUnspecified => "subscriptionActivityTypeUnspecified", + SubscriptionContentDetailActivityTypeEnum::All => "all", + SubscriptionContentDetailActivityTypeEnum::Uploads => "uploads", + } + } +} + +impl std::convert::TryFrom< &str> for SubscriptionContentDetailActivityTypeEnum { + type Error = (); + fn try_from(value: &str) -> Result { + match value { + "subscriptionActivityTypeUnspecified" => Ok(SubscriptionContentDetailActivityTypeEnum::SubscriptionActivityTypeUnspecified), + "all" => Ok(SubscriptionContentDetailActivityTypeEnum::All), + "uploads" => Ok(SubscriptionContentDetailActivityTypeEnum::Uploads), + _=> Err(()), + } + } +} + +impl<'a> Into> for &'a SubscriptionContentDetailActivityTypeEnum { + fn into(self) -> std::borrow::Cow<'a, str> { + self.as_ref().into() + } +} + + +#[derive(Clone, Copy, Eq, Hash, Debug, PartialEq, Serialize, Deserialize)] +/// Type of the link named after the entities that are being linked. +pub enum ThirdPartyLinkSnippetTypeEnum { + + /// "linkUnspecified" + #[serde(rename="linkUnspecified")] + LinkUnspecified, + + + /// A link that is connecting (or about to connect) a channel with a store on a merchandising platform in order to enable retail commerce capabilities for that channel on YouTube. + /// + /// "channelToStoreLink" + #[serde(rename="channelToStoreLink")] + ChannelToStoreLink, +} + +impl AsRef for ThirdPartyLinkSnippetTypeEnum { + fn as_ref(&self) -> &str { + match *self { + ThirdPartyLinkSnippetTypeEnum::LinkUnspecified => "linkUnspecified", + ThirdPartyLinkSnippetTypeEnum::ChannelToStoreLink => "channelToStoreLink", + } + } +} + +impl std::convert::TryFrom< &str> for ThirdPartyLinkSnippetTypeEnum { + type Error = (); + fn try_from(value: &str) -> Result { + match value { + "linkUnspecified" => Ok(ThirdPartyLinkSnippetTypeEnum::LinkUnspecified), + "channelToStoreLink" => Ok(ThirdPartyLinkSnippetTypeEnum::ChannelToStoreLink), + _=> Err(()), + } + } +} + +impl<'a> Into> for &'a ThirdPartyLinkSnippetTypeEnum { + fn into(self) -> std::borrow::Cow<'a, str> { + self.as_ref().into() + } +} + + +#[derive(Clone, Copy, Eq, Hash, Debug, PartialEq, Serialize, Deserialize)] +pub enum ThirdPartyLinkStatusLinkStatusEnum { + + /// "unknown" + #[serde(rename="unknown")] + Unknown, + + /// "failed" + #[serde(rename="failed")] + Failed, + + /// "pending" + #[serde(rename="pending")] + Pending, + + /// "linked" + #[serde(rename="linked")] + Linked, +} + +impl AsRef for ThirdPartyLinkStatusLinkStatusEnum { + fn as_ref(&self) -> &str { + match *self { + ThirdPartyLinkStatusLinkStatusEnum::Unknown => "unknown", + ThirdPartyLinkStatusLinkStatusEnum::Failed => "failed", + ThirdPartyLinkStatusLinkStatusEnum::Pending => "pending", + ThirdPartyLinkStatusLinkStatusEnum::Linked => "linked", + } + } +} + +impl std::convert::TryFrom< &str> for ThirdPartyLinkStatusLinkStatusEnum { + type Error = (); + fn try_from(value: &str) -> Result { + match value { + "unknown" => Ok(ThirdPartyLinkStatusLinkStatusEnum::Unknown), + "failed" => Ok(ThirdPartyLinkStatusLinkStatusEnum::Failed), + "pending" => Ok(ThirdPartyLinkStatusLinkStatusEnum::Pending), + "linked" => Ok(ThirdPartyLinkStatusLinkStatusEnum::Linked), + _=> Err(()), + } + } +} + +impl<'a> Into> for &'a ThirdPartyLinkStatusLinkStatusEnum { + fn into(self) -> std::borrow::Cow<'a, str> { + self.as_ref().into() + } +} + + +#[derive(Clone, Copy, Eq, Hash, Debug, PartialEq, Serialize, Deserialize)] +/// Video game rating, if any. +pub enum VideoAgeGatingVideoGameRatingEnum { + + /// "anyone" + #[serde(rename="anyone")] + Anyone, + + /// "m15Plus" + #[serde(rename="m15Plus")] + M15Plus, + + /// "m16Plus" + #[serde(rename="m16Plus")] + M16Plus, + + /// "m17Plus" + #[serde(rename="m17Plus")] + M17Plus, +} + +impl AsRef for VideoAgeGatingVideoGameRatingEnum { + fn as_ref(&self) -> &str { + match *self { + VideoAgeGatingVideoGameRatingEnum::Anyone => "anyone", + VideoAgeGatingVideoGameRatingEnum::M15Plus => "m15Plus", + VideoAgeGatingVideoGameRatingEnum::M16Plus => "m16Plus", + VideoAgeGatingVideoGameRatingEnum::M17Plus => "m17Plus", + } + } +} + +impl std::convert::TryFrom< &str> for VideoAgeGatingVideoGameRatingEnum { + type Error = (); + fn try_from(value: &str) -> Result { + match value { + "anyone" => Ok(VideoAgeGatingVideoGameRatingEnum::Anyone), + "m15Plus" => Ok(VideoAgeGatingVideoGameRatingEnum::M15Plus), + "m16Plus" => Ok(VideoAgeGatingVideoGameRatingEnum::M16Plus), + "m17Plus" => Ok(VideoAgeGatingVideoGameRatingEnum::M17Plus), + _=> Err(()), + } + } +} + +impl<'a> Into> for &'a VideoAgeGatingVideoGameRatingEnum { + fn into(self) -> std::borrow::Cow<'a, str> { + self.as_ref().into() + } +} + + +#[derive(Clone, Copy, Eq, Hash, Debug, PartialEq, Serialize, Deserialize)] +/// The value of captions indicates whether the video has captions or not. +pub enum VideoContentDetailCaptionEnum { + + /// "true" + #[serde(rename="true")] + True, + + /// "false" + #[serde(rename="false")] + False, +} + +impl AsRef for VideoContentDetailCaptionEnum { + fn as_ref(&self) -> &str { + match *self { + VideoContentDetailCaptionEnum::True => "true", + VideoContentDetailCaptionEnum::False => "false", + } + } +} + +impl std::convert::TryFrom< &str> for VideoContentDetailCaptionEnum { + type Error = (); + fn try_from(value: &str) -> Result { + match value { + "true" => Ok(VideoContentDetailCaptionEnum::True), + "false" => Ok(VideoContentDetailCaptionEnum::False), + _=> Err(()), + } + } +} + +impl<'a> Into> for &'a VideoContentDetailCaptionEnum { + fn into(self) -> std::borrow::Cow<'a, str> { + self.as_ref().into() + } +} + + +#[derive(Clone, Copy, Eq, Hash, Debug, PartialEq, Serialize, Deserialize)] +/// The value of definition indicates whether the video is available in high definition or only in standard definition. +pub enum VideoContentDetailDefinitionEnum { + + + /// sd + /// + /// "sd" + #[serde(rename="sd")] + Sd, + + + /// hd + /// + /// "hd" + #[serde(rename="hd")] + Hd, +} + +impl AsRef for VideoContentDetailDefinitionEnum { + fn as_ref(&self) -> &str { + match *self { + VideoContentDetailDefinitionEnum::Sd => "sd", + VideoContentDetailDefinitionEnum::Hd => "hd", + } + } +} + +impl std::convert::TryFrom< &str> for VideoContentDetailDefinitionEnum { + type Error = (); + fn try_from(value: &str) -> Result { + match value { + "sd" => Ok(VideoContentDetailDefinitionEnum::Sd), + "hd" => Ok(VideoContentDetailDefinitionEnum::Hd), + _=> Err(()), + } + } +} + +impl<'a> Into> for &'a VideoContentDetailDefinitionEnum { + fn into(self) -> std::borrow::Cow<'a, str> { + self.as_ref().into() + } +} + + +#[derive(Clone, Copy, Eq, Hash, Debug, PartialEq, Serialize, Deserialize)] +/// Specifies the projection format of the video. +pub enum VideoContentDetailProjectionEnum { + + /// "rectangular" + #[serde(rename="rectangular")] + Rectangular, + + /// "360" + #[serde(rename="360")] + _360, +} + +impl AsRef for VideoContentDetailProjectionEnum { + fn as_ref(&self) -> &str { + match *self { + VideoContentDetailProjectionEnum::Rectangular => "rectangular", + VideoContentDetailProjectionEnum::_360 => "360", + } + } +} + +impl std::convert::TryFrom< &str> for VideoContentDetailProjectionEnum { + type Error = (); + fn try_from(value: &str) -> Result { + match value { + "rectangular" => Ok(VideoContentDetailProjectionEnum::Rectangular), + "360" => Ok(VideoContentDetailProjectionEnum::_360), + _=> Err(()), + } + } +} + +impl<'a> Into> for &'a VideoContentDetailProjectionEnum { + fn into(self) -> std::borrow::Cow<'a, str> { + self.as_ref().into() + } +} + + +#[derive(Clone, Copy, Eq, Hash, Debug, PartialEq, Serialize, Deserialize)] +/// The uploaded file's type as detected by YouTube's video processing engine. Currently, YouTube only processes video files, but this field is present whether a video file or another type of file was uploaded. +pub enum VideoFileDetailFileTypeEnum { + + + /// Known video file (e.g., an MP4 file). + /// + /// "video" + #[serde(rename="video")] + Video, + + + /// Audio only file (e.g., an MP3 file). + /// + /// "audio" + #[serde(rename="audio")] + Audio, + + + /// Image file (e.g., a JPEG image). + /// + /// "image" + #[serde(rename="image")] + Image, + + + /// Archive file (e.g., a ZIP archive). + /// + /// "archive" + #[serde(rename="archive")] + Archive, + + + /// Document or text file (e.g., MS Word document). + /// + /// "document" + #[serde(rename="document")] + Document, + + + /// Movie project file (e.g., Microsoft Windows Movie Maker project). + /// + /// "project" + #[serde(rename="project")] + Project, + + + /// Other non-video file type. + /// + /// "other" + #[serde(rename="other")] + Other, +} + +impl AsRef for VideoFileDetailFileTypeEnum { + fn as_ref(&self) -> &str { + match *self { + VideoFileDetailFileTypeEnum::Video => "video", + VideoFileDetailFileTypeEnum::Audio => "audio", + VideoFileDetailFileTypeEnum::Image => "image", + VideoFileDetailFileTypeEnum::Archive => "archive", + VideoFileDetailFileTypeEnum::Document => "document", + VideoFileDetailFileTypeEnum::Project => "project", + VideoFileDetailFileTypeEnum::Other => "other", + } + } +} + +impl std::convert::TryFrom< &str> for VideoFileDetailFileTypeEnum { + type Error = (); + fn try_from(value: &str) -> Result { + match value { + "video" => Ok(VideoFileDetailFileTypeEnum::Video), + "audio" => Ok(VideoFileDetailFileTypeEnum::Audio), + "image" => Ok(VideoFileDetailFileTypeEnum::Image), + "archive" => Ok(VideoFileDetailFileTypeEnum::Archive), + "document" => Ok(VideoFileDetailFileTypeEnum::Document), + "project" => Ok(VideoFileDetailFileTypeEnum::Project), + "other" => Ok(VideoFileDetailFileTypeEnum::Other), + _=> Err(()), + } + } +} + +impl<'a> Into> for &'a VideoFileDetailFileTypeEnum { + fn into(self) -> std::borrow::Cow<'a, str> { + self.as_ref().into() + } +} + + +#[derive(Clone, Copy, Eq, Hash, Debug, PartialEq, Serialize, Deserialize)] +/// The amount that YouTube needs to rotate the original source content to properly display the video. +pub enum VideoFileDetailsVideoStreamRotationEnum { + + /// "none" + #[serde(rename="none")] + None, + + /// "clockwise" + #[serde(rename="clockwise")] + Clockwise, + + /// "upsideDown" + #[serde(rename="upsideDown")] + UpsideDown, + + /// "counterClockwise" + #[serde(rename="counterClockwise")] + CounterClockwise, + + /// "other" + #[serde(rename="other")] + Other, +} + +impl AsRef for VideoFileDetailsVideoStreamRotationEnum { + fn as_ref(&self) -> &str { + match *self { + VideoFileDetailsVideoStreamRotationEnum::None => "none", + VideoFileDetailsVideoStreamRotationEnum::Clockwise => "clockwise", + VideoFileDetailsVideoStreamRotationEnum::UpsideDown => "upsideDown", + VideoFileDetailsVideoStreamRotationEnum::CounterClockwise => "counterClockwise", + VideoFileDetailsVideoStreamRotationEnum::Other => "other", + } + } +} + +impl std::convert::TryFrom< &str> for VideoFileDetailsVideoStreamRotationEnum { + type Error = (); + fn try_from(value: &str) -> Result { + match value { + "none" => Ok(VideoFileDetailsVideoStreamRotationEnum::None), + "clockwise" => Ok(VideoFileDetailsVideoStreamRotationEnum::Clockwise), + "upsideDown" => Ok(VideoFileDetailsVideoStreamRotationEnum::UpsideDown), + "counterClockwise" => Ok(VideoFileDetailsVideoStreamRotationEnum::CounterClockwise), + "other" => Ok(VideoFileDetailsVideoStreamRotationEnum::Other), + _=> Err(()), + } + } +} + +impl<'a> Into> for &'a VideoFileDetailsVideoStreamRotationEnum { + fn into(self) -> std::borrow::Cow<'a, str> { + self.as_ref().into() + } +} + + +#[derive(Clone, Copy, Eq, Hash, Debug, PartialEq, Serialize, Deserialize)] +/// The reason that YouTube failed to process the video. This property will only have a value if the processingStatus property's value is failed. +pub enum VideoProcessingDetailProcessingFailureReasonEnum { + + /// "uploadFailed" + #[serde(rename="uploadFailed")] + UploadFailed, + + /// "transcodeFailed" + #[serde(rename="transcodeFailed")] + TranscodeFailed, + + /// "streamingFailed" + #[serde(rename="streamingFailed")] + StreamingFailed, + + /// "other" + #[serde(rename="other")] + Other, +} + +impl AsRef for VideoProcessingDetailProcessingFailureReasonEnum { + fn as_ref(&self) -> &str { + match *self { + VideoProcessingDetailProcessingFailureReasonEnum::UploadFailed => "uploadFailed", + VideoProcessingDetailProcessingFailureReasonEnum::TranscodeFailed => "transcodeFailed", + VideoProcessingDetailProcessingFailureReasonEnum::StreamingFailed => "streamingFailed", + VideoProcessingDetailProcessingFailureReasonEnum::Other => "other", + } + } +} + +impl std::convert::TryFrom< &str> for VideoProcessingDetailProcessingFailureReasonEnum { + type Error = (); + fn try_from(value: &str) -> Result { + match value { + "uploadFailed" => Ok(VideoProcessingDetailProcessingFailureReasonEnum::UploadFailed), + "transcodeFailed" => Ok(VideoProcessingDetailProcessingFailureReasonEnum::TranscodeFailed), + "streamingFailed" => Ok(VideoProcessingDetailProcessingFailureReasonEnum::StreamingFailed), + "other" => Ok(VideoProcessingDetailProcessingFailureReasonEnum::Other), + _=> Err(()), + } + } +} + +impl<'a> Into> for &'a VideoProcessingDetailProcessingFailureReasonEnum { + fn into(self) -> std::borrow::Cow<'a, str> { + self.as_ref().into() + } +} + + +#[derive(Clone, Copy, Eq, Hash, Debug, PartialEq, Serialize, Deserialize)] +/// The video's processing status. This value indicates whether YouTube was able to process the video or if the video is still being processed. +pub enum VideoProcessingDetailProcessingStatusEnum { + + /// "processing" + #[serde(rename="processing")] + Processing, + + /// "succeeded" + #[serde(rename="succeeded")] + Succeeded, + + /// "failed" + #[serde(rename="failed")] + Failed, + + /// "terminated" + #[serde(rename="terminated")] + Terminated, +} + +impl AsRef for VideoProcessingDetailProcessingStatusEnum { + fn as_ref(&self) -> &str { + match *self { + VideoProcessingDetailProcessingStatusEnum::Processing => "processing", + VideoProcessingDetailProcessingStatusEnum::Succeeded => "succeeded", + VideoProcessingDetailProcessingStatusEnum::Failed => "failed", + VideoProcessingDetailProcessingStatusEnum::Terminated => "terminated", + } + } +} + +impl std::convert::TryFrom< &str> for VideoProcessingDetailProcessingStatusEnum { + type Error = (); + fn try_from(value: &str) -> Result { + match value { + "processing" => Ok(VideoProcessingDetailProcessingStatusEnum::Processing), + "succeeded" => Ok(VideoProcessingDetailProcessingStatusEnum::Succeeded), + "failed" => Ok(VideoProcessingDetailProcessingStatusEnum::Failed), + "terminated" => Ok(VideoProcessingDetailProcessingStatusEnum::Terminated), + _=> Err(()), + } + } +} + +impl<'a> Into> for &'a VideoProcessingDetailProcessingStatusEnum { + fn into(self) -> std::borrow::Cow<'a, str> { + self.as_ref().into() + } +} + + +#[derive(Clone, Copy, Eq, Hash, Debug, PartialEq, Serialize, Deserialize)] +/// Rating of a video. +pub enum VideoRatingRatingEnum { + + /// "none" + #[serde(rename="none")] + None, + + + /// The entity is liked. + /// + /// "like" + #[serde(rename="like")] + Like, + + + /// The entity is disliked. + /// + /// "dislike" + #[serde(rename="dislike")] + Dislike, +} + +impl AsRef for VideoRatingRatingEnum { + fn as_ref(&self) -> &str { + match *self { + VideoRatingRatingEnum::None => "none", + VideoRatingRatingEnum::Like => "like", + VideoRatingRatingEnum::Dislike => "dislike", + } + } +} + +impl std::convert::TryFrom< &str> for VideoRatingRatingEnum { + type Error = (); + fn try_from(value: &str) -> Result { + match value { + "none" => Ok(VideoRatingRatingEnum::None), + "like" => Ok(VideoRatingRatingEnum::Like), + "dislike" => Ok(VideoRatingRatingEnum::Dislike), + _=> Err(()), + } + } +} + +impl<'a> Into> for &'a VideoRatingRatingEnum { + fn into(self) -> std::borrow::Cow<'a, str> { + self.as_ref().into() + } +} + + +#[derive(Clone, Copy, Eq, Hash, Debug, PartialEq, Serialize, Deserialize)] +/// Indicates if the video is an upcoming/active live broadcast. Or it's "none" if the video is not an upcoming/active live broadcast. +pub enum VideoSnippetLiveBroadcastContentEnum { + + /// "none" + #[serde(rename="none")] + None, + + + /// The live broadcast is upcoming. + /// + /// "upcoming" + #[serde(rename="upcoming")] + Upcoming, + + + /// The live broadcast is active. + /// + /// "live" + #[serde(rename="live")] + Live, + + + /// The live broadcast has been completed. + /// + /// "completed" + #[serde(rename="completed")] + Completed, +} + +impl AsRef for VideoSnippetLiveBroadcastContentEnum { + fn as_ref(&self) -> &str { + match *self { + VideoSnippetLiveBroadcastContentEnum::None => "none", + VideoSnippetLiveBroadcastContentEnum::Upcoming => "upcoming", + VideoSnippetLiveBroadcastContentEnum::Live => "live", + VideoSnippetLiveBroadcastContentEnum::Completed => "completed", + } + } +} + +impl std::convert::TryFrom< &str> for VideoSnippetLiveBroadcastContentEnum { + type Error = (); + fn try_from(value: &str) -> Result { + match value { + "none" => Ok(VideoSnippetLiveBroadcastContentEnum::None), + "upcoming" => Ok(VideoSnippetLiveBroadcastContentEnum::Upcoming), + "live" => Ok(VideoSnippetLiveBroadcastContentEnum::Live), + "completed" => Ok(VideoSnippetLiveBroadcastContentEnum::Completed), + _=> Err(()), + } + } +} + +impl<'a> Into> for &'a VideoSnippetLiveBroadcastContentEnum { + fn into(self) -> std::borrow::Cow<'a, str> { + self.as_ref().into() + } +} + + +#[derive(Clone, Copy, Eq, Hash, Debug, PartialEq, Serialize, Deserialize)] +/// This value explains why a video failed to upload. This property is only present if the uploadStatus property indicates that the upload failed. +pub enum VideoStatusFailureReasonEnum { + + + /// Unable to convert video content. + /// + /// "conversion" + #[serde(rename="conversion")] + Conversion, + + + /// Invalid file format. + /// + /// "invalidFile" + #[serde(rename="invalidFile")] + InvalidFile, + + + /// Empty file. + /// + /// "emptyFile" + #[serde(rename="emptyFile")] + EmptyFile, + + + /// File was too small. + /// + /// "tooSmall" + #[serde(rename="tooSmall")] + TooSmall, + + + /// Unsupported codec. + /// + /// "codec" + #[serde(rename="codec")] + Codec, + + + /// Upload wasn't finished. + /// + /// "uploadAborted" + #[serde(rename="uploadAborted")] + UploadAborted, +} + +impl AsRef for VideoStatusFailureReasonEnum { + fn as_ref(&self) -> &str { + match *self { + VideoStatusFailureReasonEnum::Conversion => "conversion", + VideoStatusFailureReasonEnum::InvalidFile => "invalidFile", + VideoStatusFailureReasonEnum::EmptyFile => "emptyFile", + VideoStatusFailureReasonEnum::TooSmall => "tooSmall", + VideoStatusFailureReasonEnum::Codec => "codec", + VideoStatusFailureReasonEnum::UploadAborted => "uploadAborted", + } + } +} + +impl std::convert::TryFrom< &str> for VideoStatusFailureReasonEnum { + type Error = (); + fn try_from(value: &str) -> Result { + match value { + "conversion" => Ok(VideoStatusFailureReasonEnum::Conversion), + "invalidFile" => Ok(VideoStatusFailureReasonEnum::InvalidFile), + "emptyFile" => Ok(VideoStatusFailureReasonEnum::EmptyFile), + "tooSmall" => Ok(VideoStatusFailureReasonEnum::TooSmall), + "codec" => Ok(VideoStatusFailureReasonEnum::Codec), + "uploadAborted" => Ok(VideoStatusFailureReasonEnum::UploadAborted), + _=> Err(()), + } + } +} + +impl<'a> Into> for &'a VideoStatusFailureReasonEnum { + fn into(self) -> std::borrow::Cow<'a, str> { + self.as_ref().into() + } +} + + +#[derive(Clone, Copy, Eq, Hash, Debug, PartialEq, Serialize, Deserialize)] +/// The video's license. @mutable youtube.videos.insert youtube.videos.update +pub enum VideoStatusLicenseEnum { + + /// "youtube" + #[serde(rename="youtube")] + Youtube, + + /// "creativeCommon" + #[serde(rename="creativeCommon")] + CreativeCommon, +} + +impl AsRef for VideoStatusLicenseEnum { + fn as_ref(&self) -> &str { + match *self { + VideoStatusLicenseEnum::Youtube => "youtube", + VideoStatusLicenseEnum::CreativeCommon => "creativeCommon", + } + } +} + +impl std::convert::TryFrom< &str> for VideoStatusLicenseEnum { + type Error = (); + fn try_from(value: &str) -> Result { + match value { + "youtube" => Ok(VideoStatusLicenseEnum::Youtube), + "creativeCommon" => Ok(VideoStatusLicenseEnum::CreativeCommon), + _=> Err(()), + } + } +} + +impl<'a> Into> for &'a VideoStatusLicenseEnum { + fn into(self) -> std::borrow::Cow<'a, str> { + self.as_ref().into() + } +} + + +#[derive(Clone, Copy, Eq, Hash, Debug, PartialEq, Serialize, Deserialize)] +/// The video's privacy status. +pub enum VideoStatusPrivacyStatusEnum { + + /// "public" + #[serde(rename="public")] + Public, + + /// "unlisted" + #[serde(rename="unlisted")] + Unlisted, + + /// "private" + #[serde(rename="private")] + Private, +} + +impl AsRef for VideoStatusPrivacyStatusEnum { + fn as_ref(&self) -> &str { + match *self { + VideoStatusPrivacyStatusEnum::Public => "public", + VideoStatusPrivacyStatusEnum::Unlisted => "unlisted", + VideoStatusPrivacyStatusEnum::Private => "private", + } + } +} + +impl std::convert::TryFrom< &str> for VideoStatusPrivacyStatusEnum { + type Error = (); + fn try_from(value: &str) -> Result { + match value { + "public" => Ok(VideoStatusPrivacyStatusEnum::Public), + "unlisted" => Ok(VideoStatusPrivacyStatusEnum::Unlisted), + "private" => Ok(VideoStatusPrivacyStatusEnum::Private), + _=> Err(()), + } + } +} + +impl<'a> Into> for &'a VideoStatusPrivacyStatusEnum { + fn into(self) -> std::borrow::Cow<'a, str> { + self.as_ref().into() + } +} + + +#[derive(Clone, Copy, Eq, Hash, Debug, PartialEq, Serialize, Deserialize)] +/// This value explains why YouTube rejected an uploaded video. This property is only present if the uploadStatus property indicates that the upload was rejected. +pub enum VideoStatusRejectionReasonEnum { + + + /// Copyright infringement. + /// + /// "copyright" + #[serde(rename="copyright")] + Copyright, + + + /// Inappropriate video content. + /// + /// "inappropriate" + #[serde(rename="inappropriate")] + Inappropriate, + + + /// Duplicate upload in the same channel. + /// + /// "duplicate" + #[serde(rename="duplicate")] + Duplicate, + + + /// Terms of use violation. + /// + /// "termsOfUse" + #[serde(rename="termsOfUse")] + TermsOfUse, + + + /// Uploader account was suspended. + /// + /// "uploaderAccountSuspended" + #[serde(rename="uploaderAccountSuspended")] + UploaderAccountSuspended, + + + /// Video duration was too long. + /// + /// "length" + #[serde(rename="length")] + Length, + + + /// Blocked by content owner. + /// + /// "claim" + #[serde(rename="claim")] + Claim, + + + /// Uploader closed his/her account. + /// + /// "uploaderAccountClosed" + #[serde(rename="uploaderAccountClosed")] + UploaderAccountClosed, + + + /// Trademark infringement. + /// + /// "trademark" + #[serde(rename="trademark")] + Trademark, + + + /// An unspecified legal reason. + /// + /// "legal" + #[serde(rename="legal")] + Legal, +} + +impl AsRef for VideoStatusRejectionReasonEnum { + fn as_ref(&self) -> &str { + match *self { + VideoStatusRejectionReasonEnum::Copyright => "copyright", + VideoStatusRejectionReasonEnum::Inappropriate => "inappropriate", + VideoStatusRejectionReasonEnum::Duplicate => "duplicate", + VideoStatusRejectionReasonEnum::TermsOfUse => "termsOfUse", + VideoStatusRejectionReasonEnum::UploaderAccountSuspended => "uploaderAccountSuspended", + VideoStatusRejectionReasonEnum::Length => "length", + VideoStatusRejectionReasonEnum::Claim => "claim", + VideoStatusRejectionReasonEnum::UploaderAccountClosed => "uploaderAccountClosed", + VideoStatusRejectionReasonEnum::Trademark => "trademark", + VideoStatusRejectionReasonEnum::Legal => "legal", + } + } +} + +impl std::convert::TryFrom< &str> for VideoStatusRejectionReasonEnum { + type Error = (); + fn try_from(value: &str) -> Result { + match value { + "copyright" => Ok(VideoStatusRejectionReasonEnum::Copyright), + "inappropriate" => Ok(VideoStatusRejectionReasonEnum::Inappropriate), + "duplicate" => Ok(VideoStatusRejectionReasonEnum::Duplicate), + "termsOfUse" => Ok(VideoStatusRejectionReasonEnum::TermsOfUse), + "uploaderAccountSuspended" => Ok(VideoStatusRejectionReasonEnum::UploaderAccountSuspended), + "length" => Ok(VideoStatusRejectionReasonEnum::Length), + "claim" => Ok(VideoStatusRejectionReasonEnum::Claim), + "uploaderAccountClosed" => Ok(VideoStatusRejectionReasonEnum::UploaderAccountClosed), + "trademark" => Ok(VideoStatusRejectionReasonEnum::Trademark), + "legal" => Ok(VideoStatusRejectionReasonEnum::Legal), + _=> Err(()), + } + } +} + +impl<'a> Into> for &'a VideoStatusRejectionReasonEnum { + fn into(self) -> std::borrow::Cow<'a, str> { + self.as_ref().into() + } +} + + +#[derive(Clone, Copy, Eq, Hash, Debug, PartialEq, Serialize, Deserialize)] +/// The status of the uploaded video. +pub enum VideoStatusUploadStatusEnum { + + + /// Video has been uploaded but not processed yet. + /// + /// "uploaded" + #[serde(rename="uploaded")] + Uploaded, + + + /// Video has been successfully processed. + /// + /// "processed" + #[serde(rename="processed")] + Processed, + + + /// Processing has failed. See FailureReason. + /// + /// "failed" + #[serde(rename="failed")] + Failed, + + + /// Video has been rejected. See RejectionReason. + /// + /// "rejected" + #[serde(rename="rejected")] + Rejected, + + + /// Video has been deleted. + /// + /// "deleted" + #[serde(rename="deleted")] + Deleted, +} + +impl AsRef for VideoStatusUploadStatusEnum { + fn as_ref(&self) -> &str { + match *self { + VideoStatusUploadStatusEnum::Uploaded => "uploaded", + VideoStatusUploadStatusEnum::Processed => "processed", + VideoStatusUploadStatusEnum::Failed => "failed", + VideoStatusUploadStatusEnum::Rejected => "rejected", + VideoStatusUploadStatusEnum::Deleted => "deleted", + } + } +} + +impl std::convert::TryFrom< &str> for VideoStatusUploadStatusEnum { + type Error = (); + fn try_from(value: &str) -> Result { + match value { + "uploaded" => Ok(VideoStatusUploadStatusEnum::Uploaded), + "processed" => Ok(VideoStatusUploadStatusEnum::Processed), + "failed" => Ok(VideoStatusUploadStatusEnum::Failed), + "rejected" => Ok(VideoStatusUploadStatusEnum::Rejected), + "deleted" => Ok(VideoStatusUploadStatusEnum::Deleted), + _=> Err(()), + } + } +} + +impl<'a> Into> for &'a VideoStatusUploadStatusEnum { + fn into(self) -> std::borrow::Cow<'a, str> { + self.as_ref().into() + } +} + + +#[derive(Clone, Copy, Eq, Hash, Debug, PartialEq, Serialize, Deserialize)] +pub enum VideoSuggestionEditorSuggestionsEnum { + + + /// Picture brightness levels seem off and could be corrected. + /// + /// "videoAutoLevels" + #[serde(rename="videoAutoLevels")] + VideoAutoLevels, + + + /// The video appears shaky and could be stabilized. + /// + /// "videoStabilize" + #[serde(rename="videoStabilize")] + VideoStabilize, + + + /// Margins (mattes) detected around the picture could be cropped. + /// + /// "videoCrop" + #[serde(rename="videoCrop")] + VideoCrop, + + + /// The audio track appears silent and could be swapped with a better quality one. + /// + /// "audioQuietAudioSwap" + #[serde(rename="audioQuietAudioSwap")] + AudioQuietAudioSwap, +} + +impl AsRef for VideoSuggestionEditorSuggestionsEnum { + fn as_ref(&self) -> &str { + match *self { + VideoSuggestionEditorSuggestionsEnum::VideoAutoLevels => "videoAutoLevels", + VideoSuggestionEditorSuggestionsEnum::VideoStabilize => "videoStabilize", + VideoSuggestionEditorSuggestionsEnum::VideoCrop => "videoCrop", + VideoSuggestionEditorSuggestionsEnum::AudioQuietAudioSwap => "audioQuietAudioSwap", + } + } +} + +impl std::convert::TryFrom< &str> for VideoSuggestionEditorSuggestionsEnum { + type Error = (); + fn try_from(value: &str) -> Result { + match value { + "videoAutoLevels" => Ok(VideoSuggestionEditorSuggestionsEnum::VideoAutoLevels), + "videoStabilize" => Ok(VideoSuggestionEditorSuggestionsEnum::VideoStabilize), + "videoCrop" => Ok(VideoSuggestionEditorSuggestionsEnum::VideoCrop), + "audioQuietAudioSwap" => Ok(VideoSuggestionEditorSuggestionsEnum::AudioQuietAudioSwap), + _=> Err(()), + } + } +} + +impl<'a> Into> for &'a VideoSuggestionEditorSuggestionsEnum { + fn into(self) -> std::borrow::Cow<'a, str> { + self.as_ref().into() + } +} + + +#[derive(Clone, Copy, Eq, Hash, Debug, PartialEq, Serialize, Deserialize)] +pub enum VideoSuggestionProcessingErrorsEnum { + + + /// File contains audio only (e.g., an MP3 file). + /// + /// "audioFile" + #[serde(rename="audioFile")] + AudioFile, + + + /// Image file (e.g., a JPEG image). + /// + /// "imageFile" + #[serde(rename="imageFile")] + ImageFile, + + + /// Movie project file (e.g., Microsoft Windows Movie Maker project). + /// + /// "projectFile" + #[serde(rename="projectFile")] + ProjectFile, + + + /// Other non-video file. + /// + /// "notAVideoFile" + #[serde(rename="notAVideoFile")] + NotAVideoFile, + + + /// Document or text file (e.g., MS Word document). + /// + /// "docFile" + #[serde(rename="docFile")] + DocFile, + + + /// An archive file (e.g., a ZIP archive). + /// + /// "archiveFile" + #[serde(rename="archiveFile")] + ArchiveFile, + + + /// Unsupported spatial audio layout type. + /// + /// "unsupportedSpatialAudioLayout" + #[serde(rename="unsupportedSpatialAudioLayout")] + UnsupportedSpatialAudioLayout, +} + +impl AsRef for VideoSuggestionProcessingErrorsEnum { + fn as_ref(&self) -> &str { + match *self { + VideoSuggestionProcessingErrorsEnum::AudioFile => "audioFile", + VideoSuggestionProcessingErrorsEnum::ImageFile => "imageFile", + VideoSuggestionProcessingErrorsEnum::ProjectFile => "projectFile", + VideoSuggestionProcessingErrorsEnum::NotAVideoFile => "notAVideoFile", + VideoSuggestionProcessingErrorsEnum::DocFile => "docFile", + VideoSuggestionProcessingErrorsEnum::ArchiveFile => "archiveFile", + VideoSuggestionProcessingErrorsEnum::UnsupportedSpatialAudioLayout => "unsupportedSpatialAudioLayout", + } + } +} + +impl std::convert::TryFrom< &str> for VideoSuggestionProcessingErrorsEnum { + type Error = (); + fn try_from(value: &str) -> Result { + match value { + "audioFile" => Ok(VideoSuggestionProcessingErrorsEnum::AudioFile), + "imageFile" => Ok(VideoSuggestionProcessingErrorsEnum::ImageFile), + "projectFile" => Ok(VideoSuggestionProcessingErrorsEnum::ProjectFile), + "notAVideoFile" => Ok(VideoSuggestionProcessingErrorsEnum::NotAVideoFile), + "docFile" => Ok(VideoSuggestionProcessingErrorsEnum::DocFile), + "archiveFile" => Ok(VideoSuggestionProcessingErrorsEnum::ArchiveFile), + "unsupportedSpatialAudioLayout" => Ok(VideoSuggestionProcessingErrorsEnum::UnsupportedSpatialAudioLayout), + _=> Err(()), + } + } +} + +impl<'a> Into> for &'a VideoSuggestionProcessingErrorsEnum { + fn into(self) -> std::borrow::Cow<'a, str> { + self.as_ref().into() + } +} + + +#[derive(Clone, Copy, Eq, Hash, Debug, PartialEq, Serialize, Deserialize)] +pub enum VideoSuggestionProcessingHintsEnum { + + + /// The MP4 file is not streamable, this will slow down the processing. MOOV atom was not found at the beginning of the file. + /// + /// "nonStreamableMov" + #[serde(rename="nonStreamableMov")] + NonStreamableMov, + + + /// Probably a better quality version of the video exists. The video has wide screen aspect ratio, but is not an HD video. + /// + /// "sendBestQualityVideo" + #[serde(rename="sendBestQualityVideo")] + SendBestQualityVideo, + + + /// Uploaded video is spherical video. + /// + /// "sphericalVideo" + #[serde(rename="sphericalVideo")] + SphericalVideo, + + + /// Uploaded video has spatial audio. + /// + /// "spatialAudio" + #[serde(rename="spatialAudio")] + SpatialAudio, + + + /// Uploaded video is VR video. + /// + /// "vrVideo" + #[serde(rename="vrVideo")] + VrVideo, + + + /// Uploaded video is HDR video. + /// + /// "hdrVideo" + #[serde(rename="hdrVideo")] + HdrVideo, +} + +impl AsRef for VideoSuggestionProcessingHintsEnum { + fn as_ref(&self) -> &str { + match *self { + VideoSuggestionProcessingHintsEnum::NonStreamableMov => "nonStreamableMov", + VideoSuggestionProcessingHintsEnum::SendBestQualityVideo => "sendBestQualityVideo", + VideoSuggestionProcessingHintsEnum::SphericalVideo => "sphericalVideo", + VideoSuggestionProcessingHintsEnum::SpatialAudio => "spatialAudio", + VideoSuggestionProcessingHintsEnum::VrVideo => "vrVideo", + VideoSuggestionProcessingHintsEnum::HdrVideo => "hdrVideo", + } + } +} + +impl std::convert::TryFrom< &str> for VideoSuggestionProcessingHintsEnum { + type Error = (); + fn try_from(value: &str) -> Result { + match value { + "nonStreamableMov" => Ok(VideoSuggestionProcessingHintsEnum::NonStreamableMov), + "sendBestQualityVideo" => Ok(VideoSuggestionProcessingHintsEnum::SendBestQualityVideo), + "sphericalVideo" => Ok(VideoSuggestionProcessingHintsEnum::SphericalVideo), + "spatialAudio" => Ok(VideoSuggestionProcessingHintsEnum::SpatialAudio), + "vrVideo" => Ok(VideoSuggestionProcessingHintsEnum::VrVideo), + "hdrVideo" => Ok(VideoSuggestionProcessingHintsEnum::HdrVideo), + _=> Err(()), + } + } +} + +impl<'a> Into> for &'a VideoSuggestionProcessingHintsEnum { + fn into(self) -> std::borrow::Cow<'a, str> { + self.as_ref().into() + } +} + + +#[derive(Clone, Copy, Eq, Hash, Debug, PartialEq, Serialize, Deserialize)] +pub enum VideoSuggestionProcessingWarningsEnum { + + + /// Unrecognized file format, transcoding is likely to fail. + /// + /// "unknownContainer" + #[serde(rename="unknownContainer")] + UnknownContainer, + + + /// Unrecognized video codec, transcoding is likely to fail. + /// + /// "unknownVideoCodec" + #[serde(rename="unknownVideoCodec")] + UnknownVideoCodec, + + + /// Unrecognized audio codec, transcoding is likely to fail. + /// + /// "unknownAudioCodec" + #[serde(rename="unknownAudioCodec")] + UnknownAudioCodec, + + + /// Conflicting container and stream resolutions. + /// + /// "inconsistentResolution" + #[serde(rename="inconsistentResolution")] + InconsistentResolution, + + + /// Edit lists are not currently supported. + /// + /// "hasEditlist" + #[serde(rename="hasEditlist")] + HasEditlist, + + + /// Video codec that is known to cause problems was used. + /// + /// "problematicVideoCodec" + #[serde(rename="problematicVideoCodec")] + ProblematicVideoCodec, + + + /// Audio codec that is known to cause problems was used. + /// + /// "problematicAudioCodec" + #[serde(rename="problematicAudioCodec")] + ProblematicAudioCodec, + + + /// Unsupported VR video stereo mode. + /// + /// "unsupportedVrStereoMode" + #[serde(rename="unsupportedVrStereoMode")] + UnsupportedVrStereoMode, + + + /// Unsupported spherical video projection type. + /// + /// "unsupportedSphericalProjectionType" + #[serde(rename="unsupportedSphericalProjectionType")] + UnsupportedSphericalProjectionType, + + + /// Unsupported HDR pixel format. + /// + /// "unsupportedHdrPixelFormat" + #[serde(rename="unsupportedHdrPixelFormat")] + UnsupportedHdrPixelFormat, + + + /// Unspecified HDR color metadata. + /// + /// "unsupportedHdrColorMetadata" + #[serde(rename="unsupportedHdrColorMetadata")] + UnsupportedHdrColorMetadata, + + + /// Problematic HDR lookup table attached. + /// + /// "problematicHdrLookupTable" + #[serde(rename="problematicHdrLookupTable")] + ProblematicHdrLookupTable, +} + +impl AsRef for VideoSuggestionProcessingWarningsEnum { + fn as_ref(&self) -> &str { + match *self { + VideoSuggestionProcessingWarningsEnum::UnknownContainer => "unknownContainer", + VideoSuggestionProcessingWarningsEnum::UnknownVideoCodec => "unknownVideoCodec", + VideoSuggestionProcessingWarningsEnum::UnknownAudioCodec => "unknownAudioCodec", + VideoSuggestionProcessingWarningsEnum::InconsistentResolution => "inconsistentResolution", + VideoSuggestionProcessingWarningsEnum::HasEditlist => "hasEditlist", + VideoSuggestionProcessingWarningsEnum::ProblematicVideoCodec => "problematicVideoCodec", + VideoSuggestionProcessingWarningsEnum::ProblematicAudioCodec => "problematicAudioCodec", + VideoSuggestionProcessingWarningsEnum::UnsupportedVrStereoMode => "unsupportedVrStereoMode", + VideoSuggestionProcessingWarningsEnum::UnsupportedSphericalProjectionType => "unsupportedSphericalProjectionType", + VideoSuggestionProcessingWarningsEnum::UnsupportedHdrPixelFormat => "unsupportedHdrPixelFormat", + VideoSuggestionProcessingWarningsEnum::UnsupportedHdrColorMetadata => "unsupportedHdrColorMetadata", + VideoSuggestionProcessingWarningsEnum::ProblematicHdrLookupTable => "problematicHdrLookupTable", + } + } +} + +impl std::convert::TryFrom< &str> for VideoSuggestionProcessingWarningsEnum { + type Error = (); + fn try_from(value: &str) -> Result { + match value { + "unknownContainer" => Ok(VideoSuggestionProcessingWarningsEnum::UnknownContainer), + "unknownVideoCodec" => Ok(VideoSuggestionProcessingWarningsEnum::UnknownVideoCodec), + "unknownAudioCodec" => Ok(VideoSuggestionProcessingWarningsEnum::UnknownAudioCodec), + "inconsistentResolution" => Ok(VideoSuggestionProcessingWarningsEnum::InconsistentResolution), + "hasEditlist" => Ok(VideoSuggestionProcessingWarningsEnum::HasEditlist), + "problematicVideoCodec" => Ok(VideoSuggestionProcessingWarningsEnum::ProblematicVideoCodec), + "problematicAudioCodec" => Ok(VideoSuggestionProcessingWarningsEnum::ProblematicAudioCodec), + "unsupportedVrStereoMode" => Ok(VideoSuggestionProcessingWarningsEnum::UnsupportedVrStereoMode), + "unsupportedSphericalProjectionType" => Ok(VideoSuggestionProcessingWarningsEnum::UnsupportedSphericalProjectionType), + "unsupportedHdrPixelFormat" => Ok(VideoSuggestionProcessingWarningsEnum::UnsupportedHdrPixelFormat), + "unsupportedHdrColorMetadata" => Ok(VideoSuggestionProcessingWarningsEnum::UnsupportedHdrColorMetadata), + "problematicHdrLookupTable" => Ok(VideoSuggestionProcessingWarningsEnum::ProblematicHdrLookupTable), + _=> Err(()), + } + } +} + +impl<'a> Into> for &'a VideoSuggestionProcessingWarningsEnum { + fn into(self) -> std::borrow::Cow<'a, str> { + self.as_ref().into() + } +} + + +#[derive(Clone, Copy, Eq, Hash, Debug, PartialEq, Serialize, Deserialize)] +/// Limits the returned comment threads to those with the specified moderation status. Not compatible with the 'id' filter. Valid values: published, heldForReview, likelySpam. +pub enum CommentThreadModerationStatusEnum { + + + /// The comment is available for public display. + /// + /// "published" + #[serde(rename="published")] + Published, + + + /// The comment is awaiting review by a moderator. + /// + /// "heldForReview" + #[serde(rename="heldForReview")] + HeldForReview, + + /// "likelySpam" + #[serde(rename="likelySpam")] + LikelySpam, + + + /// The comment is unfit for display. + /// + /// "rejected" + #[serde(rename="rejected")] + Rejected, +} + +impl AsRef for CommentThreadModerationStatusEnum { + fn as_ref(&self) -> &str { + match *self { + CommentThreadModerationStatusEnum::Published => "published", + CommentThreadModerationStatusEnum::HeldForReview => "heldForReview", + CommentThreadModerationStatusEnum::LikelySpam => "likelySpam", + CommentThreadModerationStatusEnum::Rejected => "rejected", + } + } +} + +impl std::convert::TryFrom< &str> for CommentThreadModerationStatusEnum { + type Error = (); + fn try_from(value: &str) -> Result { + match value { + "published" => Ok(CommentThreadModerationStatusEnum::Published), + "heldForReview" => Ok(CommentThreadModerationStatusEnum::HeldForReview), + "likelySpam" => Ok(CommentThreadModerationStatusEnum::LikelySpam), + "rejected" => Ok(CommentThreadModerationStatusEnum::Rejected), + _=> Err(()), + } + } +} + +impl<'a> Into> for &'a CommentThreadModerationStatusEnum { + fn into(self) -> std::borrow::Cow<'a, str> { + self.as_ref().into() + } +} + +impl Default for CommentThreadModerationStatusEnum { + fn default() -> CommentThreadModerationStatusEnum { + CommentThreadModerationStatusEnum::Published + } +} + +#[derive(Clone, Copy, Eq, Hash, Debug, PartialEq, Serialize, Deserialize)] +pub enum CommentThreadOrderEnum { + + /// "orderUnspecified" + #[serde(rename="orderUnspecified")] + OrderUnspecified, + + + /// Order by time. + /// + /// "time" + #[serde(rename="time")] + Time, + + + /// Order by relevance. + /// + /// "relevance" + #[serde(rename="relevance")] + Relevance, +} + +impl AsRef for CommentThreadOrderEnum { + fn as_ref(&self) -> &str { + match *self { + CommentThreadOrderEnum::OrderUnspecified => "orderUnspecified", + CommentThreadOrderEnum::Time => "time", + CommentThreadOrderEnum::Relevance => "relevance", + } + } +} + +impl std::convert::TryFrom< &str> for CommentThreadOrderEnum { + type Error = (); + fn try_from(value: &str) -> Result { + match value { + "orderUnspecified" => Ok(CommentThreadOrderEnum::OrderUnspecified), + "time" => Ok(CommentThreadOrderEnum::Time), + "relevance" => Ok(CommentThreadOrderEnum::Relevance), + _=> Err(()), + } + } +} + +impl<'a> Into> for &'a CommentThreadOrderEnum { + fn into(self) -> std::borrow::Cow<'a, str> { + self.as_ref().into() + } +} + +impl Default for CommentThreadOrderEnum { + fn default() -> CommentThreadOrderEnum { + CommentThreadOrderEnum::Time + } +} + +#[derive(Clone, Copy, Eq, Hash, Debug, PartialEq, Serialize, Deserialize)] +/// The requested text format for the returned comments. +pub enum CommentThreadTextFormatEnum { + + /// "textFormatUnspecified" + #[serde(rename="textFormatUnspecified")] + TextFormatUnspecified, + + + /// Returns the comments in HTML format. This is the default value. + /// + /// "html" + #[serde(rename="html")] + Html, + + + /// Returns the comments in plain text format. + /// + /// "plainText" + #[serde(rename="plainText")] + PlainText, +} + +impl AsRef for CommentThreadTextFormatEnum { + fn as_ref(&self) -> &str { + match *self { + CommentThreadTextFormatEnum::TextFormatUnspecified => "textFormatUnspecified", + CommentThreadTextFormatEnum::Html => "html", + CommentThreadTextFormatEnum::PlainText => "plainText", + } + } +} + +impl std::convert::TryFrom< &str> for CommentThreadTextFormatEnum { + type Error = (); + fn try_from(value: &str) -> Result { + match value { + "textFormatUnspecified" => Ok(CommentThreadTextFormatEnum::TextFormatUnspecified), + "html" => Ok(CommentThreadTextFormatEnum::Html), + "plainText" => Ok(CommentThreadTextFormatEnum::PlainText), + _=> Err(()), + } + } +} + +impl<'a> Into> for &'a CommentThreadTextFormatEnum { + fn into(self) -> std::borrow::Cow<'a, str> { + self.as_ref().into() + } +} + +impl Default for CommentThreadTextFormatEnum { + fn default() -> CommentThreadTextFormatEnum { + CommentThreadTextFormatEnum::Html + } +} + +#[derive(Clone, Copy, Eq, Hash, Debug, PartialEq, Serialize, Deserialize)] +/// The requested text format for the returned comments. +pub enum CommentTextFormatEnum { + + /// "textFormatUnspecified" + #[serde(rename="textFormatUnspecified")] + TextFormatUnspecified, + + + /// Returns the comments in HTML format. This is the default value. + /// + /// "html" + #[serde(rename="html")] + Html, + + + /// Returns the comments in plain text format. + /// + /// "plainText" + #[serde(rename="plainText")] + PlainText, +} + +impl AsRef for CommentTextFormatEnum { + fn as_ref(&self) -> &str { + match *self { + CommentTextFormatEnum::TextFormatUnspecified => "textFormatUnspecified", + CommentTextFormatEnum::Html => "html", + CommentTextFormatEnum::PlainText => "plainText", + } + } +} + +impl std::convert::TryFrom< &str> for CommentTextFormatEnum { + type Error = (); + fn try_from(value: &str) -> Result { + match value { + "textFormatUnspecified" => Ok(CommentTextFormatEnum::TextFormatUnspecified), + "html" => Ok(CommentTextFormatEnum::Html), + "plainText" => Ok(CommentTextFormatEnum::PlainText), + _=> Err(()), + } + } +} + +impl<'a> Into> for &'a CommentTextFormatEnum { + fn into(self) -> std::borrow::Cow<'a, str> { + self.as_ref().into() + } +} + +impl Default for CommentTextFormatEnum { + fn default() -> CommentTextFormatEnum { + CommentTextFormatEnum::Html + } +} + +#[derive(Clone, Copy, Eq, Hash, Debug, PartialEq, Serialize, Deserialize)] +/// Specifies the requested moderation status. Note, comments can be in statuses, which are not available through this call. For example, this call does not allow to mark a comment as 'likely spam'. Valid values: 'heldForReview', 'published' or 'rejected'. +pub enum CommentModerationStatusEnum { + + + /// The comment is available for public display. + /// + /// "published" + #[serde(rename="published")] + Published, + + + /// The comment is awaiting review by a moderator. + /// + /// "heldForReview" + #[serde(rename="heldForReview")] + HeldForReview, + + /// "likelySpam" + #[serde(rename="likelySpam")] + LikelySpam, + + + /// The comment is unfit for display. + /// + /// "rejected" + #[serde(rename="rejected")] + Rejected, +} + +impl AsRef for CommentModerationStatusEnum { + fn as_ref(&self) -> &str { + match *self { + CommentModerationStatusEnum::Published => "published", + CommentModerationStatusEnum::HeldForReview => "heldForReview", + CommentModerationStatusEnum::LikelySpam => "likelySpam", + CommentModerationStatusEnum::Rejected => "rejected", + } + } +} + +impl std::convert::TryFrom< &str> for CommentModerationStatusEnum { + type Error = (); + fn try_from(value: &str) -> Result { + match value { + "published" => Ok(CommentModerationStatusEnum::Published), + "heldForReview" => Ok(CommentModerationStatusEnum::HeldForReview), + "likelySpam" => Ok(CommentModerationStatusEnum::LikelySpam), + "rejected" => Ok(CommentModerationStatusEnum::Rejected), + _=> Err(()), + } + } +} + +impl<'a> Into> for &'a CommentModerationStatusEnum { + fn into(self) -> std::borrow::Cow<'a, str> { + self.as_ref().into() + } +} + + +#[derive(Clone, Copy, Eq, Hash, Debug, PartialEq, Serialize, Deserialize)] +/// The status to which the broadcast is going to transition. +pub enum LiveBroadcastBroadcastStatusEnum { + + /// "statusUnspecified" + #[serde(rename="statusUnspecified")] + StatusUnspecified, + + + /// Start testing the broadcast. YouTube transmits video to the broadcast's monitor stream. Note that you can only transition a broadcast to the testing state if its contentDetails.monitorStream.enableMonitorStream property is set to true.", + /// + /// "testing" + #[serde(rename="testing")] + Testing, + + + /// Return only persistent broadcasts. + /// + /// "live" + #[serde(rename="live")] + Live, + + + /// The broadcast is over. YouTube stops transmitting video. + /// + /// "complete" + #[serde(rename="complete")] + Complete, +} + +impl AsRef for LiveBroadcastBroadcastStatusEnum { + fn as_ref(&self) -> &str { + match *self { + LiveBroadcastBroadcastStatusEnum::StatusUnspecified => "statusUnspecified", + LiveBroadcastBroadcastStatusEnum::Testing => "testing", + LiveBroadcastBroadcastStatusEnum::Live => "live", + LiveBroadcastBroadcastStatusEnum::Complete => "complete", + } + } +} + +impl std::convert::TryFrom< &str> for LiveBroadcastBroadcastStatusEnum { + type Error = (); + fn try_from(value: &str) -> Result { + match value { + "statusUnspecified" => Ok(LiveBroadcastBroadcastStatusEnum::StatusUnspecified), + "testing" => Ok(LiveBroadcastBroadcastStatusEnum::Testing), + "live" => Ok(LiveBroadcastBroadcastStatusEnum::Live), + "complete" => Ok(LiveBroadcastBroadcastStatusEnum::Complete), + _=> Err(()), + } + } +} + +impl<'a> Into> for &'a LiveBroadcastBroadcastStatusEnum { + fn into(self) -> std::borrow::Cow<'a, str> { + self.as_ref().into() + } +} + + +#[derive(Clone, Copy, Eq, Hash, Debug, PartialEq, Serialize, Deserialize)] +/// Return only broadcasts with the selected type. +pub enum LiveBroadcastBroadcastTypeEnum { + + /// "broadcastTypeFilterUnspecified" + #[serde(rename="broadcastTypeFilterUnspecified")] + BroadcastTypeFilterUnspecified, + + + /// Return all broadcasts. + /// + /// "all" + #[serde(rename="all")] + All, + + + /// Return only scheduled event broadcasts. + /// + /// "event" + #[serde(rename="event")] + Event, + + + /// Return only persistent broadcasts. + /// + /// "persistent" + #[serde(rename="persistent")] + Persistent, +} + +impl AsRef for LiveBroadcastBroadcastTypeEnum { + fn as_ref(&self) -> &str { + match *self { + LiveBroadcastBroadcastTypeEnum::BroadcastTypeFilterUnspecified => "broadcastTypeFilterUnspecified", + LiveBroadcastBroadcastTypeEnum::All => "all", + LiveBroadcastBroadcastTypeEnum::Event => "event", + LiveBroadcastBroadcastTypeEnum::Persistent => "persistent", + } + } +} + +impl std::convert::TryFrom< &str> for LiveBroadcastBroadcastTypeEnum { + type Error = (); + fn try_from(value: &str) -> Result { + match value { + "broadcastTypeFilterUnspecified" => Ok(LiveBroadcastBroadcastTypeEnum::BroadcastTypeFilterUnspecified), + "all" => Ok(LiveBroadcastBroadcastTypeEnum::All), + "event" => Ok(LiveBroadcastBroadcastTypeEnum::Event), + "persistent" => Ok(LiveBroadcastBroadcastTypeEnum::Persistent), + _=> Err(()), + } + } +} + +impl<'a> Into> for &'a LiveBroadcastBroadcastTypeEnum { + fn into(self) -> std::borrow::Cow<'a, str> { + self.as_ref().into() + } +} + +impl Default for LiveBroadcastBroadcastTypeEnum { + fn default() -> LiveBroadcastBroadcastTypeEnum { + LiveBroadcastBroadcastTypeEnum::Event + } +} + +#[derive(Clone, Copy, Eq, Hash, Debug, PartialEq, Serialize, Deserialize)] +/// Parameter that specifies which channel members to return. +pub enum MemberModeEnum { + + /// "listMembersModeUnknown" + #[serde(rename="listMembersModeUnknown")] + ListMembersModeUnknown, + + + /// Return only members that joined after the first call with this mode was made. + /// + /// "updates" + #[serde(rename="updates")] + Updates, + + + /// Return all current members, from newest to oldest. + /// + /// "all_current" + #[serde(rename="all_current")] + AllCurrent, +} + +impl AsRef for MemberModeEnum { + fn as_ref(&self) -> &str { + match *self { + MemberModeEnum::ListMembersModeUnknown => "listMembersModeUnknown", + MemberModeEnum::Updates => "updates", + MemberModeEnum::AllCurrent => "all_current", + } + } +} + +impl std::convert::TryFrom< &str> for MemberModeEnum { + type Error = (); + fn try_from(value: &str) -> Result { + match value { + "listMembersModeUnknown" => Ok(MemberModeEnum::ListMembersModeUnknown), + "updates" => Ok(MemberModeEnum::Updates), + "all_current" => Ok(MemberModeEnum::AllCurrent), + _=> Err(()), + } + } +} + +impl<'a> Into> for &'a MemberModeEnum { + fn into(self) -> std::borrow::Cow<'a, str> { + self.as_ref().into() + } +} + +impl Default for MemberModeEnum { + fn default() -> MemberModeEnum { + MemberModeEnum::AllCurrent + } +} + +#[derive(Clone, Copy, Eq, Hash, Debug, PartialEq, Serialize, Deserialize)] +/// Add a filter on the channel search. +pub enum SearchChannelTypeEnum { + + /// "channelTypeUnspecified" + #[serde(rename="channelTypeUnspecified")] + ChannelTypeUnspecified, + + + /// Return all channels. + /// + /// "any" + #[serde(rename="any")] + Any, + + + /// Only retrieve shows. + /// + /// "show" + #[serde(rename="show")] + Show, +} + +impl AsRef for SearchChannelTypeEnum { + fn as_ref(&self) -> &str { + match *self { + SearchChannelTypeEnum::ChannelTypeUnspecified => "channelTypeUnspecified", + SearchChannelTypeEnum::Any => "any", + SearchChannelTypeEnum::Show => "show", + } + } +} + +impl std::convert::TryFrom< &str> for SearchChannelTypeEnum { + type Error = (); + fn try_from(value: &str) -> Result { + match value { + "channelTypeUnspecified" => Ok(SearchChannelTypeEnum::ChannelTypeUnspecified), + "any" => Ok(SearchChannelTypeEnum::Any), + "show" => Ok(SearchChannelTypeEnum::Show), + _=> Err(()), + } + } +} + +impl<'a> Into> for &'a SearchChannelTypeEnum { + fn into(self) -> std::borrow::Cow<'a, str> { + self.as_ref().into() + } +} + + +#[derive(Clone, Copy, Eq, Hash, Debug, PartialEq, Serialize, Deserialize)] +/// Filter on the livestream status of the videos. +pub enum SearchEventTypeEnum { + + /// "none" + #[serde(rename="none")] + None, + + + /// The live broadcast is upcoming. + /// + /// "upcoming" + #[serde(rename="upcoming")] + Upcoming, + + + /// The live broadcast is active. + /// + /// "live" + #[serde(rename="live")] + Live, + + + /// The live broadcast has been completed. + /// + /// "completed" + #[serde(rename="completed")] + Completed, +} + +impl AsRef for SearchEventTypeEnum { + fn as_ref(&self) -> &str { + match *self { + SearchEventTypeEnum::None => "none", + SearchEventTypeEnum::Upcoming => "upcoming", + SearchEventTypeEnum::Live => "live", + SearchEventTypeEnum::Completed => "completed", + } + } +} + +impl std::convert::TryFrom< &str> for SearchEventTypeEnum { + type Error = (); + fn try_from(value: &str) -> Result { + match value { + "none" => Ok(SearchEventTypeEnum::None), + "upcoming" => Ok(SearchEventTypeEnum::Upcoming), + "live" => Ok(SearchEventTypeEnum::Live), + "completed" => Ok(SearchEventTypeEnum::Completed), + _=> Err(()), + } + } +} + +impl<'a> Into> for &'a SearchEventTypeEnum { + fn into(self) -> std::borrow::Cow<'a, str> { + self.as_ref().into() + } +} + + +#[derive(Clone, Copy, Eq, Hash, Debug, PartialEq, Serialize, Deserialize)] +/// Sort order of the results. +pub enum SearchOrderEnum { + + /// "searchSortUnspecified" + #[serde(rename="searchSortUnspecified")] + SearchSortUnspecified, + + + /// Resources are sorted in reverse chronological order based on the date they were created. + /// + /// "date" + #[serde(rename="date")] + Date, + + + /// Resources are sorted from highest to lowest rating. + /// + /// "rating" + #[serde(rename="rating")] + Rating, + + + /// Resources are sorted from highest to lowest number of views. + /// + /// "viewCount" + #[serde(rename="viewCount")] + ViewCount, + + + /// Resources are sorted based on their relevance to the search query. This is the default value for this parameter. + /// + /// "relevance" + #[serde(rename="relevance")] + Relevance, + + + /// Resources are sorted alphabetically by title. + /// + /// "title" + #[serde(rename="title")] + Title, + + + /// Channels are sorted in descending order of their number of uploaded videos. + /// + /// "videoCount" + #[serde(rename="videoCount")] + VideoCount, +} + +impl AsRef for SearchOrderEnum { + fn as_ref(&self) -> &str { + match *self { + SearchOrderEnum::SearchSortUnspecified => "searchSortUnspecified", + SearchOrderEnum::Date => "date", + SearchOrderEnum::Rating => "rating", + SearchOrderEnum::ViewCount => "viewCount", + SearchOrderEnum::Relevance => "relevance", + SearchOrderEnum::Title => "title", + SearchOrderEnum::VideoCount => "videoCount", + } + } +} + +impl std::convert::TryFrom< &str> for SearchOrderEnum { + type Error = (); + fn try_from(value: &str) -> Result { + match value { + "searchSortUnspecified" => Ok(SearchOrderEnum::SearchSortUnspecified), + "date" => Ok(SearchOrderEnum::Date), + "rating" => Ok(SearchOrderEnum::Rating), + "viewCount" => Ok(SearchOrderEnum::ViewCount), + "relevance" => Ok(SearchOrderEnum::Relevance), + "title" => Ok(SearchOrderEnum::Title), + "videoCount" => Ok(SearchOrderEnum::VideoCount), + _=> Err(()), + } + } +} + +impl<'a> Into> for &'a SearchOrderEnum { + fn into(self) -> std::borrow::Cow<'a, str> { + self.as_ref().into() + } +} + +impl Default for SearchOrderEnum { + fn default() -> SearchOrderEnum { + SearchOrderEnum::Relevance + } +} + +#[derive(Clone, Copy, Eq, Hash, Debug, PartialEq, Serialize, Deserialize)] +/// Indicates whether the search results should include restricted content as well as standard content. +pub enum SearchSafeSearchEnum { + + /// "safeSearchSettingUnspecified" + #[serde(rename="safeSearchSettingUnspecified")] + SafeSearchSettingUnspecified, + + + /// YouTube will not filter the search result set. + /// + /// "none" + #[serde(rename="none")] + None, + + + /// YouTube will filter some content from search results and, at the least, will filter content that is restricted in your locale. Based on their content, search results could be removed from search results or demoted in search results. This is the default parameter value. + /// + /// "moderate" + #[serde(rename="moderate")] + Moderate, + + + /// YouTube will try to exclude all restricted content from the search result set. Based on their content, search results could be removed from search results or demoted in search results. + /// + /// "strict" + #[serde(rename="strict")] + Strict, +} + +impl AsRef for SearchSafeSearchEnum { + fn as_ref(&self) -> &str { + match *self { + SearchSafeSearchEnum::SafeSearchSettingUnspecified => "safeSearchSettingUnspecified", + SearchSafeSearchEnum::None => "none", + SearchSafeSearchEnum::Moderate => "moderate", + SearchSafeSearchEnum::Strict => "strict", + } + } +} + +impl std::convert::TryFrom< &str> for SearchSafeSearchEnum { + type Error = (); + fn try_from(value: &str) -> Result { + match value { + "safeSearchSettingUnspecified" => Ok(SearchSafeSearchEnum::SafeSearchSettingUnspecified), + "none" => Ok(SearchSafeSearchEnum::None), + "moderate" => Ok(SearchSafeSearchEnum::Moderate), + "strict" => Ok(SearchSafeSearchEnum::Strict), + _=> Err(()), + } + } +} + +impl<'a> Into> for &'a SearchSafeSearchEnum { + fn into(self) -> std::borrow::Cow<'a, str> { + self.as_ref().into() + } +} + +impl Default for SearchSafeSearchEnum { + fn default() -> SearchSafeSearchEnum { + SearchSafeSearchEnum::Moderate + } +} + +#[derive(Clone, Copy, Eq, Hash, Debug, PartialEq, Serialize, Deserialize)] +/// Filter on the presence of captions on the videos. +pub enum SearchVideoCaptionEnum { + + /// "videoCaptionUnspecified" + #[serde(rename="videoCaptionUnspecified")] + VideoCaptionUnspecified, + + + /// Do not filter results based on caption availability. + /// + /// "any" + #[serde(rename="any")] + Any, + + + /// Only include videos that have captions. + /// + /// "closedCaption" + #[serde(rename="closedCaption")] + ClosedCaption, + + + /// Only include videos that do not have captions. + /// + /// "none" + #[serde(rename="none")] + None, +} + +impl AsRef for SearchVideoCaptionEnum { + fn as_ref(&self) -> &str { + match *self { + SearchVideoCaptionEnum::VideoCaptionUnspecified => "videoCaptionUnspecified", + SearchVideoCaptionEnum::Any => "any", + SearchVideoCaptionEnum::ClosedCaption => "closedCaption", + SearchVideoCaptionEnum::None => "none", + } + } +} + +impl std::convert::TryFrom< &str> for SearchVideoCaptionEnum { + type Error = (); + fn try_from(value: &str) -> Result { + match value { + "videoCaptionUnspecified" => Ok(SearchVideoCaptionEnum::VideoCaptionUnspecified), + "any" => Ok(SearchVideoCaptionEnum::Any), + "closedCaption" => Ok(SearchVideoCaptionEnum::ClosedCaption), + "none" => Ok(SearchVideoCaptionEnum::None), + _=> Err(()), + } + } +} + +impl<'a> Into> for &'a SearchVideoCaptionEnum { + fn into(self) -> std::borrow::Cow<'a, str> { + self.as_ref().into() + } +} + + +#[derive(Clone, Copy, Eq, Hash, Debug, PartialEq, Serialize, Deserialize)] +/// Filter on the definition of the videos. +pub enum SearchVideoDefinitionEnum { + + + /// Return all videos, regardless of their resolution. + /// + /// "any" + #[serde(rename="any")] + Any, + + + /// Only retrieve videos in standard definition. + /// + /// "standard" + #[serde(rename="standard")] + Standard, + + + /// Only retrieve HD videos. + /// + /// "high" + #[serde(rename="high")] + High, +} + +impl AsRef for SearchVideoDefinitionEnum { + fn as_ref(&self) -> &str { + match *self { + SearchVideoDefinitionEnum::Any => "any", + SearchVideoDefinitionEnum::Standard => "standard", + SearchVideoDefinitionEnum::High => "high", + } + } +} + +impl std::convert::TryFrom< &str> for SearchVideoDefinitionEnum { + type Error = (); + fn try_from(value: &str) -> Result { + match value { + "any" => Ok(SearchVideoDefinitionEnum::Any), + "standard" => Ok(SearchVideoDefinitionEnum::Standard), + "high" => Ok(SearchVideoDefinitionEnum::High), + _=> Err(()), + } + } +} + +impl<'a> Into> for &'a SearchVideoDefinitionEnum { + fn into(self) -> std::borrow::Cow<'a, str> { + self.as_ref().into() + } +} + + +#[derive(Clone, Copy, Eq, Hash, Debug, PartialEq, Serialize, Deserialize)] +/// Filter on 3d videos. +pub enum SearchVideoDimensionEnum { + + + /// Include both 3D and non-3D videos in returned results. This is the default value. + /// + /// "any" + #[serde(rename="any")] + Any, + + + /// Restrict search results to exclude 3D videos. + /// + /// "2d" + #[serde(rename="2d")] + _2d, + + + /// Restrict search results to only include 3D videos. + /// + /// "3d" + #[serde(rename="3d")] + _3d, +} + +impl AsRef for SearchVideoDimensionEnum { + fn as_ref(&self) -> &str { + match *self { + SearchVideoDimensionEnum::Any => "any", + SearchVideoDimensionEnum::_2d => "2d", + SearchVideoDimensionEnum::_3d => "3d", + } + } +} + +impl std::convert::TryFrom< &str> for SearchVideoDimensionEnum { + type Error = (); + fn try_from(value: &str) -> Result { + match value { + "any" => Ok(SearchVideoDimensionEnum::Any), + "2d" => Ok(SearchVideoDimensionEnum::_2d), + "3d" => Ok(SearchVideoDimensionEnum::_3d), + _=> Err(()), + } + } +} + +impl<'a> Into> for &'a SearchVideoDimensionEnum { + fn into(self) -> std::borrow::Cow<'a, str> { + self.as_ref().into() + } +} + + +#[derive(Clone, Copy, Eq, Hash, Debug, PartialEq, Serialize, Deserialize)] +/// Filter on the duration of the videos. +pub enum SearchVideoDurationEnum { + + /// "videoDurationUnspecified" + #[serde(rename="videoDurationUnspecified")] + VideoDurationUnspecified, + + + /// Do not filter video search results based on their duration. This is the default value. + /// + /// "any" + #[serde(rename="any")] + Any, + + + /// Only include videos that are less than four minutes long. + /// + /// "short" + #[serde(rename="short")] + Short, + + + /// Only include videos that are between four and 20 minutes long (inclusive). + /// + /// "medium" + #[serde(rename="medium")] + Medium, + + + /// Only include videos longer than 20 minutes. + /// + /// "long" + #[serde(rename="long")] + Long, +} + +impl AsRef for SearchVideoDurationEnum { + fn as_ref(&self) -> &str { + match *self { + SearchVideoDurationEnum::VideoDurationUnspecified => "videoDurationUnspecified", + SearchVideoDurationEnum::Any => "any", + SearchVideoDurationEnum::Short => "short", + SearchVideoDurationEnum::Medium => "medium", + SearchVideoDurationEnum::Long => "long", + } + } +} + +impl std::convert::TryFrom< &str> for SearchVideoDurationEnum { + type Error = (); + fn try_from(value: &str) -> Result { + match value { + "videoDurationUnspecified" => Ok(SearchVideoDurationEnum::VideoDurationUnspecified), + "any" => Ok(SearchVideoDurationEnum::Any), + "short" => Ok(SearchVideoDurationEnum::Short), + "medium" => Ok(SearchVideoDurationEnum::Medium), + "long" => Ok(SearchVideoDurationEnum::Long), + _=> Err(()), + } + } +} + +impl<'a> Into> for &'a SearchVideoDurationEnum { + fn into(self) -> std::borrow::Cow<'a, str> { + self.as_ref().into() + } +} + + +#[derive(Clone, Copy, Eq, Hash, Debug, PartialEq, Serialize, Deserialize)] +/// Filter on embeddable videos. +pub enum SearchVideoEmbeddableEnum { + + /// "videoEmbeddableUnspecified" + #[serde(rename="videoEmbeddableUnspecified")] + VideoEmbeddableUnspecified, + + + /// Return all videos, embeddable or not. + /// + /// "any" + #[serde(rename="any")] + Any, + + + /// Only retrieve embeddable videos. + /// + /// "true" + #[serde(rename="true")] + True, +} + +impl AsRef for SearchVideoEmbeddableEnum { + fn as_ref(&self) -> &str { + match *self { + SearchVideoEmbeddableEnum::VideoEmbeddableUnspecified => "videoEmbeddableUnspecified", + SearchVideoEmbeddableEnum::Any => "any", + SearchVideoEmbeddableEnum::True => "true", + } + } +} + +impl std::convert::TryFrom< &str> for SearchVideoEmbeddableEnum { + type Error = (); + fn try_from(value: &str) -> Result { + match value { + "videoEmbeddableUnspecified" => Ok(SearchVideoEmbeddableEnum::VideoEmbeddableUnspecified), + "any" => Ok(SearchVideoEmbeddableEnum::Any), + "true" => Ok(SearchVideoEmbeddableEnum::True), + _=> Err(()), + } + } +} + +impl<'a> Into> for &'a SearchVideoEmbeddableEnum { + fn into(self) -> std::borrow::Cow<'a, str> { + self.as_ref().into() + } +} + + +#[derive(Clone, Copy, Eq, Hash, Debug, PartialEq, Serialize, Deserialize)] +/// Filter on the license of the videos. +pub enum SearchVideoLicenseEnum { + + + /// Return all videos, regardless of which license they have, that match the query parameters. + /// + /// "any" + #[serde(rename="any")] + Any, + + + /// Only return videos that have the standard YouTube license. + /// + /// "youtube" + #[serde(rename="youtube")] + Youtube, + + + /// Only return videos that have a Creative Commons license. Users can reuse videos with this license in other videos that they create. Learn more. + /// + /// "creativeCommon" + #[serde(rename="creativeCommon")] + CreativeCommon, +} + +impl AsRef for SearchVideoLicenseEnum { + fn as_ref(&self) -> &str { + match *self { + SearchVideoLicenseEnum::Any => "any", + SearchVideoLicenseEnum::Youtube => "youtube", + SearchVideoLicenseEnum::CreativeCommon => "creativeCommon", + } + } +} + +impl std::convert::TryFrom< &str> for SearchVideoLicenseEnum { + type Error = (); + fn try_from(value: &str) -> Result { + match value { + "any" => Ok(SearchVideoLicenseEnum::Any), + "youtube" => Ok(SearchVideoLicenseEnum::Youtube), + "creativeCommon" => Ok(SearchVideoLicenseEnum::CreativeCommon), + _=> Err(()), + } + } +} + +impl<'a> Into> for &'a SearchVideoLicenseEnum { + fn into(self) -> std::borrow::Cow<'a, str> { + self.as_ref().into() + } +} + + +#[derive(Clone, Copy, Eq, Hash, Debug, PartialEq, Serialize, Deserialize)] +pub enum SearchVideoPaidProductPlacementEnum { + + /// "videoPaidProductPlacementUnspecified" + #[serde(rename="videoPaidProductPlacementUnspecified")] + VideoPaidProductPlacementUnspecified, + + + /// Return all videos, paid product placement or not. + /// + /// "any" + #[serde(rename="any")] + Any, + + + /// Restrict results to only videos with paid product placement. + /// + /// "true" + #[serde(rename="true")] + True, +} + +impl AsRef for SearchVideoPaidProductPlacementEnum { + fn as_ref(&self) -> &str { + match *self { + SearchVideoPaidProductPlacementEnum::VideoPaidProductPlacementUnspecified => "videoPaidProductPlacementUnspecified", + SearchVideoPaidProductPlacementEnum::Any => "any", + SearchVideoPaidProductPlacementEnum::True => "true", + } + } +} + +impl std::convert::TryFrom< &str> for SearchVideoPaidProductPlacementEnum { + type Error = (); + fn try_from(value: &str) -> Result { + match value { + "videoPaidProductPlacementUnspecified" => Ok(SearchVideoPaidProductPlacementEnum::VideoPaidProductPlacementUnspecified), + "any" => Ok(SearchVideoPaidProductPlacementEnum::Any), + "true" => Ok(SearchVideoPaidProductPlacementEnum::True), + _=> Err(()), + } + } +} + +impl<'a> Into> for &'a SearchVideoPaidProductPlacementEnum { + fn into(self) -> std::borrow::Cow<'a, str> { + self.as_ref().into() + } +} + + +#[derive(Clone, Copy, Eq, Hash, Debug, PartialEq, Serialize, Deserialize)] +/// Filter on syndicated videos. +pub enum SearchVideoSyndicatedEnum { + + /// "videoSyndicatedUnspecified" + #[serde(rename="videoSyndicatedUnspecified")] + VideoSyndicatedUnspecified, + + + /// Return all videos, syndicated or not. + /// + /// "any" + #[serde(rename="any")] + Any, + + + /// Only retrieve syndicated videos. + /// + /// "true" + #[serde(rename="true")] + True, +} + +impl AsRef for SearchVideoSyndicatedEnum { + fn as_ref(&self) -> &str { + match *self { + SearchVideoSyndicatedEnum::VideoSyndicatedUnspecified => "videoSyndicatedUnspecified", + SearchVideoSyndicatedEnum::Any => "any", + SearchVideoSyndicatedEnum::True => "true", + } + } +} + +impl std::convert::TryFrom< &str> for SearchVideoSyndicatedEnum { + type Error = (); + fn try_from(value: &str) -> Result { + match value { + "videoSyndicatedUnspecified" => Ok(SearchVideoSyndicatedEnum::VideoSyndicatedUnspecified), + "any" => Ok(SearchVideoSyndicatedEnum::Any), + "true" => Ok(SearchVideoSyndicatedEnum::True), + _=> Err(()), + } + } +} + +impl<'a> Into> for &'a SearchVideoSyndicatedEnum { + fn into(self) -> std::borrow::Cow<'a, str> { + self.as_ref().into() + } +} + + +#[derive(Clone, Copy, Eq, Hash, Debug, PartialEq, Serialize, Deserialize)] +/// Filter on videos of a specific type. +pub enum SearchVideoTypeEnum { + + /// "videoTypeUnspecified" + #[serde(rename="videoTypeUnspecified")] + VideoTypeUnspecified, + + + /// Return all videos. + /// + /// "any" + #[serde(rename="any")] + Any, + + + /// Only retrieve movies. + /// + /// "movie" + #[serde(rename="movie")] + Movie, + + + /// Only retrieve episodes of shows. + /// + /// "episode" + #[serde(rename="episode")] + Episode, +} + +impl AsRef for SearchVideoTypeEnum { + fn as_ref(&self) -> &str { + match *self { + SearchVideoTypeEnum::VideoTypeUnspecified => "videoTypeUnspecified", + SearchVideoTypeEnum::Any => "any", + SearchVideoTypeEnum::Movie => "movie", + SearchVideoTypeEnum::Episode => "episode", + } + } +} + +impl std::convert::TryFrom< &str> for SearchVideoTypeEnum { + type Error = (); + fn try_from(value: &str) -> Result { + match value { + "videoTypeUnspecified" => Ok(SearchVideoTypeEnum::VideoTypeUnspecified), + "any" => Ok(SearchVideoTypeEnum::Any), + "movie" => Ok(SearchVideoTypeEnum::Movie), + "episode" => Ok(SearchVideoTypeEnum::Episode), + _=> Err(()), + } + } +} + +impl<'a> Into> for &'a SearchVideoTypeEnum { + fn into(self) -> std::borrow::Cow<'a, str> { + self.as_ref().into() + } +} + + +#[derive(Clone, Copy, Eq, Hash, Debug, PartialEq, Serialize, Deserialize)] +/// The order of the returned subscriptions +pub enum SubscriptionOrderEnum { + + /// "subscriptionOrderUnspecified" + #[serde(rename="subscriptionOrderUnspecified")] + SubscriptionOrderUnspecified, + + + /// Sort by relevance. + /// + /// "relevance" + #[serde(rename="relevance")] + Relevance, + + + /// Sort by order of activity. + /// + /// "unread" + #[serde(rename="unread")] + Unread, + + + /// Sort alphabetically. + /// + /// "alphabetical" + #[serde(rename="alphabetical")] + Alphabetical, +} + +impl AsRef for SubscriptionOrderEnum { + fn as_ref(&self) -> &str { + match *self { + SubscriptionOrderEnum::SubscriptionOrderUnspecified => "subscriptionOrderUnspecified", + SubscriptionOrderEnum::Relevance => "relevance", + SubscriptionOrderEnum::Unread => "unread", + SubscriptionOrderEnum::Alphabetical => "alphabetical", + } + } +} + +impl std::convert::TryFrom< &str> for SubscriptionOrderEnum { + type Error = (); + fn try_from(value: &str) -> Result { + match value { + "subscriptionOrderUnspecified" => Ok(SubscriptionOrderEnum::SubscriptionOrderUnspecified), + "relevance" => Ok(SubscriptionOrderEnum::Relevance), + "unread" => Ok(SubscriptionOrderEnum::Unread), + "alphabetical" => Ok(SubscriptionOrderEnum::Alphabetical), + _=> Err(()), + } + } +} + +impl<'a> Into> for &'a SubscriptionOrderEnum { + fn into(self) -> std::borrow::Cow<'a, str> { + self.as_ref().into() + } +} + +impl Default for SubscriptionOrderEnum { + fn default() -> SubscriptionOrderEnum { + SubscriptionOrderEnum::Relevance + } +} + +#[derive(Clone, Copy, Eq, Hash, Debug, PartialEq, Serialize, Deserialize)] +/// Get a third party link of the given type. +pub enum ThirdPartyLinkTypeEnum { + + /// "linkUnspecified" + #[serde(rename="linkUnspecified")] + LinkUnspecified, + + + /// A link that is connecting (or about to connect) a channel with a store on a merchandising platform in order to enable retail commerce capabilities for that channel on YouTube. + /// + /// "channelToStoreLink" + #[serde(rename="channelToStoreLink")] + ChannelToStoreLink, +} + +impl AsRef for ThirdPartyLinkTypeEnum { + fn as_ref(&self) -> &str { + match *self { + ThirdPartyLinkTypeEnum::LinkUnspecified => "linkUnspecified", + ThirdPartyLinkTypeEnum::ChannelToStoreLink => "channelToStoreLink", + } + } +} + +impl std::convert::TryFrom< &str> for ThirdPartyLinkTypeEnum { + type Error = (); + fn try_from(value: &str) -> Result { + match value { + "linkUnspecified" => Ok(ThirdPartyLinkTypeEnum::LinkUnspecified), + "channelToStoreLink" => Ok(ThirdPartyLinkTypeEnum::ChannelToStoreLink), + _=> Err(()), + } + } +} + +impl<'a> Into> for &'a ThirdPartyLinkTypeEnum { + fn into(self) -> std::borrow::Cow<'a, str> { + self.as_ref().into() + } +} + + +#[derive(Clone, Copy, Eq, Hash, Debug, PartialEq, Serialize, Deserialize)] +/// Return the videos that are in the specified chart. +pub enum VideoChartEnum { + + /// "chartUnspecified" + #[serde(rename="chartUnspecified")] + ChartUnspecified, + + + /// Return the most popular videos for the specified content region and video category. + /// + /// "mostPopular" + #[serde(rename="mostPopular")] + MostPopular, +} + +impl AsRef for VideoChartEnum { + fn as_ref(&self) -> &str { + match *self { + VideoChartEnum::ChartUnspecified => "chartUnspecified", + VideoChartEnum::MostPopular => "mostPopular", + } + } +} + +impl std::convert::TryFrom< &str> for VideoChartEnum { + type Error = (); + fn try_from(value: &str) -> Result { + match value { + "chartUnspecified" => Ok(VideoChartEnum::ChartUnspecified), + "mostPopular" => Ok(VideoChartEnum::MostPopular), + _=> Err(()), + } + } +} + +impl<'a> Into> for &'a VideoChartEnum { + fn into(self) -> std::borrow::Cow<'a, str> { + self.as_ref().into() + } +} + + +#[derive(Clone, Copy, Eq, Hash, Debug, PartialEq, Serialize, Deserialize)] +/// Return videos liked/disliked by the authenticated user. Does not support RateType.RATED_TYPE_NONE. +pub enum VideoMyRatingEnum { + + /// "none" + #[serde(rename="none")] + None, + + + /// The entity is liked. + /// + /// "like" + #[serde(rename="like")] + Like, + + + /// The entity is disliked. + /// + /// "dislike" + #[serde(rename="dislike")] + Dislike, +} + +impl AsRef for VideoMyRatingEnum { + fn as_ref(&self) -> &str { + match *self { + VideoMyRatingEnum::None => "none", + VideoMyRatingEnum::Like => "like", + VideoMyRatingEnum::Dislike => "dislike", + } + } +} + +impl std::convert::TryFrom< &str> for VideoMyRatingEnum { + type Error = (); + fn try_from(value: &str) -> Result { + match value { + "none" => Ok(VideoMyRatingEnum::None), + "like" => Ok(VideoMyRatingEnum::Like), + "dislike" => Ok(VideoMyRatingEnum::Dislike), + _=> Err(()), + } + } +} + +impl<'a> Into> for &'a VideoMyRatingEnum { + fn into(self) -> std::borrow::Cow<'a, str> { + self.as_ref().into() + } +} + + +#[derive(Clone, Copy, Eq, Hash, Debug, PartialEq, Serialize, Deserialize)] +pub enum VideoRatingEnum { + + /// "none" + #[serde(rename="none")] + None, + + + /// The entity is liked. + /// + /// "like" + #[serde(rename="like")] + Like, + + + /// The entity is disliked. + /// + /// "dislike" + #[serde(rename="dislike")] + Dislike, +} + +impl AsRef for VideoRatingEnum { + fn as_ref(&self) -> &str { + match *self { + VideoRatingEnum::None => "none", + VideoRatingEnum::Like => "like", + VideoRatingEnum::Dislike => "dislike", + } + } +} + +impl std::convert::TryFrom< &str> for VideoRatingEnum { + type Error = (); + fn try_from(value: &str) -> Result { + match value { + "none" => Ok(VideoRatingEnum::None), + "like" => Ok(VideoRatingEnum::Like), + "dislike" => Ok(VideoRatingEnum::Dislike), + _=> Err(()), + } + } +} + +impl<'a> Into> for &'a VideoRatingEnum { + fn into(self) -> std::borrow::Cow<'a, str> { + self.as_ref().into() + } +} + + diff --git a/gen/youtube3/src/api/hub.rs b/gen/youtube3/src/api/hub.rs new file mode 100644 index 0000000000..f54622da89 --- /dev/null +++ b/gen/youtube3/src/api/hub.rs @@ -0,0 +1,208 @@ +use super::*; + +/// Central instance to access all YouTube related resource activities +/// +/// # Examples +/// +/// Instantiate a new hub +/// +/// ```test_harness,no_run +/// extern crate hyper; +/// extern crate hyper_rustls; +/// extern crate google_youtube3 as youtube3; +/// use youtube3::{Result, Error}; +/// # async fn dox() { +/// use std::default::Default; +/// use youtube3::{YouTube, oauth2, hyper, hyper_rustls, chrono, FieldMask}; +/// +/// // Get an ApplicationSecret instance by some means. It contains the `client_id` and +/// // `client_secret`, among other things. +/// let secret: oauth2::ApplicationSecret = Default::default(); +/// // Instantiate the authenticator. It will choose a suitable authentication flow for you, +/// // unless you replace `None` with the desired Flow. +/// // Provide your own `AuthenticatorDelegate` to adjust the way it operates and get feedback about +/// // what's going on. You probably want to bring in your own `TokenStorage` to persist tokens and +/// // retrieve them from storage. +/// let auth = oauth2::InstalledFlowAuthenticator::builder( +/// secret, +/// oauth2::InstalledFlowReturnMethod::HTTPRedirect, +/// ).build().await.unwrap(); +/// let mut hub = YouTube::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().unwrap().https_or_http().enable_http1().build()), auth); +/// // You can configure optional parameters by calling the respective setters at will, and +/// // execute the final call using `doit()`. +/// // Values shown here are possibly random and not representative ! +/// let result = hub.videos().list(&vec!["duo".into()]) +/// .video_category_id("ipsum") +/// .region_code("sed") +/// .page_token("ut") +/// .on_behalf_of_content_owner("gubergren") +/// .my_rating(&Default::default()) +/// .max_width(-16) +/// .max_results(44) +/// .max_height(-50) +/// .locale("ipsum") +/// .add_id("est") +/// .hl("gubergren") +/// .chart(&Default::default()) +/// .doit().await; +/// +/// match result { +/// Err(e) => match e { +/// // The Error enum provides details about what exactly happened. +/// // You can also just use its `Debug`, `Display` or `Error` traits +/// Error::HttpError(_) +/// |Error::Io(_) +/// |Error::MissingAPIKey +/// |Error::MissingToken(_) +/// |Error::Cancelled +/// |Error::UploadSizeLimitExceeded(_, _) +/// |Error::Failure(_) +/// |Error::BadRequest(_) +/// |Error::FieldClash(_) +/// |Error::JsonDecodeError(_, _) => println!("{}", e), +/// }, +/// Ok(res) => println!("Success: {:?}", res), +/// } +/// # } +/// ``` +#[derive(Clone)] +pub struct YouTube { + pub client: hyper::Client, + pub auth: Box, + pub(super) _user_agent: String, + pub(super) _base_url: String, + pub(super) _root_url: String, +} + +impl<'a, S> client::Hub for YouTube {} + +impl<'a, S> YouTube { + + pub fn new(client: hyper::Client, auth: A) -> YouTube { + YouTube { + client, + auth: Box::new(auth), + _user_agent: "google-api-rust-client/5.0.5".to_string(), + _base_url: "https://youtube.googleapis.com/".to_string(), + _root_url: "https://youtube.googleapis.com/".to_string(), + } + } + + pub fn abuse_reports(&'a self) -> AbuseReportMethods<'a, S> { + AbuseReportMethods { hub: &self } + } + pub fn activities(&'a self) -> ActivityMethods<'a, S> { + ActivityMethods { hub: &self } + } + pub fn captions(&'a self) -> CaptionMethods<'a, S> { + CaptionMethods { hub: &self } + } + pub fn channel_banners(&'a self) -> ChannelBannerMethods<'a, S> { + ChannelBannerMethods { hub: &self } + } + pub fn channel_sections(&'a self) -> ChannelSectionMethods<'a, S> { + ChannelSectionMethods { hub: &self } + } + pub fn channels(&'a self) -> ChannelMethods<'a, S> { + ChannelMethods { hub: &self } + } + pub fn comment_threads(&'a self) -> CommentThreadMethods<'a, S> { + CommentThreadMethods { hub: &self } + } + pub fn comments(&'a self) -> CommentMethods<'a, S> { + CommentMethods { hub: &self } + } + pub fn i18n_languages(&'a self) -> I18nLanguageMethods<'a, S> { + I18nLanguageMethods { hub: &self } + } + pub fn i18n_regions(&'a self) -> I18nRegionMethods<'a, S> { + I18nRegionMethods { hub: &self } + } + pub fn live_broadcasts(&'a self) -> LiveBroadcastMethods<'a, S> { + LiveBroadcastMethods { hub: &self } + } + pub fn live_chat_bans(&'a self) -> LiveChatBanMethods<'a, S> { + LiveChatBanMethods { hub: &self } + } + pub fn live_chat_messages(&'a self) -> LiveChatMessageMethods<'a, S> { + LiveChatMessageMethods { hub: &self } + } + pub fn live_chat_moderators(&'a self) -> LiveChatModeratorMethods<'a, S> { + LiveChatModeratorMethods { hub: &self } + } + pub fn live_streams(&'a self) -> LiveStreamMethods<'a, S> { + LiveStreamMethods { hub: &self } + } + pub fn members(&'a self) -> MemberMethods<'a, S> { + MemberMethods { hub: &self } + } + pub fn memberships_levels(&'a self) -> MembershipsLevelMethods<'a, S> { + MembershipsLevelMethods { hub: &self } + } + pub fn playlist_images(&'a self) -> PlaylistImageMethods<'a, S> { + PlaylistImageMethods { hub: &self } + } + pub fn playlist_items(&'a self) -> PlaylistItemMethods<'a, S> { + PlaylistItemMethods { hub: &self } + } + pub fn playlists(&'a self) -> PlaylistMethods<'a, S> { + PlaylistMethods { hub: &self } + } + pub fn search(&'a self) -> SearchMethods<'a, S> { + SearchMethods { hub: &self } + } + pub fn subscriptions(&'a self) -> SubscriptionMethods<'a, S> { + SubscriptionMethods { hub: &self } + } + pub fn super_chat_events(&'a self) -> SuperChatEventMethods<'a, S> { + SuperChatEventMethods { hub: &self } + } + pub fn tests(&'a self) -> TestMethods<'a, S> { + TestMethods { hub: &self } + } + pub fn third_party_links(&'a self) -> ThirdPartyLinkMethods<'a, S> { + ThirdPartyLinkMethods { hub: &self } + } + pub fn thumbnails(&'a self) -> ThumbnailMethods<'a, S> { + ThumbnailMethods { hub: &self } + } + pub fn video_abuse_report_reasons(&'a self) -> VideoAbuseReportReasonMethods<'a, S> { + VideoAbuseReportReasonMethods { hub: &self } + } + pub fn video_categories(&'a self) -> VideoCategoryMethods<'a, S> { + VideoCategoryMethods { hub: &self } + } + pub fn videos(&'a self) -> VideoMethods<'a, S> { + VideoMethods { hub: &self } + } + pub fn watermarks(&'a self) -> WatermarkMethods<'a, S> { + WatermarkMethods { hub: &self } + } + pub fn youtube(&'a self) -> YoutubeMethods<'a, S> { + YoutubeMethods { hub: &self } + } + + /// Set the user-agent header field to use in all requests to the server. + /// It defaults to `google-api-rust-client/5.0.5`. + /// + /// Returns the previously set user-agent. + pub fn user_agent(&mut self, agent_name: String) -> String { + mem::replace(&mut self._user_agent, agent_name) + } + + /// Set the base url to use in all requests to the server. + /// It defaults to `https://youtube.googleapis.com/`. + /// + /// Returns the previously set base url. + pub fn base_url(&mut self, new_base_url: String) -> String { + mem::replace(&mut self._base_url, new_base_url) + } + + /// Set the root url to use in all requests to the server. + /// It defaults to `https://youtube.googleapis.com/`. + /// + /// Returns the previously set root url. + pub fn root_url(&mut self, new_root_url: String) -> String { + mem::replace(&mut self._root_url, new_root_url) + } +} diff --git a/gen/youtube3/src/api/method_builders.rs b/gen/youtube3/src/api/method_builders.rs new file mode 100644 index 0000000000..ade99fd03c --- /dev/null +++ b/gen/youtube3/src/api/method_builders.rs @@ -0,0 +1,2941 @@ +use super::*; +/// A builder providing access to all methods supported on *abuseReport* resources. +/// It is not used directly, but through the [`YouTube`] hub. +/// +/// # Example +/// +/// Instantiate a resource builder +/// +/// ```test_harness,no_run +/// extern crate hyper; +/// extern crate hyper_rustls; +/// extern crate google_youtube3 as youtube3; +/// +/// # async fn dox() { +/// use std::default::Default; +/// use youtube3::{YouTube, oauth2, hyper, hyper_rustls, chrono, FieldMask}; +/// +/// let secret: oauth2::ApplicationSecret = Default::default(); +/// let auth = oauth2::InstalledFlowAuthenticator::builder( +/// secret, +/// oauth2::InstalledFlowReturnMethod::HTTPRedirect, +/// ).build().await.unwrap(); +/// let mut hub = YouTube::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().unwrap().https_or_http().enable_http1().build()), auth); +/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* +/// // like `insert(...)` +/// // to build up your call. +/// let rb = hub.abuse_reports(); +/// # } +/// ``` +pub struct AbuseReportMethods<'a, S> + where S: 'a { + + pub(super) hub: &'a YouTube, +} + +impl<'a, S> client::MethodsBuilder for AbuseReportMethods<'a, S> {} + +impl<'a, S> AbuseReportMethods<'a, S> { + + /// Create a builder to help you perform the following task: + /// + /// Inserts a new resource into this collection. + /// + /// # Arguments + /// + /// * `request` - No description provided. + pub fn insert(&self, request: AbuseReport) -> AbuseReportInsertCall<'a, S> { + use client::ToParts; + let parts = vec![request.to_parts()]; + AbuseReportInsertCall { + hub: self.hub, + _request: request, + _part: parts, + _delegate: Default::default(), + _additional_params: Default::default(), + _scopes: Default::default(), + } + } +} + + + +/// A builder providing access to all methods supported on *activity* resources. +/// It is not used directly, but through the [`YouTube`] hub. +/// +/// # Example +/// +/// Instantiate a resource builder +/// +/// ```test_harness,no_run +/// extern crate hyper; +/// extern crate hyper_rustls; +/// extern crate google_youtube3 as youtube3; +/// +/// # async fn dox() { +/// use std::default::Default; +/// use youtube3::{YouTube, oauth2, hyper, hyper_rustls, chrono, FieldMask}; +/// +/// let secret: oauth2::ApplicationSecret = Default::default(); +/// let auth = oauth2::InstalledFlowAuthenticator::builder( +/// secret, +/// oauth2::InstalledFlowReturnMethod::HTTPRedirect, +/// ).build().await.unwrap(); +/// let mut hub = YouTube::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().unwrap().https_or_http().enable_http1().build()), auth); +/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* +/// // like `list(...)` +/// // to build up your call. +/// let rb = hub.activities(); +/// # } +/// ``` +pub struct ActivityMethods<'a, S> + where S: 'a { + + pub(super) hub: &'a YouTube, +} + +impl<'a, S> client::MethodsBuilder for ActivityMethods<'a, S> {} + +impl<'a, S> ActivityMethods<'a, S> { + + /// Create a builder to help you perform the following task: + /// + /// Retrieves a list of resources, possibly filtered. + /// + /// # Arguments + /// + /// * `part` - The *part* parameter specifies a comma-separated list of one or more activity resource properties that the API response will include. If the parameter identifies a property that contains child properties, the child properties will be included in the response. For example, in an activity resource, the snippet property contains other properties that identify the type of activity, a display title for the activity, and so forth. If you set *part=snippet*, the API response will also contain all of those nested properties. + pub fn list(&self, part: &Vec) -> ActivityListCall<'a, S> { + ActivityListCall { + hub: self.hub, + _part: part.clone(), + _region_code: Default::default(), + _published_before: Default::default(), + _published_after: Default::default(), + _page_token: Default::default(), + _mine: Default::default(), + _max_results: Default::default(), + _home: Default::default(), + _channel_id: Default::default(), + _delegate: Default::default(), + _additional_params: Default::default(), + _scopes: Default::default(), + } + } +} + + + +/// A builder providing access to all methods supported on *caption* resources. +/// It is not used directly, but through the [`YouTube`] hub. +/// +/// # Example +/// +/// Instantiate a resource builder +/// +/// ```test_harness,no_run +/// extern crate hyper; +/// extern crate hyper_rustls; +/// extern crate google_youtube3 as youtube3; +/// +/// # async fn dox() { +/// use std::default::Default; +/// use youtube3::{YouTube, oauth2, hyper, hyper_rustls, chrono, FieldMask}; +/// +/// let secret: oauth2::ApplicationSecret = Default::default(); +/// let auth = oauth2::InstalledFlowAuthenticator::builder( +/// secret, +/// oauth2::InstalledFlowReturnMethod::HTTPRedirect, +/// ).build().await.unwrap(); +/// let mut hub = YouTube::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().unwrap().https_or_http().enable_http1().build()), auth); +/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* +/// // like `delete(...)`, `download(...)`, `insert(...)`, `list(...)` and `update(...)` +/// // to build up your call. +/// let rb = hub.captions(); +/// # } +/// ``` +pub struct CaptionMethods<'a, S> + where S: 'a { + + pub(super) hub: &'a YouTube, +} + +impl<'a, S> client::MethodsBuilder for CaptionMethods<'a, S> {} + +impl<'a, S> CaptionMethods<'a, S> { + + /// Create a builder to help you perform the following task: + /// + /// Deletes a resource. + /// + /// # Arguments + /// + /// * `id` - No description provided. + pub fn delete(&self, id: &str) -> CaptionDeleteCall<'a, S> { + CaptionDeleteCall { + hub: self.hub, + _id: id.to_string(), + _on_behalf_of_content_owner: Default::default(), + _on_behalf_of: Default::default(), + _delegate: Default::default(), + _additional_params: Default::default(), + _scopes: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Downloads a caption track. + /// + /// # Arguments + /// + /// * `id` - The ID of the caption track to download, required for One Platform. + pub fn download(&self, id: &str) -> CaptionDownloadCall<'a, S> { + CaptionDownloadCall { + hub: self.hub, + _id: id.to_string(), + _tlang: Default::default(), + _tfmt: Default::default(), + _on_behalf_of_content_owner: Default::default(), + _on_behalf_of: Default::default(), + _delegate: Default::default(), + _additional_params: Default::default(), + _scopes: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Inserts a new resource into this collection. + /// + /// # Arguments + /// + /// * `request` - No description provided. + pub fn insert(&self, request: Caption) -> CaptionInsertCall<'a, S> { + use client::ToParts; + let parts = vec![request.to_parts()]; + CaptionInsertCall { + hub: self.hub, + _request: request, + _part: parts, + _sync: Default::default(), + _on_behalf_of_content_owner: Default::default(), + _on_behalf_of: Default::default(), + _delegate: Default::default(), + _additional_params: Default::default(), + _scopes: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Retrieves a list of resources, possibly filtered. + /// + /// # Arguments + /// + /// * `part` - The *part* parameter specifies a comma-separated list of one or more caption resource parts that the API response will include. The part names that you can include in the parameter value are id and snippet. + /// * `videoId` - Returns the captions for the specified video. + pub fn list(&self, part: &Vec, video_id: &str) -> CaptionListCall<'a, S> { + CaptionListCall { + hub: self.hub, + _part: part.clone(), + _video_id: video_id.to_string(), + _on_behalf_of_content_owner: Default::default(), + _on_behalf_of: Default::default(), + _id: Default::default(), + _delegate: Default::default(), + _additional_params: Default::default(), + _scopes: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Updates an existing resource. + /// + /// # Arguments + /// + /// * `request` - No description provided. + pub fn update(&self, request: Caption) -> CaptionUpdateCall<'a, S> { + use client::ToParts; + let parts = vec![request.to_parts()]; + CaptionUpdateCall { + hub: self.hub, + _request: request, + _part: parts, + _sync: Default::default(), + _on_behalf_of_content_owner: Default::default(), + _on_behalf_of: Default::default(), + _delegate: Default::default(), + _additional_params: Default::default(), + _scopes: Default::default(), + } + } +} + + + +/// A builder providing access to all methods supported on *channelBanner* resources. +/// It is not used directly, but through the [`YouTube`] hub. +/// +/// # Example +/// +/// Instantiate a resource builder +/// +/// ```test_harness,no_run +/// extern crate hyper; +/// extern crate hyper_rustls; +/// extern crate google_youtube3 as youtube3; +/// +/// # async fn dox() { +/// use std::default::Default; +/// use youtube3::{YouTube, oauth2, hyper, hyper_rustls, chrono, FieldMask}; +/// +/// let secret: oauth2::ApplicationSecret = Default::default(); +/// let auth = oauth2::InstalledFlowAuthenticator::builder( +/// secret, +/// oauth2::InstalledFlowReturnMethod::HTTPRedirect, +/// ).build().await.unwrap(); +/// let mut hub = YouTube::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().unwrap().https_or_http().enable_http1().build()), auth); +/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* +/// // like `insert(...)` +/// // to build up your call. +/// let rb = hub.channel_banners(); +/// # } +/// ``` +pub struct ChannelBannerMethods<'a, S> + where S: 'a { + + pub(super) hub: &'a YouTube, +} + +impl<'a, S> client::MethodsBuilder for ChannelBannerMethods<'a, S> {} + +impl<'a, S> ChannelBannerMethods<'a, S> { + + /// Create a builder to help you perform the following task: + /// + /// Inserts a new resource into this collection. + /// + /// # Arguments + /// + /// * `request` - No description provided. + pub fn insert(&self, request: ChannelBannerResource) -> ChannelBannerInsertCall<'a, S> { + ChannelBannerInsertCall { + hub: self.hub, + _request: request, + _on_behalf_of_content_owner_channel: Default::default(), + _on_behalf_of_content_owner: Default::default(), + _channel_id: Default::default(), + _delegate: Default::default(), + _additional_params: Default::default(), + _scopes: Default::default(), + } + } +} + + + +/// A builder providing access to all methods supported on *channelSection* resources. +/// It is not used directly, but through the [`YouTube`] hub. +/// +/// # Example +/// +/// Instantiate a resource builder +/// +/// ```test_harness,no_run +/// extern crate hyper; +/// extern crate hyper_rustls; +/// extern crate google_youtube3 as youtube3; +/// +/// # async fn dox() { +/// use std::default::Default; +/// use youtube3::{YouTube, oauth2, hyper, hyper_rustls, chrono, FieldMask}; +/// +/// let secret: oauth2::ApplicationSecret = Default::default(); +/// let auth = oauth2::InstalledFlowAuthenticator::builder( +/// secret, +/// oauth2::InstalledFlowReturnMethod::HTTPRedirect, +/// ).build().await.unwrap(); +/// let mut hub = YouTube::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().unwrap().https_or_http().enable_http1().build()), auth); +/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* +/// // like `delete(...)`, `insert(...)`, `list(...)` and `update(...)` +/// // to build up your call. +/// let rb = hub.channel_sections(); +/// # } +/// ``` +pub struct ChannelSectionMethods<'a, S> + where S: 'a { + + pub(super) hub: &'a YouTube, +} + +impl<'a, S> client::MethodsBuilder for ChannelSectionMethods<'a, S> {} + +impl<'a, S> ChannelSectionMethods<'a, S> { + + /// Create a builder to help you perform the following task: + /// + /// Deletes a resource. + /// + /// # Arguments + /// + /// * `id` - No description provided. + pub fn delete(&self, id: &str) -> ChannelSectionDeleteCall<'a, S> { + ChannelSectionDeleteCall { + hub: self.hub, + _id: id.to_string(), + _on_behalf_of_content_owner: Default::default(), + _delegate: Default::default(), + _additional_params: Default::default(), + _scopes: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Inserts a new resource into this collection. + /// + /// # Arguments + /// + /// * `request` - No description provided. + pub fn insert(&self, request: ChannelSection) -> ChannelSectionInsertCall<'a, S> { + use client::ToParts; + let parts = vec![request.to_parts()]; + ChannelSectionInsertCall { + hub: self.hub, + _request: request, + _part: parts, + _on_behalf_of_content_owner_channel: Default::default(), + _on_behalf_of_content_owner: Default::default(), + _delegate: Default::default(), + _additional_params: Default::default(), + _scopes: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Retrieves a list of resources, possibly filtered. + /// + /// # Arguments + /// + /// * `part` - The *part* parameter specifies a comma-separated list of one or more channelSection resource properties that the API response will include. The part names that you can include in the parameter value are id, snippet, and contentDetails. If the parameter identifies a property that contains child properties, the child properties will be included in the response. For example, in a channelSection resource, the snippet property contains other properties, such as a display title for the channelSection. If you set *part=snippet*, the API response will also contain all of those nested properties. + pub fn list(&self, part: &Vec) -> ChannelSectionListCall<'a, S> { + ChannelSectionListCall { + hub: self.hub, + _part: part.clone(), + _on_behalf_of_content_owner: Default::default(), + _mine: Default::default(), + _id: Default::default(), + _hl: Default::default(), + _channel_id: Default::default(), + _delegate: Default::default(), + _additional_params: Default::default(), + _scopes: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Updates an existing resource. + /// + /// # Arguments + /// + /// * `request` - No description provided. + pub fn update(&self, request: ChannelSection) -> ChannelSectionUpdateCall<'a, S> { + use client::ToParts; + let parts = vec![request.to_parts()]; + ChannelSectionUpdateCall { + hub: self.hub, + _request: request, + _part: parts, + _on_behalf_of_content_owner: Default::default(), + _delegate: Default::default(), + _additional_params: Default::default(), + _scopes: Default::default(), + } + } +} + + + +/// A builder providing access to all methods supported on *channel* resources. +/// It is not used directly, but through the [`YouTube`] hub. +/// +/// # Example +/// +/// Instantiate a resource builder +/// +/// ```test_harness,no_run +/// extern crate hyper; +/// extern crate hyper_rustls; +/// extern crate google_youtube3 as youtube3; +/// +/// # async fn dox() { +/// use std::default::Default; +/// use youtube3::{YouTube, oauth2, hyper, hyper_rustls, chrono, FieldMask}; +/// +/// let secret: oauth2::ApplicationSecret = Default::default(); +/// let auth = oauth2::InstalledFlowAuthenticator::builder( +/// secret, +/// oauth2::InstalledFlowReturnMethod::HTTPRedirect, +/// ).build().await.unwrap(); +/// let mut hub = YouTube::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().unwrap().https_or_http().enable_http1().build()), auth); +/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* +/// // like `list(...)` and `update(...)` +/// // to build up your call. +/// let rb = hub.channels(); +/// # } +/// ``` +pub struct ChannelMethods<'a, S> + where S: 'a { + + pub(super) hub: &'a YouTube, +} + +impl<'a, S> client::MethodsBuilder for ChannelMethods<'a, S> {} + +impl<'a, S> ChannelMethods<'a, S> { + + /// Create a builder to help you perform the following task: + /// + /// Retrieves a list of resources, possibly filtered. + /// + /// # Arguments + /// + /// * `part` - The *part* parameter specifies a comma-separated list of one or more channel resource properties that the API response will include. If the parameter identifies a property that contains child properties, the child properties will be included in the response. For example, in a channel resource, the contentDetails property contains other properties, such as the uploads properties. As such, if you set *part=contentDetails*, the API response will also contain all of those nested properties. + pub fn list(&self, part: &Vec) -> ChannelListCall<'a, S> { + ChannelListCall { + hub: self.hub, + _part: part.clone(), + _page_token: Default::default(), + _on_behalf_of_content_owner: Default::default(), + _my_subscribers: Default::default(), + _mine: Default::default(), + _max_results: Default::default(), + _managed_by_me: Default::default(), + _id: Default::default(), + _hl: Default::default(), + _for_username: Default::default(), + _for_handle: Default::default(), + _category_id: Default::default(), + _delegate: Default::default(), + _additional_params: Default::default(), + _scopes: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Updates an existing resource. + /// + /// # Arguments + /// + /// * `request` - No description provided. + pub fn update(&self, request: Channel) -> ChannelUpdateCall<'a, S> { + use client::ToParts; + let parts = vec![request.to_parts()]; + ChannelUpdateCall { + hub: self.hub, + _request: request, + _part: parts, + _on_behalf_of_content_owner: Default::default(), + _delegate: Default::default(), + _additional_params: Default::default(), + _scopes: Default::default(), + } + } +} + + + +/// A builder providing access to all methods supported on *commentThread* resources. +/// It is not used directly, but through the [`YouTube`] hub. +/// +/// # Example +/// +/// Instantiate a resource builder +/// +/// ```test_harness,no_run +/// extern crate hyper; +/// extern crate hyper_rustls; +/// extern crate google_youtube3 as youtube3; +/// +/// # async fn dox() { +/// use std::default::Default; +/// use youtube3::{YouTube, oauth2, hyper, hyper_rustls, chrono, FieldMask}; +/// +/// let secret: oauth2::ApplicationSecret = Default::default(); +/// let auth = oauth2::InstalledFlowAuthenticator::builder( +/// secret, +/// oauth2::InstalledFlowReturnMethod::HTTPRedirect, +/// ).build().await.unwrap(); +/// let mut hub = YouTube::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().unwrap().https_or_http().enable_http1().build()), 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.comment_threads(); +/// # } +/// ``` +pub struct CommentThreadMethods<'a, S> + where S: 'a { + + pub(super) hub: &'a YouTube, +} + +impl<'a, S> client::MethodsBuilder for CommentThreadMethods<'a, S> {} + +impl<'a, S> CommentThreadMethods<'a, S> { + + /// Create a builder to help you perform the following task: + /// + /// Inserts a new resource into this collection. + /// + /// # Arguments + /// + /// * `request` - No description provided. + pub fn insert(&self, request: CommentThread) -> CommentThreadInsertCall<'a, S> { + use client::ToParts; + let parts = vec![request.to_parts()]; + CommentThreadInsertCall { + hub: self.hub, + _request: request, + _part: parts, + _delegate: Default::default(), + _additional_params: Default::default(), + _scopes: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Retrieves a list of resources, possibly filtered. + /// + /// # Arguments + /// + /// * `part` - The *part* parameter specifies a comma-separated list of one or more commentThread resource properties that the API response will include. + pub fn list(&self, part: &Vec) -> CommentThreadListCall<'a, S> { + CommentThreadListCall { + hub: self.hub, + _part: part.clone(), + _video_id: Default::default(), + _text_format: Default::default(), + _search_terms: Default::default(), + _page_token: Default::default(), + _order: Default::default(), + _moderation_status: Default::default(), + _max_results: Default::default(), + _id: Default::default(), + _channel_id: Default::default(), + _all_threads_related_to_channel_id: Default::default(), + _delegate: Default::default(), + _additional_params: Default::default(), + _scopes: Default::default(), + } + } +} + + + +/// A builder providing access to all methods supported on *comment* resources. +/// It is not used directly, but through the [`YouTube`] hub. +/// +/// # Example +/// +/// Instantiate a resource builder +/// +/// ```test_harness,no_run +/// extern crate hyper; +/// extern crate hyper_rustls; +/// extern crate google_youtube3 as youtube3; +/// +/// # async fn dox() { +/// use std::default::Default; +/// use youtube3::{YouTube, oauth2, hyper, hyper_rustls, chrono, FieldMask}; +/// +/// let secret: oauth2::ApplicationSecret = Default::default(); +/// let auth = oauth2::InstalledFlowAuthenticator::builder( +/// secret, +/// oauth2::InstalledFlowReturnMethod::HTTPRedirect, +/// ).build().await.unwrap(); +/// let mut hub = YouTube::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().unwrap().https_or_http().enable_http1().build()), auth); +/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* +/// // like `delete(...)`, `insert(...)`, `list(...)`, `mark_as_spam(...)`, `set_moderation_status(...)` and `update(...)` +/// // to build up your call. +/// let rb = hub.comments(); +/// # } +/// ``` +pub struct CommentMethods<'a, S> + where S: 'a { + + pub(super) hub: &'a YouTube, +} + +impl<'a, S> client::MethodsBuilder for CommentMethods<'a, S> {} + +impl<'a, S> CommentMethods<'a, S> { + + /// Create a builder to help you perform the following task: + /// + /// Deletes a resource. + /// + /// # Arguments + /// + /// * `id` - No description provided. + pub fn delete(&self, id: &str) -> CommentDeleteCall<'a, S> { + CommentDeleteCall { + hub: self.hub, + _id: id.to_string(), + _delegate: Default::default(), + _additional_params: Default::default(), + _scopes: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Inserts a new resource into this collection. + /// + /// # Arguments + /// + /// * `request` - No description provided. + pub fn insert(&self, request: Comment) -> CommentInsertCall<'a, S> { + use client::ToParts; + let parts = vec![request.to_parts()]; + CommentInsertCall { + hub: self.hub, + _request: request, + _part: parts, + _delegate: Default::default(), + _additional_params: Default::default(), + _scopes: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Retrieves a list of resources, possibly filtered. + /// + /// # Arguments + /// + /// * `part` - The *part* parameter specifies a comma-separated list of one or more comment resource properties that the API response will include. + pub fn list(&self, part: &Vec) -> CommentListCall<'a, S> { + CommentListCall { + hub: self.hub, + _part: part.clone(), + _text_format: Default::default(), + _parent_id: Default::default(), + _page_token: Default::default(), + _max_results: Default::default(), + _id: Default::default(), + _delegate: Default::default(), + _additional_params: Default::default(), + _scopes: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Expresses the caller's opinion that one or more comments should be flagged as spam. + /// + /// # Arguments + /// + /// * `id` - Flags the comments with the given IDs as spam in the caller's opinion. + pub fn mark_as_spam(&self, id: &Vec) -> CommentMarkAsSpamCall<'a, S> { + CommentMarkAsSpamCall { + hub: self.hub, + _id: id.clone(), + _delegate: Default::default(), + _additional_params: Default::default(), + _scopes: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Sets the moderation status of one or more comments. + /// + /// # Arguments + /// + /// * `id` - Modifies the moderation status of the comments with the given IDs + /// * `moderationStatus` - Specifies the requested moderation status. Note, comments can be in statuses, which are not available through this call. For example, this call does not allow to mark a comment as 'likely spam'. Valid values: 'heldForReview', 'published' or 'rejected'. + pub fn set_moderation_status(&self, id: &Vec, moderation_status: &CommentModerationStatusEnum) -> CommentSetModerationStatusCall<'a, S> { + CommentSetModerationStatusCall { + hub: self.hub, + _id: id.clone(), + _moderation_status: moderation_status.clone(), + _ban_author: Default::default(), + _delegate: Default::default(), + _additional_params: Default::default(), + _scopes: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Updates an existing resource. + /// + /// # Arguments + /// + /// * `request` - No description provided. + pub fn update(&self, request: Comment) -> CommentUpdateCall<'a, S> { + use client::ToParts; + let parts = vec![request.to_parts()]; + CommentUpdateCall { + hub: self.hub, + _request: request, + _part: parts, + _delegate: Default::default(), + _additional_params: Default::default(), + _scopes: Default::default(), + } + } +} + + + +/// A builder providing access to all methods supported on *i18nLanguage* resources. +/// It is not used directly, but through the [`YouTube`] hub. +/// +/// # Example +/// +/// Instantiate a resource builder +/// +/// ```test_harness,no_run +/// extern crate hyper; +/// extern crate hyper_rustls; +/// extern crate google_youtube3 as youtube3; +/// +/// # async fn dox() { +/// use std::default::Default; +/// use youtube3::{YouTube, oauth2, hyper, hyper_rustls, chrono, FieldMask}; +/// +/// let secret: oauth2::ApplicationSecret = Default::default(); +/// let auth = oauth2::InstalledFlowAuthenticator::builder( +/// secret, +/// oauth2::InstalledFlowReturnMethod::HTTPRedirect, +/// ).build().await.unwrap(); +/// let mut hub = YouTube::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().unwrap().https_or_http().enable_http1().build()), auth); +/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* +/// // like `list(...)` +/// // to build up your call. +/// let rb = hub.i18n_languages(); +/// # } +/// ``` +pub struct I18nLanguageMethods<'a, S> + where S: 'a { + + pub(super) hub: &'a YouTube, +} + +impl<'a, S> client::MethodsBuilder for I18nLanguageMethods<'a, S> {} + +impl<'a, S> I18nLanguageMethods<'a, S> { + + /// Create a builder to help you perform the following task: + /// + /// Retrieves a list of resources, possibly filtered. + /// + /// # Arguments + /// + /// * `part` - The *part* parameter specifies the i18nLanguage resource properties that the API response will include. Set the parameter value to snippet. + pub fn list(&self, part: &Vec) -> I18nLanguageListCall<'a, S> { + I18nLanguageListCall { + hub: self.hub, + _part: part.clone(), + _hl: Default::default(), + _delegate: Default::default(), + _additional_params: Default::default(), + _scopes: Default::default(), + } + } +} + + + +/// A builder providing access to all methods supported on *i18nRegion* resources. +/// It is not used directly, but through the [`YouTube`] hub. +/// +/// # Example +/// +/// Instantiate a resource builder +/// +/// ```test_harness,no_run +/// extern crate hyper; +/// extern crate hyper_rustls; +/// extern crate google_youtube3 as youtube3; +/// +/// # async fn dox() { +/// use std::default::Default; +/// use youtube3::{YouTube, oauth2, hyper, hyper_rustls, chrono, FieldMask}; +/// +/// let secret: oauth2::ApplicationSecret = Default::default(); +/// let auth = oauth2::InstalledFlowAuthenticator::builder( +/// secret, +/// oauth2::InstalledFlowReturnMethod::HTTPRedirect, +/// ).build().await.unwrap(); +/// let mut hub = YouTube::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().unwrap().https_or_http().enable_http1().build()), auth); +/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* +/// // like `list(...)` +/// // to build up your call. +/// let rb = hub.i18n_regions(); +/// # } +/// ``` +pub struct I18nRegionMethods<'a, S> + where S: 'a { + + pub(super) hub: &'a YouTube, +} + +impl<'a, S> client::MethodsBuilder for I18nRegionMethods<'a, S> {} + +impl<'a, S> I18nRegionMethods<'a, S> { + + /// Create a builder to help you perform the following task: + /// + /// Retrieves a list of resources, possibly filtered. + /// + /// # Arguments + /// + /// * `part` - The *part* parameter specifies the i18nRegion resource properties that the API response will include. Set the parameter value to snippet. + pub fn list(&self, part: &Vec) -> I18nRegionListCall<'a, S> { + I18nRegionListCall { + hub: self.hub, + _part: part.clone(), + _hl: Default::default(), + _delegate: Default::default(), + _additional_params: Default::default(), + _scopes: Default::default(), + } + } +} + + + +/// A builder providing access to all methods supported on *liveBroadcast* resources. +/// It is not used directly, but through the [`YouTube`] hub. +/// +/// # Example +/// +/// Instantiate a resource builder +/// +/// ```test_harness,no_run +/// extern crate hyper; +/// extern crate hyper_rustls; +/// extern crate google_youtube3 as youtube3; +/// +/// # async fn dox() { +/// use std::default::Default; +/// use youtube3::{YouTube, oauth2, hyper, hyper_rustls, chrono, FieldMask}; +/// +/// let secret: oauth2::ApplicationSecret = Default::default(); +/// let auth = oauth2::InstalledFlowAuthenticator::builder( +/// secret, +/// oauth2::InstalledFlowReturnMethod::HTTPRedirect, +/// ).build().await.unwrap(); +/// let mut hub = YouTube::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().unwrap().https_or_http().enable_http1().build()), auth); +/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* +/// // like `bind(...)`, `delete(...)`, `insert(...)`, `insert_cuepoint(...)`, `list(...)`, `transition(...)` and `update(...)` +/// // to build up your call. +/// let rb = hub.live_broadcasts(); +/// # } +/// ``` +pub struct LiveBroadcastMethods<'a, S> + where S: 'a { + + pub(super) hub: &'a YouTube, +} + +impl<'a, S> client::MethodsBuilder for LiveBroadcastMethods<'a, S> {} + +impl<'a, S> LiveBroadcastMethods<'a, S> { + + /// Create a builder to help you perform the following task: + /// + /// Bind a broadcast to a stream. + /// + /// # Arguments + /// + /// * `id` - Broadcast to bind to the stream + /// * `part` - The *part* parameter specifies a comma-separated list of one or more liveBroadcast resource properties that the API response will include. The part names that you can include in the parameter value are id, snippet, contentDetails, and status. + pub fn bind(&self, id: &str, part: &Vec) -> LiveBroadcastBindCall<'a, S> { + LiveBroadcastBindCall { + hub: self.hub, + _id: id.to_string(), + _part: part.clone(), + _stream_id: Default::default(), + _on_behalf_of_content_owner_channel: Default::default(), + _on_behalf_of_content_owner: Default::default(), + _delegate: Default::default(), + _additional_params: Default::default(), + _scopes: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Delete a given broadcast. + /// + /// # Arguments + /// + /// * `id` - Broadcast to delete. + pub fn delete(&self, id: &str) -> LiveBroadcastDeleteCall<'a, S> { + LiveBroadcastDeleteCall { + hub: self.hub, + _id: id.to_string(), + _on_behalf_of_content_owner_channel: Default::default(), + _on_behalf_of_content_owner: Default::default(), + _delegate: Default::default(), + _additional_params: Default::default(), + _scopes: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Inserts a new stream for the authenticated user. + /// + /// # Arguments + /// + /// * `request` - No description provided. + pub fn insert(&self, request: LiveBroadcast) -> LiveBroadcastInsertCall<'a, S> { + use client::ToParts; + let parts = vec![request.to_parts()]; + LiveBroadcastInsertCall { + hub: self.hub, + _request: request, + _part: parts, + _on_behalf_of_content_owner_channel: Default::default(), + _on_behalf_of_content_owner: Default::default(), + _delegate: Default::default(), + _additional_params: Default::default(), + _scopes: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Insert cuepoints in a broadcast + /// + /// # Arguments + /// + /// * `request` - No description provided. + pub fn insert_cuepoint(&self, request: Cuepoint) -> LiveBroadcastInsertCuepointCall<'a, S> { + LiveBroadcastInsertCuepointCall { + hub: self.hub, + _request: request, + _part: Default::default(), + _on_behalf_of_content_owner_channel: Default::default(), + _on_behalf_of_content_owner: Default::default(), + _id: Default::default(), + _delegate: Default::default(), + _additional_params: Default::default(), + _scopes: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Retrieve the list of broadcasts associated with the given channel. + /// + /// # Arguments + /// + /// * `part` - The *part* parameter specifies a comma-separated list of one or more liveBroadcast resource properties that the API response will include. The part names that you can include in the parameter value are id, snippet, contentDetails, status and statistics. + pub fn list(&self, part: &Vec) -> LiveBroadcastListCall<'a, S> { + LiveBroadcastListCall { + hub: self.hub, + _part: part.clone(), + _page_token: Default::default(), + _on_behalf_of_content_owner_channel: Default::default(), + _on_behalf_of_content_owner: Default::default(), + _mine: Default::default(), + _max_results: Default::default(), + _id: Default::default(), + _broadcast_type: Default::default(), + _broadcast_status: Default::default(), + _delegate: Default::default(), + _additional_params: Default::default(), + _scopes: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Transition a broadcast to a given status. + /// + /// # Arguments + /// + /// * `broadcastStatus` - The status to which the broadcast is going to transition. + /// * `id` - Broadcast to transition. + /// * `part` - The *part* parameter specifies a comma-separated list of one or more liveBroadcast resource properties that the API response will include. The part names that you can include in the parameter value are id, snippet, contentDetails, and status. + pub fn transition(&self, broadcast_status: &LiveBroadcastBroadcastStatusEnum, id: &str, part: &Vec) -> LiveBroadcastTransitionCall<'a, S> { + LiveBroadcastTransitionCall { + hub: self.hub, + _broadcast_status: broadcast_status.clone(), + _id: id.to_string(), + _part: part.clone(), + _on_behalf_of_content_owner_channel: Default::default(), + _on_behalf_of_content_owner: Default::default(), + _delegate: Default::default(), + _additional_params: Default::default(), + _scopes: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Updates an existing broadcast for the authenticated user. + /// + /// # Arguments + /// + /// * `request` - No description provided. + pub fn update(&self, request: LiveBroadcast) -> LiveBroadcastUpdateCall<'a, S> { + use client::ToParts; + let parts = vec![request.to_parts()]; + LiveBroadcastUpdateCall { + hub: self.hub, + _request: request, + _part: parts, + _on_behalf_of_content_owner_channel: Default::default(), + _on_behalf_of_content_owner: Default::default(), + _delegate: Default::default(), + _additional_params: Default::default(), + _scopes: Default::default(), + } + } +} + + + +/// A builder providing access to all methods supported on *liveChatBan* resources. +/// It is not used directly, but through the [`YouTube`] hub. +/// +/// # Example +/// +/// Instantiate a resource builder +/// +/// ```test_harness,no_run +/// extern crate hyper; +/// extern crate hyper_rustls; +/// extern crate google_youtube3 as youtube3; +/// +/// # async fn dox() { +/// use std::default::Default; +/// use youtube3::{YouTube, oauth2, hyper, hyper_rustls, chrono, FieldMask}; +/// +/// let secret: oauth2::ApplicationSecret = Default::default(); +/// let auth = oauth2::InstalledFlowAuthenticator::builder( +/// secret, +/// oauth2::InstalledFlowReturnMethod::HTTPRedirect, +/// ).build().await.unwrap(); +/// let mut hub = YouTube::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().unwrap().https_or_http().enable_http1().build()), auth); +/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* +/// // like `delete(...)` and `insert(...)` +/// // to build up your call. +/// let rb = hub.live_chat_bans(); +/// # } +/// ``` +pub struct LiveChatBanMethods<'a, S> + where S: 'a { + + pub(super) hub: &'a YouTube, +} + +impl<'a, S> client::MethodsBuilder for LiveChatBanMethods<'a, S> {} + +impl<'a, S> LiveChatBanMethods<'a, S> { + + /// Create a builder to help you perform the following task: + /// + /// Deletes a chat ban. + /// + /// # Arguments + /// + /// * `id` - No description provided. + pub fn delete(&self, id: &str) -> LiveChatBanDeleteCall<'a, S> { + LiveChatBanDeleteCall { + hub: self.hub, + _id: id.to_string(), + _delegate: Default::default(), + _additional_params: Default::default(), + _scopes: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Inserts a new resource into this collection. + /// + /// # Arguments + /// + /// * `request` - No description provided. + pub fn insert(&self, request: LiveChatBan) -> LiveChatBanInsertCall<'a, S> { + use client::ToParts; + let parts = vec![request.to_parts()]; + LiveChatBanInsertCall { + hub: self.hub, + _request: request, + _part: parts, + _delegate: Default::default(), + _additional_params: Default::default(), + _scopes: Default::default(), + } + } +} + + + +/// A builder providing access to all methods supported on *liveChatMessage* resources. +/// It is not used directly, but through the [`YouTube`] hub. +/// +/// # Example +/// +/// Instantiate a resource builder +/// +/// ```test_harness,no_run +/// extern crate hyper; +/// extern crate hyper_rustls; +/// extern crate google_youtube3 as youtube3; +/// +/// # async fn dox() { +/// use std::default::Default; +/// use youtube3::{YouTube, oauth2, hyper, hyper_rustls, chrono, FieldMask}; +/// +/// let secret: oauth2::ApplicationSecret = Default::default(); +/// let auth = oauth2::InstalledFlowAuthenticator::builder( +/// secret, +/// oauth2::InstalledFlowReturnMethod::HTTPRedirect, +/// ).build().await.unwrap(); +/// let mut hub = YouTube::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().unwrap().https_or_http().enable_http1().build()), 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.live_chat_messages(); +/// # } +/// ``` +pub struct LiveChatMessageMethods<'a, S> + where S: 'a { + + pub(super) hub: &'a YouTube, +} + +impl<'a, S> client::MethodsBuilder for LiveChatMessageMethods<'a, S> {} + +impl<'a, S> LiveChatMessageMethods<'a, S> { + + /// Create a builder to help you perform the following task: + /// + /// Deletes a chat message. + /// + /// # Arguments + /// + /// * `id` - No description provided. + pub fn delete(&self, id: &str) -> LiveChatMessageDeleteCall<'a, S> { + LiveChatMessageDeleteCall { + hub: self.hub, + _id: id.to_string(), + _delegate: Default::default(), + _additional_params: Default::default(), + _scopes: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Inserts a new resource into this collection. + /// + /// # Arguments + /// + /// * `request` - No description provided. + pub fn insert(&self, request: LiveChatMessage) -> LiveChatMessageInsertCall<'a, S> { + use client::ToParts; + let parts = vec![request.to_parts()]; + LiveChatMessageInsertCall { + hub: self.hub, + _request: request, + _part: parts, + _delegate: Default::default(), + _additional_params: Default::default(), + _scopes: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Retrieves a list of resources, possibly filtered. + /// + /// # Arguments + /// + /// * `liveChatId` - The id of the live chat for which comments should be returned. + /// * `part` - The *part* parameter specifies the liveChatComment resource parts that the API response will include. Supported values are id and snippet. + pub fn list(&self, live_chat_id: &str, part: &Vec) -> LiveChatMessageListCall<'a, S> { + LiveChatMessageListCall { + hub: self.hub, + _live_chat_id: live_chat_id.to_string(), + _part: part.clone(), + _profile_image_size: Default::default(), + _page_token: Default::default(), + _max_results: Default::default(), + _hl: Default::default(), + _delegate: Default::default(), + _additional_params: Default::default(), + _scopes: Default::default(), + } + } +} + + + +/// A builder providing access to all methods supported on *liveChatModerator* resources. +/// It is not used directly, but through the [`YouTube`] hub. +/// +/// # Example +/// +/// Instantiate a resource builder +/// +/// ```test_harness,no_run +/// extern crate hyper; +/// extern crate hyper_rustls; +/// extern crate google_youtube3 as youtube3; +/// +/// # async fn dox() { +/// use std::default::Default; +/// use youtube3::{YouTube, oauth2, hyper, hyper_rustls, chrono, FieldMask}; +/// +/// let secret: oauth2::ApplicationSecret = Default::default(); +/// let auth = oauth2::InstalledFlowAuthenticator::builder( +/// secret, +/// oauth2::InstalledFlowReturnMethod::HTTPRedirect, +/// ).build().await.unwrap(); +/// let mut hub = YouTube::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().unwrap().https_or_http().enable_http1().build()), 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.live_chat_moderators(); +/// # } +/// ``` +pub struct LiveChatModeratorMethods<'a, S> + where S: 'a { + + pub(super) hub: &'a YouTube, +} + +impl<'a, S> client::MethodsBuilder for LiveChatModeratorMethods<'a, S> {} + +impl<'a, S> LiveChatModeratorMethods<'a, S> { + + /// Create a builder to help you perform the following task: + /// + /// Deletes a chat moderator. + /// + /// # Arguments + /// + /// * `id` - No description provided. + pub fn delete(&self, id: &str) -> LiveChatModeratorDeleteCall<'a, S> { + LiveChatModeratorDeleteCall { + hub: self.hub, + _id: id.to_string(), + _delegate: Default::default(), + _additional_params: Default::default(), + _scopes: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Inserts a new resource into this collection. + /// + /// # Arguments + /// + /// * `request` - No description provided. + pub fn insert(&self, request: LiveChatModerator) -> LiveChatModeratorInsertCall<'a, S> { + use client::ToParts; + let parts = vec![request.to_parts()]; + LiveChatModeratorInsertCall { + hub: self.hub, + _request: request, + _part: parts, + _delegate: Default::default(), + _additional_params: Default::default(), + _scopes: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Retrieves a list of resources, possibly filtered. + /// + /// # Arguments + /// + /// * `liveChatId` - The id of the live chat for which moderators should be returned. + /// * `part` - The *part* parameter specifies the liveChatModerator resource parts that the API response will include. Supported values are id and snippet. + pub fn list(&self, live_chat_id: &str, part: &Vec) -> LiveChatModeratorListCall<'a, S> { + LiveChatModeratorListCall { + hub: self.hub, + _live_chat_id: live_chat_id.to_string(), + _part: part.clone(), + _page_token: Default::default(), + _max_results: Default::default(), + _delegate: Default::default(), + _additional_params: Default::default(), + _scopes: Default::default(), + } + } +} + + + +/// A builder providing access to all methods supported on *liveStream* resources. +/// It is not used directly, but through the [`YouTube`] hub. +/// +/// # Example +/// +/// Instantiate a resource builder +/// +/// ```test_harness,no_run +/// extern crate hyper; +/// extern crate hyper_rustls; +/// extern crate google_youtube3 as youtube3; +/// +/// # async fn dox() { +/// use std::default::Default; +/// use youtube3::{YouTube, oauth2, hyper, hyper_rustls, chrono, FieldMask}; +/// +/// let secret: oauth2::ApplicationSecret = Default::default(); +/// let auth = oauth2::InstalledFlowAuthenticator::builder( +/// secret, +/// oauth2::InstalledFlowReturnMethod::HTTPRedirect, +/// ).build().await.unwrap(); +/// let mut hub = YouTube::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().unwrap().https_or_http().enable_http1().build()), auth); +/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* +/// // like `delete(...)`, `insert(...)`, `list(...)` and `update(...)` +/// // to build up your call. +/// let rb = hub.live_streams(); +/// # } +/// ``` +pub struct LiveStreamMethods<'a, S> + where S: 'a { + + pub(super) hub: &'a YouTube, +} + +impl<'a, S> client::MethodsBuilder for LiveStreamMethods<'a, S> {} + +impl<'a, S> LiveStreamMethods<'a, S> { + + /// Create a builder to help you perform the following task: + /// + /// Deletes an existing stream for the authenticated user. + /// + /// # Arguments + /// + /// * `id` - No description provided. + pub fn delete(&self, id: &str) -> LiveStreamDeleteCall<'a, S> { + LiveStreamDeleteCall { + hub: self.hub, + _id: id.to_string(), + _on_behalf_of_content_owner_channel: Default::default(), + _on_behalf_of_content_owner: Default::default(), + _delegate: Default::default(), + _additional_params: Default::default(), + _scopes: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Inserts a new stream for the authenticated user. + /// + /// # Arguments + /// + /// * `request` - No description provided. + pub fn insert(&self, request: LiveStream) -> LiveStreamInsertCall<'a, S> { + use client::ToParts; + let parts = vec![request.to_parts()]; + LiveStreamInsertCall { + hub: self.hub, + _request: request, + _part: parts, + _on_behalf_of_content_owner_channel: Default::default(), + _on_behalf_of_content_owner: Default::default(), + _delegate: Default::default(), + _additional_params: Default::default(), + _scopes: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Retrieve the list of streams associated with the given channel. -- + /// + /// # Arguments + /// + /// * `part` - The *part* parameter specifies a comma-separated list of one or more liveStream resource properties that the API response will include. The part names that you can include in the parameter value are id, snippet, cdn, and status. + pub fn list(&self, part: &Vec) -> LiveStreamListCall<'a, S> { + LiveStreamListCall { + hub: self.hub, + _part: part.clone(), + _page_token: Default::default(), + _on_behalf_of_content_owner_channel: Default::default(), + _on_behalf_of_content_owner: Default::default(), + _mine: Default::default(), + _max_results: Default::default(), + _id: Default::default(), + _delegate: Default::default(), + _additional_params: Default::default(), + _scopes: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Updates an existing stream for the authenticated user. + /// + /// # Arguments + /// + /// * `request` - No description provided. + pub fn update(&self, request: LiveStream) -> LiveStreamUpdateCall<'a, S> { + use client::ToParts; + let parts = vec![request.to_parts()]; + LiveStreamUpdateCall { + hub: self.hub, + _request: request, + _part: parts, + _on_behalf_of_content_owner_channel: Default::default(), + _on_behalf_of_content_owner: Default::default(), + _delegate: Default::default(), + _additional_params: Default::default(), + _scopes: Default::default(), + } + } +} + + + +/// A builder providing access to all methods supported on *member* resources. +/// It is not used directly, but through the [`YouTube`] hub. +/// +/// # Example +/// +/// Instantiate a resource builder +/// +/// ```test_harness,no_run +/// extern crate hyper; +/// extern crate hyper_rustls; +/// extern crate google_youtube3 as youtube3; +/// +/// # async fn dox() { +/// use std::default::Default; +/// use youtube3::{YouTube, oauth2, hyper, hyper_rustls, chrono, FieldMask}; +/// +/// let secret: oauth2::ApplicationSecret = Default::default(); +/// let auth = oauth2::InstalledFlowAuthenticator::builder( +/// secret, +/// oauth2::InstalledFlowReturnMethod::HTTPRedirect, +/// ).build().await.unwrap(); +/// let mut hub = YouTube::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().unwrap().https_or_http().enable_http1().build()), auth); +/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* +/// // like `list(...)` +/// // to build up your call. +/// let rb = hub.members(); +/// # } +/// ``` +pub struct MemberMethods<'a, S> + where S: 'a { + + pub(super) hub: &'a YouTube, +} + +impl<'a, S> client::MethodsBuilder for MemberMethods<'a, S> {} + +impl<'a, S> MemberMethods<'a, S> { + + /// Create a builder to help you perform the following task: + /// + /// Retrieves a list of members that match the request criteria for a channel. + /// + /// # Arguments + /// + /// * `part` - The *part* parameter specifies the member resource parts that the API response will include. Set the parameter value to snippet. + pub fn list(&self, part: &Vec) -> MemberListCall<'a, S> { + MemberListCall { + hub: self.hub, + _part: part.clone(), + _page_token: Default::default(), + _mode: Default::default(), + _max_results: Default::default(), + _has_access_to_level: Default::default(), + _filter_by_member_channel_id: Default::default(), + _delegate: Default::default(), + _additional_params: Default::default(), + _scopes: Default::default(), + } + } +} + + + +/// A builder providing access to all methods supported on *membershipsLevel* resources. +/// It is not used directly, but through the [`YouTube`] hub. +/// +/// # Example +/// +/// Instantiate a resource builder +/// +/// ```test_harness,no_run +/// extern crate hyper; +/// extern crate hyper_rustls; +/// extern crate google_youtube3 as youtube3; +/// +/// # async fn dox() { +/// use std::default::Default; +/// use youtube3::{YouTube, oauth2, hyper, hyper_rustls, chrono, FieldMask}; +/// +/// let secret: oauth2::ApplicationSecret = Default::default(); +/// let auth = oauth2::InstalledFlowAuthenticator::builder( +/// secret, +/// oauth2::InstalledFlowReturnMethod::HTTPRedirect, +/// ).build().await.unwrap(); +/// let mut hub = YouTube::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().unwrap().https_or_http().enable_http1().build()), auth); +/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* +/// // like `list(...)` +/// // to build up your call. +/// let rb = hub.memberships_levels(); +/// # } +/// ``` +pub struct MembershipsLevelMethods<'a, S> + where S: 'a { + + pub(super) hub: &'a YouTube, +} + +impl<'a, S> client::MethodsBuilder for MembershipsLevelMethods<'a, S> {} + +impl<'a, S> MembershipsLevelMethods<'a, S> { + + /// Create a builder to help you perform the following task: + /// + /// Retrieves a list of all pricing levels offered by a creator to the fans. + /// + /// # Arguments + /// + /// * `part` - The *part* parameter specifies the membershipsLevel resource parts that the API response will include. Supported values are id and snippet. + pub fn list(&self, part: &Vec) -> MembershipsLevelListCall<'a, S> { + MembershipsLevelListCall { + hub: self.hub, + _part: part.clone(), + _delegate: Default::default(), + _additional_params: Default::default(), + _scopes: Default::default(), + } + } +} + + + +/// A builder providing access to all methods supported on *playlistImage* resources. +/// It is not used directly, but through the [`YouTube`] hub. +/// +/// # Example +/// +/// Instantiate a resource builder +/// +/// ```test_harness,no_run +/// extern crate hyper; +/// extern crate hyper_rustls; +/// extern crate google_youtube3 as youtube3; +/// +/// # async fn dox() { +/// use std::default::Default; +/// use youtube3::{YouTube, oauth2, hyper, hyper_rustls, chrono, FieldMask}; +/// +/// let secret: oauth2::ApplicationSecret = Default::default(); +/// let auth = oauth2::InstalledFlowAuthenticator::builder( +/// secret, +/// oauth2::InstalledFlowReturnMethod::HTTPRedirect, +/// ).build().await.unwrap(); +/// let mut hub = YouTube::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().unwrap().https_or_http().enable_http1().build()), auth); +/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* +/// // like `delete(...)`, `insert(...)`, `list(...)` and `update(...)` +/// // to build up your call. +/// let rb = hub.playlist_images(); +/// # } +/// ``` +pub struct PlaylistImageMethods<'a, S> + where S: 'a { + + pub(super) hub: &'a YouTube, +} + +impl<'a, S> client::MethodsBuilder for PlaylistImageMethods<'a, S> {} + +impl<'a, S> PlaylistImageMethods<'a, S> { + + /// Create a builder to help you perform the following task: + /// + /// Deletes a resource. + pub fn delete(&self) -> PlaylistImageDeleteCall<'a, S> { + PlaylistImageDeleteCall { + hub: self.hub, + _on_behalf_of_content_owner: Default::default(), + _id: Default::default(), + _delegate: Default::default(), + _additional_params: Default::default(), + _scopes: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Inserts a new resource into this collection. + /// + /// # Arguments + /// + /// * `request` - No description provided. + pub fn insert(&self, request: PlaylistImage) -> PlaylistImageInsertCall<'a, S> { + PlaylistImageInsertCall { + hub: self.hub, + _request: request, + _part: Default::default(), + _on_behalf_of_content_owner_channel: Default::default(), + _on_behalf_of_content_owner: Default::default(), + _delegate: Default::default(), + _additional_params: Default::default(), + _scopes: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Retrieves a list of resources, possibly filtered. + pub fn list(&self) -> PlaylistImageListCall<'a, S> { + PlaylistImageListCall { + hub: self.hub, + _part: Default::default(), + _parent: Default::default(), + _page_token: Default::default(), + _on_behalf_of_content_owner_channel: Default::default(), + _on_behalf_of_content_owner: Default::default(), + _max_results: Default::default(), + _delegate: Default::default(), + _additional_params: Default::default(), + _scopes: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Updates an existing resource. + /// + /// # Arguments + /// + /// * `request` - No description provided. + pub fn update(&self, request: PlaylistImage) -> PlaylistImageUpdateCall<'a, S> { + PlaylistImageUpdateCall { + hub: self.hub, + _request: request, + _part: Default::default(), + _on_behalf_of_content_owner: Default::default(), + _delegate: Default::default(), + _additional_params: Default::default(), + _scopes: Default::default(), + } + } +} + + + +/// A builder providing access to all methods supported on *playlistItem* resources. +/// It is not used directly, but through the [`YouTube`] hub. +/// +/// # Example +/// +/// Instantiate a resource builder +/// +/// ```test_harness,no_run +/// extern crate hyper; +/// extern crate hyper_rustls; +/// extern crate google_youtube3 as youtube3; +/// +/// # async fn dox() { +/// use std::default::Default; +/// use youtube3::{YouTube, oauth2, hyper, hyper_rustls, chrono, FieldMask}; +/// +/// let secret: oauth2::ApplicationSecret = Default::default(); +/// let auth = oauth2::InstalledFlowAuthenticator::builder( +/// secret, +/// oauth2::InstalledFlowReturnMethod::HTTPRedirect, +/// ).build().await.unwrap(); +/// let mut hub = YouTube::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().unwrap().https_or_http().enable_http1().build()), auth); +/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* +/// // like `delete(...)`, `insert(...)`, `list(...)` and `update(...)` +/// // to build up your call. +/// let rb = hub.playlist_items(); +/// # } +/// ``` +pub struct PlaylistItemMethods<'a, S> + where S: 'a { + + pub(super) hub: &'a YouTube, +} + +impl<'a, S> client::MethodsBuilder for PlaylistItemMethods<'a, S> {} + +impl<'a, S> PlaylistItemMethods<'a, S> { + + /// Create a builder to help you perform the following task: + /// + /// Deletes a resource. + /// + /// # Arguments + /// + /// * `id` - No description provided. + pub fn delete(&self, id: &str) -> PlaylistItemDeleteCall<'a, S> { + PlaylistItemDeleteCall { + hub: self.hub, + _id: id.to_string(), + _on_behalf_of_content_owner: Default::default(), + _delegate: Default::default(), + _additional_params: Default::default(), + _scopes: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Inserts a new resource into this collection. + /// + /// # Arguments + /// + /// * `request` - No description provided. + pub fn insert(&self, request: PlaylistItem) -> PlaylistItemInsertCall<'a, S> { + use client::ToParts; + let parts = vec![request.to_parts()]; + PlaylistItemInsertCall { + hub: self.hub, + _request: request, + _part: parts, + _on_behalf_of_content_owner: Default::default(), + _delegate: Default::default(), + _additional_params: Default::default(), + _scopes: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Retrieves a list of resources, possibly filtered. + /// + /// # Arguments + /// + /// * `part` - The *part* parameter specifies a comma-separated list of one or more playlistItem resource properties that the API response will include. If the parameter identifies a property that contains child properties, the child properties will be included in the response. For example, in a playlistItem resource, the snippet property contains numerous fields, including the title, description, position, and resourceId properties. As such, if you set *part=snippet*, the API response will contain all of those properties. + pub fn list(&self, part: &Vec) -> PlaylistItemListCall<'a, S> { + PlaylistItemListCall { + hub: self.hub, + _part: part.clone(), + _video_id: Default::default(), + _playlist_id: Default::default(), + _page_token: Default::default(), + _on_behalf_of_content_owner: Default::default(), + _max_results: Default::default(), + _id: Default::default(), + _delegate: Default::default(), + _additional_params: Default::default(), + _scopes: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Updates an existing resource. + /// + /// # Arguments + /// + /// * `request` - No description provided. + pub fn update(&self, request: PlaylistItem) -> PlaylistItemUpdateCall<'a, S> { + use client::ToParts; + let parts = vec![request.to_parts()]; + PlaylistItemUpdateCall { + hub: self.hub, + _request: request, + _part: parts, + _on_behalf_of_content_owner: Default::default(), + _delegate: Default::default(), + _additional_params: Default::default(), + _scopes: Default::default(), + } + } +} + + + +/// A builder providing access to all methods supported on *playlist* resources. +/// It is not used directly, but through the [`YouTube`] hub. +/// +/// # Example +/// +/// Instantiate a resource builder +/// +/// ```test_harness,no_run +/// extern crate hyper; +/// extern crate hyper_rustls; +/// extern crate google_youtube3 as youtube3; +/// +/// # async fn dox() { +/// use std::default::Default; +/// use youtube3::{YouTube, oauth2, hyper, hyper_rustls, chrono, FieldMask}; +/// +/// let secret: oauth2::ApplicationSecret = Default::default(); +/// let auth = oauth2::InstalledFlowAuthenticator::builder( +/// secret, +/// oauth2::InstalledFlowReturnMethod::HTTPRedirect, +/// ).build().await.unwrap(); +/// let mut hub = YouTube::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().unwrap().https_or_http().enable_http1().build()), auth); +/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* +/// // like `delete(...)`, `insert(...)`, `list(...)` and `update(...)` +/// // to build up your call. +/// let rb = hub.playlists(); +/// # } +/// ``` +pub struct PlaylistMethods<'a, S> + where S: 'a { + + pub(super) hub: &'a YouTube, +} + +impl<'a, S> client::MethodsBuilder for PlaylistMethods<'a, S> {} + +impl<'a, S> PlaylistMethods<'a, S> { + + /// Create a builder to help you perform the following task: + /// + /// Deletes a resource. + /// + /// # Arguments + /// + /// * `id` - No description provided. + pub fn delete(&self, id: &str) -> PlaylistDeleteCall<'a, S> { + PlaylistDeleteCall { + hub: self.hub, + _id: id.to_string(), + _on_behalf_of_content_owner: Default::default(), + _delegate: Default::default(), + _additional_params: Default::default(), + _scopes: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Inserts a new resource into this collection. + /// + /// # Arguments + /// + /// * `request` - No description provided. + pub fn insert(&self, request: Playlist) -> PlaylistInsertCall<'a, S> { + use client::ToParts; + let parts = vec![request.to_parts()]; + PlaylistInsertCall { + hub: self.hub, + _request: request, + _part: parts, + _on_behalf_of_content_owner_channel: Default::default(), + _on_behalf_of_content_owner: Default::default(), + _delegate: Default::default(), + _additional_params: Default::default(), + _scopes: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Retrieves a list of resources, possibly filtered. + /// + /// # Arguments + /// + /// * `part` - The *part* parameter specifies a comma-separated list of one or more playlist resource properties that the API response will include. If the parameter identifies a property that contains child properties, the child properties will be included in the response. For example, in a playlist resource, the snippet property contains properties like author, title, description, tags, and timeCreated. As such, if you set *part=snippet*, the API response will contain all of those properties. + pub fn list(&self, part: &Vec) -> PlaylistListCall<'a, S> { + PlaylistListCall { + hub: self.hub, + _part: part.clone(), + _page_token: Default::default(), + _on_behalf_of_content_owner_channel: Default::default(), + _on_behalf_of_content_owner: Default::default(), + _mine: Default::default(), + _max_results: Default::default(), + _id: Default::default(), + _hl: Default::default(), + _channel_id: Default::default(), + _delegate: Default::default(), + _additional_params: Default::default(), + _scopes: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Updates an existing resource. + /// + /// # Arguments + /// + /// * `request` - No description provided. + pub fn update(&self, request: Playlist) -> PlaylistUpdateCall<'a, S> { + use client::ToParts; + let parts = vec![request.to_parts()]; + PlaylistUpdateCall { + hub: self.hub, + _request: request, + _part: parts, + _on_behalf_of_content_owner: Default::default(), + _delegate: Default::default(), + _additional_params: Default::default(), + _scopes: Default::default(), + } + } +} + + + +/// A builder providing access to all methods supported on *search* resources. +/// It is not used directly, but through the [`YouTube`] hub. +/// +/// # Example +/// +/// Instantiate a resource builder +/// +/// ```test_harness,no_run +/// extern crate hyper; +/// extern crate hyper_rustls; +/// extern crate google_youtube3 as youtube3; +/// +/// # async fn dox() { +/// use std::default::Default; +/// use youtube3::{YouTube, oauth2, hyper, hyper_rustls, chrono, FieldMask}; +/// +/// let secret: oauth2::ApplicationSecret = Default::default(); +/// let auth = oauth2::InstalledFlowAuthenticator::builder( +/// secret, +/// oauth2::InstalledFlowReturnMethod::HTTPRedirect, +/// ).build().await.unwrap(); +/// let mut hub = YouTube::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().unwrap().https_or_http().enable_http1().build()), auth); +/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* +/// // like `list(...)` +/// // to build up your call. +/// let rb = hub.search(); +/// # } +/// ``` +pub struct SearchMethods<'a, S> + where S: 'a { + + pub(super) hub: &'a YouTube, +} + +impl<'a, S> client::MethodsBuilder for SearchMethods<'a, S> {} + +impl<'a, S> SearchMethods<'a, S> { + + /// Create a builder to help you perform the following task: + /// + /// Retrieves a list of search resources + /// + /// # Arguments + /// + /// * `part` - The *part* parameter specifies a comma-separated list of one or more search resource properties that the API response will include. Set the parameter value to snippet. + pub fn list(&self, part: &Vec) -> SearchListCall<'a, S> { + SearchListCall { + hub: self.hub, + _part: part.clone(), + _video_type: Default::default(), + _video_syndicated: Default::default(), + _video_paid_product_placement: Default::default(), + _video_license: Default::default(), + _video_embeddable: Default::default(), + _video_duration: Default::default(), + _video_dimension: Default::default(), + _video_definition: Default::default(), + _video_category_id: Default::default(), + _video_caption: Default::default(), + _type_: Default::default(), + _topic_id: Default::default(), + _safe_search: Default::default(), + _relevance_language: Default::default(), + _region_code: Default::default(), + _q: Default::default(), + _published_before: Default::default(), + _published_after: Default::default(), + _page_token: Default::default(), + _order: Default::default(), + _on_behalf_of_content_owner: Default::default(), + _max_results: Default::default(), + _location_radius: Default::default(), + _location: Default::default(), + _for_mine: Default::default(), + _for_developer: Default::default(), + _for_content_owner: Default::default(), + _event_type: Default::default(), + _channel_type: Default::default(), + _channel_id: Default::default(), + _delegate: Default::default(), + _additional_params: Default::default(), + _scopes: Default::default(), + } + } +} + + + +/// A builder providing access to all methods supported on *subscription* resources. +/// It is not used directly, but through the [`YouTube`] hub. +/// +/// # Example +/// +/// Instantiate a resource builder +/// +/// ```test_harness,no_run +/// extern crate hyper; +/// extern crate hyper_rustls; +/// extern crate google_youtube3 as youtube3; +/// +/// # async fn dox() { +/// use std::default::Default; +/// use youtube3::{YouTube, oauth2, hyper, hyper_rustls, chrono, FieldMask}; +/// +/// let secret: oauth2::ApplicationSecret = Default::default(); +/// let auth = oauth2::InstalledFlowAuthenticator::builder( +/// secret, +/// oauth2::InstalledFlowReturnMethod::HTTPRedirect, +/// ).build().await.unwrap(); +/// let mut hub = YouTube::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().unwrap().https_or_http().enable_http1().build()), 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.subscriptions(); +/// # } +/// ``` +pub struct SubscriptionMethods<'a, S> + where S: 'a { + + pub(super) hub: &'a YouTube, +} + +impl<'a, S> client::MethodsBuilder for SubscriptionMethods<'a, S> {} + +impl<'a, S> SubscriptionMethods<'a, S> { + + /// Create a builder to help you perform the following task: + /// + /// Deletes a resource. + /// + /// # Arguments + /// + /// * `id` - No description provided. + pub fn delete(&self, id: &str) -> SubscriptionDeleteCall<'a, S> { + SubscriptionDeleteCall { + hub: self.hub, + _id: id.to_string(), + _delegate: Default::default(), + _additional_params: Default::default(), + _scopes: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Inserts a new resource into this collection. + /// + /// # Arguments + /// + /// * `request` - No description provided. + pub fn insert(&self, request: Subscription) -> SubscriptionInsertCall<'a, S> { + use client::ToParts; + let parts = vec![request.to_parts()]; + SubscriptionInsertCall { + hub: self.hub, + _request: request, + _part: parts, + _delegate: Default::default(), + _additional_params: Default::default(), + _scopes: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Retrieves a list of resources, possibly filtered. + /// + /// # Arguments + /// + /// * `part` - The *part* parameter specifies a comma-separated list of one or more subscription resource properties that the API response will include. If the parameter identifies a property that contains child properties, the child properties will be included in the response. For example, in a subscription resource, the snippet property contains other properties, such as a display title for the subscription. If you set *part=snippet*, the API response will also contain all of those nested properties. + pub fn list(&self, part: &Vec) -> SubscriptionListCall<'a, S> { + SubscriptionListCall { + hub: self.hub, + _part: part.clone(), + _page_token: Default::default(), + _order: Default::default(), + _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(), + _for_channel_id: Default::default(), + _channel_id: Default::default(), + _delegate: Default::default(), + _additional_params: Default::default(), + _scopes: Default::default(), + } + } +} + + + +/// A builder providing access to all methods supported on *superChatEvent* resources. +/// It is not used directly, but through the [`YouTube`] hub. +/// +/// # Example +/// +/// Instantiate a resource builder +/// +/// ```test_harness,no_run +/// extern crate hyper; +/// extern crate hyper_rustls; +/// extern crate google_youtube3 as youtube3; +/// +/// # async fn dox() { +/// use std::default::Default; +/// use youtube3::{YouTube, oauth2, hyper, hyper_rustls, chrono, FieldMask}; +/// +/// let secret: oauth2::ApplicationSecret = Default::default(); +/// let auth = oauth2::InstalledFlowAuthenticator::builder( +/// secret, +/// oauth2::InstalledFlowReturnMethod::HTTPRedirect, +/// ).build().await.unwrap(); +/// let mut hub = YouTube::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().unwrap().https_or_http().enable_http1().build()), auth); +/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* +/// // like `list(...)` +/// // to build up your call. +/// let rb = hub.super_chat_events(); +/// # } +/// ``` +pub struct SuperChatEventMethods<'a, S> + where S: 'a { + + pub(super) hub: &'a YouTube, +} + +impl<'a, S> client::MethodsBuilder for SuperChatEventMethods<'a, S> {} + +impl<'a, S> SuperChatEventMethods<'a, S> { + + /// Create a builder to help you perform the following task: + /// + /// Retrieves a list of resources, possibly filtered. + /// + /// # Arguments + /// + /// * `part` - The *part* parameter specifies the superChatEvent resource parts that the API response will include. This parameter is currently not supported. + pub fn list(&self, part: &Vec) -> SuperChatEventListCall<'a, S> { + SuperChatEventListCall { + hub: self.hub, + _part: part.clone(), + _page_token: Default::default(), + _max_results: Default::default(), + _hl: Default::default(), + _delegate: Default::default(), + _additional_params: Default::default(), + _scopes: Default::default(), + } + } +} + + + +/// A builder providing access to all methods supported on *test* resources. +/// It is not used directly, but through the [`YouTube`] hub. +/// +/// # Example +/// +/// Instantiate a resource builder +/// +/// ```test_harness,no_run +/// extern crate hyper; +/// extern crate hyper_rustls; +/// extern crate google_youtube3 as youtube3; +/// +/// # async fn dox() { +/// use std::default::Default; +/// use youtube3::{YouTube, oauth2, hyper, hyper_rustls, chrono, FieldMask}; +/// +/// let secret: oauth2::ApplicationSecret = Default::default(); +/// let auth = oauth2::InstalledFlowAuthenticator::builder( +/// secret, +/// oauth2::InstalledFlowReturnMethod::HTTPRedirect, +/// ).build().await.unwrap(); +/// let mut hub = YouTube::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().unwrap().https_or_http().enable_http1().build()), auth); +/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* +/// // like `insert(...)` +/// // to build up your call. +/// let rb = hub.tests(); +/// # } +/// ``` +pub struct TestMethods<'a, S> + where S: 'a { + + pub(super) hub: &'a YouTube, +} + +impl<'a, S> client::MethodsBuilder for TestMethods<'a, S> {} + +impl<'a, S> TestMethods<'a, S> { + + /// Create a builder to help you perform the following task: + /// + /// POST method. + /// + /// # Arguments + /// + /// * `request` - No description provided. + pub fn insert(&self, request: TestItem) -> TestInsertCall<'a, S> { + use client::ToParts; + let parts = vec![request.to_parts()]; + TestInsertCall { + hub: self.hub, + _request: request, + _part: parts, + _external_channel_id: Default::default(), + _delegate: Default::default(), + _additional_params: Default::default(), + _scopes: Default::default(), + } + } +} + + + +/// A builder providing access to all methods supported on *thirdPartyLink* resources. +/// It is not used directly, but through the [`YouTube`] hub. +/// +/// # Example +/// +/// Instantiate a resource builder +/// +/// ```test_harness,no_run +/// extern crate hyper; +/// extern crate hyper_rustls; +/// extern crate google_youtube3 as youtube3; +/// +/// # async fn dox() { +/// use std::default::Default; +/// use youtube3::{YouTube, oauth2, hyper, hyper_rustls, chrono, FieldMask}; +/// +/// let secret: oauth2::ApplicationSecret = Default::default(); +/// let auth = oauth2::InstalledFlowAuthenticator::builder( +/// secret, +/// oauth2::InstalledFlowReturnMethod::HTTPRedirect, +/// ).build().await.unwrap(); +/// let mut hub = YouTube::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().unwrap().https_or_http().enable_http1().build()), auth); +/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* +/// // like `delete(...)`, `insert(...)`, `list(...)` and `update(...)` +/// // to build up your call. +/// let rb = hub.third_party_links(); +/// # } +/// ``` +pub struct ThirdPartyLinkMethods<'a, S> + where S: 'a { + + pub(super) hub: &'a YouTube, +} + +impl<'a, S> client::MethodsBuilder for ThirdPartyLinkMethods<'a, S> {} + +impl<'a, S> ThirdPartyLinkMethods<'a, S> { + + /// Create a builder to help you perform the following task: + /// + /// Deletes a resource. + /// + /// # Arguments + /// + /// * `linkingToken` - Delete the partner links with the given linking token. + /// * `type` - Type of the link to be deleted. + pub fn delete(&self, linking_token: &str, type_: &ThirdPartyLinkTypeEnum) -> ThirdPartyLinkDeleteCall<'a, S> { + ThirdPartyLinkDeleteCall { + hub: self.hub, + _linking_token: linking_token.to_string(), + _type_: type_.clone(), + _part: Default::default(), + _external_channel_id: Default::default(), + _delegate: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Inserts a new resource into this collection. + /// + /// # Arguments + /// + /// * `request` - No description provided. + pub fn insert(&self, request: ThirdPartyLink) -> ThirdPartyLinkInsertCall<'a, S> { + use client::ToParts; + let parts = vec![request.to_parts()]; + ThirdPartyLinkInsertCall { + hub: self.hub, + _request: request, + _part: parts, + _external_channel_id: Default::default(), + _delegate: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Retrieves a list of resources, possibly filtered. + /// + /// # Arguments + /// + /// * `part` - The *part* parameter specifies the thirdPartyLink resource parts that the API response will include. Supported values are linkingToken, status, and snippet. + pub fn list(&self, part: &Vec) -> ThirdPartyLinkListCall<'a, S> { + ThirdPartyLinkListCall { + hub: self.hub, + _part: part.clone(), + _type_: Default::default(), + _linking_token: Default::default(), + _external_channel_id: Default::default(), + _delegate: Default::default(), + _additional_params: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Updates an existing resource. + /// + /// # Arguments + /// + /// * `request` - No description provided. + pub fn update(&self, request: ThirdPartyLink) -> ThirdPartyLinkUpdateCall<'a, S> { + use client::ToParts; + let parts = vec![request.to_parts()]; + ThirdPartyLinkUpdateCall { + hub: self.hub, + _request: request, + _part: parts, + _external_channel_id: Default::default(), + _delegate: Default::default(), + _additional_params: Default::default(), + } + } +} + + + +/// A builder providing access to all methods supported on *thumbnail* resources. +/// It is not used directly, but through the [`YouTube`] hub. +/// +/// # Example +/// +/// Instantiate a resource builder +/// +/// ```test_harness,no_run +/// extern crate hyper; +/// extern crate hyper_rustls; +/// extern crate google_youtube3 as youtube3; +/// +/// # async fn dox() { +/// use std::default::Default; +/// use youtube3::{YouTube, oauth2, hyper, hyper_rustls, chrono, FieldMask}; +/// +/// let secret: oauth2::ApplicationSecret = Default::default(); +/// let auth = oauth2::InstalledFlowAuthenticator::builder( +/// secret, +/// oauth2::InstalledFlowReturnMethod::HTTPRedirect, +/// ).build().await.unwrap(); +/// let mut hub = YouTube::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().unwrap().https_or_http().enable_http1().build()), auth); +/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* +/// // like `set(...)` +/// // to build up your call. +/// let rb = hub.thumbnails(); +/// # } +/// ``` +pub struct ThumbnailMethods<'a, S> + where S: 'a { + + pub(super) hub: &'a YouTube, +} + +impl<'a, S> client::MethodsBuilder for ThumbnailMethods<'a, S> {} + +impl<'a, S> ThumbnailMethods<'a, S> { + + /// Create a builder to help you perform the following task: + /// + /// As this is not an insert in a strict sense (it supports uploading/setting of a thumbnail for multiple videos, which doesn't result in creation of a single resource), I use a custom verb here. + /// + /// # Arguments + /// + /// * `videoId` - Returns the Thumbnail with the given video IDs for Stubby or Apiary. + pub fn set(&self, video_id: &str) -> ThumbnailSetCall<'a, S> { + ThumbnailSetCall { + hub: self.hub, + _video_id: video_id.to_string(), + _on_behalf_of_content_owner: Default::default(), + _delegate: Default::default(), + _additional_params: Default::default(), + _scopes: Default::default(), + } + } +} + + + +/// A builder providing access to all methods supported on *videoAbuseReportReason* resources. +/// It is not used directly, but through the [`YouTube`] hub. +/// +/// # Example +/// +/// Instantiate a resource builder +/// +/// ```test_harness,no_run +/// extern crate hyper; +/// extern crate hyper_rustls; +/// extern crate google_youtube3 as youtube3; +/// +/// # async fn dox() { +/// use std::default::Default; +/// use youtube3::{YouTube, oauth2, hyper, hyper_rustls, chrono, FieldMask}; +/// +/// let secret: oauth2::ApplicationSecret = Default::default(); +/// let auth = oauth2::InstalledFlowAuthenticator::builder( +/// secret, +/// oauth2::InstalledFlowReturnMethod::HTTPRedirect, +/// ).build().await.unwrap(); +/// let mut hub = YouTube::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().unwrap().https_or_http().enable_http1().build()), auth); +/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* +/// // like `list(...)` +/// // to build up your call. +/// let rb = hub.video_abuse_report_reasons(); +/// # } +/// ``` +pub struct VideoAbuseReportReasonMethods<'a, S> + where S: 'a { + + pub(super) hub: &'a YouTube, +} + +impl<'a, S> client::MethodsBuilder for VideoAbuseReportReasonMethods<'a, S> {} + +impl<'a, S> VideoAbuseReportReasonMethods<'a, S> { + + /// Create a builder to help you perform the following task: + /// + /// Retrieves a list of resources, possibly filtered. + /// + /// # Arguments + /// + /// * `part` - The *part* parameter specifies the videoCategory resource parts that the API response will include. Supported values are id and snippet. + pub fn list(&self, part: &Vec) -> VideoAbuseReportReasonListCall<'a, S> { + VideoAbuseReportReasonListCall { + hub: self.hub, + _part: part.clone(), + _hl: Default::default(), + _delegate: Default::default(), + _additional_params: Default::default(), + _scopes: Default::default(), + } + } +} + + + +/// A builder providing access to all methods supported on *videoCategory* resources. +/// It is not used directly, but through the [`YouTube`] hub. +/// +/// # Example +/// +/// Instantiate a resource builder +/// +/// ```test_harness,no_run +/// extern crate hyper; +/// extern crate hyper_rustls; +/// extern crate google_youtube3 as youtube3; +/// +/// # async fn dox() { +/// use std::default::Default; +/// use youtube3::{YouTube, oauth2, hyper, hyper_rustls, chrono, FieldMask}; +/// +/// let secret: oauth2::ApplicationSecret = Default::default(); +/// let auth = oauth2::InstalledFlowAuthenticator::builder( +/// secret, +/// oauth2::InstalledFlowReturnMethod::HTTPRedirect, +/// ).build().await.unwrap(); +/// let mut hub = YouTube::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().unwrap().https_or_http().enable_http1().build()), auth); +/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* +/// // like `list(...)` +/// // to build up your call. +/// let rb = hub.video_categories(); +/// # } +/// ``` +pub struct VideoCategoryMethods<'a, S> + where S: 'a { + + pub(super) hub: &'a YouTube, +} + +impl<'a, S> client::MethodsBuilder for VideoCategoryMethods<'a, S> {} + +impl<'a, S> VideoCategoryMethods<'a, S> { + + /// Create a builder to help you perform the following task: + /// + /// Retrieves a list of resources, possibly filtered. + /// + /// # Arguments + /// + /// * `part` - The *part* parameter specifies the videoCategory resource properties that the API response will include. Set the parameter value to snippet. + pub fn list(&self, part: &Vec) -> VideoCategoryListCall<'a, S> { + VideoCategoryListCall { + hub: self.hub, + _part: part.clone(), + _region_code: Default::default(), + _id: Default::default(), + _hl: Default::default(), + _delegate: Default::default(), + _additional_params: Default::default(), + _scopes: Default::default(), + } + } +} + + + +/// A builder providing access to all methods supported on *video* resources. +/// It is not used directly, but through the [`YouTube`] hub. +/// +/// # Example +/// +/// Instantiate a resource builder +/// +/// ```test_harness,no_run +/// extern crate hyper; +/// extern crate hyper_rustls; +/// extern crate google_youtube3 as youtube3; +/// +/// # async fn dox() { +/// use std::default::Default; +/// use youtube3::{YouTube, oauth2, hyper, hyper_rustls, chrono, FieldMask}; +/// +/// let secret: oauth2::ApplicationSecret = Default::default(); +/// let auth = oauth2::InstalledFlowAuthenticator::builder( +/// secret, +/// oauth2::InstalledFlowReturnMethod::HTTPRedirect, +/// ).build().await.unwrap(); +/// let mut hub = YouTube::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().unwrap().https_or_http().enable_http1().build()), auth); +/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* +/// // like `delete(...)`, `get_rating(...)`, `insert(...)`, `list(...)`, `rate(...)`, `report_abuse(...)` and `update(...)` +/// // to build up your call. +/// let rb = hub.videos(); +/// # } +/// ``` +pub struct VideoMethods<'a, S> + where S: 'a { + + pub(super) hub: &'a YouTube, +} + +impl<'a, S> client::MethodsBuilder for VideoMethods<'a, S> {} + +impl<'a, S> VideoMethods<'a, S> { + + /// Create a builder to help you perform the following task: + /// + /// Deletes a resource. + /// + /// # Arguments + /// + /// * `id` - No description provided. + pub fn delete(&self, id: &str) -> VideoDeleteCall<'a, S> { + VideoDeleteCall { + hub: self.hub, + _id: id.to_string(), + _on_behalf_of_content_owner: Default::default(), + _delegate: Default::default(), + _additional_params: Default::default(), + _scopes: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Retrieves the ratings that the authorized user gave to a list of specified videos. + /// + /// # Arguments + /// + /// * `id` - No description provided. + pub fn get_rating(&self, id: &Vec) -> VideoGetRatingCall<'a, S> { + VideoGetRatingCall { + hub: self.hub, + _id: id.clone(), + _on_behalf_of_content_owner: Default::default(), + _delegate: Default::default(), + _additional_params: Default::default(), + _scopes: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Inserts a new resource into this collection. + /// + /// # Arguments + /// + /// * `request` - No description provided. + pub fn insert(&self, request: Video) -> VideoInsertCall<'a, S> { + use client::ToParts; + let parts = vec![request.to_parts()]; + VideoInsertCall { + hub: self.hub, + _request: request, + _part: parts, + _stabilize: Default::default(), + _on_behalf_of_content_owner_channel: Default::default(), + _on_behalf_of_content_owner: Default::default(), + _notify_subscribers: Default::default(), + _auto_levels: Default::default(), + _delegate: Default::default(), + _additional_params: Default::default(), + _scopes: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Retrieves a list of resources, possibly filtered. + /// + /// # Arguments + /// + /// * `part` - The *part* parameter specifies a comma-separated list of one or more video resource properties that the API response will include. If the parameter identifies a property that contains child properties, the child properties will be included in the response. For example, in a video resource, the snippet property contains the channelId, title, description, tags, and categoryId properties. As such, if you set *part=snippet*, the API response will contain all of those properties. + pub fn list(&self, part: &Vec) -> VideoListCall<'a, S> { + VideoListCall { + hub: self.hub, + _part: part.clone(), + _video_category_id: Default::default(), + _region_code: Default::default(), + _page_token: Default::default(), + _on_behalf_of_content_owner: Default::default(), + _my_rating: Default::default(), + _max_width: Default::default(), + _max_results: Default::default(), + _max_height: Default::default(), + _locale: Default::default(), + _id: Default::default(), + _hl: Default::default(), + _chart: Default::default(), + _delegate: Default::default(), + _additional_params: Default::default(), + _scopes: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Adds a like or dislike rating to a video or removes a rating from a video. + /// + /// # Arguments + /// + /// * `id` - No description provided. + /// * `rating` - No description provided. + pub fn rate(&self, id: &str, rating: &VideoRatingEnum) -> VideoRateCall<'a, S> { + VideoRateCall { + hub: self.hub, + _id: id.to_string(), + _rating: rating.clone(), + _delegate: Default::default(), + _additional_params: Default::default(), + _scopes: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Report abuse for a video. + /// + /// # Arguments + /// + /// * `request` - No description provided. + pub fn report_abuse(&self, request: VideoAbuseReport) -> VideoReportAbuseCall<'a, S> { + VideoReportAbuseCall { + hub: self.hub, + _request: request, + _on_behalf_of_content_owner: Default::default(), + _delegate: Default::default(), + _additional_params: Default::default(), + _scopes: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Updates an existing resource. + /// + /// # Arguments + /// + /// * `request` - No description provided. + pub fn update(&self, request: Video) -> VideoUpdateCall<'a, S> { + use client::ToParts; + let parts = vec![request.to_parts()]; + VideoUpdateCall { + hub: self.hub, + _request: request, + _part: parts, + _on_behalf_of_content_owner: Default::default(), + _delegate: Default::default(), + _additional_params: Default::default(), + _scopes: Default::default(), + } + } +} + + + +/// A builder providing access to all methods supported on *watermark* resources. +/// It is not used directly, but through the [`YouTube`] hub. +/// +/// # Example +/// +/// Instantiate a resource builder +/// +/// ```test_harness,no_run +/// extern crate hyper; +/// extern crate hyper_rustls; +/// extern crate google_youtube3 as youtube3; +/// +/// # async fn dox() { +/// use std::default::Default; +/// use youtube3::{YouTube, oauth2, hyper, hyper_rustls, chrono, FieldMask}; +/// +/// let secret: oauth2::ApplicationSecret = Default::default(); +/// let auth = oauth2::InstalledFlowAuthenticator::builder( +/// secret, +/// oauth2::InstalledFlowReturnMethod::HTTPRedirect, +/// ).build().await.unwrap(); +/// let mut hub = YouTube::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().unwrap().https_or_http().enable_http1().build()), auth); +/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* +/// // like `set(...)` and `unset(...)` +/// // to build up your call. +/// let rb = hub.watermarks(); +/// # } +/// ``` +pub struct WatermarkMethods<'a, S> + where S: 'a { + + pub(super) hub: &'a YouTube, +} + +impl<'a, S> client::MethodsBuilder for WatermarkMethods<'a, S> {} + +impl<'a, S> WatermarkMethods<'a, S> { + + /// Create a builder to help you perform the following task: + /// + /// Allows upload of watermark image and setting it for a channel. + /// + /// # Arguments + /// + /// * `request` - No description provided. + /// * `channelId` - No description provided. + pub fn set(&self, request: InvideoBranding, channel_id: &str) -> WatermarkSetCall<'a, S> { + WatermarkSetCall { + hub: self.hub, + _request: request, + _channel_id: channel_id.to_string(), + _on_behalf_of_content_owner: Default::default(), + _delegate: Default::default(), + _additional_params: Default::default(), + _scopes: Default::default(), + } + } + + /// Create a builder to help you perform the following task: + /// + /// Allows removal of channel watermark. + /// + /// # Arguments + /// + /// * `channelId` - No description provided. + pub fn unset(&self, channel_id: &str) -> WatermarkUnsetCall<'a, S> { + WatermarkUnsetCall { + hub: self.hub, + _channel_id: channel_id.to_string(), + _on_behalf_of_content_owner: Default::default(), + _delegate: Default::default(), + _additional_params: Default::default(), + _scopes: Default::default(), + } + } +} + + + +/// A builder providing access to all methods supported on *youtube* resources. +/// It is not used directly, but through the [`YouTube`] hub. +/// +/// # Example +/// +/// Instantiate a resource builder +/// +/// ```test_harness,no_run +/// extern crate hyper; +/// extern crate hyper_rustls; +/// extern crate google_youtube3 as youtube3; +/// +/// # async fn dox() { +/// use std::default::Default; +/// use youtube3::{YouTube, oauth2, hyper, hyper_rustls, chrono, FieldMask}; +/// +/// let secret: oauth2::ApplicationSecret = Default::default(); +/// let auth = oauth2::InstalledFlowAuthenticator::builder( +/// secret, +/// oauth2::InstalledFlowReturnMethod::HTTPRedirect, +/// ).build().await.unwrap(); +/// let mut hub = YouTube::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().unwrap().https_or_http().enable_http1().build()), auth); +/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders* +/// // like `v3_update_comment_threads(...)` +/// // to build up your call. +/// let rb = hub.youtube(); +/// # } +/// ``` +pub struct YoutubeMethods<'a, S> + where S: 'a { + + pub(super) hub: &'a YouTube, +} + +impl<'a, S> client::MethodsBuilder for YoutubeMethods<'a, S> {} + +impl<'a, S> YoutubeMethods<'a, S> { + + /// Create a builder to help you perform the following task: + /// + /// Updates an existing resource. + /// + /// # Arguments + /// + /// * `request` - No description provided. + pub fn v3_update_comment_threads(&self, request: CommentThread) -> YoutubeV3UpdateCommentThreadCall<'a, S> { + YoutubeV3UpdateCommentThreadCall { + hub: self.hub, + _request: request, + _part: Default::default(), + _delegate: Default::default(), + _additional_params: Default::default(), + } + } +} + + + diff --git a/gen/youtube3/src/api/mod.rs b/gen/youtube3/src/api/mod.rs new file mode 100644 index 0000000000..aca6f89327 --- /dev/null +++ b/gen/youtube3/src/api/mod.rs @@ -0,0 +1,35 @@ +use std::collections::HashMap; +use std::cell::RefCell; +use std::default::Default; +use std::collections::BTreeSet; +use std::error::Error as StdError; +use serde_json as json; +use std::io; +use std::fs; +use std::mem; + +use hyper::client::connect; +use tokio::io::{AsyncRead, AsyncWrite}; +use tokio::time::sleep; +use tower_service; +use serde::{Serialize, Deserialize}; + +use crate::{client, client::GetToken, client::serde_with}; + +mod utilities; +pub use utilities::*; + +mod hub; +pub use hub::*; + +mod schemas; +pub use schemas::*; + +mod method_builders; +pub use method_builders::*; + +mod call_builders; +pub use call_builders::*; + +pub mod enums; +pub(crate) use enums::*; diff --git a/gen/youtube3/src/api/schemas.rs b/gen/youtube3/src/api/schemas.rs new file mode 100644 index 0000000000..18ef7b01f6 --- /dev/null +++ b/gen/youtube3/src/api/schemas.rs @@ -0,0 +1,7108 @@ +use super::*; +/// 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 abuse reports](AbuseReportInsertCall) (request|response) +#[serde_with::serde_as(crate = "::client::serde_with")] +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct AbuseReport { + /// no description provided + #[serde(rename="abuseTypes")] + + pub abuse_types: Option>, + /// no description provided + + pub description: Option, + /// no description provided + #[serde(rename="relatedEntities")] + + pub related_entities: Option>, + /// no description provided + + pub subject: Option, +} + +impl client::RequestValue for AbuseReport {} +impl client::Resource for AbuseReport {} +impl client::ResponseResult for AbuseReport {} + +impl client::ToParts for AbuseReport { + /// Return a comma separated list of members that are currently set, i.e. for which `self.member.is_some()`. + /// The produced string is suitable for use as a parts list that indicates the parts you are sending, and/or + /// the parts you want to see in the server response. + fn to_parts(&self) -> String { + let mut r = String::new(); + if self.abuse_types.is_some() { r = r + "abuseTypes,"; } + if self.description.is_some() { r = r + "description,"; } + if self.related_entities.is_some() { r = r + "relatedEntities,"; } + if self.subject.is_some() { r = r + "subject,"; } + r.pop(); + r + } +} + +/// There is no detailed description. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[serde_with::serde_as(crate = "::client::serde_with")] +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct AbuseType { + /// no description provided + + pub id: Option, +} + +impl client::Part for AbuseType {} + + +/// Rights management policy for YouTube resources. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[serde_with::serde_as(crate = "::client::serde_with")] +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct AccessPolicy { + /// The value of allowed indicates whether the access to the policy is allowed or denied by default. + + pub allowed: Option, + /// A list of region codes that identify countries where the default policy do not apply. + + pub exception: Option>, +} + +impl client::Part for AccessPolicy {} + + +/// An *activity* resource contains information about an action that a particular channel, or user, has taken on YouTube.The actions reported in activity feeds include rating a video, sharing a video, marking a video as a favorite, commenting on a video, uploading a video, and so forth. Each activity resource identifies the type of action, the channel associated with the action, and the resource(s) associated with the action, such as the video that was rated or uploaded. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[serde_with::serde_as(crate = "::client::serde_with")] +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct Activity { + /// The contentDetails object contains information about the content associated with the activity. For example, if the snippet.type value is videoRated, then the contentDetails object's content identifies the rated video. + #[serde(rename="contentDetails")] + + pub content_details: Option, + /// Etag of this resource + + pub etag: Option, + /// The ID that YouTube uses to uniquely identify the activity. + + pub id: Option, + /// Identifies what kind of resource this is. Value: the fixed string "youtube#activity". + + pub kind: Option, + /// The snippet object contains basic details about the activity, including the activity's type and group ID. + + pub snippet: Option, +} + +impl client::Part for Activity {} + + +/// 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. +/// +#[serde_with::serde_as(crate = "::client::serde_with")] +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct ActivityContentDetails { + /// 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 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 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 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 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 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 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 social object contains details about a social network post. This property is only present if the snippet.type is social. + + pub social: 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, + /// The upload object contains information about the uploaded video. This property is only present if the snippet.type is upload. + + pub upload: Option, +} + +impl client::Part for ActivityContentDetails {} + + +/// Details about a channel bulletin post. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[serde_with::serde_as(crate = "::client::serde_with")] +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct ActivityContentDetailsBulletin { + /// The resourceId object contains information that identifies the resource associated with a bulletin post. @mutable youtube.activities.insert + #[serde(rename="resourceId")] + + pub resource_id: Option, +} + +impl client::Part for ActivityContentDetailsBulletin {} + + +/// Details about a resource which was added to a channel. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[serde_with::serde_as(crate = "::client::serde_with")] +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct ActivityContentDetailsChannelItem { + /// The resourceId object contains information that identifies the resource that was added to the channel. + #[serde(rename="resourceId")] + + pub resource_id: Option, +} + +impl client::Part for ActivityContentDetailsChannelItem {} + + +/// Information about a resource that received a comment. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[serde_with::serde_as(crate = "::client::serde_with")] +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct ActivityContentDetailsComment { + /// The resourceId object contains information that identifies the resource associated with the comment. + #[serde(rename="resourceId")] + + pub resource_id: Option, +} + +impl client::Part for ActivityContentDetailsComment {} + + +/// Information about a video that was marked as a favorite video. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[serde_with::serde_as(crate = "::client::serde_with")] +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct ActivityContentDetailsFavorite { + /// The resourceId object contains information that identifies the resource that was marked as a favorite. + #[serde(rename="resourceId")] + + pub resource_id: Option, +} + +impl client::Part for ActivityContentDetailsFavorite {} + + +/// Information about a resource that received a positive (like) rating. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[serde_with::serde_as(crate = "::client::serde_with")] +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct ActivityContentDetailsLike { + /// The resourceId object contains information that identifies the rated resource. + #[serde(rename="resourceId")] + + pub resource_id: Option, +} + +impl client::Part for ActivityContentDetailsLike {} + + +/// Information about a new playlist item. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[serde_with::serde_as(crate = "::client::serde_with")] +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct ActivityContentDetailsPlaylistItem { + /// The value that YouTube uses to uniquely identify the playlist. + #[serde(rename="playlistId")] + + pub playlist_id: Option, + /// ID of the item within the playlist. + #[serde(rename="playlistItemId")] + + pub playlist_item_id: Option, + /// The resourceId object contains information about the resource that was added to the playlist. + #[serde(rename="resourceId")] + + pub resource_id: Option, +} + +impl client::Part for ActivityContentDetailsPlaylistItem {} + + +/// Details about a resource which is being promoted. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[serde_with::serde_as(crate = "::client::serde_with")] +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct ActivityContentDetailsPromotedItem { + /// The URL the client should fetch to request a promoted item. + #[serde(rename="adTag")] + + pub ad_tag: Option, + /// The URL the client should ping to indicate that the user clicked through on this promoted item. + #[serde(rename="clickTrackingUrl")] + + pub click_tracking_url: Option, + /// The URL the client should ping to indicate that the user was shown this promoted item. + #[serde(rename="creativeViewUrl")] + + pub creative_view_url: Option, + /// The type of call-to-action, a message to the user indicating action that can be taken. + #[serde(rename="ctaType")] + + pub cta_type: Option, + /// The custom call-to-action button text. If specified, it will override the default button text for the cta_type. + #[serde(rename="customCtaButtonText")] + + pub custom_cta_button_text: Option, + /// The text description to accompany the promoted item. + #[serde(rename="descriptionText")] + + pub description_text: Option, + /// The URL the client should direct the user to, if the user chooses to visit the advertiser's website. + #[serde(rename="destinationUrl")] + + pub destination_url: Option, + /// The list of forecasting URLs. The client should ping all of these URLs when a promoted item is not available, to indicate that a promoted item could have been shown. + #[serde(rename="forecastingUrl")] + + pub forecasting_url: Option>, + /// The list of impression URLs. The client should ping all of these URLs to indicate that the user was shown this promoted item. + #[serde(rename="impressionUrl")] + + pub impression_url: Option>, + /// The ID that YouTube uses to uniquely identify the promoted video. + #[serde(rename="videoId")] + + pub video_id: Option, +} + +impl client::Part for ActivityContentDetailsPromotedItem {} + + +/// Information that identifies the recommended resource. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[serde_with::serde_as(crate = "::client::serde_with")] +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct ActivityContentDetailsRecommendation { + /// The reason that the resource is recommended to the user. + + pub reason: Option, + /// The resourceId object contains information that identifies the recommended resource. + #[serde(rename="resourceId")] + + pub resource_id: Option, + /// The seedResourceId object contains information about the resource that caused the recommendation. + #[serde(rename="seedResourceId")] + + pub seed_resource_id: Option, +} + +impl client::Part for ActivityContentDetailsRecommendation {} + + +/// Details about a social network post. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[serde_with::serde_as(crate = "::client::serde_with")] +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct ActivityContentDetailsSocial { + /// The author of the social network post. + + pub author: Option, + /// An image of the post's author. + #[serde(rename="imageUrl")] + + pub image_url: Option, + /// The URL of the social network post. + #[serde(rename="referenceUrl")] + + pub reference_url: Option, + /// The resourceId object encapsulates information that identifies the resource associated with a social network post. + #[serde(rename="resourceId")] + + pub resource_id: Option, + /// The name of the social network. + #[serde(rename="type")] + + pub type_: Option, +} + +impl client::Part for ActivityContentDetailsSocial {} + + +/// Information about a channel that a user subscribed to. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[serde_with::serde_as(crate = "::client::serde_with")] +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct ActivityContentDetailsSubscription { + /// The resourceId object contains information that identifies the resource that the user subscribed to. + #[serde(rename="resourceId")] + + pub resource_id: Option, +} + +impl client::Part for ActivityContentDetailsSubscription {} + + +/// Information about the uploaded video. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[serde_with::serde_as(crate = "::client::serde_with")] +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct ActivityContentDetailsUpload { + /// The ID that YouTube uses to uniquely identify the uploaded video. + #[serde(rename="videoId")] + + pub video_id: Option, +} + +impl client::Part for ActivityContentDetailsUpload {} + + +/// 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 activities](ActivityListCall) (response) +#[serde_with::serde_as(crate = "::client::serde_with")] +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct ActivityListResponse { + /// Etag of this resource. + + pub etag: Option, + /// Serialized EventId of the request which produced this response. + #[serde(rename="eventId")] + + pub event_id: Option, + /// no description provided + + pub items: Option>, + /// Identifies what kind of resource this is. Value: the fixed string "youtube#activityListResponse". + + pub kind: Option, + /// The token that can be used as the value of the pageToken parameter to retrieve the next page in the result set. + #[serde(rename="nextPageToken")] + + pub next_page_token: Option, + /// General pagination information. + #[serde(rename="pageInfo")] + + pub page_info: Option, + /// The token that can be used as the value of the pageToken parameter to retrieve the previous page in the result set. + #[serde(rename="prevPageToken")] + + pub prev_page_token: Option, + /// no description provided + #[serde(rename="tokenPagination")] + + pub token_pagination: Option, + /// The visitorId identifies the visitor. + #[serde(rename="visitorId")] + + pub visitor_id: Option, +} + +impl client::ResponseResult for ActivityListResponse {} + +impl client::ToParts for ActivityListResponse { + /// Return a comma separated list of members that are currently set, i.e. for which `self.member.is_some()`. + /// The produced string is suitable for use as a parts list that indicates the parts you are sending, and/or + /// the parts you want to see in the server response. + fn to_parts(&self) -> String { + let mut r = String::new(); + if self.etag.is_some() { r = r + "etag,"; } + if self.event_id.is_some() { r = r + "eventId,"; } + if self.items.is_some() { r = r + "items,"; } + if self.kind.is_some() { r = r + "kind,"; } + if self.next_page_token.is_some() { r = r + "nextPageToken,"; } + if self.page_info.is_some() { r = r + "pageInfo,"; } + if self.prev_page_token.is_some() { r = r + "prevPageToken,"; } + if self.token_pagination.is_some() { r = r + "tokenPagination,"; } + if self.visitor_id.is_some() { r = r + "visitorId,"; } + r.pop(); + r + } +} + +/// Basic details about an activity, including title, description, thumbnails, activity type and group. Next ID: 12 +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[serde_with::serde_as(crate = "::client::serde_with")] +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct ActivitySnippet { + /// The ID that YouTube uses to uniquely identify the channel associated with the activity. + #[serde(rename="channelId")] + + pub channel_id: Option, + /// Channel title for the channel responsible for this activity + #[serde(rename="channelTitle")] + + pub channel_title: Option, + /// The description of the resource primarily associated with the activity. @mutable youtube.activities.insert + + pub description: Option, + /// The group ID associated with the activity. A group ID identifies user events that are associated with the same user and resource. For example, if a user rates a video and marks the same video as a favorite, the entries for those events would have the same group ID in the user's activity feed. In your user interface, you can avoid repetition by grouping events with the same groupId value. + #[serde(rename="groupId")] + + pub group_id: Option, + /// The date and time that the video was uploaded. + #[serde(rename="publishedAt")] + + pub published_at: Option>, + /// A map of thumbnail images associated with the resource that is primarily associated with the activity. For each object in the map, the key is the name of the thumbnail image, and the value is an object that contains other information about the thumbnail. + + pub thumbnails: Option, + /// The title of the resource primarily associated with the activity. + + pub title: Option, + /// The type of activity that the resource describes. + #[serde(rename="type")] + + pub type_: Option, +} + +impl client::Part for ActivitySnippet {} + + +/// A *caption* resource represents a YouTube caption track. A caption track is associated with exactly one YouTube video. +/// +/// # Activities +/// +/// This type is used in activities, which are methods you may call on this type or where 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 captions](CaptionDeleteCall) (none) +/// * [download captions](CaptionDownloadCall) (none) +/// * [insert captions](CaptionInsertCall) (request|response) +/// * [list captions](CaptionListCall) (none) +/// * [update captions](CaptionUpdateCall) (request|response) +#[serde_with::serde_as(crate = "::client::serde_with")] +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct Caption { + /// Etag of this resource. + + pub etag: Option, + /// The ID that YouTube uses to uniquely identify the caption track. + + pub id: Option, + /// Identifies what kind of resource this is. Value: the fixed string "youtube#caption". + + pub kind: Option, + /// The snippet object contains basic details about the caption. + + pub snippet: Option, +} + +impl client::RequestValue for Caption {} +impl client::Resource for Caption {} +impl client::ResponseResult for Caption {} + +impl client::ToParts for Caption { + /// Return a comma separated list of members that are currently set, i.e. for which `self.member.is_some()`. + /// The produced string is suitable for use as a parts list that indicates the parts you are sending, and/or + /// the parts you want to see in the server response. + fn to_parts(&self) -> String { + let mut r = String::new(); + if self.etag.is_some() { r = r + "etag,"; } + if self.id.is_some() { r = r + "id,"; } + if self.kind.is_some() { r = r + "kind,"; } + if self.snippet.is_some() { r = r + "snippet,"; } + r.pop(); + r + } +} + +/// 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 captions](CaptionListCall) (response) +#[serde_with::serde_as(crate = "::client::serde_with")] +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct CaptionListResponse { + /// Etag of this resource. + + pub etag: Option, + /// Serialized EventId of the request which produced this response. + #[serde(rename="eventId")] + + pub event_id: Option, + /// A list of captions that match the request criteria. + + pub items: Option>, + /// Identifies what kind of resource this is. Value: the fixed string "youtube#captionListResponse". + + pub kind: Option, + /// The visitorId identifies the visitor. + #[serde(rename="visitorId")] + + pub visitor_id: Option, +} + +impl client::ResponseResult for CaptionListResponse {} + +impl client::ToParts for CaptionListResponse { + /// Return a comma separated list of members that are currently set, i.e. for which `self.member.is_some()`. + /// The produced string is suitable for use as a parts list that indicates the parts you are sending, and/or + /// the parts you want to see in the server response. + fn to_parts(&self) -> String { + let mut r = String::new(); + if self.etag.is_some() { r = r + "etag,"; } + if self.event_id.is_some() { r = r + "eventId,"; } + if self.items.is_some() { r = r + "items,"; } + if self.kind.is_some() { r = r + "kind,"; } + if self.visitor_id.is_some() { r = r + "visitorId,"; } + r.pop(); + r + } +} + +/// Basic details about a caption track, such as its language and name. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[serde_with::serde_as(crate = "::client::serde_with")] +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct CaptionSnippet { + /// The type of audio track associated with the caption track. + #[serde(rename="audioTrackType")] + + pub audio_track_type: Option, + /// The reason that YouTube failed to process the caption track. This property is only present if the state property's value is failed. + #[serde(rename="failureReason")] + + pub failure_reason: Option, + /// Indicates whether YouTube synchronized the caption track to the audio track in the video. The value will be true if a sync was explicitly requested when the caption track was uploaded. For example, when calling the captions.insert or captions.update methods, you can set the sync parameter to true to instruct YouTube to sync the uploaded track to the video. If the value is false, YouTube uses the time codes in the uploaded caption track to determine when to display captions. + #[serde(rename="isAutoSynced")] + + pub is_auto_synced: Option, + /// Indicates whether the track contains closed captions for the deaf and hard of hearing. The default value is false. + #[serde(rename="isCC")] + + pub is_cc: Option, + /// Indicates whether the caption track is a draft. If the value is true, then the track is not publicly visible. The default value is false. @mutable youtube.captions.insert youtube.captions.update + #[serde(rename="isDraft")] + + pub is_draft: Option, + /// Indicates whether caption track is formatted for "easy reader," meaning it is at a third-grade level for language learners. The default value is false. + #[serde(rename="isEasyReader")] + + pub is_easy_reader: Option, + /// Indicates whether the caption track uses large text for the vision-impaired. The default value is false. + #[serde(rename="isLarge")] + + pub is_large: Option, + /// The language of the caption track. The property value is a BCP-47 language tag. + + pub language: Option, + /// The date and time when the caption track was last updated. + #[serde(rename="lastUpdated")] + + pub last_updated: Option>, + /// The name of the caption track. The name is intended to be visible to the user as an option during playback. + + pub name: Option, + /// The caption track's status. + + pub status: Option, + /// The caption track's type. + #[serde(rename="trackKind")] + + pub track_kind: Option, + /// The ID that YouTube uses to uniquely identify the video associated with the caption track. @mutable youtube.captions.insert + #[serde(rename="videoId")] + + pub video_id: Option, +} + +impl client::Part for CaptionSnippet {} + + +/// Brief description of the live stream cdn settings. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[serde_with::serde_as(crate = "::client::serde_with")] +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct CdnSettings { + /// The format of the video stream that you are sending to Youtube. + + pub format: Option, + /// The frame rate of the inbound video data. + #[serde(rename="frameRate")] + + pub frame_rate: 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 method or protocol used to transmit the video stream. + #[serde(rename="ingestionType")] + + pub ingestion_type: Option, + /// The resolution of the inbound video data. + + pub resolution: Option, +} + +impl client::Part for CdnSettings {} + + +/// A *channel* resource contains information about a YouTube channel. +/// +/// # Activities +/// +/// This type is used in activities, which are methods you may call on this type or where 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 channels](ChannelListCall) (none) +/// * [update channels](ChannelUpdateCall) (request|response) +#[serde_with::serde_as(crate = "::client::serde_with")] +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct Channel { + /// The auditionDetails object encapsulates channel data that is relevant for YouTube Partners during the audition process. + #[serde(rename="auditDetails")] + + pub audit_details: Option, + /// The brandingSettings object encapsulates information about the branding of the channel. + #[serde(rename="brandingSettings")] + + pub branding_settings: Option, + /// The contentDetails object encapsulates information about the channel's content. + #[serde(rename="contentDetails")] + + pub content_details: Option, + /// The contentOwnerDetails object encapsulates channel data that is relevant for YouTube Partners linked with the channel. + #[serde(rename="contentOwnerDetails")] + + pub content_owner_details: Option, + /// The conversionPings object encapsulates information about conversion pings that need to be respected by the channel. + #[serde(rename="conversionPings")] + + pub conversion_pings: Option, + /// Etag of this resource. + + pub etag: Option, + /// The ID that YouTube uses to uniquely identify the channel. + + pub id: Option, + /// Identifies what kind of resource this is. Value: the fixed string "youtube#channel". + + pub kind: Option, + /// Localizations for different languages + + pub localizations: Option>, + /// The snippet object contains basic details about the channel, such as its title, description, and thumbnail images. + + pub snippet: Option, + /// The statistics object encapsulates statistics for the channel. + + pub statistics: Option, + /// The status object encapsulates information about the privacy status of the channel. + + pub status: Option, + /// The topicDetails object encapsulates information about Freebase topics associated with the channel. + #[serde(rename="topicDetails")] + + pub topic_details: Option, +} + +impl client::RequestValue for Channel {} +impl client::Resource for Channel {} +impl client::ResponseResult for Channel {} + +impl client::ToParts for Channel { + /// Return a comma separated list of members that are currently set, i.e. for which `self.member.is_some()`. + /// The produced string is suitable for use as a parts list that indicates the parts you are sending, and/or + /// the parts you want to see in the server response. + fn to_parts(&self) -> String { + let mut r = String::new(); + if self.audit_details.is_some() { r = r + "auditDetails,"; } + if self.branding_settings.is_some() { r = r + "brandingSettings,"; } + if self.content_details.is_some() { r = r + "contentDetails,"; } + if self.content_owner_details.is_some() { r = r + "contentOwnerDetails,"; } + if self.conversion_pings.is_some() { r = r + "conversionPings,"; } + if self.etag.is_some() { r = r + "etag,"; } + if self.id.is_some() { r = r + "id,"; } + if self.kind.is_some() { r = r + "kind,"; } + if self.localizations.is_some() { r = r + "localizations,"; } + if self.snippet.is_some() { r = r + "snippet,"; } + if self.statistics.is_some() { r = r + "statistics,"; } + if self.status.is_some() { r = r + "status,"; } + if self.topic_details.is_some() { r = r + "topicDetails,"; } + r.pop(); + r + } +} + +/// The auditDetails object encapsulates channel data that is relevant for YouTube Partners during the audit process. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[serde_with::serde_as(crate = "::client::serde_with")] +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct ChannelAuditDetails { + /// Whether or not the channel respects the community guidelines. + #[serde(rename="communityGuidelinesGoodStanding")] + + pub community_guidelines_good_standing: Option, + /// Whether or not the channel has any unresolved claims. + #[serde(rename="contentIdClaimsGoodStanding")] + + pub content_id_claims_good_standing: Option, + /// Whether or not the channel has any copyright strikes. + #[serde(rename="copyrightStrikesGoodStanding")] + + pub copyright_strikes_good_standing: Option, +} + +impl client::Part for ChannelAuditDetails {} + + +/// A channel banner returned as the response to a channel_banner.insert 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*). +/// +/// * [insert channel banners](ChannelBannerInsertCall) (request|response) +#[serde_with::serde_as(crate = "::client::serde_with")] +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct ChannelBannerResource { + /// no description provided + + pub etag: Option, + /// Identifies what kind of resource this is. Value: the fixed string "youtube#channelBannerResource". + + pub kind: Option, + /// The URL of this banner image. + + pub url: Option, +} + +impl client::RequestValue for ChannelBannerResource {} +impl client::ResponseResult for ChannelBannerResource {} + + +/// Branding properties of a YouTube channel. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[serde_with::serde_as(crate = "::client::serde_with")] +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct ChannelBrandingSettings { + /// Branding properties for the channel view. + + pub channel: Option, + /// Additional experimental branding properties. + + pub hints: Option>, + /// Branding properties for branding images. + + pub image: Option, + /// Branding properties for the watch page. + + pub watch: Option, +} + +impl client::Part for ChannelBrandingSettings {} + + +/// Details about the content of a channel. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[serde_with::serde_as(crate = "::client::serde_with")] +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct ChannelContentDetails { + /// no description provided + #[serde(rename="relatedPlaylists")] + + pub related_playlists: Option, +} + +impl client::Part for ChannelContentDetails {} + + +/// The contentOwnerDetails object encapsulates channel data that is relevant for YouTube Partners linked with the channel. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[serde_with::serde_as(crate = "::client::serde_with")] +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct ChannelContentOwnerDetails { + /// The ID of the content owner linked to the channel. + #[serde(rename="contentOwner")] + + pub content_owner: Option, + /// The date and time when the channel was linked to the content owner. + #[serde(rename="timeLinked")] + + pub time_linked: Option>, +} + +impl client::Part for ChannelContentOwnerDetails {} + + +/// Pings that the app shall fire (authenticated by biscotti cookie). Each ping has a context, in which the app must fire the ping, and a url identifying the ping. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[serde_with::serde_as(crate = "::client::serde_with")] +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct ChannelConversionPing { + /// Defines the context of the ping. + + pub context: Option, + /// The url (without the schema) that the player shall send the ping to. It's at caller's descretion to decide which schema to use (http vs https) Example of a returned url: //googleads.g.doubleclick.net/pagead/ viewthroughconversion/962985656/?data=path%3DtHe_path%3Btype%3D cview%3Butuid%3DGISQtTNGYqaYl4sKxoVvKA&labe=default The caller must append biscotti authentication (ms param in case of mobile, for example) to this ping. + #[serde(rename="conversionUrl")] + + pub conversion_url: Option, +} + +impl client::Part for ChannelConversionPing {} + + +/// The conversionPings object encapsulates information about conversion pings that need to be respected by the channel. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[serde_with::serde_as(crate = "::client::serde_with")] +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct ChannelConversionPings { + /// Pings that the app shall fire (authenticated by biscotti cookie). Each ping has a context, in which the app must fire the ping, and a url identifying the ping. + + pub pings: Option>, +} + +impl client::Part for ChannelConversionPings {} + + +/// 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 channels](ChannelListCall) (response) +#[serde_with::serde_as(crate = "::client::serde_with")] +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct ChannelListResponse { + /// Etag of this resource. + + pub etag: Option, + /// Serialized EventId of the request which produced this response. + #[serde(rename="eventId")] + + pub event_id: Option, + /// no description provided + + pub items: Option>, + /// Identifies what kind of resource this is. Value: the fixed string "youtube#channelListResponse". + + pub kind: Option, + /// The token that can be used as the value of the pageToken parameter to retrieve the next page in the result set. + #[serde(rename="nextPageToken")] + + pub next_page_token: Option, + /// General pagination information. + #[serde(rename="pageInfo")] + + pub page_info: Option, + /// The token that can be used as the value of the pageToken parameter to retrieve the previous page in the result set. + #[serde(rename="prevPageToken")] + + pub prev_page_token: Option, + /// no description provided + #[serde(rename="tokenPagination")] + + pub token_pagination: Option, + /// The visitorId identifies the visitor. + #[serde(rename="visitorId")] + + pub visitor_id: Option, +} + +impl client::ResponseResult for ChannelListResponse {} + +impl client::ToParts for ChannelListResponse { + /// Return a comma separated list of members that are currently set, i.e. for which `self.member.is_some()`. + /// The produced string is suitable for use as a parts list that indicates the parts you are sending, and/or + /// the parts you want to see in the server response. + fn to_parts(&self) -> String { + let mut r = String::new(); + if self.etag.is_some() { r = r + "etag,"; } + if self.event_id.is_some() { r = r + "eventId,"; } + if self.items.is_some() { r = r + "items,"; } + if self.kind.is_some() { r = r + "kind,"; } + if self.next_page_token.is_some() { r = r + "nextPageToken,"; } + if self.page_info.is_some() { r = r + "pageInfo,"; } + if self.prev_page_token.is_some() { r = r + "prevPageToken,"; } + if self.token_pagination.is_some() { r = r + "tokenPagination,"; } + if self.visitor_id.is_some() { r = r + "visitorId,"; } + r.pop(); + r + } +} + +/// Channel localization setting +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[serde_with::serde_as(crate = "::client::serde_with")] +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct ChannelLocalization { + /// The localized strings for channel's description. + + pub description: Option, + /// The localized strings for channel's title. + + pub title: Option, +} + +impl client::Part for ChannelLocalization {} + + +/// There is no detailed description. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[serde_with::serde_as(crate = "::client::serde_with")] +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct ChannelProfileDetails { + /// The YouTube channel ID. + #[serde(rename="channelId")] + + pub channel_id: Option, + /// The channel's URL. + #[serde(rename="channelUrl")] + + pub channel_url: Option, + /// The channel's display name. + #[serde(rename="displayName")] + + pub display_name: Option, + /// The channels's avatar URL. + #[serde(rename="profileImageUrl")] + + pub profile_image_url: Option, +} + +impl client::Part for ChannelProfileDetails {} + + +/// There is no detailed description. +/// +/// # Activities +/// +/// This type is used in activities, which are methods you may call on this type or where this type is involved in. +/// The list links the activity name, along with information about where it is used (one of *request* and *response*). +/// +/// * [delete channel sections](ChannelSectionDeleteCall) (none) +/// * [insert channel sections](ChannelSectionInsertCall) (request|response) +/// * [list channel sections](ChannelSectionListCall) (none) +/// * [update channel sections](ChannelSectionUpdateCall) (request|response) +#[serde_with::serde_as(crate = "::client::serde_with")] +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct ChannelSection { + /// The contentDetails object contains details about the channel section content, such as a list of playlists or channels featured in the section. + #[serde(rename="contentDetails")] + + pub content_details: Option, + /// Etag of this resource. + + pub etag: Option, + /// The ID that YouTube uses to uniquely identify the channel section. + + pub id: Option, + /// Identifies what kind of resource this is. Value: the fixed string "youtube#channelSection". + + pub kind: Option, + /// Localizations for different languages + + pub localizations: Option>, + /// The snippet object contains basic details about the channel section, such as its type, style and title. + + pub snippet: Option, + /// The targeting object contains basic targeting settings about the channel section. + + pub targeting: Option, +} + +impl client::RequestValue for ChannelSection {} +impl client::Resource for ChannelSection {} +impl client::ResponseResult for ChannelSection {} + +impl client::ToParts for ChannelSection { + /// Return a comma separated list of members that are currently set, i.e. for which `self.member.is_some()`. + /// The produced string is suitable for use as a parts list that indicates the parts you are sending, and/or + /// the parts you want to see in the server response. + fn to_parts(&self) -> String { + let mut r = String::new(); + if self.content_details.is_some() { r = r + "contentDetails,"; } + if self.etag.is_some() { r = r + "etag,"; } + if self.id.is_some() { r = r + "id,"; } + if self.kind.is_some() { r = r + "kind,"; } + if self.localizations.is_some() { r = r + "localizations,"; } + if self.snippet.is_some() { r = r + "snippet,"; } + if self.targeting.is_some() { r = r + "targeting,"; } + r.pop(); + r + } +} + +/// Details about a channelsection, including playlists and channels. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[serde_with::serde_as(crate = "::client::serde_with")] +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct ChannelSectionContentDetails { + /// The channel ids for type multiple_channels. + + pub channels: Option>, + /// The playlist ids for type single_playlist and multiple_playlists. For singlePlaylist, only one playlistId is allowed. + + pub playlists: Option>, +} + +impl client::Part for ChannelSectionContentDetails {} + + +/// 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 channel sections](ChannelSectionListCall) (response) +#[serde_with::serde_as(crate = "::client::serde_with")] +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct ChannelSectionListResponse { + /// Etag of this resource. + + pub etag: Option, + /// Serialized EventId of the request which produced this response. + #[serde(rename="eventId")] + + pub event_id: Option, + /// A list of ChannelSections that match the request criteria. + + pub items: Option>, + /// Identifies what kind of resource this is. Value: the fixed string "youtube#channelSectionListResponse". + + pub kind: Option, + /// The visitorId identifies the visitor. + #[serde(rename="visitorId")] + + pub visitor_id: Option, +} + +impl client::ResponseResult for ChannelSectionListResponse {} + +impl client::ToParts for ChannelSectionListResponse { + /// Return a comma separated list of members that are currently set, i.e. for which `self.member.is_some()`. + /// The produced string is suitable for use as a parts list that indicates the parts you are sending, and/or + /// the parts you want to see in the server response. + fn to_parts(&self) -> String { + let mut r = String::new(); + if self.etag.is_some() { r = r + "etag,"; } + if self.event_id.is_some() { r = r + "eventId,"; } + if self.items.is_some() { r = r + "items,"; } + if self.kind.is_some() { r = r + "kind,"; } + if self.visitor_id.is_some() { r = r + "visitorId,"; } + r.pop(); + r + } +} + +/// ChannelSection localization setting +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[serde_with::serde_as(crate = "::client::serde_with")] +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct ChannelSectionLocalization { + /// The localized strings for channel section's title. + + pub title: Option, +} + +impl client::Part for ChannelSectionLocalization {} + + +/// Basic details about a channel section, including title, style and position. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[serde_with::serde_as(crate = "::client::serde_with")] +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct ChannelSectionSnippet { + /// The ID that YouTube uses to uniquely identify the channel that published the channel section. + #[serde(rename="channelId")] + + pub channel_id: Option, + /// The language of the channel section's default title and description. + #[serde(rename="defaultLanguage")] + + pub default_language: Option, + /// Localized title, read-only. + + pub localized: Option, + /// The position of the channel section in the channel. + + pub position: Option, + /// The style of the channel section. + + pub style: Option, + /// The channel section's title for multiple_playlists and multiple_channels. + + pub title: Option, + /// The type of the channel section. + #[serde(rename="type")] + + pub type_: Option, +} + +impl client::Part for ChannelSectionSnippet {} + + +/// ChannelSection targeting setting. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[serde_with::serde_as(crate = "::client::serde_with")] +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct ChannelSectionTargeting { + /// The country the channel section is targeting. + + pub countries: Option>, + /// The language the channel section is targeting. + + pub languages: Option>, + /// The region the channel section is targeting. + + pub regions: Option>, +} + +impl client::Part for ChannelSectionTargeting {} + + +/// Branding properties for the channel view. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[serde_with::serde_as(crate = "::client::serde_with")] +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct ChannelSettings { + /// The country of the channel. + + pub country: Option, + /// no description provided + #[serde(rename="defaultLanguage")] + + pub default_language: Option, + /// Which content tab users should see when viewing the channel. + #[serde(rename="defaultTab")] + + pub default_tab: Option, + /// Specifies the channel description. + + pub description: Option, + /// Title for the featured channels tab. + #[serde(rename="featuredChannelsTitle")] + + pub featured_channels_title: Option, + /// The list of featured channels. + #[serde(rename="featuredChannelsUrls")] + + pub featured_channels_urls: Option>, + /// Lists keywords associated with the channel, comma-separated. + + pub keywords: Option, + /// Whether user-submitted comments left on the channel page need to be approved by the channel owner to be publicly visible. + #[serde(rename="moderateComments")] + + pub moderate_comments: Option, + /// A prominent color that can be rendered on this channel page. + #[serde(rename="profileColor")] + + pub profile_color: Option, + /// Whether the tab to browse the videos should be displayed. + #[serde(rename="showBrowseView")] + + pub show_browse_view: Option, + /// Whether related channels should be proposed. + #[serde(rename="showRelatedChannels")] + + pub show_related_channels: Option, + /// Specifies the channel title. + + pub title: Option, + /// The ID for a Google Analytics account to track and measure traffic to the channels. + #[serde(rename="trackingAnalyticsAccountId")] + + pub tracking_analytics_account_id: Option, + /// The trailer of the channel, for users that are not subscribers. + #[serde(rename="unsubscribedTrailer")] + + pub unsubscribed_trailer: Option, +} + +impl client::Part for ChannelSettings {} + + +/// Basic details about a channel, including title, description and thumbnails. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[serde_with::serde_as(crate = "::client::serde_with")] +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct ChannelSnippet { + /// The country of the channel. + + pub country: Option, + /// The custom url of the channel. + #[serde(rename="customUrl")] + + pub custom_url: Option, + /// The language of the channel's default title and description. + #[serde(rename="defaultLanguage")] + + pub default_language: Option, + /// The description of the channel. + + pub description: Option, + /// Localized title and description, read-only. + + pub localized: Option, + /// The date and time that the channel was created. + #[serde(rename="publishedAt")] + + pub published_at: Option>, + /// A map of thumbnail images associated with the channel. For each object in the map, the key is the name of the thumbnail image, and the value is an object that contains other information about the thumbnail. When displaying thumbnails in your application, make sure that your code uses the image URLs exactly as they are returned in API responses. For example, your application should not use the http domain instead of the https domain in a URL returned in an API response. Beginning in July 2018, channel thumbnail URLs will only be available in the https domain, which is how the URLs appear in API responses. After that time, you might see broken images in your application if it tries to load YouTube images from the http domain. Thumbnail images might be empty for newly created channels and might take up to one day to populate. + + pub thumbnails: Option, + /// The channel's title. + + pub title: Option, +} + +impl client::Part for ChannelSnippet {} + + +/// Statistics about a channel: number of subscribers, number of videos in the channel, etc. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[serde_with::serde_as(crate = "::client::serde_with")] +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct ChannelStatistics { + /// The number of comments for the channel. + #[serde(rename="commentCount")] + + #[serde_as(as = "Option<::client::serde_with::DisplayFromStr>")] + pub comment_count: Option, + /// Whether or not the number of subscribers is shown for this user. + #[serde(rename="hiddenSubscriberCount")] + + pub hidden_subscriber_count: Option, + /// The number of subscribers that the channel has. + #[serde(rename="subscriberCount")] + + #[serde_as(as = "Option<::client::serde_with::DisplayFromStr>")] + pub subscriber_count: Option, + /// The number of videos uploaded to the channel. + #[serde(rename="videoCount")] + + #[serde_as(as = "Option<::client::serde_with::DisplayFromStr>")] + pub video_count: Option, + /// The number of times the channel has been viewed. + #[serde(rename="viewCount")] + + #[serde_as(as = "Option<::client::serde_with::DisplayFromStr>")] + pub view_count: Option, +} + +impl client::Part for ChannelStatistics {} + + +/// JSON template for the status part of a channel. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[serde_with::serde_as(crate = "::client::serde_with")] +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct ChannelStatus { + /// If true, then the user is linked to either a YouTube username or G+ account. Otherwise, the user doesn't have a public YouTube identity. + #[serde(rename="isLinked")] + + pub is_linked: Option, + /// The long uploads status of this channel. See https://support.google.com/youtube/answer/71673 for more information. + #[serde(rename="longUploadsStatus")] + + pub long_uploads_status: Option, + /// no description provided + #[serde(rename="madeForKids")] + + pub made_for_kids: Option, + /// Privacy status of the channel. + #[serde(rename="privacyStatus")] + + pub privacy_status: Option, + /// no description provided + #[serde(rename="selfDeclaredMadeForKids")] + + pub self_declared_made_for_kids: Option, +} + +impl client::Part for ChannelStatus {} + + +/// Information specific to a store on a merchandising platform linked to a YouTube channel. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[serde_with::serde_as(crate = "::client::serde_with")] +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct ChannelToStoreLinkDetails { + /// Information specific to billing (read-only). + #[serde(rename="billingDetails")] + + pub billing_details: Option, + /// Google Merchant Center id of the store. + #[serde(rename="merchantId")] + + #[serde_as(as = "Option<::client::serde_with::DisplayFromStr>")] + pub merchant_id: Option, + /// Name of the store. + #[serde(rename="storeName")] + + pub store_name: Option, + /// Landing page of the store. + #[serde(rename="storeUrl")] + + pub store_url: Option, +} + +impl client::Part for ChannelToStoreLinkDetails {} + + +/// Information specific to billing. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[serde_with::serde_as(crate = "::client::serde_with")] +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct ChannelToStoreLinkDetailsBillingDetails { + /// The current billing profile status. + #[serde(rename="billingStatus")] + + pub billing_status: Option, +} + +impl client::Part for ChannelToStoreLinkDetailsBillingDetails {} + + +/// Freebase topic information related to the channel. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[serde_with::serde_as(crate = "::client::serde_with")] +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct ChannelTopicDetails { + /// A list of Wikipedia URLs that describe the channel's content. + #[serde(rename="topicCategories")] + + pub topic_categories: Option>, + /// A list of Freebase topic IDs associated with the channel. You can retrieve information about each topic using the Freebase Topic API. + #[serde(rename="topicIds")] + + pub topic_ids: Option>, +} + +impl client::Part for ChannelTopicDetails {} + + +/// A *comment* represents a single YouTube comment. +/// +/// # Activities +/// +/// This type is used in activities, which are methods you may call on this type or where 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 comments](CommentDeleteCall) (none) +/// * [insert comments](CommentInsertCall) (request|response) +/// * [list comments](CommentListCall) (none) +/// * [mark as spam comments](CommentMarkAsSpamCall) (none) +/// * [set moderation status comments](CommentSetModerationStatusCall) (none) +/// * [update comments](CommentUpdateCall) (request|response) +#[serde_with::serde_as(crate = "::client::serde_with")] +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct Comment { + /// Etag of this resource. + + pub etag: Option, + /// The ID that YouTube uses to uniquely identify the comment. + + pub id: Option, + /// Identifies what kind of resource this is. Value: the fixed string "youtube#comment". + + pub kind: Option, + /// The snippet object contains basic details about the comment. + + pub snippet: Option, +} + +impl client::RequestValue for Comment {} +impl client::Resource for Comment {} +impl client::ResponseResult for Comment {} + +impl client::ToParts for Comment { + /// Return a comma separated list of members that are currently set, i.e. for which `self.member.is_some()`. + /// The produced string is suitable for use as a parts list that indicates the parts you are sending, and/or + /// the parts you want to see in the server response. + fn to_parts(&self) -> String { + let mut r = String::new(); + if self.etag.is_some() { r = r + "etag,"; } + if self.id.is_some() { r = r + "id,"; } + if self.kind.is_some() { r = r + "kind,"; } + if self.snippet.is_some() { r = r + "snippet,"; } + r.pop(); + r + } +} + +/// 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 comments](CommentListCall) (response) +#[serde_with::serde_as(crate = "::client::serde_with")] +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct CommentListResponse { + /// Etag of this resource. + + pub etag: Option, + /// Serialized EventId of the request which produced this response. + #[serde(rename="eventId")] + + pub event_id: Option, + /// A list of comments that match the request criteria. + + pub items: Option>, + /// Identifies what kind of resource this is. Value: the fixed string "youtube#commentListResponse". + + pub kind: Option, + /// The token that can be used as the value of the pageToken parameter to retrieve the next page in the result set. + #[serde(rename="nextPageToken")] + + pub next_page_token: Option, + /// General pagination information. + #[serde(rename="pageInfo")] + + pub page_info: Option, + /// no description provided + #[serde(rename="tokenPagination")] + + pub token_pagination: Option, + /// The visitorId identifies the visitor. + #[serde(rename="visitorId")] + + pub visitor_id: Option, +} + +impl client::ResponseResult for CommentListResponse {} + +impl client::ToParts for CommentListResponse { + /// Return a comma separated list of members that are currently set, i.e. for which `self.member.is_some()`. + /// The produced string is suitable for use as a parts list that indicates the parts you are sending, and/or + /// the parts you want to see in the server response. + fn to_parts(&self) -> String { + let mut r = String::new(); + if self.etag.is_some() { r = r + "etag,"; } + if self.event_id.is_some() { r = r + "eventId,"; } + if self.items.is_some() { r = r + "items,"; } + if self.kind.is_some() { r = r + "kind,"; } + if self.next_page_token.is_some() { r = r + "nextPageToken,"; } + if self.page_info.is_some() { r = r + "pageInfo,"; } + if self.token_pagination.is_some() { r = r + "tokenPagination,"; } + if self.visitor_id.is_some() { r = r + "visitorId,"; } + r.pop(); + r + } +} + +/// Basic details about a comment, such as its author and text. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[serde_with::serde_as(crate = "::client::serde_with")] +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct CommentSnippet { + /// no description provided + #[serde(rename="authorChannelId")] + + pub author_channel_id: Option, + /// Link to the author's YouTube channel, if any. + #[serde(rename="authorChannelUrl")] + + pub author_channel_url: Option, + /// The name of the user who posted the comment. + #[serde(rename="authorDisplayName")] + + pub author_display_name: Option, + /// The URL for the avatar of the user who posted the comment. + #[serde(rename="authorProfileImageUrl")] + + pub author_profile_image_url: Option, + /// Whether the current viewer can rate this comment. + #[serde(rename="canRate")] + + pub can_rate: Option, + /// The id of the corresponding YouTube channel. In case of a channel comment this is the channel the comment refers to. In case of a video comment it's the video's channel. + #[serde(rename="channelId")] + + pub channel_id: Option, + /// The total number of likes this comment has received. + #[serde(rename="likeCount")] + + pub like_count: Option, + /// The comment's moderation status. Will not be set if the comments were requested through the id filter. + #[serde(rename="moderationStatus")] + + pub moderation_status: Option, + /// The unique id of the parent comment, only set for replies. + #[serde(rename="parentId")] + + pub parent_id: Option, + /// The date and time when the comment was originally published. + #[serde(rename="publishedAt")] + + pub published_at: Option>, + /// The comment's text. The format is either plain text or HTML dependent on what has been requested. Even the plain text representation may differ from the text originally posted in that it may replace video links with video titles etc. + #[serde(rename="textDisplay")] + + pub text_display: Option, + /// The comment's original raw text as initially posted or last updated. The original text will only be returned if it is accessible to the viewer, which is only guaranteed if the viewer is the comment's author. + #[serde(rename="textOriginal")] + + pub text_original: Option, + /// The date and time when the comment was last updated. + #[serde(rename="updatedAt")] + + pub updated_at: Option>, + /// The ID of the video the comment refers to, if any. + #[serde(rename="videoId")] + + pub video_id: Option, + /// The rating the viewer has given to this comment. For the time being this will never return RATE_TYPE_DISLIKE and instead return RATE_TYPE_NONE. This may change in the future. + #[serde(rename="viewerRating")] + + pub viewer_rating: Option, +} + +impl client::Part for CommentSnippet {} + + +/// The id of the author's YouTube channel, if any. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[serde_with::serde_as(crate = "::client::serde_with")] +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct CommentSnippetAuthorChannelId { + /// no description provided + + pub value: Option, +} + +impl client::Part for CommentSnippetAuthorChannelId {} + + +/// A *comment thread* represents information that applies to a top level comment and all its replies. It can also include the top level comment itself and some of the replies. +/// +/// # Activities +/// +/// This type is used in activities, which are methods you may call on this type or where 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 comment threads](CommentThreadInsertCall) (request|response) +/// * [list comment threads](CommentThreadListCall) (none) +/// * [v3 update comment threads youtube](YoutubeV3UpdateCommentThreadCall) (request|response) +#[serde_with::serde_as(crate = "::client::serde_with")] +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct CommentThread { + /// Etag of this resource. + + pub etag: Option, + /// The ID that YouTube uses to uniquely identify the comment thread. + + pub id: Option, + /// Identifies what kind of resource this is. Value: the fixed string "youtube#commentThread". + + pub kind: Option, + /// The replies object contains a limited number of replies (if any) to the top level comment found in the snippet. + + pub replies: Option, + /// The snippet object contains basic details about the comment thread and also the top level comment. + + pub snippet: Option, +} + +impl client::RequestValue for CommentThread {} +impl client::Resource for CommentThread {} +impl client::ResponseResult for CommentThread {} + +impl client::ToParts for CommentThread { + /// Return a comma separated list of members that are currently set, i.e. for which `self.member.is_some()`. + /// The produced string is suitable for use as a parts list that indicates the parts you are sending, and/or + /// the parts you want to see in the server response. + fn to_parts(&self) -> String { + let mut r = String::new(); + if self.etag.is_some() { r = r + "etag,"; } + if self.id.is_some() { r = r + "id,"; } + if self.kind.is_some() { r = r + "kind,"; } + if self.replies.is_some() { r = r + "replies,"; } + if self.snippet.is_some() { r = r + "snippet,"; } + r.pop(); + r + } +} + +/// 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 comment threads](CommentThreadListCall) (response) +#[serde_with::serde_as(crate = "::client::serde_with")] +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct CommentThreadListResponse { + /// Etag of this resource. + + pub etag: Option, + /// Serialized EventId of the request which produced this response. + #[serde(rename="eventId")] + + pub event_id: Option, + /// A list of comment threads that match the request criteria. + + pub items: Option>, + /// Identifies what kind of resource this is. Value: the fixed string "youtube#commentThreadListResponse". + + pub kind: Option, + /// The token that can be used as the value of the pageToken parameter to retrieve the next page in the result set. + #[serde(rename="nextPageToken")] + + pub next_page_token: Option, + /// General pagination information. + #[serde(rename="pageInfo")] + + pub page_info: Option, + /// no description provided + #[serde(rename="tokenPagination")] + + pub token_pagination: Option, + /// The visitorId identifies the visitor. + #[serde(rename="visitorId")] + + pub visitor_id: Option, +} + +impl client::ResponseResult for CommentThreadListResponse {} + +impl client::ToParts for CommentThreadListResponse { + /// Return a comma separated list of members that are currently set, i.e. for which `self.member.is_some()`. + /// The produced string is suitable for use as a parts list that indicates the parts you are sending, and/or + /// the parts you want to see in the server response. + fn to_parts(&self) -> String { + let mut r = String::new(); + if self.etag.is_some() { r = r + "etag,"; } + if self.event_id.is_some() { r = r + "eventId,"; } + if self.items.is_some() { r = r + "items,"; } + if self.kind.is_some() { r = r + "kind,"; } + if self.next_page_token.is_some() { r = r + "nextPageToken,"; } + if self.page_info.is_some() { r = r + "pageInfo,"; } + if self.token_pagination.is_some() { r = r + "tokenPagination,"; } + if self.visitor_id.is_some() { r = r + "visitorId,"; } + r.pop(); + r + } +} + +/// Comments written in (direct or indirect) reply to the top level comment. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[serde_with::serde_as(crate = "::client::serde_with")] +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct CommentThreadReplies { + /// A limited number of replies. Unless the number of replies returned equals total_reply_count in the snippet the returned replies are only a subset of the total number of replies. + + pub comments: Option>, +} + +impl client::Part for CommentThreadReplies {} + + +/// Basic details about a comment thread. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[serde_with::serde_as(crate = "::client::serde_with")] +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct CommentThreadSnippet { + /// Whether the current viewer of the thread can reply to it. This is viewer specific - other viewers may see a different value for this field. + #[serde(rename="canReply")] + + pub can_reply: Option, + /// The YouTube channel the comments in the thread refer to or the channel with the video the comments refer to. If video_id isn't set the comments refer to the channel itself. + #[serde(rename="channelId")] + + pub channel_id: Option, + /// Whether the thread (and therefore all its comments) is visible to all YouTube users. + #[serde(rename="isPublic")] + + pub is_public: Option, + /// The top level comment of this thread. + #[serde(rename="topLevelComment")] + + pub top_level_comment: Option, + /// The total number of replies (not including the top level comment). + #[serde(rename="totalReplyCount")] + + pub total_reply_count: Option, + /// The ID of the video the comments refer to, if any. No video_id implies a channel discussion comment. + #[serde(rename="videoId")] + + pub video_id: Option, +} + +impl client::Part for CommentThreadSnippet {} + + +/// Ratings schemes. The country-specific ratings are mostly for movies and shows. LINT.IfChange +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[serde_with::serde_as(crate = "::client::serde_with")] +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct ContentRating { + /// The video's Australian Classification Board (ACB) or Australian Communications and Media Authority (ACMA) rating. ACMA ratings are used to classify children's television programming. + #[serde(rename="acbRating")] + + pub acb_rating: Option, + /// The video's rating from Italy's Autorità per le Garanzie nelle Comunicazioni (AGCOM). + #[serde(rename="agcomRating")] + + pub agcom_rating: Option, + /// The video's Anatel (Asociación Nacional de Televisión) rating for Chilean television. + #[serde(rename="anatelRating")] + + pub anatel_rating: Option, + /// The video's British Board of Film Classification (BBFC) rating. + #[serde(rename="bbfcRating")] + + pub bbfc_rating: Option, + /// The video's rating from Thailand's Board of Film and Video Censors. + #[serde(rename="bfvcRating")] + + pub bfvc_rating: Option, + /// The video's rating from the Austrian Board of Media Classification (Bundesministerium für Unterricht, Kunst und Kultur). + #[serde(rename="bmukkRating")] + + pub bmukk_rating: Option, + /// Rating system for Canadian TV - Canadian TV Classification System The video's rating from the Canadian Radio-Television and Telecommunications Commission (CRTC) for Canadian English-language broadcasts. For more information, see the Canadian Broadcast Standards Council website. + #[serde(rename="catvRating")] + + pub catv_rating: Option, + /// The video's rating from the Canadian Radio-Television and Telecommunications Commission (CRTC) for Canadian French-language broadcasts. For more information, see the Canadian Broadcast Standards Council website. + #[serde(rename="catvfrRating")] + + pub catvfr_rating: Option, + /// The video's Central Board of Film Certification (CBFC - India) rating. + #[serde(rename="cbfcRating")] + + pub cbfc_rating: Option, + /// The video's Consejo de Calificación Cinematográfica (Chile) rating. + #[serde(rename="cccRating")] + + pub ccc_rating: Option, + /// The video's rating from Portugal's Comissão de Classificação de Espect´culos. + #[serde(rename="cceRating")] + + pub cce_rating: Option, + /// The video's rating in Switzerland. + #[serde(rename="chfilmRating")] + + pub chfilm_rating: Option, + /// The video's Canadian Home Video Rating System (CHVRS) rating. + #[serde(rename="chvrsRating")] + + pub chvrs_rating: Option, + /// The video's rating from the Commission de Contrôle des Films (Belgium). + #[serde(rename="cicfRating")] + + pub cicf_rating: Option, + /// The video's rating from Romania's CONSILIUL NATIONAL AL AUDIOVIZUALULUI (CNA). + #[serde(rename="cnaRating")] + + pub cna_rating: Option, + /// Rating system in France - Commission de classification cinematographique + #[serde(rename="cncRating")] + + pub cnc_rating: Option, + /// The video's rating from France's Conseil supérieur de l’audiovisuel, which rates broadcast content. + #[serde(rename="csaRating")] + + pub csa_rating: Option, + /// The video's rating from Luxembourg's Commission de surveillance de la classification des films (CSCF). + #[serde(rename="cscfRating")] + + pub cscf_rating: Option, + /// The video's rating in the Czech Republic. + #[serde(rename="czfilmRating")] + + pub czfilm_rating: Option, + /// The video's Departamento de Justiça, Classificação, Qualificação e Títulos (DJCQT - Brazil) rating. + #[serde(rename="djctqRating")] + + pub djctq_rating: Option, + /// Reasons that explain why the video received its DJCQT (Brazil) rating. + #[serde(rename="djctqRatingReasons")] + + pub djctq_rating_reasons: Option>, + /// Rating system in Turkey - Evaluation and Classification Board of the Ministry of Culture and Tourism + #[serde(rename="ecbmctRating")] + + pub ecbmct_rating: Option, + /// The video's rating in Estonia. + #[serde(rename="eefilmRating")] + + pub eefilm_rating: Option, + /// The video's rating in Egypt. + #[serde(rename="egfilmRating")] + + pub egfilm_rating: Option, + /// The video's Eirin (映倫) rating. Eirin is the Japanese rating system. + #[serde(rename="eirinRating")] + + pub eirin_rating: Option, + /// The video's rating from Malaysia's Film Censorship Board. + #[serde(rename="fcbmRating")] + + pub fcbm_rating: Option, + /// The video's rating from Hong Kong's Office for Film, Newspaper and Article Administration. + #[serde(rename="fcoRating")] + + pub fco_rating: Option, + /// This property has been deprecated. Use the contentDetails.contentRating.cncRating instead. + #[serde(rename="fmocRating")] + + pub fmoc_rating: Option, + /// The video's rating from South Africa's Film and Publication Board. + #[serde(rename="fpbRating")] + + pub fpb_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 Freiwillige Selbstkontrolle der Filmwirtschaft (FSK - Germany) rating. + #[serde(rename="fskRating")] + + pub fsk_rating: Option, + /// The video's rating in Greece. + #[serde(rename="grfilmRating")] + + pub grfilm_rating: Option, + /// The video's Instituto de la Cinematografía y de las Artes Audiovisuales (ICAA - Spain) rating. + #[serde(rename="icaaRating")] + + pub icaa_rating: Option, + /// The video's Irish Film Classification Office (IFCO - Ireland) rating. See the IFCO website for more information. + #[serde(rename="ifcoRating")] + + pub ifco_rating: Option, + /// The video's rating in Israel. + #[serde(rename="ilfilmRating")] + + pub ilfilm_rating: Option, + /// The video's INCAA (Instituto Nacional de Cine y Artes Audiovisuales - Argentina) rating. + #[serde(rename="incaaRating")] + + pub incaa_rating: Option, + /// The video's rating from the Kenya Film Classification Board. + #[serde(rename="kfcbRating")] + + pub kfcb_rating: Option, + /// The video's NICAM/Kijkwijzer rating from the Nederlands Instituut voor de Classificatie van Audiovisuele Media (Netherlands). + #[serde(rename="kijkwijzerRating")] + + pub kijkwijzer_rating: Option, + /// The video's Korea Media Rating Board (영상물등급위원회) rating. The KMRB rates videos in South Korea. + #[serde(rename="kmrbRating")] + + pub kmrb_rating: Option, + /// The video's rating from Indonesia's Lembaga Sensor Film. + #[serde(rename="lsfRating")] + + pub lsf_rating: Option, + /// The video's rating from Malta's Film Age-Classification Board. + #[serde(rename="mccaaRating")] + + pub mccaa_rating: Option, + /// The video's rating from the Danish Film Institute's (Det Danske Filminstitut) Media Council for Children and Young People. + #[serde(rename="mccypRating")] + + pub mccyp_rating: Option, + /// The video's rating system for Vietnam - MCST + #[serde(rename="mcstRating")] + + pub mcst_rating: Option, + /// The video's rating from Singapore's Media Development Authority (MDA) and, specifically, it's Board of Film Censors (BFC). + #[serde(rename="mdaRating")] + + pub mda_rating: Option, + /// The video's rating from Medietilsynet, the Norwegian Media Authority. + #[serde(rename="medietilsynetRating")] + + pub medietilsynet_rating: Option, + /// The video's rating from Finland's Kansallinen Audiovisuaalinen Instituutti (National Audiovisual Institute). + #[serde(rename="mekuRating")] + + pub meku_rating: Option, + /// The rating system for MENA countries, a clone of MPAA. It is needed to prevent titles go live w/o additional QC check, since some of them can be inappropriate for the countries at all. See b/33408548 for more details. + #[serde(rename="menaMpaaRating")] + + pub mena_mpaa_rating: Option, + /// The video's rating from the Ministero dei Beni e delle Attività Culturali e del Turismo (Italy). + #[serde(rename="mibacRating")] + + pub mibac_rating: Option, + /// The video's Ministerio de Cultura (Colombia) rating. + #[serde(rename="mocRating")] + + pub moc_rating: Option, + /// The video's rating from Taiwan's Ministry of Culture (文化部). + #[serde(rename="moctwRating")] + + pub moctw_rating: Option, + /// The video's Motion Picture Association of America (MPAA) rating. + #[serde(rename="mpaaRating")] + + pub mpaa_rating: Option, + /// The rating system for trailer, DVD, and Ad in the US. See http://movielabs.com/md/ratings/v2.3/html/US_MPAAT_Ratings.html. + #[serde(rename="mpaatRating")] + + pub mpaat_rating: Option, + /// The video's rating from the Movie and Television Review and Classification Board (Philippines). + #[serde(rename="mtrcbRating")] + + pub mtrcb_rating: Option, + /// The video's rating from the Maldives National Bureau of Classification. + #[serde(rename="nbcRating")] + + pub nbc_rating: Option, + /// The video's rating in Poland. + #[serde(rename="nbcplRating")] + + pub nbcpl_rating: Option, + /// The video's rating from the Bulgarian National Film Center. + #[serde(rename="nfrcRating")] + + pub nfrc_rating: Option, + /// The video's rating from Nigeria's National Film and Video Censors Board. + #[serde(rename="nfvcbRating")] + + pub nfvcb_rating: Option, + /// The video's rating from the Nacionãlais Kino centrs (National Film Centre of Latvia). + #[serde(rename="nkclvRating")] + + pub nkclv_rating: Option, + /// The National Media Council ratings system for United Arab Emirates. + #[serde(rename="nmcRating")] + + pub nmc_rating: Option, + /// The video's Office of Film and Literature Classification (OFLC - New Zealand) rating. + #[serde(rename="oflcRating")] + + pub oflc_rating: Option, + /// The video's rating in Peru. + #[serde(rename="pefilmRating")] + + pub pefilm_rating: Option, + /// The video's rating from the Hungarian Nemzeti Filmiroda, the Rating Committee of the National Office of Film. + #[serde(rename="rcnofRating")] + + pub rcnof_rating: Option, + /// The video's rating in Venezuela. + #[serde(rename="resorteviolenciaRating")] + + pub resorteviolencia_rating: Option, + /// The video's General Directorate of Radio, Television and Cinematography (Mexico) rating. + #[serde(rename="rtcRating")] + + pub rtc_rating: Option, + /// The video's rating from Ireland's Raidió Teilifís Éireann. + #[serde(rename="rteRating")] + + pub rte_rating: Option, + /// The video's National Film Registry of the Russian Federation (MKRF - Russia) rating. + #[serde(rename="russiaRating")] + + pub russia_rating: Option, + /// The video's rating in Slovakia. + #[serde(rename="skfilmRating")] + + pub skfilm_rating: Option, + /// The video's rating in Iceland. + #[serde(rename="smaisRating")] + + pub smais_rating: Option, + /// The video's rating from Statens medieråd (Sweden's National Media Council). + #[serde(rename="smsaRating")] + + pub smsa_rating: Option, + /// The video's TV Parental Guidelines (TVPG) rating. + #[serde(rename="tvpgRating")] + + pub tvpg_rating: Option, + /// A rating that YouTube uses to identify age-restricted content. + #[serde(rename="ytRating")] + + pub yt_rating: Option, +} + +impl client::Part for ContentRating {} + + +/// Note that there may be a 5-second end-point resolution issue. For instance, if a cuepoint comes in for 22:03:27, we may stuff the cuepoint into 22:03:25 or 22:03:30, depending. This is an artifact of HLS. +/// +/// # Activities +/// +/// This type is used in activities, which are methods you may call on this type or where 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 cuepoint live broadcasts](LiveBroadcastInsertCuepointCall) (request|response) +#[serde_with::serde_as(crate = "::client::serde_with")] +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct Cuepoint { + /// no description provided + #[serde(rename="cueType")] + + pub cue_type: Option, + /// The duration of this cuepoint. + #[serde(rename="durationSecs")] + + pub duration_secs: Option, + /// no description provided + + pub etag: Option, + /// The identifier for cuepoint resource. + + pub id: Option, + /// The time when the cuepoint should be inserted by offset to the broadcast actual start time. + #[serde(rename="insertionOffsetTimeMs")] + + #[serde_as(as = "Option<::client::serde_with::DisplayFromStr>")] + pub insertion_offset_time_ms: Option, + /// The wall clock time at which the cuepoint should be inserted. Only one of insertion_offset_time_ms and walltime_ms may be set at a time. + #[serde(rename="walltimeMs")] + + #[serde_as(as = "Option<::client::serde_with::DisplayFromStr>")] + pub walltime_ms: Option, +} + +impl client::RequestValue for Cuepoint {} +impl client::ResponseResult for Cuepoint {} + +impl client::ToParts for Cuepoint { + /// Return a comma separated list of members that are currently set, i.e. for which `self.member.is_some()`. + /// The produced string is suitable for use as a parts list that indicates the parts you are sending, and/or + /// the parts you want to see in the server response. + fn to_parts(&self) -> String { + let mut r = String::new(); + if self.cue_type.is_some() { r = r + "cueType,"; } + if self.duration_secs.is_some() { r = r + "durationSecs,"; } + if self.etag.is_some() { r = r + "etag,"; } + if self.id.is_some() { r = r + "id,"; } + if self.insertion_offset_time_ms.is_some() { r = r + "insertionOffsetTimeMs,"; } + if self.walltime_ms.is_some() { r = r + "walltimeMs,"; } + r.pop(); + r + } +} + +/// Schedule to insert cuepoints into a broadcast by ads automator. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[serde_with::serde_as(crate = "::client::serde_with")] +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct CuepointSchedule { + /// This field is semantically required. If it is set false or not set, other fields in this message will be ignored. + + pub enabled: Option, + /// If set, automatic cuepoint insertion is paused until this timestamp ("No Ad Zone"). The value is specified in ISO 8601 format. + #[serde(rename="pauseAdsUntil")] + + pub pause_ads_until: Option, + /// Interval frequency in seconds that api uses to insert cuepoints automatically. + #[serde(rename="repeatIntervalSecs")] + + pub repeat_interval_secs: Option, + /// The strategy to use when scheduling cuepoints. + #[serde(rename="scheduleStrategy")] + + pub schedule_strategy: Option, +} + +impl client::Part for CuepointSchedule {} + + +/// There is no detailed description. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[serde_with::serde_as(crate = "::client::serde_with")] +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct Entity { + /// no description provided + + pub id: Option, + /// no description provided + #[serde(rename="typeId")] + + pub type_id: Option, + /// no description provided + + pub url: Option, +} + +impl client::Part for Entity {} + + +/// Geographical coordinates of a point, in WGS84. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[serde_with::serde_as(crate = "::client::serde_with")] +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct GeoPoint { + /// Altitude above the reference ellipsoid, in meters. + + pub altitude: Option, + /// Latitude in degrees. + + pub latitude: Option, + /// Longitude in degrees. + + pub longitude: Option, +} + +impl client::Part for GeoPoint {} + + +/// An *i18nLanguage* resource identifies a UI language currently supported by YouTube. +/// +/// # Activities +/// +/// This type is used in activities, which are methods you may call on this type or where 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 i18n languages](I18nLanguageListCall) (none) +#[serde_with::serde_as(crate = "::client::serde_with")] +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct I18nLanguage { + /// Etag of this resource. + + pub etag: Option, + /// The ID that YouTube uses to uniquely identify the i18n language. + + pub id: Option, + /// Identifies what kind of resource this is. Value: the fixed string "youtube#i18nLanguage". + + pub kind: Option, + /// The snippet object contains basic details about the i18n language, such as language code and human-readable name. + + pub snippet: Option, +} + +impl client::Resource for I18nLanguage {} + +impl client::ToParts for I18nLanguage { + /// Return a comma separated list of members that are currently set, i.e. for which `self.member.is_some()`. + /// The produced string is suitable for use as a parts list that indicates the parts you are sending, and/or + /// the parts you want to see in the server response. + fn to_parts(&self) -> String { + let mut r = String::new(); + if self.etag.is_some() { r = r + "etag,"; } + if self.id.is_some() { r = r + "id,"; } + if self.kind.is_some() { r = r + "kind,"; } + if self.snippet.is_some() { r = r + "snippet,"; } + r.pop(); + r + } +} + +/// 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 i18n languages](I18nLanguageListCall) (response) +#[serde_with::serde_as(crate = "::client::serde_with")] +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct I18nLanguageListResponse { + /// Etag of this resource. + + pub etag: Option, + /// Serialized EventId of the request which produced this response. + #[serde(rename="eventId")] + + pub event_id: Option, + /// A list of supported i18n languages. In this map, the i18n language ID is the map key, and its value is the corresponding i18nLanguage resource. + + pub items: Option>, + /// Identifies what kind of resource this is. Value: the fixed string "youtube#i18nLanguageListResponse". + + pub kind: Option, + /// The visitorId identifies the visitor. + #[serde(rename="visitorId")] + + pub visitor_id: Option, +} + +impl client::ResponseResult for I18nLanguageListResponse {} + +impl client::ToParts for I18nLanguageListResponse { + /// Return a comma separated list of members that are currently set, i.e. for which `self.member.is_some()`. + /// The produced string is suitable for use as a parts list that indicates the parts you are sending, and/or + /// the parts you want to see in the server response. + fn to_parts(&self) -> String { + let mut r = String::new(); + if self.etag.is_some() { r = r + "etag,"; } + if self.event_id.is_some() { r = r + "eventId,"; } + if self.items.is_some() { r = r + "items,"; } + if self.kind.is_some() { r = r + "kind,"; } + if self.visitor_id.is_some() { r = r + "visitorId,"; } + r.pop(); + r + } +} + +/// Basic details about an i18n language, such as language code and human-readable name. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[serde_with::serde_as(crate = "::client::serde_with")] +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct I18nLanguageSnippet { + /// A short BCP-47 code that uniquely identifies a language. + + pub hl: Option, + /// The human-readable name of the language in the language itself. + + pub name: Option, +} + +impl client::Part for I18nLanguageSnippet {} + + +/// A *i18nRegion* resource identifies a region where YouTube is 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*). +/// +/// * [list i18n regions](I18nRegionListCall) (none) +#[serde_with::serde_as(crate = "::client::serde_with")] +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct I18nRegion { + /// Etag of this resource. + + pub etag: Option, + /// The ID that YouTube uses to uniquely identify the i18n region. + + pub id: Option, + /// Identifies what kind of resource this is. Value: the fixed string "youtube#i18nRegion". + + pub kind: Option, + /// The snippet object contains basic details about the i18n region, such as region code and human-readable name. + + pub snippet: Option, +} + +impl client::Resource for I18nRegion {} + +impl client::ToParts for I18nRegion { + /// Return a comma separated list of members that are currently set, i.e. for which `self.member.is_some()`. + /// The produced string is suitable for use as a parts list that indicates the parts you are sending, and/or + /// the parts you want to see in the server response. + fn to_parts(&self) -> String { + let mut r = String::new(); + if self.etag.is_some() { r = r + "etag,"; } + if self.id.is_some() { r = r + "id,"; } + if self.kind.is_some() { r = r + "kind,"; } + if self.snippet.is_some() { r = r + "snippet,"; } + r.pop(); + r + } +} + +/// 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 i18n regions](I18nRegionListCall) (response) +#[serde_with::serde_as(crate = "::client::serde_with")] +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct I18nRegionListResponse { + /// Etag of this resource. + + pub etag: Option, + /// Serialized EventId of the request which produced this response. + #[serde(rename="eventId")] + + pub event_id: Option, + /// A list of regions where YouTube is available. In this map, the i18n region ID is the map key, and its value is the corresponding i18nRegion resource. + + pub items: Option>, + /// Identifies what kind of resource this is. Value: the fixed string "youtube#i18nRegionListResponse". + + pub kind: Option, + /// The visitorId identifies the visitor. + #[serde(rename="visitorId")] + + pub visitor_id: Option, +} + +impl client::ResponseResult for I18nRegionListResponse {} + +impl client::ToParts for I18nRegionListResponse { + /// Return a comma separated list of members that are currently set, i.e. for which `self.member.is_some()`. + /// The produced string is suitable for use as a parts list that indicates the parts you are sending, and/or + /// the parts you want to see in the server response. + fn to_parts(&self) -> String { + let mut r = String::new(); + if self.etag.is_some() { r = r + "etag,"; } + if self.event_id.is_some() { r = r + "eventId,"; } + if self.items.is_some() { r = r + "items,"; } + if self.kind.is_some() { r = r + "kind,"; } + if self.visitor_id.is_some() { r = r + "visitorId,"; } + r.pop(); + r + } +} + +/// Basic details about an i18n region, such as region code and human-readable name. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[serde_with::serde_as(crate = "::client::serde_with")] +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct I18nRegionSnippet { + /// The region code as a 2-letter ISO country code. + + pub gl: Option, + /// The human-readable name of the region. + + pub name: Option, +} + +impl client::Part for I18nRegionSnippet {} + + +/// Branding properties for images associated with the channel. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[serde_with::serde_as(crate = "::client::serde_with")] +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct ImageSettings { + /// The URL for the background image shown on the video watch page. The image should be 1200px by 615px, with a maximum file size of 128k. + #[serde(rename="backgroundImageUrl")] + + pub background_image_url: Option, + /// This is generated when a ChannelBanner.Insert request has succeeded for the given channel. + #[serde(rename="bannerExternalUrl")] + + pub banner_external_url: Option, + /// Banner image. Desktop size (1060x175). + #[serde(rename="bannerImageUrl")] + + pub banner_image_url: Option, + /// Banner image. Mobile size high resolution (1440x395). + #[serde(rename="bannerMobileExtraHdImageUrl")] + + pub banner_mobile_extra_hd_image_url: Option, + /// Banner image. Mobile size high resolution (1280x360). + #[serde(rename="bannerMobileHdImageUrl")] + + pub banner_mobile_hd_image_url: Option, + /// Banner image. Mobile size (640x175). + #[serde(rename="bannerMobileImageUrl")] + + pub banner_mobile_image_url: Option, + /// Banner image. Mobile size low resolution (320x88). + #[serde(rename="bannerMobileLowImageUrl")] + + pub banner_mobile_low_image_url: Option, + /// Banner image. Mobile size medium/high resolution (960x263). + #[serde(rename="bannerMobileMediumHdImageUrl")] + + pub banner_mobile_medium_hd_image_url: Option, + /// Banner image. Tablet size extra high resolution (2560x424). + #[serde(rename="bannerTabletExtraHdImageUrl")] + + pub banner_tablet_extra_hd_image_url: Option, + /// Banner image. Tablet size high resolution (2276x377). + #[serde(rename="bannerTabletHdImageUrl")] + + pub banner_tablet_hd_image_url: Option, + /// Banner image. Tablet size (1707x283). + #[serde(rename="bannerTabletImageUrl")] + + pub banner_tablet_image_url: Option, + /// Banner image. Tablet size low resolution (1138x188). + #[serde(rename="bannerTabletLowImageUrl")] + + pub banner_tablet_low_image_url: Option, + /// Banner image. TV size high resolution (1920x1080). + #[serde(rename="bannerTvHighImageUrl")] + + pub banner_tv_high_image_url: Option, + /// Banner image. TV size extra high resolution (2120x1192). + #[serde(rename="bannerTvImageUrl")] + + pub banner_tv_image_url: Option, + /// Banner image. TV size low resolution (854x480). + #[serde(rename="bannerTvLowImageUrl")] + + pub banner_tv_low_image_url: Option, + /// Banner image. TV size medium resolution (1280x720). + #[serde(rename="bannerTvMediumImageUrl")] + + pub banner_tv_medium_image_url: Option, + /// The image map script for the large banner image. + #[serde(rename="largeBrandedBannerImageImapScript")] + + pub large_branded_banner_image_imap_script: Option, + /// The URL for the 854px by 70px image that appears below the video player in the expanded video view of the video watch page. + #[serde(rename="largeBrandedBannerImageUrl")] + + pub large_branded_banner_image_url: Option, + /// The image map script for the small banner image. + #[serde(rename="smallBrandedBannerImageImapScript")] + + pub small_branded_banner_image_imap_script: Option, + /// The URL for the 640px by 70px banner image that appears below the video player in the default view of the video watch page. The URL for the image that appears above the top-left corner of the video player. This is a 25-pixel-high image with a flexible width that cannot exceed 170 pixels. + #[serde(rename="smallBrandedBannerImageUrl")] + + pub small_branded_banner_image_url: Option, + /// The URL for a 1px by 1px tracking pixel that can be used to collect statistics for views of the channel or video pages. + #[serde(rename="trackingImageUrl")] + + pub tracking_image_url: Option, + /// no description provided + #[serde(rename="watchIconImageUrl")] + + pub watch_icon_image_url: Option, +} + +impl client::Part for ImageSettings {} + + +/// Describes information necessary for ingesting an RTMP, HTTP, or SRT stream. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[serde_with::serde_as(crate = "::client::serde_with")] +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct IngestionInfo { + /// The backup ingestion URL that you should use to stream video to YouTube. You have the option of simultaneously streaming the content that you are sending to the ingestionAddress to this URL. + #[serde(rename="backupIngestionAddress")] + + pub backup_ingestion_address: Option, + /// The primary ingestion URL that you should use to stream video to YouTube. You must stream video to this URL. Depending on which application or tool you use to encode your video stream, you may need to enter the stream URL and stream name separately or you may need to concatenate them in the following format: *STREAM_URL/STREAM_NAME* + #[serde(rename="ingestionAddress")] + + pub ingestion_address: Option, + /// This ingestion url may be used instead of backupIngestionAddress in order to stream via RTMPS. Not applicable to non-RTMP streams. + #[serde(rename="rtmpsBackupIngestionAddress")] + + pub rtmps_backup_ingestion_address: Option, + /// This ingestion url may be used instead of ingestionAddress in order to stream via RTMPS. Not applicable to non-RTMP streams. + #[serde(rename="rtmpsIngestionAddress")] + + pub rtmps_ingestion_address: Option, + /// The stream name that YouTube assigns to the video stream. + #[serde(rename="streamName")] + + pub stream_name: Option, +} + +impl client::Part for IngestionInfo {} + + +/// LINT.IfChange Describes an invideo branding. +/// +/// # Activities +/// +/// This type is used in activities, which are methods you may call on this type or where 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 watermarks](WatermarkSetCall) (request) +#[serde_with::serde_as(crate = "::client::serde_with")] +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct InvideoBranding { + /// The bytes the uploaded image. Only used in api to youtube communication. + #[serde(rename="imageBytes")] + + #[serde_as(as = "Option<::client::serde::standard_base64::Wrapper>")] + pub image_bytes: Option>, + /// The url of the uploaded image. Only used in apiary to api communication. + #[serde(rename="imageUrl")] + + pub image_url: Option, + /// The spatial position within the video where the branding watermark will be displayed. + + pub position: Option, + /// The channel to which this branding links. If not present it defaults to the current channel. + #[serde(rename="targetChannelId")] + + pub target_channel_id: Option, + /// The temporal position within the video where watermark will be displayed. + + pub timing: Option, +} + +impl client::RequestValue for InvideoBranding {} + + +/// Describes the spatial position of a visual widget inside a video. It is a union of various position types, out of which only will be set one. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[serde_with::serde_as(crate = "::client::serde_with")] +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct InvideoPosition { + /// Describes in which corner of the video the visual widget will appear. + #[serde(rename="cornerPosition")] + + pub corner_position: Option, + /// Defines the position type. + #[serde(rename="type")] + + pub type_: Option, +} + +impl client::Part for InvideoPosition {} + + +/// Describes a temporal position of a visual widget inside a video. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[serde_with::serde_as(crate = "::client::serde_with")] +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct InvideoTiming { + /// Defines the duration in milliseconds for which the promotion should be displayed. If missing, the client should use the default. + #[serde(rename="durationMs")] + + #[serde_as(as = "Option<::client::serde_with::DisplayFromStr>")] + pub duration_ms: Option, + /// Defines the time at which the promotion will appear. Depending on the value of type the value of the offsetMs field will represent a time offset from the start or from the end of the video, expressed in milliseconds. + #[serde(rename="offsetMs")] + + #[serde_as(as = "Option<::client::serde_with::DisplayFromStr>")] + pub offset_ms: Option, + /// Describes a timing type. If the value is offsetFromStart, then the offsetMs field represents an offset from the start of the video. If the value is offsetFromEnd, then the offsetMs field represents an offset from the end of the video. + #[serde(rename="type")] + + pub type_: Option, +} + +impl client::Part for InvideoTiming {} + + +/// There is no detailed description. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[serde_with::serde_as(crate = "::client::serde_with")] +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct LanguageTag { + /// no description provided + + pub value: Option, +} + +impl client::Part for LanguageTag {} + + +/// There is no detailed description. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[serde_with::serde_as(crate = "::client::serde_with")] +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct LevelDetails { + /// The name that should be used when referring to this level. + #[serde(rename="displayName")] + + pub display_name: Option, +} + +impl client::Part for LevelDetails {} + + +/// A *liveBroadcast* resource represents an event that will be streamed, via live video, on YouTube. +/// +/// # Activities +/// +/// This type is used in activities, which are methods you may call on this type or where this type is involved in. +/// The list links the activity name, along with information about where it is used (one of *request* and *response*). +/// +/// * [bind live broadcasts](LiveBroadcastBindCall) (response) +/// * [delete live broadcasts](LiveBroadcastDeleteCall) (none) +/// * [insert live broadcasts](LiveBroadcastInsertCall) (request|response) +/// * [insert cuepoint live broadcasts](LiveBroadcastInsertCuepointCall) (none) +/// * [list live broadcasts](LiveBroadcastListCall) (none) +/// * [transition live broadcasts](LiveBroadcastTransitionCall) (response) +/// * [update live broadcasts](LiveBroadcastUpdateCall) (request|response) +#[serde_with::serde_as(crate = "::client::serde_with")] +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct LiveBroadcast { + /// The contentDetails object contains information about the event's video content, such as whether the content can be shown in an embedded video player or if it will be archived and therefore available for viewing after the event has concluded. + #[serde(rename="contentDetails")] + + pub content_details: Option, + /// Etag of this resource. + + pub etag: Option, + /// The ID that YouTube assigns to uniquely identify the broadcast. + + pub id: Option, + /// Identifies what kind of resource this is. Value: the fixed string "youtube#liveBroadcast". + + pub kind: Option, + /// The monetizationDetails object contains information about the event's monetization details. + #[serde(rename="monetizationDetails")] + + pub monetization_details: Option, + /// The snippet object contains basic details about the event, including its title, description, start time, and end time. + + pub snippet: Option, + /// The statistics object contains info about the event's current stats. These include concurrent viewers and total chat count. Statistics can change (in either direction) during the lifetime of an event. Statistics are only returned while the event is live. + + pub statistics: Option, + /// The status object contains information about the event's status. + + pub status: Option, +} + +impl client::RequestValue for LiveBroadcast {} +impl client::Resource for LiveBroadcast {} +impl client::ResponseResult for LiveBroadcast {} + +impl client::ToParts for LiveBroadcast { + /// Return a comma separated list of members that are currently set, i.e. for which `self.member.is_some()`. + /// The produced string is suitable for use as a parts list that indicates the parts you are sending, and/or + /// the parts you want to see in the server response. + fn to_parts(&self) -> String { + let mut r = String::new(); + if self.content_details.is_some() { r = r + "contentDetails,"; } + if self.etag.is_some() { r = r + "etag,"; } + if self.id.is_some() { r = r + "id,"; } + if self.kind.is_some() { r = r + "kind,"; } + if self.monetization_details.is_some() { r = r + "monetizationDetails,"; } + if self.snippet.is_some() { r = r + "snippet,"; } + if self.statistics.is_some() { r = r + "statistics,"; } + if self.status.is_some() { r = r + "status,"; } + r.pop(); + r + } +} + +/// Detailed settings of a broadcast. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[serde_with::serde_as(crate = "::client::serde_with")] +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct LiveBroadcastContentDetails { + /// This value uniquely identifies the live stream bound to the broadcast. + #[serde(rename="boundStreamId")] + + pub bound_stream_id: 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>, + /// no description provided + #[serde(rename="closedCaptionsType")] + + pub closed_captions_type: Option, + /// This setting indicates whether auto start is enabled for this broadcast. The default value for this property is false. This setting can only be used by Events. + #[serde(rename="enableAutoStart")] + + pub enable_auto_start: Option, + /// This setting indicates whether auto stop is enabled for this broadcast. The default value for this property is false. This setting can only be used by Events. + #[serde(rename="enableAutoStop")] + + pub enable_auto_stop: Option, + /// 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, + /// This setting indicates whether YouTube should enable content encryption for the broadcast. + #[serde(rename="enableContentEncryption")] + + pub enable_content_encryption: Option, + /// This setting determines whether viewers can access DVR controls while watching the video. DVR controls enable the viewer to control the video playback experience by pausing, rewinding, or fast forwarding content. The default value for this property is true. *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 video can be played in an embedded player. If you choose to archive the video (using the enableArchive property), this setting will also apply to the archived video. + #[serde(rename="enableEmbed")] + + pub enable_embed: Option, + /// Indicates whether this broadcast has low latency enabled. + #[serde(rename="enableLowLatency")] + + pub enable_low_latency: Option, + /// If both this and enable_low_latency are set, they must match. LATENCY_NORMAL should match enable_low_latency=false LATENCY_LOW should match enable_low_latency=true LATENCY_ULTRA_LOW should have enable_low_latency omitted. + #[serde(rename="latencyPreference")] + + pub latency_preference: Option, + /// The mesh for projecting the video if projection is mesh. The mesh value must be a UTF-8 string containing the base-64 encoding of 3D mesh data that follows the Spherical Video V2 RFC specification for an mshp box, excluding the box size and type but including the following four reserved zero bytes for the version and flags. + + #[serde_as(as = "Option<::client::serde::standard_base64::Wrapper>")] + pub mesh: 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 projection format of this broadcast. This defaults to rectangular. + + pub projection: Option, + /// Automatically start recording after the event goes live. The default value for this property is true. *Important:* You must also set the enableDvr property's value to true if you want the playback to be available immediately after the broadcast ends. If you set this property's value to true but do not also set the enableDvr property to true, there may be a delay of around one day before the archived video will be available for playback. + #[serde(rename="recordFromStart")] + + pub record_from_start: 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 3D stereo layout of this broadcast. This defaults to mono. + #[serde(rename="stereoLayout")] + + pub stereo_layout: Option, +} + +impl client::Part for LiveBroadcastContentDetails {} + + +/// 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 live broadcasts](LiveBroadcastListCall) (response) +#[serde_with::serde_as(crate = "::client::serde_with")] +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct LiveBroadcastListResponse { + /// Etag of this resource. + + pub etag: Option, + /// Serialized EventId of the request which produced this response. + #[serde(rename="eventId")] + + pub event_id: Option, + /// A list of broadcasts that match the request criteria. + + pub items: Option>, + /// Identifies what kind of resource this is. Value: the fixed string "youtube#liveBroadcastListResponse". + + pub kind: Option, + /// The token that can be used as the value of the pageToken parameter to retrieve the next page in the result set. + #[serde(rename="nextPageToken")] + + pub next_page_token: Option, + /// General pagination information. + #[serde(rename="pageInfo")] + + pub page_info: Option, + /// The token that can be used as the value of the pageToken parameter to retrieve the previous page in the result set. + #[serde(rename="prevPageToken")] + + pub prev_page_token: Option, + /// no description provided + #[serde(rename="tokenPagination")] + + pub token_pagination: Option, + /// The visitorId identifies the visitor. + #[serde(rename="visitorId")] + + pub visitor_id: Option, +} + +impl client::ResponseResult for LiveBroadcastListResponse {} + +impl client::ToParts for LiveBroadcastListResponse { + /// Return a comma separated list of members that are currently set, i.e. for which `self.member.is_some()`. + /// The produced string is suitable for use as a parts list that indicates the parts you are sending, and/or + /// the parts you want to see in the server response. + fn to_parts(&self) -> String { + let mut r = String::new(); + if self.etag.is_some() { r = r + "etag,"; } + if self.event_id.is_some() { r = r + "eventId,"; } + if self.items.is_some() { r = r + "items,"; } + if self.kind.is_some() { r = r + "kind,"; } + if self.next_page_token.is_some() { r = r + "nextPageToken,"; } + if self.page_info.is_some() { r = r + "pageInfo,"; } + if self.prev_page_token.is_some() { r = r + "prevPageToken,"; } + if self.token_pagination.is_some() { r = r + "tokenPagination,"; } + if self.visitor_id.is_some() { r = r + "visitorId,"; } + r.pop(); + r + } +} + +/// Monetization settings of a broadcast. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[serde_with::serde_as(crate = "::client::serde_with")] +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct LiveBroadcastMonetizationDetails { + /// no description provided + #[serde(rename="cuepointSchedule")] + + pub cuepoint_schedule: Option, +} + +impl client::Part for LiveBroadcastMonetizationDetails {} + + +/// Basic broadcast information. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[serde_with::serde_as(crate = "::client::serde_with")] +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct LiveBroadcastSnippet { + /// The date and time that the broadcast actually ended. This information is only available once the broadcast's state is complete. + #[serde(rename="actualEndTime")] + + pub actual_end_time: Option>, + /// The date and time that the broadcast actually started. This information is only available once the broadcast's state is live. + #[serde(rename="actualStartTime")] + + pub actual_start_time: Option>, + /// The ID that YouTube uses to uniquely identify the channel that is publishing the broadcast. + #[serde(rename="channelId")] + + pub channel_id: Option, + /// The broadcast's description. As with the title, you can set this field by modifying the broadcast resource or by setting the description field of the corresponding video resource. + + pub description: Option, + /// Indicates whether this broadcast is the default broadcast. Internal only. + #[serde(rename="isDefaultBroadcast")] + + pub is_default_broadcast: Option, + /// The id of the live chat for this broadcast. + #[serde(rename="liveChatId")] + + pub live_chat_id: Option, + /// The date and time that the broadcast was added to YouTube's live broadcast schedule. + #[serde(rename="publishedAt")] + + pub published_at: Option>, + /// The date and time that the broadcast is scheduled to end. + #[serde(rename="scheduledEndTime")] + + pub scheduled_end_time: Option>, + /// The date and time that the broadcast is scheduled to start. + #[serde(rename="scheduledStartTime")] + + pub scheduled_start_time: Option>, + /// A map of thumbnail images associated with the broadcast. For each nested object in this object, the key is the name of the thumbnail image, and the value is an object that contains other information about the thumbnail. + + pub thumbnails: Option, + /// The broadcast's title. Note that the broadcast represents exactly one YouTube video. You can set this field by modifying the broadcast resource or by setting the title field of the corresponding video resource. + + pub title: Option, +} + +impl client::Part for LiveBroadcastSnippet {} + + +/// Statistics about the live broadcast. These represent a snapshot of the values at the time of the request. Statistics are only returned for live broadcasts. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[serde_with::serde_as(crate = "::client::serde_with")] +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct LiveBroadcastStatistics { + /// The number of viewers currently watching the broadcast. The property and its value will be present if the broadcast has current viewers and the broadcast owner has not hidden the viewcount for the video. Note that YouTube stops tracking the number of concurrent viewers for a broadcast when the broadcast ends. So, this property would not identify the number of viewers watching an archived video of a live broadcast that already ended. + #[serde(rename="concurrentViewers")] + + #[serde_as(as = "Option<::client::serde_with::DisplayFromStr>")] + pub concurrent_viewers: Option, +} + +impl client::Part for LiveBroadcastStatistics {} + + +/// Live broadcast state. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[serde_with::serde_as(crate = "::client::serde_with")] +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct LiveBroadcastStatus { + /// The broadcast's status. The status can be updated using the API's liveBroadcasts.transition method. + #[serde(rename="lifeCycleStatus")] + + pub life_cycle_status: Option, + /// Priority of the live broadcast event (internal state). + #[serde(rename="liveBroadcastPriority")] + + pub live_broadcast_priority: Option, + /// Whether the broadcast is made for kids or not, decided by YouTube instead of the creator. This field is read only. + #[serde(rename="madeForKids")] + + pub made_for_kids: Option, + /// The broadcast's privacy status. Note that the broadcast represents exactly one YouTube video, so the privacy settings are identical to those supported for videos. In addition, you can set this field by modifying the broadcast resource or by setting the privacyStatus field of the corresponding video resource. + #[serde(rename="privacyStatus")] + + pub privacy_status: Option, + /// The broadcast's recording status. + #[serde(rename="recordingStatus")] + + pub recording_status: Option, + /// This field will be set to True if the creator declares the broadcast to be kids only: go/live-cw-work. + #[serde(rename="selfDeclaredMadeForKids")] + + pub self_declared_made_for_kids: Option, +} + +impl client::Part for LiveBroadcastStatus {} + + +/// A `__liveChatBan__` resource represents a ban for a YouTube live chat. +/// +/// # Activities +/// +/// This type is used in activities, which are methods you may call on this type or where 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 live chat bans](LiveChatBanDeleteCall) (none) +/// * [insert live chat bans](LiveChatBanInsertCall) (request|response) +#[serde_with::serde_as(crate = "::client::serde_with")] +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct LiveChatBan { + /// Etag of this resource. + + pub etag: Option, + /// The ID that YouTube assigns to uniquely identify the ban. + + pub id: Option, + /// Identifies what kind of resource this is. Value: the fixed string `"youtube#liveChatBan"`. + + pub kind: Option, + /// The `snippet` object contains basic details about the ban. + + pub snippet: Option, +} + +impl client::RequestValue for LiveChatBan {} +impl client::Resource for LiveChatBan {} +impl client::ResponseResult for LiveChatBan {} + +impl client::ToParts for LiveChatBan { + /// Return a comma separated list of members that are currently set, i.e. for which `self.member.is_some()`. + /// The produced string is suitable for use as a parts list that indicates the parts you are sending, and/or + /// the parts you want to see in the server response. + fn to_parts(&self) -> String { + let mut r = String::new(); + if self.etag.is_some() { r = r + "etag,"; } + if self.id.is_some() { r = r + "id,"; } + if self.kind.is_some() { r = r + "kind,"; } + if self.snippet.is_some() { r = r + "snippet,"; } + r.pop(); + r + } +} + +/// There is no detailed description. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[serde_with::serde_as(crate = "::client::serde_with")] +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct LiveChatBanSnippet { + /// The duration of a ban, only filled if the ban has type TEMPORARY. + #[serde(rename="banDurationSeconds")] + + #[serde_as(as = "Option<::client::serde_with::DisplayFromStr>")] + pub ban_duration_seconds: Option, + /// no description provided + #[serde(rename="bannedUserDetails")] + + pub banned_user_details: Option, + /// The chat this ban is pertinent to. + #[serde(rename="liveChatId")] + + pub live_chat_id: Option, + /// The type of ban. + #[serde(rename="type")] + + pub type_: Option, +} + +impl client::Part for LiveChatBanSnippet {} + + +/// There is no detailed description. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[serde_with::serde_as(crate = "::client::serde_with")] +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct LiveChatFanFundingEventDetails { + /// A rendered string that displays the fund amount and currency to the user. + #[serde(rename="amountDisplayString")] + + pub amount_display_string: Option, + /// The amount of the fund. + #[serde(rename="amountMicros")] + + #[serde_as(as = "Option<::client::serde_with::DisplayFromStr>")] + pub amount_micros: Option, + /// The currency in which the fund was made. + + pub currency: Option, + /// The comment added by the user to this fan funding event. + #[serde(rename="userComment")] + + pub user_comment: Option, +} + +impl client::Part for LiveChatFanFundingEventDetails {} + + +/// There is no detailed description. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[serde_with::serde_as(crate = "::client::serde_with")] +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct LiveChatGiftMembershipReceivedDetails { + /// The ID of the membership gifting message that is related to this gift membership. This ID will always refer to a message whose type is 'membershipGiftingEvent'. + #[serde(rename="associatedMembershipGiftingMessageId")] + + pub associated_membership_gifting_message_id: Option, + /// The ID of the user that made the membership gifting purchase. This matches the `snippet.authorChannelId` of the associated membership gifting message. + #[serde(rename="gifterChannelId")] + + pub gifter_channel_id: Option, + /// The name of the Level at which the viewer is a member. This matches the `snippet.membershipGiftingDetails.giftMembershipsLevelName` of the associated membership gifting message. The Level names are defined by the YouTube channel offering the Membership. In some situations this field isn't filled. + #[serde(rename="memberLevelName")] + + pub member_level_name: Option, +} + +impl client::Part for LiveChatGiftMembershipReceivedDetails {} + + +/// There is no detailed description. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[serde_with::serde_as(crate = "::client::serde_with")] +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct LiveChatMemberMilestoneChatDetails { + /// The name of the Level at which the viever is a member. The Level names are defined by the YouTube channel offering the Membership. In some situations this field isn't filled. + #[serde(rename="memberLevelName")] + + pub member_level_name: Option, + /// The total amount of months (rounded up) the viewer has been a member that granted them this Member Milestone Chat. This is the same number of months as is being displayed to YouTube users. + #[serde(rename="memberMonth")] + + pub member_month: Option, + /// The comment added by the member to this Member Milestone Chat. This field is empty for messages without a comment from the member. + #[serde(rename="userComment")] + + pub user_comment: Option, +} + +impl client::Part for LiveChatMemberMilestoneChatDetails {} + + +/// There is no detailed description. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[serde_with::serde_as(crate = "::client::serde_with")] +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct LiveChatMembershipGiftingDetails { + /// The number of gift memberships purchased by the user. + #[serde(rename="giftMembershipsCount")] + + pub gift_memberships_count: Option, + /// The name of the level of the gift memberships purchased by the user. The Level names are defined by the YouTube channel offering the Membership. In some situations this field isn't filled. + #[serde(rename="giftMembershipsLevelName")] + + pub gift_memberships_level_name: Option, +} + +impl client::Part for LiveChatMembershipGiftingDetails {} + + +/// A *liveChatMessage* resource represents a chat message in a YouTube Live Chat. +/// +/// # Activities +/// +/// This type is used in activities, which are methods you may call on this type or where 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 live chat messages](LiveChatMessageDeleteCall) (none) +/// * [insert live chat messages](LiveChatMessageInsertCall) (request|response) +/// * [list live chat messages](LiveChatMessageListCall) (none) +#[serde_with::serde_as(crate = "::client::serde_with")] +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct LiveChatMessage { + /// The authorDetails object contains basic details about the user that posted this message. + #[serde(rename="authorDetails")] + + pub author_details: Option, + /// Etag of this resource. + + pub etag: Option, + /// The ID that YouTube assigns to uniquely identify the message. + + pub id: Option, + /// Identifies what kind of resource this is. Value: the fixed string "youtube#liveChatMessage". + + pub kind: Option, + /// The snippet object contains basic details about the message. + + pub snippet: Option, +} + +impl client::RequestValue for LiveChatMessage {} +impl client::Resource for LiveChatMessage {} +impl client::ResponseResult for LiveChatMessage {} + +impl client::ToParts for LiveChatMessage { + /// Return a comma separated list of members that are currently set, i.e. for which `self.member.is_some()`. + /// The produced string is suitable for use as a parts list that indicates the parts you are sending, and/or + /// the parts you want to see in the server response. + fn to_parts(&self) -> String { + let mut r = String::new(); + if self.author_details.is_some() { r = r + "authorDetails,"; } + if self.etag.is_some() { r = r + "etag,"; } + if self.id.is_some() { r = r + "id,"; } + if self.kind.is_some() { r = r + "kind,"; } + if self.snippet.is_some() { r = r + "snippet,"; } + r.pop(); + r + } +} + +/// There is no detailed description. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[serde_with::serde_as(crate = "::client::serde_with")] +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct LiveChatMessageAuthorDetails { + /// The YouTube channel ID. + #[serde(rename="channelId")] + + pub channel_id: Option, + /// The channel's URL. + #[serde(rename="channelUrl")] + + pub channel_url: Option, + /// The channel's display name. + #[serde(rename="displayName")] + + pub display_name: Option, + /// Whether the author is a moderator of the live chat. + #[serde(rename="isChatModerator")] + + pub is_chat_moderator: Option, + /// Whether the author is the owner of the live chat. + #[serde(rename="isChatOwner")] + + pub is_chat_owner: Option, + /// Whether the author is a sponsor of the live chat. + #[serde(rename="isChatSponsor")] + + pub is_chat_sponsor: Option, + /// Whether the author's identity has been verified by YouTube. + #[serde(rename="isVerified")] + + pub is_verified: Option, + /// The channels's avatar URL. + #[serde(rename="profileImageUrl")] + + pub profile_image_url: Option, +} + +impl client::Part for LiveChatMessageAuthorDetails {} + + +/// There is no detailed description. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[serde_with::serde_as(crate = "::client::serde_with")] +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct LiveChatMessageDeletedDetails { + /// no description provided + #[serde(rename="deletedMessageId")] + + pub deleted_message_id: Option, +} + +impl client::Part for LiveChatMessageDeletedDetails {} + + +/// 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 live chat messages](LiveChatMessageListCall) (response) +#[serde_with::serde_as(crate = "::client::serde_with")] +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct LiveChatMessageListResponse { + /// Set when there is an active poll. + #[serde(rename="activePollItem")] + + pub active_poll_item: Option, + /// Etag of this resource. + + pub etag: Option, + /// Serialized EventId of the request which produced this response. + #[serde(rename="eventId")] + + pub event_id: Option, + /// no description provided + + pub items: Option>, + /// Identifies what kind of resource this is. Value: the fixed string "youtube#liveChatMessageListResponse". + + pub kind: Option, + /// no description provided + #[serde(rename="nextPageToken")] + + pub next_page_token: Option, + /// The date and time when the underlying stream went offline. + #[serde(rename="offlineAt")] + + pub offline_at: Option>, + /// General pagination information. + #[serde(rename="pageInfo")] + + pub page_info: Option, + /// The amount of time the client should wait before polling again. + #[serde(rename="pollingIntervalMillis")] + + pub polling_interval_millis: Option, + /// no description provided + #[serde(rename="tokenPagination")] + + pub token_pagination: Option, + /// The visitorId identifies the visitor. + #[serde(rename="visitorId")] + + pub visitor_id: Option, +} + +impl client::ResponseResult for LiveChatMessageListResponse {} + +impl client::ToParts for LiveChatMessageListResponse { + /// Return a comma separated list of members that are currently set, i.e. for which `self.member.is_some()`. + /// The produced string is suitable for use as a parts list that indicates the parts you are sending, and/or + /// the parts you want to see in the server response. + fn to_parts(&self) -> String { + let mut r = String::new(); + if self.active_poll_item.is_some() { r = r + "activePollItem,"; } + if self.etag.is_some() { r = r + "etag,"; } + if self.event_id.is_some() { r = r + "eventId,"; } + if self.items.is_some() { r = r + "items,"; } + if self.kind.is_some() { r = r + "kind,"; } + if self.next_page_token.is_some() { r = r + "nextPageToken,"; } + if self.offline_at.is_some() { r = r + "offlineAt,"; } + if self.page_info.is_some() { r = r + "pageInfo,"; } + if self.polling_interval_millis.is_some() { r = r + "pollingIntervalMillis,"; } + if self.token_pagination.is_some() { r = r + "tokenPagination,"; } + if self.visitor_id.is_some() { r = r + "visitorId,"; } + r.pop(); + r + } +} + +/// There is no detailed description. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[serde_with::serde_as(crate = "::client::serde_with")] +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct LiveChatMessageRetractedDetails { + /// no description provided + #[serde(rename="retractedMessageId")] + + pub retracted_message_id: Option, +} + +impl client::Part for LiveChatMessageRetractedDetails {} + + +/// Next ID: 34 +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[serde_with::serde_as(crate = "::client::serde_with")] +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct LiveChatMessageSnippet { + /// 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 memberMilestoneChatEvent - the member that sent the message membershipGiftingEvent - the user that made the purchase giftMembershipReceivedEvent - the user that received the gift membership messageDeletedEvent - the moderator that took the action messageRetractedEvent - the author that retracted their message userBannedEvent - the moderator that took the action superChatEvent - the user that made the purchase superStickerEvent - the user that made the purchase pollEvent - the user that created the poll + #[serde(rename="authorChannelId")] + + pub author_channel_id: Option, + /// 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, + /// Details about the funding event, this is only set if the type is 'fanFundingEvent'. + #[serde(rename="fanFundingEventDetails")] + + pub fan_funding_event_details: Option, + /// Details about the Gift Membership Received event, this is only set if the type is 'giftMembershipReceivedEvent'. + #[serde(rename="giftMembershipReceivedDetails")] + + pub gift_membership_received_details: Option, + /// Whether the message has display content that should be displayed to users. + #[serde(rename="hasDisplayContent")] + + pub has_display_content: Option, + /// no description provided + #[serde(rename="liveChatId")] + + pub live_chat_id: Option, + /// Details about the Member Milestone Chat event, this is only set if the type is 'memberMilestoneChatEvent'. + #[serde(rename="memberMilestoneChatDetails")] + + pub member_milestone_chat_details: Option, + /// Details about the Membership Gifting event, this is only set if the type is 'membershipGiftingEvent'. + #[serde(rename="membershipGiftingDetails")] + + pub membership_gifting_details: Option, + /// no description provided + #[serde(rename="messageDeletedDetails")] + + pub message_deleted_details: Option, + /// no description provided + #[serde(rename="messageRetractedDetails")] + + pub message_retracted_details: Option, + /// Details about the New Member Announcement event, this is only set if the type is 'newSponsorEvent'. Please note that "member" is the new term for "sponsor". + #[serde(rename="newSponsorDetails")] + + pub new_sponsor_details: Option, + /// Details about the poll event, this is only set if the type is 'pollEvent'. + #[serde(rename="pollDetails")] + + pub poll_details: Option, + /// The date and time when the message was orignally published. + #[serde(rename="publishedAt")] + + pub published_at: Option>, + /// Details about the Super Chat event, this is only set if the type is 'superChatEvent'. + #[serde(rename="superChatDetails")] + + pub super_chat_details: Option, + /// Details about the Super Sticker event, this is only set if the type is 'superStickerEvent'. + #[serde(rename="superStickerDetails")] + + pub super_sticker_details: Option, + /// Details about the text message, this is only set if the type is 'textMessageEvent'. + #[serde(rename="textMessageDetails")] + + pub text_message_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="userBannedDetails")] + + pub user_banned_details: Option, +} + +impl client::Part for LiveChatMessageSnippet {} + + +/// A *liveChatModerator* resource represents a moderator for a YouTube live chat. A chat moderator has the ability to ban/unban users from a chat, remove message, etc. +/// +/// # Activities +/// +/// This type is used in activities, which are methods you may call on this type or where 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 live chat moderators](LiveChatModeratorDeleteCall) (none) +/// * [insert live chat moderators](LiveChatModeratorInsertCall) (request|response) +/// * [list live chat moderators](LiveChatModeratorListCall) (none) +#[serde_with::serde_as(crate = "::client::serde_with")] +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct LiveChatModerator { + /// Etag of this resource. + + pub etag: Option, + /// The ID that YouTube assigns to uniquely identify the moderator. + + pub id: Option, + /// Identifies what kind of resource this is. Value: the fixed string "youtube#liveChatModerator". + + pub kind: Option, + /// The snippet object contains basic details about the moderator. + + pub snippet: Option, +} + +impl client::RequestValue for LiveChatModerator {} +impl client::Resource for LiveChatModerator {} +impl client::ResponseResult for LiveChatModerator {} + +impl client::ToParts for LiveChatModerator { + /// Return a comma separated list of members that are currently set, i.e. for which `self.member.is_some()`. + /// The produced string is suitable for use as a parts list that indicates the parts you are sending, and/or + /// the parts you want to see in the server response. + fn to_parts(&self) -> String { + let mut r = String::new(); + if self.etag.is_some() { r = r + "etag,"; } + if self.id.is_some() { r = r + "id,"; } + if self.kind.is_some() { r = r + "kind,"; } + if self.snippet.is_some() { r = r + "snippet,"; } + r.pop(); + r + } +} + +/// 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 live chat moderators](LiveChatModeratorListCall) (response) +#[serde_with::serde_as(crate = "::client::serde_with")] +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct LiveChatModeratorListResponse { + /// Etag of this resource. + + pub etag: Option, + /// Serialized EventId of the request which produced this response. + #[serde(rename="eventId")] + + pub event_id: Option, + /// A list of moderators that match the request criteria. + + pub items: Option>, + /// Identifies what kind of resource this is. Value: the fixed string "youtube#liveChatModeratorListResponse". + + pub kind: Option, + /// The token that can be used as the value of the pageToken parameter to retrieve the next page in the result set. + #[serde(rename="nextPageToken")] + + pub next_page_token: Option, + /// General pagination information. + #[serde(rename="pageInfo")] + + pub page_info: Option, + /// The token that can be used as the value of the pageToken parameter to retrieve the previous page in the result set. + #[serde(rename="prevPageToken")] + + pub prev_page_token: Option, + /// no description provided + #[serde(rename="tokenPagination")] + + pub token_pagination: Option, + /// The visitorId identifies the visitor. + #[serde(rename="visitorId")] + + pub visitor_id: Option, +} + +impl client::ResponseResult for LiveChatModeratorListResponse {} + +impl client::ToParts for LiveChatModeratorListResponse { + /// Return a comma separated list of members that are currently set, i.e. for which `self.member.is_some()`. + /// The produced string is suitable for use as a parts list that indicates the parts you are sending, and/or + /// the parts you want to see in the server response. + fn to_parts(&self) -> String { + let mut r = String::new(); + if self.etag.is_some() { r = r + "etag,"; } + if self.event_id.is_some() { r = r + "eventId,"; } + if self.items.is_some() { r = r + "items,"; } + if self.kind.is_some() { r = r + "kind,"; } + if self.next_page_token.is_some() { r = r + "nextPageToken,"; } + if self.page_info.is_some() { r = r + "pageInfo,"; } + if self.prev_page_token.is_some() { r = r + "prevPageToken,"; } + if self.token_pagination.is_some() { r = r + "tokenPagination,"; } + if self.visitor_id.is_some() { r = r + "visitorId,"; } + r.pop(); + r + } +} + +/// There is no detailed description. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[serde_with::serde_as(crate = "::client::serde_with")] +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct LiveChatModeratorSnippet { + /// The ID of the live chat this moderator can act on. + #[serde(rename="liveChatId")] + + pub live_chat_id: Option, + /// Details about the moderator. + #[serde(rename="moderatorDetails")] + + pub moderator_details: Option, +} + +impl client::Part for LiveChatModeratorSnippet {} + + +/// There is no detailed description. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[serde_with::serde_as(crate = "::client::serde_with")] +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct LiveChatNewSponsorDetails { + /// If the viewer just had upgraded from a lower level. For viewers that were not members at the time of purchase, this field is false. + #[serde(rename="isUpgrade")] + + pub is_upgrade: Option, + /// The name of the Level that the viewer just had joined. The Level names are defined by the YouTube channel offering the Membership. In some situations this field isn't filled. + #[serde(rename="memberLevelName")] + + pub member_level_name: Option, +} + +impl client::Part for LiveChatNewSponsorDetails {} + + +/// There is no detailed description. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[serde_with::serde_as(crate = "::client::serde_with")] +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct LiveChatPollDetails { + /// no description provided + + pub metadata: Option, + /// no description provided + + pub status: Option, +} + +impl client::Part for LiveChatPollDetails {} + + +/// There is no detailed description. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[serde_with::serde_as(crate = "::client::serde_with")] +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct LiveChatPollDetailsPollMetadata { + /// The options will be returned in the order that is displayed in 1P + + pub options: Option>, + /// no description provided + #[serde(rename="questionText")] + + pub question_text: Option, +} + +impl client::Part for LiveChatPollDetailsPollMetadata {} + + +/// There is no detailed description. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[serde_with::serde_as(crate = "::client::serde_with")] +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct LiveChatPollDetailsPollMetadataPollOption { + /// no description provided + #[serde(rename="optionText")] + + pub option_text: Option, + /// no description provided + + #[serde_as(as = "Option<::client::serde_with::DisplayFromStr>")] + pub tally: Option, +} + +impl client::Part for LiveChatPollDetailsPollMetadataPollOption {} + + +/// There is no detailed description. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[serde_with::serde_as(crate = "::client::serde_with")] +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct LiveChatSuperChatDetails { + /// A rendered string that displays the fund amount and currency to the user. + #[serde(rename="amountDisplayString")] + + pub amount_display_string: Option, + /// The amount purchased by the user, in micros (1,750,000 micros = 1.75). + #[serde(rename="amountMicros")] + + #[serde_as(as = "Option<::client::serde_with::DisplayFromStr>")] + pub amount_micros: Option, + /// The currency in which the purchase was made. + + pub currency: Option, + /// The tier in which the amount belongs. Lower amounts belong to lower tiers. The lowest tier is 1. + + pub tier: Option, + /// The comment added by the user to this Super Chat event. + #[serde(rename="userComment")] + + pub user_comment: Option, +} + +impl client::Part for LiveChatSuperChatDetails {} + + +/// There is no detailed description. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[serde_with::serde_as(crate = "::client::serde_with")] +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct LiveChatSuperStickerDetails { + /// A rendered string that displays the fund amount and currency to the user. + #[serde(rename="amountDisplayString")] + + pub amount_display_string: Option, + /// The amount purchased by the user, in micros (1,750,000 micros = 1.75). + #[serde(rename="amountMicros")] + + #[serde_as(as = "Option<::client::serde_with::DisplayFromStr>")] + pub amount_micros: Option, + /// The currency in which the purchase was made. + + pub currency: Option, + /// Information about the Super Sticker. + #[serde(rename="superStickerMetadata")] + + pub super_sticker_metadata: Option, + /// The tier in which the amount belongs. Lower amounts belong to lower tiers. The lowest tier is 1. + + pub tier: Option, +} + +impl client::Part for LiveChatSuperStickerDetails {} + + +/// There is no detailed description. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[serde_with::serde_as(crate = "::client::serde_with")] +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct LiveChatTextMessageDetails { + /// The user's message. + #[serde(rename="messageText")] + + pub message_text: Option, +} + +impl client::Part for LiveChatTextMessageDetails {} + + +/// There is no detailed description. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[serde_with::serde_as(crate = "::client::serde_with")] +#[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")] + + #[serde_as(as = "Option<::client::serde_with::DisplayFromStr>")] + 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 client::Part for LiveChatUserBannedMessageDetails {} + + +/// A live stream describes a live ingestion point. +/// +/// # Activities +/// +/// This type is used in activities, which are methods you may call on this type or where 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 live streams](LiveStreamDeleteCall) (none) +/// * [insert live streams](LiveStreamInsertCall) (request|response) +/// * [list live streams](LiveStreamListCall) (none) +/// * [update live streams](LiveStreamUpdateCall) (request|response) +#[serde_with::serde_as(crate = "::client::serde_with")] +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct LiveStream { + /// The cdn object defines the live stream's content delivery network (CDN) settings. These settings provide details about the manner in which you stream your content to YouTube. + + pub cdn: Option, + /// The content_details object contains information about the stream, including the closed captions ingestion URL. + #[serde(rename="contentDetails")] + + pub content_details: Option, + /// Etag of this resource. + + pub etag: Option, + /// The ID that YouTube assigns to uniquely identify the stream. + + pub id: Option, + /// Identifies what kind of resource this is. Value: the fixed string "youtube#liveStream". + + pub kind: Option, + /// The snippet object contains basic details about the stream, including its channel, title, and description. + + pub snippet: Option, + /// The status object contains information about live stream's status. + + pub status: Option, +} + +impl client::RequestValue for LiveStream {} +impl client::Resource for LiveStream {} +impl client::ResponseResult for LiveStream {} + +impl client::ToParts for LiveStream { + /// Return a comma separated list of members that are currently set, i.e. for which `self.member.is_some()`. + /// The produced string is suitable for use as a parts list that indicates the parts you are sending, and/or + /// the parts you want to see in the server response. + fn to_parts(&self) -> String { + let mut r = String::new(); + if self.cdn.is_some() { r = r + "cdn,"; } + if self.content_details.is_some() { r = r + "contentDetails,"; } + if self.etag.is_some() { r = r + "etag,"; } + if self.id.is_some() { r = r + "id,"; } + if self.kind.is_some() { r = r + "kind,"; } + if self.snippet.is_some() { r = r + "snippet,"; } + if self.status.is_some() { r = r + "status,"; } + r.pop(); + r + } +} + +/// There is no detailed description. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[serde_with::serde_as(crate = "::client::serde_with")] +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct LiveStreamConfigurationIssue { + /// The long-form description of the issue and how to resolve it. + + pub description: Option, + /// The short-form reason for this issue. + + pub reason: Option, + /// How severe this issue is to the stream. + + pub severity: Option, + /// The kind of error happening. + #[serde(rename="type")] + + pub type_: Option, +} + +impl client::Part for LiveStreamConfigurationIssue {} + + +/// Detailed settings of a stream. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[serde_with::serde_as(crate = "::client::serde_with")] +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct LiveStreamContentDetails { + /// The ingestion URL where the closed captions of this stream are sent. + #[serde(rename="closedCaptionsIngestionUrl")] + + pub closed_captions_ingestion_url: Option, + /// Indicates whether the stream is reusable, which means that it can be bound to multiple broadcasts. It is common for broadcasters to reuse the same stream for many different broadcasts if those broadcasts occur at different times. If you set this value to false, then the stream will not be reusable, which means that it can only be bound to one broadcast. Non-reusable streams differ from reusable streams in the following ways: - A non-reusable stream can only be bound to one broadcast. - A non-reusable stream might be deleted by an automated process after the broadcast ends. - The liveStreams.list method does not list non-reusable streams if you call the method and set the mine parameter to true. The only way to use that method to retrieve the resource for a non-reusable stream is to use the id parameter to identify the stream. + #[serde(rename="isReusable")] + + pub is_reusable: Option, +} + +impl client::Part for LiveStreamContentDetails {} + + +/// There is no detailed description. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[serde_with::serde_as(crate = "::client::serde_with")] +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct LiveStreamHealthStatus { + /// The configurations issues on this stream + #[serde(rename="configurationIssues")] + + pub configuration_issues: Option>, + /// The last time this status was updated (in seconds) + #[serde(rename="lastUpdateTimeSeconds")] + + #[serde_as(as = "Option<::client::serde_with::DisplayFromStr>")] + pub last_update_time_seconds: Option, + /// The status code of this stream + + pub status: Option, +} + +impl client::Part for LiveStreamHealthStatus {} + + +/// 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 live streams](LiveStreamListCall) (response) +#[serde_with::serde_as(crate = "::client::serde_with")] +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct LiveStreamListResponse { + /// Etag of this resource. + + pub etag: Option, + /// Serialized EventId of the request which produced this response. + #[serde(rename="eventId")] + + pub event_id: Option, + /// A list of live streams that match the request criteria. + + pub items: Option>, + /// Identifies what kind of resource this is. Value: the fixed string "youtube#liveStreamListResponse". + + pub kind: Option, + /// The token that can be used as the value of the pageToken parameter to retrieve the next page in the result set. + #[serde(rename="nextPageToken")] + + pub next_page_token: Option, + /// no description provided + #[serde(rename="pageInfo")] + + pub page_info: Option, + /// The token that can be used as the value of the pageToken parameter to retrieve the previous page in the result set. + #[serde(rename="prevPageToken")] + + pub prev_page_token: Option, + /// no description provided + #[serde(rename="tokenPagination")] + + pub token_pagination: Option, + /// The visitorId identifies the visitor. + #[serde(rename="visitorId")] + + pub visitor_id: Option, +} + +impl client::ResponseResult for LiveStreamListResponse {} + +impl client::ToParts for LiveStreamListResponse { + /// Return a comma separated list of members that are currently set, i.e. for which `self.member.is_some()`. + /// The produced string is suitable for use as a parts list that indicates the parts you are sending, and/or + /// the parts you want to see in the server response. + fn to_parts(&self) -> String { + let mut r = String::new(); + if self.etag.is_some() { r = r + "etag,"; } + if self.event_id.is_some() { r = r + "eventId,"; } + if self.items.is_some() { r = r + "items,"; } + if self.kind.is_some() { r = r + "kind,"; } + if self.next_page_token.is_some() { r = r + "nextPageToken,"; } + if self.page_info.is_some() { r = r + "pageInfo,"; } + if self.prev_page_token.is_some() { r = r + "prevPageToken,"; } + if self.token_pagination.is_some() { r = r + "tokenPagination,"; } + if self.visitor_id.is_some() { r = r + "visitorId,"; } + r.pop(); + r + } +} + +/// There is no detailed description. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[serde_with::serde_as(crate = "::client::serde_with")] +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct LiveStreamSnippet { + /// The ID that YouTube uses to uniquely identify the channel that is transmitting the stream. + #[serde(rename="channelId")] + + pub channel_id: Option, + /// The stream's description. The value cannot be longer than 10000 characters. + + pub description: Option, + /// no description provided + #[serde(rename="isDefaultStream")] + + pub is_default_stream: Option, + /// The date and time that the stream was created. + #[serde(rename="publishedAt")] + + pub published_at: Option>, + /// The stream's title. The value must be between 1 and 128 characters long. + + pub title: Option, +} + +impl client::Part for LiveStreamSnippet {} + + +/// Brief description of the live stream status. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[serde_with::serde_as(crate = "::client::serde_with")] +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct LiveStreamStatus { + /// The health status of the stream. + #[serde(rename="healthStatus")] + + pub health_status: Option, + /// no description provided + #[serde(rename="streamStatus")] + + pub stream_status: Option, +} + +impl client::Part for LiveStreamStatus {} + + +/// There is no detailed description. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[serde_with::serde_as(crate = "::client::serde_with")] +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct LocalizedProperty { + /// no description provided + + pub default: Option, + /// The language of the default property. + #[serde(rename="defaultLanguage")] + + pub default_language: Option, + /// no description provided + + pub localized: Option>, +} + +impl client::Part for LocalizedProperty {} + + +/// There is no detailed description. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[serde_with::serde_as(crate = "::client::serde_with")] +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct LocalizedString { + /// no description provided + + pub language: Option, + /// no description provided + + pub value: Option, +} + +impl client::Part for LocalizedString {} + + +/// A *member* resource represents a member for a YouTube channel. A member provides recurring monetary support to a creator and receives special benefits. +/// +/// # Activities +/// +/// This type is used in activities, which are methods you may call on this type or where 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 members](MemberListCall) (none) +#[serde_with::serde_as(crate = "::client::serde_with")] +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct Member { + /// Etag of this resource. + + pub etag: Option, + /// Identifies what kind of resource this is. Value: the fixed string "youtube#member". + + pub kind: Option, + /// The snippet object contains basic details about the member. + + pub snippet: Option, +} + +impl client::Resource for Member {} + +impl client::ToParts for Member { + /// Return a comma separated list of members that are currently set, i.e. for which `self.member.is_some()`. + /// The produced string is suitable for use as a parts list that indicates the parts you are sending, and/or + /// the parts you want to see in the server response. + fn to_parts(&self) -> String { + let mut r = String::new(); + if self.etag.is_some() { r = r + "etag,"; } + if self.kind.is_some() { r = r + "kind,"; } + if self.snippet.is_some() { r = r + "snippet,"; } + r.pop(); + r + } +} + +/// 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 members](MemberListCall) (response) +#[serde_with::serde_as(crate = "::client::serde_with")] +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct MemberListResponse { + /// Etag of this resource. + + pub etag: Option, + /// Serialized EventId of the request which produced this response. + #[serde(rename="eventId")] + + pub event_id: Option, + /// A list of members that match the request criteria. + + pub items: Option>, + /// Identifies what kind of resource this is. Value: the fixed string "youtube#memberListResponse". + + pub kind: Option, + /// The token that can be used as the value of the pageToken parameter to retrieve the next page in the result set. + #[serde(rename="nextPageToken")] + + pub next_page_token: Option, + /// no description provided + #[serde(rename="pageInfo")] + + pub page_info: Option, + /// no description provided + #[serde(rename="tokenPagination")] + + pub token_pagination: Option, + /// The visitorId identifies the visitor. + #[serde(rename="visitorId")] + + pub visitor_id: Option, +} + +impl client::ResponseResult for MemberListResponse {} + +impl client::ToParts for MemberListResponse { + /// Return a comma separated list of members that are currently set, i.e. for which `self.member.is_some()`. + /// The produced string is suitable for use as a parts list that indicates the parts you are sending, and/or + /// the parts you want to see in the server response. + fn to_parts(&self) -> String { + let mut r = String::new(); + if self.etag.is_some() { r = r + "etag,"; } + if self.event_id.is_some() { r = r + "eventId,"; } + if self.items.is_some() { r = r + "items,"; } + if self.kind.is_some() { r = r + "kind,"; } + if self.next_page_token.is_some() { r = r + "nextPageToken,"; } + if self.page_info.is_some() { r = r + "pageInfo,"; } + if self.token_pagination.is_some() { r = r + "tokenPagination,"; } + if self.visitor_id.is_some() { r = r + "visitorId,"; } + r.pop(); + r + } +} + +/// There is no detailed description. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[serde_with::serde_as(crate = "::client::serde_with")] +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct MemberSnippet { + /// The id of the channel that's offering memberships. + #[serde(rename="creatorChannelId")] + + pub creator_channel_id: Option, + /// Details about the member. + #[serde(rename="memberDetails")] + + pub member_details: Option, + /// Details about the user's membership. + #[serde(rename="membershipsDetails")] + + pub memberships_details: Option, +} + +impl client::Part for MemberSnippet {} + + +/// There is no detailed description. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[serde_with::serde_as(crate = "::client::serde_with")] +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct MembershipsDetails { + /// Ids of all levels that the user has access to. This includes the currently active level and all other levels that are included because of a higher purchase. + #[serde(rename="accessibleLevels")] + + pub accessible_levels: Option>, + /// Id of the highest level that the user has access to at the moment. + #[serde(rename="highestAccessibleLevel")] + + pub highest_accessible_level: Option, + /// Display name for the highest level that the user has access to at the moment. + #[serde(rename="highestAccessibleLevelDisplayName")] + + pub highest_accessible_level_display_name: Option, + /// Data about memberships duration without taking into consideration pricing levels. + #[serde(rename="membershipsDuration")] + + pub memberships_duration: Option, + /// Data about memberships duration on particular pricing levels. + #[serde(rename="membershipsDurationAtLevels")] + + pub memberships_duration_at_levels: Option>, +} + +impl client::Part for MembershipsDetails {} + + +/// There is no detailed description. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[serde_with::serde_as(crate = "::client::serde_with")] +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct MembershipsDuration { + /// The date and time when the user became a continuous member across all levels. + #[serde(rename="memberSince")] + + pub member_since: Option, + /// The cumulative time the user has been a member across all levels in complete months (the time is rounded down to the nearest integer). + #[serde(rename="memberTotalDurationMonths")] + + pub member_total_duration_months: Option, +} + +impl client::Part for MembershipsDuration {} + + +/// There is no detailed description. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[serde_with::serde_as(crate = "::client::serde_with")] +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct MembershipsDurationAtLevel { + /// Pricing level ID. + + pub level: Option, + /// The date and time when the user became a continuous member for the given level. + #[serde(rename="memberSince")] + + pub member_since: Option, + /// The cumulative time the user has been a member for the given level in complete months (the time is rounded down to the nearest integer). + #[serde(rename="memberTotalDurationMonths")] + + pub member_total_duration_months: Option, +} + +impl client::Part for MembershipsDurationAtLevel {} + + +/// A *membershipsLevel* resource represents an offer made by YouTube creators for their fans. Users can become members of the channel by joining one of the available levels. They will provide recurring monetary support and receives special benefits. +/// +/// # Activities +/// +/// This type is used in activities, which are methods you may call on this type or where 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 memberships levels](MembershipsLevelListCall) (none) +#[serde_with::serde_as(crate = "::client::serde_with")] +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct MembershipsLevel { + /// Etag of this resource. + + pub etag: Option, + /// The ID that YouTube assigns to uniquely identify the memberships level. + + pub id: Option, + /// Identifies what kind of resource this is. Value: the fixed string "youtube#membershipsLevelListResponse". + + pub kind: Option, + /// The snippet object contains basic details about the level. + + pub snippet: Option, +} + +impl client::Resource for MembershipsLevel {} + +impl client::ToParts for MembershipsLevel { + /// Return a comma separated list of members that are currently set, i.e. for which `self.member.is_some()`. + /// The produced string is suitable for use as a parts list that indicates the parts you are sending, and/or + /// the parts you want to see in the server response. + fn to_parts(&self) -> String { + let mut r = String::new(); + if self.etag.is_some() { r = r + "etag,"; } + if self.id.is_some() { r = r + "id,"; } + if self.kind.is_some() { r = r + "kind,"; } + if self.snippet.is_some() { r = r + "snippet,"; } + r.pop(); + r + } +} + +/// 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 memberships levels](MembershipsLevelListCall) (response) +#[serde_with::serde_as(crate = "::client::serde_with")] +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct MembershipsLevelListResponse { + /// Etag of this resource. + + pub etag: Option, + /// Serialized EventId of the request which produced this response. + #[serde(rename="eventId")] + + pub event_id: Option, + /// A list of pricing levels offered by a creator to the fans. + + pub items: Option>, + /// Identifies what kind of resource this is. Value: the fixed string "youtube#membershipsLevelListResponse". + + pub kind: Option, + /// The visitorId identifies the visitor. + #[serde(rename="visitorId")] + + pub visitor_id: Option, +} + +impl client::ResponseResult for MembershipsLevelListResponse {} + +impl client::ToParts for MembershipsLevelListResponse { + /// Return a comma separated list of members that are currently set, i.e. for which `self.member.is_some()`. + /// The produced string is suitable for use as a parts list that indicates the parts you are sending, and/or + /// the parts you want to see in the server response. + fn to_parts(&self) -> String { + let mut r = String::new(); + if self.etag.is_some() { r = r + "etag,"; } + if self.event_id.is_some() { r = r + "eventId,"; } + if self.items.is_some() { r = r + "items,"; } + if self.kind.is_some() { r = r + "kind,"; } + if self.visitor_id.is_some() { r = r + "visitorId,"; } + r.pop(); + r + } +} + +/// There is no detailed description. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[serde_with::serde_as(crate = "::client::serde_with")] +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct MembershipsLevelSnippet { + /// The id of the channel that's offering channel memberships. + #[serde(rename="creatorChannelId")] + + pub creator_channel_id: Option, + /// Details about the pricing level. + #[serde(rename="levelDetails")] + + pub level_details: Option, +} + +impl client::Part for MembershipsLevelSnippet {} + + +/// Settings and Info of the monitor stream +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[serde_with::serde_as(crate = "::client::serde_with")] +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct MonitorStreamInfo { + /// If you have set the enableMonitorStream property to true, then this property determines the length of the live broadcast delay. + #[serde(rename="broadcastStreamDelayMs")] + + pub broadcast_stream_delay_ms: Option, + /// HTML code that embeds a player that plays the monitor stream. + #[serde(rename="embedHtml")] + + pub embed_html: Option, + /// This value determines whether the monitor stream is enabled for the broadcast. If the monitor stream is enabled, then YouTube will broadcast the event content on a special stream intended only for the broadcaster's consumption. The broadcaster can use the stream to review the event content and also to identify the optimal times to insert cuepoints. You need to set this value to true if you intend to have a broadcast delay for your event. *Note:* This property cannot be updated once the broadcast is in the testing or live state. + #[serde(rename="enableMonitorStream")] + + pub enable_monitor_stream: Option, +} + +impl client::Part for MonitorStreamInfo {} + + +/// Paging details for lists of resources, including total number of items available and number of resources returned in a single page. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[serde_with::serde_as(crate = "::client::serde_with")] +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct PageInfo { + /// The number of results included in the API response. + #[serde(rename="resultsPerPage")] + + pub results_per_page: Option, + /// The total number of results in the result set. + #[serde(rename="totalResults")] + + pub total_results: Option, +} + +impl client::Part for PageInfo {} + + +/// 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: - uploaded videos - favorite videos - positively rated (liked) videos - watch history - watch later To be more specific, these lists are associated with a channel, which is a collection of a person, group, or company’s videos, playlists, and other YouTube information. You can retrieve the playlist IDs for each of these lists from the channel resource for a given channel. You can then use the playlistItems.list method to retrieve any of those lists. You can also add or remove items from those lists by calling the playlistItems.insert and playlistItems.delete methods. +/// +/// # Activities +/// +/// This type is used in activities, which are methods you may call on this type or where 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 playlists](PlaylistDeleteCall) (none) +/// * [insert playlists](PlaylistInsertCall) (request|response) +/// * [list playlists](PlaylistListCall) (none) +/// * [update playlists](PlaylistUpdateCall) (request|response) +#[serde_with::serde_as(crate = "::client::serde_with")] +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct Playlist { + /// The contentDetails object contains information like video count. + #[serde(rename="contentDetails")] + + pub content_details: Option, + /// Etag of this resource. + + pub etag: Option, + /// The ID that YouTube uses to uniquely identify the playlist. + + pub id: Option, + /// Identifies what kind of resource this is. Value: the fixed string "youtube#playlist". + + pub kind: Option, + /// Localizations for different languages + + pub localizations: Option>, + /// The player object contains information that you would use to play the playlist in an embedded player. + + pub player: Option, + /// The snippet object contains basic details about the playlist, such as its title and description. + + pub snippet: Option, + /// The status object contains status information for the playlist. + + pub status: Option, +} + +impl client::RequestValue for Playlist {} +impl client::Resource for Playlist {} +impl client::ResponseResult for Playlist {} + +impl client::ToParts for Playlist { + /// Return a comma separated list of members that are currently set, i.e. for which `self.member.is_some()`. + /// The produced string is suitable for use as a parts list that indicates the parts you are sending, and/or + /// the parts you want to see in the server response. + fn to_parts(&self) -> String { + let mut r = String::new(); + if self.content_details.is_some() { r = r + "contentDetails,"; } + if self.etag.is_some() { r = r + "etag,"; } + if self.id.is_some() { r = r + "id,"; } + if self.kind.is_some() { r = r + "kind,"; } + if self.localizations.is_some() { r = r + "localizations,"; } + if self.player.is_some() { r = r + "player,"; } + if self.snippet.is_some() { r = r + "snippet,"; } + if self.status.is_some() { r = r + "status,"; } + r.pop(); + r + } +} + +/// There is no detailed description. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[serde_with::serde_as(crate = "::client::serde_with")] +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct PlaylistContentDetails { + /// The number of videos in the playlist. + #[serde(rename="itemCount")] + + pub item_count: Option, +} + +impl client::Part for PlaylistContentDetails {} + + +/// There is no detailed description. +/// +/// # Activities +/// +/// This type is used in activities, which are methods you may call on this type or where this type is involved in. +/// The list links the activity name, along with information about where it is used (one of *request* and *response*). +/// +/// * [delete playlist images](PlaylistImageDeleteCall) (none) +/// * [insert playlist images](PlaylistImageInsertCall) (request|response) +/// * [list playlist images](PlaylistImageListCall) (none) +/// * [update playlist images](PlaylistImageUpdateCall) (request|response) +#[serde_with::serde_as(crate = "::client::serde_with")] +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct PlaylistImage { + /// Identifies this resource (playlist id and image type). + + pub id: Option, + /// Identifies what kind of resource this is. Value: the fixed string "youtube#playlistImages". + + pub kind: Option, + /// no description provided + + pub snippet: Option, +} + +impl client::RequestValue for PlaylistImage {} +impl client::Resource for PlaylistImage {} +impl client::ResponseResult for PlaylistImage {} + +impl client::ToParts for PlaylistImage { + /// Return a comma separated list of members that are currently set, i.e. for which `self.member.is_some()`. + /// The produced string is suitable for use as a parts list that indicates the parts you are sending, and/or + /// the parts you want to see in the server response. + fn to_parts(&self) -> String { + let mut r = String::new(); + if self.id.is_some() { r = r + "id,"; } + if self.kind.is_some() { r = r + "kind,"; } + if self.snippet.is_some() { r = r + "snippet,"; } + r.pop(); + r + } +} + +/// 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 playlist images](PlaylistImageListCall) (response) +#[serde_with::serde_as(crate = "::client::serde_with")] +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct PlaylistImageListResponse { + /// no description provided + + pub items: Option>, + /// Identifies what kind of resource this is. Value: the fixed string "youtube#playlistImageListResponse". + + pub kind: Option, + /// The token that can be used as the value of the pageToken parameter to retrieve the next page in the result set. + #[serde(rename="nextPageToken")] + + pub next_page_token: Option, + /// General pagination information. + #[serde(rename="pageInfo")] + + pub page_info: Option, + /// The token that can be used as the value of the pageToken parameter to retrieve the previous page in the result set. + #[serde(rename="prevPageToken")] + + pub prev_page_token: Option, +} + +impl client::ResponseResult for PlaylistImageListResponse {} + +impl client::ToParts for PlaylistImageListResponse { + /// Return a comma separated list of members that are currently set, i.e. for which `self.member.is_some()`. + /// The produced string is suitable for use as a parts list that indicates the parts you are sending, and/or + /// the parts you want to see in the server response. + fn to_parts(&self) -> String { + let mut r = String::new(); + if self.items.is_some() { r = r + "items,"; } + if self.kind.is_some() { r = r + "kind,"; } + if self.next_page_token.is_some() { r = r + "nextPageToken,"; } + if self.page_info.is_some() { r = r + "pageInfo,"; } + if self.prev_page_token.is_some() { r = r + "prevPageToken,"; } + r.pop(); + r + } +} + +/// A *playlistImage* resource identifies another resource, such as a image, that is associated with a playlist. In addition, the playlistImage resource contains details about the included resource that pertain specifically to how that resource is used in that playlist. YouTube uses playlists to identify special collections of videos for a channel, such as: - uploaded videos - favorite videos - positively rated (liked) videos - watch history To be more specific, these lists are associated with a channel, which is a collection of a person, group, or company's videos, playlists, and other YouTube information. You can retrieve the playlist IDs for each of these lists from the channel resource for a given channel. You can then use the playlistImages.list method to retrieve image data for any of those playlists. You can also add or remove images from those lists by calling the playlistImages.insert and playlistImages.delete methods. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[serde_with::serde_as(crate = "::client::serde_with")] +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct PlaylistImageSnippet { + /// The image height. + + pub height: Option, + /// The Playlist ID of the playlist this image is associated with. + #[serde(rename="playlistId")] + + pub playlist_id: Option, + /// The image type. + #[serde(rename="type")] + + pub type_: Option, + /// The image width. + + pub width: Option, +} + +impl client::Part for PlaylistImageSnippet {} + + +/// A *playlistItem* resource identifies another resource, such as a video, that is included in a playlist. In addition, the playlistItem resource contains details about the included resource that pertain specifically to how that resource is used in that playlist. YouTube uses playlists to identify special collections of videos for a channel, such as: - uploaded videos - favorite videos - positively rated (liked) videos - watch history - watch later To be more specific, these lists are associated with a channel, which is a collection of a person, group, or company’s videos, playlists, and other YouTube information. You can retrieve the playlist IDs for each of these lists from the channel resource for a given channel. You can then use the playlistItems.list method to retrieve any of those lists. You can also add or remove items from those lists by calling the playlistItems.insert and playlistItems.delete methods. For example, if a user gives a positive rating to a video, you would insert that video into the liked videos playlist for that user’s channel. +/// +/// # Activities +/// +/// This type is used in activities, which are methods you may call on this type or where 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 playlist items](PlaylistItemDeleteCall) (none) +/// * [insert playlist items](PlaylistItemInsertCall) (request|response) +/// * [list playlist items](PlaylistItemListCall) (none) +/// * [update playlist items](PlaylistItemUpdateCall) (request|response) +#[serde_with::serde_as(crate = "::client::serde_with")] +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct PlaylistItem { + /// The contentDetails object is included in the resource if the included item is a YouTube video. The object contains additional information about the video. + #[serde(rename="contentDetails")] + + pub content_details: Option, + /// Etag of this resource. + + pub etag: Option, + /// The ID that YouTube uses to uniquely identify the playlist item. + + pub id: Option, + /// Identifies what kind of resource this is. Value: the fixed string "youtube#playlistItem". + + pub kind: Option, + /// The snippet object contains basic details about the playlist item, such as its title and position in the playlist. + + pub snippet: Option, + /// The status object contains information about the playlist item's privacy status. + + pub status: Option, +} + +impl client::RequestValue for PlaylistItem {} +impl client::Resource for PlaylistItem {} +impl client::ResponseResult for PlaylistItem {} + +impl client::ToParts for PlaylistItem { + /// Return a comma separated list of members that are currently set, i.e. for which `self.member.is_some()`. + /// The produced string is suitable for use as a parts list that indicates the parts you are sending, and/or + /// the parts you want to see in the server response. + fn to_parts(&self) -> String { + let mut r = String::new(); + if self.content_details.is_some() { r = r + "contentDetails,"; } + if self.etag.is_some() { r = r + "etag,"; } + if self.id.is_some() { r = r + "id,"; } + if self.kind.is_some() { r = r + "kind,"; } + if self.snippet.is_some() { r = r + "snippet,"; } + if self.status.is_some() { r = r + "status,"; } + r.pop(); + r + } +} + +/// There is no detailed description. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[serde_with::serde_as(crate = "::client::serde_with")] +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct PlaylistItemContentDetails { + /// The time, measured in seconds from the start of the video, when the video should stop playing. (The playlist owner can specify the times when the video should start and stop playing when the video is played in the context of the playlist.) By default, assume that the video.endTime is the end of the video. + #[serde(rename="endAt")] + + pub end_at: Option, + /// A user-generated note for this item. + + pub note: Option, + /// The time, measured in seconds from the start of the video, when the video should start playing. (The playlist owner can specify the times when the video should start and stop playing when the video is played in the context of the playlist.) The default value is 0. + #[serde(rename="startAt")] + + pub start_at: Option, + /// The ID that YouTube uses to uniquely identify a video. To retrieve the video resource, set the id query parameter to this value in your API request. + #[serde(rename="videoId")] + + pub video_id: Option, + /// The date and time that the video was published to YouTube. + #[serde(rename="videoPublishedAt")] + + pub video_published_at: Option>, +} + +impl client::Part for PlaylistItemContentDetails {} + + +/// 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 playlist items](PlaylistItemListCall) (response) +#[serde_with::serde_as(crate = "::client::serde_with")] +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct PlaylistItemListResponse { + /// no description provided + + pub etag: Option, + /// Serialized EventId of the request which produced this response. + #[serde(rename="eventId")] + + pub event_id: Option, + /// A list of playlist items that match the request criteria. + + pub items: Option>, + /// Identifies what kind of resource this is. Value: the fixed string "youtube#playlistItemListResponse". Etag of this resource. + + pub kind: Option, + /// The token that can be used as the value of the pageToken parameter to retrieve the next page in the result set. + #[serde(rename="nextPageToken")] + + pub next_page_token: Option, + /// General pagination information. + #[serde(rename="pageInfo")] + + pub page_info: Option, + /// The token that can be used as the value of the pageToken parameter to retrieve the previous page in the result set. + #[serde(rename="prevPageToken")] + + pub prev_page_token: Option, + /// no description provided + #[serde(rename="tokenPagination")] + + pub token_pagination: Option, + /// The visitorId identifies the visitor. + #[serde(rename="visitorId")] + + pub visitor_id: Option, +} + +impl client::ResponseResult for PlaylistItemListResponse {} + +impl client::ToParts for PlaylistItemListResponse { + /// Return a comma separated list of members that are currently set, i.e. for which `self.member.is_some()`. + /// The produced string is suitable for use as a parts list that indicates the parts you are sending, and/or + /// the parts you want to see in the server response. + fn to_parts(&self) -> String { + let mut r = String::new(); + if self.etag.is_some() { r = r + "etag,"; } + if self.event_id.is_some() { r = r + "eventId,"; } + if self.items.is_some() { r = r + "items,"; } + if self.kind.is_some() { r = r + "kind,"; } + if self.next_page_token.is_some() { r = r + "nextPageToken,"; } + if self.page_info.is_some() { r = r + "pageInfo,"; } + if self.prev_page_token.is_some() { r = r + "prevPageToken,"; } + if self.token_pagination.is_some() { r = r + "tokenPagination,"; } + if self.visitor_id.is_some() { r = r + "visitorId,"; } + r.pop(); + r + } +} + +/// Basic details about a playlist, including title, description and thumbnails. Basic details of a YouTube Playlist item provided by the author. Next ID: 15 +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[serde_with::serde_as(crate = "::client::serde_with")] +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct PlaylistItemSnippet { + /// The ID that YouTube uses to uniquely identify the user that added the item to the playlist. + #[serde(rename="channelId")] + + pub channel_id: Option, + /// Channel title for the channel that the playlist item belongs to. + #[serde(rename="channelTitle")] + + pub channel_title: Option, + /// The item's description. + + pub description: Option, + /// The ID that YouTube uses to uniquely identify thGe playlist that the playlist item is in. + #[serde(rename="playlistId")] + + pub playlist_id: Option, + /// The order in which the item appears in the playlist. The value uses a zero-based index, so the first item has a position of 0, the second item has a position of 1, and so forth. + + pub position: Option, + /// The date and time that the item was added to the playlist. + #[serde(rename="publishedAt")] + + pub published_at: Option>, + /// The id object contains information that can be used to uniquely identify the resource that is included in the playlist as the playlist item. + #[serde(rename="resourceId")] + + pub resource_id: Option, + /// A map of thumbnail images associated with the playlist item. For each object in the map, the key is the name of the thumbnail image, and the value is an object that contains other information about the thumbnail. + + pub thumbnails: Option, + /// The item's title. + + pub title: Option, + /// Channel id for the channel this video belongs to. + #[serde(rename="videoOwnerChannelId")] + + pub video_owner_channel_id: Option, + /// Channel title for the channel this video belongs to. + #[serde(rename="videoOwnerChannelTitle")] + + pub video_owner_channel_title: Option, +} + +impl client::Part for PlaylistItemSnippet {} + + +/// Information about the playlist item's privacy status. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[serde_with::serde_as(crate = "::client::serde_with")] +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct PlaylistItemStatus { + /// This resource's privacy status. + #[serde(rename="privacyStatus")] + + pub privacy_status: Option, +} + +impl client::Part for PlaylistItemStatus {} + + +/// 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 playlists](PlaylistListCall) (response) +#[serde_with::serde_as(crate = "::client::serde_with")] +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct PlaylistListResponse { + /// Etag of this resource. + + pub etag: Option, + /// Serialized EventId of the request which produced this response. + #[serde(rename="eventId")] + + pub event_id: Option, + /// A list of playlists that match the request criteria + + pub items: Option>, + /// Identifies what kind of resource this is. Value: the fixed string "youtube#playlistListResponse". + + pub kind: Option, + /// The token that can be used as the value of the pageToken parameter to retrieve the next page in the result set. + #[serde(rename="nextPageToken")] + + pub next_page_token: Option, + /// General pagination information. + #[serde(rename="pageInfo")] + + pub page_info: Option, + /// The token that can be used as the value of the pageToken parameter to retrieve the previous page in the result set. + #[serde(rename="prevPageToken")] + + pub prev_page_token: Option, + /// no description provided + #[serde(rename="tokenPagination")] + + pub token_pagination: Option, + /// The visitorId identifies the visitor. + #[serde(rename="visitorId")] + + pub visitor_id: Option, +} + +impl client::ResponseResult for PlaylistListResponse {} + +impl client::ToParts for PlaylistListResponse { + /// Return a comma separated list of members that are currently set, i.e. for which `self.member.is_some()`. + /// The produced string is suitable for use as a parts list that indicates the parts you are sending, and/or + /// the parts you want to see in the server response. + fn to_parts(&self) -> String { + let mut r = String::new(); + if self.etag.is_some() { r = r + "etag,"; } + if self.event_id.is_some() { r = r + "eventId,"; } + if self.items.is_some() { r = r + "items,"; } + if self.kind.is_some() { r = r + "kind,"; } + if self.next_page_token.is_some() { r = r + "nextPageToken,"; } + if self.page_info.is_some() { r = r + "pageInfo,"; } + if self.prev_page_token.is_some() { r = r + "prevPageToken,"; } + if self.token_pagination.is_some() { r = r + "tokenPagination,"; } + if self.visitor_id.is_some() { r = r + "visitorId,"; } + r.pop(); + r + } +} + +/// Playlist localization setting +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[serde_with::serde_as(crate = "::client::serde_with")] +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct PlaylistLocalization { + /// The localized strings for playlist's description. + + pub description: Option, + /// The localized strings for playlist's title. + + pub title: Option, +} + +impl client::Part for PlaylistLocalization {} + + +/// There is no detailed description. +/// +/// This type is not used in any activity, and only used as *part* of another schema. +/// +#[serde_with::serde_as(crate = "::client::serde_with")] +#[derive(Default, Clone, Debug, Serialize, Deserialize)] +pub struct PlaylistPlayer { + /// An