#![allow(clippy::ptr_arg)]
use std::collections::{BTreeSet, HashMap};
use tokio::time::sleep;
// ##############
// UTILITIES ###
// ############
/// Identifies the an OAuth2 authorization scope.
/// A scope is needed when requesting an
/// [authorization token](https://developers.google.com/youtube/v3/guides/authentication).
#[derive(PartialEq, Eq, Ord, PartialOrd, Hash, Debug, Clone, Copy)]
pub enum Scope {
/// Manage your YouTube account
Full,
/// See a list of your current active channel members, their current level, and when they became a member
ChannelMembershipCreator,
/// See, edit, and permanently delete your YouTube videos, ratings, comments and captions
ForceSsl,
/// View your YouTube account
Readonly,
/// Manage your YouTube videos
Upload,
/// View and manage your assets and associated content on YouTube
Partner,
/// View private information of your YouTube channel relevant during the audit process with a YouTube partner
PartnerChannelAudit,
}
impl AsRef<str> for Scope {
fn as_ref(&self) -> &str {
match *self {
Scope::Full => "https://www.googleapis.com/auth/youtube",
Scope::ChannelMembershipCreator => {
"https://www.googleapis.com/auth/youtube.channel-memberships.creator"
}
Scope::ForceSsl => "https://www.googleapis.com/auth/youtube.force-ssl",
Scope::Readonly => "https://www.googleapis.com/auth/youtube.readonly",
Scope::Upload => "https://www.googleapis.com/auth/youtube.upload",
Scope::Partner => "https://www.googleapis.com/auth/youtubepartner",
Scope::PartnerChannelAudit => {
"https://www.googleapis.com/auth/youtubepartner-channel-audit"
}
}
}
}
#[allow(clippy::derivable_impls)]
impl Default for Scope {
fn default() -> Scope {
Scope::Readonly
}
}
// ########
// HUB ###
// ######
/// 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 youtube3::{YouTube, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// // Get an ApplicationSecret instance by some means. It contains the `client_id` and
/// // `client_secret`, among other things.
/// let secret: yup_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 connector = hyper_rustls::HttpsConnectorBuilder::new()
/// .with_native_roots()
/// .unwrap()
/// .https_only()
/// .enable_http2()
/// .build();
///
/// let executor = hyper_util::rt::TokioExecutor::new();
/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// secret,
/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// yup_oauth2::client::CustomHyperClientBuilder::from(
/// hyper_util::client::legacy::Client::builder(executor).build(connector),
/// ),
/// ).build().await.unwrap();
///
/// let client = hyper_util::client::legacy::Client::builder(
/// hyper_util::rt::TokioExecutor::new()
/// )
/// .build(
/// hyper_rustls::HttpsConnectorBuilder::new()
/// .with_native_roots()
/// .unwrap()
/// .https_or_http()
/// .enable_http2()
/// .build()
/// );
/// let mut hub = YouTube::new(client, auth);
/// // You can configure optional parameters by calling 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!["gubergren".into()])
/// .video_category_id("rebum.")
/// .region_code("est")
/// .page_token("ipsum")
/// .on_behalf_of_content_owner("ipsum")
/// .my_rating("est")
/// .max_width(-62)
/// .max_results(84)
/// .max_height(-99)
/// .locale("Lorem")
/// .add_id("eos")
/// .hl("labore")
/// .chart("sed")
/// .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<C> {
pub client: common::Client<C>,
pub auth: Box<dyn common::GetToken>,
_user_agent: String,
_base_url: String,
_root_url: String,
}
impl<C> common::Hub for YouTube<C> {}
impl<'a, C> YouTube<C> {
pub fn new<A: 'static + common::GetToken>(client: common::Client<C>, auth: A) -> YouTube<C> {
YouTube {
client,
auth: Box::new(auth),
_user_agent: "google-api-rust-client/7.0.0".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, C> {
AbuseReportMethods { hub: self }
}
pub fn activities(&'a self) -> ActivityMethods<'a, C> {
ActivityMethods { hub: self }
}
pub fn captions(&'a self) -> CaptionMethods<'a, C> {
CaptionMethods { hub: self }
}
pub fn channel_banners(&'a self) -> ChannelBannerMethods<'a, C> {
ChannelBannerMethods { hub: self }
}
pub fn channel_sections(&'a self) -> ChannelSectionMethods<'a, C> {
ChannelSectionMethods { hub: self }
}
pub fn channels(&'a self) -> ChannelMethods<'a, C> {
ChannelMethods { hub: self }
}
pub fn comment_threads(&'a self) -> CommentThreadMethods<'a, C> {
CommentThreadMethods { hub: self }
}
pub fn comments(&'a self) -> CommentMethods<'a, C> {
CommentMethods { hub: self }
}
pub fn i18n_languages(&'a self) -> I18nLanguageMethods<'a, C> {
I18nLanguageMethods { hub: self }
}
pub fn i18n_regions(&'a self) -> I18nRegionMethods<'a, C> {
I18nRegionMethods { hub: self }
}
pub fn live_broadcasts(&'a self) -> LiveBroadcastMethods<'a, C> {
LiveBroadcastMethods { hub: self }
}
pub fn live_chat_bans(&'a self) -> LiveChatBanMethods<'a, C> {
LiveChatBanMethods { hub: self }
}
pub fn live_chat_messages(&'a self) -> LiveChatMessageMethods<'a, C> {
LiveChatMessageMethods { hub: self }
}
pub fn live_chat_moderators(&'a self) -> LiveChatModeratorMethods<'a, C> {
LiveChatModeratorMethods { hub: self }
}
pub fn live_streams(&'a self) -> LiveStreamMethods<'a, C> {
LiveStreamMethods { hub: self }
}
pub fn members(&'a self) -> MemberMethods<'a, C> {
MemberMethods { hub: self }
}
pub fn memberships_levels(&'a self) -> MembershipsLevelMethods<'a, C> {
MembershipsLevelMethods { hub: self }
}
pub fn playlist_images(&'a self) -> PlaylistImageMethods<'a, C> {
PlaylistImageMethods { hub: self }
}
pub fn playlist_items(&'a self) -> PlaylistItemMethods<'a, C> {
PlaylistItemMethods { hub: self }
}
pub fn playlists(&'a self) -> PlaylistMethods<'a, C> {
PlaylistMethods { hub: self }
}
pub fn search(&'a self) -> SearchMethods<'a, C> {
SearchMethods { hub: self }
}
pub fn subscriptions(&'a self) -> SubscriptionMethods<'a, C> {
SubscriptionMethods { hub: self }
}
pub fn super_chat_events(&'a self) -> SuperChatEventMethods<'a, C> {
SuperChatEventMethods { hub: self }
}
pub fn tests(&'a self) -> TestMethods<'a, C> {
TestMethods { hub: self }
}
pub fn third_party_links(&'a self) -> ThirdPartyLinkMethods<'a, C> {
ThirdPartyLinkMethods { hub: self }
}
pub fn thumbnails(&'a self) -> ThumbnailMethods<'a, C> {
ThumbnailMethods { hub: self }
}
pub fn video_abuse_report_reasons(&'a self) -> VideoAbuseReportReasonMethods<'a, C> {
VideoAbuseReportReasonMethods { hub: self }
}
pub fn video_categories(&'a self) -> VideoCategoryMethods<'a, C> {
VideoCategoryMethods { hub: self }
}
pub fn video_trainability(&'a self) -> VideoTrainabilityMethods<'a, C> {
VideoTrainabilityMethods { hub: self }
}
pub fn videos(&'a self) -> VideoMethods<'a, C> {
VideoMethods { hub: self }
}
pub fn watermarks(&'a self) -> WatermarkMethods<'a, C> {
WatermarkMethods { hub: self }
}
pub fn youtube(&'a self) -> YoutubeMethods<'a, C> {
YoutubeMethods { hub: self }
}
/// Set the user-agent header field to use in all requests to the server.
/// It defaults to `google-api-rust-client/7.0.0`.
///
/// Returns the previously set user-agent.
pub fn user_agent(&mut self, agent_name: String) -> String {
std::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 {
std::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 {
std::mem::replace(&mut self._root_url, new_root_url)
}
}
// ############
// SCHEMAS ###
// ##########
/// There is no detailed description.
///
/// # Activities
///
/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
///
/// * [insert abuse reports](AbuseReportInsertCall) (request|response)
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct AbuseReport {
/// no description provided
#[serde(rename = "abuseTypes")]
pub abuse_types: Option<Vec<AbuseType>>,
/// no description provided
pub description: Option<String>,
/// no description provided
#[serde(rename = "relatedEntities")]
pub related_entities: Option<Vec<RelatedEntity>>,
/// no description provided
pub subject: Option<Entity>,
}
impl common::RequestValue for AbuseReport {}
impl common::Resource for AbuseReport {}
impl common::ResponseResult for AbuseReport {}
impl common::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.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct AbuseType {
/// no description provided
pub id: Option<String>,
}
impl common::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.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct AccessPolicy {
/// The value of allowed indicates whether the access to the policy is allowed or denied by default.
pub allowed: Option<bool>,
/// A list of region codes that identify countries where the default policy do not apply.
pub exception: Option<Vec<String>>,
}
impl common::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.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::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<ActivityContentDetails>,
/// Etag of this resource
pub etag: Option<String>,
/// The ID that YouTube uses to uniquely identify the activity.
pub id: Option<String>,
/// Identifies what kind of resource this is. Value: the fixed string "youtube#activity".
pub kind: Option<String>,
/// The snippet object contains basic details about the activity, including the activity's type and group ID.
pub snippet: Option<ActivitySnippet>,
}
impl common::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.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::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<ActivityContentDetailsBulletin>,
/// 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<ActivityContentDetailsChannelItem>,
/// 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<ActivityContentDetailsComment>,
/// 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<ActivityContentDetailsFavorite>,
/// 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<ActivityContentDetailsLike>,
/// 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<ActivityContentDetailsPlaylistItem>,
/// 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<ActivityContentDetailsPromotedItem>,
/// The recommendation object contains information about a recommended resource. This property is only present if the snippet.type is recommendation.
pub recommendation: Option<ActivityContentDetailsRecommendation>,
/// The social object contains details about a social network post. This property is only present if the snippet.type is social.
pub social: Option<ActivityContentDetailsSocial>,
/// 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<ActivityContentDetailsSubscription>,
/// The upload object contains information about the uploaded video. This property is only present if the snippet.type is upload.
pub upload: Option<ActivityContentDetailsUpload>,
}
impl common::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.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::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<ResourceId>,
}
impl common::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.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::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<ResourceId>,
}
impl common::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.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct ActivityContentDetailsComment {
/// The resourceId object contains information that identifies the resource associated with the comment.
#[serde(rename = "resourceId")]
pub resource_id: Option<ResourceId>,
}
impl common::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.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::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<ResourceId>,
}
impl common::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.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct ActivityContentDetailsLike {
/// The resourceId object contains information that identifies the rated resource.
#[serde(rename = "resourceId")]
pub resource_id: Option<ResourceId>,
}
impl common::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.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct ActivityContentDetailsPlaylistItem {
/// The value that YouTube uses to uniquely identify the playlist.
#[serde(rename = "playlistId")]
pub playlist_id: Option<String>,
/// ID of the item within the playlist.
#[serde(rename = "playlistItemId")]
pub playlist_item_id: Option<String>,
/// The resourceId object contains information about the resource that was added to the playlist.
#[serde(rename = "resourceId")]
pub resource_id: Option<ResourceId>,
}
impl common::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.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct ActivityContentDetailsPromotedItem {
/// The URL the client should fetch to request a promoted item.
#[serde(rename = "adTag")]
pub ad_tag: Option<String>,
/// 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<String>,
/// The URL the client should ping to indicate that the user was shown this promoted item.
#[serde(rename = "creativeViewUrl")]
pub creative_view_url: Option<String>,
/// The type of call-to-action, a message to the user indicating action that can be taken.
#[serde(rename = "ctaType")]
pub cta_type: Option<String>,
/// 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<String>,
/// The text description to accompany the promoted item.
#[serde(rename = "descriptionText")]
pub description_text: Option<String>,
/// 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<String>,
/// 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<Vec<String>>,
/// 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<Vec<String>>,
/// The ID that YouTube uses to uniquely identify the promoted video.
#[serde(rename = "videoId")]
pub video_id: Option<String>,
}
impl common::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.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct ActivityContentDetailsRecommendation {
/// The reason that the resource is recommended to the user.
pub reason: Option<String>,
/// The resourceId object contains information that identifies the recommended resource.
#[serde(rename = "resourceId")]
pub resource_id: Option<ResourceId>,
/// The seedResourceId object contains information about the resource that caused the recommendation.
#[serde(rename = "seedResourceId")]
pub seed_resource_id: Option<ResourceId>,
}
impl common::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.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct ActivityContentDetailsSocial {
/// The author of the social network post.
pub author: Option<String>,
/// An image of the post's author.
#[serde(rename = "imageUrl")]
pub image_url: Option<String>,
/// The URL of the social network post.
#[serde(rename = "referenceUrl")]
pub reference_url: Option<String>,
/// The resourceId object encapsulates information that identifies the resource associated with a social network post.
#[serde(rename = "resourceId")]
pub resource_id: Option<ResourceId>,
/// The name of the social network.
#[serde(rename = "type")]
pub type_: Option<String>,
}
impl common::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.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::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<ResourceId>,
}
impl common::Part for ActivityContentDetailsSubscription {}
/// Information about the uploaded video.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct ActivityContentDetailsUpload {
/// The ID that YouTube uses to uniquely identify the uploaded video.
#[serde(rename = "videoId")]
pub video_id: Option<String>,
}
impl common::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)
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct ActivityListResponse {
/// Etag of this resource.
pub etag: Option<String>,
/// Serialized EventId of the request which produced this response.
#[serde(rename = "eventId")]
pub event_id: Option<String>,
/// no description provided
pub items: Option<Vec<Activity>>,
/// Identifies what kind of resource this is. Value: the fixed string "youtube#activityListResponse".
pub kind: Option<String>,
/// 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<String>,
/// General pagination information.
#[serde(rename = "pageInfo")]
pub page_info: Option<PageInfo>,
/// 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<String>,
/// no description provided
#[serde(rename = "tokenPagination")]
pub token_pagination: Option<TokenPagination>,
/// The visitorId identifies the visitor.
#[serde(rename = "visitorId")]
pub visitor_id: Option<String>,
}
impl common::ResponseResult for ActivityListResponse {}
impl common::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.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::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<String>,
/// Channel title for the channel responsible for this activity
#[serde(rename = "channelTitle")]
pub channel_title: Option<String>,
/// The description of the resource primarily associated with the activity. @mutable youtube.activities.insert
pub description: Option<String>,
/// 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<String>,
/// The date and time that the video was uploaded.
#[serde(rename = "publishedAt")]
pub published_at: Option<chrono::DateTime<chrono::offset::Utc>>,
/// 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<ThumbnailDetails>,
/// The title of the resource primarily associated with the activity.
pub title: Option<String>,
/// The type of activity that the resource describes.
#[serde(rename = "type")]
pub type_: Option<String>,
}
impl common::Part for ActivitySnippet {}
/// Response for the Videos.stats API. Returns VideoStat information about a batch of videos. VideoStat contains a subset of the information in Video that is relevant to statistics and content details.
///
/// # Activities
///
/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
///
/// * [v3 videos batch get stats youtube](YoutubeV3VideoBatchGetStatCall) (response)
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct BatchGetStatsResponse {
/// Output only. Etag of this resource.
pub etag: Option<String>,
/// Output only. The videos' stats information.
pub items: Option<Vec<VideoStat>>,
/// Output only. Identifies what kind of resource this is. Value: the fixed string "youtube#batchGetStatsResponse".
pub kind: Option<String>,
}
impl common::ResponseResult for BatchGetStatsResponse {}
impl common::ToParts for BatchGetStatsResponse {
/// 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.items.is_some() {
r = r + "items,";
}
if self.kind.is_some() {
r = r + "kind,";
}
r.pop();
r
}
}
/// 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)
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct Caption {
/// Etag of this resource.
pub etag: Option<String>,
/// The ID that YouTube uses to uniquely identify the caption track.
pub id: Option<String>,
/// Identifies what kind of resource this is. Value: the fixed string "youtube#caption".
pub kind: Option<String>,
/// The snippet object contains basic details about the caption.
pub snippet: Option<CaptionSnippet>,
}
impl common::RequestValue for Caption {}
impl common::Resource for Caption {}
impl common::ResponseResult for Caption {}
impl common::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)
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct CaptionListResponse {
/// Etag of this resource.
pub etag: Option<String>,
/// Serialized EventId of the request which produced this response.
#[serde(rename = "eventId")]
pub event_id: Option<String>,
/// A list of captions that match the request criteria.
pub items: Option<Vec<Caption>>,
/// Identifies what kind of resource this is. Value: the fixed string "youtube#captionListResponse".
pub kind: Option<String>,
/// The visitorId identifies the visitor.
#[serde(rename = "visitorId")]
pub visitor_id: Option<String>,
}
impl common::ResponseResult for CaptionListResponse {}
impl common::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.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct CaptionSnippet {
/// The type of audio track associated with the caption track.
#[serde(rename = "audioTrackType")]
pub audio_track_type: Option<String>,
/// 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<String>,
/// 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<bool>,
/// 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<bool>,
/// 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<bool>,
/// 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<bool>,
/// Indicates whether the caption track uses large text for the vision-impaired. The default value is false.
#[serde(rename = "isLarge")]
pub is_large: Option<bool>,
/// The language of the caption track. The property value is a BCP-47 language tag.
pub language: Option<String>,
/// The date and time when the caption track was last updated.
#[serde(rename = "lastUpdated")]
pub last_updated: Option<chrono::DateTime<chrono::offset::Utc>>,
/// The name of the caption track. The name is intended to be visible to the user as an option during playback.
pub name: Option<String>,
/// The caption track's status.
pub status: Option<String>,
/// The caption track's type.
#[serde(rename = "trackKind")]
pub track_kind: Option<String>,
/// 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<String>,
}
impl common::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.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct CdnSettings {
/// The format of the video stream that you are sending to Youtube.
pub format: Option<String>,
/// The frame rate of the inbound video data.
#[serde(rename = "frameRate")]
pub frame_rate: Option<String>,
/// 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<IngestionInfo>,
/// The method or protocol used to transmit the video stream.
#[serde(rename = "ingestionType")]
pub ingestion_type: Option<String>,
/// The resolution of the inbound video data.
pub resolution: Option<String>,
}
impl common::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)
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::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<ChannelAuditDetails>,
/// The brandingSettings object encapsulates information about the branding of the channel.
#[serde(rename = "brandingSettings")]
pub branding_settings: Option<ChannelBrandingSettings>,
/// The contentDetails object encapsulates information about the channel's content.
#[serde(rename = "contentDetails")]
pub content_details: Option<ChannelContentDetails>,
/// The contentOwnerDetails object encapsulates channel data that is relevant for YouTube Partners linked with the channel.
#[serde(rename = "contentOwnerDetails")]
pub content_owner_details: Option<ChannelContentOwnerDetails>,
/// The conversionPings object encapsulates information about conversion pings that need to be respected by the channel.
#[serde(rename = "conversionPings")]
pub conversion_pings: Option<ChannelConversionPings>,
/// Etag of this resource.
pub etag: Option<String>,
/// The ID that YouTube uses to uniquely identify the channel.
pub id: Option<String>,
/// Identifies what kind of resource this is. Value: the fixed string "youtube#channel".
pub kind: Option<String>,
/// Localizations for different languages
pub localizations: Option<HashMap<String, ChannelLocalization>>,
/// The snippet object contains basic details about the channel, such as its title, description, and thumbnail images.
pub snippet: Option<ChannelSnippet>,
/// The statistics object encapsulates statistics for the channel.
pub statistics: Option<ChannelStatistics>,
/// The status object encapsulates information about the privacy status of the channel.
pub status: Option<ChannelStatus>,
/// The topicDetails object encapsulates information about Freebase topics associated with the channel.
#[serde(rename = "topicDetails")]
pub topic_details: Option<ChannelTopicDetails>,
}
impl common::RequestValue for Channel {}
impl common::Resource for Channel {}
impl common::ResponseResult for Channel {}
impl common::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.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct ChannelAuditDetails {
/// Whether or not the channel respects the community guidelines.
#[serde(rename = "communityGuidelinesGoodStanding")]
pub community_guidelines_good_standing: Option<bool>,
/// Whether or not the channel has any unresolved claims.
#[serde(rename = "contentIdClaimsGoodStanding")]
pub content_id_claims_good_standing: Option<bool>,
/// Whether or not the channel has any copyright strikes.
#[serde(rename = "copyrightStrikesGoodStanding")]
pub copyright_strikes_good_standing: Option<bool>,
}
impl common::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)
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct ChannelBannerResource {
/// no description provided
pub etag: Option<String>,
/// Identifies what kind of resource this is. Value: the fixed string "youtube#channelBannerResource".
pub kind: Option<String>,
/// The URL of this banner image.
pub url: Option<String>,
}
impl common::RequestValue for ChannelBannerResource {}
impl common::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.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct ChannelBrandingSettings {
/// Branding properties for the channel view.
pub channel: Option<ChannelSettings>,
/// Additional experimental branding properties.
pub hints: Option<Vec<PropertyValue>>,
/// Branding properties for branding images.
pub image: Option<ImageSettings>,
/// Branding properties for the watch page.
pub watch: Option<WatchSettings>,
}
impl common::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.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct ChannelContentDetails {
/// no description provided
#[serde(rename = "relatedPlaylists")]
pub related_playlists: Option<ChannelContentDetailsRelatedPlaylists>,
}
impl common::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.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct ChannelContentOwnerDetails {
/// The ID of the content owner linked to the channel.
#[serde(rename = "contentOwner")]
pub content_owner: Option<String>,
/// The date and time when the channel was linked to the content owner.
#[serde(rename = "timeLinked")]
pub time_linked: Option<chrono::DateTime<chrono::offset::Utc>>,
}
impl common::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.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct ChannelConversionPing {
/// Defines the context of the ping.
pub context: Option<String>,
/// 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<String>,
}
impl common::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.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::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<Vec<ChannelConversionPing>>,
}
impl common::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)
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct ChannelListResponse {
/// Etag of this resource.
pub etag: Option<String>,
/// Serialized EventId of the request which produced this response.
#[serde(rename = "eventId")]
pub event_id: Option<String>,
/// no description provided
pub items: Option<Vec<Channel>>,
/// Identifies what kind of resource this is. Value: the fixed string "youtube#channelListResponse".
pub kind: Option<String>,
/// 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<String>,
/// General pagination information.
#[serde(rename = "pageInfo")]
pub page_info: Option<PageInfo>,
/// 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<String>,
/// no description provided
#[serde(rename = "tokenPagination")]
pub token_pagination: Option<TokenPagination>,
/// The visitorId identifies the visitor.
#[serde(rename = "visitorId")]
pub visitor_id: Option<String>,
}
impl common::ResponseResult for ChannelListResponse {}
impl common::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.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct ChannelLocalization {
/// The localized strings for channel's description.
pub description: Option<String>,
/// The localized strings for channel's title.
pub title: Option<String>,
}
impl common::Part for ChannelLocalization {}
/// There is no detailed description.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct ChannelProfileDetails {
/// The YouTube channel ID.
#[serde(rename = "channelId")]
pub channel_id: Option<String>,
/// The channel's URL.
#[serde(rename = "channelUrl")]
pub channel_url: Option<String>,
/// The channel's display name.
#[serde(rename = "displayName")]
pub display_name: Option<String>,
/// The channels's avatar URL.
#[serde(rename = "profileImageUrl")]
pub profile_image_url: Option<String>,
}
impl common::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)
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::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<ChannelSectionContentDetails>,
/// Etag of this resource.
pub etag: Option<String>,
/// The ID that YouTube uses to uniquely identify the channel section.
pub id: Option<String>,
/// Identifies what kind of resource this is. Value: the fixed string "youtube#channelSection".
pub kind: Option<String>,
/// Localizations for different languages
pub localizations: Option<HashMap<String, ChannelSectionLocalization>>,
/// The snippet object contains basic details about the channel section, such as its type, style and title.
pub snippet: Option<ChannelSectionSnippet>,
/// The targeting object contains basic targeting settings about the channel section.
pub targeting: Option<ChannelSectionTargeting>,
}
impl common::RequestValue for ChannelSection {}
impl common::Resource for ChannelSection {}
impl common::ResponseResult for ChannelSection {}
impl common::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.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct ChannelSectionContentDetails {
/// The channel ids for type multiple_channels.
pub channels: Option<Vec<String>>,
/// The playlist ids for type single_playlist and multiple_playlists. For singlePlaylist, only one playlistId is allowed.
pub playlists: Option<Vec<String>>,
}
impl common::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)
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct ChannelSectionListResponse {
/// Etag of this resource.
pub etag: Option<String>,
/// Serialized EventId of the request which produced this response.
#[serde(rename = "eventId")]
pub event_id: Option<String>,
/// A list of ChannelSections that match the request criteria.
pub items: Option<Vec<ChannelSection>>,
/// Identifies what kind of resource this is. Value: the fixed string "youtube#channelSectionListResponse".
pub kind: Option<String>,
/// The visitorId identifies the visitor.
#[serde(rename = "visitorId")]
pub visitor_id: Option<String>,
}
impl common::ResponseResult for ChannelSectionListResponse {}
impl common::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.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct ChannelSectionLocalization {
/// The localized strings for channel section's title.
pub title: Option<String>,
}
impl common::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.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::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<String>,
/// The language of the channel section's default title and description.
#[serde(rename = "defaultLanguage")]
pub default_language: Option<String>,
/// Localized title, read-only.
pub localized: Option<ChannelSectionLocalization>,
/// The position of the channel section in the channel.
pub position: Option<u32>,
/// The style of the channel section.
pub style: Option<String>,
/// The channel section's title for multiple_playlists and multiple_channels.
pub title: Option<String>,
/// The type of the channel section.
#[serde(rename = "type")]
pub type_: Option<String>,
}
impl common::Part for ChannelSectionSnippet {}
/// ChannelSection targeting setting.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct ChannelSectionTargeting {
/// The country the channel section is targeting.
pub countries: Option<Vec<String>>,
/// The language the channel section is targeting.
pub languages: Option<Vec<String>>,
/// The region the channel section is targeting.
pub regions: Option<Vec<String>>,
}
impl common::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.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct ChannelSettings {
/// The country of the channel.
pub country: Option<String>,
/// no description provided
#[serde(rename = "defaultLanguage")]
pub default_language: Option<String>,
/// Which content tab users should see when viewing the channel.
#[serde(rename = "defaultTab")]
pub default_tab: Option<String>,
/// Specifies the channel description.
pub description: Option<String>,
/// Title for the featured channels tab.
#[serde(rename = "featuredChannelsTitle")]
pub featured_channels_title: Option<String>,
/// The list of featured channels.
#[serde(rename = "featuredChannelsUrls")]
pub featured_channels_urls: Option<Vec<String>>,
/// Lists keywords associated with the channel, comma-separated.
pub keywords: Option<String>,
/// 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<bool>,
/// A prominent color that can be rendered on this channel page.
#[serde(rename = "profileColor")]
pub profile_color: Option<String>,
/// Whether the tab to browse the videos should be displayed.
#[serde(rename = "showBrowseView")]
pub show_browse_view: Option<bool>,
/// Whether related channels should be proposed.
#[serde(rename = "showRelatedChannels")]
pub show_related_channels: Option<bool>,
/// Specifies the channel title.
pub title: Option<String>,
/// The ID for a Google Analytics account to track and measure traffic to the channels.
#[serde(rename = "trackingAnalyticsAccountId")]
pub tracking_analytics_account_id: Option<String>,
/// The trailer of the channel, for users that are not subscribers.
#[serde(rename = "unsubscribedTrailer")]
pub unsubscribed_trailer: Option<String>,
}
impl common::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.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct ChannelSnippet {
/// The country of the channel.
pub country: Option<String>,
/// The custom url of the channel.
#[serde(rename = "customUrl")]
pub custom_url: Option<String>,
/// The language of the channel's default title and description.
#[serde(rename = "defaultLanguage")]
pub default_language: Option<String>,
/// The description of the channel.
pub description: Option<String>,
/// Localized title and description, read-only.
pub localized: Option<ChannelLocalization>,
/// The date and time that the channel was created.
#[serde(rename = "publishedAt")]
pub published_at: Option<chrono::DateTime<chrono::offset::Utc>>,
/// 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<ThumbnailDetails>,
/// The channel's title.
pub title: Option<String>,
}
impl common::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.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct ChannelStatistics {
/// The number of comments for the channel.
#[serde(rename = "commentCount")]
#[serde_as(as = "Option<serde_with::DisplayFromStr>")]
pub comment_count: Option<u64>,
/// Whether or not the number of subscribers is shown for this user.
#[serde(rename = "hiddenSubscriberCount")]
pub hidden_subscriber_count: Option<bool>,
/// The number of subscribers that the channel has.
#[serde(rename = "subscriberCount")]
#[serde_as(as = "Option<serde_with::DisplayFromStr>")]
pub subscriber_count: Option<u64>,
/// The number of videos uploaded to the channel.
#[serde(rename = "videoCount")]
#[serde_as(as = "Option<serde_with::DisplayFromStr>")]
pub video_count: Option<u64>,
/// The number of times the channel has been viewed.
#[serde(rename = "viewCount")]
#[serde_as(as = "Option<serde_with::DisplayFromStr>")]
pub view_count: Option<u64>,
}
impl common::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.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct ChannelStatus {
/// Whether the channel is considered ypp monetization enabled. See go/yppornot for more details.
#[serde(rename = "isChannelMonetizationEnabled")]
pub is_channel_monetization_enabled: Option<bool>,
/// 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<bool>,
/// 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<String>,
/// no description provided
#[serde(rename = "madeForKids")]
pub made_for_kids: Option<bool>,
/// Privacy status of the channel.
#[serde(rename = "privacyStatus")]
pub privacy_status: Option<String>,
/// no description provided
#[serde(rename = "selfDeclaredMadeForKids")]
pub self_declared_made_for_kids: Option<bool>,
}
impl common::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.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct ChannelToStoreLinkDetails {
/// Information specific to billing (read-only).
#[serde(rename = "billingDetails")]
pub billing_details: Option<ChannelToStoreLinkDetailsBillingDetails>,
/// Information specific to merchant affiliate program (read-only).
#[serde(rename = "merchantAffiliateProgramDetails")]
pub merchant_affiliate_program_details:
Option<ChannelToStoreLinkDetailsMerchantAffiliateProgramDetails>,
/// Google Merchant Center id of the store.
#[serde(rename = "merchantId")]
#[serde_as(as = "Option<serde_with::DisplayFromStr>")]
pub merchant_id: Option<u64>,
/// Name of the store.
#[serde(rename = "storeName")]
pub store_name: Option<String>,
/// Landing page of the store.
#[serde(rename = "storeUrl")]
pub store_url: Option<String>,
}
impl common::Part for ChannelToStoreLinkDetails {}
/// Information specific to billing.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct ChannelToStoreLinkDetailsBillingDetails {
/// The current billing profile status.
#[serde(rename = "billingStatus")]
pub billing_status: Option<String>,
}
impl common::Part for ChannelToStoreLinkDetailsBillingDetails {}
/// Information specific to merchant affiliate program.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct ChannelToStoreLinkDetailsMerchantAffiliateProgramDetails {
/// The current merchant affiliate program status.
pub status: Option<String>,
}
impl common::Part for ChannelToStoreLinkDetailsMerchantAffiliateProgramDetails {}
/// Freebase topic information related to the channel.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct ChannelTopicDetails {
/// A list of Wikipedia URLs that describe the channel's content.
#[serde(rename = "topicCategories")]
pub topic_categories: Option<Vec<String>>,
/// 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<Vec<String>>,
}
impl common::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](CommentSetModerationStatuCall) (none)
/// * [update comments](CommentUpdateCall) (request|response)
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct Comment {
/// Etag of this resource.
pub etag: Option<String>,
/// The ID that YouTube uses to uniquely identify the comment.
pub id: Option<String>,
/// Identifies what kind of resource this is. Value: the fixed string "youtube#comment".
pub kind: Option<String>,
/// The snippet object contains basic details about the comment.
pub snippet: Option<CommentSnippet>,
}
impl common::RequestValue for Comment {}
impl common::Resource for Comment {}
impl common::ResponseResult for Comment {}
impl common::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)
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct CommentListResponse {
/// Etag of this resource.
pub etag: Option<String>,
/// Serialized EventId of the request which produced this response.
#[serde(rename = "eventId")]
pub event_id: Option<String>,
/// A list of comments that match the request criteria.
pub items: Option<Vec<Comment>>,
/// Identifies what kind of resource this is. Value: the fixed string "youtube#commentListResponse".
pub kind: Option<String>,
/// 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<String>,
/// General pagination information.
#[serde(rename = "pageInfo")]
pub page_info: Option<PageInfo>,
/// no description provided
#[serde(rename = "tokenPagination")]
pub token_pagination: Option<TokenPagination>,
/// The visitorId identifies the visitor.
#[serde(rename = "visitorId")]
pub visitor_id: Option<String>,
}
impl common::ResponseResult for CommentListResponse {}
impl common::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.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct CommentSnippet {
/// no description provided
#[serde(rename = "authorChannelId")]
pub author_channel_id: Option<CommentSnippetAuthorChannelId>,
/// Link to the author's YouTube channel, if any.
#[serde(rename = "authorChannelUrl")]
pub author_channel_url: Option<String>,
/// The name of the user who posted the comment.
#[serde(rename = "authorDisplayName")]
pub author_display_name: Option<String>,
/// The URL for the avatar of the user who posted the comment.
#[serde(rename = "authorProfileImageUrl")]
pub author_profile_image_url: Option<String>,
/// Whether the current viewer can rate this comment.
#[serde(rename = "canRate")]
pub can_rate: Option<bool>,
/// 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 or post comment it's the video/post's channel.
#[serde(rename = "channelId")]
pub channel_id: Option<String>,
/// The total number of likes this comment has received.
#[serde(rename = "likeCount")]
pub like_count: Option<u32>,
/// 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<String>,
/// The unique id of the top-level comment, only set for replies.
#[serde(rename = "parentId")]
pub parent_id: Option<String>,
/// The ID of the post the comment refers to, if any.
#[serde(rename = "postId")]
pub post_id: Option<String>,
/// The date and time when the comment was originally published.
#[serde(rename = "publishedAt")]
pub published_at: Option<chrono::DateTime<chrono::offset::Utc>>,
/// 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<String>,
/// 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<String>,
/// The date and time when the comment was last updated.
#[serde(rename = "updatedAt")]
pub updated_at: Option<chrono::DateTime<chrono::offset::Utc>>,
/// The ID of the video the comment refers to, if any.
#[serde(rename = "videoId")]
pub video_id: Option<String>,
/// 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<String>,
}
impl common::Part for CommentSnippet {}
/// Contains 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.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct CommentSnippetAuthorChannelId {
/// The id of the author's YouTube channel.
pub value: Option<String>,
}
impl common::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)
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct CommentThread {
/// Etag of this resource.
pub etag: Option<String>,
/// The ID that YouTube uses to uniquely identify the comment thread.
pub id: Option<String>,
/// Identifies what kind of resource this is. Value: the fixed string "youtube#commentThread".
pub kind: Option<String>,
/// The replies object contains a limited number of replies (if any) to the top level comment found in the snippet.
pub replies: Option<CommentThreadReplies>,
/// The snippet object contains basic details about the comment thread and also the top level comment.
pub snippet: Option<CommentThreadSnippet>,
}
impl common::RequestValue for CommentThread {}
impl common::Resource for CommentThread {}
impl common::ResponseResult for CommentThread {}
impl common::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)
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct CommentThreadListResponse {
/// Etag of this resource.
pub etag: Option<String>,
/// Serialized EventId of the request which produced this response.
#[serde(rename = "eventId")]
pub event_id: Option<String>,
/// A list of comment threads that match the request criteria.
pub items: Option<Vec<CommentThread>>,
/// Identifies what kind of resource this is. Value: the fixed string "youtube#commentThreadListResponse".
pub kind: Option<String>,
/// 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<String>,
/// General pagination information.
#[serde(rename = "pageInfo")]
pub page_info: Option<PageInfo>,
/// no description provided
#[serde(rename = "tokenPagination")]
pub token_pagination: Option<TokenPagination>,
/// The visitorId identifies the visitor.
#[serde(rename = "visitorId")]
pub visitor_id: Option<String>,
}
impl common::ResponseResult for CommentThreadListResponse {}
impl common::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.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::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<Vec<Comment>>,
}
impl common::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.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::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<bool>,
/// The YouTube channel the comments in the thread refer to or the channel with the video the comments refer to. If neither video_id nor post_id is set the comments refer to the channel itself.
#[serde(rename = "channelId")]
pub channel_id: Option<String>,
/// Whether the thread (and therefore all its comments) is visible to all YouTube users.
#[serde(rename = "isPublic")]
pub is_public: Option<bool>,
/// The ID of the post the comments refer to, if any.
#[serde(rename = "postId")]
pub post_id: Option<String>,
/// The top level comment of this thread.
#[serde(rename = "topLevelComment")]
pub top_level_comment: Option<Comment>,
/// The total number of replies (not including the top level comment).
#[serde(rename = "totalReplyCount")]
pub total_reply_count: Option<u32>,
/// The ID of the video the comments refer to, if any.
#[serde(rename = "videoId")]
pub video_id: Option<String>,
}
impl common::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.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::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<String>,
/// The video's rating from Italy's Autorità per le Garanzie nelle Comunicazioni (AGCOM).
#[serde(rename = "agcomRating")]
pub agcom_rating: Option<String>,
/// The video's Anatel (Asociación Nacional de Televisión) rating for Chilean television.
#[serde(rename = "anatelRating")]
pub anatel_rating: Option<String>,
/// The video's British Board of Film Classification (BBFC) rating.
#[serde(rename = "bbfcRating")]
pub bbfc_rating: Option<String>,
/// The video's rating from Thailand's Board of Film and Video Censors.
#[serde(rename = "bfvcRating")]
pub bfvc_rating: Option<String>,
/// 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<String>,
/// 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<String>,
/// 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<String>,
/// The video's Central Board of Film Certification (CBFC - India) rating.
#[serde(rename = "cbfcRating")]
pub cbfc_rating: Option<String>,
/// The video's Consejo de Calificación Cinematográfica (Chile) rating.
#[serde(rename = "cccRating")]
pub ccc_rating: Option<String>,
/// The video's rating from Portugal's Comissão de Classificação de Espect´culos.
#[serde(rename = "cceRating")]
pub cce_rating: Option<String>,
/// The video's rating in Switzerland.
#[serde(rename = "chfilmRating")]
pub chfilm_rating: Option<String>,
/// The video's Canadian Home Video Rating System (CHVRS) rating.
#[serde(rename = "chvrsRating")]
pub chvrs_rating: Option<String>,
/// The video's rating from the Commission de Contrôle des Films (Belgium).
#[serde(rename = "cicfRating")]
pub cicf_rating: Option<String>,
/// The video's rating from Romania's CONSILIUL NATIONAL AL AUDIOVIZUALULUI (CNA).
#[serde(rename = "cnaRating")]
pub cna_rating: Option<String>,
/// Rating system in France - Commission de classification cinematographique
#[serde(rename = "cncRating")]
pub cnc_rating: Option<String>,
/// The video's rating from France's Conseil supérieur de l’audiovisuel, which rates broadcast content.
#[serde(rename = "csaRating")]
pub csa_rating: Option<String>,
/// The video's rating from Luxembourg's Commission de surveillance de la classification des films (CSCF).
#[serde(rename = "cscfRating")]
pub cscf_rating: Option<String>,
/// The video's rating in the Czech Republic.
#[serde(rename = "czfilmRating")]
pub czfilm_rating: Option<String>,
/// The video's Departamento de Justiça, Classificação, Qualificação e Títulos (DJCQT - Brazil) rating.
#[serde(rename = "djctqRating")]
pub djctq_rating: Option<String>,
/// Reasons that explain why the video received its DJCQT (Brazil) rating.
#[serde(rename = "djctqRatingReasons")]
pub djctq_rating_reasons: Option<Vec<String>>,
/// Rating system in Turkey - Evaluation and Classification Board of the Ministry of Culture and Tourism
#[serde(rename = "ecbmctRating")]
pub ecbmct_rating: Option<String>,
/// The video's rating in Estonia.
#[serde(rename = "eefilmRating")]
pub eefilm_rating: Option<String>,
/// The video's rating in Egypt.
#[serde(rename = "egfilmRating")]
pub egfilm_rating: Option<String>,
/// The video's Eirin (映倫) rating. Eirin is the Japanese rating system.
#[serde(rename = "eirinRating")]
pub eirin_rating: Option<String>,
/// The video's rating from Malaysia's Film Censorship Board.
#[serde(rename = "fcbmRating")]
pub fcbm_rating: Option<String>,
/// The video's rating from Hong Kong's Office for Film, Newspaper and Article Administration.
#[serde(rename = "fcoRating")]
pub fco_rating: Option<String>,
/// This property has been deprecated. Use the contentDetails.contentRating.cncRating instead.
#[serde(rename = "fmocRating")]
pub fmoc_rating: Option<String>,
/// The video's rating from South Africa's Film and Publication Board.
#[serde(rename = "fpbRating")]
pub fpb_rating: Option<String>,
/// Reasons that explain why the video received its FPB (South Africa) rating.
#[serde(rename = "fpbRatingReasons")]
pub fpb_rating_reasons: Option<Vec<String>>,
/// The video's Freiwillige Selbstkontrolle der Filmwirtschaft (FSK - Germany) rating.
#[serde(rename = "fskRating")]
pub fsk_rating: Option<String>,
/// The video's rating in Greece.
#[serde(rename = "grfilmRating")]
pub grfilm_rating: Option<String>,
/// The video's Instituto de la Cinematografía y de las Artes Audiovisuales (ICAA - Spain) rating.
#[serde(rename = "icaaRating")]
pub icaa_rating: Option<String>,
/// The video's Irish Film Classification Office (IFCO - Ireland) rating. See the IFCO website for more information.
#[serde(rename = "ifcoRating")]
pub ifco_rating: Option<String>,
/// The video's rating in Israel.
#[serde(rename = "ilfilmRating")]
pub ilfilm_rating: Option<String>,
/// The video's INCAA (Instituto Nacional de Cine y Artes Audiovisuales - Argentina) rating.
#[serde(rename = "incaaRating")]
pub incaa_rating: Option<String>,
/// The video's rating from the Kenya Film Classification Board.
#[serde(rename = "kfcbRating")]
pub kfcb_rating: Option<String>,
/// The video's NICAM/Kijkwijzer rating from the Nederlands Instituut voor de Classificatie van Audiovisuele Media (Netherlands).
#[serde(rename = "kijkwijzerRating")]
pub kijkwijzer_rating: Option<String>,
/// The video's Korea Media Rating Board (영상물등급위원회) rating. The KMRB rates videos in South Korea.
#[serde(rename = "kmrbRating")]
pub kmrb_rating: Option<String>,
/// The video's rating from Indonesia's Lembaga Sensor Film.
#[serde(rename = "lsfRating")]
pub lsf_rating: Option<String>,
/// The video's rating from Malta's Film Age-Classification Board.
#[serde(rename = "mccaaRating")]
pub mccaa_rating: Option<String>,
/// 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<String>,
/// The video's rating system for Vietnam - MCST
#[serde(rename = "mcstRating")]
pub mcst_rating: Option<String>,
/// 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<String>,
/// The video's rating from Medietilsynet, the Norwegian Media Authority.
#[serde(rename = "medietilsynetRating")]
pub medietilsynet_rating: Option<String>,
/// The video's rating from Finland's Kansallinen Audiovisuaalinen Instituutti (National Audiovisual Institute).
#[serde(rename = "mekuRating")]
pub meku_rating: Option<String>,
/// 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<String>,
/// The video's rating from the Ministero dei Beni e delle Attività Culturali e del Turismo (Italy).
#[serde(rename = "mibacRating")]
pub mibac_rating: Option<String>,
/// The video's Ministerio de Cultura (Colombia) rating.
#[serde(rename = "mocRating")]
pub moc_rating: Option<String>,
/// The video's rating from Taiwan's Ministry of Culture (文化部).
#[serde(rename = "moctwRating")]
pub moctw_rating: Option<String>,
/// The video's Motion Picture Association of America (MPAA) rating.
#[serde(rename = "mpaaRating")]
pub mpaa_rating: Option<String>,
/// 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<String>,
/// The video's rating from the Movie and Television Review and Classification Board (Philippines).
#[serde(rename = "mtrcbRating")]
pub mtrcb_rating: Option<String>,
/// The video's rating from the Maldives National Bureau of Classification.
#[serde(rename = "nbcRating")]
pub nbc_rating: Option<String>,
/// The video's rating in Poland.
#[serde(rename = "nbcplRating")]
pub nbcpl_rating: Option<String>,
/// The video's rating from the Bulgarian National Film Center.
#[serde(rename = "nfrcRating")]
pub nfrc_rating: Option<String>,
/// The video's rating from Nigeria's National Film and Video Censors Board.
#[serde(rename = "nfvcbRating")]
pub nfvcb_rating: Option<String>,
/// The video's rating from the Nacionãlais Kino centrs (National Film Centre of Latvia).
#[serde(rename = "nkclvRating")]
pub nkclv_rating: Option<String>,
/// The National Media Council ratings system for United Arab Emirates.
#[serde(rename = "nmcRating")]
pub nmc_rating: Option<String>,
/// The video's Office of Film and Literature Classification (OFLC - New Zealand) rating.
#[serde(rename = "oflcRating")]
pub oflc_rating: Option<String>,
/// The video's rating in Peru.
#[serde(rename = "pefilmRating")]
pub pefilm_rating: Option<String>,
/// 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<String>,
/// The video's rating in Venezuela.
#[serde(rename = "resorteviolenciaRating")]
pub resorteviolencia_rating: Option<String>,
/// The video's General Directorate of Radio, Television and Cinematography (Mexico) rating.
#[serde(rename = "rtcRating")]
pub rtc_rating: Option<String>,
/// The video's rating from Ireland's Raidió Teilifís Éireann.
#[serde(rename = "rteRating")]
pub rte_rating: Option<String>,
/// The video's National Film Registry of the Russian Federation (MKRF - Russia) rating.
#[serde(rename = "russiaRating")]
pub russia_rating: Option<String>,
/// The video's rating in Slovakia.
#[serde(rename = "skfilmRating")]
pub skfilm_rating: Option<String>,
/// The video's rating in Iceland.
#[serde(rename = "smaisRating")]
pub smais_rating: Option<String>,
/// The video's rating from Statens medieråd (Sweden's National Media Council).
#[serde(rename = "smsaRating")]
pub smsa_rating: Option<String>,
/// The video's TV Parental Guidelines (TVPG) rating.
#[serde(rename = "tvpgRating")]
pub tvpg_rating: Option<String>,
/// A rating that YouTube uses to identify age-restricted content.
#[serde(rename = "ytRating")]
pub yt_rating: Option<String>,
}
impl common::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)
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct Cuepoint {
/// no description provided
#[serde(rename = "cueType")]
pub cue_type: Option<String>,
/// The duration of this cuepoint.
#[serde(rename = "durationSecs")]
pub duration_secs: Option<u32>,
/// no description provided
pub etag: Option<String>,
/// The identifier for cuepoint resource.
pub id: Option<String>,
/// The time when the cuepoint should be inserted by offset to the broadcast actual start time.
#[serde(rename = "insertionOffsetTimeMs")]
#[serde_as(as = "Option<serde_with::DisplayFromStr>")]
pub insertion_offset_time_ms: Option<i64>,
/// 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<serde_with::DisplayFromStr>")]
pub walltime_ms: Option<u64>,
}
impl common::RequestValue for Cuepoint {}
impl common::ResponseResult for Cuepoint {}
impl common::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.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::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<bool>,
/// 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<String>,
/// Interval frequency in seconds that api uses to insert cuepoints automatically.
#[serde(rename = "repeatIntervalSecs")]
pub repeat_interval_secs: Option<i32>,
/// The strategy to use when scheduling cuepoints.
#[serde(rename = "scheduleStrategy")]
pub schedule_strategy: Option<String>,
}
impl common::Part for CuepointSchedule {}
/// There is no detailed description.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct Entity {
/// no description provided
pub id: Option<String>,
/// no description provided
#[serde(rename = "typeId")]
pub type_id: Option<String>,
/// no description provided
pub url: Option<String>,
}
impl common::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.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct GeoPoint {
/// Altitude above the reference ellipsoid, in meters.
pub altitude: Option<f64>,
/// Latitude in degrees.
pub latitude: Option<f64>,
/// Longitude in degrees.
pub longitude: Option<f64>,
}
impl common::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)
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct I18nLanguage {
/// Etag of this resource.
pub etag: Option<String>,
/// The ID that YouTube uses to uniquely identify the i18n language.
pub id: Option<String>,
/// Identifies what kind of resource this is. Value: the fixed string "youtube#i18nLanguage".
pub kind: Option<String>,
/// The snippet object contains basic details about the i18n language, such as language code and human-readable name.
pub snippet: Option<I18nLanguageSnippet>,
}
impl common::Resource for I18nLanguage {}
impl common::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)
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct I18nLanguageListResponse {
/// Etag of this resource.
pub etag: Option<String>,
/// Serialized EventId of the request which produced this response.
#[serde(rename = "eventId")]
pub event_id: Option<String>,
/// 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<Vec<I18nLanguage>>,
/// Identifies what kind of resource this is. Value: the fixed string "youtube#i18nLanguageListResponse".
pub kind: Option<String>,
/// The visitorId identifies the visitor.
#[serde(rename = "visitorId")]
pub visitor_id: Option<String>,
}
impl common::ResponseResult for I18nLanguageListResponse {}
impl common::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.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct I18nLanguageSnippet {
/// A short BCP-47 code that uniquely identifies a language.
pub hl: Option<String>,
/// The human-readable name of the language in the language itself.
pub name: Option<String>,
}
impl common::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)
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct I18nRegion {
/// Etag of this resource.
pub etag: Option<String>,
/// The ID that YouTube uses to uniquely identify the i18n region.
pub id: Option<String>,
/// Identifies what kind of resource this is. Value: the fixed string "youtube#i18nRegion".
pub kind: Option<String>,
/// The snippet object contains basic details about the i18n region, such as region code and human-readable name.
pub snippet: Option<I18nRegionSnippet>,
}
impl common::Resource for I18nRegion {}
impl common::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)
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct I18nRegionListResponse {
/// Etag of this resource.
pub etag: Option<String>,
/// Serialized EventId of the request which produced this response.
#[serde(rename = "eventId")]
pub event_id: Option<String>,
/// 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<Vec<I18nRegion>>,
/// Identifies what kind of resource this is. Value: the fixed string "youtube#i18nRegionListResponse".
pub kind: Option<String>,
/// The visitorId identifies the visitor.
#[serde(rename = "visitorId")]
pub visitor_id: Option<String>,
}
impl common::ResponseResult for I18nRegionListResponse {}
impl common::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.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct I18nRegionSnippet {
/// The region code as a 2-letter ISO country code.
pub gl: Option<String>,
/// The human-readable name of the region.
pub name: Option<String>,
}
impl common::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.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::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<LocalizedProperty>,
/// This is generated when a ChannelBanner.Insert request has succeeded for the given channel.
#[serde(rename = "bannerExternalUrl")]
pub banner_external_url: Option<String>,
/// Banner image. Desktop size (1060x175).
#[serde(rename = "bannerImageUrl")]
pub banner_image_url: Option<String>,
/// Banner image. Mobile size high resolution (1440x395).
#[serde(rename = "bannerMobileExtraHdImageUrl")]
pub banner_mobile_extra_hd_image_url: Option<String>,
/// Banner image. Mobile size high resolution (1280x360).
#[serde(rename = "bannerMobileHdImageUrl")]
pub banner_mobile_hd_image_url: Option<String>,
/// Banner image. Mobile size (640x175).
#[serde(rename = "bannerMobileImageUrl")]
pub banner_mobile_image_url: Option<String>,
/// Banner image. Mobile size low resolution (320x88).
#[serde(rename = "bannerMobileLowImageUrl")]
pub banner_mobile_low_image_url: Option<String>,
/// Banner image. Mobile size medium/high resolution (960x263).
#[serde(rename = "bannerMobileMediumHdImageUrl")]
pub banner_mobile_medium_hd_image_url: Option<String>,
/// Banner image. Tablet size extra high resolution (2560x424).
#[serde(rename = "bannerTabletExtraHdImageUrl")]
pub banner_tablet_extra_hd_image_url: Option<String>,
/// Banner image. Tablet size high resolution (2276x377).
#[serde(rename = "bannerTabletHdImageUrl")]
pub banner_tablet_hd_image_url: Option<String>,
/// Banner image. Tablet size (1707x283).
#[serde(rename = "bannerTabletImageUrl")]
pub banner_tablet_image_url: Option<String>,
/// Banner image. Tablet size low resolution (1138x188).
#[serde(rename = "bannerTabletLowImageUrl")]
pub banner_tablet_low_image_url: Option<String>,
/// Banner image. TV size high resolution (1920x1080).
#[serde(rename = "bannerTvHighImageUrl")]
pub banner_tv_high_image_url: Option<String>,
/// Banner image. TV size extra high resolution (2120x1192).
#[serde(rename = "bannerTvImageUrl")]
pub banner_tv_image_url: Option<String>,
/// Banner image. TV size low resolution (854x480).
#[serde(rename = "bannerTvLowImageUrl")]
pub banner_tv_low_image_url: Option<String>,
/// Banner image. TV size medium resolution (1280x720).
#[serde(rename = "bannerTvMediumImageUrl")]
pub banner_tv_medium_image_url: Option<String>,
/// The image map script for the large banner image.
#[serde(rename = "largeBrandedBannerImageImapScript")]
pub large_branded_banner_image_imap_script: Option<LocalizedProperty>,
/// 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<LocalizedProperty>,
/// The image map script for the small banner image.
#[serde(rename = "smallBrandedBannerImageImapScript")]
pub small_branded_banner_image_imap_script: Option<LocalizedProperty>,
/// 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<LocalizedProperty>,
/// 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<String>,
/// no description provided
#[serde(rename = "watchIconImageUrl")]
pub watch_icon_image_url: Option<String>,
}
impl common::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.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::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<String>,
/// 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<String>,
/// 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<String>,
/// 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<String>,
/// The stream name that YouTube assigns to the video stream.
#[serde(rename = "streamName")]
pub stream_name: Option<String>,
}
impl common::Part for IngestionInfo {}
/// 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)
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct InvideoBranding {
/// The bytes the uploaded image. Only used in api to youtube communication.
#[serde(rename = "imageBytes")]
#[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
pub image_bytes: Option<Vec<u8>>,
/// The url of the uploaded image. Only used in apiary to api communication.
#[serde(rename = "imageUrl")]
pub image_url: Option<String>,
/// The spatial position within the video where the branding watermark will be displayed.
pub position: Option<InvideoPosition>,
/// The channel to which this branding links. If not present it defaults to the current channel.
#[serde(rename = "targetChannelId")]
pub target_channel_id: Option<String>,
/// The temporal position within the video where watermark will be displayed.
pub timing: Option<InvideoTiming>,
}
impl common::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.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct InvideoPosition {
/// Describes in which corner of the video the visual widget will appear.
#[serde(rename = "cornerPosition")]
pub corner_position: Option<String>,
/// Defines the position type.
#[serde(rename = "type")]
pub type_: Option<String>,
}
impl common::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.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::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<serde_with::DisplayFromStr>")]
pub duration_ms: Option<u64>,
/// 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<serde_with::DisplayFromStr>")]
pub offset_ms: Option<u64>,
/// 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<String>,
}
impl common::Part for InvideoTiming {}
/// There is no detailed description.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct LanguageTag {
/// no description provided
pub value: Option<String>,
}
impl common::Part for LanguageTag {}
/// There is no detailed description.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct LevelDetails {
/// The name that should be used when referring to this level.
#[serde(rename = "displayName")]
pub display_name: Option<String>,
}
impl common::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)
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::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<LiveBroadcastContentDetails>,
/// Etag of this resource.
pub etag: Option<String>,
/// The ID that YouTube assigns to uniquely identify the broadcast.
pub id: Option<String>,
/// Identifies what kind of resource this is. Value: the fixed string "youtube#liveBroadcast".
pub kind: Option<String>,
/// The monetizationDetails object contains information about the event's monetization details.
#[serde(rename = "monetizationDetails")]
pub monetization_details: Option<LiveBroadcastMonetizationDetails>,
/// The snippet object contains basic details about the event, including its title, description, start time, and end time.
pub snippet: Option<LiveBroadcastSnippet>,
/// 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<LiveBroadcastStatistics>,
/// The status object contains information about the event's status.
pub status: Option<LiveBroadcastStatus>,
}
impl common::RequestValue for LiveBroadcast {}
impl common::Resource for LiveBroadcast {}
impl common::ResponseResult for LiveBroadcast {}
impl common::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.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct LiveBroadcastContentDetails {
/// This value uniquely identifies the live stream bound to the broadcast.
#[serde(rename = "boundStreamId")]
pub bound_stream_id: Option<String>,
/// 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<chrono::DateTime<chrono::offset::Utc>>,
/// no description provided
#[serde(rename = "closedCaptionsType")]
pub closed_captions_type: Option<String>,
/// 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<bool>,
/// 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<bool>,
/// 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<bool>,
/// This setting indicates whether YouTube should enable content encryption for the broadcast.
#[serde(rename = "enableContentEncryption")]
pub enable_content_encryption: Option<bool>,
/// 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<bool>,
/// 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<bool>,
/// Indicates whether this broadcast has low latency enabled.
#[serde(rename = "enableLowLatency")]
pub enable_low_latency: Option<bool>,
/// 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<String>,
/// 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<common::serde::standard_base64::Wrapper>")]
pub mesh: Option<Vec<u8>>,
/// 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<MonitorStreamInfo>,
/// The projection format of this broadcast. This defaults to rectangular.
pub projection: Option<String>,
/// 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<bool>,
/// 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<bool>,
/// The 3D stereo layout of this broadcast. This defaults to mono.
#[serde(rename = "stereoLayout")]
pub stereo_layout: Option<String>,
}
impl common::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)
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct LiveBroadcastListResponse {
/// Etag of this resource.
pub etag: Option<String>,
/// Serialized EventId of the request which produced this response.
#[serde(rename = "eventId")]
pub event_id: Option<String>,
/// A list of broadcasts that match the request criteria.
pub items: Option<Vec<LiveBroadcast>>,
/// Identifies what kind of resource this is. Value: the fixed string "youtube#liveBroadcastListResponse".
pub kind: Option<String>,
/// 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<String>,
/// General pagination information.
#[serde(rename = "pageInfo")]
pub page_info: Option<PageInfo>,
/// 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<String>,
/// no description provided
#[serde(rename = "tokenPagination")]
pub token_pagination: Option<TokenPagination>,
/// The visitorId identifies the visitor.
#[serde(rename = "visitorId")]
pub visitor_id: Option<String>,
}
impl common::ResponseResult for LiveBroadcastListResponse {}
impl common::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.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct LiveBroadcastMonetizationDetails {
/// no description provided
#[serde(rename = "cuepointSchedule")]
pub cuepoint_schedule: Option<CuepointSchedule>,
}
impl common::Part for LiveBroadcastMonetizationDetails {}
/// Basic broadcast information.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::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<chrono::DateTime<chrono::offset::Utc>>,
/// 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<chrono::DateTime<chrono::offset::Utc>>,
/// The ID that YouTube uses to uniquely identify the channel that is publishing the broadcast.
#[serde(rename = "channelId")]
pub channel_id: Option<String>,
/// 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<String>,
/// Indicates whether this broadcast is the default broadcast. Internal only.
#[serde(rename = "isDefaultBroadcast")]
pub is_default_broadcast: Option<bool>,
/// The id of the live chat for this broadcast.
#[serde(rename = "liveChatId")]
pub live_chat_id: Option<String>,
/// The date and time that the broadcast was added to YouTube's live broadcast schedule.
#[serde(rename = "publishedAt")]
pub published_at: Option<chrono::DateTime<chrono::offset::Utc>>,
/// The date and time that the broadcast is scheduled to end.
#[serde(rename = "scheduledEndTime")]
pub scheduled_end_time: Option<chrono::DateTime<chrono::offset::Utc>>,
/// The date and time that the broadcast is scheduled to start.
#[serde(rename = "scheduledStartTime")]
pub scheduled_start_time: Option<chrono::DateTime<chrono::offset::Utc>>,
/// 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<ThumbnailDetails>,
/// 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<String>,
}
impl common::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.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::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<serde_with::DisplayFromStr>")]
pub concurrent_viewers: Option<u64>,
}
impl common::Part for LiveBroadcastStatistics {}
/// Live broadcast state.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::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<String>,
/// Priority of the live broadcast event (internal state).
#[serde(rename = "liveBroadcastPriority")]
pub live_broadcast_priority: Option<String>,
/// 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<bool>,
/// 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<String>,
/// The broadcast's recording status.
#[serde(rename = "recordingStatus")]
pub recording_status: Option<String>,
/// 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<bool>,
}
impl common::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)
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct LiveChatBan {
/// Etag of this resource.
pub etag: Option<String>,
/// The ID that YouTube assigns to uniquely identify the ban.
pub id: Option<String>,
/// Identifies what kind of resource this is. Value: the fixed string `"youtube#liveChatBan"`.
pub kind: Option<String>,
/// The `snippet` object contains basic details about the ban.
pub snippet: Option<LiveChatBanSnippet>,
}
impl common::RequestValue for LiveChatBan {}
impl common::Resource for LiveChatBan {}
impl common::ResponseResult for LiveChatBan {}
impl common::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.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct LiveChatBanSnippet {
/// The duration of a ban, only filled if the ban has type TEMPORARY.
#[serde(rename = "banDurationSeconds")]
#[serde_as(as = "Option<serde_with::DisplayFromStr>")]
pub ban_duration_seconds: Option<u64>,
/// no description provided
#[serde(rename = "bannedUserDetails")]
pub banned_user_details: Option<ChannelProfileDetails>,
/// The chat this ban is pertinent to.
#[serde(rename = "liveChatId")]
pub live_chat_id: Option<String>,
/// The type of ban.
#[serde(rename = "type")]
pub type_: Option<String>,
}
impl common::Part for LiveChatBanSnippet {}
/// There is no detailed description.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::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<String>,
/// The amount of the fund.
#[serde(rename = "amountMicros")]
#[serde_as(as = "Option<serde_with::DisplayFromStr>")]
pub amount_micros: Option<u64>,
/// The currency in which the fund was made.
pub currency: Option<String>,
/// The comment added by the user to this fan funding event.
#[serde(rename = "userComment")]
pub user_comment: Option<String>,
}
impl common::Part for LiveChatFanFundingEventDetails {}
/// There is no detailed description.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::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<String>,
/// 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<String>,
/// 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<String>,
}
impl common::Part for LiveChatGiftMembershipReceivedDetails {}
/// There is no detailed description.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::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<String>,
/// 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<u32>,
/// 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<String>,
}
impl common::Part for LiveChatMemberMilestoneChatDetails {}
/// There is no detailed description.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct LiveChatMembershipGiftingDetails {
/// The number of gift memberships purchased by the user.
#[serde(rename = "giftMembershipsCount")]
pub gift_memberships_count: Option<i32>,
/// 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<String>,
}
impl common::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)
/// * [transition live chat messages](LiveChatMessageTransitionCall) (response)
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct LiveChatMessage {
/// The authorDetails object contains basic details about the user that posted this message.
#[serde(rename = "authorDetails")]
pub author_details: Option<LiveChatMessageAuthorDetails>,
/// Etag of this resource.
pub etag: Option<String>,
/// The ID that YouTube assigns to uniquely identify the message.
pub id: Option<String>,
/// Identifies what kind of resource this is. Value: the fixed string "youtube#liveChatMessage".
pub kind: Option<String>,
/// The snippet object contains basic details about the message.
pub snippet: Option<LiveChatMessageSnippet>,
}
impl common::RequestValue for LiveChatMessage {}
impl common::Resource for LiveChatMessage {}
impl common::ResponseResult for LiveChatMessage {}
impl common::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.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct LiveChatMessageAuthorDetails {
/// The YouTube channel ID.
#[serde(rename = "channelId")]
pub channel_id: Option<String>,
/// The channel's URL.
#[serde(rename = "channelUrl")]
pub channel_url: Option<String>,
/// The channel's display name.
#[serde(rename = "displayName")]
pub display_name: Option<String>,
/// Whether the author is a moderator of the live chat.
#[serde(rename = "isChatModerator")]
pub is_chat_moderator: Option<bool>,
/// Whether the author is the owner of the live chat.
#[serde(rename = "isChatOwner")]
pub is_chat_owner: Option<bool>,
/// Whether the author is a sponsor of the live chat.
#[serde(rename = "isChatSponsor")]
pub is_chat_sponsor: Option<bool>,
/// Whether the author's identity has been verified by YouTube.
#[serde(rename = "isVerified")]
pub is_verified: Option<bool>,
/// The channels's avatar URL.
#[serde(rename = "profileImageUrl")]
pub profile_image_url: Option<String>,
}
impl common::Part for LiveChatMessageAuthorDetails {}
/// There is no detailed description.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct LiveChatMessageDeletedDetails {
/// no description provided
#[serde(rename = "deletedMessageId")]
pub deleted_message_id: Option<String>,
}
impl common::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)
/// * [v3 live chat messages stream youtube](YoutubeV3LiveChatMessageStreamCall) (response)
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct LiveChatMessageListResponse {
/// Set when there is an active poll.
#[serde(rename = "activePollItem")]
pub active_poll_item: Option<LiveChatMessage>,
/// Etag of this resource.
pub etag: Option<String>,
/// Serialized EventId of the request which produced this response.
#[serde(rename = "eventId")]
pub event_id: Option<String>,
/// no description provided
pub items: Option<Vec<LiveChatMessage>>,
/// Identifies what kind of resource this is. Value: the fixed string "youtube#liveChatMessageListResponse".
pub kind: Option<String>,
/// no description provided
#[serde(rename = "nextPageToken")]
pub next_page_token: Option<String>,
/// The date and time when the underlying stream went offline.
#[serde(rename = "offlineAt")]
pub offline_at: Option<chrono::DateTime<chrono::offset::Utc>>,
/// General pagination information.
#[serde(rename = "pageInfo")]
pub page_info: Option<PageInfo>,
/// The amount of time the client should wait before polling again.
#[serde(rename = "pollingIntervalMillis")]
pub polling_interval_millis: Option<u32>,
/// no description provided
#[serde(rename = "tokenPagination")]
pub token_pagination: Option<TokenPagination>,
/// The visitorId identifies the visitor.
#[serde(rename = "visitorId")]
pub visitor_id: Option<String>,
}
impl common::ResponseResult for LiveChatMessageListResponse {}
impl common::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.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct LiveChatMessageRetractedDetails {
/// no description provided
#[serde(rename = "retractedMessageId")]
pub retracted_message_id: Option<String>,
}
impl common::Part for LiveChatMessageRetractedDetails {}
/// Next ID: 34
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::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<String>,
/// 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<String>,
/// Details about the funding event, this is only set if the type is 'fanFundingEvent'.
#[serde(rename = "fanFundingEventDetails")]
pub fan_funding_event_details: Option<LiveChatFanFundingEventDetails>,
/// 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<LiveChatGiftMembershipReceivedDetails>,
/// Whether the message has display content that should be displayed to users.
#[serde(rename = "hasDisplayContent")]
pub has_display_content: Option<bool>,
/// no description provided
#[serde(rename = "liveChatId")]
pub live_chat_id: Option<String>,
/// 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<LiveChatMemberMilestoneChatDetails>,
/// Details about the Membership Gifting event, this is only set if the type is 'membershipGiftingEvent'.
#[serde(rename = "membershipGiftingDetails")]
pub membership_gifting_details: Option<LiveChatMembershipGiftingDetails>,
/// no description provided
#[serde(rename = "messageDeletedDetails")]
pub message_deleted_details: Option<LiveChatMessageDeletedDetails>,
/// no description provided
#[serde(rename = "messageRetractedDetails")]
pub message_retracted_details: Option<LiveChatMessageRetractedDetails>,
/// 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<LiveChatNewSponsorDetails>,
/// Details about the poll event, this is only set if the type is 'pollEvent'.
#[serde(rename = "pollDetails")]
pub poll_details: Option<LiveChatPollDetails>,
/// The date and time when the message was orignally published.
#[serde(rename = "publishedAt")]
pub published_at: Option<chrono::DateTime<chrono::offset::Utc>>,
/// Details about the Super Chat event, this is only set if the type is 'superChatEvent'.
#[serde(rename = "superChatDetails")]
pub super_chat_details: Option<LiveChatSuperChatDetails>,
/// Details about the Super Sticker event, this is only set if the type is 'superStickerEvent'.
#[serde(rename = "superStickerDetails")]
pub super_sticker_details: Option<LiveChatSuperStickerDetails>,
/// Details about the text message, this is only set if the type is 'textMessageEvent'.
#[serde(rename = "textMessageDetails")]
pub text_message_details: Option<LiveChatTextMessageDetails>,
/// 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<String>,
/// no description provided
#[serde(rename = "userBannedDetails")]
pub user_banned_details: Option<LiveChatUserBannedMessageDetails>,
}
impl common::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)
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct LiveChatModerator {
/// Etag of this resource.
pub etag: Option<String>,
/// The ID that YouTube assigns to uniquely identify the moderator.
pub id: Option<String>,
/// Identifies what kind of resource this is. Value: the fixed string "youtube#liveChatModerator".
pub kind: Option<String>,
/// The snippet object contains basic details about the moderator.
pub snippet: Option<LiveChatModeratorSnippet>,
}
impl common::RequestValue for LiveChatModerator {}
impl common::Resource for LiveChatModerator {}
impl common::ResponseResult for LiveChatModerator {}
impl common::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)
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct LiveChatModeratorListResponse {
/// Etag of this resource.
pub etag: Option<String>,
/// Serialized EventId of the request which produced this response.
#[serde(rename = "eventId")]
pub event_id: Option<String>,
/// A list of moderators that match the request criteria.
pub items: Option<Vec<LiveChatModerator>>,
/// Identifies what kind of resource this is. Value: the fixed string "youtube#liveChatModeratorListResponse".
pub kind: Option<String>,
/// 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<String>,
/// General pagination information.
#[serde(rename = "pageInfo")]
pub page_info: Option<PageInfo>,
/// 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<String>,
/// no description provided
#[serde(rename = "tokenPagination")]
pub token_pagination: Option<TokenPagination>,
/// The visitorId identifies the visitor.
#[serde(rename = "visitorId")]
pub visitor_id: Option<String>,
}
impl common::ResponseResult for LiveChatModeratorListResponse {}
impl common::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.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct LiveChatModeratorSnippet {
/// The ID of the live chat this moderator can act on.
#[serde(rename = "liveChatId")]
pub live_chat_id: Option<String>,
/// Details about the moderator.
#[serde(rename = "moderatorDetails")]
pub moderator_details: Option<ChannelProfileDetails>,
}
impl common::Part for LiveChatModeratorSnippet {}
/// There is no detailed description.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::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<bool>,
/// 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<String>,
}
impl common::Part for LiveChatNewSponsorDetails {}
/// There is no detailed description.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct LiveChatPollDetails {
/// no description provided
pub metadata: Option<LiveChatPollDetailsPollMetadata>,
/// no description provided
pub status: Option<String>,
}
impl common::Part for LiveChatPollDetails {}
/// There is no detailed description.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct LiveChatPollDetailsPollMetadata {
/// The options will be returned in the order that is displayed in 1P
pub options: Option<Vec<LiveChatPollDetailsPollMetadataPollOption>>,
/// no description provided
#[serde(rename = "questionText")]
pub question_text: Option<String>,
}
impl common::Part for LiveChatPollDetailsPollMetadata {}
/// There is no detailed description.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct LiveChatPollDetailsPollMetadataPollOption {
/// no description provided
#[serde(rename = "optionText")]
pub option_text: Option<String>,
/// no description provided
#[serde_as(as = "Option<serde_with::DisplayFromStr>")]
pub tally: Option<i64>,
}
impl common::Part for LiveChatPollDetailsPollMetadataPollOption {}
/// There is no detailed description.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::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<String>,
/// The amount purchased by the user, in micros (1,750,000 micros = 1.75).
#[serde(rename = "amountMicros")]
#[serde_as(as = "Option<serde_with::DisplayFromStr>")]
pub amount_micros: Option<u64>,
/// The currency in which the purchase was made.
pub currency: Option<String>,
/// The tier in which the amount belongs. Lower amounts belong to lower tiers. The lowest tier is 1.
pub tier: Option<u32>,
/// The comment added by the user to this Super Chat event.
#[serde(rename = "userComment")]
pub user_comment: Option<String>,
}
impl common::Part for LiveChatSuperChatDetails {}
/// There is no detailed description.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::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<String>,
/// The amount purchased by the user, in micros (1,750,000 micros = 1.75).
#[serde(rename = "amountMicros")]
#[serde_as(as = "Option<serde_with::DisplayFromStr>")]
pub amount_micros: Option<u64>,
/// The currency in which the purchase was made.
pub currency: Option<String>,
/// Information about the Super Sticker.
#[serde(rename = "superStickerMetadata")]
pub super_sticker_metadata: Option<SuperStickerMetadata>,
/// The tier in which the amount belongs. Lower amounts belong to lower tiers. The lowest tier is 1.
pub tier: Option<u32>,
}
impl common::Part for LiveChatSuperStickerDetails {}
/// There is no detailed description.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct LiveChatTextMessageDetails {
/// The user's message.
#[serde(rename = "messageText")]
pub message_text: Option<String>,
}
impl common::Part for LiveChatTextMessageDetails {}
/// There is no detailed description.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::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<serde_with::DisplayFromStr>")]
pub ban_duration_seconds: Option<u64>,
/// The type of ban.
#[serde(rename = "banType")]
pub ban_type: Option<String>,
/// The details of the user that was banned.
#[serde(rename = "bannedUserDetails")]
pub banned_user_details: Option<ChannelProfileDetails>,
}
impl common::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)
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::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<CdnSettings>,
/// The content_details object contains information about the stream, including the closed captions ingestion URL.
#[serde(rename = "contentDetails")]
pub content_details: Option<LiveStreamContentDetails>,
/// Etag of this resource.
pub etag: Option<String>,
/// The ID that YouTube assigns to uniquely identify the stream.
pub id: Option<String>,
/// Identifies what kind of resource this is. Value: the fixed string "youtube#liveStream".
pub kind: Option<String>,
/// The snippet object contains basic details about the stream, including its channel, title, and description.
pub snippet: Option<LiveStreamSnippet>,
/// The status object contains information about live stream's status.
pub status: Option<LiveStreamStatus>,
}
impl common::RequestValue for LiveStream {}
impl common::Resource for LiveStream {}
impl common::ResponseResult for LiveStream {}
impl common::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.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct LiveStreamConfigurationIssue {
/// The long-form description of the issue and how to resolve it.
pub description: Option<String>,
/// The short-form reason for this issue.
pub reason: Option<String>,
/// How severe this issue is to the stream.
pub severity: Option<String>,
/// The kind of error happening.
#[serde(rename = "type")]
pub type_: Option<String>,
}
impl common::Part for LiveStreamConfigurationIssue {}
/// Detailed settings of a stream.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::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<String>,
/// 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<bool>,
}
impl common::Part for LiveStreamContentDetails {}
/// There is no detailed description.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct LiveStreamHealthStatus {
/// The configurations issues on this stream
#[serde(rename = "configurationIssues")]
pub configuration_issues: Option<Vec<LiveStreamConfigurationIssue>>,
/// The last time this status was updated (in seconds)
#[serde(rename = "lastUpdateTimeSeconds")]
#[serde_as(as = "Option<serde_with::DisplayFromStr>")]
pub last_update_time_seconds: Option<u64>,
/// The status code of this stream
pub status: Option<String>,
}
impl common::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)
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct LiveStreamListResponse {
/// Etag of this resource.
pub etag: Option<String>,
/// Serialized EventId of the request which produced this response.
#[serde(rename = "eventId")]
pub event_id: Option<String>,
/// A list of live streams that match the request criteria.
pub items: Option<Vec<LiveStream>>,
/// Identifies what kind of resource this is. Value: the fixed string "youtube#liveStreamListResponse".
pub kind: Option<String>,
/// 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<String>,
/// no description provided
#[serde(rename = "pageInfo")]
pub page_info: Option<PageInfo>,
/// 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<String>,
/// no description provided
#[serde(rename = "tokenPagination")]
pub token_pagination: Option<TokenPagination>,
/// The visitorId identifies the visitor.
#[serde(rename = "visitorId")]
pub visitor_id: Option<String>,
}
impl common::ResponseResult for LiveStreamListResponse {}
impl common::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.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::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<String>,
/// The stream's description. The value cannot be longer than 10000 characters.
pub description: Option<String>,
/// no description provided
#[serde(rename = "isDefaultStream")]
pub is_default_stream: Option<bool>,
/// The date and time that the stream was created.
#[serde(rename = "publishedAt")]
pub published_at: Option<chrono::DateTime<chrono::offset::Utc>>,
/// The stream's title. The value must be between 1 and 128 characters long.
pub title: Option<String>,
}
impl common::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.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct LiveStreamStatus {
/// The health status of the stream.
#[serde(rename = "healthStatus")]
pub health_status: Option<LiveStreamHealthStatus>,
/// no description provided
#[serde(rename = "streamStatus")]
pub stream_status: Option<String>,
}
impl common::Part for LiveStreamStatus {}
/// There is no detailed description.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct LocalizedProperty {
/// no description provided
pub default: Option<String>,
/// The language of the default property.
#[serde(rename = "defaultLanguage")]
pub default_language: Option<LanguageTag>,
/// no description provided
pub localized: Option<Vec<LocalizedString>>,
}
impl common::Part for LocalizedProperty {}
/// There is no detailed description.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct LocalizedString {
/// no description provided
pub language: Option<String>,
/// no description provided
pub value: Option<String>,
}
impl common::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)
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct Member {
/// Etag of this resource.
pub etag: Option<String>,
/// Identifies what kind of resource this is. Value: the fixed string "youtube#member".
pub kind: Option<String>,
/// The snippet object contains basic details about the member.
pub snippet: Option<MemberSnippet>,
}
impl common::Resource for Member {}
impl common::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)
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct MemberListResponse {
/// Etag of this resource.
pub etag: Option<String>,
/// Serialized EventId of the request which produced this response.
#[serde(rename = "eventId")]
pub event_id: Option<String>,
/// A list of members that match the request criteria.
pub items: Option<Vec<Member>>,
/// Identifies what kind of resource this is. Value: the fixed string "youtube#memberListResponse".
pub kind: Option<String>,
/// 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<String>,
/// no description provided
#[serde(rename = "pageInfo")]
pub page_info: Option<PageInfo>,
/// no description provided
#[serde(rename = "tokenPagination")]
pub token_pagination: Option<TokenPagination>,
/// The visitorId identifies the visitor.
#[serde(rename = "visitorId")]
pub visitor_id: Option<String>,
}
impl common::ResponseResult for MemberListResponse {}
impl common::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.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct MemberSnippet {
/// The id of the channel that's offering memberships.
#[serde(rename = "creatorChannelId")]
pub creator_channel_id: Option<String>,
/// Details about the member.
#[serde(rename = "memberDetails")]
pub member_details: Option<ChannelProfileDetails>,
/// Details about the user's membership.
#[serde(rename = "membershipsDetails")]
pub memberships_details: Option<MembershipsDetails>,
}
impl common::Part for MemberSnippet {}
/// There is no detailed description.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::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<Vec<String>>,
/// Id of the highest level that the user has access to at the moment.
#[serde(rename = "highestAccessibleLevel")]
pub highest_accessible_level: Option<String>,
/// 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<String>,
/// Data about memberships duration without taking into consideration pricing levels.
#[serde(rename = "membershipsDuration")]
pub memberships_duration: Option<MembershipsDuration>,
/// Data about memberships duration on particular pricing levels.
#[serde(rename = "membershipsDurationAtLevels")]
pub memberships_duration_at_levels: Option<Vec<MembershipsDurationAtLevel>>,
}
impl common::Part for MembershipsDetails {}
/// There is no detailed description.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::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<String>,
/// 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<i32>,
}
impl common::Part for MembershipsDuration {}
/// There is no detailed description.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct MembershipsDurationAtLevel {
/// Pricing level ID.
pub level: Option<String>,
/// The date and time when the user became a continuous member for the given level.
#[serde(rename = "memberSince")]
pub member_since: Option<String>,
/// 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<i32>,
}
impl common::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)
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct MembershipsLevel {
/// Etag of this resource.
pub etag: Option<String>,
/// The ID that YouTube assigns to uniquely identify the memberships level.
pub id: Option<String>,
/// Identifies what kind of resource this is. Value: the fixed string "youtube#membershipsLevelListResponse".
pub kind: Option<String>,
/// The snippet object contains basic details about the level.
pub snippet: Option<MembershipsLevelSnippet>,
}
impl common::Resource for MembershipsLevel {}
impl common::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)
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct MembershipsLevelListResponse {
/// Etag of this resource.
pub etag: Option<String>,
/// Serialized EventId of the request which produced this response.
#[serde(rename = "eventId")]
pub event_id: Option<String>,
/// A list of pricing levels offered by a creator to the fans.
pub items: Option<Vec<MembershipsLevel>>,
/// Identifies what kind of resource this is. Value: the fixed string "youtube#membershipsLevelListResponse".
pub kind: Option<String>,
/// The visitorId identifies the visitor.
#[serde(rename = "visitorId")]
pub visitor_id: Option<String>,
}
impl common::ResponseResult for MembershipsLevelListResponse {}
impl common::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.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct MembershipsLevelSnippet {
/// The id of the channel that's offering channel memberships.
#[serde(rename = "creatorChannelId")]
pub creator_channel_id: Option<String>,
/// Details about the pricing level.
#[serde(rename = "levelDetails")]
pub level_details: Option<LevelDetails>,
}
impl common::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.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::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<u32>,
/// HTML code that embeds a player that plays the monitor stream.
#[serde(rename = "embedHtml")]
pub embed_html: Option<String>,
/// 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<bool>,
}
impl common::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.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct PageInfo {
/// The number of results included in the API response.
#[serde(rename = "resultsPerPage")]
pub results_per_page: Option<i32>,
/// The total number of results in the result set.
#[serde(rename = "totalResults")]
pub total_results: Option<i32>,
}
impl common::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)
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct Playlist {
/// The contentDetails object contains information like video count.
#[serde(rename = "contentDetails")]
pub content_details: Option<PlaylistContentDetails>,
/// Etag of this resource.
pub etag: Option<String>,
/// The ID that YouTube uses to uniquely identify the playlist.
pub id: Option<String>,
/// Identifies what kind of resource this is. Value: the fixed string "youtube#playlist".
pub kind: Option<String>,
/// Localizations for different languages
pub localizations: Option<HashMap<String, PlaylistLocalization>>,
/// The player object contains information that you would use to play the playlist in an embedded player.
pub player: Option<PlaylistPlayer>,
/// The snippet object contains basic details about the playlist, such as its title and description.
pub snippet: Option<PlaylistSnippet>,
/// The status object contains status information for the playlist.
pub status: Option<PlaylistStatus>,
}
impl common::RequestValue for Playlist {}
impl common::Resource for Playlist {}
impl common::ResponseResult for Playlist {}
impl common::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.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct PlaylistContentDetails {
/// The number of videos in the playlist.
#[serde(rename = "itemCount")]
pub item_count: Option<u32>,
}
impl common::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)
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct PlaylistImage {
/// Identifies this resource (playlist id and image type).
pub id: Option<String>,
/// Identifies what kind of resource this is. Value: the fixed string "youtube#playlistImages".
pub kind: Option<String>,
/// no description provided
pub snippet: Option<PlaylistImageSnippet>,
}
impl common::RequestValue for PlaylistImage {}
impl common::Resource for PlaylistImage {}
impl common::ResponseResult for PlaylistImage {}
impl common::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)
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct PlaylistImageListResponse {
/// no description provided
pub items: Option<Vec<PlaylistImage>>,
/// Identifies what kind of resource this is. Value: the fixed string "youtube#playlistImageListResponse".
pub kind: Option<String>,
/// 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<String>,
/// General pagination information.
#[serde(rename = "pageInfo")]
pub page_info: Option<PageInfo>,
/// 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<String>,
}
impl common::ResponseResult for PlaylistImageListResponse {}
impl common::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.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct PlaylistImageSnippet {
/// The image height.
pub height: Option<i32>,
/// The Playlist ID of the playlist this image is associated with.
#[serde(rename = "playlistId")]
pub playlist_id: Option<String>,
/// The image type.
#[serde(rename = "type")]
pub type_: Option<String>,
/// The image width.
pub width: Option<i32>,
}
impl common::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)
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::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<PlaylistItemContentDetails>,
/// Etag of this resource.
pub etag: Option<String>,
/// The ID that YouTube uses to uniquely identify the playlist item.
pub id: Option<String>,
/// Identifies what kind of resource this is. Value: the fixed string "youtube#playlistItem".
pub kind: Option<String>,
/// The snippet object contains basic details about the playlist item, such as its title and position in the playlist.
pub snippet: Option<PlaylistItemSnippet>,
/// The status object contains information about the playlist item's privacy status.
pub status: Option<PlaylistItemStatus>,
}
impl common::RequestValue for PlaylistItem {}
impl common::Resource for PlaylistItem {}
impl common::ResponseResult for PlaylistItem {}
impl common::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.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::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<String>,
/// A user-generated note for this item.
pub note: Option<String>,
/// 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<String>,
/// 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<String>,
/// The date and time that the video was published to YouTube.
#[serde(rename = "videoPublishedAt")]
pub video_published_at: Option<chrono::DateTime<chrono::offset::Utc>>,
}
impl common::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)
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct PlaylistItemListResponse {
/// no description provided
pub etag: Option<String>,
/// Serialized EventId of the request which produced this response.
#[serde(rename = "eventId")]
pub event_id: Option<String>,
/// A list of playlist items that match the request criteria.
pub items: Option<Vec<PlaylistItem>>,
/// Identifies what kind of resource this is. Value: the fixed string "youtube#playlistItemListResponse".
pub kind: Option<String>,
/// 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<String>,
/// General pagination information.
#[serde(rename = "pageInfo")]
pub page_info: Option<PageInfo>,
/// 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<String>,
/// no description provided
#[serde(rename = "tokenPagination")]
pub token_pagination: Option<TokenPagination>,
/// The visitorId identifies the visitor.
#[serde(rename = "visitorId")]
pub visitor_id: Option<String>,
}
impl common::ResponseResult for PlaylistItemListResponse {}
impl common::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.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::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<String>,
/// Channel title for the channel that the playlist item belongs to.
#[serde(rename = "channelTitle")]
pub channel_title: Option<String>,
/// The item's description.
pub description: Option<String>,
/// The ID that YouTube uses to uniquely identify thGe playlist that the playlist item is in.
#[serde(rename = "playlistId")]
pub playlist_id: Option<String>,
/// 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<u32>,
/// The date and time that the item was added to the playlist.
#[serde(rename = "publishedAt")]
pub published_at: Option<chrono::DateTime<chrono::offset::Utc>>,
/// 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<ResourceId>,
/// 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<ThumbnailDetails>,
/// The item's title.
pub title: Option<String>,
/// Channel id for the channel this video belongs to.
#[serde(rename = "videoOwnerChannelId")]
pub video_owner_channel_id: Option<String>,
/// Channel title for the channel this video belongs to.
#[serde(rename = "videoOwnerChannelTitle")]
pub video_owner_channel_title: Option<String>,
}
impl common::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.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct PlaylistItemStatus {
/// This resource's privacy status.
#[serde(rename = "privacyStatus")]
pub privacy_status: Option<String>,
}
impl common::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)
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct PlaylistListResponse {
/// Etag of this resource.
pub etag: Option<String>,
/// Serialized EventId of the request which produced this response.
#[serde(rename = "eventId")]
pub event_id: Option<String>,
/// A list of playlists that match the request criteria
pub items: Option<Vec<Playlist>>,
/// Identifies what kind of resource this is. Value: the fixed string "youtube#playlistListResponse".
pub kind: Option<String>,
/// 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<String>,
/// General pagination information.
#[serde(rename = "pageInfo")]
pub page_info: Option<PageInfo>,
/// 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<String>,
/// no description provided
#[serde(rename = "tokenPagination")]
pub token_pagination: Option<TokenPagination>,
/// The visitorId identifies the visitor.
#[serde(rename = "visitorId")]
pub visitor_id: Option<String>,
}
impl common::ResponseResult for PlaylistListResponse {}
impl common::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.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct PlaylistLocalization {
/// The localized strings for playlist's description.
pub description: Option<String>,
/// The localized strings for playlist's title.
pub title: Option<String>,
}
impl common::Part for PlaylistLocalization {}
/// There is no detailed description.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct PlaylistPlayer {
/// An <iframe> tag that embeds a player that will play the playlist.
#[serde(rename = "embedHtml")]
pub embed_html: Option<String>,
}
impl common::Part for PlaylistPlayer {}
/// Basic details about a playlist, including title, description and thumbnails.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct PlaylistSnippet {
/// The ID that YouTube uses to uniquely identify the channel that published the playlist.
#[serde(rename = "channelId")]
pub channel_id: Option<String>,
/// The channel title of the channel that the video belongs to.
#[serde(rename = "channelTitle")]
pub channel_title: Option<String>,
/// The language of the playlist's default title and description.
#[serde(rename = "defaultLanguage")]
pub default_language: Option<String>,
/// The playlist's description.
pub description: Option<String>,
/// Localized title and description, read-only.
pub localized: Option<PlaylistLocalization>,
/// The date and time that the playlist was created.
#[serde(rename = "publishedAt")]
pub published_at: Option<chrono::DateTime<chrono::offset::Utc>>,
/// Keyword tags associated with the playlist.
pub tags: Option<Vec<String>>,
/// Note: if the playlist has a custom thumbnail, this field will not be populated. The video id selected by the user that will be used as the thumbnail of this playlist. This field defaults to the first publicly viewable video in the playlist, if: 1. The user has never selected a video to be the thumbnail of the playlist. 2. The user selects a video to be the thumbnail, and then removes that video from the playlist. 3. The user selects a non-owned video to be the thumbnail, but that video becomes private, or gets deleted.
#[serde(rename = "thumbnailVideoId")]
pub thumbnail_video_id: Option<String>,
/// A map of thumbnail images associated with the playlist. 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<ThumbnailDetails>,
/// The playlist's title.
pub title: Option<String>,
}
impl common::Part for PlaylistSnippet {}
/// There is no detailed description.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct PlaylistStatus {
/// The playlist's podcast status.
#[serde(rename = "podcastStatus")]
pub podcast_status: Option<String>,
/// The playlist's privacy status.
#[serde(rename = "privacyStatus")]
pub privacy_status: Option<String>,
}
impl common::Part for PlaylistStatus {}
/// A pair Property / Value.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct PropertyValue {
/// A property.
pub property: Option<String>,
/// The property's value.
pub value: Option<String>,
}
impl common::Part for PropertyValue {}
/// There is no detailed description.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct RelatedEntity {
/// no description provided
pub entity: Option<Entity>,
}
impl common::Part for RelatedEntity {}
/// A resource id is a generic reference that points to another YouTube resource.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct ResourceId {
/// The ID that YouTube uses to uniquely identify the referred resource, if that resource is a channel. This property is only present if the resourceId.kind value is youtube#channel.
#[serde(rename = "channelId")]
pub channel_id: Option<String>,
/// The type of the API resource.
pub kind: Option<String>,
/// The ID that YouTube uses to uniquely identify the referred resource, if that resource is a playlist. This property is only present if the resourceId.kind value is youtube#playlist.
#[serde(rename = "playlistId")]
pub playlist_id: Option<String>,
/// The ID that YouTube uses to uniquely identify the referred resource, if that resource is a video. This property is only present if the resourceId.kind value is youtube#video.
#[serde(rename = "videoId")]
pub video_id: Option<String>,
}
impl common::Part for ResourceId {}
/// 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 search](SearchListCall) (response)
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct SearchListResponse {
/// Etag of this resource.
pub etag: Option<String>,
/// Serialized EventId of the request which produced this response.
#[serde(rename = "eventId")]
pub event_id: Option<String>,
/// Pagination information for token pagination.
pub items: Option<Vec<SearchResult>>,
/// Identifies what kind of resource this is. Value: the fixed string "youtube#searchListResponse".
pub kind: Option<String>,
/// 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<String>,
/// General pagination information.
#[serde(rename = "pageInfo")]
pub page_info: Option<PageInfo>,
/// 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<String>,
/// no description provided
#[serde(rename = "regionCode")]
pub region_code: Option<String>,
/// no description provided
#[serde(rename = "tokenPagination")]
pub token_pagination: Option<TokenPagination>,
/// The visitorId identifies the visitor.
#[serde(rename = "visitorId")]
pub visitor_id: Option<String>,
}
impl common::ResponseResult for SearchListResponse {}
impl common::ToParts for SearchListResponse {
/// 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.region_code.is_some() {
r = r + "regionCode,";
}
if self.token_pagination.is_some() {
r = r + "tokenPagination,";
}
if self.visitor_id.is_some() {
r = r + "visitorId,";
}
r.pop();
r
}
}
/// A search result contains information about a YouTube video, channel, or playlist that matches the search parameters specified in an API request. While a search result points to a uniquely identifiable resource, like a video, it does not have its own persistent data.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct SearchResult {
/// Etag of this resource.
pub etag: Option<String>,
/// The id object contains information that can be used to uniquely identify the resource that matches the search request.
pub id: Option<ResourceId>,
/// Identifies what kind of resource this is. Value: the fixed string "youtube#searchResult".
pub kind: Option<String>,
/// The snippet object contains basic details about a search result, such as its title or description. For example, if the search result is a video, then the title will be the video's title and the description will be the video's description.
pub snippet: Option<SearchResultSnippet>,
}
impl common::Part for SearchResult {}
/// Basic details about a search result, including title, description and thumbnails of the item referenced by the search result.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct SearchResultSnippet {
/// The value that YouTube uses to uniquely identify the channel that published the resource that the search result identifies.
#[serde(rename = "channelId")]
pub channel_id: Option<String>,
/// The title of the channel that published the resource that the search result identifies.
#[serde(rename = "channelTitle")]
pub channel_title: Option<String>,
/// A description of the search result.
pub description: Option<String>,
/// 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.
#[serde(rename = "liveBroadcastContent")]
pub live_broadcast_content: Option<String>,
/// The creation date and time of the resource that the search result identifies.
#[serde(rename = "publishedAt")]
pub published_at: Option<chrono::DateTime<chrono::offset::Utc>>,
/// A map of thumbnail images associated with the search result. 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<ThumbnailDetails>,
/// The title of the search result.
pub title: Option<String>,
}
impl common::Part for SearchResultSnippet {}
/// A *subscription* resource contains information about a YouTube user subscription. A subscription notifies a user when new videos are added to a channel or when another user takes one of several actions on YouTube, such as uploading a video, rating a video, or commenting on a 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 subscriptions](SubscriptionDeleteCall) (none)
/// * [insert subscriptions](SubscriptionInsertCall) (request|response)
/// * [list subscriptions](SubscriptionListCall) (none)
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct Subscription {
/// The contentDetails object contains basic statistics about the subscription.
#[serde(rename = "contentDetails")]
pub content_details: Option<SubscriptionContentDetails>,
/// Etag of this resource.
pub etag: Option<String>,
/// The ID that YouTube uses to uniquely identify the subscription.
pub id: Option<String>,
/// Identifies what kind of resource this is. Value: the fixed string "youtube#subscription".
pub kind: Option<String>,
/// The snippet object contains basic details about the subscription, including its title and the channel that the user subscribed to.
pub snippet: Option<SubscriptionSnippet>,
/// The subscriberSnippet object contains basic details about the subscriber.
#[serde(rename = "subscriberSnippet")]
pub subscriber_snippet: Option<SubscriptionSubscriberSnippet>,
}
impl common::RequestValue for Subscription {}
impl common::Resource for Subscription {}
impl common::ResponseResult for Subscription {}
impl common::ToParts for Subscription {
/// 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.subscriber_snippet.is_some() {
r = r + "subscriberSnippet,";
}
r.pop();
r
}
}
/// Details about the content to witch a subscription refers.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct SubscriptionContentDetails {
/// The type of activity this subscription is for (only uploads, everything).
#[serde(rename = "activityType")]
pub activity_type: Option<String>,
/// The number of new items in the subscription since its content was last read.
#[serde(rename = "newItemCount")]
pub new_item_count: Option<u32>,
/// The approximate number of items that the subscription points to.
#[serde(rename = "totalItemCount")]
pub total_item_count: Option<u32>,
}
impl common::Part for SubscriptionContentDetails {}
/// 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 subscriptions](SubscriptionListCall) (response)
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct SubscriptionListResponse {
/// Etag of this resource.
pub etag: Option<String>,
/// Serialized EventId of the request which produced this response.
#[serde(rename = "eventId")]
pub event_id: Option<String>,
/// A list of subscriptions that match the request criteria.
pub items: Option<Vec<Subscription>>,
/// Identifies what kind of resource this is. Value: the fixed string "youtube#subscriptionListResponse".
pub kind: Option<String>,
/// 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<String>,
/// no description provided
#[serde(rename = "pageInfo")]
pub page_info: Option<PageInfo>,
/// 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<String>,
/// no description provided
#[serde(rename = "tokenPagination")]
pub token_pagination: Option<TokenPagination>,
/// The visitorId identifies the visitor.
#[serde(rename = "visitorId")]
pub visitor_id: Option<String>,
}
impl common::ResponseResult for SubscriptionListResponse {}
impl common::ToParts for SubscriptionListResponse {
/// 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 subscription, including title, description and thumbnails of the subscribed item.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct SubscriptionSnippet {
/// The ID that YouTube uses to uniquely identify the subscriber's channel.
#[serde(rename = "channelId")]
pub channel_id: Option<String>,
/// The subscription's details.
pub description: Option<String>,
/// The date and time that the subscription was created.
#[serde(rename = "publishedAt")]
pub published_at: Option<chrono::DateTime<chrono::offset::Utc>>,
/// The id object contains information about the channel that the user subscribed to.
#[serde(rename = "resourceId")]
pub resource_id: Option<ResourceId>,
/// A map of thumbnail images associated with the video. 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<ThumbnailDetails>,
/// The subscription's title.
pub title: Option<String>,
}
impl common::Part for SubscriptionSnippet {}
/// Basic details about a subscription's subscriber including title, description, channel ID and thumbnails.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct SubscriptionSubscriberSnippet {
/// The channel ID of the subscriber.
#[serde(rename = "channelId")]
pub channel_id: Option<String>,
/// The description of the subscriber.
pub description: Option<String>,
/// Thumbnails for this subscriber.
pub thumbnails: Option<ThumbnailDetails>,
/// The title of the subscriber.
pub title: Option<String>,
}
impl common::Part for SubscriptionSubscriberSnippet {}
/// A `__superChatEvent__` resource represents a Super Chat purchase on 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 super chat events](SuperChatEventListCall) (none)
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct SuperChatEvent {
/// Etag of this resource.
pub etag: Option<String>,
/// The ID that YouTube assigns to uniquely identify the Super Chat event.
pub id: Option<String>,
/// Identifies what kind of resource this is. Value: the fixed string `"youtube#superChatEvent"`.
pub kind: Option<String>,
/// The `snippet` object contains basic details about the Super Chat event.
pub snippet: Option<SuperChatEventSnippet>,
}
impl common::Resource for SuperChatEvent {}
impl common::ToParts for SuperChatEvent {
/// 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 super chat events](SuperChatEventListCall) (response)
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct SuperChatEventListResponse {
/// Etag of this resource.
pub etag: Option<String>,
/// Serialized EventId of the request which produced this response.
#[serde(rename = "eventId")]
pub event_id: Option<String>,
/// A list of Super Chat purchases that match the request criteria.
pub items: Option<Vec<SuperChatEvent>>,
/// Identifies what kind of resource this is. Value: the fixed string "youtube#superChatEventListResponse".
pub kind: Option<String>,
/// 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<String>,
/// no description provided
#[serde(rename = "pageInfo")]
pub page_info: Option<PageInfo>,
/// no description provided
#[serde(rename = "tokenPagination")]
pub token_pagination: Option<TokenPagination>,
/// The visitorId identifies the visitor.
#[serde(rename = "visitorId")]
pub visitor_id: Option<String>,
}
impl common::ResponseResult for SuperChatEventListResponse {}
impl common::ToParts for SuperChatEventListResponse {
/// 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.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct SuperChatEventSnippet {
/// The purchase amount, in micros of the purchase currency. e.g., 1 is represented as 1000000.
#[serde(rename = "amountMicros")]
#[serde_as(as = "Option<serde_with::DisplayFromStr>")]
pub amount_micros: Option<u64>,
/// Channel id where the event occurred.
#[serde(rename = "channelId")]
pub channel_id: Option<String>,
/// The text contents of the comment left by the user.
#[serde(rename = "commentText")]
pub comment_text: Option<String>,
/// The date and time when the event occurred.
#[serde(rename = "createdAt")]
pub created_at: Option<chrono::DateTime<chrono::offset::Utc>>,
/// The currency in which the purchase was made. ISO 4217.
pub currency: Option<String>,
/// A rendered string that displays the purchase amount and currency (e.g., "$1.00"). The string is rendered for the given language.
#[serde(rename = "displayString")]
pub display_string: Option<String>,
/// True if this event is a Super Sticker event.
#[serde(rename = "isSuperStickerEvent")]
pub is_super_sticker_event: Option<bool>,
/// The tier for the paid message, which is based on the amount of money spent to purchase the message.
#[serde(rename = "messageType")]
pub message_type: Option<u32>,
/// If this event is a Super Sticker event, this field will contain metadata about the Super Sticker.
#[serde(rename = "superStickerMetadata")]
pub super_sticker_metadata: Option<SuperStickerMetadata>,
/// Details about the supporter.
#[serde(rename = "supporterDetails")]
pub supporter_details: Option<ChannelProfileDetails>,
}
impl common::Part for SuperChatEventSnippet {}
/// There is no detailed description.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct SuperStickerMetadata {
/// Internationalized alt text that describes the sticker image and any animation associated with it.
#[serde(rename = "altText")]
pub alt_text: Option<String>,
/// Specifies the localization language in which the alt text is returned.
#[serde(rename = "altTextLanguage")]
pub alt_text_language: Option<String>,
/// Unique identifier of the Super Sticker. This is a shorter form of the alt_text that includes pack name and a recognizable characteristic of the sticker.
#[serde(rename = "stickerId")]
pub sticker_id: Option<String>,
}
impl common::Part for SuperStickerMetadata {}
/// 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 tests](TestInsertCall) (request|response)
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct TestItem {
/// Etag for the resource. See https://en.wikipedia.org/wiki/HTTP_ETag.
pub etag: Option<String>,
/// no description provided
#[serde(rename = "featuredPart")]
pub featured_part: Option<bool>,
/// no description provided
#[serde_as(as = "Option<serde_with::DisplayFromStr>")]
pub gaia: Option<i64>,
/// no description provided
pub id: Option<String>,
/// no description provided
pub snippet: Option<TestItemTestItemSnippet>,
}
impl common::RequestValue for TestItem {}
impl common::ResponseResult for TestItem {}
impl common::ToParts for TestItem {
/// 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.featured_part.is_some() {
r = r + "featuredPart,";
}
if self.gaia.is_some() {
r = r + "gaia,";
}
if self.id.is_some() {
r = r + "id,";
}
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.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct TestItemTestItemSnippet {
_never_set: Option<bool>,
}
impl common::Part for TestItemTestItemSnippet {}
/// A *third party account link* resource represents a link between a YouTube account or a channel and an account on a third-party service.
///
/// # Activities
///
/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
///
/// * [delete third party links](ThirdPartyLinkDeleteCall) (none)
/// * [insert third party links](ThirdPartyLinkInsertCall) (request|response)
/// * [list third party links](ThirdPartyLinkListCall) (none)
/// * [update third party links](ThirdPartyLinkUpdateCall) (request|response)
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct ThirdPartyLink {
/// Etag of this resource
pub etag: Option<String>,
/// Identifies what kind of resource this is. Value: the fixed string "youtube#thirdPartyLink".
pub kind: Option<String>,
/// The linking_token identifies a YouTube account and channel with which the third party account is linked.
#[serde(rename = "linkingToken")]
pub linking_token: Option<String>,
/// The snippet object contains basic details about the third- party account link.
pub snippet: Option<ThirdPartyLinkSnippet>,
/// The status object contains information about the status of the link.
pub status: Option<ThirdPartyLinkStatus>,
}
impl common::RequestValue for ThirdPartyLink {}
impl common::Resource for ThirdPartyLink {}
impl common::ResponseResult for ThirdPartyLink {}
impl common::ToParts for ThirdPartyLink {
/// 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.linking_token.is_some() {
r = r + "linkingToken,";
}
if self.snippet.is_some() {
r = r + "snippet,";
}
if self.status.is_some() {
r = r + "status,";
}
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 third party links](ThirdPartyLinkListCall) (response)
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct ThirdPartyLinkListResponse {
/// Etag of this resource.
pub etag: Option<String>,
/// no description provided
pub items: Option<Vec<ThirdPartyLink>>,
/// Identifies what kind of resource this is. Value: the fixed string "youtube#thirdPartyLinkListResponse".
pub kind: Option<String>,
}
impl common::ResponseResult for ThirdPartyLinkListResponse {}
impl common::ToParts for ThirdPartyLinkListResponse {
/// 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.items.is_some() {
r = r + "items,";
}
if self.kind.is_some() {
r = r + "kind,";
}
r.pop();
r
}
}
/// Basic information about a third party account link, including its type and type-specific information.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct ThirdPartyLinkSnippet {
/// Information specific to a link between a channel and a store on a merchandising platform.
#[serde(rename = "channelToStoreLink")]
pub channel_to_store_link: Option<ChannelToStoreLinkDetails>,
/// Type of the link named after the entities that are being linked.
#[serde(rename = "type")]
pub type_: Option<String>,
}
impl common::Part for ThirdPartyLinkSnippet {}
/// The third-party link status object contains information about the status of the link.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct ThirdPartyLinkStatus {
/// no description provided
#[serde(rename = "linkStatus")]
pub link_status: Option<String>,
}
impl common::Part for ThirdPartyLinkStatus {}
/// A thumbnail is an image representing a YouTube resource.
///
/// # Activities
///
/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
///
/// * [set thumbnails](ThumbnailSetCall) (none)
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct Thumbnail {
/// (Optional) Height of the thumbnail image.
pub height: Option<u32>,
/// The thumbnail image's URL.
pub url: Option<String>,
/// (Optional) Width of the thumbnail image.
pub width: Option<u32>,
}
impl common::Resource for Thumbnail {}
/// Internal representation of thumbnails for a YouTube resource.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct ThumbnailDetails {
/// The default image for this resource.
pub default: Option<Thumbnail>,
/// The high quality image for this resource.
pub high: Option<Thumbnail>,
/// The maximum resolution quality image for this resource.
pub maxres: Option<Thumbnail>,
/// The medium quality image for this resource.
pub medium: Option<Thumbnail>,
/// The standard quality image for this resource.
pub standard: Option<Thumbnail>,
}
impl common::Part for ThumbnailDetails {}
/// There is no detailed description.
///
/// # Activities
///
/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
///
/// * [set thumbnails](ThumbnailSetCall) (response)
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct ThumbnailSetResponse {
/// Etag of this resource.
pub etag: Option<String>,
/// Serialized EventId of the request which produced this response.
#[serde(rename = "eventId")]
pub event_id: Option<String>,
/// A list of thumbnails.
pub items: Option<Vec<ThumbnailDetails>>,
/// Identifies what kind of resource this is. Value: the fixed string "youtube#thumbnailSetResponse".
pub kind: Option<String>,
/// The visitorId identifies the visitor.
#[serde(rename = "visitorId")]
pub visitor_id: Option<String>,
}
impl common::ResponseResult for ThumbnailSetResponse {}
/// Stub token pagination template to suppress results.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct TokenPagination {
_never_set: Option<bool>,
}
impl common::Part for TokenPagination {}
/// A *video* resource represents a 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 videos](VideoDeleteCall) (none)
/// * [get rating videos](VideoGetRatingCall) (none)
/// * [insert videos](VideoInsertCall) (request|response)
/// * [list videos](VideoListCall) (none)
/// * [rate videos](VideoRateCall) (none)
/// * [report abuse videos](VideoReportAbuseCall) (none)
/// * [update videos](VideoUpdateCall) (request|response)
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct Video {
/// Age restriction details related to a video. This data can only be retrieved by the video owner.
#[serde(rename = "ageGating")]
pub age_gating: Option<VideoAgeGating>,
/// The contentDetails object contains information about the video content, including the length of the video and its aspect ratio.
#[serde(rename = "contentDetails")]
pub content_details: Option<VideoContentDetails>,
/// Etag of this resource.
pub etag: Option<String>,
/// The fileDetails object encapsulates information about the video file that was uploaded to YouTube, including the file's resolution, duration, audio and video codecs, stream bitrates, and more. This data can only be retrieved by the video owner.
#[serde(rename = "fileDetails")]
pub file_details: Option<VideoFileDetails>,
/// The ID that YouTube uses to uniquely identify the video.
pub id: Option<String>,
/// Identifies what kind of resource this is. Value: the fixed string "youtube#video".
pub kind: Option<String>,
/// The liveStreamingDetails object contains metadata about a live video broadcast. The object will only be present in a video resource if the video is an upcoming, live, or completed live broadcast.
#[serde(rename = "liveStreamingDetails")]
pub live_streaming_details: Option<VideoLiveStreamingDetails>,
/// The localizations object contains localized versions of the basic details about the video, such as its title and description.
pub localizations: Option<HashMap<String, VideoLocalization>>,
/// The monetizationDetails object encapsulates information about the monetization status of the video.
#[serde(rename = "monetizationDetails")]
pub monetization_details: Option<VideoMonetizationDetails>,
/// no description provided
#[serde(rename = "paidProductPlacementDetails")]
pub paid_product_placement_details: Option<VideoPaidProductPlacementDetails>,
/// The player object contains information that you would use to play the video in an embedded player.
pub player: Option<VideoPlayer>,
/// The processingDetails object encapsulates information about YouTube's progress in processing the uploaded video file. The properties in the object identify the current processing status and an estimate of the time remaining until YouTube finishes processing the video. This part also indicates whether different types of data or content, such as file details or thumbnail images, are available for the video. The processingProgress object is designed to be polled so that the video uploaded can track the progress that YouTube has made in processing the uploaded video file. This data can only be retrieved by the video owner.
#[serde(rename = "processingDetails")]
pub processing_details: Option<VideoProcessingDetails>,
/// The projectDetails object contains information about the project specific video metadata. b/157517979: This part was never populated after it was added. However, it sees non-zero traffic because there is generated client code in the wild that refers to it [1]. We keep this field and do NOT remove it because otherwise V3 would return an error when this part gets requested [2]. [1] https://developers.google.com/resources/api-libraries/documentation/youtube/v3/csharp/latest/classGoogle_1_1Apis_1_1YouTube_1_1v3_1_1Data_1_1VideoProjectDetails.html [2] http://google3/video/youtube/src/python/servers/data_api/common.py?l=1565-1569&rcl=344141677
#[serde(rename = "projectDetails")]
pub project_details: Option<VideoProjectDetails>,
/// The recordingDetails object encapsulates information about the location, date and address where the video was recorded.
#[serde(rename = "recordingDetails")]
pub recording_details: Option<VideoRecordingDetails>,
/// The snippet object contains basic details about the video, such as its title, description, and category.
pub snippet: Option<VideoSnippet>,
/// The statistics object contains statistics about the video.
pub statistics: Option<VideoStatistics>,
/// The status object contains information about the video's uploading, processing, and privacy statuses.
pub status: Option<VideoStatus>,
/// The suggestions object encapsulates suggestions that identify opportunities to improve the video quality or the metadata for the uploaded video. This data can only be retrieved by the video owner.
pub suggestions: Option<VideoSuggestions>,
/// The topicDetails object encapsulates information about Freebase topics associated with the video.
#[serde(rename = "topicDetails")]
pub topic_details: Option<VideoTopicDetails>,
}
impl common::RequestValue for Video {}
impl common::Resource for Video {}
impl common::ResponseResult for Video {}
impl common::ToParts for Video {
/// 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.age_gating.is_some() {
r = r + "ageGating,";
}
if self.content_details.is_some() {
r = r + "contentDetails,";
}
if self.etag.is_some() {
r = r + "etag,";
}
if self.file_details.is_some() {
r = r + "fileDetails,";
}
if self.id.is_some() {
r = r + "id,";
}
if self.kind.is_some() {
r = r + "kind,";
}
if self.live_streaming_details.is_some() {
r = r + "liveStreamingDetails,";
}
if self.localizations.is_some() {
r = r + "localizations,";
}
if self.monetization_details.is_some() {
r = r + "monetizationDetails,";
}
if self.paid_product_placement_details.is_some() {
r = r + "paidProductPlacementDetails,";
}
if self.player.is_some() {
r = r + "player,";
}
if self.processing_details.is_some() {
r = r + "processingDetails,";
}
if self.project_details.is_some() {
r = r + "projectDetails,";
}
if self.recording_details.is_some() {
r = r + "recordingDetails,";
}
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.suggestions.is_some() {
r = r + "suggestions,";
}
if self.topic_details.is_some() {
r = r + "topicDetails,";
}
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*).
///
/// * [report abuse videos](VideoReportAbuseCall) (request)
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct VideoAbuseReport {
/// Additional comments regarding the abuse report.
pub comments: Option<String>,
/// The language that the content was viewed in.
pub language: Option<String>,
/// The high-level, or primary, reason that the content is abusive. The value is an abuse report reason ID.
#[serde(rename = "reasonId")]
pub reason_id: Option<String>,
/// The specific, or secondary, reason that this content is abusive (if available). The value is an abuse report reason ID that is a valid secondary reason for the primary reason.
#[serde(rename = "secondaryReasonId")]
pub secondary_reason_id: Option<String>,
/// The ID that YouTube uses to uniquely identify the video.
#[serde(rename = "videoId")]
pub video_id: Option<String>,
}
impl common::RequestValue for VideoAbuseReport {}
/// A `__videoAbuseReportReason__` resource identifies a reason that a video could be reported as abusive. Video abuse report reasons are used with `video.ReportAbuse`.
///
/// # Activities
///
/// This type is used in activities, which are methods you may call on this type or where 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 video abuse report reasons](VideoAbuseReportReasonListCall) (none)
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct VideoAbuseReportReason {
/// Etag of this resource.
pub etag: Option<String>,
/// The ID of this abuse report reason.
pub id: Option<String>,
/// Identifies what kind of resource this is. Value: the fixed string `"youtube#videoAbuseReportReason"`.
pub kind: Option<String>,
/// The `snippet` object contains basic details about the abuse report reason.
pub snippet: Option<VideoAbuseReportReasonSnippet>,
}
impl common::Resource for VideoAbuseReportReason {}
impl common::ToParts for VideoAbuseReportReason {
/// 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 video abuse report reasons](VideoAbuseReportReasonListCall) (response)
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct VideoAbuseReportReasonListResponse {
/// Etag of this resource.
pub etag: Option<String>,
/// Serialized EventId of the request which produced this response.
#[serde(rename = "eventId")]
pub event_id: Option<String>,
/// A list of valid abuse reasons that are used with `video.ReportAbuse`.
pub items: Option<Vec<VideoAbuseReportReason>>,
/// Identifies what kind of resource this is. Value: the fixed string `"youtube#videoAbuseReportReasonListResponse"`.
pub kind: Option<String>,
/// The `visitorId` identifies the visitor.
#[serde(rename = "visitorId")]
pub visitor_id: Option<String>,
}
impl common::ResponseResult for VideoAbuseReportReasonListResponse {}
impl common::ToParts for VideoAbuseReportReasonListResponse {
/// 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 video category, such as its localized title.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct VideoAbuseReportReasonSnippet {
/// The localized label belonging to this abuse report reason.
pub label: Option<String>,
/// The secondary reasons associated with this reason, if any are available. (There might be 0 or more.)
#[serde(rename = "secondaryReasons")]
pub secondary_reasons: Option<Vec<VideoAbuseReportSecondaryReason>>,
}
impl common::Part for VideoAbuseReportReasonSnippet {}
/// There is no detailed description.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct VideoAbuseReportSecondaryReason {
/// The ID of this abuse report secondary reason.
pub id: Option<String>,
/// The localized label for this abuse report secondary reason.
pub label: Option<String>,
}
impl common::Part for VideoAbuseReportSecondaryReason {}
/// There is no detailed description.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct VideoAgeGating {
/// Indicates whether or not the video has alcoholic beverage content. Only users of legal purchasing age in a particular country, as identified by ICAP, can view the content.
#[serde(rename = "alcoholContent")]
pub alcohol_content: Option<bool>,
/// Age-restricted trailers. For redband trailers and adult-rated video-games. Only users aged 18+ can view the content. The the field is true the content is restricted to viewers aged 18+. Otherwise The field won't be present.
pub restricted: Option<bool>,
/// Video game rating, if any.
#[serde(rename = "videoGameRating")]
pub video_game_rating: Option<String>,
}
impl common::Part for VideoAgeGating {}
/// A *videoCategory* resource identifies a category that has been or could be associated with uploaded videos.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct VideoCategory {
/// Etag of this resource.
pub etag: Option<String>,
/// The ID that YouTube uses to uniquely identify the video category.
pub id: Option<String>,
/// Identifies what kind of resource this is. Value: the fixed string "youtube#videoCategory".
pub kind: Option<String>,
/// The snippet object contains basic details about the video category, including its title.
pub snippet: Option<VideoCategorySnippet>,
}
impl common::Part for VideoCategory {}
/// 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 video categories](VideoCategoryListCall) (response)
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct VideoCategoryListResponse {
/// Etag of this resource.
pub etag: Option<String>,
/// Serialized EventId of the request which produced this response.
#[serde(rename = "eventId")]
pub event_id: Option<String>,
/// A list of video categories that can be associated with YouTube videos. In this map, the video category ID is the map key, and its value is the corresponding videoCategory resource.
pub items: Option<Vec<VideoCategory>>,
/// Identifies what kind of resource this is. Value: the fixed string "youtube#videoCategoryListResponse".
pub kind: Option<String>,
/// 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<String>,
/// General pagination information.
#[serde(rename = "pageInfo")]
pub page_info: Option<PageInfo>,
/// 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<String>,
/// no description provided
#[serde(rename = "tokenPagination")]
pub token_pagination: Option<TokenPagination>,
/// The visitorId identifies the visitor.
#[serde(rename = "visitorId")]
pub visitor_id: Option<String>,
}
impl common::ResponseResult for VideoCategoryListResponse {}
impl common::ToParts for VideoCategoryListResponse {
/// 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 video category, such as its localized title.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct VideoCategorySnippet {
/// no description provided
pub assignable: Option<bool>,
/// The YouTube channel that created the video category.
#[serde(rename = "channelId")]
pub channel_id: Option<String>,
/// The video category's title.
pub title: Option<String>,
}
impl common::Part for VideoCategorySnippet {}
/// Details about the content of a YouTube Video.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct VideoContentDetails {
/// The value of captions indicates whether the video has captions or not.
pub caption: Option<String>,
/// Specifies the ratings that the video received under various rating schemes.
#[serde(rename = "contentRating")]
pub content_rating: Option<ContentRating>,
/// The countryRestriction object contains information about the countries where a video is (or is not) viewable.
#[serde(rename = "countryRestriction")]
pub country_restriction: Option<AccessPolicy>,
/// The value of definition indicates whether the video is available in high definition or only in standard definition.
pub definition: Option<String>,
/// The value of dimension indicates whether the video is available in 3D or in 2D.
pub dimension: Option<String>,
/// The length of the video. The tag value is an ISO 8601 duration in the format PT#M#S, in which the letters PT indicate that the value specifies a period of time, and the letters M and S refer to length in minutes and seconds, respectively. The # characters preceding the M and S letters are both integers that specify the number of minutes (or seconds) of the video. For example, a value of PT15M51S indicates that the video is 15 minutes and 51 seconds long.
pub duration: Option<String>,
/// Indicates whether the video uploader has provided a custom thumbnail image for the video. This property is only visible to the video uploader.
#[serde(rename = "hasCustomThumbnail")]
pub has_custom_thumbnail: Option<bool>,
/// The value of is_license_content indicates whether the video is licensed content.
#[serde(rename = "licensedContent")]
pub licensed_content: Option<bool>,
/// Specifies the projection format of the video.
pub projection: Option<String>,
/// The regionRestriction object contains information about the countries where a video is (or is not) viewable. The object will contain either the contentDetails.regionRestriction.allowed property or the contentDetails.regionRestriction.blocked property.
#[serde(rename = "regionRestriction")]
pub region_restriction: Option<VideoContentDetailsRegionRestriction>,
}
impl common::Part for VideoContentDetails {}
/// DEPRECATED Region restriction of the video.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct VideoContentDetailsRegionRestriction {
/// A list of region codes that identify countries where the video is viewable. If this property is present and a country is not listed in its value, then the video is blocked from appearing in that country. If this property is present and contains an empty list, the video is blocked in all countries.
pub allowed: Option<Vec<String>>,
/// A list of region codes that identify countries where the video is blocked. If this property is present and a country is not listed in its value, then the video is viewable in that country. If this property is present and contains an empty list, the video is viewable in all countries.
pub blocked: Option<Vec<String>>,
}
impl common::Part for VideoContentDetailsRegionRestriction {}
/// Describes original video file properties, including technical details about audio and video streams, but also metadata information like content length, digitization time, or geotagging information.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct VideoFileDetails {
/// A list of audio streams contained in the uploaded video file. Each item in the list contains detailed metadata about an audio stream.
#[serde(rename = "audioStreams")]
pub audio_streams: Option<Vec<VideoFileDetailsAudioStream>>,
/// The uploaded video file's combined (video and audio) bitrate in bits per second.
#[serde(rename = "bitrateBps")]
#[serde_as(as = "Option<serde_with::DisplayFromStr>")]
pub bitrate_bps: Option<u64>,
/// The uploaded video file's container format.
pub container: Option<String>,
/// The date and time when the uploaded video file was created. The value is specified in ISO 8601 format. Currently, the following ISO 8601 formats are supported: - Date only: YYYY-MM-DD - Naive time: YYYY-MM-DDTHH:MM:SS - Time with timezone: YYYY-MM-DDTHH:MM:SS+HH:MM
#[serde(rename = "creationTime")]
pub creation_time: Option<String>,
/// The length of the uploaded video in milliseconds.
#[serde(rename = "durationMs")]
#[serde_as(as = "Option<serde_with::DisplayFromStr>")]
pub duration_ms: Option<u64>,
/// The uploaded file's name. This field is present whether a video file or another type of file was uploaded.
#[serde(rename = "fileName")]
pub file_name: Option<String>,
/// The uploaded file's size in bytes. This field is present whether a video file or another type of file was uploaded.
#[serde(rename = "fileSize")]
#[serde_as(as = "Option<serde_with::DisplayFromStr>")]
pub file_size: Option<u64>,
/// 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.
#[serde(rename = "fileType")]
pub file_type: Option<String>,
/// A list of video streams contained in the uploaded video file. Each item in the list contains detailed metadata about a video stream.
#[serde(rename = "videoStreams")]
pub video_streams: Option<Vec<VideoFileDetailsVideoStream>>,
}
impl common::Part for VideoFileDetails {}
/// Information about an audio stream.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct VideoFileDetailsAudioStream {
/// The audio stream's bitrate, in bits per second.
#[serde(rename = "bitrateBps")]
#[serde_as(as = "Option<serde_with::DisplayFromStr>")]
pub bitrate_bps: Option<u64>,
/// The number of audio channels that the stream contains.
#[serde(rename = "channelCount")]
pub channel_count: Option<u32>,
/// The audio codec that the stream uses.
pub codec: Option<String>,
/// A value that uniquely identifies a video vendor. Typically, the value is a four-letter vendor code.
pub vendor: Option<String>,
}
impl common::Part for VideoFileDetailsAudioStream {}
/// Information about a video stream.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct VideoFileDetailsVideoStream {
/// The video content's display aspect ratio, which specifies the aspect ratio in which the video should be displayed.
#[serde(rename = "aspectRatio")]
pub aspect_ratio: Option<f64>,
/// The video stream's bitrate, in bits per second.
#[serde(rename = "bitrateBps")]
#[serde_as(as = "Option<serde_with::DisplayFromStr>")]
pub bitrate_bps: Option<u64>,
/// The video codec that the stream uses.
pub codec: Option<String>,
/// The video stream's frame rate, in frames per second.
#[serde(rename = "frameRateFps")]
pub frame_rate_fps: Option<f64>,
/// The encoded video content's height in pixels.
#[serde(rename = "heightPixels")]
pub height_pixels: Option<u32>,
/// The amount that YouTube needs to rotate the original source content to properly display the video.
pub rotation: Option<String>,
/// A value that uniquely identifies a video vendor. Typically, the value is a four-letter vendor code.
pub vendor: Option<String>,
/// The encoded video content's width in pixels. You can calculate the video's encoding aspect ratio as width_pixels / height_pixels.
#[serde(rename = "widthPixels")]
pub width_pixels: Option<u32>,
}
impl common::Part for VideoFileDetailsVideoStream {}
/// There is no detailed description.
///
/// # Activities
///
/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
///
/// * [get rating videos](VideoGetRatingCall) (response)
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct VideoGetRatingResponse {
/// Etag of this resource.
pub etag: Option<String>,
/// Serialized EventId of the request which produced this response.
#[serde(rename = "eventId")]
pub event_id: Option<String>,
/// A list of ratings that match the request criteria.
pub items: Option<Vec<VideoRating>>,
/// Identifies what kind of resource this is. Value: the fixed string "youtube#videoGetRatingResponse".
pub kind: Option<String>,
/// The visitorId identifies the visitor.
#[serde(rename = "visitorId")]
pub visitor_id: Option<String>,
}
impl common::ResponseResult for VideoGetRatingResponse {}
/// 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 videos](VideoListCall) (response)
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct VideoListResponse {
/// Etag of this resource.
pub etag: Option<String>,
/// Serialized EventId of the request which produced this response.
#[serde(rename = "eventId")]
pub event_id: Option<String>,
/// no description provided
pub items: Option<Vec<Video>>,
/// Identifies what kind of resource this is. Value: the fixed string "youtube#videoListResponse".
pub kind: Option<String>,
/// 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<String>,
/// General pagination information.
#[serde(rename = "pageInfo")]
pub page_info: Option<PageInfo>,
/// 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<String>,
/// no description provided
#[serde(rename = "tokenPagination")]
pub token_pagination: Option<TokenPagination>,
/// The visitorId identifies the visitor.
#[serde(rename = "visitorId")]
pub visitor_id: Option<String>,
}
impl common::ResponseResult for VideoListResponse {}
impl common::ToParts for VideoListResponse {
/// 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
}
}
/// Details about the live streaming metadata.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct VideoLiveStreamingDetails {
/// The ID of the currently active live chat attached to this video. This field is filled only if the video is a currently live broadcast that has live chat. Once the broadcast transitions to complete this field will be removed and the live chat closed down. For persistent broadcasts that live chat id will no longer be tied to this video but rather to the new video being displayed at the persistent page.
#[serde(rename = "activeLiveChatId")]
pub active_live_chat_id: Option<String>,
/// The time that the broadcast actually ended. This value will not be available until the broadcast is over.
#[serde(rename = "actualEndTime")]
pub actual_end_time: Option<chrono::DateTime<chrono::offset::Utc>>,
/// The time that the broadcast actually started. This value will not be available until the broadcast begins.
#[serde(rename = "actualStartTime")]
pub actual_start_time: Option<chrono::DateTime<chrono::offset::Utc>>,
/// 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<serde_with::DisplayFromStr>")]
pub concurrent_viewers: Option<u64>,
/// The time that the broadcast is scheduled to end. If the value is empty or the property is not present, then the broadcast is scheduled to continue indefinitely.
#[serde(rename = "scheduledEndTime")]
pub scheduled_end_time: Option<chrono::DateTime<chrono::offset::Utc>>,
/// The time that the broadcast is scheduled to begin.
#[serde(rename = "scheduledStartTime")]
pub scheduled_start_time: Option<chrono::DateTime<chrono::offset::Utc>>,
}
impl common::Part for VideoLiveStreamingDetails {}
/// Localized versions of certain video properties (e.g. title).
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct VideoLocalization {
/// Localized version of the video's description.
pub description: Option<String>,
/// Localized version of the video's title.
pub title: Option<String>,
}
impl common::Part for VideoLocalization {}
/// Details about monetization of a YouTube Video.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct VideoMonetizationDetails {
/// The value of access indicates whether the video can be monetized or not.
pub access: Option<AccessPolicy>,
}
impl common::Part for VideoMonetizationDetails {}
/// Details about paid content, such as paid product placement, sponsorships or endorsement, contained in a YouTube video and a method to inform viewers of paid promotion. This data can only be retrieved by the video owner.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct VideoPaidProductPlacementDetails {
/// This boolean represents whether the video contains Paid Product Placement, Studio equivalent: https://screenshot.googleplex.com/4Me79DE6AfT2ktp.png
#[serde(rename = "hasPaidProductPlacement")]
pub has_paid_product_placement: Option<bool>,
}
impl common::Part for VideoPaidProductPlacementDetails {}
/// Player to be used for a video playback.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct VideoPlayer {
/// no description provided
#[serde(rename = "embedHeight")]
#[serde_as(as = "Option<serde_with::DisplayFromStr>")]
pub embed_height: Option<i64>,
/// An <iframe> tag that embeds a player that will play the video.
#[serde(rename = "embedHtml")]
pub embed_html: Option<String>,
/// The embed width
#[serde(rename = "embedWidth")]
#[serde_as(as = "Option<serde_with::DisplayFromStr>")]
pub embed_width: Option<i64>,
}
impl common::Part for VideoPlayer {}
/// Describes processing status and progress and availability of some other Video resource parts.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct VideoProcessingDetails {
/// This value indicates whether video editing suggestions, which might improve video quality or the playback experience, are available for the video. You can retrieve these suggestions by requesting the suggestions part in your videos.list() request.
#[serde(rename = "editorSuggestionsAvailability")]
pub editor_suggestions_availability: Option<String>,
/// This value indicates whether file details are available for the uploaded video. You can retrieve a video's file details by requesting the fileDetails part in your videos.list() request.
#[serde(rename = "fileDetailsAvailability")]
pub file_details_availability: Option<String>,
/// The reason that YouTube failed to process the video. This property will only have a value if the processingStatus property's value is failed.
#[serde(rename = "processingFailureReason")]
pub processing_failure_reason: Option<String>,
/// This value indicates whether the video processing engine has generated suggestions that might improve YouTube's ability to process the the video, warnings that explain video processing problems, or errors that cause video processing problems. You can retrieve these suggestions by requesting the suggestions part in your videos.list() request.
#[serde(rename = "processingIssuesAvailability")]
pub processing_issues_availability: Option<String>,
/// The processingProgress object contains information about the progress YouTube has made in processing the video. The values are really only relevant if the video's processing status is processing.
#[serde(rename = "processingProgress")]
pub processing_progress: Option<VideoProcessingDetailsProcessingProgress>,
/// The video's processing status. This value indicates whether YouTube was able to process the video or if the video is still being processed.
#[serde(rename = "processingStatus")]
pub processing_status: Option<String>,
/// This value indicates whether keyword (tag) suggestions are available for the video. Tags can be added to a video's metadata to make it easier for other users to find the video. You can retrieve these suggestions by requesting the suggestions part in your videos.list() request.
#[serde(rename = "tagSuggestionsAvailability")]
pub tag_suggestions_availability: Option<String>,
/// This value indicates whether thumbnail images have been generated for the video.
#[serde(rename = "thumbnailsAvailability")]
pub thumbnails_availability: Option<String>,
}
impl common::Part for VideoProcessingDetails {}
/// Video processing progress and completion time estimate.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct VideoProcessingDetailsProcessingProgress {
/// The number of parts of the video that YouTube has already processed. You can estimate the percentage of the video that YouTube has already processed by calculating: 100 * parts_processed / parts_total Note that since the estimated number of parts could increase without a corresponding increase in the number of parts that have already been processed, it is possible that the calculated progress could periodically decrease while YouTube processes a video.
#[serde(rename = "partsProcessed")]
#[serde_as(as = "Option<serde_with::DisplayFromStr>")]
pub parts_processed: Option<u64>,
/// An estimate of the total number of parts that need to be processed for the video. The number may be updated with more precise estimates while YouTube processes the video.
#[serde(rename = "partsTotal")]
#[serde_as(as = "Option<serde_with::DisplayFromStr>")]
pub parts_total: Option<u64>,
/// An estimate of the amount of time, in millseconds, that YouTube needs to finish processing the video.
#[serde(rename = "timeLeftMs")]
#[serde_as(as = "Option<serde_with::DisplayFromStr>")]
pub time_left_ms: Option<u64>,
}
impl common::Part for VideoProcessingDetailsProcessingProgress {}
/// DEPRECATED. b/157517979: This part was never populated after it was added. However, it sees non-zero traffic because there is generated client code in the wild that refers to it [1]. We keep this field and do NOT remove it because otherwise V3 would return an error when this part gets requested [2]. [1] https://developers.google.com/resources/api-libraries/documentation/youtube/v3/csharp/latest/classGoogle_1_1Apis_1_1YouTube_1_1v3_1_1Data_1_1VideoProjectDetails.html [2] http://google3/video/youtube/src/python/servers/data_api/common.py?l=1565-1569&rcl=344141677
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct VideoProjectDetails {
_never_set: Option<bool>,
}
impl common::Part for VideoProjectDetails {}
/// Basic details about rating of a video.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct VideoRating {
/// Rating of a video.
pub rating: Option<String>,
/// The ID that YouTube uses to uniquely identify the video.
#[serde(rename = "videoId")]
pub video_id: Option<String>,
}
impl common::Part for VideoRating {}
/// Recording information associated with the video.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct VideoRecordingDetails {
/// The geolocation information associated with the video.
pub location: Option<GeoPoint>,
/// The text description of the location where the video was recorded.
#[serde(rename = "locationDescription")]
pub location_description: Option<String>,
/// The date and time when the video was recorded.
#[serde(rename = "recordingDate")]
pub recording_date: Option<chrono::DateTime<chrono::offset::Utc>>,
}
impl common::Part for VideoRecordingDetails {}
/// Basic details about a video, including title, description, uploader, thumbnails and category.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct VideoSnippet {
/// The YouTube video category associated with the video.
#[serde(rename = "categoryId")]
pub category_id: Option<String>,
/// The ID that YouTube uses to uniquely identify the channel that the video was uploaded to.
#[serde(rename = "channelId")]
pub channel_id: Option<String>,
/// Channel title for the channel that the video belongs to.
#[serde(rename = "channelTitle")]
pub channel_title: Option<String>,
/// The default_audio_language property specifies the language spoken in the video's default audio track.
#[serde(rename = "defaultAudioLanguage")]
pub default_audio_language: Option<String>,
/// The language of the videos's default snippet.
#[serde(rename = "defaultLanguage")]
pub default_language: Option<String>,
/// The video's description. @mutable youtube.videos.insert youtube.videos.update
pub description: Option<String>,
/// Indicates if the video is an upcoming/active live broadcast. Or it's "none" if the video is not an upcoming/active live broadcast.
#[serde(rename = "liveBroadcastContent")]
pub live_broadcast_content: Option<String>,
/// Localized snippet selected with the hl parameter. If no such localization exists, this field is populated with the default snippet. (Read-only)
pub localized: Option<VideoLocalization>,
/// The date and time when the video was uploaded.
#[serde(rename = "publishedAt")]
pub published_at: Option<chrono::DateTime<chrono::offset::Utc>>,
/// A list of keyword tags associated with the video. Tags may contain spaces.
pub tags: Option<Vec<String>>,
/// A map of thumbnail images associated with the video. 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<ThumbnailDetails>,
/// The video's title. @mutable youtube.videos.insert youtube.videos.update
pub title: Option<String>,
}
impl common::Part for VideoSnippet {}
/// A *VideoStat* resource represents a YouTube video's stats.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct VideoStat {
/// Output only. The VideoStatsContentDetails object contains information about the video content, including the length of the video.
#[serde(rename = "contentDetails")]
pub content_details: Option<VideoStatsContentDetails>,
/// Output only. Etag of this resource.
pub etag: Option<String>,
/// Output only. The ID that YouTube uses to uniquely identify the video.
pub id: Option<String>,
/// Output only. Identifies what kind of resource this is. Value: the fixed string "youtube#videoStats".
pub kind: Option<String>,
/// Output only. The VideoStatsSnippet object contains basic details about the video, such publish time.
pub snippet: Option<VideoStatsSnippet>,
/// Output only. The VideoStatsStatistics object contains statistics about the video.
pub statistics: Option<VideoStatsStatistics>,
}
impl common::Part for VideoStat {}
/// Statistics about the video, such as the number of times the video was viewed or liked.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct VideoStatistics {
/// The number of comments for the video.
#[serde(rename = "commentCount")]
#[serde_as(as = "Option<serde_with::DisplayFromStr>")]
pub comment_count: Option<u64>,
/// The number of users who have indicated that they disliked the video by giving it a negative rating.
#[serde(rename = "dislikeCount")]
#[serde_as(as = "Option<serde_with::DisplayFromStr>")]
pub dislike_count: Option<u64>,
/// The number of users who currently have the video marked as a favorite video.
#[serde(rename = "favoriteCount")]
#[serde_as(as = "Option<serde_with::DisplayFromStr>")]
pub favorite_count: Option<u64>,
/// The number of users who have indicated that they liked the video by giving it a positive rating.
#[serde(rename = "likeCount")]
#[serde_as(as = "Option<serde_with::DisplayFromStr>")]
pub like_count: Option<u64>,
/// The number of times the video has been viewed.
#[serde(rename = "viewCount")]
#[serde_as(as = "Option<serde_with::DisplayFromStr>")]
pub view_count: Option<u64>,
}
impl common::Part for VideoStatistics {}
/// Details about the content of a YouTube Video. This is a subset of the information in VideoContentDetails specifically for the Videos.stats API.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct VideoStatsContentDetails {
/// Output only. The length of the video. The property value is a [`google.protobuf.Duration`](https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#duration) object.
#[serde_as(as = "Option<common::serde::duration::Wrapper>")]
pub duration: Option<chrono::Duration>,
}
impl common::Part for VideoStatsContentDetails {}
/// Basic details about a video. This is a subset of the information in VideoSnippet specifically for the Videos.stats API.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct VideoStatsSnippet {
/// Output only. The date and time that the video was uploaded. The property value is a [`google.protobuf.Timestamp`](https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#timestamp) object.
#[serde(rename = "publishTime")]
pub publish_time: Option<chrono::DateTime<chrono::offset::Utc>>,
}
impl common::Part for VideoStatsSnippet {}
/// Statistics about the video, such as the number of times the video was viewed or liked.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct VideoStatsStatistics {
/// Output only. The number of comments for the video.
#[serde(rename = "commentCount")]
#[serde_as(as = "Option<serde_with::DisplayFromStr>")]
pub comment_count: Option<i64>,
/// Output only. The number of users who have indicated that they liked the video by giving it a positive rating.
#[serde(rename = "likeCount")]
#[serde_as(as = "Option<serde_with::DisplayFromStr>")]
pub like_count: Option<i64>,
/// Output only. The number of times the video has been viewed.
#[serde(rename = "viewCount")]
#[serde_as(as = "Option<serde_with::DisplayFromStr>")]
pub view_count: Option<i64>,
}
impl common::Part for VideoStatsStatistics {}
/// Basic details about a video category, such as its localized title. Next Id: 19
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct VideoStatus {
/// Indicates if the video contains altered or synthetic media.
#[serde(rename = "containsSyntheticMedia")]
pub contains_synthetic_media: Option<bool>,
/// This value indicates if the video can be embedded on another website. @mutable youtube.videos.insert youtube.videos.update
pub embeddable: Option<bool>,
/// This value explains why a video failed to upload. This property is only present if the uploadStatus property indicates that the upload failed.
#[serde(rename = "failureReason")]
pub failure_reason: Option<String>,
/// The video's license. @mutable youtube.videos.insert youtube.videos.update
pub license: Option<String>,
/// no description provided
#[serde(rename = "madeForKids")]
pub made_for_kids: Option<bool>,
/// The video's privacy status.
#[serde(rename = "privacyStatus")]
pub privacy_status: Option<String>,
/// This value indicates if the extended video statistics on the watch page can be viewed by everyone. Note that the view count, likes, etc will still be visible if this is disabled. @mutable youtube.videos.insert youtube.videos.update
#[serde(rename = "publicStatsViewable")]
pub public_stats_viewable: Option<bool>,
/// The date and time when the video is scheduled to publish. It can be set only if the privacy status of the video is private..
#[serde(rename = "publishAt")]
pub publish_at: Option<chrono::DateTime<chrono::offset::Utc>>,
/// This value explains why YouTube rejected an uploaded video. This property is only present if the uploadStatus property indicates that the upload was rejected.
#[serde(rename = "rejectionReason")]
pub rejection_reason: Option<String>,
/// no description provided
#[serde(rename = "selfDeclaredMadeForKids")]
pub self_declared_made_for_kids: Option<bool>,
/// The status of the uploaded video.
#[serde(rename = "uploadStatus")]
pub upload_status: Option<String>,
}
impl common::Part for VideoStatus {}
/// Specifies suggestions on how to improve video content, including encoding hints, tag suggestions, and editor suggestions.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct VideoSuggestions {
/// A list of video editing operations that might improve the video quality or playback experience of the uploaded video.
#[serde(rename = "editorSuggestions")]
pub editor_suggestions: Option<Vec<String>>,
/// A list of errors that will prevent YouTube from successfully processing the uploaded video video. These errors indicate that, regardless of the video's current processing status, eventually, that status will almost certainly be failed.
#[serde(rename = "processingErrors")]
pub processing_errors: Option<Vec<String>>,
/// A list of suggestions that may improve YouTube's ability to process the video.
#[serde(rename = "processingHints")]
pub processing_hints: Option<Vec<String>>,
/// A list of reasons why YouTube may have difficulty transcoding the uploaded video or that might result in an erroneous transcoding. These warnings are generated before YouTube actually processes the uploaded video file. In addition, they identify issues that are unlikely to cause the video processing to fail but that might cause problems such as sync issues, video artifacts, or a missing audio track.
#[serde(rename = "processingWarnings")]
pub processing_warnings: Option<Vec<String>>,
/// A list of keyword tags that could be added to the video's metadata to increase the likelihood that users will locate your video when searching or browsing on YouTube.
#[serde(rename = "tagSuggestions")]
pub tag_suggestions: Option<Vec<VideoSuggestionsTagSuggestion>>,
}
impl common::Part for VideoSuggestions {}
/// A single tag suggestion with its relevance information.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct VideoSuggestionsTagSuggestion {
/// A set of video categories for which the tag is relevant. You can use this information to display appropriate tag suggestions based on the video category that the video uploader associates with the video. By default, tag suggestions are relevant for all categories if there are no restricts defined for the keyword.
#[serde(rename = "categoryRestricts")]
pub category_restricts: Option<Vec<String>>,
/// The keyword tag suggested for the video.
pub tag: Option<String>,
}
impl common::Part for VideoSuggestionsTagSuggestion {}
/// Freebase topic information related to the video.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct VideoTopicDetails {
/// Similar to topic_id, except that these topics are merely relevant to the video. These are topics that may be mentioned in, or appear in the video. You can retrieve information about each topic using Freebase Topic API.
#[serde(rename = "relevantTopicIds")]
pub relevant_topic_ids: Option<Vec<String>>,
/// A list of Wikipedia URLs that provide a high-level description of the video's content.
#[serde(rename = "topicCategories")]
pub topic_categories: Option<Vec<String>>,
/// A list of Freebase topic IDs that are centrally associated with the video. These are topics that are centrally featured in the video, and it can be said that the video is mainly about each of these. You can retrieve information about each topic using the < a href="http://wiki.freebase.com/wiki/Topic_API">Freebase Topic API.
#[serde(rename = "topicIds")]
pub topic_ids: Option<Vec<String>>,
}
impl common::Part for VideoTopicDetails {}
/// Specifies who is allowed to train on the 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*).
///
/// * [get video trainability](VideoTrainabilityGetCall) (response)
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct VideoTrainability {
/// Etag of this resource.
pub etag: Option<String>,
/// Identifies what kind of resource this is. Value: the fixed string "youtube#videoTrainability".
pub kind: Option<String>,
/// Specifies who is allowed to train on the video. Valid values are: - a single string "all" - a single string "none" - a list of allowed parties
pub permitted: Option<Vec<String>>,
/// The ID of the video.
#[serde(rename = "videoId")]
pub video_id: Option<String>,
}
impl common::ResponseResult for VideoTrainability {}
/// Branding properties for the watch. All deprecated.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct WatchSettings {
/// The text color for the video watch page's branded area.
#[serde(rename = "backgroundColor")]
pub background_color: Option<String>,
/// An ID that uniquely identifies a playlist that displays next to the video player.
#[serde(rename = "featuredPlaylistId")]
pub featured_playlist_id: Option<String>,
/// The background color for the video watch page's branded area.
#[serde(rename = "textColor")]
pub text_color: Option<String>,
}
impl common::Part for WatchSettings {}
/// There is no detailed description.
///
/// This type is not used in any activity, and only used as *part* of another schema.
///
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[serde_with::serde_as]
#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub struct ChannelContentDetailsRelatedPlaylists {
/// The ID of the playlist that contains the channel"s favorite videos. Use the playlistItems.insert and playlistItems.delete to add or remove items from that list.
pub favorites: Option<String>,
/// The ID of the playlist that contains the channel"s liked videos. Use the playlistItems.insert and playlistItems.delete to add or remove items from that list.
pub likes: Option<String>,
/// The ID of the playlist that contains the channel"s uploaded videos. Use the videos.insert method to upload new videos and the videos.delete method to delete previously uploaded videos.
pub uploads: Option<String>,
/// The ID of the playlist that contains the channel"s watch history. Use the playlistItems.insert and playlistItems.delete to add or remove items from that list.
#[serde(rename = "watchHistory")]
pub watch_history: Option<String>,
/// The ID of the playlist that contains the channel"s watch later playlist. Use the playlistItems.insert and playlistItems.delete to add or remove items from that list.
#[serde(rename = "watchLater")]
pub watch_later: Option<String>,
}
impl common::NestedType for ChannelContentDetailsRelatedPlaylists {}
impl common::Part for ChannelContentDetailsRelatedPlaylists {}
// ###################
// MethodBuilders ###
// #################
/// 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 youtube3::{YouTube, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// let secret: yup_oauth2::ApplicationSecret = Default::default();
/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// .with_native_roots()
/// .unwrap()
/// .https_only()
/// .enable_http2()
/// .build();
///
/// let executor = hyper_util::rt::TokioExecutor::new();
/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// secret,
/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// yup_oauth2::client::CustomHyperClientBuilder::from(
/// hyper_util::client::legacy::Client::builder(executor).build(connector),
/// ),
/// ).build().await.unwrap();
///
/// let client = hyper_util::client::legacy::Client::builder(
/// hyper_util::rt::TokioExecutor::new()
/// )
/// .build(
/// hyper_rustls::HttpsConnectorBuilder::new()
/// .with_native_roots()
/// .unwrap()
/// .https_or_http()
/// .enable_http2()
/// .build()
/// );
/// let mut hub = YouTube::new(client, 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, C>
where
C: 'a,
{
hub: &'a YouTube<C>,
}
impl<'a, C> common::MethodsBuilder for AbuseReportMethods<'a, C> {}
impl<'a, C> AbuseReportMethods<'a, C> {
/// 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, C> {
use common::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 youtube3::{YouTube, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// let secret: yup_oauth2::ApplicationSecret = Default::default();
/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// .with_native_roots()
/// .unwrap()
/// .https_only()
/// .enable_http2()
/// .build();
///
/// let executor = hyper_util::rt::TokioExecutor::new();
/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// secret,
/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// yup_oauth2::client::CustomHyperClientBuilder::from(
/// hyper_util::client::legacy::Client::builder(executor).build(connector),
/// ),
/// ).build().await.unwrap();
///
/// let client = hyper_util::client::legacy::Client::builder(
/// hyper_util::rt::TokioExecutor::new()
/// )
/// .build(
/// hyper_rustls::HttpsConnectorBuilder::new()
/// .with_native_roots()
/// .unwrap()
/// .https_or_http()
/// .enable_http2()
/// .build()
/// );
/// let mut hub = YouTube::new(client, 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, C>
where
C: 'a,
{
hub: &'a YouTube<C>,
}
impl<'a, C> common::MethodsBuilder for ActivityMethods<'a, C> {}
impl<'a, C> ActivityMethods<'a, C> {
/// 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<String>) -> ActivityListCall<'a, C> {
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 youtube3::{YouTube, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// let secret: yup_oauth2::ApplicationSecret = Default::default();
/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// .with_native_roots()
/// .unwrap()
/// .https_only()
/// .enable_http2()
/// .build();
///
/// let executor = hyper_util::rt::TokioExecutor::new();
/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// secret,
/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// yup_oauth2::client::CustomHyperClientBuilder::from(
/// hyper_util::client::legacy::Client::builder(executor).build(connector),
/// ),
/// ).build().await.unwrap();
///
/// let client = hyper_util::client::legacy::Client::builder(
/// hyper_util::rt::TokioExecutor::new()
/// )
/// .build(
/// hyper_rustls::HttpsConnectorBuilder::new()
/// .with_native_roots()
/// .unwrap()
/// .https_or_http()
/// .enable_http2()
/// .build()
/// );
/// let mut hub = YouTube::new(client, 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, C>
where
C: 'a,
{
hub: &'a YouTube<C>,
}
impl<'a, C> common::MethodsBuilder for CaptionMethods<'a, C> {}
impl<'a, C> CaptionMethods<'a, C> {
/// 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, C> {
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, C> {
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, C> {
use common::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<String>, video_id: &str) -> CaptionListCall<'a, C> {
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, C> {
use common::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 youtube3::{YouTube, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// let secret: yup_oauth2::ApplicationSecret = Default::default();
/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// .with_native_roots()
/// .unwrap()
/// .https_only()
/// .enable_http2()
/// .build();
///
/// let executor = hyper_util::rt::TokioExecutor::new();
/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// secret,
/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// yup_oauth2::client::CustomHyperClientBuilder::from(
/// hyper_util::client::legacy::Client::builder(executor).build(connector),
/// ),
/// ).build().await.unwrap();
///
/// let client = hyper_util::client::legacy::Client::builder(
/// hyper_util::rt::TokioExecutor::new()
/// )
/// .build(
/// hyper_rustls::HttpsConnectorBuilder::new()
/// .with_native_roots()
/// .unwrap()
/// .https_or_http()
/// .enable_http2()
/// .build()
/// );
/// let mut hub = YouTube::new(client, 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, C>
where
C: 'a,
{
hub: &'a YouTube<C>,
}
impl<'a, C> common::MethodsBuilder for ChannelBannerMethods<'a, C> {}
impl<'a, C> ChannelBannerMethods<'a, C> {
/// 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, C> {
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 youtube3::{YouTube, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// let secret: yup_oauth2::ApplicationSecret = Default::default();
/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// .with_native_roots()
/// .unwrap()
/// .https_only()
/// .enable_http2()
/// .build();
///
/// let executor = hyper_util::rt::TokioExecutor::new();
/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// secret,
/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// yup_oauth2::client::CustomHyperClientBuilder::from(
/// hyper_util::client::legacy::Client::builder(executor).build(connector),
/// ),
/// ).build().await.unwrap();
///
/// let client = hyper_util::client::legacy::Client::builder(
/// hyper_util::rt::TokioExecutor::new()
/// )
/// .build(
/// hyper_rustls::HttpsConnectorBuilder::new()
/// .with_native_roots()
/// .unwrap()
/// .https_or_http()
/// .enable_http2()
/// .build()
/// );
/// let mut hub = YouTube::new(client, 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, C>
where
C: 'a,
{
hub: &'a YouTube<C>,
}
impl<'a, C> common::MethodsBuilder for ChannelSectionMethods<'a, C> {}
impl<'a, C> ChannelSectionMethods<'a, C> {
/// 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, C> {
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, C> {
use common::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<String>) -> ChannelSectionListCall<'a, C> {
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, C> {
use common::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 youtube3::{YouTube, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// let secret: yup_oauth2::ApplicationSecret = Default::default();
/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// .with_native_roots()
/// .unwrap()
/// .https_only()
/// .enable_http2()
/// .build();
///
/// let executor = hyper_util::rt::TokioExecutor::new();
/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// secret,
/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// yup_oauth2::client::CustomHyperClientBuilder::from(
/// hyper_util::client::legacy::Client::builder(executor).build(connector),
/// ),
/// ).build().await.unwrap();
///
/// let client = hyper_util::client::legacy::Client::builder(
/// hyper_util::rt::TokioExecutor::new()
/// )
/// .build(
/// hyper_rustls::HttpsConnectorBuilder::new()
/// .with_native_roots()
/// .unwrap()
/// .https_or_http()
/// .enable_http2()
/// .build()
/// );
/// let mut hub = YouTube::new(client, 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, C>
where
C: 'a,
{
hub: &'a YouTube<C>,
}
impl<'a, C> common::MethodsBuilder for ChannelMethods<'a, C> {}
impl<'a, C> ChannelMethods<'a, C> {
/// 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<String>) -> ChannelListCall<'a, C> {
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, C> {
use common::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 youtube3::{YouTube, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// let secret: yup_oauth2::ApplicationSecret = Default::default();
/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// .with_native_roots()
/// .unwrap()
/// .https_only()
/// .enable_http2()
/// .build();
///
/// let executor = hyper_util::rt::TokioExecutor::new();
/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// secret,
/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// yup_oauth2::client::CustomHyperClientBuilder::from(
/// hyper_util::client::legacy::Client::builder(executor).build(connector),
/// ),
/// ).build().await.unwrap();
///
/// let client = hyper_util::client::legacy::Client::builder(
/// hyper_util::rt::TokioExecutor::new()
/// )
/// .build(
/// hyper_rustls::HttpsConnectorBuilder::new()
/// .with_native_roots()
/// .unwrap()
/// .https_or_http()
/// .enable_http2()
/// .build()
/// );
/// let mut hub = YouTube::new(client, 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, C>
where
C: 'a,
{
hub: &'a YouTube<C>,
}
impl<'a, C> common::MethodsBuilder for CommentThreadMethods<'a, C> {}
impl<'a, C> CommentThreadMethods<'a, C> {
/// 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, C> {
use common::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<String>) -> CommentThreadListCall<'a, C> {
CommentThreadListCall {
hub: self.hub,
_part: part.clone(),
_video_id: Default::default(),
_text_format: Default::default(),
_search_terms: Default::default(),
_post_id: 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 youtube3::{YouTube, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// let secret: yup_oauth2::ApplicationSecret = Default::default();
/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// .with_native_roots()
/// .unwrap()
/// .https_only()
/// .enable_http2()
/// .build();
///
/// let executor = hyper_util::rt::TokioExecutor::new();
/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// secret,
/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// yup_oauth2::client::CustomHyperClientBuilder::from(
/// hyper_util::client::legacy::Client::builder(executor).build(connector),
/// ),
/// ).build().await.unwrap();
///
/// let client = hyper_util::client::legacy::Client::builder(
/// hyper_util::rt::TokioExecutor::new()
/// )
/// .build(
/// hyper_rustls::HttpsConnectorBuilder::new()
/// .with_native_roots()
/// .unwrap()
/// .https_or_http()
/// .enable_http2()
/// .build()
/// );
/// let mut hub = YouTube::new(client, 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, C>
where
C: 'a,
{
hub: &'a YouTube<C>,
}
impl<'a, C> common::MethodsBuilder for CommentMethods<'a, C> {}
impl<'a, C> CommentMethods<'a, C> {
/// 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, C> {
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, C> {
use common::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<String>) -> CommentListCall<'a, C> {
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<String>) -> CommentMarkAsSpamCall<'a, C> {
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<String>,
moderation_status: &str,
) -> CommentSetModerationStatuCall<'a, C> {
CommentSetModerationStatuCall {
hub: self.hub,
_id: id.clone(),
_moderation_status: moderation_status.to_string(),
_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, C> {
use common::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 youtube3::{YouTube, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// let secret: yup_oauth2::ApplicationSecret = Default::default();
/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// .with_native_roots()
/// .unwrap()
/// .https_only()
/// .enable_http2()
/// .build();
///
/// let executor = hyper_util::rt::TokioExecutor::new();
/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// secret,
/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// yup_oauth2::client::CustomHyperClientBuilder::from(
/// hyper_util::client::legacy::Client::builder(executor).build(connector),
/// ),
/// ).build().await.unwrap();
///
/// let client = hyper_util::client::legacy::Client::builder(
/// hyper_util::rt::TokioExecutor::new()
/// )
/// .build(
/// hyper_rustls::HttpsConnectorBuilder::new()
/// .with_native_roots()
/// .unwrap()
/// .https_or_http()
/// .enable_http2()
/// .build()
/// );
/// let mut hub = YouTube::new(client, 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, C>
where
C: 'a,
{
hub: &'a YouTube<C>,
}
impl<'a, C> common::MethodsBuilder for I18nLanguageMethods<'a, C> {}
impl<'a, C> I18nLanguageMethods<'a, C> {
/// 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<String>) -> I18nLanguageListCall<'a, C> {
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 youtube3::{YouTube, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// let secret: yup_oauth2::ApplicationSecret = Default::default();
/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// .with_native_roots()
/// .unwrap()
/// .https_only()
/// .enable_http2()
/// .build();
///
/// let executor = hyper_util::rt::TokioExecutor::new();
/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// secret,
/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// yup_oauth2::client::CustomHyperClientBuilder::from(
/// hyper_util::client::legacy::Client::builder(executor).build(connector),
/// ),
/// ).build().await.unwrap();
///
/// let client = hyper_util::client::legacy::Client::builder(
/// hyper_util::rt::TokioExecutor::new()
/// )
/// .build(
/// hyper_rustls::HttpsConnectorBuilder::new()
/// .with_native_roots()
/// .unwrap()
/// .https_or_http()
/// .enable_http2()
/// .build()
/// );
/// let mut hub = YouTube::new(client, 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, C>
where
C: 'a,
{
hub: &'a YouTube<C>,
}
impl<'a, C> common::MethodsBuilder for I18nRegionMethods<'a, C> {}
impl<'a, C> I18nRegionMethods<'a, C> {
/// 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<String>) -> I18nRegionListCall<'a, C> {
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 youtube3::{YouTube, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// let secret: yup_oauth2::ApplicationSecret = Default::default();
/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// .with_native_roots()
/// .unwrap()
/// .https_only()
/// .enable_http2()
/// .build();
///
/// let executor = hyper_util::rt::TokioExecutor::new();
/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// secret,
/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// yup_oauth2::client::CustomHyperClientBuilder::from(
/// hyper_util::client::legacy::Client::builder(executor).build(connector),
/// ),
/// ).build().await.unwrap();
///
/// let client = hyper_util::client::legacy::Client::builder(
/// hyper_util::rt::TokioExecutor::new()
/// )
/// .build(
/// hyper_rustls::HttpsConnectorBuilder::new()
/// .with_native_roots()
/// .unwrap()
/// .https_or_http()
/// .enable_http2()
/// .build()
/// );
/// let mut hub = YouTube::new(client, 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, C>
where
C: 'a,
{
hub: &'a YouTube<C>,
}
impl<'a, C> common::MethodsBuilder for LiveBroadcastMethods<'a, C> {}
impl<'a, C> LiveBroadcastMethods<'a, C> {
/// 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<String>) -> LiveBroadcastBindCall<'a, C> {
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, C> {
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, C> {
use common::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, C> {
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<String>) -> LiveBroadcastListCall<'a, C> {
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: &str,
id: &str,
part: &Vec<String>,
) -> LiveBroadcastTransitionCall<'a, C> {
LiveBroadcastTransitionCall {
hub: self.hub,
_broadcast_status: broadcast_status.to_string(),
_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, C> {
use common::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 youtube3::{YouTube, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// let secret: yup_oauth2::ApplicationSecret = Default::default();
/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// .with_native_roots()
/// .unwrap()
/// .https_only()
/// .enable_http2()
/// .build();
///
/// let executor = hyper_util::rt::TokioExecutor::new();
/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// secret,
/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// yup_oauth2::client::CustomHyperClientBuilder::from(
/// hyper_util::client::legacy::Client::builder(executor).build(connector),
/// ),
/// ).build().await.unwrap();
///
/// let client = hyper_util::client::legacy::Client::builder(
/// hyper_util::rt::TokioExecutor::new()
/// )
/// .build(
/// hyper_rustls::HttpsConnectorBuilder::new()
/// .with_native_roots()
/// .unwrap()
/// .https_or_http()
/// .enable_http2()
/// .build()
/// );
/// let mut hub = YouTube::new(client, 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, C>
where
C: 'a,
{
hub: &'a YouTube<C>,
}
impl<'a, C> common::MethodsBuilder for LiveChatBanMethods<'a, C> {}
impl<'a, C> LiveChatBanMethods<'a, C> {
/// 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, C> {
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, C> {
use common::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 youtube3::{YouTube, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// let secret: yup_oauth2::ApplicationSecret = Default::default();
/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// .with_native_roots()
/// .unwrap()
/// .https_only()
/// .enable_http2()
/// .build();
///
/// let executor = hyper_util::rt::TokioExecutor::new();
/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// secret,
/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// yup_oauth2::client::CustomHyperClientBuilder::from(
/// hyper_util::client::legacy::Client::builder(executor).build(connector),
/// ),
/// ).build().await.unwrap();
///
/// let client = hyper_util::client::legacy::Client::builder(
/// hyper_util::rt::TokioExecutor::new()
/// )
/// .build(
/// hyper_rustls::HttpsConnectorBuilder::new()
/// .with_native_roots()
/// .unwrap()
/// .https_or_http()
/// .enable_http2()
/// .build()
/// );
/// let mut hub = YouTube::new(client, auth);
/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
/// // like `delete(...)`, `insert(...)`, `list(...)` and `transition(...)`
/// // to build up your call.
/// let rb = hub.live_chat_messages();
/// # }
/// ```
pub struct LiveChatMessageMethods<'a, C>
where
C: 'a,
{
hub: &'a YouTube<C>,
}
impl<'a, C> common::MethodsBuilder for LiveChatMessageMethods<'a, C> {}
impl<'a, C> LiveChatMessageMethods<'a, C> {
/// 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, C> {
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, C> {
use common::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, snippet, and authorDetails.
pub fn list(&self, live_chat_id: &str, part: &Vec<String>) -> LiveChatMessageListCall<'a, C> {
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(),
}
}
/// Create a builder to help you perform the following task:
///
/// Transition a durable chat event.
pub fn transition(&self) -> LiveChatMessageTransitionCall<'a, C> {
LiveChatMessageTransitionCall {
hub: self.hub,
_status: Default::default(),
_id: 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 youtube3::{YouTube, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// let secret: yup_oauth2::ApplicationSecret = Default::default();
/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// .with_native_roots()
/// .unwrap()
/// .https_only()
/// .enable_http2()
/// .build();
///
/// let executor = hyper_util::rt::TokioExecutor::new();
/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// secret,
/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// yup_oauth2::client::CustomHyperClientBuilder::from(
/// hyper_util::client::legacy::Client::builder(executor).build(connector),
/// ),
/// ).build().await.unwrap();
///
/// let client = hyper_util::client::legacy::Client::builder(
/// hyper_util::rt::TokioExecutor::new()
/// )
/// .build(
/// hyper_rustls::HttpsConnectorBuilder::new()
/// .with_native_roots()
/// .unwrap()
/// .https_or_http()
/// .enable_http2()
/// .build()
/// );
/// let mut hub = YouTube::new(client, 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, C>
where
C: 'a,
{
hub: &'a YouTube<C>,
}
impl<'a, C> common::MethodsBuilder for LiveChatModeratorMethods<'a, C> {}
impl<'a, C> LiveChatModeratorMethods<'a, C> {
/// 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, C> {
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, C> {
use common::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<String>) -> LiveChatModeratorListCall<'a, C> {
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 youtube3::{YouTube, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// let secret: yup_oauth2::ApplicationSecret = Default::default();
/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// .with_native_roots()
/// .unwrap()
/// .https_only()
/// .enable_http2()
/// .build();
///
/// let executor = hyper_util::rt::TokioExecutor::new();
/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// secret,
/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// yup_oauth2::client::CustomHyperClientBuilder::from(
/// hyper_util::client::legacy::Client::builder(executor).build(connector),
/// ),
/// ).build().await.unwrap();
///
/// let client = hyper_util::client::legacy::Client::builder(
/// hyper_util::rt::TokioExecutor::new()
/// )
/// .build(
/// hyper_rustls::HttpsConnectorBuilder::new()
/// .with_native_roots()
/// .unwrap()
/// .https_or_http()
/// .enable_http2()
/// .build()
/// );
/// let mut hub = YouTube::new(client, 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, C>
where
C: 'a,
{
hub: &'a YouTube<C>,
}
impl<'a, C> common::MethodsBuilder for LiveStreamMethods<'a, C> {}
impl<'a, C> LiveStreamMethods<'a, C> {
/// 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, C> {
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, C> {
use common::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<String>) -> LiveStreamListCall<'a, C> {
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, C> {
use common::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 youtube3::{YouTube, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// let secret: yup_oauth2::ApplicationSecret = Default::default();
/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// .with_native_roots()
/// .unwrap()
/// .https_only()
/// .enable_http2()
/// .build();
///
/// let executor = hyper_util::rt::TokioExecutor::new();
/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// secret,
/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// yup_oauth2::client::CustomHyperClientBuilder::from(
/// hyper_util::client::legacy::Client::builder(executor).build(connector),
/// ),
/// ).build().await.unwrap();
///
/// let client = hyper_util::client::legacy::Client::builder(
/// hyper_util::rt::TokioExecutor::new()
/// )
/// .build(
/// hyper_rustls::HttpsConnectorBuilder::new()
/// .with_native_roots()
/// .unwrap()
/// .https_or_http()
/// .enable_http2()
/// .build()
/// );
/// let mut hub = YouTube::new(client, 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, C>
where
C: 'a,
{
hub: &'a YouTube<C>,
}
impl<'a, C> common::MethodsBuilder for MemberMethods<'a, C> {}
impl<'a, C> MemberMethods<'a, C> {
/// 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<String>) -> MemberListCall<'a, C> {
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 youtube3::{YouTube, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// let secret: yup_oauth2::ApplicationSecret = Default::default();
/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// .with_native_roots()
/// .unwrap()
/// .https_only()
/// .enable_http2()
/// .build();
///
/// let executor = hyper_util::rt::TokioExecutor::new();
/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// secret,
/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// yup_oauth2::client::CustomHyperClientBuilder::from(
/// hyper_util::client::legacy::Client::builder(executor).build(connector),
/// ),
/// ).build().await.unwrap();
///
/// let client = hyper_util::client::legacy::Client::builder(
/// hyper_util::rt::TokioExecutor::new()
/// )
/// .build(
/// hyper_rustls::HttpsConnectorBuilder::new()
/// .with_native_roots()
/// .unwrap()
/// .https_or_http()
/// .enable_http2()
/// .build()
/// );
/// let mut hub = YouTube::new(client, 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, C>
where
C: 'a,
{
hub: &'a YouTube<C>,
}
impl<'a, C> common::MethodsBuilder for MembershipsLevelMethods<'a, C> {}
impl<'a, C> MembershipsLevelMethods<'a, C> {
/// 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<String>) -> MembershipsLevelListCall<'a, C> {
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 youtube3::{YouTube, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// let secret: yup_oauth2::ApplicationSecret = Default::default();
/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// .with_native_roots()
/// .unwrap()
/// .https_only()
/// .enable_http2()
/// .build();
///
/// let executor = hyper_util::rt::TokioExecutor::new();
/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// secret,
/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// yup_oauth2::client::CustomHyperClientBuilder::from(
/// hyper_util::client::legacy::Client::builder(executor).build(connector),
/// ),
/// ).build().await.unwrap();
///
/// let client = hyper_util::client::legacy::Client::builder(
/// hyper_util::rt::TokioExecutor::new()
/// )
/// .build(
/// hyper_rustls::HttpsConnectorBuilder::new()
/// .with_native_roots()
/// .unwrap()
/// .https_or_http()
/// .enable_http2()
/// .build()
/// );
/// let mut hub = YouTube::new(client, 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, C>
where
C: 'a,
{
hub: &'a YouTube<C>,
}
impl<'a, C> common::MethodsBuilder for PlaylistImageMethods<'a, C> {}
impl<'a, C> PlaylistImageMethods<'a, C> {
/// Create a builder to help you perform the following task:
///
/// Deletes a resource.
pub fn delete(&self) -> PlaylistImageDeleteCall<'a, C> {
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, C> {
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, C> {
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, C> {
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 youtube3::{YouTube, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// let secret: yup_oauth2::ApplicationSecret = Default::default();
/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// .with_native_roots()
/// .unwrap()
/// .https_only()
/// .enable_http2()
/// .build();
///
/// let executor = hyper_util::rt::TokioExecutor::new();
/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// secret,
/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// yup_oauth2::client::CustomHyperClientBuilder::from(
/// hyper_util::client::legacy::Client::builder(executor).build(connector),
/// ),
/// ).build().await.unwrap();
///
/// let client = hyper_util::client::legacy::Client::builder(
/// hyper_util::rt::TokioExecutor::new()
/// )
/// .build(
/// hyper_rustls::HttpsConnectorBuilder::new()
/// .with_native_roots()
/// .unwrap()
/// .https_or_http()
/// .enable_http2()
/// .build()
/// );
/// let mut hub = YouTube::new(client, 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, C>
where
C: 'a,
{
hub: &'a YouTube<C>,
}
impl<'a, C> common::MethodsBuilder for PlaylistItemMethods<'a, C> {}
impl<'a, C> PlaylistItemMethods<'a, C> {
/// 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, C> {
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, C> {
use common::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<String>) -> PlaylistItemListCall<'a, C> {
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, C> {
use common::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 youtube3::{YouTube, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// let secret: yup_oauth2::ApplicationSecret = Default::default();
/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// .with_native_roots()
/// .unwrap()
/// .https_only()
/// .enable_http2()
/// .build();
///
/// let executor = hyper_util::rt::TokioExecutor::new();
/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// secret,
/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// yup_oauth2::client::CustomHyperClientBuilder::from(
/// hyper_util::client::legacy::Client::builder(executor).build(connector),
/// ),
/// ).build().await.unwrap();
///
/// let client = hyper_util::client::legacy::Client::builder(
/// hyper_util::rt::TokioExecutor::new()
/// )
/// .build(
/// hyper_rustls::HttpsConnectorBuilder::new()
/// .with_native_roots()
/// .unwrap()
/// .https_or_http()
/// .enable_http2()
/// .build()
/// );
/// let mut hub = YouTube::new(client, 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, C>
where
C: 'a,
{
hub: &'a YouTube<C>,
}
impl<'a, C> common::MethodsBuilder for PlaylistMethods<'a, C> {}
impl<'a, C> PlaylistMethods<'a, C> {
/// 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, C> {
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, C> {
use common::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<String>) -> PlaylistListCall<'a, C> {
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, C> {
use common::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 youtube3::{YouTube, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// let secret: yup_oauth2::ApplicationSecret = Default::default();
/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// .with_native_roots()
/// .unwrap()
/// .https_only()
/// .enable_http2()
/// .build();
///
/// let executor = hyper_util::rt::TokioExecutor::new();
/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// secret,
/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// yup_oauth2::client::CustomHyperClientBuilder::from(
/// hyper_util::client::legacy::Client::builder(executor).build(connector),
/// ),
/// ).build().await.unwrap();
///
/// let client = hyper_util::client::legacy::Client::builder(
/// hyper_util::rt::TokioExecutor::new()
/// )
/// .build(
/// hyper_rustls::HttpsConnectorBuilder::new()
/// .with_native_roots()
/// .unwrap()
/// .https_or_http()
/// .enable_http2()
/// .build()
/// );
/// let mut hub = YouTube::new(client, 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, C>
where
C: 'a,
{
hub: &'a YouTube<C>,
}
impl<'a, C> common::MethodsBuilder for SearchMethods<'a, C> {}
impl<'a, C> SearchMethods<'a, C> {
/// 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<String>) -> SearchListCall<'a, C> {
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 youtube3::{YouTube, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// let secret: yup_oauth2::ApplicationSecret = Default::default();
/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// .with_native_roots()
/// .unwrap()
/// .https_only()
/// .enable_http2()
/// .build();
///
/// let executor = hyper_util::rt::TokioExecutor::new();
/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// secret,
/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// yup_oauth2::client::CustomHyperClientBuilder::from(
/// hyper_util::client::legacy::Client::builder(executor).build(connector),
/// ),
/// ).build().await.unwrap();
///
/// let client = hyper_util::client::legacy::Client::builder(
/// hyper_util::rt::TokioExecutor::new()
/// )
/// .build(
/// hyper_rustls::HttpsConnectorBuilder::new()
/// .with_native_roots()
/// .unwrap()
/// .https_or_http()
/// .enable_http2()
/// .build()
/// );
/// let mut hub = YouTube::new(client, 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, C>
where
C: 'a,
{
hub: &'a YouTube<C>,
}
impl<'a, C> common::MethodsBuilder for SubscriptionMethods<'a, C> {}
impl<'a, C> SubscriptionMethods<'a, C> {
/// 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, C> {
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, C> {
use common::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<String>) -> SubscriptionListCall<'a, C> {
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 youtube3::{YouTube, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// let secret: yup_oauth2::ApplicationSecret = Default::default();
/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// .with_native_roots()
/// .unwrap()
/// .https_only()
/// .enable_http2()
/// .build();
///
/// let executor = hyper_util::rt::TokioExecutor::new();
/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// secret,
/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// yup_oauth2::client::CustomHyperClientBuilder::from(
/// hyper_util::client::legacy::Client::builder(executor).build(connector),
/// ),
/// ).build().await.unwrap();
///
/// let client = hyper_util::client::legacy::Client::builder(
/// hyper_util::rt::TokioExecutor::new()
/// )
/// .build(
/// hyper_rustls::HttpsConnectorBuilder::new()
/// .with_native_roots()
/// .unwrap()
/// .https_or_http()
/// .enable_http2()
/// .build()
/// );
/// let mut hub = YouTube::new(client, 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, C>
where
C: 'a,
{
hub: &'a YouTube<C>,
}
impl<'a, C> common::MethodsBuilder for SuperChatEventMethods<'a, C> {}
impl<'a, C> SuperChatEventMethods<'a, C> {
/// 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<String>) -> SuperChatEventListCall<'a, C> {
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 youtube3::{YouTube, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// let secret: yup_oauth2::ApplicationSecret = Default::default();
/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// .with_native_roots()
/// .unwrap()
/// .https_only()
/// .enable_http2()
/// .build();
///
/// let executor = hyper_util::rt::TokioExecutor::new();
/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// secret,
/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// yup_oauth2::client::CustomHyperClientBuilder::from(
/// hyper_util::client::legacy::Client::builder(executor).build(connector),
/// ),
/// ).build().await.unwrap();
///
/// let client = hyper_util::client::legacy::Client::builder(
/// hyper_util::rt::TokioExecutor::new()
/// )
/// .build(
/// hyper_rustls::HttpsConnectorBuilder::new()
/// .with_native_roots()
/// .unwrap()
/// .https_or_http()
/// .enable_http2()
/// .build()
/// );
/// let mut hub = YouTube::new(client, 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, C>
where
C: 'a,
{
hub: &'a YouTube<C>,
}
impl<'a, C> common::MethodsBuilder for TestMethods<'a, C> {}
impl<'a, C> TestMethods<'a, C> {
/// 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, C> {
use common::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 youtube3::{YouTube, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// let secret: yup_oauth2::ApplicationSecret = Default::default();
/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// .with_native_roots()
/// .unwrap()
/// .https_only()
/// .enable_http2()
/// .build();
///
/// let executor = hyper_util::rt::TokioExecutor::new();
/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// secret,
/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// yup_oauth2::client::CustomHyperClientBuilder::from(
/// hyper_util::client::legacy::Client::builder(executor).build(connector),
/// ),
/// ).build().await.unwrap();
///
/// let client = hyper_util::client::legacy::Client::builder(
/// hyper_util::rt::TokioExecutor::new()
/// )
/// .build(
/// hyper_rustls::HttpsConnectorBuilder::new()
/// .with_native_roots()
/// .unwrap()
/// .https_or_http()
/// .enable_http2()
/// .build()
/// );
/// let mut hub = YouTube::new(client, 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, C>
where
C: 'a,
{
hub: &'a YouTube<C>,
}
impl<'a, C> common::MethodsBuilder for ThirdPartyLinkMethods<'a, C> {}
impl<'a, C> ThirdPartyLinkMethods<'a, C> {
/// 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_: &str) -> ThirdPartyLinkDeleteCall<'a, C> {
ThirdPartyLinkDeleteCall {
hub: self.hub,
_linking_token: linking_token.to_string(),
_type_: type_.to_string(),
_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, C> {
use common::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<String>) -> ThirdPartyLinkListCall<'a, C> {
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, C> {
use common::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 youtube3::{YouTube, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// let secret: yup_oauth2::ApplicationSecret = Default::default();
/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// .with_native_roots()
/// .unwrap()
/// .https_only()
/// .enable_http2()
/// .build();
///
/// let executor = hyper_util::rt::TokioExecutor::new();
/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// secret,
/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// yup_oauth2::client::CustomHyperClientBuilder::from(
/// hyper_util::client::legacy::Client::builder(executor).build(connector),
/// ),
/// ).build().await.unwrap();
///
/// let client = hyper_util::client::legacy::Client::builder(
/// hyper_util::rt::TokioExecutor::new()
/// )
/// .build(
/// hyper_rustls::HttpsConnectorBuilder::new()
/// .with_native_roots()
/// .unwrap()
/// .https_or_http()
/// .enable_http2()
/// .build()
/// );
/// let mut hub = YouTube::new(client, 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, C>
where
C: 'a,
{
hub: &'a YouTube<C>,
}
impl<'a, C> common::MethodsBuilder for ThumbnailMethods<'a, C> {}
impl<'a, C> ThumbnailMethods<'a, C> {
/// 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, C> {
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 youtube3::{YouTube, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// let secret: yup_oauth2::ApplicationSecret = Default::default();
/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// .with_native_roots()
/// .unwrap()
/// .https_only()
/// .enable_http2()
/// .build();
///
/// let executor = hyper_util::rt::TokioExecutor::new();
/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// secret,
/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// yup_oauth2::client::CustomHyperClientBuilder::from(
/// hyper_util::client::legacy::Client::builder(executor).build(connector),
/// ),
/// ).build().await.unwrap();
///
/// let client = hyper_util::client::legacy::Client::builder(
/// hyper_util::rt::TokioExecutor::new()
/// )
/// .build(
/// hyper_rustls::HttpsConnectorBuilder::new()
/// .with_native_roots()
/// .unwrap()
/// .https_or_http()
/// .enable_http2()
/// .build()
/// );
/// let mut hub = YouTube::new(client, 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, C>
where
C: 'a,
{
hub: &'a YouTube<C>,
}
impl<'a, C> common::MethodsBuilder for VideoAbuseReportReasonMethods<'a, C> {}
impl<'a, C> VideoAbuseReportReasonMethods<'a, C> {
/// 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<String>) -> VideoAbuseReportReasonListCall<'a, C> {
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 youtube3::{YouTube, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// let secret: yup_oauth2::ApplicationSecret = Default::default();
/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// .with_native_roots()
/// .unwrap()
/// .https_only()
/// .enable_http2()
/// .build();
///
/// let executor = hyper_util::rt::TokioExecutor::new();
/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// secret,
/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// yup_oauth2::client::CustomHyperClientBuilder::from(
/// hyper_util::client::legacy::Client::builder(executor).build(connector),
/// ),
/// ).build().await.unwrap();
///
/// let client = hyper_util::client::legacy::Client::builder(
/// hyper_util::rt::TokioExecutor::new()
/// )
/// .build(
/// hyper_rustls::HttpsConnectorBuilder::new()
/// .with_native_roots()
/// .unwrap()
/// .https_or_http()
/// .enable_http2()
/// .build()
/// );
/// let mut hub = YouTube::new(client, 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, C>
where
C: 'a,
{
hub: &'a YouTube<C>,
}
impl<'a, C> common::MethodsBuilder for VideoCategoryMethods<'a, C> {}
impl<'a, C> VideoCategoryMethods<'a, C> {
/// 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<String>) -> VideoCategoryListCall<'a, C> {
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 *videoTrainability* 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 youtube3::{YouTube, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// let secret: yup_oauth2::ApplicationSecret = Default::default();
/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// .with_native_roots()
/// .unwrap()
/// .https_only()
/// .enable_http2()
/// .build();
///
/// let executor = hyper_util::rt::TokioExecutor::new();
/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// secret,
/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// yup_oauth2::client::CustomHyperClientBuilder::from(
/// hyper_util::client::legacy::Client::builder(executor).build(connector),
/// ),
/// ).build().await.unwrap();
///
/// let client = hyper_util::client::legacy::Client::builder(
/// hyper_util::rt::TokioExecutor::new()
/// )
/// .build(
/// hyper_rustls::HttpsConnectorBuilder::new()
/// .with_native_roots()
/// .unwrap()
/// .https_or_http()
/// .enable_http2()
/// .build()
/// );
/// let mut hub = YouTube::new(client, auth);
/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
/// // like `get(...)`
/// // to build up your call.
/// let rb = hub.video_trainability();
/// # }
/// ```
pub struct VideoTrainabilityMethods<'a, C>
where
C: 'a,
{
hub: &'a YouTube<C>,
}
impl<'a, C> common::MethodsBuilder for VideoTrainabilityMethods<'a, C> {}
impl<'a, C> VideoTrainabilityMethods<'a, C> {
/// Create a builder to help you perform the following task:
///
/// Returns the trainability status of a video.
pub fn get(&self) -> VideoTrainabilityGetCall<'a, C> {
VideoTrainabilityGetCall {
hub: self.hub,
_id: 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 youtube3::{YouTube, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// let secret: yup_oauth2::ApplicationSecret = Default::default();
/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// .with_native_roots()
/// .unwrap()
/// .https_only()
/// .enable_http2()
/// .build();
///
/// let executor = hyper_util::rt::TokioExecutor::new();
/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// secret,
/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// yup_oauth2::client::CustomHyperClientBuilder::from(
/// hyper_util::client::legacy::Client::builder(executor).build(connector),
/// ),
/// ).build().await.unwrap();
///
/// let client = hyper_util::client::legacy::Client::builder(
/// hyper_util::rt::TokioExecutor::new()
/// )
/// .build(
/// hyper_rustls::HttpsConnectorBuilder::new()
/// .with_native_roots()
/// .unwrap()
/// .https_or_http()
/// .enable_http2()
/// .build()
/// );
/// let mut hub = YouTube::new(client, 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, C>
where
C: 'a,
{
hub: &'a YouTube<C>,
}
impl<'a, C> common::MethodsBuilder for VideoMethods<'a, C> {}
impl<'a, C> VideoMethods<'a, C> {
/// 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, C> {
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<String>) -> VideoGetRatingCall<'a, C> {
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, C> {
use common::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<String>) -> VideoListCall<'a, C> {
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: &str) -> VideoRateCall<'a, C> {
VideoRateCall {
hub: self.hub,
_id: id.to_string(),
_rating: rating.to_string(),
_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, C> {
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, C> {
use common::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 youtube3::{YouTube, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// let secret: yup_oauth2::ApplicationSecret = Default::default();
/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// .with_native_roots()
/// .unwrap()
/// .https_only()
/// .enable_http2()
/// .build();
///
/// let executor = hyper_util::rt::TokioExecutor::new();
/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// secret,
/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// yup_oauth2::client::CustomHyperClientBuilder::from(
/// hyper_util::client::legacy::Client::builder(executor).build(connector),
/// ),
/// ).build().await.unwrap();
///
/// let client = hyper_util::client::legacy::Client::builder(
/// hyper_util::rt::TokioExecutor::new()
/// )
/// .build(
/// hyper_rustls::HttpsConnectorBuilder::new()
/// .with_native_roots()
/// .unwrap()
/// .https_or_http()
/// .enable_http2()
/// .build()
/// );
/// let mut hub = YouTube::new(client, 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, C>
where
C: 'a,
{
hub: &'a YouTube<C>,
}
impl<'a, C> common::MethodsBuilder for WatermarkMethods<'a, C> {}
impl<'a, C> WatermarkMethods<'a, C> {
/// 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, C> {
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, C> {
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 youtube3::{YouTube, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// let secret: yup_oauth2::ApplicationSecret = Default::default();
/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// .with_native_roots()
/// .unwrap()
/// .https_only()
/// .enable_http2()
/// .build();
///
/// let executor = hyper_util::rt::TokioExecutor::new();
/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// secret,
/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// yup_oauth2::client::CustomHyperClientBuilder::from(
/// hyper_util::client::legacy::Client::builder(executor).build(connector),
/// ),
/// ).build().await.unwrap();
///
/// let client = hyper_util::client::legacy::Client::builder(
/// hyper_util::rt::TokioExecutor::new()
/// )
/// .build(
/// hyper_rustls::HttpsConnectorBuilder::new()
/// .with_native_roots()
/// .unwrap()
/// .https_or_http()
/// .enable_http2()
/// .build()
/// );
/// let mut hub = YouTube::new(client, auth);
/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
/// // like `v3_live_chat_messages_stream(...)`, `v3_update_comment_threads(...)` and `v3_videos_batch_get_stats(...)`
/// // to build up your call.
/// let rb = hub.youtube();
/// # }
/// ```
pub struct YoutubeMethods<'a, C>
where
C: 'a,
{
hub: &'a YouTube<C>,
}
impl<'a, C> common::MethodsBuilder for YoutubeMethods<'a, C> {}
impl<'a, C> YoutubeMethods<'a, C> {
/// Create a builder to help you perform the following task:
///
/// Allows a user to load live chat through a server-streamed RPC.
pub fn v3_live_chat_messages_stream(&self) -> YoutubeV3LiveChatMessageStreamCall<'a, C> {
YoutubeV3LiveChatMessageStreamCall {
hub: self.hub,
_profile_image_size: Default::default(),
_part: Default::default(),
_page_token: Default::default(),
_max_results: Default::default(),
_live_chat_id: Default::default(),
_hl: Default::default(),
_delegate: Default::default(),
_additional_params: Default::default(),
_scopes: Default::default(),
}
}
/// Create a builder to help you perform the following task:
///
/// Retrieves a batch of VideoStat resources, possibly filtered.
pub fn v3_videos_batch_get_stats(&self) -> YoutubeV3VideoBatchGetStatCall<'a, C> {
YoutubeV3VideoBatchGetStatCall {
hub: self.hub,
_part: Default::default(),
_on_behalf_of_content_owner: Default::default(),
_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 v3_update_comment_threads(
&self,
request: CommentThread,
) -> YoutubeV3UpdateCommentThreadCall<'a, C> {
YoutubeV3UpdateCommentThreadCall {
hub: self.hub,
_request: request,
_part: Default::default(),
_delegate: Default::default(),
_additional_params: Default::default(),
}
}
}
// ###################
// CallBuilders ###
// #################
/// 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 youtube3::{YouTube, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_only()
/// # .enable_http2()
/// # .build();
///
/// # let executor = hyper_util::rt::TokioExecutor::new();
/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// # secret,
/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # yup_oauth2::client::CustomHyperClientBuilder::from(
/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
/// # ),
/// # ).build().await.unwrap();
///
/// # let client = hyper_util::client::legacy::Client::builder(
/// # hyper_util::rt::TokioExecutor::new()
/// # )
/// # .build(
/// # hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_or_http()
/// # .enable_http2()
/// # .build()
/// # );
/// # let mut hub = YouTube::new(client, auth);
/// // As the method needs a request, you would usually fill it with the desired information
/// // into the 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, C>
where
C: 'a,
{
hub: &'a YouTube<C>,
_request: AbuseReport,
_part: Vec<String>,
_delegate: Option<&'a mut dyn common::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>,
}
impl<'a, C> common::CallBuilder for AbuseReportInsertCall<'a, C> {}
impl<'a, C> AbuseReportInsertCall<'a, C>
where
C: common::Connector,
{
/// Perform the operation you have build so far.
pub async fn doit(mut self) -> common::Result<(common::Response, AbuseReport)> {
use std::borrow::Cow;
use std::io::{Read, Seek};
use common::{url::Params, ToParts};
use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
let mut dd = common::DefaultDelegate;
let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(common::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(common::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.is_empty() {
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 = serde_json::value::to_value(&self._request).expect("serde to work");
common::remove_json_null_values(&mut value);
let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
serde_json::to_writer(&mut dst, &value).unwrap();
dst
};
let request_size = request_value_reader
.seek(std::io::SeekFrom::End(0))
.unwrap();
request_value_reader
.seek(std::io::SeekFrom::Start(0))
.unwrap();
loop {
let token = match self
.hub
.auth
.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
.await
{
Ok(token) => token,
Err(e) => match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(common::Error::MissingToken(e));
}
},
};
request_value_reader
.seek(std::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(common::to_body(
request_value_reader.get_ref().clone().into(),
));
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let common::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(common::Error::HttpError(err));
}
Ok(res) => {
let (mut parts, body) = res.into_parts();
let mut body = common::Body::new(body);
if !parts.status.is_success() {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let error = serde_json::from_str(&common::to_string(&bytes));
let response = common::to_response(parts, bytes.into());
if let common::Retry::After(d) =
dlg.http_failure(&response, error.as_ref().ok())
{
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(match error {
Ok(value) => common::Error::BadRequest(value),
_ => common::Error::Failure(response),
});
}
let response = {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let encoded = common::to_string(&bytes);
match serde_json::from_str(&encoded) {
Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
Err(error) => {
dlg.response_json_decode_error(&encoded, &error);
return Err(common::Error::JsonDecodeError(
encoded.to_string(),
error,
));
}
}
};
dlg.finished(true);
return Ok(response);
}
}
}
}
///
/// Sets the *request* property to the given value.
///
/// Even though 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, C> {
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, C> {
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 common::Delegate,
) -> AbuseReportInsertCall<'a, C> {
self._delegate = Some(new_value);
self
}
/// Set any additional parameter of the query string used in the request.
/// It should be used to set parameters 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<T>(mut self, name: T, value: T) -> AbuseReportInsertCall<'a, C>
where
T: AsRef<str>,
{
self._additional_params
.insert(name.as_ref().to_string(), value.as_ref().to_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<St>(mut self, scope: St) -> AbuseReportInsertCall<'a, C>
where
St: AsRef<str>,
{
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<I, St>(mut self, scopes: I) -> AbuseReportInsertCall<'a, C>
where
I: IntoIterator<Item = St>,
St: AsRef<str>,
{
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, C> {
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 youtube3::{YouTube, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_only()
/// # .enable_http2()
/// # .build();
///
/// # let executor = hyper_util::rt::TokioExecutor::new();
/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// # secret,
/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # yup_oauth2::client::CustomHyperClientBuilder::from(
/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
/// # ),
/// # ).build().await.unwrap();
///
/// # let client = hyper_util::client::legacy::Client::builder(
/// # hyper_util::rt::TokioExecutor::new()
/// # )
/// # .build(
/// # hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_or_http()
/// # .enable_http2()
/// # .build()
/// # );
/// # let mut hub = YouTube::new(client, auth);
/// // You can configure optional parameters by calling 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!["duo".into()])
/// .region_code("sed")
/// .published_before(chrono::Utc::now())
/// .published_after(chrono::Utc::now())
/// .page_token("no")
/// .mine(true)
/// .max_results(77)
/// .home(true)
/// .channel_id("vero")
/// .doit().await;
/// # }
/// ```
pub struct ActivityListCall<'a, C>
where
C: 'a,
{
hub: &'a YouTube<C>,
_part: Vec<String>,
_region_code: Option<String>,
_published_before: Option<chrono::DateTime<chrono::offset::Utc>>,
_published_after: Option<chrono::DateTime<chrono::offset::Utc>>,
_page_token: Option<String>,
_mine: Option<bool>,
_max_results: Option<u32>,
_home: Option<bool>,
_channel_id: Option<String>,
_delegate: Option<&'a mut dyn common::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>,
}
impl<'a, C> common::CallBuilder for ActivityListCall<'a, C> {}
impl<'a, C> ActivityListCall<'a, C>
where
C: common::Connector,
{
/// Perform the operation you have build so far.
pub async fn doit(mut self) -> common::Result<(common::Response, ActivityListResponse)> {
use std::borrow::Cow;
use std::io::{Read, Seek};
use common::{url::Params, ToParts};
use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
let mut dd = common::DefaultDelegate;
let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(common::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(common::Error::FieldClash(field));
}
}
let mut params = Params::with_capacity(11 + self._additional_params.len());
if !self._part.is_empty() {
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", common::serde::datetime_to_string(&value));
}
if let Some(value) = self._published_after.as_ref() {
params.push("publishedAfter", common::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::<Vec<_>>()[..])
.await
{
Ok(token) => token,
Err(e) => match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(common::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(common::to_body::<String>(None));
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let common::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(common::Error::HttpError(err));
}
Ok(res) => {
let (mut parts, body) = res.into_parts();
let mut body = common::Body::new(body);
if !parts.status.is_success() {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let error = serde_json::from_str(&common::to_string(&bytes));
let response = common::to_response(parts, bytes.into());
if let common::Retry::After(d) =
dlg.http_failure(&response, error.as_ref().ok())
{
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(match error {
Ok(value) => common::Error::BadRequest(value),
_ => common::Error::Failure(response),
});
}
let response = {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let encoded = common::to_string(&bytes);
match serde_json::from_str(&encoded) {
Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
Err(error) => {
dlg.response_json_decode_error(&encoded, &error);
return Err(common::Error::JsonDecodeError(
encoded.to_string(),
error,
));
}
}
};
dlg.finished(true);
return Ok(response);
}
}
}
}
/// 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, C> {
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, C> {
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: chrono::DateTime<chrono::offset::Utc>,
) -> ActivityListCall<'a, C> {
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: chrono::DateTime<chrono::offset::Utc>,
) -> ActivityListCall<'a, C> {
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, C> {
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, C> {
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, C> {
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, C> {
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, C> {
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 common::Delegate) -> ActivityListCall<'a, C> {
self._delegate = Some(new_value);
self
}
/// Set any additional parameter of the query string used in the request.
/// It should be used to set parameters 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<T>(mut self, name: T, value: T) -> ActivityListCall<'a, C>
where
T: AsRef<str>,
{
self._additional_params
.insert(name.as_ref().to_string(), value.as_ref().to_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<St>(mut self, scope: St) -> ActivityListCall<'a, C>
where
St: AsRef<str>,
{
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<I, St>(mut self, scopes: I) -> ActivityListCall<'a, C>
where
I: IntoIterator<Item = St>,
St: AsRef<str>,
{
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, C> {
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 youtube3::{YouTube, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_only()
/// # .enable_http2()
/// # .build();
///
/// # let executor = hyper_util::rt::TokioExecutor::new();
/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// # secret,
/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # yup_oauth2::client::CustomHyperClientBuilder::from(
/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
/// # ),
/// # ).build().await.unwrap();
///
/// # let client = hyper_util::client::legacy::Client::builder(
/// # hyper_util::rt::TokioExecutor::new()
/// # )
/// # .build(
/// # hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_or_http()
/// # .enable_http2()
/// # .build()
/// # );
/// # let mut hub = YouTube::new(client, auth);
/// // You can configure optional parameters by calling 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("sed")
/// .on_behalf_of("duo")
/// .doit().await;
/// # }
/// ```
pub struct CaptionDeleteCall<'a, C>
where
C: 'a,
{
hub: &'a YouTube<C>,
_id: String,
_on_behalf_of_content_owner: Option<String>,
_on_behalf_of: Option<String>,
_delegate: Option<&'a mut dyn common::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>,
}
impl<'a, C> common::CallBuilder for CaptionDeleteCall<'a, C> {}
impl<'a, C> CaptionDeleteCall<'a, C>
where
C: common::Connector,
{
/// Perform the operation you have build so far.
pub async fn doit(mut self) -> common::Result<common::Response> {
use std::borrow::Cow;
use std::io::{Read, Seek};
use common::{url::Params, ToParts};
use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
let mut dd = common::DefaultDelegate;
let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(common::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(common::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::<Vec<_>>()[..])
.await
{
Ok(token) => token,
Err(e) => match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(common::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(common::to_body::<String>(None));
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let common::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(common::Error::HttpError(err));
}
Ok(res) => {
let (mut parts, body) = res.into_parts();
let mut body = common::Body::new(body);
if !parts.status.is_success() {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let error = serde_json::from_str(&common::to_string(&bytes));
let response = common::to_response(parts, bytes.into());
if let common::Retry::After(d) =
dlg.http_failure(&response, error.as_ref().ok())
{
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(match error {
Ok(value) => common::Error::BadRequest(value),
_ => common::Error::Failure(response),
});
}
let response = common::Response::from_parts(parts, body);
dlg.finished(true);
return Ok(response);
}
}
}
}
///
/// 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, C> {
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, C> {
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, C> {
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 common::Delegate) -> CaptionDeleteCall<'a, C> {
self._delegate = Some(new_value);
self
}
/// Set any additional parameter of the query string used in the request.
/// It should be used to set parameters 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<T>(mut self, name: T, value: T) -> CaptionDeleteCall<'a, C>
where
T: AsRef<str>,
{
self._additional_params
.insert(name.as_ref().to_string(), value.as_ref().to_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<St>(mut self, scope: St) -> CaptionDeleteCall<'a, C>
where
St: AsRef<str>,
{
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<I, St>(mut self, scopes: I) -> CaptionDeleteCall<'a, C>
where
I: IntoIterator<Item = St>,
St: AsRef<str>,
{
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, C> {
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 youtube3::{YouTube, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_only()
/// # .enable_http2()
/// # .build();
///
/// # let executor = hyper_util::rt::TokioExecutor::new();
/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// # secret,
/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # yup_oauth2::client::CustomHyperClientBuilder::from(
/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
/// # ),
/// # ).build().await.unwrap();
///
/// # let client = hyper_util::client::legacy::Client::builder(
/// # hyper_util::rt::TokioExecutor::new()
/// # )
/// # .build(
/// # hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_or_http()
/// # .enable_http2()
/// # .build()
/// # );
/// # let mut hub = YouTube::new(client, auth);
/// // You can configure optional parameters by calling 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("et")
/// .tfmt("voluptua.")
/// .on_behalf_of_content_owner("amet.")
/// .on_behalf_of("consetetur")
/// .doit().await;
/// # }
/// ```
pub struct CaptionDownloadCall<'a, C>
where
C: 'a,
{
hub: &'a YouTube<C>,
_id: String,
_tlang: Option<String>,
_tfmt: Option<String>,
_on_behalf_of_content_owner: Option<String>,
_on_behalf_of: Option<String>,
_delegate: Option<&'a mut dyn common::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>,
}
impl<'a, C> common::CallBuilder for CaptionDownloadCall<'a, C> {}
impl<'a, C> CaptionDownloadCall<'a, C>
where
C: common::Connector,
{
/// Perform the operation you have build so far.
pub async fn doit(mut self) -> common::Result<common::Response> {
use std::borrow::Cow;
use std::io::{Read, Seek};
use common::{url::Params, ToParts};
use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
let mut dd = common::DefaultDelegate;
let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(common::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(common::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());
}
#[allow(clippy::single_element_loop)]
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::<Vec<_>>()[..])
.await
{
Ok(token) => token,
Err(e) => match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(common::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(common::to_body::<String>(None));
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let common::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(common::Error::HttpError(err));
}
Ok(res) => {
let (mut parts, body) = res.into_parts();
let mut body = common::Body::new(body);
if !parts.status.is_success() {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let error = serde_json::from_str(&common::to_string(&bytes));
let response = common::to_response(parts, bytes.into());
if let common::Retry::After(d) =
dlg.http_failure(&response, error.as_ref().ok())
{
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(match error {
Ok(value) => common::Error::BadRequest(value),
_ => common::Error::Failure(response),
});
}
let response = common::Response::from_parts(parts, body);
dlg.finished(true);
return Ok(response);
}
}
}
}
/// 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, C> {
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, C> {
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, C> {
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, C> {
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, C> {
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 common::Delegate,
) -> CaptionDownloadCall<'a, C> {
self._delegate = Some(new_value);
self
}
/// Set any additional parameter of the query string used in the request.
/// It should be used to set parameters 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<T>(mut self, name: T, value: T) -> CaptionDownloadCall<'a, C>
where
T: AsRef<str>,
{
self._additional_params
.insert(name.as_ref().to_string(), value.as_ref().to_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<St>(mut self, scope: St) -> CaptionDownloadCall<'a, C>
where
St: AsRef<str>,
{
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<I, St>(mut self, scopes: I) -> CaptionDownloadCall<'a, C>
where
I: IntoIterator<Item = St>,
St: AsRef<str>,
{
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, C> {
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 youtube3::{YouTube, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_only()
/// # .enable_http2()
/// # .build();
///
/// # let executor = hyper_util::rt::TokioExecutor::new();
/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// # secret,
/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # yup_oauth2::client::CustomHyperClientBuilder::from(
/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
/// # ),
/// # ).build().await.unwrap();
///
/// # let client = hyper_util::client::legacy::Client::builder(
/// # hyper_util::rt::TokioExecutor::new()
/// # )
/// # .build(
/// # hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_or_http()
/// # .enable_http2()
/// # .build()
/// # );
/// # let mut hub = YouTube::new(client, auth);
/// // As the method needs a request, you would usually fill it with the desired information
/// // into the 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("dolor")
/// .on_behalf_of("et")
/// .upload(fs::File::open("file.ext").unwrap(), "application/octet-stream".parse().unwrap()).await;
/// # }
/// ```
pub struct CaptionInsertCall<'a, C>
where
C: 'a,
{
hub: &'a YouTube<C>,
_request: Caption,
_part: Vec<String>,
_sync: Option<bool>,
_on_behalf_of_content_owner: Option<String>,
_on_behalf_of: Option<String>,
_delegate: Option<&'a mut dyn common::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>,
}
impl<'a, C> common::CallBuilder for CaptionInsertCall<'a, C> {}
impl<'a, C> CaptionInsertCall<'a, C>
where
C: common::Connector,
{
/// Perform the operation you have build so far.
async fn doit<RS>(
mut self,
mut reader: RS,
reader_mime_type: mime::Mime,
protocol: common::UploadProtocol,
) -> common::Result<(common::Response, Caption)>
where
RS: common::ReadSeek,
{
use std::borrow::Cow;
use std::io::{Read, Seek};
use common::{url::Params, ToParts};
use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
let mut dd = common::DefaultDelegate;
let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(common::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(common::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.is_empty() {
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 == common::UploadProtocol::Resumable {
(
self.hub._root_url.clone() + "resumable/upload/youtube/v3/captions",
"resumable",
)
} else if protocol == common::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 = serde_json::value::to_value(&self._request).expect("serde to work");
common::remove_json_null_values(&mut value);
let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
serde_json::to_writer(&mut dst, &value).unwrap();
dst
};
let request_size = request_value_reader
.seek(std::io::SeekFrom::End(0))
.unwrap();
request_value_reader
.seek(std::io::SeekFrom::Start(0))
.unwrap();
let mut upload_url_from_server;
loop {
let token = match self
.hub
.auth
.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
.await
{
Ok(token) => token,
Err(e) => match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(common::Error::MissingToken(e));
}
},
};
request_value_reader
.seek(std::io::SeekFrom::Start(0))
.unwrap();
let mut req_result = {
let mut mp_reader: common::MultiPartReader = Default::default();
let (mut body_reader, content_type) = match protocol {
common::UploadProtocol::Simple => {
mp_reader.reserve_exact(2);
let size = reader.seek(std::io::SeekFrom::End(0)).unwrap();
reader.seek(std::io::SeekFrom::Start(0)).unwrap();
if size > 104857600 {
return Err(common::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 std::io::Read + Send),
common::MultiPartReader::mime_type(),
)
}
_ => (
&mut request_value_reader as &mut (dyn std::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 == common::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(common::to_body(body_reader_bytes.into()));
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let common::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(common::Error::HttpError(err));
}
Ok(res) => {
let (mut parts, body) = res.into_parts();
let mut body = common::Body::new(body);
if !parts.status.is_success() {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let error = serde_json::from_str(&common::to_string(&bytes));
let response = common::to_response(parts, bytes.into());
if let common::Retry::After(d) =
dlg.http_failure(&response, error.as_ref().ok())
{
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(match error {
Ok(value) => common::Error::BadRequest(value),
_ => common::Error::Failure(response),
});
}
if protocol == common::UploadProtocol::Resumable {
let size = reader.seek(std::io::SeekFrom::End(0)).unwrap();
reader.seek(std::io::SeekFrom::Start(0)).unwrap();
if size > 104857600 {
return Err(common::Error::UploadSizeLimitExceeded(size, 104857600));
}
let upload_result = {
let url_str = &parts
.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));
}
common::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(|| common::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(common::Error::Cancelled);
}
Some(Err(err)) => {
dlg.finished(false);
return Err(common::Error::HttpError(err));
}
Some(Ok(response)) => {
(parts, body) = response.into_parts();
if !parts.status.is_success() {
dlg.store_upload_url(None);
dlg.finished(false);
return Err(common::Error::Failure(
common::Response::from_parts(parts, body),
));
}
}
}
}
let response = {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let encoded = common::to_string(&bytes);
match serde_json::from_str(&encoded) {
Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
Err(error) => {
dlg.response_json_decode_error(&encoded, &error);
return Err(common::Error::JsonDecodeError(
encoded.to_string(),
error,
));
}
}
};
dlg.finished(true);
return Ok(response);
}
}
}
}
/// 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<RS>(
self,
resumeable_stream: RS,
mime_type: mime::Mime,
) -> common::Result<(common::Response, Caption)>
where
RS: common::ReadSeek,
{
self.doit(
resumeable_stream,
mime_type,
common::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<RS>(
self,
stream: RS,
mime_type: mime::Mime,
) -> common::Result<(common::Response, Caption)>
where
RS: common::ReadSeek,
{
self.doit(stream, mime_type, common::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, C> {
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, C> {
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, C> {
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, C> {
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, C> {
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 common::Delegate) -> CaptionInsertCall<'a, C> {
self._delegate = Some(new_value);
self
}
/// Set any additional parameter of the query string used in the request.
/// It should be used to set parameters 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<T>(mut self, name: T, value: T) -> CaptionInsertCall<'a, C>
where
T: AsRef<str>,
{
self._additional_params
.insert(name.as_ref().to_string(), value.as_ref().to_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<St>(mut self, scope: St) -> CaptionInsertCall<'a, C>
where
St: AsRef<str>,
{
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<I, St>(mut self, scopes: I) -> CaptionInsertCall<'a, C>
where
I: IntoIterator<Item = St>,
St: AsRef<str>,
{
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, C> {
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 youtube3::{YouTube, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_only()
/// # .enable_http2()
/// # .build();
///
/// # let executor = hyper_util::rt::TokioExecutor::new();
/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// # secret,
/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # yup_oauth2::client::CustomHyperClientBuilder::from(
/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
/// # ),
/// # ).build().await.unwrap();
///
/// # let client = hyper_util::client::legacy::Client::builder(
/// # hyper_util::rt::TokioExecutor::new()
/// # )
/// # .build(
/// # hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_or_http()
/// # .enable_http2()
/// # .build()
/// # );
/// # let mut hub = YouTube::new(client, auth);
/// // You can configure optional parameters by calling 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("Stet")
/// .on_behalf_of("dolor")
/// .add_id("duo")
/// .doit().await;
/// # }
/// ```
pub struct CaptionListCall<'a, C>
where
C: 'a,
{
hub: &'a YouTube<C>,
_part: Vec<String>,
_video_id: String,
_on_behalf_of_content_owner: Option<String>,
_on_behalf_of: Option<String>,
_id: Vec<String>,
_delegate: Option<&'a mut dyn common::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>,
}
impl<'a, C> common::CallBuilder for CaptionListCall<'a, C> {}
impl<'a, C> CaptionListCall<'a, C>
where
C: common::Connector,
{
/// Perform the operation you have build so far.
pub async fn doit(mut self) -> common::Result<(common::Response, CaptionListResponse)> {
use std::borrow::Cow;
use std::io::{Read, Seek};
use common::{url::Params, ToParts};
use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
let mut dd = common::DefaultDelegate;
let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(common::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(common::Error::FieldClash(field));
}
}
let mut params = Params::with_capacity(7 + self._additional_params.len());
if !self._part.is_empty() {
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.is_empty() {
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::<Vec<_>>()[..])
.await
{
Ok(token) => token,
Err(e) => match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(common::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(common::to_body::<String>(None));
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let common::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(common::Error::HttpError(err));
}
Ok(res) => {
let (mut parts, body) = res.into_parts();
let mut body = common::Body::new(body);
if !parts.status.is_success() {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let error = serde_json::from_str(&common::to_string(&bytes));
let response = common::to_response(parts, bytes.into());
if let common::Retry::After(d) =
dlg.http_failure(&response, error.as_ref().ok())
{
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(match error {
Ok(value) => common::Error::BadRequest(value),
_ => common::Error::Failure(response),
});
}
let response = {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let encoded = common::to_string(&bytes);
match serde_json::from_str(&encoded) {
Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
Err(error) => {
dlg.response_json_decode_error(&encoded, &error);
return Err(common::Error::JsonDecodeError(
encoded.to_string(),
error,
));
}
}
};
dlg.finished(true);
return Ok(response);
}
}
}
}
/// 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, C> {
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, C> {
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, C> {
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, C> {
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, C> {
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 common::Delegate) -> CaptionListCall<'a, C> {
self._delegate = Some(new_value);
self
}
/// Set any additional parameter of the query string used in the request.
/// It should be used to set parameters 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<T>(mut self, name: T, value: T) -> CaptionListCall<'a, C>
where
T: AsRef<str>,
{
self._additional_params
.insert(name.as_ref().to_string(), value.as_ref().to_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<St>(mut self, scope: St) -> CaptionListCall<'a, C>
where
St: AsRef<str>,
{
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<I, St>(mut self, scopes: I) -> CaptionListCall<'a, C>
where
I: IntoIterator<Item = St>,
St: AsRef<str>,
{
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, C> {
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 youtube3::{YouTube, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_only()
/// # .enable_http2()
/// # .build();
///
/// # let executor = hyper_util::rt::TokioExecutor::new();
/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// # secret,
/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # yup_oauth2::client::CustomHyperClientBuilder::from(
/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
/// # ),
/// # ).build().await.unwrap();
///
/// # let client = hyper_util::client::legacy::Client::builder(
/// # hyper_util::rt::TokioExecutor::new()
/// # )
/// # .build(
/// # hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_or_http()
/// # .enable_http2()
/// # .build()
/// # );
/// # let mut hub = YouTube::new(client, auth);
/// // As the method needs a request, you would usually fill it with the desired information
/// // into the 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("vero".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("invidunt")
/// .on_behalf_of("Stet")
/// .upload(fs::File::open("file.ext").unwrap(), "application/octet-stream".parse().unwrap()).await;
/// # }
/// ```
pub struct CaptionUpdateCall<'a, C>
where
C: 'a,
{
hub: &'a YouTube<C>,
_request: Caption,
_part: Vec<String>,
_sync: Option<bool>,
_on_behalf_of_content_owner: Option<String>,
_on_behalf_of: Option<String>,
_delegate: Option<&'a mut dyn common::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>,
}
impl<'a, C> common::CallBuilder for CaptionUpdateCall<'a, C> {}
impl<'a, C> CaptionUpdateCall<'a, C>
where
C: common::Connector,
{
/// Perform the operation you have build so far.
async fn doit<RS>(
mut self,
mut reader: RS,
reader_mime_type: mime::Mime,
protocol: common::UploadProtocol,
) -> common::Result<(common::Response, Caption)>
where
RS: common::ReadSeek,
{
use std::borrow::Cow;
use std::io::{Read, Seek};
use common::{url::Params, ToParts};
use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
let mut dd = common::DefaultDelegate;
let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(common::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(common::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.is_empty() {
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 == common::UploadProtocol::Resumable {
(
self.hub._root_url.clone() + "resumable/upload/youtube/v3/captions",
"resumable",
)
} else if protocol == common::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 = serde_json::value::to_value(&self._request).expect("serde to work");
common::remove_json_null_values(&mut value);
let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
serde_json::to_writer(&mut dst, &value).unwrap();
dst
};
let request_size = request_value_reader
.seek(std::io::SeekFrom::End(0))
.unwrap();
request_value_reader
.seek(std::io::SeekFrom::Start(0))
.unwrap();
let mut upload_url_from_server;
loop {
let token = match self
.hub
.auth
.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
.await
{
Ok(token) => token,
Err(e) => match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(common::Error::MissingToken(e));
}
},
};
request_value_reader
.seek(std::io::SeekFrom::Start(0))
.unwrap();
let mut req_result = {
let mut mp_reader: common::MultiPartReader = Default::default();
let (mut body_reader, content_type) = match protocol {
common::UploadProtocol::Simple => {
mp_reader.reserve_exact(2);
let size = reader.seek(std::io::SeekFrom::End(0)).unwrap();
reader.seek(std::io::SeekFrom::Start(0)).unwrap();
if size > 104857600 {
return Err(common::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 std::io::Read + Send),
common::MultiPartReader::mime_type(),
)
}
_ => (
&mut request_value_reader as &mut (dyn std::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 == common::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(common::to_body(body_reader_bytes.into()));
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let common::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(common::Error::HttpError(err));
}
Ok(res) => {
let (mut parts, body) = res.into_parts();
let mut body = common::Body::new(body);
if !parts.status.is_success() {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let error = serde_json::from_str(&common::to_string(&bytes));
let response = common::to_response(parts, bytes.into());
if let common::Retry::After(d) =
dlg.http_failure(&response, error.as_ref().ok())
{
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(match error {
Ok(value) => common::Error::BadRequest(value),
_ => common::Error::Failure(response),
});
}
if protocol == common::UploadProtocol::Resumable {
let size = reader.seek(std::io::SeekFrom::End(0)).unwrap();
reader.seek(std::io::SeekFrom::Start(0)).unwrap();
if size > 104857600 {
return Err(common::Error::UploadSizeLimitExceeded(size, 104857600));
}
let upload_result = {
let url_str = &parts
.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));
}
common::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(|| common::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(common::Error::Cancelled);
}
Some(Err(err)) => {
dlg.finished(false);
return Err(common::Error::HttpError(err));
}
Some(Ok(response)) => {
(parts, body) = response.into_parts();
if !parts.status.is_success() {
dlg.store_upload_url(None);
dlg.finished(false);
return Err(common::Error::Failure(
common::Response::from_parts(parts, body),
));
}
}
}
}
let response = {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let encoded = common::to_string(&bytes);
match serde_json::from_str(&encoded) {
Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
Err(error) => {
dlg.response_json_decode_error(&encoded, &error);
return Err(common::Error::JsonDecodeError(
encoded.to_string(),
error,
));
}
}
};
dlg.finished(true);
return Ok(response);
}
}
}
}
/// 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<RS>(
self,
resumeable_stream: RS,
mime_type: mime::Mime,
) -> common::Result<(common::Response, Caption)>
where
RS: common::ReadSeek,
{
self.doit(
resumeable_stream,
mime_type,
common::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<RS>(
self,
stream: RS,
mime_type: mime::Mime,
) -> common::Result<(common::Response, Caption)>
where
RS: common::ReadSeek,
{
self.doit(stream, mime_type, common::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, C> {
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, C> {
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, C> {
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, C> {
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, C> {
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 common::Delegate) -> CaptionUpdateCall<'a, C> {
self._delegate = Some(new_value);
self
}
/// Set any additional parameter of the query string used in the request.
/// It should be used to set parameters 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<T>(mut self, name: T, value: T) -> CaptionUpdateCall<'a, C>
where
T: AsRef<str>,
{
self._additional_params
.insert(name.as_ref().to_string(), value.as_ref().to_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<St>(mut self, scope: St) -> CaptionUpdateCall<'a, C>
where
St: AsRef<str>,
{
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<I, St>(mut self, scopes: I) -> CaptionUpdateCall<'a, C>
where
I: IntoIterator<Item = St>,
St: AsRef<str>,
{
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, C> {
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 youtube3::{YouTube, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_only()
/// # .enable_http2()
/// # .build();
///
/// # let executor = hyper_util::rt::TokioExecutor::new();
/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// # secret,
/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # yup_oauth2::client::CustomHyperClientBuilder::from(
/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
/// # ),
/// # ).build().await.unwrap();
///
/// # let client = hyper_util::client::legacy::Client::builder(
/// # hyper_util::rt::TokioExecutor::new()
/// # )
/// # .build(
/// # hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_or_http()
/// # .enable_http2()
/// # .build()
/// # );
/// # let mut hub = YouTube::new(client, auth);
/// // As the method needs a request, you would usually fill it with the desired information
/// // into the 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("vero")
/// .on_behalf_of_content_owner("elitr")
/// .channel_id("Lorem")
/// .upload_resumable(fs::File::open("file.ext").unwrap(), "application/octet-stream".parse().unwrap()).await;
/// # }
/// ```
pub struct ChannelBannerInsertCall<'a, C>
where
C: 'a,
{
hub: &'a YouTube<C>,
_request: ChannelBannerResource,
_on_behalf_of_content_owner_channel: Option<String>,
_on_behalf_of_content_owner: Option<String>,
_channel_id: Option<String>,
_delegate: Option<&'a mut dyn common::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>,
}
impl<'a, C> common::CallBuilder for ChannelBannerInsertCall<'a, C> {}
impl<'a, C> ChannelBannerInsertCall<'a, C>
where
C: common::Connector,
{
/// Perform the operation you have build so far.
async fn doit<RS>(
mut self,
mut reader: RS,
reader_mime_type: mime::Mime,
protocol: common::UploadProtocol,
) -> common::Result<(common::Response, ChannelBannerResource)>
where
RS: common::ReadSeek,
{
use std::borrow::Cow;
use std::io::{Read, Seek};
use common::{url::Params, ToParts};
use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
let mut dd = common::DefaultDelegate;
let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(common::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(common::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 == common::UploadProtocol::Resumable {
(
self.hub._root_url.clone() + "resumable/upload/youtube/v3/channelBanners/insert",
"resumable",
)
} else if protocol == common::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 = serde_json::value::to_value(&self._request).expect("serde to work");
common::remove_json_null_values(&mut value);
let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
serde_json::to_writer(&mut dst, &value).unwrap();
dst
};
let request_size = request_value_reader
.seek(std::io::SeekFrom::End(0))
.unwrap();
request_value_reader
.seek(std::io::SeekFrom::Start(0))
.unwrap();
let mut upload_url_from_server;
loop {
let token = match self
.hub
.auth
.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
.await
{
Ok(token) => token,
Err(e) => match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(common::Error::MissingToken(e));
}
},
};
request_value_reader
.seek(std::io::SeekFrom::Start(0))
.unwrap();
let mut req_result = {
let mut mp_reader: common::MultiPartReader = Default::default();
let (mut body_reader, content_type) = match protocol {
common::UploadProtocol::Simple => {
mp_reader.reserve_exact(2);
let size = reader.seek(std::io::SeekFrom::End(0)).unwrap();
reader.seek(std::io::SeekFrom::Start(0)).unwrap();
if size > 6291456 {
return Err(common::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 std::io::Read + Send),
common::MultiPartReader::mime_type(),
)
}
_ => (
&mut request_value_reader as &mut (dyn std::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 == common::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(common::to_body(body_reader_bytes.into()));
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let common::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(common::Error::HttpError(err));
}
Ok(res) => {
let (mut parts, body) = res.into_parts();
let mut body = common::Body::new(body);
if !parts.status.is_success() {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let error = serde_json::from_str(&common::to_string(&bytes));
let response = common::to_response(parts, bytes.into());
if let common::Retry::After(d) =
dlg.http_failure(&response, error.as_ref().ok())
{
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(match error {
Ok(value) => common::Error::BadRequest(value),
_ => common::Error::Failure(response),
});
}
if protocol == common::UploadProtocol::Resumable {
let size = reader.seek(std::io::SeekFrom::End(0)).unwrap();
reader.seek(std::io::SeekFrom::Start(0)).unwrap();
if size > 6291456 {
return Err(common::Error::UploadSizeLimitExceeded(size, 6291456));
}
let upload_result = {
let url_str = &parts
.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));
}
common::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(|| common::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(common::Error::Cancelled);
}
Some(Err(err)) => {
dlg.finished(false);
return Err(common::Error::HttpError(err));
}
Some(Ok(response)) => {
(parts, body) = response.into_parts();
if !parts.status.is_success() {
dlg.store_upload_url(None);
dlg.finished(false);
return Err(common::Error::Failure(
common::Response::from_parts(parts, body),
));
}
}
}
}
let response = {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let encoded = common::to_string(&bytes);
match serde_json::from_str(&encoded) {
Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
Err(error) => {
dlg.response_json_decode_error(&encoded, &error);
return Err(common::Error::JsonDecodeError(
encoded.to_string(),
error,
));
}
}
};
dlg.finished(true);
return Ok(response);
}
}
}
}
/// 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<RS>(
self,
resumeable_stream: RS,
mime_type: mime::Mime,
) -> common::Result<(common::Response, ChannelBannerResource)>
where
RS: common::ReadSeek,
{
self.doit(
resumeable_stream,
mime_type,
common::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<RS>(
self,
stream: RS,
mime_type: mime::Mime,
) -> common::Result<(common::Response, ChannelBannerResource)>
where
RS: common::ReadSeek,
{
self.doit(stream, mime_type, common::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, C> {
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, C> {
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, C> {
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, C> {
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 common::Delegate,
) -> ChannelBannerInsertCall<'a, C> {
self._delegate = Some(new_value);
self
}
/// Set any additional parameter of the query string used in the request.
/// It should be used to set parameters 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<T>(mut self, name: T, value: T) -> ChannelBannerInsertCall<'a, C>
where
T: AsRef<str>,
{
self._additional_params
.insert(name.as_ref().to_string(), value.as_ref().to_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<St>(mut self, scope: St) -> ChannelBannerInsertCall<'a, C>
where
St: AsRef<str>,
{
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<I, St>(mut self, scopes: I) -> ChannelBannerInsertCall<'a, C>
where
I: IntoIterator<Item = St>,
St: AsRef<str>,
{
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, C> {
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 youtube3::{YouTube, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_only()
/// # .enable_http2()
/// # .build();
///
/// # let executor = hyper_util::rt::TokioExecutor::new();
/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// # secret,
/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # yup_oauth2::client::CustomHyperClientBuilder::from(
/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
/// # ),
/// # ).build().await.unwrap();
///
/// # let client = hyper_util::client::legacy::Client::builder(
/// # hyper_util::rt::TokioExecutor::new()
/// # )
/// # .build(
/// # hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_or_http()
/// # .enable_http2()
/// # .build()
/// # );
/// # let mut hub = YouTube::new(client, auth);
/// // You can configure optional parameters by calling 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("no")
/// .doit().await;
/// # }
/// ```
pub struct ChannelSectionDeleteCall<'a, C>
where
C: 'a,
{
hub: &'a YouTube<C>,
_id: String,
_on_behalf_of_content_owner: Option<String>,
_delegate: Option<&'a mut dyn common::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>,
}
impl<'a, C> common::CallBuilder for ChannelSectionDeleteCall<'a, C> {}
impl<'a, C> ChannelSectionDeleteCall<'a, C>
where
C: common::Connector,
{
/// Perform the operation you have build so far.
pub async fn doit(mut self) -> common::Result<common::Response> {
use std::borrow::Cow;
use std::io::{Read, Seek};
use common::{url::Params, ToParts};
use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
let mut dd = common::DefaultDelegate;
let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(common::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(common::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::<Vec<_>>()[..])
.await
{
Ok(token) => token,
Err(e) => match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(common::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(common::to_body::<String>(None));
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let common::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(common::Error::HttpError(err));
}
Ok(res) => {
let (mut parts, body) = res.into_parts();
let mut body = common::Body::new(body);
if !parts.status.is_success() {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let error = serde_json::from_str(&common::to_string(&bytes));
let response = common::to_response(parts, bytes.into());
if let common::Retry::After(d) =
dlg.http_failure(&response, error.as_ref().ok())
{
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(match error {
Ok(value) => common::Error::BadRequest(value),
_ => common::Error::Failure(response),
});
}
let response = common::Response::from_parts(parts, body);
dlg.finished(true);
return Ok(response);
}
}
}
}
///
/// 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, C> {
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, C> {
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 common::Delegate,
) -> ChannelSectionDeleteCall<'a, C> {
self._delegate = Some(new_value);
self
}
/// Set any additional parameter of the query string used in the request.
/// It should be used to set parameters 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<T>(mut self, name: T, value: T) -> ChannelSectionDeleteCall<'a, C>
where
T: AsRef<str>,
{
self._additional_params
.insert(name.as_ref().to_string(), value.as_ref().to_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<St>(mut self, scope: St) -> ChannelSectionDeleteCall<'a, C>
where
St: AsRef<str>,
{
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<I, St>(mut self, scopes: I) -> ChannelSectionDeleteCall<'a, C>
where
I: IntoIterator<Item = St>,
St: AsRef<str>,
{
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, C> {
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 youtube3::{YouTube, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_only()
/// # .enable_http2()
/// # .build();
///
/// # let executor = hyper_util::rt::TokioExecutor::new();
/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// # secret,
/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # yup_oauth2::client::CustomHyperClientBuilder::from(
/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
/// # ),
/// # ).build().await.unwrap();
///
/// # let client = hyper_util::client::legacy::Client::builder(
/// # hyper_util::rt::TokioExecutor::new()
/// # )
/// # .build(
/// # hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_or_http()
/// # .enable_http2()
/// # .build()
/// # );
/// # let mut hub = YouTube::new(client, auth);
/// // As the method needs a request, you would usually fill it with the desired information
/// // into the 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("ipsum")
/// .on_behalf_of_content_owner("accusam")
/// .doit().await;
/// # }
/// ```
pub struct ChannelSectionInsertCall<'a, C>
where
C: 'a,
{
hub: &'a YouTube<C>,
_request: ChannelSection,
_part: Vec<String>,
_on_behalf_of_content_owner_channel: Option<String>,
_on_behalf_of_content_owner: Option<String>,
_delegate: Option<&'a mut dyn common::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>,
}
impl<'a, C> common::CallBuilder for ChannelSectionInsertCall<'a, C> {}
impl<'a, C> ChannelSectionInsertCall<'a, C>
where
C: common::Connector,
{
/// Perform the operation you have build so far.
pub async fn doit(mut self) -> common::Result<(common::Response, ChannelSection)> {
use std::borrow::Cow;
use std::io::{Read, Seek};
use common::{url::Params, ToParts};
use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
let mut dd = common::DefaultDelegate;
let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(common::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(common::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.is_empty() {
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 = serde_json::value::to_value(&self._request).expect("serde to work");
common::remove_json_null_values(&mut value);
let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
serde_json::to_writer(&mut dst, &value).unwrap();
dst
};
let request_size = request_value_reader
.seek(std::io::SeekFrom::End(0))
.unwrap();
request_value_reader
.seek(std::io::SeekFrom::Start(0))
.unwrap();
loop {
let token = match self
.hub
.auth
.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
.await
{
Ok(token) => token,
Err(e) => match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(common::Error::MissingToken(e));
}
},
};
request_value_reader
.seek(std::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(common::to_body(
request_value_reader.get_ref().clone().into(),
));
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let common::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(common::Error::HttpError(err));
}
Ok(res) => {
let (mut parts, body) = res.into_parts();
let mut body = common::Body::new(body);
if !parts.status.is_success() {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let error = serde_json::from_str(&common::to_string(&bytes));
let response = common::to_response(parts, bytes.into());
if let common::Retry::After(d) =
dlg.http_failure(&response, error.as_ref().ok())
{
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(match error {
Ok(value) => common::Error::BadRequest(value),
_ => common::Error::Failure(response),
});
}
let response = {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let encoded = common::to_string(&bytes);
match serde_json::from_str(&encoded) {
Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
Err(error) => {
dlg.response_json_decode_error(&encoded, &error);
return Err(common::Error::JsonDecodeError(
encoded.to_string(),
error,
));
}
}
};
dlg.finished(true);
return Ok(response);
}
}
}
}
///
/// Sets the *request* 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, C> {
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, C> {
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, C> {
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, C> {
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 common::Delegate,
) -> ChannelSectionInsertCall<'a, C> {
self._delegate = Some(new_value);
self
}
/// Set any additional parameter of the query string used in the request.
/// It should be used to set parameters 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<T>(mut self, name: T, value: T) -> ChannelSectionInsertCall<'a, C>
where
T: AsRef<str>,
{
self._additional_params
.insert(name.as_ref().to_string(), value.as_ref().to_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<St>(mut self, scope: St) -> ChannelSectionInsertCall<'a, C>
where
St: AsRef<str>,
{
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<I, St>(mut self, scopes: I) -> ChannelSectionInsertCall<'a, C>
where
I: IntoIterator<Item = St>,
St: AsRef<str>,
{
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, C> {
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 youtube3::{YouTube, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_only()
/// # .enable_http2()
/// # .build();
///
/// # let executor = hyper_util::rt::TokioExecutor::new();
/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// # secret,
/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # yup_oauth2::client::CustomHyperClientBuilder::from(
/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
/// # ),
/// # ).build().await.unwrap();
///
/// # let client = hyper_util::client::legacy::Client::builder(
/// # hyper_util::rt::TokioExecutor::new()
/// # )
/// # .build(
/// # hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_or_http()
/// # .enable_http2()
/// # .build()
/// # );
/// # let mut hub = YouTube::new(client, auth);
/// // You can configure optional parameters by calling 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!["takimata".into()])
/// .on_behalf_of_content_owner("consetetur")
/// .mine(false)
/// .add_id("erat")
/// .hl("consetetur")
/// .channel_id("amet.")
/// .doit().await;
/// # }
/// ```
pub struct ChannelSectionListCall<'a, C>
where
C: 'a,
{
hub: &'a YouTube<C>,
_part: Vec<String>,
_on_behalf_of_content_owner: Option<String>,
_mine: Option<bool>,
_id: Vec<String>,
_hl: Option<String>,
_channel_id: Option<String>,
_delegate: Option<&'a mut dyn common::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>,
}
impl<'a, C> common::CallBuilder for ChannelSectionListCall<'a, C> {}
impl<'a, C> ChannelSectionListCall<'a, C>
where
C: common::Connector,
{
/// Perform the operation you have build so far.
pub async fn doit(mut self) -> common::Result<(common::Response, ChannelSectionListResponse)> {
use std::borrow::Cow;
use std::io::{Read, Seek};
use common::{url::Params, ToParts};
use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
let mut dd = common::DefaultDelegate;
let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(common::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(common::Error::FieldClash(field));
}
}
let mut params = Params::with_capacity(8 + self._additional_params.len());
if !self._part.is_empty() {
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.is_empty() {
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::<Vec<_>>()[..])
.await
{
Ok(token) => token,
Err(e) => match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(common::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(common::to_body::<String>(None));
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let common::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(common::Error::HttpError(err));
}
Ok(res) => {
let (mut parts, body) = res.into_parts();
let mut body = common::Body::new(body);
if !parts.status.is_success() {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let error = serde_json::from_str(&common::to_string(&bytes));
let response = common::to_response(parts, bytes.into());
if let common::Retry::After(d) =
dlg.http_failure(&response, error.as_ref().ok())
{
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(match error {
Ok(value) => common::Error::BadRequest(value),
_ => common::Error::Failure(response),
});
}
let response = {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let encoded = common::to_string(&bytes);
match serde_json::from_str(&encoded) {
Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
Err(error) => {
dlg.response_json_decode_error(&encoded, &error);
return Err(common::Error::JsonDecodeError(
encoded.to_string(),
error,
));
}
}
};
dlg.finished(true);
return Ok(response);
}
}
}
}
/// 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, C> {
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, C> {
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, C> {
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, C> {
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, C> {
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, C> {
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 common::Delegate,
) -> ChannelSectionListCall<'a, C> {
self._delegate = Some(new_value);
self
}
/// Set any additional parameter of the query string used in the request.
/// It should be used to set parameters 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<T>(mut self, name: T, value: T) -> ChannelSectionListCall<'a, C>
where
T: AsRef<str>,
{
self._additional_params
.insert(name.as_ref().to_string(), value.as_ref().to_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<St>(mut self, scope: St) -> ChannelSectionListCall<'a, C>
where
St: AsRef<str>,
{
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<I, St>(mut self, scopes: I) -> ChannelSectionListCall<'a, C>
where
I: IntoIterator<Item = St>,
St: AsRef<str>,
{
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, C> {
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 youtube3::{YouTube, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_only()
/// # .enable_http2()
/// # .build();
///
/// # let executor = hyper_util::rt::TokioExecutor::new();
/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// # secret,
/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # yup_oauth2::client::CustomHyperClientBuilder::from(
/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
/// # ),
/// # ).build().await.unwrap();
///
/// # let client = hyper_util::client::legacy::Client::builder(
/// # hyper_util::rt::TokioExecutor::new()
/// # )
/// # .build(
/// # hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_or_http()
/// # .enable_http2()
/// # .build()
/// # );
/// # let mut hub = YouTube::new(client, auth);
/// // As the method needs a request, you would usually fill it with the desired information
/// // into the 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("sed")
/// .doit().await;
/// # }
/// ```
pub struct ChannelSectionUpdateCall<'a, C>
where
C: 'a,
{
hub: &'a YouTube<C>,
_request: ChannelSection,
_part: Vec<String>,
_on_behalf_of_content_owner: Option<String>,
_delegate: Option<&'a mut dyn common::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>,
}
impl<'a, C> common::CallBuilder for ChannelSectionUpdateCall<'a, C> {}
impl<'a, C> ChannelSectionUpdateCall<'a, C>
where
C: common::Connector,
{
/// Perform the operation you have build so far.
pub async fn doit(mut self) -> common::Result<(common::Response, ChannelSection)> {
use std::borrow::Cow;
use std::io::{Read, Seek};
use common::{url::Params, ToParts};
use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
let mut dd = common::DefaultDelegate;
let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(common::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(common::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.is_empty() {
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 = serde_json::value::to_value(&self._request).expect("serde to work");
common::remove_json_null_values(&mut value);
let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
serde_json::to_writer(&mut dst, &value).unwrap();
dst
};
let request_size = request_value_reader
.seek(std::io::SeekFrom::End(0))
.unwrap();
request_value_reader
.seek(std::io::SeekFrom::Start(0))
.unwrap();
loop {
let token = match self
.hub
.auth
.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
.await
{
Ok(token) => token,
Err(e) => match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(common::Error::MissingToken(e));
}
},
};
request_value_reader
.seek(std::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(common::to_body(
request_value_reader.get_ref().clone().into(),
));
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let common::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(common::Error::HttpError(err));
}
Ok(res) => {
let (mut parts, body) = res.into_parts();
let mut body = common::Body::new(body);
if !parts.status.is_success() {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let error = serde_json::from_str(&common::to_string(&bytes));
let response = common::to_response(parts, bytes.into());
if let common::Retry::After(d) =
dlg.http_failure(&response, error.as_ref().ok())
{
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(match error {
Ok(value) => common::Error::BadRequest(value),
_ => common::Error::Failure(response),
});
}
let response = {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let encoded = common::to_string(&bytes);
match serde_json::from_str(&encoded) {
Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
Err(error) => {
dlg.response_json_decode_error(&encoded, &error);
return Err(common::Error::JsonDecodeError(
encoded.to_string(),
error,
));
}
}
};
dlg.finished(true);
return Ok(response);
}
}
}
}
///
/// Sets the *request* 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, C> {
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, C> {
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, C> {
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 common::Delegate,
) -> ChannelSectionUpdateCall<'a, C> {
self._delegate = Some(new_value);
self
}
/// Set any additional parameter of the query string used in the request.
/// It should be used to set parameters 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<T>(mut self, name: T, value: T) -> ChannelSectionUpdateCall<'a, C>
where
T: AsRef<str>,
{
self._additional_params
.insert(name.as_ref().to_string(), value.as_ref().to_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<St>(mut self, scope: St) -> ChannelSectionUpdateCall<'a, C>
where
St: AsRef<str>,
{
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<I, St>(mut self, scopes: I) -> ChannelSectionUpdateCall<'a, C>
where
I: IntoIterator<Item = St>,
St: AsRef<str>,
{
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, C> {
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 youtube3::{YouTube, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_only()
/// # .enable_http2()
/// # .build();
///
/// # let executor = hyper_util::rt::TokioExecutor::new();
/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// # secret,
/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # yup_oauth2::client::CustomHyperClientBuilder::from(
/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
/// # ),
/// # ).build().await.unwrap();
///
/// # let client = hyper_util::client::legacy::Client::builder(
/// # hyper_util::rt::TokioExecutor::new()
/// # )
/// # .build(
/// # hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_or_http()
/// # .enable_http2()
/// # .build()
/// # );
/// # let mut hub = YouTube::new(client, auth);
/// // You can configure optional parameters by calling 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!["takimata".into()])
/// .page_token("dolores")
/// .on_behalf_of_content_owner("gubergren")
/// .my_subscribers(false)
/// .mine(false)
/// .max_results(67)
/// .managed_by_me(false)
/// .add_id("amet.")
/// .hl("ea")
/// .for_username("sadipscing")
/// .for_handle("Lorem")
/// .category_id("invidunt")
/// .doit().await;
/// # }
/// ```
pub struct ChannelListCall<'a, C>
where
C: 'a,
{
hub: &'a YouTube<C>,
_part: Vec<String>,
_page_token: Option<String>,
_on_behalf_of_content_owner: Option<String>,
_my_subscribers: Option<bool>,
_mine: Option<bool>,
_max_results: Option<u32>,
_managed_by_me: Option<bool>,
_id: Vec<String>,
_hl: Option<String>,
_for_username: Option<String>,
_for_handle: Option<String>,
_category_id: Option<String>,
_delegate: Option<&'a mut dyn common::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>,
}
impl<'a, C> common::CallBuilder for ChannelListCall<'a, C> {}
impl<'a, C> ChannelListCall<'a, C>
where
C: common::Connector,
{
/// Perform the operation you have build so far.
pub async fn doit(mut self) -> common::Result<(common::Response, ChannelListResponse)> {
use std::borrow::Cow;
use std::io::{Read, Seek};
use common::{url::Params, ToParts};
use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
let mut dd = common::DefaultDelegate;
let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(common::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(common::Error::FieldClash(field));
}
}
let mut params = Params::with_capacity(14 + self._additional_params.len());
if !self._part.is_empty() {
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.is_empty() {
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::<Vec<_>>()[..])
.await
{
Ok(token) => token,
Err(e) => match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(common::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(common::to_body::<String>(None));
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let common::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(common::Error::HttpError(err));
}
Ok(res) => {
let (mut parts, body) = res.into_parts();
let mut body = common::Body::new(body);
if !parts.status.is_success() {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let error = serde_json::from_str(&common::to_string(&bytes));
let response = common::to_response(parts, bytes.into());
if let common::Retry::After(d) =
dlg.http_failure(&response, error.as_ref().ok())
{
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(match error {
Ok(value) => common::Error::BadRequest(value),
_ => common::Error::Failure(response),
});
}
let response = {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let encoded = common::to_string(&bytes);
match serde_json::from_str(&encoded) {
Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
Err(error) => {
dlg.response_json_decode_error(&encoded, &error);
return Err(common::Error::JsonDecodeError(
encoded.to_string(),
error,
));
}
}
};
dlg.finished(true);
return Ok(response);
}
}
}
}
/// 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, C> {
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, C> {
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, C> {
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, C> {
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, C> {
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, C> {
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, C> {
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, C> {
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, C> {
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, C> {
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, C> {
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, C> {
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 common::Delegate) -> ChannelListCall<'a, C> {
self._delegate = Some(new_value);
self
}
/// Set any additional parameter of the query string used in the request.
/// It should be used to set parameters 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<T>(mut self, name: T, value: T) -> ChannelListCall<'a, C>
where
T: AsRef<str>,
{
self._additional_params
.insert(name.as_ref().to_string(), value.as_ref().to_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<St>(mut self, scope: St) -> ChannelListCall<'a, C>
where
St: AsRef<str>,
{
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<I, St>(mut self, scopes: I) -> ChannelListCall<'a, C>
where
I: IntoIterator<Item = St>,
St: AsRef<str>,
{
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, C> {
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 youtube3::{YouTube, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_only()
/// # .enable_http2()
/// # .build();
///
/// # let executor = hyper_util::rt::TokioExecutor::new();
/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// # secret,
/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # yup_oauth2::client::CustomHyperClientBuilder::from(
/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
/// # ),
/// # ).build().await.unwrap();
///
/// # let client = hyper_util::client::legacy::Client::builder(
/// # hyper_util::rt::TokioExecutor::new()
/// # )
/// # .build(
/// # hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_or_http()
/// # .enable_http2()
/// # .build()
/// # );
/// # let mut hub = YouTube::new(client, auth);
/// // As the method needs a request, you would usually fill it with the desired information
/// // into the 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("no")
/// .doit().await;
/// # }
/// ```
pub struct ChannelUpdateCall<'a, C>
where
C: 'a,
{
hub: &'a YouTube<C>,
_request: Channel,
_part: Vec<String>,
_on_behalf_of_content_owner: Option<String>,
_delegate: Option<&'a mut dyn common::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>,
}
impl<'a, C> common::CallBuilder for ChannelUpdateCall<'a, C> {}
impl<'a, C> ChannelUpdateCall<'a, C>
where
C: common::Connector,
{
/// Perform the operation you have build so far.
pub async fn doit(mut self) -> common::Result<(common::Response, Channel)> {
use std::borrow::Cow;
use std::io::{Read, Seek};
use common::{url::Params, ToParts};
use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
let mut dd = common::DefaultDelegate;
let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(common::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(common::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.is_empty() {
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 = serde_json::value::to_value(&self._request).expect("serde to work");
common::remove_json_null_values(&mut value);
let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
serde_json::to_writer(&mut dst, &value).unwrap();
dst
};
let request_size = request_value_reader
.seek(std::io::SeekFrom::End(0))
.unwrap();
request_value_reader
.seek(std::io::SeekFrom::Start(0))
.unwrap();
loop {
let token = match self
.hub
.auth
.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
.await
{
Ok(token) => token,
Err(e) => match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(common::Error::MissingToken(e));
}
},
};
request_value_reader
.seek(std::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(common::to_body(
request_value_reader.get_ref().clone().into(),
));
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let common::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(common::Error::HttpError(err));
}
Ok(res) => {
let (mut parts, body) = res.into_parts();
let mut body = common::Body::new(body);
if !parts.status.is_success() {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let error = serde_json::from_str(&common::to_string(&bytes));
let response = common::to_response(parts, bytes.into());
if let common::Retry::After(d) =
dlg.http_failure(&response, error.as_ref().ok())
{
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(match error {
Ok(value) => common::Error::BadRequest(value),
_ => common::Error::Failure(response),
});
}
let response = {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let encoded = common::to_string(&bytes);
match serde_json::from_str(&encoded) {
Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
Err(error) => {
dlg.response_json_decode_error(&encoded, &error);
return Err(common::Error::JsonDecodeError(
encoded.to_string(),
error,
));
}
}
};
dlg.finished(true);
return Ok(response);
}
}
}
}
///
/// Sets the *request* property to the given value.
///
/// Even though 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, C> {
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, C> {
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, C> {
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 common::Delegate) -> ChannelUpdateCall<'a, C> {
self._delegate = Some(new_value);
self
}
/// Set any additional parameter of the query string used in the request.
/// It should be used to set parameters 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<T>(mut self, name: T, value: T) -> ChannelUpdateCall<'a, C>
where
T: AsRef<str>,
{
self._additional_params
.insert(name.as_ref().to_string(), value.as_ref().to_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<St>(mut self, scope: St) -> ChannelUpdateCall<'a, C>
where
St: AsRef<str>,
{
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<I, St>(mut self, scopes: I) -> ChannelUpdateCall<'a, C>
where
I: IntoIterator<Item = St>,
St: AsRef<str>,
{
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, C> {
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 youtube3::{YouTube, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_only()
/// # .enable_http2()
/// # .build();
///
/// # let executor = hyper_util::rt::TokioExecutor::new();
/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// # secret,
/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # yup_oauth2::client::CustomHyperClientBuilder::from(
/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
/// # ),
/// # ).build().await.unwrap();
///
/// # let client = hyper_util::client::legacy::Client::builder(
/// # hyper_util::rt::TokioExecutor::new()
/// # )
/// # .build(
/// # hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_or_http()
/// # .enable_http2()
/// # .build()
/// # );
/// # let mut hub = YouTube::new(client, auth);
/// // As the method needs a request, you would usually fill it with the desired information
/// // into the 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, C>
where
C: 'a,
{
hub: &'a YouTube<C>,
_request: CommentThread,
_part: Vec<String>,
_delegate: Option<&'a mut dyn common::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>,
}
impl<'a, C> common::CallBuilder for CommentThreadInsertCall<'a, C> {}
impl<'a, C> CommentThreadInsertCall<'a, C>
where
C: common::Connector,
{
/// Perform the operation you have build so far.
pub async fn doit(mut self) -> common::Result<(common::Response, CommentThread)> {
use std::borrow::Cow;
use std::io::{Read, Seek};
use common::{url::Params, ToParts};
use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
let mut dd = common::DefaultDelegate;
let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(common::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(common::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.is_empty() {
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 = serde_json::value::to_value(&self._request).expect("serde to work");
common::remove_json_null_values(&mut value);
let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
serde_json::to_writer(&mut dst, &value).unwrap();
dst
};
let request_size = request_value_reader
.seek(std::io::SeekFrom::End(0))
.unwrap();
request_value_reader
.seek(std::io::SeekFrom::Start(0))
.unwrap();
loop {
let token = match self
.hub
.auth
.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
.await
{
Ok(token) => token,
Err(e) => match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(common::Error::MissingToken(e));
}
},
};
request_value_reader
.seek(std::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(common::to_body(
request_value_reader.get_ref().clone().into(),
));
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let common::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(common::Error::HttpError(err));
}
Ok(res) => {
let (mut parts, body) = res.into_parts();
let mut body = common::Body::new(body);
if !parts.status.is_success() {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let error = serde_json::from_str(&common::to_string(&bytes));
let response = common::to_response(parts, bytes.into());
if let common::Retry::After(d) =
dlg.http_failure(&response, error.as_ref().ok())
{
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(match error {
Ok(value) => common::Error::BadRequest(value),
_ => common::Error::Failure(response),
});
}
let response = {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let encoded = common::to_string(&bytes);
match serde_json::from_str(&encoded) {
Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
Err(error) => {
dlg.response_json_decode_error(&encoded, &error);
return Err(common::Error::JsonDecodeError(
encoded.to_string(),
error,
));
}
}
};
dlg.finished(true);
return Ok(response);
}
}
}
}
///
/// Sets the *request* property to the given value.
///
/// Even though 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, C> {
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, C> {
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 common::Delegate,
) -> CommentThreadInsertCall<'a, C> {
self._delegate = Some(new_value);
self
}
/// Set any additional parameter of the query string used in the request.
/// It should be used to set parameters 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<T>(mut self, name: T, value: T) -> CommentThreadInsertCall<'a, C>
where
T: AsRef<str>,
{
self._additional_params
.insert(name.as_ref().to_string(), value.as_ref().to_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<St>(mut self, scope: St) -> CommentThreadInsertCall<'a, C>
where
St: AsRef<str>,
{
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<I, St>(mut self, scopes: I) -> CommentThreadInsertCall<'a, C>
where
I: IntoIterator<Item = St>,
St: AsRef<str>,
{
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, C> {
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 youtube3::{YouTube, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_only()
/// # .enable_http2()
/// # .build();
///
/// # let executor = hyper_util::rt::TokioExecutor::new();
/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// # secret,
/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # yup_oauth2::client::CustomHyperClientBuilder::from(
/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
/// # ),
/// # ).build().await.unwrap();
///
/// # let client = hyper_util::client::legacy::Client::builder(
/// # hyper_util::rt::TokioExecutor::new()
/// # )
/// # .build(
/// # hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_or_http()
/// # .enable_http2()
/// # .build()
/// # );
/// # let mut hub = YouTube::new(client, auth);
/// // You can configure optional parameters by calling 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!["est".into()])
/// .video_id("At")
/// .text_format("sed")
/// .search_terms("sit")
/// .post_id("et")
/// .page_token("tempor")
/// .order("aliquyam")
/// .moderation_status("ipsum")
/// .max_results(83)
/// .add_id("sanctus")
/// .channel_id("Lorem")
/// .all_threads_related_to_channel_id("est")
/// .doit().await;
/// # }
/// ```
pub struct CommentThreadListCall<'a, C>
where
C: 'a,
{
hub: &'a YouTube<C>,
_part: Vec<String>,
_video_id: Option<String>,
_text_format: Option<String>,
_search_terms: Option<String>,
_post_id: Option<String>,
_page_token: Option<String>,
_order: Option<String>,
_moderation_status: Option<String>,
_max_results: Option<u32>,
_id: Vec<String>,
_channel_id: Option<String>,
_all_threads_related_to_channel_id: Option<String>,
_delegate: Option<&'a mut dyn common::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>,
}
impl<'a, C> common::CallBuilder for CommentThreadListCall<'a, C> {}
impl<'a, C> CommentThreadListCall<'a, C>
where
C: common::Connector,
{
/// Perform the operation you have build so far.
pub async fn doit(mut self) -> common::Result<(common::Response, CommentThreadListResponse)> {
use std::borrow::Cow;
use std::io::{Read, Seek};
use common::{url::Params, ToParts};
use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
let mut dd = common::DefaultDelegate;
let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(common::MethodInfo {
id: "youtube.commentThreads.list",
http_method: hyper::Method::GET,
});
for &field in [
"alt",
"part",
"videoId",
"textFormat",
"searchTerms",
"postId",
"pageToken",
"order",
"moderationStatus",
"maxResults",
"id",
"channelId",
"allThreadsRelatedToChannelId",
]
.iter()
{
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Err(common::Error::FieldClash(field));
}
}
let mut params = Params::with_capacity(14 + self._additional_params.len());
if !self._part.is_empty() {
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._post_id.as_ref() {
params.push("postId", 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.is_empty() {
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::<Vec<_>>()[..])
.await
{
Ok(token) => token,
Err(e) => match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(common::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(common::to_body::<String>(None));
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let common::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(common::Error::HttpError(err));
}
Ok(res) => {
let (mut parts, body) = res.into_parts();
let mut body = common::Body::new(body);
if !parts.status.is_success() {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let error = serde_json::from_str(&common::to_string(&bytes));
let response = common::to_response(parts, bytes.into());
if let common::Retry::After(d) =
dlg.http_failure(&response, error.as_ref().ok())
{
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(match error {
Ok(value) => common::Error::BadRequest(value),
_ => common::Error::Failure(response),
});
}
let response = {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let encoded = common::to_string(&bytes);
match serde_json::from_str(&encoded) {
Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
Err(error) => {
dlg.response_json_decode_error(&encoded, &error);
return Err(common::Error::JsonDecodeError(
encoded.to_string(),
error,
));
}
}
};
dlg.finished(true);
return Ok(response);
}
}
}
}
/// 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, C> {
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, C> {
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: &str) -> CommentThreadListCall<'a, C> {
self._text_format = Some(new_value.to_string());
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, C> {
self._search_terms = Some(new_value.to_string());
self
}
/// Returns the comment threads of the specified post.
///
/// Sets the *post id* query property to the given value.
pub fn post_id(mut self, new_value: &str) -> CommentThreadListCall<'a, C> {
self._post_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) -> CommentThreadListCall<'a, C> {
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: &str) -> CommentThreadListCall<'a, C> {
self._order = Some(new_value.to_string());
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: &str) -> CommentThreadListCall<'a, C> {
self._moderation_status = 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) -> CommentThreadListCall<'a, C> {
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, C> {
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, C> {
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, C> {
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 common::Delegate,
) -> CommentThreadListCall<'a, C> {
self._delegate = Some(new_value);
self
}
/// Set any additional parameter of the query string used in the request.
/// It should be used to set parameters 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<T>(mut self, name: T, value: T) -> CommentThreadListCall<'a, C>
where
T: AsRef<str>,
{
self._additional_params
.insert(name.as_ref().to_string(), value.as_ref().to_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<St>(mut self, scope: St) -> CommentThreadListCall<'a, C>
where
St: AsRef<str>,
{
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<I, St>(mut self, scopes: I) -> CommentThreadListCall<'a, C>
where
I: IntoIterator<Item = St>,
St: AsRef<str>,
{
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, C> {
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 youtube3::{YouTube, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_only()
/// # .enable_http2()
/// # .build();
///
/// # let executor = hyper_util::rt::TokioExecutor::new();
/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// # secret,
/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # yup_oauth2::client::CustomHyperClientBuilder::from(
/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
/// # ),
/// # ).build().await.unwrap();
///
/// # let client = hyper_util::client::legacy::Client::builder(
/// # hyper_util::rt::TokioExecutor::new()
/// # )
/// # .build(
/// # hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_or_http()
/// # .enable_http2()
/// # .build()
/// # );
/// # let mut hub = YouTube::new(client, auth);
/// // You can configure optional parameters by calling 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, C>
where
C: 'a,
{
hub: &'a YouTube<C>,
_id: String,
_delegate: Option<&'a mut dyn common::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>,
}
impl<'a, C> common::CallBuilder for CommentDeleteCall<'a, C> {}
impl<'a, C> CommentDeleteCall<'a, C>
where
C: common::Connector,
{
/// Perform the operation you have build so far.
pub async fn doit(mut self) -> common::Result<common::Response> {
use std::borrow::Cow;
use std::io::{Read, Seek};
use common::{url::Params, ToParts};
use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
let mut dd = common::DefaultDelegate;
let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(common::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(common::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::<Vec<_>>()[..])
.await
{
Ok(token) => token,
Err(e) => match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(common::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(common::to_body::<String>(None));
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let common::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(common::Error::HttpError(err));
}
Ok(res) => {
let (mut parts, body) = res.into_parts();
let mut body = common::Body::new(body);
if !parts.status.is_success() {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let error = serde_json::from_str(&common::to_string(&bytes));
let response = common::to_response(parts, bytes.into());
if let common::Retry::After(d) =
dlg.http_failure(&response, error.as_ref().ok())
{
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(match error {
Ok(value) => common::Error::BadRequest(value),
_ => common::Error::Failure(response),
});
}
let response = common::Response::from_parts(parts, body);
dlg.finished(true);
return Ok(response);
}
}
}
}
///
/// 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, C> {
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 common::Delegate) -> CommentDeleteCall<'a, C> {
self._delegate = Some(new_value);
self
}
/// Set any additional parameter of the query string used in the request.
/// It should be used to set parameters 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<T>(mut self, name: T, value: T) -> CommentDeleteCall<'a, C>
where
T: AsRef<str>,
{
self._additional_params
.insert(name.as_ref().to_string(), value.as_ref().to_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<St>(mut self, scope: St) -> CommentDeleteCall<'a, C>
where
St: AsRef<str>,
{
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<I, St>(mut self, scopes: I) -> CommentDeleteCall<'a, C>
where
I: IntoIterator<Item = St>,
St: AsRef<str>,
{
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, C> {
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 youtube3::{YouTube, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_only()
/// # .enable_http2()
/// # .build();
///
/// # let executor = hyper_util::rt::TokioExecutor::new();
/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// # secret,
/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # yup_oauth2::client::CustomHyperClientBuilder::from(
/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
/// # ),
/// # ).build().await.unwrap();
///
/// # let client = hyper_util::client::legacy::Client::builder(
/// # hyper_util::rt::TokioExecutor::new()
/// # )
/// # .build(
/// # hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_or_http()
/// # .enable_http2()
/// # .build()
/// # );
/// # let mut hub = YouTube::new(client, auth);
/// // As the method needs a request, you would usually fill it with the desired information
/// // into the 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, C>
where
C: 'a,
{
hub: &'a YouTube<C>,
_request: Comment,
_part: Vec<String>,
_delegate: Option<&'a mut dyn common::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>,
}
impl<'a, C> common::CallBuilder for CommentInsertCall<'a, C> {}
impl<'a, C> CommentInsertCall<'a, C>
where
C: common::Connector,
{
/// Perform the operation you have build so far.
pub async fn doit(mut self) -> common::Result<(common::Response, Comment)> {
use std::borrow::Cow;
use std::io::{Read, Seek};
use common::{url::Params, ToParts};
use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
let mut dd = common::DefaultDelegate;
let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(common::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(common::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.is_empty() {
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 = serde_json::value::to_value(&self._request).expect("serde to work");
common::remove_json_null_values(&mut value);
let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
serde_json::to_writer(&mut dst, &value).unwrap();
dst
};
let request_size = request_value_reader
.seek(std::io::SeekFrom::End(0))
.unwrap();
request_value_reader
.seek(std::io::SeekFrom::Start(0))
.unwrap();
loop {
let token = match self
.hub
.auth
.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
.await
{
Ok(token) => token,
Err(e) => match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(common::Error::MissingToken(e));
}
},
};
request_value_reader
.seek(std::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(common::to_body(
request_value_reader.get_ref().clone().into(),
));
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let common::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(common::Error::HttpError(err));
}
Ok(res) => {
let (mut parts, body) = res.into_parts();
let mut body = common::Body::new(body);
if !parts.status.is_success() {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let error = serde_json::from_str(&common::to_string(&bytes));
let response = common::to_response(parts, bytes.into());
if let common::Retry::After(d) =
dlg.http_failure(&response, error.as_ref().ok())
{
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(match error {
Ok(value) => common::Error::BadRequest(value),
_ => common::Error::Failure(response),
});
}
let response = {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let encoded = common::to_string(&bytes);
match serde_json::from_str(&encoded) {
Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
Err(error) => {
dlg.response_json_decode_error(&encoded, &error);
return Err(common::Error::JsonDecodeError(
encoded.to_string(),
error,
));
}
}
};
dlg.finished(true);
return Ok(response);
}
}
}
}
///
/// Sets the *request* property to the given value.
///
/// Even though 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, C> {
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, C> {
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 common::Delegate) -> CommentInsertCall<'a, C> {
self._delegate = Some(new_value);
self
}
/// Set any additional parameter of the query string used in the request.
/// It should be used to set parameters 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<T>(mut self, name: T, value: T) -> CommentInsertCall<'a, C>
where
T: AsRef<str>,
{
self._additional_params
.insert(name.as_ref().to_string(), value.as_ref().to_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<St>(mut self, scope: St) -> CommentInsertCall<'a, C>
where
St: AsRef<str>,
{
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<I, St>(mut self, scopes: I) -> CommentInsertCall<'a, C>
where
I: IntoIterator<Item = St>,
St: AsRef<str>,
{
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, C> {
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 youtube3::{YouTube, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_only()
/// # .enable_http2()
/// # .build();
///
/// # let executor = hyper_util::rt::TokioExecutor::new();
/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// # secret,
/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # yup_oauth2::client::CustomHyperClientBuilder::from(
/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
/// # ),
/// # ).build().await.unwrap();
///
/// # let client = hyper_util::client::legacy::Client::builder(
/// # hyper_util::rt::TokioExecutor::new()
/// # )
/// # .build(
/// # hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_or_http()
/// # .enable_http2()
/// # .build()
/// # );
/// # let mut hub = YouTube::new(client, auth);
/// // You can configure optional parameters by calling 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!["diam".into()])
/// .text_format("dolores")
/// .parent_id("dolores")
/// .page_token("et")
/// .max_results(8)
/// .add_id("no")
/// .doit().await;
/// # }
/// ```
pub struct CommentListCall<'a, C>
where
C: 'a,
{
hub: &'a YouTube<C>,
_part: Vec<String>,
_text_format: Option<String>,
_parent_id: Option<String>,
_page_token: Option<String>,
_max_results: Option<u32>,
_id: Vec<String>,
_delegate: Option<&'a mut dyn common::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>,
}
impl<'a, C> common::CallBuilder for CommentListCall<'a, C> {}
impl<'a, C> CommentListCall<'a, C>
where
C: common::Connector,
{
/// Perform the operation you have build so far.
pub async fn doit(mut self) -> common::Result<(common::Response, CommentListResponse)> {
use std::borrow::Cow;
use std::io::{Read, Seek};
use common::{url::Params, ToParts};
use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
let mut dd = common::DefaultDelegate;
let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(common::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(common::Error::FieldClash(field));
}
}
let mut params = Params::with_capacity(8 + self._additional_params.len());
if !self._part.is_empty() {
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.is_empty() {
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::<Vec<_>>()[..])
.await
{
Ok(token) => token,
Err(e) => match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(common::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(common::to_body::<String>(None));
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let common::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(common::Error::HttpError(err));
}
Ok(res) => {
let (mut parts, body) = res.into_parts();
let mut body = common::Body::new(body);
if !parts.status.is_success() {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let error = serde_json::from_str(&common::to_string(&bytes));
let response = common::to_response(parts, bytes.into());
if let common::Retry::After(d) =
dlg.http_failure(&response, error.as_ref().ok())
{
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(match error {
Ok(value) => common::Error::BadRequest(value),
_ => common::Error::Failure(response),
});
}
let response = {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let encoded = common::to_string(&bytes);
match serde_json::from_str(&encoded) {
Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
Err(error) => {
dlg.response_json_decode_error(&encoded, &error);
return Err(common::Error::JsonDecodeError(
encoded.to_string(),
error,
));
}
}
};
dlg.finished(true);
return Ok(response);
}
}
}
}
/// 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, C> {
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: &str) -> CommentListCall<'a, C> {
self._text_format = Some(new_value.to_string());
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, C> {
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, C> {
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, C> {
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, C> {
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 common::Delegate) -> CommentListCall<'a, C> {
self._delegate = Some(new_value);
self
}
/// Set any additional parameter of the query string used in the request.
/// It should be used to set parameters 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<T>(mut self, name: T, value: T) -> CommentListCall<'a, C>
where
T: AsRef<str>,
{
self._additional_params
.insert(name.as_ref().to_string(), value.as_ref().to_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<St>(mut self, scope: St) -> CommentListCall<'a, C>
where
St: AsRef<str>,
{
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<I, St>(mut self, scopes: I) -> CommentListCall<'a, C>
where
I: IntoIterator<Item = St>,
St: AsRef<str>,
{
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, C> {
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 youtube3::{YouTube, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_only()
/// # .enable_http2()
/// # .build();
///
/// # let executor = hyper_util::rt::TokioExecutor::new();
/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// # secret,
/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # yup_oauth2::client::CustomHyperClientBuilder::from(
/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
/// # ),
/// # ).build().await.unwrap();
///
/// # let client = hyper_util::client::legacy::Client::builder(
/// # hyper_util::rt::TokioExecutor::new()
/// # )
/// # .build(
/// # hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_or_http()
/// # .enable_http2()
/// # .build()
/// # );
/// # let mut hub = YouTube::new(client, auth);
/// // You can configure optional parameters by calling 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!["et".into()])
/// .doit().await;
/// # }
/// ```
pub struct CommentMarkAsSpamCall<'a, C>
where
C: 'a,
{
hub: &'a YouTube<C>,
_id: Vec<String>,
_delegate: Option<&'a mut dyn common::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>,
}
impl<'a, C> common::CallBuilder for CommentMarkAsSpamCall<'a, C> {}
impl<'a, C> CommentMarkAsSpamCall<'a, C>
where
C: common::Connector,
{
/// Perform the operation you have build so far.
pub async fn doit(mut self) -> common::Result<common::Response> {
use std::borrow::Cow;
use std::io::{Read, Seek};
use common::{url::Params, ToParts};
use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
let mut dd = common::DefaultDelegate;
let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(common::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(common::Error::FieldClash(field));
}
}
let mut params = Params::with_capacity(2 + self._additional_params.len());
if !self._id.is_empty() {
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::<Vec<_>>()[..])
.await
{
Ok(token) => token,
Err(e) => match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(common::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(common::to_body::<String>(None));
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let common::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(common::Error::HttpError(err));
}
Ok(res) => {
let (mut parts, body) = res.into_parts();
let mut body = common::Body::new(body);
if !parts.status.is_success() {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let error = serde_json::from_str(&common::to_string(&bytes));
let response = common::to_response(parts, bytes.into());
if let common::Retry::After(d) =
dlg.http_failure(&response, error.as_ref().ok())
{
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(match error {
Ok(value) => common::Error::BadRequest(value),
_ => common::Error::Failure(response),
});
}
let response = common::Response::from_parts(parts, body);
dlg.finished(true);
return Ok(response);
}
}
}
}
/// 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, C> {
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 common::Delegate,
) -> CommentMarkAsSpamCall<'a, C> {
self._delegate = Some(new_value);
self
}
/// Set any additional parameter of the query string used in the request.
/// It should be used to set parameters 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<T>(mut self, name: T, value: T) -> CommentMarkAsSpamCall<'a, C>
where
T: AsRef<str>,
{
self._additional_params
.insert(name.as_ref().to_string(), value.as_ref().to_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<St>(mut self, scope: St) -> CommentMarkAsSpamCall<'a, C>
where
St: AsRef<str>,
{
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<I, St>(mut self, scopes: I) -> CommentMarkAsSpamCall<'a, C>
where
I: IntoIterator<Item = St>,
St: AsRef<str>,
{
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, C> {
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 youtube3::{YouTube, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_only()
/// # .enable_http2()
/// # .build();
///
/// # let executor = hyper_util::rt::TokioExecutor::new();
/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// # secret,
/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # yup_oauth2::client::CustomHyperClientBuilder::from(
/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
/// # ),
/// # ).build().await.unwrap();
///
/// # let client = hyper_util::client::legacy::Client::builder(
/// # hyper_util::rt::TokioExecutor::new()
/// # )
/// # .build(
/// # hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_or_http()
/// # .enable_http2()
/// # .build()
/// # );
/// # let mut hub = YouTube::new(client, auth);
/// // You can configure optional parameters by calling 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!["elitr".into()], "moderationStatus")
/// .ban_author(true)
/// .doit().await;
/// # }
/// ```
pub struct CommentSetModerationStatuCall<'a, C>
where
C: 'a,
{
hub: &'a YouTube<C>,
_id: Vec<String>,
_moderation_status: String,
_ban_author: Option<bool>,
_delegate: Option<&'a mut dyn common::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>,
}
impl<'a, C> common::CallBuilder for CommentSetModerationStatuCall<'a, C> {}
impl<'a, C> CommentSetModerationStatuCall<'a, C>
where
C: common::Connector,
{
/// Perform the operation you have build so far.
pub async fn doit(mut self) -> common::Result<common::Response> {
use std::borrow::Cow;
use std::io::{Read, Seek};
use common::{url::Params, ToParts};
use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
let mut dd = common::DefaultDelegate;
let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(common::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(common::Error::FieldClash(field));
}
}
let mut params = Params::with_capacity(4 + self._additional_params.len());
if !self._id.is_empty() {
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::<Vec<_>>()[..])
.await
{
Ok(token) => token,
Err(e) => match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(common::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(common::to_body::<String>(None));
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let common::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(common::Error::HttpError(err));
}
Ok(res) => {
let (mut parts, body) = res.into_parts();
let mut body = common::Body::new(body);
if !parts.status.is_success() {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let error = serde_json::from_str(&common::to_string(&bytes));
let response = common::to_response(parts, bytes.into());
if let common::Retry::After(d) =
dlg.http_failure(&response, error.as_ref().ok())
{
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(match error {
Ok(value) => common::Error::BadRequest(value),
_ => common::Error::Failure(response),
});
}
let response = common::Response::from_parts(parts, body);
dlg.finished(true);
return Ok(response);
}
}
}
}
/// 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) -> CommentSetModerationStatuCall<'a, C> {
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: &str) -> CommentSetModerationStatuCall<'a, C> {
self._moderation_status = new_value.to_string();
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) -> CommentSetModerationStatuCall<'a, C> {
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 common::Delegate,
) -> CommentSetModerationStatuCall<'a, C> {
self._delegate = Some(new_value);
self
}
/// Set any additional parameter of the query string used in the request.
/// It should be used to set parameters 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<T>(mut self, name: T, value: T) -> CommentSetModerationStatuCall<'a, C>
where
T: AsRef<str>,
{
self._additional_params
.insert(name.as_ref().to_string(), value.as_ref().to_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<St>(mut self, scope: St) -> CommentSetModerationStatuCall<'a, C>
where
St: AsRef<str>,
{
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<I, St>(mut self, scopes: I) -> CommentSetModerationStatuCall<'a, C>
where
I: IntoIterator<Item = St>,
St: AsRef<str>,
{
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) -> CommentSetModerationStatuCall<'a, C> {
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 youtube3::{YouTube, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_only()
/// # .enable_http2()
/// # .build();
///
/// # let executor = hyper_util::rt::TokioExecutor::new();
/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// # secret,
/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # yup_oauth2::client::CustomHyperClientBuilder::from(
/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
/// # ),
/// # ).build().await.unwrap();
///
/// # let client = hyper_util::client::legacy::Client::builder(
/// # hyper_util::rt::TokioExecutor::new()
/// # )
/// # .build(
/// # hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_or_http()
/// # .enable_http2()
/// # .build()
/// # );
/// # let mut hub = YouTube::new(client, auth);
/// // As the method needs a request, you would usually fill it with the desired information
/// // into the 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, C>
where
C: 'a,
{
hub: &'a YouTube<C>,
_request: Comment,
_part: Vec<String>,
_delegate: Option<&'a mut dyn common::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>,
}
impl<'a, C> common::CallBuilder for CommentUpdateCall<'a, C> {}
impl<'a, C> CommentUpdateCall<'a, C>
where
C: common::Connector,
{
/// Perform the operation you have build so far.
pub async fn doit(mut self) -> common::Result<(common::Response, Comment)> {
use std::borrow::Cow;
use std::io::{Read, Seek};
use common::{url::Params, ToParts};
use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
let mut dd = common::DefaultDelegate;
let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(common::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(common::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.is_empty() {
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 = serde_json::value::to_value(&self._request).expect("serde to work");
common::remove_json_null_values(&mut value);
let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
serde_json::to_writer(&mut dst, &value).unwrap();
dst
};
let request_size = request_value_reader
.seek(std::io::SeekFrom::End(0))
.unwrap();
request_value_reader
.seek(std::io::SeekFrom::Start(0))
.unwrap();
loop {
let token = match self
.hub
.auth
.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
.await
{
Ok(token) => token,
Err(e) => match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(common::Error::MissingToken(e));
}
},
};
request_value_reader
.seek(std::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(common::to_body(
request_value_reader.get_ref().clone().into(),
));
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let common::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(common::Error::HttpError(err));
}
Ok(res) => {
let (mut parts, body) = res.into_parts();
let mut body = common::Body::new(body);
if !parts.status.is_success() {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let error = serde_json::from_str(&common::to_string(&bytes));
let response = common::to_response(parts, bytes.into());
if let common::Retry::After(d) =
dlg.http_failure(&response, error.as_ref().ok())
{
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(match error {
Ok(value) => common::Error::BadRequest(value),
_ => common::Error::Failure(response),
});
}
let response = {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let encoded = common::to_string(&bytes);
match serde_json::from_str(&encoded) {
Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
Err(error) => {
dlg.response_json_decode_error(&encoded, &error);
return Err(common::Error::JsonDecodeError(
encoded.to_string(),
error,
));
}
}
};
dlg.finished(true);
return Ok(response);
}
}
}
}
///
/// Sets the *request* property to the given value.
///
/// Even though 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, C> {
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, C> {
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 common::Delegate) -> CommentUpdateCall<'a, C> {
self._delegate = Some(new_value);
self
}
/// Set any additional parameter of the query string used in the request.
/// It should be used to set parameters 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<T>(mut self, name: T, value: T) -> CommentUpdateCall<'a, C>
where
T: AsRef<str>,
{
self._additional_params
.insert(name.as_ref().to_string(), value.as_ref().to_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<St>(mut self, scope: St) -> CommentUpdateCall<'a, C>
where
St: AsRef<str>,
{
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<I, St>(mut self, scopes: I) -> CommentUpdateCall<'a, C>
where
I: IntoIterator<Item = St>,
St: AsRef<str>,
{
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, C> {
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 youtube3::{YouTube, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_only()
/// # .enable_http2()
/// # .build();
///
/// # let executor = hyper_util::rt::TokioExecutor::new();
/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// # secret,
/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # yup_oauth2::client::CustomHyperClientBuilder::from(
/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
/// # ),
/// # ).build().await.unwrap();
///
/// # let client = hyper_util::client::legacy::Client::builder(
/// # hyper_util::rt::TokioExecutor::new()
/// # )
/// # .build(
/// # hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_or_http()
/// # .enable_http2()
/// # .build()
/// # );
/// # let mut hub = YouTube::new(client, auth);
/// // You can configure optional parameters by calling 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!["nonumy".into()])
/// .hl("At")
/// .doit().await;
/// # }
/// ```
pub struct I18nLanguageListCall<'a, C>
where
C: 'a,
{
hub: &'a YouTube<C>,
_part: Vec<String>,
_hl: Option<String>,
_delegate: Option<&'a mut dyn common::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>,
}
impl<'a, C> common::CallBuilder for I18nLanguageListCall<'a, C> {}
impl<'a, C> I18nLanguageListCall<'a, C>
where
C: common::Connector,
{
/// Perform the operation you have build so far.
pub async fn doit(mut self) -> common::Result<(common::Response, I18nLanguageListResponse)> {
use std::borrow::Cow;
use std::io::{Read, Seek};
use common::{url::Params, ToParts};
use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
let mut dd = common::DefaultDelegate;
let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(common::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(common::Error::FieldClash(field));
}
}
let mut params = Params::with_capacity(4 + self._additional_params.len());
if !self._part.is_empty() {
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::<Vec<_>>()[..])
.await
{
Ok(token) => token,
Err(e) => match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(common::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(common::to_body::<String>(None));
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let common::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(common::Error::HttpError(err));
}
Ok(res) => {
let (mut parts, body) = res.into_parts();
let mut body = common::Body::new(body);
if !parts.status.is_success() {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let error = serde_json::from_str(&common::to_string(&bytes));
let response = common::to_response(parts, bytes.into());
if let common::Retry::After(d) =
dlg.http_failure(&response, error.as_ref().ok())
{
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(match error {
Ok(value) => common::Error::BadRequest(value),
_ => common::Error::Failure(response),
});
}
let response = {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let encoded = common::to_string(&bytes);
match serde_json::from_str(&encoded) {
Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
Err(error) => {
dlg.response_json_decode_error(&encoded, &error);
return Err(common::Error::JsonDecodeError(
encoded.to_string(),
error,
));
}
}
};
dlg.finished(true);
return Ok(response);
}
}
}
}
/// 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, C> {
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, C> {
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 common::Delegate,
) -> I18nLanguageListCall<'a, C> {
self._delegate = Some(new_value);
self
}
/// Set any additional parameter of the query string used in the request.
/// It should be used to set parameters 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<T>(mut self, name: T, value: T) -> I18nLanguageListCall<'a, C>
where
T: AsRef<str>,
{
self._additional_params
.insert(name.as_ref().to_string(), value.as_ref().to_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<St>(mut self, scope: St) -> I18nLanguageListCall<'a, C>
where
St: AsRef<str>,
{
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<I, St>(mut self, scopes: I) -> I18nLanguageListCall<'a, C>
where
I: IntoIterator<Item = St>,
St: AsRef<str>,
{
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, C> {
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 youtube3::{YouTube, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_only()
/// # .enable_http2()
/// # .build();
///
/// # let executor = hyper_util::rt::TokioExecutor::new();
/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// # secret,
/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # yup_oauth2::client::CustomHyperClientBuilder::from(
/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
/// # ),
/// # ).build().await.unwrap();
///
/// # let client = hyper_util::client::legacy::Client::builder(
/// # hyper_util::rt::TokioExecutor::new()
/// # )
/// # .build(
/// # hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_or_http()
/// # .enable_http2()
/// # .build()
/// # );
/// # let mut hub = YouTube::new(client, auth);
/// // You can configure optional parameters by calling 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!["sadipscing".into()])
/// .hl("aliquyam")
/// .doit().await;
/// # }
/// ```
pub struct I18nRegionListCall<'a, C>
where
C: 'a,
{
hub: &'a YouTube<C>,
_part: Vec<String>,
_hl: Option<String>,
_delegate: Option<&'a mut dyn common::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>,
}
impl<'a, C> common::CallBuilder for I18nRegionListCall<'a, C> {}
impl<'a, C> I18nRegionListCall<'a, C>
where
C: common::Connector,
{
/// Perform the operation you have build so far.
pub async fn doit(mut self) -> common::Result<(common::Response, I18nRegionListResponse)> {
use std::borrow::Cow;
use std::io::{Read, Seek};
use common::{url::Params, ToParts};
use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
let mut dd = common::DefaultDelegate;
let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(common::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(common::Error::FieldClash(field));
}
}
let mut params = Params::with_capacity(4 + self._additional_params.len());
if !self._part.is_empty() {
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::<Vec<_>>()[..])
.await
{
Ok(token) => token,
Err(e) => match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(common::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(common::to_body::<String>(None));
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let common::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(common::Error::HttpError(err));
}
Ok(res) => {
let (mut parts, body) = res.into_parts();
let mut body = common::Body::new(body);
if !parts.status.is_success() {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let error = serde_json::from_str(&common::to_string(&bytes));
let response = common::to_response(parts, bytes.into());
if let common::Retry::After(d) =
dlg.http_failure(&response, error.as_ref().ok())
{
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(match error {
Ok(value) => common::Error::BadRequest(value),
_ => common::Error::Failure(response),
});
}
let response = {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let encoded = common::to_string(&bytes);
match serde_json::from_str(&encoded) {
Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
Err(error) => {
dlg.response_json_decode_error(&encoded, &error);
return Err(common::Error::JsonDecodeError(
encoded.to_string(),
error,
));
}
}
};
dlg.finished(true);
return Ok(response);
}
}
}
}
/// 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, C> {
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, C> {
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 common::Delegate,
) -> I18nRegionListCall<'a, C> {
self._delegate = Some(new_value);
self
}
/// Set any additional parameter of the query string used in the request.
/// It should be used to set parameters 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<T>(mut self, name: T, value: T) -> I18nRegionListCall<'a, C>
where
T: AsRef<str>,
{
self._additional_params
.insert(name.as_ref().to_string(), value.as_ref().to_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<St>(mut self, scope: St) -> I18nRegionListCall<'a, C>
where
St: AsRef<str>,
{
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<I, St>(mut self, scopes: I) -> I18nRegionListCall<'a, C>
where
I: IntoIterator<Item = St>,
St: AsRef<str>,
{
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, C> {
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 youtube3::{YouTube, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_only()
/// # .enable_http2()
/// # .build();
///
/// # let executor = hyper_util::rt::TokioExecutor::new();
/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// # secret,
/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # yup_oauth2::client::CustomHyperClientBuilder::from(
/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
/// # ),
/// # ).build().await.unwrap();
///
/// # let client = hyper_util::client::legacy::Client::builder(
/// # hyper_util::rt::TokioExecutor::new()
/// # )
/// # .build(
/// # hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_or_http()
/// # .enable_http2()
/// # .build()
/// # );
/// # let mut hub = YouTube::new(client, auth);
/// // You can configure optional parameters by calling 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!["sadipscing".into()])
/// .stream_id("erat")
/// .on_behalf_of_content_owner_channel("aliquyam")
/// .on_behalf_of_content_owner("amet")
/// .doit().await;
/// # }
/// ```
pub struct LiveBroadcastBindCall<'a, C>
where
C: 'a,
{
hub: &'a YouTube<C>,
_id: String,
_part: Vec<String>,
_stream_id: Option<String>,
_on_behalf_of_content_owner_channel: Option<String>,
_on_behalf_of_content_owner: Option<String>,
_delegate: Option<&'a mut dyn common::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>,
}
impl<'a, C> common::CallBuilder for LiveBroadcastBindCall<'a, C> {}
impl<'a, C> LiveBroadcastBindCall<'a, C>
where
C: common::Connector,
{
/// Perform the operation you have build so far.
pub async fn doit(mut self) -> common::Result<(common::Response, LiveBroadcast)> {
use std::borrow::Cow;
use std::io::{Read, Seek};
use common::{url::Params, ToParts};
use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
let mut dd = common::DefaultDelegate;
let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(common::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(common::Error::FieldClash(field));
}
}
let mut params = Params::with_capacity(7 + self._additional_params.len());
params.push("id", self._id);
if !self._part.is_empty() {
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::<Vec<_>>()[..])
.await
{
Ok(token) => token,
Err(e) => match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(common::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(common::to_body::<String>(None));
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let common::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(common::Error::HttpError(err));
}
Ok(res) => {
let (mut parts, body) = res.into_parts();
let mut body = common::Body::new(body);
if !parts.status.is_success() {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let error = serde_json::from_str(&common::to_string(&bytes));
let response = common::to_response(parts, bytes.into());
if let common::Retry::After(d) =
dlg.http_failure(&response, error.as_ref().ok())
{
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(match error {
Ok(value) => common::Error::BadRequest(value),
_ => common::Error::Failure(response),
});
}
let response = {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let encoded = common::to_string(&bytes);
match serde_json::from_str(&encoded) {
Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
Err(error) => {
dlg.response_json_decode_error(&encoded, &error);
return Err(common::Error::JsonDecodeError(
encoded.to_string(),
error,
));
}
}
};
dlg.finished(true);
return Ok(response);
}
}
}
}
/// 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, C> {
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, C> {
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, C> {
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, C> {
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, C> {
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 common::Delegate,
) -> LiveBroadcastBindCall<'a, C> {
self._delegate = Some(new_value);
self
}
/// Set any additional parameter of the query string used in the request.
/// It should be used to set parameters 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<T>(mut self, name: T, value: T) -> LiveBroadcastBindCall<'a, C>
where
T: AsRef<str>,
{
self._additional_params
.insert(name.as_ref().to_string(), value.as_ref().to_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<St>(mut self, scope: St) -> LiveBroadcastBindCall<'a, C>
where
St: AsRef<str>,
{
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<I, St>(mut self, scopes: I) -> LiveBroadcastBindCall<'a, C>
where
I: IntoIterator<Item = St>,
St: AsRef<str>,
{
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, C> {
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 youtube3::{YouTube, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_only()
/// # .enable_http2()
/// # .build();
///
/// # let executor = hyper_util::rt::TokioExecutor::new();
/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// # secret,
/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # yup_oauth2::client::CustomHyperClientBuilder::from(
/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
/// # ),
/// # ).build().await.unwrap();
///
/// # let client = hyper_util::client::legacy::Client::builder(
/// # hyper_util::rt::TokioExecutor::new()
/// # )
/// # .build(
/// # hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_or_http()
/// # .enable_http2()
/// # .build()
/// # );
/// # let mut hub = YouTube::new(client, auth);
/// // You can configure optional parameters by calling 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("et")
/// .on_behalf_of_content_owner("sea")
/// .doit().await;
/// # }
/// ```
pub struct LiveBroadcastDeleteCall<'a, C>
where
C: 'a,
{
hub: &'a YouTube<C>,
_id: String,
_on_behalf_of_content_owner_channel: Option<String>,
_on_behalf_of_content_owner: Option<String>,
_delegate: Option<&'a mut dyn common::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>,
}
impl<'a, C> common::CallBuilder for LiveBroadcastDeleteCall<'a, C> {}
impl<'a, C> LiveBroadcastDeleteCall<'a, C>
where
C: common::Connector,
{
/// Perform the operation you have build so far.
pub async fn doit(mut self) -> common::Result<common::Response> {
use std::borrow::Cow;
use std::io::{Read, Seek};
use common::{url::Params, ToParts};
use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
let mut dd = common::DefaultDelegate;
let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(common::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(common::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::<Vec<_>>()[..])
.await
{
Ok(token) => token,
Err(e) => match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(common::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(common::to_body::<String>(None));
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let common::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(common::Error::HttpError(err));
}
Ok(res) => {
let (mut parts, body) = res.into_parts();
let mut body = common::Body::new(body);
if !parts.status.is_success() {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let error = serde_json::from_str(&common::to_string(&bytes));
let response = common::to_response(parts, bytes.into());
if let common::Retry::After(d) =
dlg.http_failure(&response, error.as_ref().ok())
{
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(match error {
Ok(value) => common::Error::BadRequest(value),
_ => common::Error::Failure(response),
});
}
let response = common::Response::from_parts(parts, body);
dlg.finished(true);
return Ok(response);
}
}
}
}
/// 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, C> {
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, C> {
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, C> {
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 common::Delegate,
) -> LiveBroadcastDeleteCall<'a, C> {
self._delegate = Some(new_value);
self
}
/// Set any additional parameter of the query string used in the request.
/// It should be used to set parameters 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<T>(mut self, name: T, value: T) -> LiveBroadcastDeleteCall<'a, C>
where
T: AsRef<str>,
{
self._additional_params
.insert(name.as_ref().to_string(), value.as_ref().to_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<St>(mut self, scope: St) -> LiveBroadcastDeleteCall<'a, C>
where
St: AsRef<str>,
{
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<I, St>(mut self, scopes: I) -> LiveBroadcastDeleteCall<'a, C>
where
I: IntoIterator<Item = St>,
St: AsRef<str>,
{
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, C> {
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 youtube3::{YouTube, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_only()
/// # .enable_http2()
/// # .build();
///
/// # let executor = hyper_util::rt::TokioExecutor::new();
/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// # secret,
/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # yup_oauth2::client::CustomHyperClientBuilder::from(
/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
/// # ),
/// # ).build().await.unwrap();
///
/// # let client = hyper_util::client::legacy::Client::builder(
/// # hyper_util::rt::TokioExecutor::new()
/// # )
/// # .build(
/// # hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_or_http()
/// # .enable_http2()
/// # .build()
/// # );
/// # let mut hub = YouTube::new(client, auth);
/// // As the method needs a request, you would usually fill it with the desired information
/// // into the 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("consetetur".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("consetetur")
/// .on_behalf_of_content_owner("Stet")
/// .doit().await;
/// # }
/// ```
pub struct LiveBroadcastInsertCall<'a, C>
where
C: 'a,
{
hub: &'a YouTube<C>,
_request: LiveBroadcast,
_part: Vec<String>,
_on_behalf_of_content_owner_channel: Option<String>,
_on_behalf_of_content_owner: Option<String>,
_delegate: Option<&'a mut dyn common::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>,
}
impl<'a, C> common::CallBuilder for LiveBroadcastInsertCall<'a, C> {}
impl<'a, C> LiveBroadcastInsertCall<'a, C>
where
C: common::Connector,
{
/// Perform the operation you have build so far.
pub async fn doit(mut self) -> common::Result<(common::Response, LiveBroadcast)> {
use std::borrow::Cow;
use std::io::{Read, Seek};
use common::{url::Params, ToParts};
use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
let mut dd = common::DefaultDelegate;
let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(common::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(common::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.is_empty() {
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 = serde_json::value::to_value(&self._request).expect("serde to work");
common::remove_json_null_values(&mut value);
let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
serde_json::to_writer(&mut dst, &value).unwrap();
dst
};
let request_size = request_value_reader
.seek(std::io::SeekFrom::End(0))
.unwrap();
request_value_reader
.seek(std::io::SeekFrom::Start(0))
.unwrap();
loop {
let token = match self
.hub
.auth
.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
.await
{
Ok(token) => token,
Err(e) => match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(common::Error::MissingToken(e));
}
},
};
request_value_reader
.seek(std::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(common::to_body(
request_value_reader.get_ref().clone().into(),
));
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let common::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(common::Error::HttpError(err));
}
Ok(res) => {
let (mut parts, body) = res.into_parts();
let mut body = common::Body::new(body);
if !parts.status.is_success() {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let error = serde_json::from_str(&common::to_string(&bytes));
let response = common::to_response(parts, bytes.into());
if let common::Retry::After(d) =
dlg.http_failure(&response, error.as_ref().ok())
{
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(match error {
Ok(value) => common::Error::BadRequest(value),
_ => common::Error::Failure(response),
});
}
let response = {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let encoded = common::to_string(&bytes);
match serde_json::from_str(&encoded) {
Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
Err(error) => {
dlg.response_json_decode_error(&encoded, &error);
return Err(common::Error::JsonDecodeError(
encoded.to_string(),
error,
));
}
}
};
dlg.finished(true);
return Ok(response);
}
}
}
}
///
/// Sets the *request* 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, C> {
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, C> {
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, C> {
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, C> {
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 common::Delegate,
) -> LiveBroadcastInsertCall<'a, C> {
self._delegate = Some(new_value);
self
}
/// Set any additional parameter of the query string used in the request.
/// It should be used to set parameters 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<T>(mut self, name: T, value: T) -> LiveBroadcastInsertCall<'a, C>
where
T: AsRef<str>,
{
self._additional_params
.insert(name.as_ref().to_string(), value.as_ref().to_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<St>(mut self, scope: St) -> LiveBroadcastInsertCall<'a, C>
where
St: AsRef<str>,
{
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<I, St>(mut self, scopes: I) -> LiveBroadcastInsertCall<'a, C>
where
I: IntoIterator<Item = St>,
St: AsRef<str>,
{
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, C> {
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 youtube3::{YouTube, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_only()
/// # .enable_http2()
/// # .build();
///
/// # let executor = hyper_util::rt::TokioExecutor::new();
/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// # secret,
/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # yup_oauth2::client::CustomHyperClientBuilder::from(
/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
/// # ),
/// # ).build().await.unwrap();
///
/// # let client = hyper_util::client::legacy::Client::builder(
/// # hyper_util::rt::TokioExecutor::new()
/// # )
/// # .build(
/// # hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_or_http()
/// # .enable_http2()
/// # .build()
/// # );
/// # let mut hub = YouTube::new(client, auth);
/// // As the method needs a request, you would usually fill it with the desired information
/// // into the 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("est".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("aliquyam")
/// .on_behalf_of_content_owner_channel("elitr")
/// .on_behalf_of_content_owner("duo")
/// .id("diam")
/// .doit().await;
/// # }
/// ```
pub struct LiveBroadcastInsertCuepointCall<'a, C>
where
C: 'a,
{
hub: &'a YouTube<C>,
_request: Cuepoint,
_part: Vec<String>,
_on_behalf_of_content_owner_channel: Option<String>,
_on_behalf_of_content_owner: Option<String>,
_id: Option<String>,
_delegate: Option<&'a mut dyn common::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>,
}
impl<'a, C> common::CallBuilder for LiveBroadcastInsertCuepointCall<'a, C> {}
impl<'a, C> LiveBroadcastInsertCuepointCall<'a, C>
where
C: common::Connector,
{
/// Perform the operation you have build so far.
pub async fn doit(mut self) -> common::Result<(common::Response, Cuepoint)> {
use std::borrow::Cow;
use std::io::{Read, Seek};
use common::{url::Params, ToParts};
use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
let mut dd = common::DefaultDelegate;
let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(common::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(common::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.is_empty() {
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 = serde_json::value::to_value(&self._request).expect("serde to work");
common::remove_json_null_values(&mut value);
let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
serde_json::to_writer(&mut dst, &value).unwrap();
dst
};
let request_size = request_value_reader
.seek(std::io::SeekFrom::End(0))
.unwrap();
request_value_reader
.seek(std::io::SeekFrom::Start(0))
.unwrap();
loop {
let token = match self
.hub
.auth
.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
.await
{
Ok(token) => token,
Err(e) => match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(common::Error::MissingToken(e));
}
},
};
request_value_reader
.seek(std::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(common::to_body(
request_value_reader.get_ref().clone().into(),
));
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let common::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(common::Error::HttpError(err));
}
Ok(res) => {
let (mut parts, body) = res.into_parts();
let mut body = common::Body::new(body);
if !parts.status.is_success() {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let error = serde_json::from_str(&common::to_string(&bytes));
let response = common::to_response(parts, bytes.into());
if let common::Retry::After(d) =
dlg.http_failure(&response, error.as_ref().ok())
{
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(match error {
Ok(value) => common::Error::BadRequest(value),
_ => common::Error::Failure(response),
});
}
let response = {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let encoded = common::to_string(&bytes);
match serde_json::from_str(&encoded) {
Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
Err(error) => {
dlg.response_json_decode_error(&encoded, &error);
return Err(common::Error::JsonDecodeError(
encoded.to_string(),
error,
));
}
}
};
dlg.finished(true);
return Ok(response);
}
}
}
}
///
/// Sets the *request* 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, C> {
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, C> {
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, C> {
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, C> {
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, C> {
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 common::Delegate,
) -> LiveBroadcastInsertCuepointCall<'a, C> {
self._delegate = Some(new_value);
self
}
/// Set any additional parameter of the query string used in the request.
/// It should be used to set parameters 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<T>(mut self, name: T, value: T) -> LiveBroadcastInsertCuepointCall<'a, C>
where
T: AsRef<str>,
{
self._additional_params
.insert(name.as_ref().to_string(), value.as_ref().to_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<St>(mut self, scope: St) -> LiveBroadcastInsertCuepointCall<'a, C>
where
St: AsRef<str>,
{
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<I, St>(mut self, scopes: I) -> LiveBroadcastInsertCuepointCall<'a, C>
where
I: IntoIterator<Item = St>,
St: AsRef<str>,
{
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, C> {
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 youtube3::{YouTube, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_only()
/// # .enable_http2()
/// # .build();
///
/// # let executor = hyper_util::rt::TokioExecutor::new();
/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// # secret,
/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # yup_oauth2::client::CustomHyperClientBuilder::from(
/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
/// # ),
/// # ).build().await.unwrap();
///
/// # let client = hyper_util::client::legacy::Client::builder(
/// # hyper_util::rt::TokioExecutor::new()
/// # )
/// # .build(
/// # hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_or_http()
/// # .enable_http2()
/// # .build()
/// # );
/// # let mut hub = YouTube::new(client, auth);
/// // You can configure optional parameters by calling 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!["est".into()])
/// .page_token("sit")
/// .on_behalf_of_content_owner_channel("sed")
/// .on_behalf_of_content_owner("eos")
/// .mine(true)
/// .max_results(84)
/// .add_id("Stet")
/// .broadcast_type("dolores")
/// .broadcast_status("eos")
/// .doit().await;
/// # }
/// ```
pub struct LiveBroadcastListCall<'a, C>
where
C: 'a,
{
hub: &'a YouTube<C>,
_part: Vec<String>,
_page_token: Option<String>,
_on_behalf_of_content_owner_channel: Option<String>,
_on_behalf_of_content_owner: Option<String>,
_mine: Option<bool>,
_max_results: Option<u32>,
_id: Vec<String>,
_broadcast_type: Option<String>,
_broadcast_status: Option<String>,
_delegate: Option<&'a mut dyn common::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>,
}
impl<'a, C> common::CallBuilder for LiveBroadcastListCall<'a, C> {}
impl<'a, C> LiveBroadcastListCall<'a, C>
where
C: common::Connector,
{
/// Perform the operation you have build so far.
pub async fn doit(mut self) -> common::Result<(common::Response, LiveBroadcastListResponse)> {
use std::borrow::Cow;
use std::io::{Read, Seek};
use common::{url::Params, ToParts};
use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
let mut dd = common::DefaultDelegate;
let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(common::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(common::Error::FieldClash(field));
}
}
let mut params = Params::with_capacity(11 + self._additional_params.len());
if !self._part.is_empty() {
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.is_empty() {
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::<Vec<_>>()[..])
.await
{
Ok(token) => token,
Err(e) => match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(common::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(common::to_body::<String>(None));
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let common::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(common::Error::HttpError(err));
}
Ok(res) => {
let (mut parts, body) = res.into_parts();
let mut body = common::Body::new(body);
if !parts.status.is_success() {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let error = serde_json::from_str(&common::to_string(&bytes));
let response = common::to_response(parts, bytes.into());
if let common::Retry::After(d) =
dlg.http_failure(&response, error.as_ref().ok())
{
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(match error {
Ok(value) => common::Error::BadRequest(value),
_ => common::Error::Failure(response),
});
}
let response = {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let encoded = common::to_string(&bytes);
match serde_json::from_str(&encoded) {
Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
Err(error) => {
dlg.response_json_decode_error(&encoded, &error);
return Err(common::Error::JsonDecodeError(
encoded.to_string(),
error,
));
}
}
};
dlg.finished(true);
return Ok(response);
}
}
}
}
/// 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, C> {
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, C> {
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, C> {
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, C> {
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, C> {
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, C> {
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, C> {
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: &str) -> LiveBroadcastListCall<'a, C> {
self._broadcast_type = Some(new_value.to_string());
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: &str) -> LiveBroadcastListCall<'a, C> {
self._broadcast_status = 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 common::Delegate,
) -> LiveBroadcastListCall<'a, C> {
self._delegate = Some(new_value);
self
}
/// Set any additional parameter of the query string used in the request.
/// It should be used to set parameters 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<T>(mut self, name: T, value: T) -> LiveBroadcastListCall<'a, C>
where
T: AsRef<str>,
{
self._additional_params
.insert(name.as_ref().to_string(), value.as_ref().to_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<St>(mut self, scope: St) -> LiveBroadcastListCall<'a, C>
where
St: AsRef<str>,
{
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<I, St>(mut self, scopes: I) -> LiveBroadcastListCall<'a, C>
where
I: IntoIterator<Item = St>,
St: AsRef<str>,
{
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, C> {
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 youtube3::{YouTube, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_only()
/// # .enable_http2()
/// # .build();
///
/// # let executor = hyper_util::rt::TokioExecutor::new();
/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// # secret,
/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # yup_oauth2::client::CustomHyperClientBuilder::from(
/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
/// # ),
/// # ).build().await.unwrap();
///
/// # let client = hyper_util::client::legacy::Client::builder(
/// # hyper_util::rt::TokioExecutor::new()
/// # )
/// # .build(
/// # hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_or_http()
/// # .enable_http2()
/// # .build()
/// # );
/// # let mut hub = YouTube::new(client, auth);
/// // You can configure optional parameters by calling 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("broadcastStatus", "id", &vec!["et".into()])
/// .on_behalf_of_content_owner_channel("At")
/// .on_behalf_of_content_owner("dolore")
/// .doit().await;
/// # }
/// ```
pub struct LiveBroadcastTransitionCall<'a, C>
where
C: 'a,
{
hub: &'a YouTube<C>,
_broadcast_status: String,
_id: String,
_part: Vec<String>,
_on_behalf_of_content_owner_channel: Option<String>,
_on_behalf_of_content_owner: Option<String>,
_delegate: Option<&'a mut dyn common::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>,
}
impl<'a, C> common::CallBuilder for LiveBroadcastTransitionCall<'a, C> {}
impl<'a, C> LiveBroadcastTransitionCall<'a, C>
where
C: common::Connector,
{
/// Perform the operation you have build so far.
pub async fn doit(mut self) -> common::Result<(common::Response, LiveBroadcast)> {
use std::borrow::Cow;
use std::io::{Read, Seek};
use common::{url::Params, ToParts};
use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
let mut dd = common::DefaultDelegate;
let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(common::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(common::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.is_empty() {
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::<Vec<_>>()[..])
.await
{
Ok(token) => token,
Err(e) => match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(common::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(common::to_body::<String>(None));
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let common::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(common::Error::HttpError(err));
}
Ok(res) => {
let (mut parts, body) = res.into_parts();
let mut body = common::Body::new(body);
if !parts.status.is_success() {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let error = serde_json::from_str(&common::to_string(&bytes));
let response = common::to_response(parts, bytes.into());
if let common::Retry::After(d) =
dlg.http_failure(&response, error.as_ref().ok())
{
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(match error {
Ok(value) => common::Error::BadRequest(value),
_ => common::Error::Failure(response),
});
}
let response = {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let encoded = common::to_string(&bytes);
match serde_json::from_str(&encoded) {
Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
Err(error) => {
dlg.response_json_decode_error(&encoded, &error);
return Err(common::Error::JsonDecodeError(
encoded.to_string(),
error,
));
}
}
};
dlg.finished(true);
return Ok(response);
}
}
}
}
/// 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: &str) -> LiveBroadcastTransitionCall<'a, C> {
self._broadcast_status = new_value.to_string();
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, C> {
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, C> {
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, C> {
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, C> {
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 common::Delegate,
) -> LiveBroadcastTransitionCall<'a, C> {
self._delegate = Some(new_value);
self
}
/// Set any additional parameter of the query string used in the request.
/// It should be used to set parameters 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<T>(mut self, name: T, value: T) -> LiveBroadcastTransitionCall<'a, C>
where
T: AsRef<str>,
{
self._additional_params
.insert(name.as_ref().to_string(), value.as_ref().to_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<St>(mut self, scope: St) -> LiveBroadcastTransitionCall<'a, C>
where
St: AsRef<str>,
{
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<I, St>(mut self, scopes: I) -> LiveBroadcastTransitionCall<'a, C>
where
I: IntoIterator<Item = St>,
St: AsRef<str>,
{
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, C> {
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 youtube3::{YouTube, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_only()
/// # .enable_http2()
/// # .build();
///
/// # let executor = hyper_util::rt::TokioExecutor::new();
/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// # secret,
/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # yup_oauth2::client::CustomHyperClientBuilder::from(
/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
/// # ),
/// # ).build().await.unwrap();
///
/// # let client = hyper_util::client::legacy::Client::builder(
/// # hyper_util::rt::TokioExecutor::new()
/// # )
/// # .build(
/// # hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_or_http()
/// # .enable_http2()
/// # .build()
/// # );
/// # let mut hub = YouTube::new(client, auth);
/// // As the method needs a request, you would usually fill it with the desired information
/// // into the 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("eirmod".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("Lorem")
/// .on_behalf_of_content_owner("accusam")
/// .doit().await;
/// # }
/// ```
pub struct LiveBroadcastUpdateCall<'a, C>
where
C: 'a,
{
hub: &'a YouTube<C>,
_request: LiveBroadcast,
_part: Vec<String>,
_on_behalf_of_content_owner_channel: Option<String>,
_on_behalf_of_content_owner: Option<String>,
_delegate: Option<&'a mut dyn common::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>,
}
impl<'a, C> common::CallBuilder for LiveBroadcastUpdateCall<'a, C> {}
impl<'a, C> LiveBroadcastUpdateCall<'a, C>
where
C: common::Connector,
{
/// Perform the operation you have build so far.
pub async fn doit(mut self) -> common::Result<(common::Response, LiveBroadcast)> {
use std::borrow::Cow;
use std::io::{Read, Seek};
use common::{url::Params, ToParts};
use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
let mut dd = common::DefaultDelegate;
let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(common::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(common::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.is_empty() {
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 = serde_json::value::to_value(&self._request).expect("serde to work");
common::remove_json_null_values(&mut value);
let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
serde_json::to_writer(&mut dst, &value).unwrap();
dst
};
let request_size = request_value_reader
.seek(std::io::SeekFrom::End(0))
.unwrap();
request_value_reader
.seek(std::io::SeekFrom::Start(0))
.unwrap();
loop {
let token = match self
.hub
.auth
.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
.await
{
Ok(token) => token,
Err(e) => match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(common::Error::MissingToken(e));
}
},
};
request_value_reader
.seek(std::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(common::to_body(
request_value_reader.get_ref().clone().into(),
));
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let common::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(common::Error::HttpError(err));
}
Ok(res) => {
let (mut parts, body) = res.into_parts();
let mut body = common::Body::new(body);
if !parts.status.is_success() {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let error = serde_json::from_str(&common::to_string(&bytes));
let response = common::to_response(parts, bytes.into());
if let common::Retry::After(d) =
dlg.http_failure(&response, error.as_ref().ok())
{
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(match error {
Ok(value) => common::Error::BadRequest(value),
_ => common::Error::Failure(response),
});
}
let response = {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let encoded = common::to_string(&bytes);
match serde_json::from_str(&encoded) {
Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
Err(error) => {
dlg.response_json_decode_error(&encoded, &error);
return Err(common::Error::JsonDecodeError(
encoded.to_string(),
error,
));
}
}
};
dlg.finished(true);
return Ok(response);
}
}
}
}
///
/// Sets the *request* 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, C> {
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, C> {
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, C> {
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, C> {
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 common::Delegate,
) -> LiveBroadcastUpdateCall<'a, C> {
self._delegate = Some(new_value);
self
}
/// Set any additional parameter of the query string used in the request.
/// It should be used to set parameters 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<T>(mut self, name: T, value: T) -> LiveBroadcastUpdateCall<'a, C>
where
T: AsRef<str>,
{
self._additional_params
.insert(name.as_ref().to_string(), value.as_ref().to_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<St>(mut self, scope: St) -> LiveBroadcastUpdateCall<'a, C>
where
St: AsRef<str>,
{
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<I, St>(mut self, scopes: I) -> LiveBroadcastUpdateCall<'a, C>
where
I: IntoIterator<Item = St>,
St: AsRef<str>,
{
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, C> {
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 youtube3::{YouTube, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_only()
/// # .enable_http2()
/// # .build();
///
/// # let executor = hyper_util::rt::TokioExecutor::new();
/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// # secret,
/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # yup_oauth2::client::CustomHyperClientBuilder::from(
/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
/// # ),
/// # ).build().await.unwrap();
///
/// # let client = hyper_util::client::legacy::Client::builder(
/// # hyper_util::rt::TokioExecutor::new()
/// # )
/// # .build(
/// # hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_or_http()
/// # .enable_http2()
/// # .build()
/// # );
/// # let mut hub = YouTube::new(client, auth);
/// // You can configure optional parameters by calling 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, C>
where
C: 'a,
{
hub: &'a YouTube<C>,
_id: String,
_delegate: Option<&'a mut dyn common::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>,
}
impl<'a, C> common::CallBuilder for LiveChatBanDeleteCall<'a, C> {}
impl<'a, C> LiveChatBanDeleteCall<'a, C>
where
C: common::Connector,
{
/// Perform the operation you have build so far.
pub async fn doit(mut self) -> common::Result<common::Response> {
use std::borrow::Cow;
use std::io::{Read, Seek};
use common::{url::Params, ToParts};
use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
let mut dd = common::DefaultDelegate;
let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(common::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(common::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::<Vec<_>>()[..])
.await
{
Ok(token) => token,
Err(e) => match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(common::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(common::to_body::<String>(None));
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let common::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(common::Error::HttpError(err));
}
Ok(res) => {
let (mut parts, body) = res.into_parts();
let mut body = common::Body::new(body);
if !parts.status.is_success() {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let error = serde_json::from_str(&common::to_string(&bytes));
let response = common::to_response(parts, bytes.into());
if let common::Retry::After(d) =
dlg.http_failure(&response, error.as_ref().ok())
{
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(match error {
Ok(value) => common::Error::BadRequest(value),
_ => common::Error::Failure(response),
});
}
let response = common::Response::from_parts(parts, body);
dlg.finished(true);
return Ok(response);
}
}
}
}
///
/// 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, C> {
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 common::Delegate,
) -> LiveChatBanDeleteCall<'a, C> {
self._delegate = Some(new_value);
self
}
/// Set any additional parameter of the query string used in the request.
/// It should be used to set parameters 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<T>(mut self, name: T, value: T) -> LiveChatBanDeleteCall<'a, C>
where
T: AsRef<str>,
{
self._additional_params
.insert(name.as_ref().to_string(), value.as_ref().to_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<St>(mut self, scope: St) -> LiveChatBanDeleteCall<'a, C>
where
St: AsRef<str>,
{
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<I, St>(mut self, scopes: I) -> LiveChatBanDeleteCall<'a, C>
where
I: IntoIterator<Item = St>,
St: AsRef<str>,
{
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, C> {
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 youtube3::{YouTube, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_only()
/// # .enable_http2()
/// # .build();
///
/// # let executor = hyper_util::rt::TokioExecutor::new();
/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// # secret,
/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # yup_oauth2::client::CustomHyperClientBuilder::from(
/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
/// # ),
/// # ).build().await.unwrap();
///
/// # let client = hyper_util::client::legacy::Client::builder(
/// # hyper_util::rt::TokioExecutor::new()
/// # )
/// # .build(
/// # hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_or_http()
/// # .enable_http2()
/// # .build()
/// # );
/// # let mut hub = YouTube::new(client, auth);
/// // As the method needs a request, you would usually fill it with the desired information
/// // into the 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, C>
where
C: 'a,
{
hub: &'a YouTube<C>,
_request: LiveChatBan,
_part: Vec<String>,
_delegate: Option<&'a mut dyn common::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>,
}
impl<'a, C> common::CallBuilder for LiveChatBanInsertCall<'a, C> {}
impl<'a, C> LiveChatBanInsertCall<'a, C>
where
C: common::Connector,
{
/// Perform the operation you have build so far.
pub async fn doit(mut self) -> common::Result<(common::Response, LiveChatBan)> {
use std::borrow::Cow;
use std::io::{Read, Seek};
use common::{url::Params, ToParts};
use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
let mut dd = common::DefaultDelegate;
let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(common::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(common::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.is_empty() {
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 = serde_json::value::to_value(&self._request).expect("serde to work");
common::remove_json_null_values(&mut value);
let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
serde_json::to_writer(&mut dst, &value).unwrap();
dst
};
let request_size = request_value_reader
.seek(std::io::SeekFrom::End(0))
.unwrap();
request_value_reader
.seek(std::io::SeekFrom::Start(0))
.unwrap();
loop {
let token = match self
.hub
.auth
.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
.await
{
Ok(token) => token,
Err(e) => match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(common::Error::MissingToken(e));
}
},
};
request_value_reader
.seek(std::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(common::to_body(
request_value_reader.get_ref().clone().into(),
));
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let common::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(common::Error::HttpError(err));
}
Ok(res) => {
let (mut parts, body) = res.into_parts();
let mut body = common::Body::new(body);
if !parts.status.is_success() {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let error = serde_json::from_str(&common::to_string(&bytes));
let response = common::to_response(parts, bytes.into());
if let common::Retry::After(d) =
dlg.http_failure(&response, error.as_ref().ok())
{
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(match error {
Ok(value) => common::Error::BadRequest(value),
_ => common::Error::Failure(response),
});
}
let response = {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let encoded = common::to_string(&bytes);
match serde_json::from_str(&encoded) {
Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
Err(error) => {
dlg.response_json_decode_error(&encoded, &error);
return Err(common::Error::JsonDecodeError(
encoded.to_string(),
error,
));
}
}
};
dlg.finished(true);
return Ok(response);
}
}
}
}
///
/// Sets the *request* property to the given value.
///
/// Even though 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, C> {
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, C> {
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 common::Delegate,
) -> LiveChatBanInsertCall<'a, C> {
self._delegate = Some(new_value);
self
}
/// Set any additional parameter of the query string used in the request.
/// It should be used to set parameters 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<T>(mut self, name: T, value: T) -> LiveChatBanInsertCall<'a, C>
where
T: AsRef<str>,
{
self._additional_params
.insert(name.as_ref().to_string(), value.as_ref().to_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<St>(mut self, scope: St) -> LiveChatBanInsertCall<'a, C>
where
St: AsRef<str>,
{
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<I, St>(mut self, scopes: I) -> LiveChatBanInsertCall<'a, C>
where
I: IntoIterator<Item = St>,
St: AsRef<str>,
{
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, C> {
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 youtube3::{YouTube, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_only()
/// # .enable_http2()
/// # .build();
///
/// # let executor = hyper_util::rt::TokioExecutor::new();
/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// # secret,
/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # yup_oauth2::client::CustomHyperClientBuilder::from(
/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
/// # ),
/// # ).build().await.unwrap();
///
/// # let client = hyper_util::client::legacy::Client::builder(
/// # hyper_util::rt::TokioExecutor::new()
/// # )
/// # .build(
/// # hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_or_http()
/// # .enable_http2()
/// # .build()
/// # );
/// # let mut hub = YouTube::new(client, auth);
/// // You can configure optional parameters by calling 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, C>
where
C: 'a,
{
hub: &'a YouTube<C>,
_id: String,
_delegate: Option<&'a mut dyn common::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>,
}
impl<'a, C> common::CallBuilder for LiveChatMessageDeleteCall<'a, C> {}
impl<'a, C> LiveChatMessageDeleteCall<'a, C>
where
C: common::Connector,
{
/// Perform the operation you have build so far.
pub async fn doit(mut self) -> common::Result<common::Response> {
use std::borrow::Cow;
use std::io::{Read, Seek};
use common::{url::Params, ToParts};
use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
let mut dd = common::DefaultDelegate;
let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(common::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(common::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::<Vec<_>>()[..])
.await
{
Ok(token) => token,
Err(e) => match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(common::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(common::to_body::<String>(None));
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let common::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(common::Error::HttpError(err));
}
Ok(res) => {
let (mut parts, body) = res.into_parts();
let mut body = common::Body::new(body);
if !parts.status.is_success() {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let error = serde_json::from_str(&common::to_string(&bytes));
let response = common::to_response(parts, bytes.into());
if let common::Retry::After(d) =
dlg.http_failure(&response, error.as_ref().ok())
{
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(match error {
Ok(value) => common::Error::BadRequest(value),
_ => common::Error::Failure(response),
});
}
let response = common::Response::from_parts(parts, body);
dlg.finished(true);
return Ok(response);
}
}
}
}
///
/// 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, C> {
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 common::Delegate,
) -> LiveChatMessageDeleteCall<'a, C> {
self._delegate = Some(new_value);
self
}
/// Set any additional parameter of the query string used in the request.
/// It should be used to set parameters 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<T>(mut self, name: T, value: T) -> LiveChatMessageDeleteCall<'a, C>
where
T: AsRef<str>,
{
self._additional_params
.insert(name.as_ref().to_string(), value.as_ref().to_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<St>(mut self, scope: St) -> LiveChatMessageDeleteCall<'a, C>
where
St: AsRef<str>,
{
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<I, St>(mut self, scopes: I) -> LiveChatMessageDeleteCall<'a, C>
where
I: IntoIterator<Item = St>,
St: AsRef<str>,
{
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, C> {
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 youtube3::{YouTube, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_only()
/// # .enable_http2()
/// # .build();
///
/// # let executor = hyper_util::rt::TokioExecutor::new();
/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// # secret,
/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # yup_oauth2::client::CustomHyperClientBuilder::from(
/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
/// # ),
/// # ).build().await.unwrap();
///
/// # let client = hyper_util::client::legacy::Client::builder(
/// # hyper_util::rt::TokioExecutor::new()
/// # )
/// # .build(
/// # hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_or_http()
/// # .enable_http2()
/// # .build()
/// # );
/// # let mut hub = YouTube::new(client, auth);
/// // As the method needs a request, you would usually fill it with the desired information
/// // into the 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, C>
where
C: 'a,
{
hub: &'a YouTube<C>,
_request: LiveChatMessage,
_part: Vec<String>,
_delegate: Option<&'a mut dyn common::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>,
}
impl<'a, C> common::CallBuilder for LiveChatMessageInsertCall<'a, C> {}
impl<'a, C> LiveChatMessageInsertCall<'a, C>
where
C: common::Connector,
{
/// Perform the operation you have build so far.
pub async fn doit(mut self) -> common::Result<(common::Response, LiveChatMessage)> {
use std::borrow::Cow;
use std::io::{Read, Seek};
use common::{url::Params, ToParts};
use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
let mut dd = common::DefaultDelegate;
let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(common::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(common::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.is_empty() {
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 = serde_json::value::to_value(&self._request).expect("serde to work");
common::remove_json_null_values(&mut value);
let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
serde_json::to_writer(&mut dst, &value).unwrap();
dst
};
let request_size = request_value_reader
.seek(std::io::SeekFrom::End(0))
.unwrap();
request_value_reader
.seek(std::io::SeekFrom::Start(0))
.unwrap();
loop {
let token = match self
.hub
.auth
.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
.await
{
Ok(token) => token,
Err(e) => match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(common::Error::MissingToken(e));
}
},
};
request_value_reader
.seek(std::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(common::to_body(
request_value_reader.get_ref().clone().into(),
));
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let common::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(common::Error::HttpError(err));
}
Ok(res) => {
let (mut parts, body) = res.into_parts();
let mut body = common::Body::new(body);
if !parts.status.is_success() {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let error = serde_json::from_str(&common::to_string(&bytes));
let response = common::to_response(parts, bytes.into());
if let common::Retry::After(d) =
dlg.http_failure(&response, error.as_ref().ok())
{
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(match error {
Ok(value) => common::Error::BadRequest(value),
_ => common::Error::Failure(response),
});
}
let response = {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let encoded = common::to_string(&bytes);
match serde_json::from_str(&encoded) {
Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
Err(error) => {
dlg.response_json_decode_error(&encoded, &error);
return Err(common::Error::JsonDecodeError(
encoded.to_string(),
error,
));
}
}
};
dlg.finished(true);
return Ok(response);
}
}
}
}
///
/// Sets the *request* property to the given value.
///
/// Even though 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, C> {
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, C> {
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 common::Delegate,
) -> LiveChatMessageInsertCall<'a, C> {
self._delegate = Some(new_value);
self
}
/// Set any additional parameter of the query string used in the request.
/// It should be used to set parameters 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<T>(mut self, name: T, value: T) -> LiveChatMessageInsertCall<'a, C>
where
T: AsRef<str>,
{
self._additional_params
.insert(name.as_ref().to_string(), value.as_ref().to_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<St>(mut self, scope: St) -> LiveChatMessageInsertCall<'a, C>
where
St: AsRef<str>,
{
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<I, St>(mut self, scopes: I) -> LiveChatMessageInsertCall<'a, C>
where
I: IntoIterator<Item = St>,
St: AsRef<str>,
{
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, C> {
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*
/// * *authorDetails*
///
/// # 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 youtube3::{YouTube, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_only()
/// # .enable_http2()
/// # .build();
///
/// # let executor = hyper_util::rt::TokioExecutor::new();
/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// # secret,
/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # yup_oauth2::client::CustomHyperClientBuilder::from(
/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
/// # ),
/// # ).build().await.unwrap();
///
/// # let client = hyper_util::client::legacy::Client::builder(
/// # hyper_util::rt::TokioExecutor::new()
/// # )
/// # .build(
/// # hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_or_http()
/// # .enable_http2()
/// # .build()
/// # );
/// # let mut hub = YouTube::new(client, auth);
/// // You can configure optional parameters by calling 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!["erat".into()])
/// .profile_image_size(28)
/// .page_token("sea")
/// .max_results(42)
/// .hl("Lorem")
/// .doit().await;
/// # }
/// ```
pub struct LiveChatMessageListCall<'a, C>
where
C: 'a,
{
hub: &'a YouTube<C>,
_live_chat_id: String,
_part: Vec<String>,
_profile_image_size: Option<u32>,
_page_token: Option<String>,
_max_results: Option<u32>,
_hl: Option<String>,
_delegate: Option<&'a mut dyn common::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>,
}
impl<'a, C> common::CallBuilder for LiveChatMessageListCall<'a, C> {}
impl<'a, C> LiveChatMessageListCall<'a, C>
where
C: common::Connector,
{
/// Perform the operation you have build so far.
pub async fn doit(mut self) -> common::Result<(common::Response, LiveChatMessageListResponse)> {
use std::borrow::Cow;
use std::io::{Read, Seek};
use common::{url::Params, ToParts};
use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
let mut dd = common::DefaultDelegate;
let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(common::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(common::Error::FieldClash(field));
}
}
let mut params = Params::with_capacity(8 + self._additional_params.len());
params.push("liveChatId", self._live_chat_id);
if !self._part.is_empty() {
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::<Vec<_>>()[..])
.await
{
Ok(token) => token,
Err(e) => match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(common::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(common::to_body::<String>(None));
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let common::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(common::Error::HttpError(err));
}
Ok(res) => {
let (mut parts, body) = res.into_parts();
let mut body = common::Body::new(body);
if !parts.status.is_success() {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let error = serde_json::from_str(&common::to_string(&bytes));
let response = common::to_response(parts, bytes.into());
if let common::Retry::After(d) =
dlg.http_failure(&response, error.as_ref().ok())
{
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(match error {
Ok(value) => common::Error::BadRequest(value),
_ => common::Error::Failure(response),
});
}
let response = {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let encoded = common::to_string(&bytes);
match serde_json::from_str(&encoded) {
Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
Err(error) => {
dlg.response_json_decode_error(&encoded, &error);
return Err(common::Error::JsonDecodeError(
encoded.to_string(),
error,
));
}
}
};
dlg.finished(true);
return Ok(response);
}
}
}
}
/// 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, C> {
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, snippet, and authorDetails.
///
/// 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*
/// * *authorDetails*
pub fn add_part(mut self, new_value: &str) -> LiveChatMessageListCall<'a, C> {
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, C> {
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, C> {
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. Not used in the streaming RPC.
///
/// Sets the *max results* query property to the given value.
pub fn max_results(mut self, new_value: u32) -> LiveChatMessageListCall<'a, C> {
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, C> {
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 common::Delegate,
) -> LiveChatMessageListCall<'a, C> {
self._delegate = Some(new_value);
self
}
/// Set any additional parameter of the query string used in the request.
/// It should be used to set parameters 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<T>(mut self, name: T, value: T) -> LiveChatMessageListCall<'a, C>
where
T: AsRef<str>,
{
self._additional_params
.insert(name.as_ref().to_string(), value.as_ref().to_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<St>(mut self, scope: St) -> LiveChatMessageListCall<'a, C>
where
St: AsRef<str>,
{
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<I, St>(mut self, scopes: I) -> LiveChatMessageListCall<'a, C>
where
I: IntoIterator<Item = St>,
St: AsRef<str>,
{
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, C> {
self._scopes.clear();
self
}
}
/// Transition a durable chat event.
///
/// A builder for the *transition* 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 youtube3::{YouTube, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_only()
/// # .enable_http2()
/// # .build();
///
/// # let executor = hyper_util::rt::TokioExecutor::new();
/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// # secret,
/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # yup_oauth2::client::CustomHyperClientBuilder::from(
/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
/// # ),
/// # ).build().await.unwrap();
///
/// # let client = hyper_util::client::legacy::Client::builder(
/// # hyper_util::rt::TokioExecutor::new()
/// # )
/// # .build(
/// # hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_or_http()
/// # .enable_http2()
/// # .build()
/// # );
/// # let mut hub = YouTube::new(client, auth);
/// // You can configure optional parameters by calling 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().transition()
/// .status("et")
/// .id("At")
/// .doit().await;
/// # }
/// ```
pub struct LiveChatMessageTransitionCall<'a, C>
where
C: 'a,
{
hub: &'a YouTube<C>,
_status: Option<String>,
_id: Option<String>,
_delegate: Option<&'a mut dyn common::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>,
}
impl<'a, C> common::CallBuilder for LiveChatMessageTransitionCall<'a, C> {}
impl<'a, C> LiveChatMessageTransitionCall<'a, C>
where
C: common::Connector,
{
/// Perform the operation you have build so far.
pub async fn doit(mut self) -> common::Result<(common::Response, LiveChatMessage)> {
use std::borrow::Cow;
use std::io::{Read, Seek};
use common::{url::Params, ToParts};
use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
let mut dd = common::DefaultDelegate;
let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(common::MethodInfo {
id: "youtube.liveChatMessages.transition",
http_method: hyper::Method::POST,
});
for &field in ["alt", "status", "id"].iter() {
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Err(common::Error::FieldClash(field));
}
}
let mut params = Params::with_capacity(4 + self._additional_params.len());
if let Some(value) = self._status.as_ref() {
params.push("status", 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/liveChat/messages/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::<Vec<_>>()[..])
.await
{
Ok(token) => token,
Err(e) => match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(common::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(common::to_body::<String>(None));
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let common::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(common::Error::HttpError(err));
}
Ok(res) => {
let (mut parts, body) = res.into_parts();
let mut body = common::Body::new(body);
if !parts.status.is_success() {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let error = serde_json::from_str(&common::to_string(&bytes));
let response = common::to_response(parts, bytes.into());
if let common::Retry::After(d) =
dlg.http_failure(&response, error.as_ref().ok())
{
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(match error {
Ok(value) => common::Error::BadRequest(value),
_ => common::Error::Failure(response),
});
}
let response = {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let encoded = common::to_string(&bytes);
match serde_json::from_str(&encoded) {
Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
Err(error) => {
dlg.response_json_decode_error(&encoded, &error);
return Err(common::Error::JsonDecodeError(
encoded.to_string(),
error,
));
}
}
};
dlg.finished(true);
return Ok(response);
}
}
}
}
/// The status to which the chat event is going to transition.
///
/// Sets the *status* query property to the given value.
pub fn status(mut self, new_value: &str) -> LiveChatMessageTransitionCall<'a, C> {
self._status = Some(new_value.to_string());
self
}
/// The ID that uniquely identify the chat message event to transition.
///
/// Sets the *id* query property to the given value.
pub fn id(mut self, new_value: &str) -> LiveChatMessageTransitionCall<'a, C> {
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 common::Delegate,
) -> LiveChatMessageTransitionCall<'a, C> {
self._delegate = Some(new_value);
self
}
/// Set any additional parameter of the query string used in the request.
/// It should be used to set parameters 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<T>(mut self, name: T, value: T) -> LiveChatMessageTransitionCall<'a, C>
where
T: AsRef<str>,
{
self._additional_params
.insert(name.as_ref().to_string(), value.as_ref().to_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<St>(mut self, scope: St) -> LiveChatMessageTransitionCall<'a, C>
where
St: AsRef<str>,
{
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<I, St>(mut self, scopes: I) -> LiveChatMessageTransitionCall<'a, C>
where
I: IntoIterator<Item = St>,
St: AsRef<str>,
{
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) -> LiveChatMessageTransitionCall<'a, C> {
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 youtube3::{YouTube, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_only()
/// # .enable_http2()
/// # .build();
///
/// # let executor = hyper_util::rt::TokioExecutor::new();
/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// # secret,
/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # yup_oauth2::client::CustomHyperClientBuilder::from(
/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
/// # ),
/// # ).build().await.unwrap();
///
/// # let client = hyper_util::client::legacy::Client::builder(
/// # hyper_util::rt::TokioExecutor::new()
/// # )
/// # .build(
/// # hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_or_http()
/// # .enable_http2()
/// # .build()
/// # );
/// # let mut hub = YouTube::new(client, auth);
/// // You can configure optional parameters by calling 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, C>
where
C: 'a,
{
hub: &'a YouTube<C>,
_id: String,
_delegate: Option<&'a mut dyn common::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>,
}
impl<'a, C> common::CallBuilder for LiveChatModeratorDeleteCall<'a, C> {}
impl<'a, C> LiveChatModeratorDeleteCall<'a, C>
where
C: common::Connector,
{
/// Perform the operation you have build so far.
pub async fn doit(mut self) -> common::Result<common::Response> {
use std::borrow::Cow;
use std::io::{Read, Seek};
use common::{url::Params, ToParts};
use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
let mut dd = common::DefaultDelegate;
let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(common::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(common::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::<Vec<_>>()[..])
.await
{
Ok(token) => token,
Err(e) => match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(common::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(common::to_body::<String>(None));
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let common::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(common::Error::HttpError(err));
}
Ok(res) => {
let (mut parts, body) = res.into_parts();
let mut body = common::Body::new(body);
if !parts.status.is_success() {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let error = serde_json::from_str(&common::to_string(&bytes));
let response = common::to_response(parts, bytes.into());
if let common::Retry::After(d) =
dlg.http_failure(&response, error.as_ref().ok())
{
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(match error {
Ok(value) => common::Error::BadRequest(value),
_ => common::Error::Failure(response),
});
}
let response = common::Response::from_parts(parts, body);
dlg.finished(true);
return Ok(response);
}
}
}
}
///
/// 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, C> {
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 common::Delegate,
) -> LiveChatModeratorDeleteCall<'a, C> {
self._delegate = Some(new_value);
self
}
/// Set any additional parameter of the query string used in the request.
/// It should be used to set parameters 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<T>(mut self, name: T, value: T) -> LiveChatModeratorDeleteCall<'a, C>
where
T: AsRef<str>,
{
self._additional_params
.insert(name.as_ref().to_string(), value.as_ref().to_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<St>(mut self, scope: St) -> LiveChatModeratorDeleteCall<'a, C>
where
St: AsRef<str>,
{
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<I, St>(mut self, scopes: I) -> LiveChatModeratorDeleteCall<'a, C>
where
I: IntoIterator<Item = St>,
St: AsRef<str>,
{
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, C> {
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 youtube3::{YouTube, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_only()
/// # .enable_http2()
/// # .build();
///
/// # let executor = hyper_util::rt::TokioExecutor::new();
/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// # secret,
/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # yup_oauth2::client::CustomHyperClientBuilder::from(
/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
/// # ),
/// # ).build().await.unwrap();
///
/// # let client = hyper_util::client::legacy::Client::builder(
/// # hyper_util::rt::TokioExecutor::new()
/// # )
/// # .build(
/// # hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_or_http()
/// # .enable_http2()
/// # .build()
/// # );
/// # let mut hub = YouTube::new(client, auth);
/// // As the method needs a request, you would usually fill it with the desired information
/// // into the 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, C>
where
C: 'a,
{
hub: &'a YouTube<C>,
_request: LiveChatModerator,
_part: Vec<String>,
_delegate: Option<&'a mut dyn common::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>,
}
impl<'a, C> common::CallBuilder for LiveChatModeratorInsertCall<'a, C> {}
impl<'a, C> LiveChatModeratorInsertCall<'a, C>
where
C: common::Connector,
{
/// Perform the operation you have build so far.
pub async fn doit(mut self) -> common::Result<(common::Response, LiveChatModerator)> {
use std::borrow::Cow;
use std::io::{Read, Seek};
use common::{url::Params, ToParts};
use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
let mut dd = common::DefaultDelegate;
let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(common::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(common::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.is_empty() {
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 = serde_json::value::to_value(&self._request).expect("serde to work");
common::remove_json_null_values(&mut value);
let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
serde_json::to_writer(&mut dst, &value).unwrap();
dst
};
let request_size = request_value_reader
.seek(std::io::SeekFrom::End(0))
.unwrap();
request_value_reader
.seek(std::io::SeekFrom::Start(0))
.unwrap();
loop {
let token = match self
.hub
.auth
.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
.await
{
Ok(token) => token,
Err(e) => match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(common::Error::MissingToken(e));
}
},
};
request_value_reader
.seek(std::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(common::to_body(
request_value_reader.get_ref().clone().into(),
));
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let common::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(common::Error::HttpError(err));
}
Ok(res) => {
let (mut parts, body) = res.into_parts();
let mut body = common::Body::new(body);
if !parts.status.is_success() {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let error = serde_json::from_str(&common::to_string(&bytes));
let response = common::to_response(parts, bytes.into());
if let common::Retry::After(d) =
dlg.http_failure(&response, error.as_ref().ok())
{
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(match error {
Ok(value) => common::Error::BadRequest(value),
_ => common::Error::Failure(response),
});
}
let response = {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let encoded = common::to_string(&bytes);
match serde_json::from_str(&encoded) {
Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
Err(error) => {
dlg.response_json_decode_error(&encoded, &error);
return Err(common::Error::JsonDecodeError(
encoded.to_string(),
error,
));
}
}
};
dlg.finished(true);
return Ok(response);
}
}
}
}
///
/// Sets the *request* property to the given value.
///
/// Even though 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, C> {
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, C> {
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 common::Delegate,
) -> LiveChatModeratorInsertCall<'a, C> {
self._delegate = Some(new_value);
self
}
/// Set any additional parameter of the query string used in the request.
/// It should be used to set parameters 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<T>(mut self, name: T, value: T) -> LiveChatModeratorInsertCall<'a, C>
where
T: AsRef<str>,
{
self._additional_params
.insert(name.as_ref().to_string(), value.as_ref().to_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<St>(mut self, scope: St) -> LiveChatModeratorInsertCall<'a, C>
where
St: AsRef<str>,
{
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<I, St>(mut self, scopes: I) -> LiveChatModeratorInsertCall<'a, C>
where
I: IntoIterator<Item = St>,
St: AsRef<str>,
{
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, C> {
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 youtube3::{YouTube, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_only()
/// # .enable_http2()
/// # .build();
///
/// # let executor = hyper_util::rt::TokioExecutor::new();
/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// # secret,
/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # yup_oauth2::client::CustomHyperClientBuilder::from(
/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
/// # ),
/// # ).build().await.unwrap();
///
/// # let client = hyper_util::client::legacy::Client::builder(
/// # hyper_util::rt::TokioExecutor::new()
/// # )
/// # .build(
/// # hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_or_http()
/// # .enable_http2()
/// # .build()
/// # );
/// # let mut hub = YouTube::new(client, auth);
/// // You can configure optional parameters by calling 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!["sit".into()])
/// .page_token("erat")
/// .max_results(91)
/// .doit().await;
/// # }
/// ```
pub struct LiveChatModeratorListCall<'a, C>
where
C: 'a,
{
hub: &'a YouTube<C>,
_live_chat_id: String,
_part: Vec<String>,
_page_token: Option<String>,
_max_results: Option<u32>,
_delegate: Option<&'a mut dyn common::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>,
}
impl<'a, C> common::CallBuilder for LiveChatModeratorListCall<'a, C> {}
impl<'a, C> LiveChatModeratorListCall<'a, C>
where
C: common::Connector,
{
/// Perform the operation you have build so far.
pub async fn doit(
mut self,
) -> common::Result<(common::Response, LiveChatModeratorListResponse)> {
use std::borrow::Cow;
use std::io::{Read, Seek};
use common::{url::Params, ToParts};
use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
let mut dd = common::DefaultDelegate;
let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(common::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(common::Error::FieldClash(field));
}
}
let mut params = Params::with_capacity(6 + self._additional_params.len());
params.push("liveChatId", self._live_chat_id);
if !self._part.is_empty() {
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::<Vec<_>>()[..])
.await
{
Ok(token) => token,
Err(e) => match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(common::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(common::to_body::<String>(None));
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let common::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(common::Error::HttpError(err));
}
Ok(res) => {
let (mut parts, body) = res.into_parts();
let mut body = common::Body::new(body);
if !parts.status.is_success() {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let error = serde_json::from_str(&common::to_string(&bytes));
let response = common::to_response(parts, bytes.into());
if let common::Retry::After(d) =
dlg.http_failure(&response, error.as_ref().ok())
{
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(match error {
Ok(value) => common::Error::BadRequest(value),
_ => common::Error::Failure(response),
});
}
let response = {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let encoded = common::to_string(&bytes);
match serde_json::from_str(&encoded) {
Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
Err(error) => {
dlg.response_json_decode_error(&encoded, &error);
return Err(common::Error::JsonDecodeError(
encoded.to_string(),
error,
));
}
}
};
dlg.finished(true);
return Ok(response);
}
}
}
}
/// 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, C> {
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, C> {
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, C> {
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, C> {
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 common::Delegate,
) -> LiveChatModeratorListCall<'a, C> {
self._delegate = Some(new_value);
self
}
/// Set any additional parameter of the query string used in the request.
/// It should be used to set parameters 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<T>(mut self, name: T, value: T) -> LiveChatModeratorListCall<'a, C>
where
T: AsRef<str>,
{
self._additional_params
.insert(name.as_ref().to_string(), value.as_ref().to_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<St>(mut self, scope: St) -> LiveChatModeratorListCall<'a, C>
where
St: AsRef<str>,
{
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<I, St>(mut self, scopes: I) -> LiveChatModeratorListCall<'a, C>
where
I: IntoIterator<Item = St>,
St: AsRef<str>,
{
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, C> {
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 youtube3::{YouTube, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_only()
/// # .enable_http2()
/// # .build();
///
/// # let executor = hyper_util::rt::TokioExecutor::new();
/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// # secret,
/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # yup_oauth2::client::CustomHyperClientBuilder::from(
/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
/// # ),
/// # ).build().await.unwrap();
///
/// # let client = hyper_util::client::legacy::Client::builder(
/// # hyper_util::rt::TokioExecutor::new()
/// # )
/// # .build(
/// # hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_or_http()
/// # .enable_http2()
/// # .build()
/// # );
/// # let mut hub = YouTube::new(client, auth);
/// // You can configure optional parameters by calling 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("et")
/// .on_behalf_of_content_owner("gubergren")
/// .doit().await;
/// # }
/// ```
pub struct LiveStreamDeleteCall<'a, C>
where
C: 'a,
{
hub: &'a YouTube<C>,
_id: String,
_on_behalf_of_content_owner_channel: Option<String>,
_on_behalf_of_content_owner: Option<String>,
_delegate: Option<&'a mut dyn common::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>,
}
impl<'a, C> common::CallBuilder for LiveStreamDeleteCall<'a, C> {}
impl<'a, C> LiveStreamDeleteCall<'a, C>
where
C: common::Connector,
{
/// Perform the operation you have build so far.
pub async fn doit(mut self) -> common::Result<common::Response> {
use std::borrow::Cow;
use std::io::{Read, Seek};
use common::{url::Params, ToParts};
use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
let mut dd = common::DefaultDelegate;
let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(common::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(common::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::<Vec<_>>()[..])
.await
{
Ok(token) => token,
Err(e) => match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(common::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(common::to_body::<String>(None));
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let common::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(common::Error::HttpError(err));
}
Ok(res) => {
let (mut parts, body) = res.into_parts();
let mut body = common::Body::new(body);
if !parts.status.is_success() {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let error = serde_json::from_str(&common::to_string(&bytes));
let response = common::to_response(parts, bytes.into());
if let common::Retry::After(d) =
dlg.http_failure(&response, error.as_ref().ok())
{
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(match error {
Ok(value) => common::Error::BadRequest(value),
_ => common::Error::Failure(response),
});
}
let response = common::Response::from_parts(parts, body);
dlg.finished(true);
return Ok(response);
}
}
}
}
///
/// 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, C> {
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, C> {
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, C> {
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 common::Delegate,
) -> LiveStreamDeleteCall<'a, C> {
self._delegate = Some(new_value);
self
}
/// Set any additional parameter of the query string used in the request.
/// It should be used to set parameters 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<T>(mut self, name: T, value: T) -> LiveStreamDeleteCall<'a, C>
where
T: AsRef<str>,
{
self._additional_params
.insert(name.as_ref().to_string(), value.as_ref().to_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<St>(mut self, scope: St) -> LiveStreamDeleteCall<'a, C>
where
St: AsRef<str>,
{
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<I, St>(mut self, scopes: I) -> LiveStreamDeleteCall<'a, C>
where
I: IntoIterator<Item = St>,
St: AsRef<str>,
{
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, C> {
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 youtube3::{YouTube, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_only()
/// # .enable_http2()
/// # .build();
///
/// # let executor = hyper_util::rt::TokioExecutor::new();
/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// # secret,
/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # yup_oauth2::client::CustomHyperClientBuilder::from(
/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
/// # ),
/// # ).build().await.unwrap();
///
/// # let client = hyper_util::client::legacy::Client::builder(
/// # hyper_util::rt::TokioExecutor::new()
/// # )
/// # .build(
/// # hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_or_http()
/// # .enable_http2()
/// # .build()
/// # );
/// # let mut hub = YouTube::new(client, auth);
/// // As the method needs a request, you would usually fill it with the desired information
/// // into the 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("justo".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("sea")
/// .on_behalf_of_content_owner("consetetur")
/// .doit().await;
/// # }
/// ```
pub struct LiveStreamInsertCall<'a, C>
where
C: 'a,
{
hub: &'a YouTube<C>,
_request: LiveStream,
_part: Vec<String>,
_on_behalf_of_content_owner_channel: Option<String>,
_on_behalf_of_content_owner: Option<String>,
_delegate: Option<&'a mut dyn common::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>,
}
impl<'a, C> common::CallBuilder for LiveStreamInsertCall<'a, C> {}
impl<'a, C> LiveStreamInsertCall<'a, C>
where
C: common::Connector,
{
/// Perform the operation you have build so far.
pub async fn doit(mut self) -> common::Result<(common::Response, LiveStream)> {
use std::borrow::Cow;
use std::io::{Read, Seek};
use common::{url::Params, ToParts};
use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
let mut dd = common::DefaultDelegate;
let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(common::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(common::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.is_empty() {
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 = serde_json::value::to_value(&self._request).expect("serde to work");
common::remove_json_null_values(&mut value);
let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
serde_json::to_writer(&mut dst, &value).unwrap();
dst
};
let request_size = request_value_reader
.seek(std::io::SeekFrom::End(0))
.unwrap();
request_value_reader
.seek(std::io::SeekFrom::Start(0))
.unwrap();
loop {
let token = match self
.hub
.auth
.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
.await
{
Ok(token) => token,
Err(e) => match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(common::Error::MissingToken(e));
}
},
};
request_value_reader
.seek(std::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(common::to_body(
request_value_reader.get_ref().clone().into(),
));
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let common::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(common::Error::HttpError(err));
}
Ok(res) => {
let (mut parts, body) = res.into_parts();
let mut body = common::Body::new(body);
if !parts.status.is_success() {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let error = serde_json::from_str(&common::to_string(&bytes));
let response = common::to_response(parts, bytes.into());
if let common::Retry::After(d) =
dlg.http_failure(&response, error.as_ref().ok())
{
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(match error {
Ok(value) => common::Error::BadRequest(value),
_ => common::Error::Failure(response),
});
}
let response = {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let encoded = common::to_string(&bytes);
match serde_json::from_str(&encoded) {
Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
Err(error) => {
dlg.response_json_decode_error(&encoded, &error);
return Err(common::Error::JsonDecodeError(
encoded.to_string(),
error,
));
}
}
};
dlg.finished(true);
return Ok(response);
}
}
}
}
///
/// Sets the *request* 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, C> {
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, C> {
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, C> {
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, C> {
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 common::Delegate,
) -> LiveStreamInsertCall<'a, C> {
self._delegate = Some(new_value);
self
}
/// Set any additional parameter of the query string used in the request.
/// It should be used to set parameters 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<T>(mut self, name: T, value: T) -> LiveStreamInsertCall<'a, C>
where
T: AsRef<str>,
{
self._additional_params
.insert(name.as_ref().to_string(), value.as_ref().to_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<St>(mut self, scope: St) -> LiveStreamInsertCall<'a, C>
where
St: AsRef<str>,
{
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<I, St>(mut self, scopes: I) -> LiveStreamInsertCall<'a, C>
where
I: IntoIterator<Item = St>,
St: AsRef<str>,
{
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, C> {
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 youtube3::{YouTube, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_only()
/// # .enable_http2()
/// # .build();
///
/// # let executor = hyper_util::rt::TokioExecutor::new();
/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// # secret,
/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # yup_oauth2::client::CustomHyperClientBuilder::from(
/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
/// # ),
/// # ).build().await.unwrap();
///
/// # let client = hyper_util::client::legacy::Client::builder(
/// # hyper_util::rt::TokioExecutor::new()
/// # )
/// # .build(
/// # hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_or_http()
/// # .enable_http2()
/// # .build()
/// # );
/// # let mut hub = YouTube::new(client, auth);
/// // You can configure optional parameters by calling 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!["sit".into()])
/// .page_token("aliquyam")
/// .on_behalf_of_content_owner_channel("eos")
/// .on_behalf_of_content_owner("At")
/// .mine(true)
/// .max_results(39)
/// .add_id("dolor")
/// .doit().await;
/// # }
/// ```
pub struct LiveStreamListCall<'a, C>
where
C: 'a,
{
hub: &'a YouTube<C>,
_part: Vec<String>,
_page_token: Option<String>,
_on_behalf_of_content_owner_channel: Option<String>,
_on_behalf_of_content_owner: Option<String>,
_mine: Option<bool>,
_max_results: Option<u32>,
_id: Vec<String>,
_delegate: Option<&'a mut dyn common::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>,
}
impl<'a, C> common::CallBuilder for LiveStreamListCall<'a, C> {}
impl<'a, C> LiveStreamListCall<'a, C>
where
C: common::Connector,
{
/// Perform the operation you have build so far.
pub async fn doit(mut self) -> common::Result<(common::Response, LiveStreamListResponse)> {
use std::borrow::Cow;
use std::io::{Read, Seek};
use common::{url::Params, ToParts};
use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
let mut dd = common::DefaultDelegate;
let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(common::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(common::Error::FieldClash(field));
}
}
let mut params = Params::with_capacity(9 + self._additional_params.len());
if !self._part.is_empty() {
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.is_empty() {
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::<Vec<_>>()[..])
.await
{
Ok(token) => token,
Err(e) => match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(common::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(common::to_body::<String>(None));
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let common::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(common::Error::HttpError(err));
}
Ok(res) => {
let (mut parts, body) = res.into_parts();
let mut body = common::Body::new(body);
if !parts.status.is_success() {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let error = serde_json::from_str(&common::to_string(&bytes));
let response = common::to_response(parts, bytes.into());
if let common::Retry::After(d) =
dlg.http_failure(&response, error.as_ref().ok())
{
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(match error {
Ok(value) => common::Error::BadRequest(value),
_ => common::Error::Failure(response),
});
}
let response = {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let encoded = common::to_string(&bytes);
match serde_json::from_str(&encoded) {
Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
Err(error) => {
dlg.response_json_decode_error(&encoded, &error);
return Err(common::Error::JsonDecodeError(
encoded.to_string(),
error,
));
}
}
};
dlg.finished(true);
return Ok(response);
}
}
}
}
/// 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, C> {
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, C> {
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, C> {
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, C> {
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, C> {
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, C> {
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, C> {
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 common::Delegate,
) -> LiveStreamListCall<'a, C> {
self._delegate = Some(new_value);
self
}
/// Set any additional parameter of the query string used in the request.
/// It should be used to set parameters 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<T>(mut self, name: T, value: T) -> LiveStreamListCall<'a, C>
where
T: AsRef<str>,
{
self._additional_params
.insert(name.as_ref().to_string(), value.as_ref().to_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<St>(mut self, scope: St) -> LiveStreamListCall<'a, C>
where
St: AsRef<str>,
{
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<I, St>(mut self, scopes: I) -> LiveStreamListCall<'a, C>
where
I: IntoIterator<Item = St>,
St: AsRef<str>,
{
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, C> {
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 youtube3::{YouTube, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_only()
/// # .enable_http2()
/// # .build();
///
/// # let executor = hyper_util::rt::TokioExecutor::new();
/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// # secret,
/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # yup_oauth2::client::CustomHyperClientBuilder::from(
/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
/// # ),
/// # ).build().await.unwrap();
///
/// # let client = hyper_util::client::legacy::Client::builder(
/// # hyper_util::rt::TokioExecutor::new()
/// # )
/// # .build(
/// # hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_or_http()
/// # .enable_http2()
/// # .build()
/// # );
/// # let mut hub = YouTube::new(client, auth);
/// // As the method needs a request, you would usually fill it with the desired information
/// // into the 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("aliquyam".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("no")
/// .on_behalf_of_content_owner("amet.")
/// .doit().await;
/// # }
/// ```
pub struct LiveStreamUpdateCall<'a, C>
where
C: 'a,
{
hub: &'a YouTube<C>,
_request: LiveStream,
_part: Vec<String>,
_on_behalf_of_content_owner_channel: Option<String>,
_on_behalf_of_content_owner: Option<String>,
_delegate: Option<&'a mut dyn common::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>,
}
impl<'a, C> common::CallBuilder for LiveStreamUpdateCall<'a, C> {}
impl<'a, C> LiveStreamUpdateCall<'a, C>
where
C: common::Connector,
{
/// Perform the operation you have build so far.
pub async fn doit(mut self) -> common::Result<(common::Response, LiveStream)> {
use std::borrow::Cow;
use std::io::{Read, Seek};
use common::{url::Params, ToParts};
use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
let mut dd = common::DefaultDelegate;
let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(common::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(common::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.is_empty() {
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 = serde_json::value::to_value(&self._request).expect("serde to work");
common::remove_json_null_values(&mut value);
let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
serde_json::to_writer(&mut dst, &value).unwrap();
dst
};
let request_size = request_value_reader
.seek(std::io::SeekFrom::End(0))
.unwrap();
request_value_reader
.seek(std::io::SeekFrom::Start(0))
.unwrap();
loop {
let token = match self
.hub
.auth
.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
.await
{
Ok(token) => token,
Err(e) => match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(common::Error::MissingToken(e));
}
},
};
request_value_reader
.seek(std::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(common::to_body(
request_value_reader.get_ref().clone().into(),
));
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let common::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(common::Error::HttpError(err));
}
Ok(res) => {
let (mut parts, body) = res.into_parts();
let mut body = common::Body::new(body);
if !parts.status.is_success() {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let error = serde_json::from_str(&common::to_string(&bytes));
let response = common::to_response(parts, bytes.into());
if let common::Retry::After(d) =
dlg.http_failure(&response, error.as_ref().ok())
{
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(match error {
Ok(value) => common::Error::BadRequest(value),
_ => common::Error::Failure(response),
});
}
let response = {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let encoded = common::to_string(&bytes);
match serde_json::from_str(&encoded) {
Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
Err(error) => {
dlg.response_json_decode_error(&encoded, &error);
return Err(common::Error::JsonDecodeError(
encoded.to_string(),
error,
));
}
}
};
dlg.finished(true);
return Ok(response);
}
}
}
}
///
/// Sets the *request* 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, C> {
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, C> {
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, C> {
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, C> {
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 common::Delegate,
) -> LiveStreamUpdateCall<'a, C> {
self._delegate = Some(new_value);
self
}
/// Set any additional parameter of the query string used in the request.
/// It should be used to set parameters 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<T>(mut self, name: T, value: T) -> LiveStreamUpdateCall<'a, C>
where
T: AsRef<str>,
{
self._additional_params
.insert(name.as_ref().to_string(), value.as_ref().to_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<St>(mut self, scope: St) -> LiveStreamUpdateCall<'a, C>
where
St: AsRef<str>,
{
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<I, St>(mut self, scopes: I) -> LiveStreamUpdateCall<'a, C>
where
I: IntoIterator<Item = St>,
St: AsRef<str>,
{
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, C> {
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 youtube3::{YouTube, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_only()
/// # .enable_http2()
/// # .build();
///
/// # let executor = hyper_util::rt::TokioExecutor::new();
/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// # secret,
/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # yup_oauth2::client::CustomHyperClientBuilder::from(
/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
/// # ),
/// # ).build().await.unwrap();
///
/// # let client = hyper_util::client::legacy::Client::builder(
/// # hyper_util::rt::TokioExecutor::new()
/// # )
/// # .build(
/// # hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_or_http()
/// # .enable_http2()
/// # .build()
/// # );
/// # let mut hub = YouTube::new(client, auth);
/// // You can configure optional parameters by calling 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!["ipsum".into()])
/// .page_token("Lorem")
/// .mode("accusam")
/// .max_results(39)
/// .has_access_to_level("sadipscing")
/// .filter_by_member_channel_id("At")
/// .doit().await;
/// # }
/// ```
pub struct MemberListCall<'a, C>
where
C: 'a,
{
hub: &'a YouTube<C>,
_part: Vec<String>,
_page_token: Option<String>,
_mode: Option<String>,
_max_results: Option<u32>,
_has_access_to_level: Option<String>,
_filter_by_member_channel_id: Option<String>,
_delegate: Option<&'a mut dyn common::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>,
}
impl<'a, C> common::CallBuilder for MemberListCall<'a, C> {}
impl<'a, C> MemberListCall<'a, C>
where
C: common::Connector,
{
/// Perform the operation you have build so far.
pub async fn doit(mut self) -> common::Result<(common::Response, MemberListResponse)> {
use std::borrow::Cow;
use std::io::{Read, Seek};
use common::{url::Params, ToParts};
use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
let mut dd = common::DefaultDelegate;
let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(common::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(common::Error::FieldClash(field));
}
}
let mut params = Params::with_capacity(8 + self._additional_params.len());
if !self._part.is_empty() {
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::<Vec<_>>()[..])
.await
{
Ok(token) => token,
Err(e) => match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(common::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(common::to_body::<String>(None));
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let common::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(common::Error::HttpError(err));
}
Ok(res) => {
let (mut parts, body) = res.into_parts();
let mut body = common::Body::new(body);
if !parts.status.is_success() {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let error = serde_json::from_str(&common::to_string(&bytes));
let response = common::to_response(parts, bytes.into());
if let common::Retry::After(d) =
dlg.http_failure(&response, error.as_ref().ok())
{
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(match error {
Ok(value) => common::Error::BadRequest(value),
_ => common::Error::Failure(response),
});
}
let response = {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let encoded = common::to_string(&bytes);
match serde_json::from_str(&encoded) {
Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
Err(error) => {
dlg.response_json_decode_error(&encoded, &error);
return Err(common::Error::JsonDecodeError(
encoded.to_string(),
error,
));
}
}
};
dlg.finished(true);
return Ok(response);
}
}
}
}
/// 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, C> {
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, C> {
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: &str) -> MemberListCall<'a, C> {
self._mode = 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) -> MemberListCall<'a, C> {
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, C> {
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, C> {
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 common::Delegate) -> MemberListCall<'a, C> {
self._delegate = Some(new_value);
self
}
/// Set any additional parameter of the query string used in the request.
/// It should be used to set parameters 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<T>(mut self, name: T, value: T) -> MemberListCall<'a, C>
where
T: AsRef<str>,
{
self._additional_params
.insert(name.as_ref().to_string(), value.as_ref().to_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<St>(mut self, scope: St) -> MemberListCall<'a, C>
where
St: AsRef<str>,
{
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<I, St>(mut self, scopes: I) -> MemberListCall<'a, C>
where
I: IntoIterator<Item = St>,
St: AsRef<str>,
{
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, C> {
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 youtube3::{YouTube, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_only()
/// # .enable_http2()
/// # .build();
///
/// # let executor = hyper_util::rt::TokioExecutor::new();
/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// # secret,
/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # yup_oauth2::client::CustomHyperClientBuilder::from(
/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
/// # ),
/// # ).build().await.unwrap();
///
/// # let client = hyper_util::client::legacy::Client::builder(
/// # hyper_util::rt::TokioExecutor::new()
/// # )
/// # .build(
/// # hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_or_http()
/// # .enable_http2()
/// # .build()
/// # );
/// # let mut hub = YouTube::new(client, auth);
/// // You can configure optional parameters by calling 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!["sit".into()])
/// .doit().await;
/// # }
/// ```
pub struct MembershipsLevelListCall<'a, C>
where
C: 'a,
{
hub: &'a YouTube<C>,
_part: Vec<String>,
_delegate: Option<&'a mut dyn common::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>,
}
impl<'a, C> common::CallBuilder for MembershipsLevelListCall<'a, C> {}
impl<'a, C> MembershipsLevelListCall<'a, C>
where
C: common::Connector,
{
/// Perform the operation you have build so far.
pub async fn doit(
mut self,
) -> common::Result<(common::Response, MembershipsLevelListResponse)> {
use std::borrow::Cow;
use std::io::{Read, Seek};
use common::{url::Params, ToParts};
use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
let mut dd = common::DefaultDelegate;
let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(common::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(common::Error::FieldClash(field));
}
}
let mut params = Params::with_capacity(3 + self._additional_params.len());
if !self._part.is_empty() {
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::<Vec<_>>()[..])
.await
{
Ok(token) => token,
Err(e) => match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(common::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(common::to_body::<String>(None));
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let common::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(common::Error::HttpError(err));
}
Ok(res) => {
let (mut parts, body) = res.into_parts();
let mut body = common::Body::new(body);
if !parts.status.is_success() {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let error = serde_json::from_str(&common::to_string(&bytes));
let response = common::to_response(parts, bytes.into());
if let common::Retry::After(d) =
dlg.http_failure(&response, error.as_ref().ok())
{
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(match error {
Ok(value) => common::Error::BadRequest(value),
_ => common::Error::Failure(response),
});
}
let response = {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let encoded = common::to_string(&bytes);
match serde_json::from_str(&encoded) {
Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
Err(error) => {
dlg.response_json_decode_error(&encoded, &error);
return Err(common::Error::JsonDecodeError(
encoded.to_string(),
error,
));
}
}
};
dlg.finished(true);
return Ok(response);
}
}
}
}
/// 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, C> {
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 common::Delegate,
) -> MembershipsLevelListCall<'a, C> {
self._delegate = Some(new_value);
self
}
/// Set any additional parameter of the query string used in the request.
/// It should be used to set parameters 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<T>(mut self, name: T, value: T) -> MembershipsLevelListCall<'a, C>
where
T: AsRef<str>,
{
self._additional_params
.insert(name.as_ref().to_string(), value.as_ref().to_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<St>(mut self, scope: St) -> MembershipsLevelListCall<'a, C>
where
St: AsRef<str>,
{
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<I, St>(mut self, scopes: I) -> MembershipsLevelListCall<'a, C>
where
I: IntoIterator<Item = St>,
St: AsRef<str>,
{
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, C> {
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 youtube3::{YouTube, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_only()
/// # .enable_http2()
/// # .build();
///
/// # let executor = hyper_util::rt::TokioExecutor::new();
/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// # secret,
/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # yup_oauth2::client::CustomHyperClientBuilder::from(
/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
/// # ),
/// # ).build().await.unwrap();
///
/// # let client = hyper_util::client::legacy::Client::builder(
/// # hyper_util::rt::TokioExecutor::new()
/// # )
/// # .build(
/// # hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_or_http()
/// # .enable_http2()
/// # .build()
/// # );
/// # let mut hub = YouTube::new(client, auth);
/// // You can configure optional parameters by calling 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("duo")
/// .id("sit")
/// .doit().await;
/// # }
/// ```
pub struct PlaylistImageDeleteCall<'a, C>
where
C: 'a,
{
hub: &'a YouTube<C>,
_on_behalf_of_content_owner: Option<String>,
_id: Option<String>,
_delegate: Option<&'a mut dyn common::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>,
}
impl<'a, C> common::CallBuilder for PlaylistImageDeleteCall<'a, C> {}
impl<'a, C> PlaylistImageDeleteCall<'a, C>
where
C: common::Connector,
{
/// Perform the operation you have build so far.
pub async fn doit(mut self) -> common::Result<common::Response> {
use std::borrow::Cow;
use std::io::{Read, Seek};
use common::{url::Params, ToParts};
use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
let mut dd = common::DefaultDelegate;
let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(common::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(common::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::<Vec<_>>()[..])
.await
{
Ok(token) => token,
Err(e) => match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(common::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(common::to_body::<String>(None));
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let common::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(common::Error::HttpError(err));
}
Ok(res) => {
let (mut parts, body) = res.into_parts();
let mut body = common::Body::new(body);
if !parts.status.is_success() {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let error = serde_json::from_str(&common::to_string(&bytes));
let response = common::to_response(parts, bytes.into());
if let common::Retry::After(d) =
dlg.http_failure(&response, error.as_ref().ok())
{
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(match error {
Ok(value) => common::Error::BadRequest(value),
_ => common::Error::Failure(response),
});
}
let response = common::Response::from_parts(parts, body);
dlg.finished(true);
return Ok(response);
}
}
}
}
/// *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, C> {
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, C> {
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 common::Delegate,
) -> PlaylistImageDeleteCall<'a, C> {
self._delegate = Some(new_value);
self
}
/// Set any additional parameter of the query string used in the request.
/// It should be used to set parameters 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<T>(mut self, name: T, value: T) -> PlaylistImageDeleteCall<'a, C>
where
T: AsRef<str>,
{
self._additional_params
.insert(name.as_ref().to_string(), value.as_ref().to_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<St>(mut self, scope: St) -> PlaylistImageDeleteCall<'a, C>
where
St: AsRef<str>,
{
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<I, St>(mut self, scopes: I) -> PlaylistImageDeleteCall<'a, C>
where
I: IntoIterator<Item = St>,
St: AsRef<str>,
{
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, C> {
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 youtube3::{YouTube, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_only()
/// # .enable_http2()
/// # .build();
///
/// # let executor = hyper_util::rt::TokioExecutor::new();
/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// # secret,
/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # yup_oauth2::client::CustomHyperClientBuilder::from(
/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
/// # ),
/// # ).build().await.unwrap();
///
/// # let client = hyper_util::client::legacy::Client::builder(
/// # hyper_util::rt::TokioExecutor::new()
/// # )
/// # .build(
/// # hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_or_http()
/// # .enable_http2()
/// # .build()
/// # );
/// # let mut hub = YouTube::new(client, auth);
/// // As the method needs a request, you would usually fill it with the desired information
/// // into the 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("magna")
/// .on_behalf_of_content_owner_channel("et")
/// .on_behalf_of_content_owner("rebum.")
/// .upload_resumable(fs::File::open("file.ext").unwrap(), "application/octet-stream".parse().unwrap()).await;
/// # }
/// ```
pub struct PlaylistImageInsertCall<'a, C>
where
C: 'a,
{
hub: &'a YouTube<C>,
_request: PlaylistImage,
_part: Vec<String>,
_on_behalf_of_content_owner_channel: Option<String>,
_on_behalf_of_content_owner: Option<String>,
_delegate: Option<&'a mut dyn common::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>,
}
impl<'a, C> common::CallBuilder for PlaylistImageInsertCall<'a, C> {}
impl<'a, C> PlaylistImageInsertCall<'a, C>
where
C: common::Connector,
{
/// Perform the operation you have build so far.
async fn doit<RS>(
mut self,
mut reader: RS,
reader_mime_type: mime::Mime,
protocol: common::UploadProtocol,
) -> common::Result<(common::Response, PlaylistImage)>
where
RS: common::ReadSeek,
{
use std::borrow::Cow;
use std::io::{Read, Seek};
use common::{url::Params, ToParts};
use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
let mut dd = common::DefaultDelegate;
let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(common::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(common::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.is_empty() {
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 == common::UploadProtocol::Resumable {
(
self.hub._root_url.clone() + "resumable/upload/youtube/v3/playlistImages",
"resumable",
)
} else if protocol == common::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 = serde_json::value::to_value(&self._request).expect("serde to work");
common::remove_json_null_values(&mut value);
let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
serde_json::to_writer(&mut dst, &value).unwrap();
dst
};
let request_size = request_value_reader
.seek(std::io::SeekFrom::End(0))
.unwrap();
request_value_reader
.seek(std::io::SeekFrom::Start(0))
.unwrap();
let mut upload_url_from_server;
loop {
let token = match self
.hub
.auth
.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
.await
{
Ok(token) => token,
Err(e) => match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(common::Error::MissingToken(e));
}
},
};
request_value_reader
.seek(std::io::SeekFrom::Start(0))
.unwrap();
let mut req_result = {
let mut mp_reader: common::MultiPartReader = Default::default();
let (mut body_reader, content_type) = match protocol {
common::UploadProtocol::Simple => {
mp_reader.reserve_exact(2);
let size = reader.seek(std::io::SeekFrom::End(0)).unwrap();
reader.seek(std::io::SeekFrom::Start(0)).unwrap();
if size > 2097152 {
return Err(common::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 std::io::Read + Send),
common::MultiPartReader::mime_type(),
)
}
_ => (
&mut request_value_reader as &mut (dyn std::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 == common::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(common::to_body(body_reader_bytes.into()));
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let common::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(common::Error::HttpError(err));
}
Ok(res) => {
let (mut parts, body) = res.into_parts();
let mut body = common::Body::new(body);
if !parts.status.is_success() {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let error = serde_json::from_str(&common::to_string(&bytes));
let response = common::to_response(parts, bytes.into());
if let common::Retry::After(d) =
dlg.http_failure(&response, error.as_ref().ok())
{
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(match error {
Ok(value) => common::Error::BadRequest(value),
_ => common::Error::Failure(response),
});
}
if protocol == common::UploadProtocol::Resumable {
let size = reader.seek(std::io::SeekFrom::End(0)).unwrap();
reader.seek(std::io::SeekFrom::Start(0)).unwrap();
if size > 2097152 {
return Err(common::Error::UploadSizeLimitExceeded(size, 2097152));
}
let upload_result = {
let url_str = &parts
.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));
}
common::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(|| common::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(common::Error::Cancelled);
}
Some(Err(err)) => {
dlg.finished(false);
return Err(common::Error::HttpError(err));
}
Some(Ok(response)) => {
(parts, body) = response.into_parts();
if !parts.status.is_success() {
dlg.store_upload_url(None);
dlg.finished(false);
return Err(common::Error::Failure(
common::Response::from_parts(parts, body),
));
}
}
}
}
let response = {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let encoded = common::to_string(&bytes);
match serde_json::from_str(&encoded) {
Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
Err(error) => {
dlg.response_json_decode_error(&encoded, &error);
return Err(common::Error::JsonDecodeError(
encoded.to_string(),
error,
));
}
}
};
dlg.finished(true);
return Ok(response);
}
}
}
}
/// 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<RS>(
self,
resumeable_stream: RS,
mime_type: mime::Mime,
) -> common::Result<(common::Response, PlaylistImage)>
where
RS: common::ReadSeek,
{
self.doit(
resumeable_stream,
mime_type,
common::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<RS>(
self,
stream: RS,
mime_type: mime::Mime,
) -> common::Result<(common::Response, PlaylistImage)>
where
RS: common::ReadSeek,
{
self.doit(stream, mime_type, common::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, C> {
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, C> {
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, C> {
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, C> {
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 common::Delegate,
) -> PlaylistImageInsertCall<'a, C> {
self._delegate = Some(new_value);
self
}
/// Set any additional parameter of the query string used in the request.
/// It should be used to set parameters 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<T>(mut self, name: T, value: T) -> PlaylistImageInsertCall<'a, C>
where
T: AsRef<str>,
{
self._additional_params
.insert(name.as_ref().to_string(), value.as_ref().to_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<St>(mut self, scope: St) -> PlaylistImageInsertCall<'a, C>
where
St: AsRef<str>,
{
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<I, St>(mut self, scopes: I) -> PlaylistImageInsertCall<'a, C>
where
I: IntoIterator<Item = St>,
St: AsRef<str>,
{
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, C> {
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 youtube3::{YouTube, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_only()
/// # .enable_http2()
/// # .build();
///
/// # let executor = hyper_util::rt::TokioExecutor::new();
/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// # secret,
/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # yup_oauth2::client::CustomHyperClientBuilder::from(
/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
/// # ),
/// # ).build().await.unwrap();
///
/// # let client = hyper_util::client::legacy::Client::builder(
/// # hyper_util::rt::TokioExecutor::new()
/// # )
/// # .build(
/// # hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_or_http()
/// # .enable_http2()
/// # .build()
/// # );
/// # let mut hub = YouTube::new(client, auth);
/// // You can configure optional parameters by calling 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("dolor")
/// .parent("Lorem")
/// .page_token("justo")
/// .on_behalf_of_content_owner_channel("amet.")
/// .on_behalf_of_content_owner("no")
/// .max_results(10)
/// .doit().await;
/// # }
/// ```
pub struct PlaylistImageListCall<'a, C>
where
C: 'a,
{
hub: &'a YouTube<C>,
_part: Vec<String>,
_parent: Option<String>,
_page_token: Option<String>,
_on_behalf_of_content_owner_channel: Option<String>,
_on_behalf_of_content_owner: Option<String>,
_max_results: Option<u32>,
_delegate: Option<&'a mut dyn common::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>,
}
impl<'a, C> common::CallBuilder for PlaylistImageListCall<'a, C> {}
impl<'a, C> PlaylistImageListCall<'a, C>
where
C: common::Connector,
{
/// Perform the operation you have build so far.
pub async fn doit(mut self) -> common::Result<(common::Response, PlaylistImageListResponse)> {
use std::borrow::Cow;
use std::io::{Read, Seek};
use common::{url::Params, ToParts};
use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
let mut dd = common::DefaultDelegate;
let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(common::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(common::Error::FieldClash(field));
}
}
let mut params = Params::with_capacity(8 + self._additional_params.len());
if !self._part.is_empty() {
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::<Vec<_>>()[..])
.await
{
Ok(token) => token,
Err(e) => match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(common::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(common::to_body::<String>(None));
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let common::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(common::Error::HttpError(err));
}
Ok(res) => {
let (mut parts, body) = res.into_parts();
let mut body = common::Body::new(body);
if !parts.status.is_success() {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let error = serde_json::from_str(&common::to_string(&bytes));
let response = common::to_response(parts, bytes.into());
if let common::Retry::After(d) =
dlg.http_failure(&response, error.as_ref().ok())
{
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(match error {
Ok(value) => common::Error::BadRequest(value),
_ => common::Error::Failure(response),
});
}
let response = {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let encoded = common::to_string(&bytes);
match serde_json::from_str(&encoded) {
Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
Err(error) => {
dlg.response_json_decode_error(&encoded, &error);
return Err(common::Error::JsonDecodeError(
encoded.to_string(),
error,
));
}
}
};
dlg.finished(true);
return Ok(response);
}
}
}
}
/// 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, C> {
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, C> {
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, C> {
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, C> {
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, C> {
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, C> {
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 common::Delegate,
) -> PlaylistImageListCall<'a, C> {
self._delegate = Some(new_value);
self
}
/// Set any additional parameter of the query string used in the request.
/// It should be used to set parameters 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<T>(mut self, name: T, value: T) -> PlaylistImageListCall<'a, C>
where
T: AsRef<str>,
{
self._additional_params
.insert(name.as_ref().to_string(), value.as_ref().to_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<St>(mut self, scope: St) -> PlaylistImageListCall<'a, C>
where
St: AsRef<str>,
{
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<I, St>(mut self, scopes: I) -> PlaylistImageListCall<'a, C>
where
I: IntoIterator<Item = St>,
St: AsRef<str>,
{
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, C> {
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 youtube3::{YouTube, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_only()
/// # .enable_http2()
/// # .build();
///
/// # let executor = hyper_util::rt::TokioExecutor::new();
/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// # secret,
/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # yup_oauth2::client::CustomHyperClientBuilder::from(
/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
/// # ),
/// # ).build().await.unwrap();
///
/// # let client = hyper_util::client::legacy::Client::builder(
/// # hyper_util::rt::TokioExecutor::new()
/// # )
/// # .build(
/// # hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_or_http()
/// # .enable_http2()
/// # .build()
/// # );
/// # let mut hub = YouTube::new(client, auth);
/// // As the method needs a request, you would usually fill it with the desired information
/// // into the 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("sed")
/// .on_behalf_of_content_owner("kasd")
/// .upload_resumable(fs::File::open("file.ext").unwrap(), "application/octet-stream".parse().unwrap()).await;
/// # }
/// ```
pub struct PlaylistImageUpdateCall<'a, C>
where
C: 'a,
{
hub: &'a YouTube<C>,
_request: PlaylistImage,
_part: Vec<String>,
_on_behalf_of_content_owner: Option<String>,
_delegate: Option<&'a mut dyn common::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>,
}
impl<'a, C> common::CallBuilder for PlaylistImageUpdateCall<'a, C> {}
impl<'a, C> PlaylistImageUpdateCall<'a, C>
where
C: common::Connector,
{
/// Perform the operation you have build so far.
async fn doit<RS>(
mut self,
mut reader: RS,
reader_mime_type: mime::Mime,
protocol: common::UploadProtocol,
) -> common::Result<(common::Response, PlaylistImage)>
where
RS: common::ReadSeek,
{
use std::borrow::Cow;
use std::io::{Read, Seek};
use common::{url::Params, ToParts};
use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
let mut dd = common::DefaultDelegate;
let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(common::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(common::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.is_empty() {
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 == common::UploadProtocol::Resumable {
(
self.hub._root_url.clone() + "resumable/upload/youtube/v3/playlistImages",
"resumable",
)
} else if protocol == common::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 = serde_json::value::to_value(&self._request).expect("serde to work");
common::remove_json_null_values(&mut value);
let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
serde_json::to_writer(&mut dst, &value).unwrap();
dst
};
let request_size = request_value_reader
.seek(std::io::SeekFrom::End(0))
.unwrap();
request_value_reader
.seek(std::io::SeekFrom::Start(0))
.unwrap();
let mut upload_url_from_server;
loop {
let token = match self
.hub
.auth
.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
.await
{
Ok(token) => token,
Err(e) => match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(common::Error::MissingToken(e));
}
},
};
request_value_reader
.seek(std::io::SeekFrom::Start(0))
.unwrap();
let mut req_result = {
let mut mp_reader: common::MultiPartReader = Default::default();
let (mut body_reader, content_type) = match protocol {
common::UploadProtocol::Simple => {
mp_reader.reserve_exact(2);
let size = reader.seek(std::io::SeekFrom::End(0)).unwrap();
reader.seek(std::io::SeekFrom::Start(0)).unwrap();
if size > 2097152 {
return Err(common::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 std::io::Read + Send),
common::MultiPartReader::mime_type(),
)
}
_ => (
&mut request_value_reader as &mut (dyn std::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 == common::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(common::to_body(body_reader_bytes.into()));
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let common::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(common::Error::HttpError(err));
}
Ok(res) => {
let (mut parts, body) = res.into_parts();
let mut body = common::Body::new(body);
if !parts.status.is_success() {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let error = serde_json::from_str(&common::to_string(&bytes));
let response = common::to_response(parts, bytes.into());
if let common::Retry::After(d) =
dlg.http_failure(&response, error.as_ref().ok())
{
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(match error {
Ok(value) => common::Error::BadRequest(value),
_ => common::Error::Failure(response),
});
}
if protocol == common::UploadProtocol::Resumable {
let size = reader.seek(std::io::SeekFrom::End(0)).unwrap();
reader.seek(std::io::SeekFrom::Start(0)).unwrap();
if size > 2097152 {
return Err(common::Error::UploadSizeLimitExceeded(size, 2097152));
}
let upload_result = {
let url_str = &parts
.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));
}
common::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(|| common::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(common::Error::Cancelled);
}
Some(Err(err)) => {
dlg.finished(false);
return Err(common::Error::HttpError(err));
}
Some(Ok(response)) => {
(parts, body) = response.into_parts();
if !parts.status.is_success() {
dlg.store_upload_url(None);
dlg.finished(false);
return Err(common::Error::Failure(
common::Response::from_parts(parts, body),
));
}
}
}
}
let response = {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let encoded = common::to_string(&bytes);
match serde_json::from_str(&encoded) {
Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
Err(error) => {
dlg.response_json_decode_error(&encoded, &error);
return Err(common::Error::JsonDecodeError(
encoded.to_string(),
error,
));
}
}
};
dlg.finished(true);
return Ok(response);
}
}
}
}
/// 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<RS>(
self,
resumeable_stream: RS,
mime_type: mime::Mime,
) -> common::Result<(common::Response, PlaylistImage)>
where
RS: common::ReadSeek,
{
self.doit(
resumeable_stream,
mime_type,
common::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<RS>(
self,
stream: RS,
mime_type: mime::Mime,
) -> common::Result<(common::Response, PlaylistImage)>
where
RS: common::ReadSeek,
{
self.doit(stream, mime_type, common::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, C> {
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, C> {
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, C> {
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 common::Delegate,
) -> PlaylistImageUpdateCall<'a, C> {
self._delegate = Some(new_value);
self
}
/// Set any additional parameter of the query string used in the request.
/// It should be used to set parameters 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<T>(mut self, name: T, value: T) -> PlaylistImageUpdateCall<'a, C>
where
T: AsRef<str>,
{
self._additional_params
.insert(name.as_ref().to_string(), value.as_ref().to_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<St>(mut self, scope: St) -> PlaylistImageUpdateCall<'a, C>
where
St: AsRef<str>,
{
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<I, St>(mut self, scopes: I) -> PlaylistImageUpdateCall<'a, C>
where
I: IntoIterator<Item = St>,
St: AsRef<str>,
{
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, C> {
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 youtube3::{YouTube, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_only()
/// # .enable_http2()
/// # .build();
///
/// # let executor = hyper_util::rt::TokioExecutor::new();
/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// # secret,
/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # yup_oauth2::client::CustomHyperClientBuilder::from(
/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
/// # ),
/// # ).build().await.unwrap();
///
/// # let client = hyper_util::client::legacy::Client::builder(
/// # hyper_util::rt::TokioExecutor::new()
/// # )
/// # .build(
/// # hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_or_http()
/// # .enable_http2()
/// # .build()
/// # );
/// # let mut hub = YouTube::new(client, auth);
/// // You can configure optional parameters by calling 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("sanctus")
/// .doit().await;
/// # }
/// ```
pub struct PlaylistItemDeleteCall<'a, C>
where
C: 'a,
{
hub: &'a YouTube<C>,
_id: String,
_on_behalf_of_content_owner: Option<String>,
_delegate: Option<&'a mut dyn common::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>,
}
impl<'a, C> common::CallBuilder for PlaylistItemDeleteCall<'a, C> {}
impl<'a, C> PlaylistItemDeleteCall<'a, C>
where
C: common::Connector,
{
/// Perform the operation you have build so far.
pub async fn doit(mut self) -> common::Result<common::Response> {
use std::borrow::Cow;
use std::io::{Read, Seek};
use common::{url::Params, ToParts};
use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
let mut dd = common::DefaultDelegate;
let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(common::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(common::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::<Vec<_>>()[..])
.await
{
Ok(token) => token,
Err(e) => match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(common::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(common::to_body::<String>(None));
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let common::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(common::Error::HttpError(err));
}
Ok(res) => {
let (mut parts, body) = res.into_parts();
let mut body = common::Body::new(body);
if !parts.status.is_success() {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let error = serde_json::from_str(&common::to_string(&bytes));
let response = common::to_response(parts, bytes.into());
if let common::Retry::After(d) =
dlg.http_failure(&response, error.as_ref().ok())
{
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(match error {
Ok(value) => common::Error::BadRequest(value),
_ => common::Error::Failure(response),
});
}
let response = common::Response::from_parts(parts, body);
dlg.finished(true);
return Ok(response);
}
}
}
}
///
/// 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, C> {
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, C> {
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 common::Delegate,
) -> PlaylistItemDeleteCall<'a, C> {
self._delegate = Some(new_value);
self
}
/// Set any additional parameter of the query string used in the request.
/// It should be used to set parameters 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<T>(mut self, name: T, value: T) -> PlaylistItemDeleteCall<'a, C>
where
T: AsRef<str>,
{
self._additional_params
.insert(name.as_ref().to_string(), value.as_ref().to_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<St>(mut self, scope: St) -> PlaylistItemDeleteCall<'a, C>
where
St: AsRef<str>,
{
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<I, St>(mut self, scopes: I) -> PlaylistItemDeleteCall<'a, C>
where
I: IntoIterator<Item = St>,
St: AsRef<str>,
{
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, C> {
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 youtube3::{YouTube, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_only()
/// # .enable_http2()
/// # .build();
///
/// # let executor = hyper_util::rt::TokioExecutor::new();
/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// # secret,
/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # yup_oauth2::client::CustomHyperClientBuilder::from(
/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
/// # ),
/// # ).build().await.unwrap();
///
/// # let client = hyper_util::client::legacy::Client::builder(
/// # hyper_util::rt::TokioExecutor::new()
/// # )
/// # .build(
/// # hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_or_http()
/// # .enable_http2()
/// # .build()
/// # );
/// # let mut hub = YouTube::new(client, auth);
/// // As the method needs a request, you would usually fill it with the desired information
/// // into the 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("nonumy")
/// .doit().await;
/// # }
/// ```
pub struct PlaylistItemInsertCall<'a, C>
where
C: 'a,
{
hub: &'a YouTube<C>,
_request: PlaylistItem,
_part: Vec<String>,
_on_behalf_of_content_owner: Option<String>,
_delegate: Option<&'a mut dyn common::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>,
}
impl<'a, C> common::CallBuilder for PlaylistItemInsertCall<'a, C> {}
impl<'a, C> PlaylistItemInsertCall<'a, C>
where
C: common::Connector,
{
/// Perform the operation you have build so far.
pub async fn doit(mut self) -> common::Result<(common::Response, PlaylistItem)> {
use std::borrow::Cow;
use std::io::{Read, Seek};
use common::{url::Params, ToParts};
use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
let mut dd = common::DefaultDelegate;
let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(common::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(common::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.is_empty() {
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 = serde_json::value::to_value(&self._request).expect("serde to work");
common::remove_json_null_values(&mut value);
let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
serde_json::to_writer(&mut dst, &value).unwrap();
dst
};
let request_size = request_value_reader
.seek(std::io::SeekFrom::End(0))
.unwrap();
request_value_reader
.seek(std::io::SeekFrom::Start(0))
.unwrap();
loop {
let token = match self
.hub
.auth
.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
.await
{
Ok(token) => token,
Err(e) => match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(common::Error::MissingToken(e));
}
},
};
request_value_reader
.seek(std::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(common::to_body(
request_value_reader.get_ref().clone().into(),
));
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let common::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(common::Error::HttpError(err));
}
Ok(res) => {
let (mut parts, body) = res.into_parts();
let mut body = common::Body::new(body);
if !parts.status.is_success() {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let error = serde_json::from_str(&common::to_string(&bytes));
let response = common::to_response(parts, bytes.into());
if let common::Retry::After(d) =
dlg.http_failure(&response, error.as_ref().ok())
{
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(match error {
Ok(value) => common::Error::BadRequest(value),
_ => common::Error::Failure(response),
});
}
let response = {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let encoded = common::to_string(&bytes);
match serde_json::from_str(&encoded) {
Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
Err(error) => {
dlg.response_json_decode_error(&encoded, &error);
return Err(common::Error::JsonDecodeError(
encoded.to_string(),
error,
));
}
}
};
dlg.finished(true);
return Ok(response);
}
}
}
}
///
/// Sets the *request* property to the given value.
///
/// Even though 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, C> {
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, C> {
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, C> {
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 common::Delegate,
) -> PlaylistItemInsertCall<'a, C> {
self._delegate = Some(new_value);
self
}
/// Set any additional parameter of the query string used in the request.
/// It should be used to set parameters 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<T>(mut self, name: T, value: T) -> PlaylistItemInsertCall<'a, C>
where
T: AsRef<str>,
{
self._additional_params
.insert(name.as_ref().to_string(), value.as_ref().to_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<St>(mut self, scope: St) -> PlaylistItemInsertCall<'a, C>
where
St: AsRef<str>,
{
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<I, St>(mut self, scopes: I) -> PlaylistItemInsertCall<'a, C>
where
I: IntoIterator<Item = St>,
St: AsRef<str>,
{
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, C> {
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 youtube3::{YouTube, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_only()
/// # .enable_http2()
/// # .build();
///
/// # let executor = hyper_util::rt::TokioExecutor::new();
/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// # secret,
/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # yup_oauth2::client::CustomHyperClientBuilder::from(
/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
/// # ),
/// # ).build().await.unwrap();
///
/// # let client = hyper_util::client::legacy::Client::builder(
/// # hyper_util::rt::TokioExecutor::new()
/// # )
/// # .build(
/// # hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_or_http()
/// # .enable_http2()
/// # .build()
/// # );
/// # let mut hub = YouTube::new(client, auth);
/// // You can configure optional parameters by calling 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!["rebum.".into()])
/// .video_id("tempor")
/// .playlist_id("dolore")
/// .page_token("eos")
/// .on_behalf_of_content_owner("amet.")
/// .max_results(17)
/// .add_id("amet")
/// .doit().await;
/// # }
/// ```
pub struct PlaylistItemListCall<'a, C>
where
C: 'a,
{
hub: &'a YouTube<C>,
_part: Vec<String>,
_video_id: Option<String>,
_playlist_id: Option<String>,
_page_token: Option<String>,
_on_behalf_of_content_owner: Option<String>,
_max_results: Option<u32>,
_id: Vec<String>,
_delegate: Option<&'a mut dyn common::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>,
}
impl<'a, C> common::CallBuilder for PlaylistItemListCall<'a, C> {}
impl<'a, C> PlaylistItemListCall<'a, C>
where
C: common::Connector,
{
/// Perform the operation you have build so far.
pub async fn doit(mut self) -> common::Result<(common::Response, PlaylistItemListResponse)> {
use std::borrow::Cow;
use std::io::{Read, Seek};
use common::{url::Params, ToParts};
use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
let mut dd = common::DefaultDelegate;
let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(common::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(common::Error::FieldClash(field));
}
}
let mut params = Params::with_capacity(9 + self._additional_params.len());
if !self._part.is_empty() {
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.is_empty() {
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::<Vec<_>>()[..])
.await
{
Ok(token) => token,
Err(e) => match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(common::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(common::to_body::<String>(None));
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let common::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(common::Error::HttpError(err));
}
Ok(res) => {
let (mut parts, body) = res.into_parts();
let mut body = common::Body::new(body);
if !parts.status.is_success() {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let error = serde_json::from_str(&common::to_string(&bytes));
let response = common::to_response(parts, bytes.into());
if let common::Retry::After(d) =
dlg.http_failure(&response, error.as_ref().ok())
{
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(match error {
Ok(value) => common::Error::BadRequest(value),
_ => common::Error::Failure(response),
});
}
let response = {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let encoded = common::to_string(&bytes);
match serde_json::from_str(&encoded) {
Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
Err(error) => {
dlg.response_json_decode_error(&encoded, &error);
return Err(common::Error::JsonDecodeError(
encoded.to_string(),
error,
));
}
}
};
dlg.finished(true);
return Ok(response);
}
}
}
}
/// 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, C> {
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, C> {
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, C> {
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, C> {
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, C> {
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, C> {
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, C> {
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 common::Delegate,
) -> PlaylistItemListCall<'a, C> {
self._delegate = Some(new_value);
self
}
/// Set any additional parameter of the query string used in the request.
/// It should be used to set parameters 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<T>(mut self, name: T, value: T) -> PlaylistItemListCall<'a, C>
where
T: AsRef<str>,
{
self._additional_params
.insert(name.as_ref().to_string(), value.as_ref().to_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<St>(mut self, scope: St) -> PlaylistItemListCall<'a, C>
where
St: AsRef<str>,
{
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<I, St>(mut self, scopes: I) -> PlaylistItemListCall<'a, C>
where
I: IntoIterator<Item = St>,
St: AsRef<str>,
{
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, C> {
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 youtube3::{YouTube, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_only()
/// # .enable_http2()
/// # .build();
///
/// # let executor = hyper_util::rt::TokioExecutor::new();
/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// # secret,
/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # yup_oauth2::client::CustomHyperClientBuilder::from(
/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
/// # ),
/// # ).build().await.unwrap();
///
/// # let client = hyper_util::client::legacy::Client::builder(
/// # hyper_util::rt::TokioExecutor::new()
/// # )
/// # .build(
/// # hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_or_http()
/// # .enable_http2()
/// # .build()
/// # );
/// # let mut hub = YouTube::new(client, auth);
/// // As the method needs a request, you would usually fill it with the desired information
/// // into the 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("ut")
/// .doit().await;
/// # }
/// ```
pub struct PlaylistItemUpdateCall<'a, C>
where
C: 'a,
{
hub: &'a YouTube<C>,
_request: PlaylistItem,
_part: Vec<String>,
_on_behalf_of_content_owner: Option<String>,
_delegate: Option<&'a mut dyn common::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>,
}
impl<'a, C> common::CallBuilder for PlaylistItemUpdateCall<'a, C> {}
impl<'a, C> PlaylistItemUpdateCall<'a, C>
where
C: common::Connector,
{
/// Perform the operation you have build so far.
pub async fn doit(mut self) -> common::Result<(common::Response, PlaylistItem)> {
use std::borrow::Cow;
use std::io::{Read, Seek};
use common::{url::Params, ToParts};
use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
let mut dd = common::DefaultDelegate;
let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(common::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(common::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.is_empty() {
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 = serde_json::value::to_value(&self._request).expect("serde to work");
common::remove_json_null_values(&mut value);
let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
serde_json::to_writer(&mut dst, &value).unwrap();
dst
};
let request_size = request_value_reader
.seek(std::io::SeekFrom::End(0))
.unwrap();
request_value_reader
.seek(std::io::SeekFrom::Start(0))
.unwrap();
loop {
let token = match self
.hub
.auth
.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
.await
{
Ok(token) => token,
Err(e) => match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(common::Error::MissingToken(e));
}
},
};
request_value_reader
.seek(std::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(common::to_body(
request_value_reader.get_ref().clone().into(),
));
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let common::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(common::Error::HttpError(err));
}
Ok(res) => {
let (mut parts, body) = res.into_parts();
let mut body = common::Body::new(body);
if !parts.status.is_success() {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let error = serde_json::from_str(&common::to_string(&bytes));
let response = common::to_response(parts, bytes.into());
if let common::Retry::After(d) =
dlg.http_failure(&response, error.as_ref().ok())
{
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(match error {
Ok(value) => common::Error::BadRequest(value),
_ => common::Error::Failure(response),
});
}
let response = {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let encoded = common::to_string(&bytes);
match serde_json::from_str(&encoded) {
Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
Err(error) => {
dlg.response_json_decode_error(&encoded, &error);
return Err(common::Error::JsonDecodeError(
encoded.to_string(),
error,
));
}
}
};
dlg.finished(true);
return Ok(response);
}
}
}
}
///
/// Sets the *request* property to the given value.
///
/// Even though 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, C> {
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, C> {
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, C> {
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 common::Delegate,
) -> PlaylistItemUpdateCall<'a, C> {
self._delegate = Some(new_value);
self
}
/// Set any additional parameter of the query string used in the request.
/// It should be used to set parameters 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<T>(mut self, name: T, value: T) -> PlaylistItemUpdateCall<'a, C>
where
T: AsRef<str>,
{
self._additional_params
.insert(name.as_ref().to_string(), value.as_ref().to_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<St>(mut self, scope: St) -> PlaylistItemUpdateCall<'a, C>
where
St: AsRef<str>,
{
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<I, St>(mut self, scopes: I) -> PlaylistItemUpdateCall<'a, C>
where
I: IntoIterator<Item = St>,
St: AsRef<str>,
{
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, C> {
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 youtube3::{YouTube, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_only()
/// # .enable_http2()
/// # .build();
///
/// # let executor = hyper_util::rt::TokioExecutor::new();
/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// # secret,
/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # yup_oauth2::client::CustomHyperClientBuilder::from(
/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
/// # ),
/// # ).build().await.unwrap();
///
/// # let client = hyper_util::client::legacy::Client::builder(
/// # hyper_util::rt::TokioExecutor::new()
/// # )
/// # .build(
/// # hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_or_http()
/// # .enable_http2()
/// # .build()
/// # );
/// # let mut hub = YouTube::new(client, auth);
/// // You can configure optional parameters by calling 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("sit")
/// .doit().await;
/// # }
/// ```
pub struct PlaylistDeleteCall<'a, C>
where
C: 'a,
{
hub: &'a YouTube<C>,
_id: String,
_on_behalf_of_content_owner: Option<String>,
_delegate: Option<&'a mut dyn common::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>,
}
impl<'a, C> common::CallBuilder for PlaylistDeleteCall<'a, C> {}
impl<'a, C> PlaylistDeleteCall<'a, C>
where
C: common::Connector,
{
/// Perform the operation you have build so far.
pub async fn doit(mut self) -> common::Result<common::Response> {
use std::borrow::Cow;
use std::io::{Read, Seek};
use common::{url::Params, ToParts};
use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
let mut dd = common::DefaultDelegate;
let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(common::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(common::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::<Vec<_>>()[..])
.await
{
Ok(token) => token,
Err(e) => match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(common::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(common::to_body::<String>(None));
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let common::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(common::Error::HttpError(err));
}
Ok(res) => {
let (mut parts, body) = res.into_parts();
let mut body = common::Body::new(body);
if !parts.status.is_success() {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let error = serde_json::from_str(&common::to_string(&bytes));
let response = common::to_response(parts, bytes.into());
if let common::Retry::After(d) =
dlg.http_failure(&response, error.as_ref().ok())
{
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(match error {
Ok(value) => common::Error::BadRequest(value),
_ => common::Error::Failure(response),
});
}
let response = common::Response::from_parts(parts, body);
dlg.finished(true);
return Ok(response);
}
}
}
}
///
/// 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, C> {
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, C> {
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 common::Delegate,
) -> PlaylistDeleteCall<'a, C> {
self._delegate = Some(new_value);
self
}
/// Set any additional parameter of the query string used in the request.
/// It should be used to set parameters 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<T>(mut self, name: T, value: T) -> PlaylistDeleteCall<'a, C>
where
T: AsRef<str>,
{
self._additional_params
.insert(name.as_ref().to_string(), value.as_ref().to_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<St>(mut self, scope: St) -> PlaylistDeleteCall<'a, C>
where
St: AsRef<str>,
{
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<I, St>(mut self, scopes: I) -> PlaylistDeleteCall<'a, C>
where
I: IntoIterator<Item = St>,
St: AsRef<str>,
{
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, C> {
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 youtube3::{YouTube, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_only()
/// # .enable_http2()
/// # .build();
///
/// # let executor = hyper_util::rt::TokioExecutor::new();
/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// # secret,
/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # yup_oauth2::client::CustomHyperClientBuilder::from(
/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
/// # ),
/// # ).build().await.unwrap();
///
/// # let client = hyper_util::client::legacy::Client::builder(
/// # hyper_util::rt::TokioExecutor::new()
/// # )
/// # .build(
/// # hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_or_http()
/// # .enable_http2()
/// # .build()
/// # );
/// # let mut hub = YouTube::new(client, auth);
/// // As the method needs a request, you would usually fill it with the desired information
/// // into the 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("vero")
/// .on_behalf_of_content_owner("duo")
/// .doit().await;
/// # }
/// ```
pub struct PlaylistInsertCall<'a, C>
where
C: 'a,
{
hub: &'a YouTube<C>,
_request: Playlist,
_part: Vec<String>,
_on_behalf_of_content_owner_channel: Option<String>,
_on_behalf_of_content_owner: Option<String>,
_delegate: Option<&'a mut dyn common::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>,
}
impl<'a, C> common::CallBuilder for PlaylistInsertCall<'a, C> {}
impl<'a, C> PlaylistInsertCall<'a, C>
where
C: common::Connector,
{
/// Perform the operation you have build so far.
pub async fn doit(mut self) -> common::Result<(common::Response, Playlist)> {
use std::borrow::Cow;
use std::io::{Read, Seek};
use common::{url::Params, ToParts};
use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
let mut dd = common::DefaultDelegate;
let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(common::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(common::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.is_empty() {
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 = serde_json::value::to_value(&self._request).expect("serde to work");
common::remove_json_null_values(&mut value);
let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
serde_json::to_writer(&mut dst, &value).unwrap();
dst
};
let request_size = request_value_reader
.seek(std::io::SeekFrom::End(0))
.unwrap();
request_value_reader
.seek(std::io::SeekFrom::Start(0))
.unwrap();
loop {
let token = match self
.hub
.auth
.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
.await
{
Ok(token) => token,
Err(e) => match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(common::Error::MissingToken(e));
}
},
};
request_value_reader
.seek(std::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(common::to_body(
request_value_reader.get_ref().clone().into(),
));
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let common::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(common::Error::HttpError(err));
}
Ok(res) => {
let (mut parts, body) = res.into_parts();
let mut body = common::Body::new(body);
if !parts.status.is_success() {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let error = serde_json::from_str(&common::to_string(&bytes));
let response = common::to_response(parts, bytes.into());
if let common::Retry::After(d) =
dlg.http_failure(&response, error.as_ref().ok())
{
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(match error {
Ok(value) => common::Error::BadRequest(value),
_ => common::Error::Failure(response),
});
}
let response = {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let encoded = common::to_string(&bytes);
match serde_json::from_str(&encoded) {
Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
Err(error) => {
dlg.response_json_decode_error(&encoded, &error);
return Err(common::Error::JsonDecodeError(
encoded.to_string(),
error,
));
}
}
};
dlg.finished(true);
return Ok(response);
}
}
}
}
///
/// Sets the *request* property to the given value.
///
/// Even though 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, C> {
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, C> {
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, C> {
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, C> {
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 common::Delegate,
) -> PlaylistInsertCall<'a, C> {
self._delegate = Some(new_value);
self
}
/// Set any additional parameter of the query string used in the request.
/// It should be used to set parameters 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<T>(mut self, name: T, value: T) -> PlaylistInsertCall<'a, C>
where
T: AsRef<str>,
{
self._additional_params
.insert(name.as_ref().to_string(), value.as_ref().to_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<St>(mut self, scope: St) -> PlaylistInsertCall<'a, C>
where
St: AsRef<str>,
{
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<I, St>(mut self, scopes: I) -> PlaylistInsertCall<'a, C>
where
I: IntoIterator<Item = St>,
St: AsRef<str>,
{
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, C> {
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 youtube3::{YouTube, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_only()
/// # .enable_http2()
/// # .build();
///
/// # let executor = hyper_util::rt::TokioExecutor::new();
/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// # secret,
/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # yup_oauth2::client::CustomHyperClientBuilder::from(
/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
/// # ),
/// # ).build().await.unwrap();
///
/// # let client = hyper_util::client::legacy::Client::builder(
/// # hyper_util::rt::TokioExecutor::new()
/// # )
/// # .build(
/// # hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_or_http()
/// # .enable_http2()
/// # .build()
/// # );
/// # let mut hub = YouTube::new(client, auth);
/// // You can configure optional parameters by calling 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!["sadipscing".into()])
/// .page_token("ut")
/// .on_behalf_of_content_owner_channel("rebum.")
/// .on_behalf_of_content_owner("duo")
/// .mine(true)
/// .max_results(6)
/// .add_id("tempor")
/// .hl("sea")
/// .channel_id("et")
/// .doit().await;
/// # }
/// ```
pub struct PlaylistListCall<'a, C>
where
C: 'a,
{
hub: &'a YouTube<C>,
_part: Vec<String>,
_page_token: Option<String>,
_on_behalf_of_content_owner_channel: Option<String>,
_on_behalf_of_content_owner: Option<String>,
_mine: Option<bool>,
_max_results: Option<u32>,
_id: Vec<String>,
_hl: Option<String>,
_channel_id: Option<String>,
_delegate: Option<&'a mut dyn common::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>,
}
impl<'a, C> common::CallBuilder for PlaylistListCall<'a, C> {}
impl<'a, C> PlaylistListCall<'a, C>
where
C: common::Connector,
{
/// Perform the operation you have build so far.
pub async fn doit(mut self) -> common::Result<(common::Response, PlaylistListResponse)> {
use std::borrow::Cow;
use std::io::{Read, Seek};
use common::{url::Params, ToParts};
use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
let mut dd = common::DefaultDelegate;
let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(common::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(common::Error::FieldClash(field));
}
}
let mut params = Params::with_capacity(11 + self._additional_params.len());
if !self._part.is_empty() {
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.is_empty() {
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::<Vec<_>>()[..])
.await
{
Ok(token) => token,
Err(e) => match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(common::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(common::to_body::<String>(None));
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let common::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(common::Error::HttpError(err));
}
Ok(res) => {
let (mut parts, body) = res.into_parts();
let mut body = common::Body::new(body);
if !parts.status.is_success() {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let error = serde_json::from_str(&common::to_string(&bytes));
let response = common::to_response(parts, bytes.into());
if let common::Retry::After(d) =
dlg.http_failure(&response, error.as_ref().ok())
{
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(match error {
Ok(value) => common::Error::BadRequest(value),
_ => common::Error::Failure(response),
});
}
let response = {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let encoded = common::to_string(&bytes);
match serde_json::from_str(&encoded) {
Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
Err(error) => {
dlg.response_json_decode_error(&encoded, &error);
return Err(common::Error::JsonDecodeError(
encoded.to_string(),
error,
));
}
}
};
dlg.finished(true);
return Ok(response);
}
}
}
}
/// 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, C> {
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, C> {
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, C> {
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, C> {
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, C> {
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, C> {
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, C> {
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, C> {
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, C> {
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 common::Delegate) -> PlaylistListCall<'a, C> {
self._delegate = Some(new_value);
self
}
/// Set any additional parameter of the query string used in the request.
/// It should be used to set parameters 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<T>(mut self, name: T, value: T) -> PlaylistListCall<'a, C>
where
T: AsRef<str>,
{
self._additional_params
.insert(name.as_ref().to_string(), value.as_ref().to_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<St>(mut self, scope: St) -> PlaylistListCall<'a, C>
where
St: AsRef<str>,
{
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<I, St>(mut self, scopes: I) -> PlaylistListCall<'a, C>
where
I: IntoIterator<Item = St>,
St: AsRef<str>,
{
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, C> {
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 youtube3::{YouTube, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_only()
/// # .enable_http2()
/// # .build();
///
/// # let executor = hyper_util::rt::TokioExecutor::new();
/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// # secret,
/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # yup_oauth2::client::CustomHyperClientBuilder::from(
/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
/// # ),
/// # ).build().await.unwrap();
///
/// # let client = hyper_util::client::legacy::Client::builder(
/// # hyper_util::rt::TokioExecutor::new()
/// # )
/// # .build(
/// # hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_or_http()
/// # .enable_http2()
/// # .build()
/// # );
/// # let mut hub = YouTube::new(client, auth);
/// // As the method needs a request, you would usually fill it with the desired information
/// // into the 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("Lorem")
/// .doit().await;
/// # }
/// ```
pub struct PlaylistUpdateCall<'a, C>
where
C: 'a,
{
hub: &'a YouTube<C>,
_request: Playlist,
_part: Vec<String>,
_on_behalf_of_content_owner: Option<String>,
_delegate: Option<&'a mut dyn common::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>,
}
impl<'a, C> common::CallBuilder for PlaylistUpdateCall<'a, C> {}
impl<'a, C> PlaylistUpdateCall<'a, C>
where
C: common::Connector,
{
/// Perform the operation you have build so far.
pub async fn doit(mut self) -> common::Result<(common::Response, Playlist)> {
use std::borrow::Cow;
use std::io::{Read, Seek};
use common::{url::Params, ToParts};
use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
let mut dd = common::DefaultDelegate;
let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(common::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(common::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.is_empty() {
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 = serde_json::value::to_value(&self._request).expect("serde to work");
common::remove_json_null_values(&mut value);
let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
serde_json::to_writer(&mut dst, &value).unwrap();
dst
};
let request_size = request_value_reader
.seek(std::io::SeekFrom::End(0))
.unwrap();
request_value_reader
.seek(std::io::SeekFrom::Start(0))
.unwrap();
loop {
let token = match self
.hub
.auth
.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
.await
{
Ok(token) => token,
Err(e) => match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(common::Error::MissingToken(e));
}
},
};
request_value_reader
.seek(std::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(common::to_body(
request_value_reader.get_ref().clone().into(),
));
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let common::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(common::Error::HttpError(err));
}
Ok(res) => {
let (mut parts, body) = res.into_parts();
let mut body = common::Body::new(body);
if !parts.status.is_success() {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let error = serde_json::from_str(&common::to_string(&bytes));
let response = common::to_response(parts, bytes.into());
if let common::Retry::After(d) =
dlg.http_failure(&response, error.as_ref().ok())
{
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(match error {
Ok(value) => common::Error::BadRequest(value),
_ => common::Error::Failure(response),
});
}
let response = {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let encoded = common::to_string(&bytes);
match serde_json::from_str(&encoded) {
Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
Err(error) => {
dlg.response_json_decode_error(&encoded, &error);
return Err(common::Error::JsonDecodeError(
encoded.to_string(),
error,
));
}
}
};
dlg.finished(true);
return Ok(response);
}
}
}
}
///
/// Sets the *request* property to the given value.
///
/// Even though 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, C> {
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, C> {
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, C> {
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 common::Delegate,
) -> PlaylistUpdateCall<'a, C> {
self._delegate = Some(new_value);
self
}
/// Set any additional parameter of the query string used in the request.
/// It should be used to set parameters 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<T>(mut self, name: T, value: T) -> PlaylistUpdateCall<'a, C>
where
T: AsRef<str>,
{
self._additional_params
.insert(name.as_ref().to_string(), value.as_ref().to_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<St>(mut self, scope: St) -> PlaylistUpdateCall<'a, C>
where
St: AsRef<str>,
{
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<I, St>(mut self, scopes: I) -> PlaylistUpdateCall<'a, C>
where
I: IntoIterator<Item = St>,
St: AsRef<str>,
{
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, C> {
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 youtube3::{YouTube, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_only()
/// # .enable_http2()
/// # .build();
///
/// # let executor = hyper_util::rt::TokioExecutor::new();
/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// # secret,
/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # yup_oauth2::client::CustomHyperClientBuilder::from(
/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
/// # ),
/// # ).build().await.unwrap();
///
/// # let client = hyper_util::client::legacy::Client::builder(
/// # hyper_util::rt::TokioExecutor::new()
/// # )
/// # .build(
/// # hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_or_http()
/// # .enable_http2()
/// # .build()
/// # );
/// # let mut hub = YouTube::new(client, auth);
/// // You can configure optional parameters by calling 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!["magna".into()])
/// .video_type("takimata")
/// .video_syndicated("rebum.")
/// .video_paid_product_placement("At")
/// .video_license("invidunt")
/// .video_embeddable("clita")
/// .video_duration("Stet")
/// .video_dimension("aliquyam")
/// .video_definition("ut")
/// .video_category_id("sit")
/// .video_caption("vero")
/// .add_type("rebum.")
/// .topic_id("dolores")
/// .safe_search("consetetur")
/// .relevance_language("dolores")
/// .region_code("sed")
/// .q("invidunt")
/// .published_before(chrono::Utc::now())
/// .published_after(chrono::Utc::now())
/// .page_token("clita")
/// .order("dolor")
/// .on_behalf_of_content_owner("aliquyam")
/// .max_results(18)
/// .location_radius("diam")
/// .location("nonumy")
/// .for_mine(true)
/// .for_developer(true)
/// .for_content_owner(false)
/// .event_type("diam")
/// .channel_type("At")
/// .channel_id("erat")
/// .doit().await;
/// # }
/// ```
pub struct SearchListCall<'a, C>
where
C: 'a,
{
hub: &'a YouTube<C>,
_part: Vec<String>,
_video_type: Option<String>,
_video_syndicated: Option<String>,
_video_paid_product_placement: Option<String>,
_video_license: Option<String>,
_video_embeddable: Option<String>,
_video_duration: Option<String>,
_video_dimension: Option<String>,
_video_definition: Option<String>,
_video_category_id: Option<String>,
_video_caption: Option<String>,
_type_: Vec<String>,
_topic_id: Option<String>,
_safe_search: Option<String>,
_relevance_language: Option<String>,
_region_code: Option<String>,
_q: Option<String>,
_published_before: Option<chrono::DateTime<chrono::offset::Utc>>,
_published_after: Option<chrono::DateTime<chrono::offset::Utc>>,
_page_token: Option<String>,
_order: Option<String>,
_on_behalf_of_content_owner: Option<String>,
_max_results: Option<u32>,
_location_radius: Option<String>,
_location: Option<String>,
_for_mine: Option<bool>,
_for_developer: Option<bool>,
_for_content_owner: Option<bool>,
_event_type: Option<String>,
_channel_type: Option<String>,
_channel_id: Option<String>,
_delegate: Option<&'a mut dyn common::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>,
}
impl<'a, C> common::CallBuilder for SearchListCall<'a, C> {}
impl<'a, C> SearchListCall<'a, C>
where
C: common::Connector,
{
/// Perform the operation you have build so far.
pub async fn doit(mut self) -> common::Result<(common::Response, SearchListResponse)> {
use std::borrow::Cow;
use std::io::{Read, Seek};
use common::{url::Params, ToParts};
use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
let mut dd = common::DefaultDelegate;
let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(common::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(common::Error::FieldClash(field));
}
}
let mut params = Params::with_capacity(33 + self._additional_params.len());
if !self._part.is_empty() {
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_.is_empty() {
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", common::serde::datetime_to_string(&value));
}
if let Some(value) = self._published_after.as_ref() {
params.push("publishedAfter", common::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::<Vec<_>>()[..])
.await
{
Ok(token) => token,
Err(e) => match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(common::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(common::to_body::<String>(None));
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let common::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(common::Error::HttpError(err));
}
Ok(res) => {
let (mut parts, body) = res.into_parts();
let mut body = common::Body::new(body);
if !parts.status.is_success() {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let error = serde_json::from_str(&common::to_string(&bytes));
let response = common::to_response(parts, bytes.into());
if let common::Retry::After(d) =
dlg.http_failure(&response, error.as_ref().ok())
{
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(match error {
Ok(value) => common::Error::BadRequest(value),
_ => common::Error::Failure(response),
});
}
let response = {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let encoded = common::to_string(&bytes);
match serde_json::from_str(&encoded) {
Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
Err(error) => {
dlg.response_json_decode_error(&encoded, &error);
return Err(common::Error::JsonDecodeError(
encoded.to_string(),
error,
));
}
}
};
dlg.finished(true);
return Ok(response);
}
}
}
}
/// 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, C> {
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: &str) -> SearchListCall<'a, C> {
self._video_type = Some(new_value.to_string());
self
}
/// Filter on syndicated videos.
///
/// Sets the *video syndicated* query property to the given value.
pub fn video_syndicated(mut self, new_value: &str) -> SearchListCall<'a, C> {
self._video_syndicated = Some(new_value.to_string());
self
}
///
/// Sets the *video paid product placement* query property to the given value.
pub fn video_paid_product_placement(mut self, new_value: &str) -> SearchListCall<'a, C> {
self._video_paid_product_placement = Some(new_value.to_string());
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: &str) -> SearchListCall<'a, C> {
self._video_license = Some(new_value.to_string());
self
}
/// Filter on embeddable videos.
///
/// Sets the *video embeddable* query property to the given value.
pub fn video_embeddable(mut self, new_value: &str) -> SearchListCall<'a, C> {
self._video_embeddable = Some(new_value.to_string());
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: &str) -> SearchListCall<'a, C> {
self._video_duration = Some(new_value.to_string());
self
}
/// Filter on 3d videos.
///
/// Sets the *video dimension* query property to the given value.
pub fn video_dimension(mut self, new_value: &str) -> SearchListCall<'a, C> {
self._video_dimension = Some(new_value.to_string());
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: &str) -> SearchListCall<'a, C> {
self._video_definition = Some(new_value.to_string());
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, C> {
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: &str) -> SearchListCall<'a, C> {
self._video_caption = Some(new_value.to_string());
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, C> {
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, C> {
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: &str) -> SearchListCall<'a, C> {
self._safe_search = Some(new_value.to_string());
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, C> {
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, C> {
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, C> {
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: chrono::DateTime<chrono::offset::Utc>,
) -> SearchListCall<'a, C> {
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: chrono::DateTime<chrono::offset::Utc>,
) -> SearchListCall<'a, C> {
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, C> {
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: &str) -> SearchListCall<'a, C> {
self._order = 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) -> SearchListCall<'a, C> {
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, C> {
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, C> {
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, C> {
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, C> {
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, C> {
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, C> {
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: &str) -> SearchListCall<'a, C> {
self._event_type = Some(new_value.to_string());
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: &str) -> SearchListCall<'a, C> {
self._channel_type = Some(new_value.to_string());
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, C> {
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 common::Delegate) -> SearchListCall<'a, C> {
self._delegate = Some(new_value);
self
}
/// Set any additional parameter of the query string used in the request.
/// It should be used to set parameters 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<T>(mut self, name: T, value: T) -> SearchListCall<'a, C>
where
T: AsRef<str>,
{
self._additional_params
.insert(name.as_ref().to_string(), value.as_ref().to_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<St>(mut self, scope: St) -> SearchListCall<'a, C>
where
St: AsRef<str>,
{
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<I, St>(mut self, scopes: I) -> SearchListCall<'a, C>
where
I: IntoIterator<Item = St>,
St: AsRef<str>,
{
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, C> {
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 youtube3::{YouTube, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_only()
/// # .enable_http2()
/// # .build();
///
/// # let executor = hyper_util::rt::TokioExecutor::new();
/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// # secret,
/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # yup_oauth2::client::CustomHyperClientBuilder::from(
/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
/// # ),
/// # ).build().await.unwrap();
///
/// # let client = hyper_util::client::legacy::Client::builder(
/// # hyper_util::rt::TokioExecutor::new()
/// # )
/// # .build(
/// # hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_or_http()
/// # .enable_http2()
/// # .build()
/// # );
/// # let mut hub = YouTube::new(client, auth);
/// // You can configure optional parameters by calling 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, C>
where
C: 'a,
{
hub: &'a YouTube<C>,
_id: String,
_delegate: Option<&'a mut dyn common::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>,
}
impl<'a, C> common::CallBuilder for SubscriptionDeleteCall<'a, C> {}
impl<'a, C> SubscriptionDeleteCall<'a, C>
where
C: common::Connector,
{
/// Perform the operation you have build so far.
pub async fn doit(mut self) -> common::Result<common::Response> {
use std::borrow::Cow;
use std::io::{Read, Seek};
use common::{url::Params, ToParts};
use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
let mut dd = common::DefaultDelegate;
let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(common::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(common::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::<Vec<_>>()[..])
.await
{
Ok(token) => token,
Err(e) => match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(common::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(common::to_body::<String>(None));
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let common::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(common::Error::HttpError(err));
}
Ok(res) => {
let (mut parts, body) = res.into_parts();
let mut body = common::Body::new(body);
if !parts.status.is_success() {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let error = serde_json::from_str(&common::to_string(&bytes));
let response = common::to_response(parts, bytes.into());
if let common::Retry::After(d) =
dlg.http_failure(&response, error.as_ref().ok())
{
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(match error {
Ok(value) => common::Error::BadRequest(value),
_ => common::Error::Failure(response),
});
}
let response = common::Response::from_parts(parts, body);
dlg.finished(true);
return Ok(response);
}
}
}
}
///
/// 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, C> {
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 common::Delegate,
) -> SubscriptionDeleteCall<'a, C> {
self._delegate = Some(new_value);
self
}
/// Set any additional parameter of the query string used in the request.
/// It should be used to set parameters 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<T>(mut self, name: T, value: T) -> SubscriptionDeleteCall<'a, C>
where
T: AsRef<str>,
{
self._additional_params
.insert(name.as_ref().to_string(), value.as_ref().to_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<St>(mut self, scope: St) -> SubscriptionDeleteCall<'a, C>
where
St: AsRef<str>,
{
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<I, St>(mut self, scopes: I) -> SubscriptionDeleteCall<'a, C>
where
I: IntoIterator<Item = St>,
St: AsRef<str>,
{
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, C> {
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 youtube3::{YouTube, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_only()
/// # .enable_http2()
/// # .build();
///
/// # let executor = hyper_util::rt::TokioExecutor::new();
/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// # secret,
/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # yup_oauth2::client::CustomHyperClientBuilder::from(
/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
/// # ),
/// # ).build().await.unwrap();
///
/// # let client = hyper_util::client::legacy::Client::builder(
/// # hyper_util::rt::TokioExecutor::new()
/// # )
/// # .build(
/// # hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_or_http()
/// # .enable_http2()
/// # .build()
/// # );
/// # let mut hub = YouTube::new(client, auth);
/// // As the method needs a request, you would usually fill it with the desired information
/// // into the 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, C>
where
C: 'a,
{
hub: &'a YouTube<C>,
_request: Subscription,
_part: Vec<String>,
_delegate: Option<&'a mut dyn common::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>,
}
impl<'a, C> common::CallBuilder for SubscriptionInsertCall<'a, C> {}
impl<'a, C> SubscriptionInsertCall<'a, C>
where
C: common::Connector,
{
/// Perform the operation you have build so far.
pub async fn doit(mut self) -> common::Result<(common::Response, Subscription)> {
use std::borrow::Cow;
use std::io::{Read, Seek};
use common::{url::Params, ToParts};
use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
let mut dd = common::DefaultDelegate;
let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(common::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(common::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.is_empty() {
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 = serde_json::value::to_value(&self._request).expect("serde to work");
common::remove_json_null_values(&mut value);
let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
serde_json::to_writer(&mut dst, &value).unwrap();
dst
};
let request_size = request_value_reader
.seek(std::io::SeekFrom::End(0))
.unwrap();
request_value_reader
.seek(std::io::SeekFrom::Start(0))
.unwrap();
loop {
let token = match self
.hub
.auth
.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
.await
{
Ok(token) => token,
Err(e) => match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(common::Error::MissingToken(e));
}
},
};
request_value_reader
.seek(std::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(common::to_body(
request_value_reader.get_ref().clone().into(),
));
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let common::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(common::Error::HttpError(err));
}
Ok(res) => {
let (mut parts, body) = res.into_parts();
let mut body = common::Body::new(body);
if !parts.status.is_success() {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let error = serde_json::from_str(&common::to_string(&bytes));
let response = common::to_response(parts, bytes.into());
if let common::Retry::After(d) =
dlg.http_failure(&response, error.as_ref().ok())
{
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(match error {
Ok(value) => common::Error::BadRequest(value),
_ => common::Error::Failure(response),
});
}
let response = {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let encoded = common::to_string(&bytes);
match serde_json::from_str(&encoded) {
Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
Err(error) => {
dlg.response_json_decode_error(&encoded, &error);
return Err(common::Error::JsonDecodeError(
encoded.to_string(),
error,
));
}
}
};
dlg.finished(true);
return Ok(response);
}
}
}
}
///
/// Sets the *request* property to the given value.
///
/// Even though 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, C> {
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, C> {
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 common::Delegate,
) -> SubscriptionInsertCall<'a, C> {
self._delegate = Some(new_value);
self
}
/// Set any additional parameter of the query string used in the request.
/// It should be used to set parameters 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<T>(mut self, name: T, value: T) -> SubscriptionInsertCall<'a, C>
where
T: AsRef<str>,
{
self._additional_params
.insert(name.as_ref().to_string(), value.as_ref().to_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<St>(mut self, scope: St) -> SubscriptionInsertCall<'a, C>
where
St: AsRef<str>,
{
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<I, St>(mut self, scopes: I) -> SubscriptionInsertCall<'a, C>
where
I: IntoIterator<Item = St>,
St: AsRef<str>,
{
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, C> {
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 youtube3::{YouTube, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_only()
/// # .enable_http2()
/// # .build();
///
/// # let executor = hyper_util::rt::TokioExecutor::new();
/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// # secret,
/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # yup_oauth2::client::CustomHyperClientBuilder::from(
/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
/// # ),
/// # ).build().await.unwrap();
///
/// # let client = hyper_util::client::legacy::Client::builder(
/// # hyper_util::rt::TokioExecutor::new()
/// # )
/// # .build(
/// # hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_or_http()
/// # .enable_http2()
/// # .build()
/// # );
/// # let mut hub = YouTube::new(client, auth);
/// // You can configure optional parameters by calling 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!["ipsum".into()])
/// .page_token("accusam")
/// .order("dolores")
/// .on_behalf_of_content_owner_channel("consetetur")
/// .on_behalf_of_content_owner("no")
/// .my_subscribers(true)
/// .my_recent_subscribers(true)
/// .mine(true)
/// .max_results(86)
/// .add_id("gubergren")
/// .for_channel_id("ipsum")
/// .channel_id("no")
/// .doit().await;
/// # }
/// ```
pub struct SubscriptionListCall<'a, C>
where
C: 'a,
{
hub: &'a YouTube<C>,
_part: Vec<String>,
_page_token: Option<String>,
_order: Option<String>,
_on_behalf_of_content_owner_channel: Option<String>,
_on_behalf_of_content_owner: Option<String>,
_my_subscribers: Option<bool>,
_my_recent_subscribers: Option<bool>,
_mine: Option<bool>,
_max_results: Option<u32>,
_id: Vec<String>,
_for_channel_id: Option<String>,
_channel_id: Option<String>,
_delegate: Option<&'a mut dyn common::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>,
}
impl<'a, C> common::CallBuilder for SubscriptionListCall<'a, C> {}
impl<'a, C> SubscriptionListCall<'a, C>
where
C: common::Connector,
{
/// Perform the operation you have build so far.
pub async fn doit(mut self) -> common::Result<(common::Response, SubscriptionListResponse)> {
use std::borrow::Cow;
use std::io::{Read, Seek};
use common::{url::Params, ToParts};
use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
let mut dd = common::DefaultDelegate;
let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(common::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(common::Error::FieldClash(field));
}
}
let mut params = Params::with_capacity(14 + self._additional_params.len());
if !self._part.is_empty() {
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.is_empty() {
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::<Vec<_>>()[..])
.await
{
Ok(token) => token,
Err(e) => match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(common::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(common::to_body::<String>(None));
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let common::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(common::Error::HttpError(err));
}
Ok(res) => {
let (mut parts, body) = res.into_parts();
let mut body = common::Body::new(body);
if !parts.status.is_success() {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let error = serde_json::from_str(&common::to_string(&bytes));
let response = common::to_response(parts, bytes.into());
if let common::Retry::After(d) =
dlg.http_failure(&response, error.as_ref().ok())
{
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(match error {
Ok(value) => common::Error::BadRequest(value),
_ => common::Error::Failure(response),
});
}
let response = {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let encoded = common::to_string(&bytes);
match serde_json::from_str(&encoded) {
Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
Err(error) => {
dlg.response_json_decode_error(&encoded, &error);
return Err(common::Error::JsonDecodeError(
encoded.to_string(),
error,
));
}
}
};
dlg.finished(true);
return Ok(response);
}
}
}
}
/// 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, C> {
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, C> {
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: &str) -> SubscriptionListCall<'a, C> {
self._order = 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,
) -> SubscriptionListCall<'a, C> {
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, C> {
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, C> {
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, C> {
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, C> {
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, C> {
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, C> {
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, C> {
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, C> {
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 common::Delegate,
) -> SubscriptionListCall<'a, C> {
self._delegate = Some(new_value);
self
}
/// Set any additional parameter of the query string used in the request.
/// It should be used to set parameters 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<T>(mut self, name: T, value: T) -> SubscriptionListCall<'a, C>
where
T: AsRef<str>,
{
self._additional_params
.insert(name.as_ref().to_string(), value.as_ref().to_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<St>(mut self, scope: St) -> SubscriptionListCall<'a, C>
where
St: AsRef<str>,
{
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<I, St>(mut self, scopes: I) -> SubscriptionListCall<'a, C>
where
I: IntoIterator<Item = St>,
St: AsRef<str>,
{
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, C> {
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 youtube3::{YouTube, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_only()
/// # .enable_http2()
/// # .build();
///
/// # let executor = hyper_util::rt::TokioExecutor::new();
/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// # secret,
/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # yup_oauth2::client::CustomHyperClientBuilder::from(
/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
/// # ),
/// # ).build().await.unwrap();
///
/// # let client = hyper_util::client::legacy::Client::builder(
/// # hyper_util::rt::TokioExecutor::new()
/// # )
/// # .build(
/// # hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_or_http()
/// # .enable_http2()
/// # .build()
/// # );
/// # let mut hub = YouTube::new(client, auth);
/// // You can configure optional parameters by calling 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!["sit".into()])
/// .page_token("kasd")
/// .max_results(54)
/// .hl("Lorem")
/// .doit().await;
/// # }
/// ```
pub struct SuperChatEventListCall<'a, C>
where
C: 'a,
{
hub: &'a YouTube<C>,
_part: Vec<String>,
_page_token: Option<String>,
_max_results: Option<u32>,
_hl: Option<String>,
_delegate: Option<&'a mut dyn common::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>,
}
impl<'a, C> common::CallBuilder for SuperChatEventListCall<'a, C> {}
impl<'a, C> SuperChatEventListCall<'a, C>
where
C: common::Connector,
{
/// Perform the operation you have build so far.
pub async fn doit(mut self) -> common::Result<(common::Response, SuperChatEventListResponse)> {
use std::borrow::Cow;
use std::io::{Read, Seek};
use common::{url::Params, ToParts};
use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
let mut dd = common::DefaultDelegate;
let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(common::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(common::Error::FieldClash(field));
}
}
let mut params = Params::with_capacity(6 + self._additional_params.len());
if !self._part.is_empty() {
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::<Vec<_>>()[..])
.await
{
Ok(token) => token,
Err(e) => match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(common::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(common::to_body::<String>(None));
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let common::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(common::Error::HttpError(err));
}
Ok(res) => {
let (mut parts, body) = res.into_parts();
let mut body = common::Body::new(body);
if !parts.status.is_success() {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let error = serde_json::from_str(&common::to_string(&bytes));
let response = common::to_response(parts, bytes.into());
if let common::Retry::After(d) =
dlg.http_failure(&response, error.as_ref().ok())
{
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(match error {
Ok(value) => common::Error::BadRequest(value),
_ => common::Error::Failure(response),
});
}
let response = {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let encoded = common::to_string(&bytes);
match serde_json::from_str(&encoded) {
Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
Err(error) => {
dlg.response_json_decode_error(&encoded, &error);
return Err(common::Error::JsonDecodeError(
encoded.to_string(),
error,
));
}
}
};
dlg.finished(true);
return Ok(response);
}
}
}
}
/// 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, C> {
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, C> {
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, C> {
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, C> {
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 common::Delegate,
) -> SuperChatEventListCall<'a, C> {
self._delegate = Some(new_value);
self
}
/// Set any additional parameter of the query string used in the request.
/// It should be used to set parameters 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<T>(mut self, name: T, value: T) -> SuperChatEventListCall<'a, C>
where
T: AsRef<str>,
{
self._additional_params
.insert(name.as_ref().to_string(), value.as_ref().to_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<St>(mut self, scope: St) -> SuperChatEventListCall<'a, C>
where
St: AsRef<str>,
{
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<I, St>(mut self, scopes: I) -> SuperChatEventListCall<'a, C>
where
I: IntoIterator<Item = St>,
St: AsRef<str>,
{
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, C> {
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 youtube3::{YouTube, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_only()
/// # .enable_http2()
/// # .build();
///
/// # let executor = hyper_util::rt::TokioExecutor::new();
/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// # secret,
/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # yup_oauth2::client::CustomHyperClientBuilder::from(
/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
/// # ),
/// # ).build().await.unwrap();
///
/// # let client = hyper_util::client::legacy::Client::builder(
/// # hyper_util::rt::TokioExecutor::new()
/// # )
/// # .build(
/// # hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_or_http()
/// # .enable_http2()
/// # .build()
/// # );
/// # let mut hub = YouTube::new(client, auth);
/// // As the method needs a request, you would usually fill it with the desired information
/// // into the 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("justo")
/// .doit().await;
/// # }
/// ```
pub struct TestInsertCall<'a, C>
where
C: 'a,
{
hub: &'a YouTube<C>,
_request: TestItem,
_part: Vec<String>,
_external_channel_id: Option<String>,
_delegate: Option<&'a mut dyn common::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>,
}
impl<'a, C> common::CallBuilder for TestInsertCall<'a, C> {}
impl<'a, C> TestInsertCall<'a, C>
where
C: common::Connector,
{
/// Perform the operation you have build so far.
pub async fn doit(mut self) -> common::Result<(common::Response, TestItem)> {
use std::borrow::Cow;
use std::io::{Read, Seek};
use common::{url::Params, ToParts};
use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
let mut dd = common::DefaultDelegate;
let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(common::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(common::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.is_empty() {
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 = serde_json::value::to_value(&self._request).expect("serde to work");
common::remove_json_null_values(&mut value);
let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
serde_json::to_writer(&mut dst, &value).unwrap();
dst
};
let request_size = request_value_reader
.seek(std::io::SeekFrom::End(0))
.unwrap();
request_value_reader
.seek(std::io::SeekFrom::Start(0))
.unwrap();
loop {
let token = match self
.hub
.auth
.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
.await
{
Ok(token) => token,
Err(e) => match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(common::Error::MissingToken(e));
}
},
};
request_value_reader
.seek(std::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(common::to_body(
request_value_reader.get_ref().clone().into(),
));
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let common::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(common::Error::HttpError(err));
}
Ok(res) => {
let (mut parts, body) = res.into_parts();
let mut body = common::Body::new(body);
if !parts.status.is_success() {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let error = serde_json::from_str(&common::to_string(&bytes));
let response = common::to_response(parts, bytes.into());
if let common::Retry::After(d) =
dlg.http_failure(&response, error.as_ref().ok())
{
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(match error {
Ok(value) => common::Error::BadRequest(value),
_ => common::Error::Failure(response),
});
}
let response = {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let encoded = common::to_string(&bytes);
match serde_json::from_str(&encoded) {
Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
Err(error) => {
dlg.response_json_decode_error(&encoded, &error);
return Err(common::Error::JsonDecodeError(
encoded.to_string(),
error,
));
}
}
};
dlg.finished(true);
return Ok(response);
}
}
}
}
///
/// Sets the *request* property to the given value.
///
/// Even though 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, C> {
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, C> {
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, C> {
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 common::Delegate) -> TestInsertCall<'a, C> {
self._delegate = Some(new_value);
self
}
/// Set any additional parameter of the query string used in the request.
/// It should be used to set parameters 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<T>(mut self, name: T, value: T) -> TestInsertCall<'a, C>
where
T: AsRef<str>,
{
self._additional_params
.insert(name.as_ref().to_string(), value.as_ref().to_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<St>(mut self, scope: St) -> TestInsertCall<'a, C>
where
St: AsRef<str>,
{
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<I, St>(mut self, scopes: I) -> TestInsertCall<'a, C>
where
I: IntoIterator<Item = St>,
St: AsRef<str>,
{
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, C> {
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 youtube3::{YouTube, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_only()
/// # .enable_http2()
/// # .build();
///
/// # let executor = hyper_util::rt::TokioExecutor::new();
/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// # secret,
/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # yup_oauth2::client::CustomHyperClientBuilder::from(
/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
/// # ),
/// # ).build().await.unwrap();
///
/// # let client = hyper_util::client::legacy::Client::builder(
/// # hyper_util::rt::TokioExecutor::new()
/// # )
/// # .build(
/// # hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_or_http()
/// # .enable_http2()
/// # .build()
/// # );
/// # let mut hub = YouTube::new(client, auth);
/// // You can configure optional parameters by calling 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", "type")
/// .add_part("nonumy")
/// .external_channel_id("sea")
/// .doit().await;
/// # }
/// ```
pub struct ThirdPartyLinkDeleteCall<'a, C>
where
C: 'a,
{
hub: &'a YouTube<C>,
_linking_token: String,
_type_: String,
_part: Vec<String>,
_external_channel_id: Option<String>,
_delegate: Option<&'a mut dyn common::Delegate>,
_additional_params: HashMap<String, String>,
}
impl<'a, C> common::CallBuilder for ThirdPartyLinkDeleteCall<'a, C> {}
impl<'a, C> ThirdPartyLinkDeleteCall<'a, C>
where
C: common::Connector,
{
/// Perform the operation you have build so far.
pub async fn doit(mut self) -> common::Result<common::Response> {
use std::borrow::Cow;
use std::io::{Read, Seek};
use common::{url::Params, ToParts};
use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
let mut dd = common::DefaultDelegate;
let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(common::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(common::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.is_empty() {
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(common::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(common::to_body::<String>(None));
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let common::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(common::Error::HttpError(err));
}
Ok(res) => {
let (mut parts, body) = res.into_parts();
let mut body = common::Body::new(body);
if !parts.status.is_success() {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let error = serde_json::from_str(&common::to_string(&bytes));
let response = common::to_response(parts, bytes.into());
if let common::Retry::After(d) =
dlg.http_failure(&response, error.as_ref().ok())
{
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(match error {
Ok(value) => common::Error::BadRequest(value),
_ => common::Error::Failure(response),
});
}
let response = common::Response::from_parts(parts, body);
dlg.finished(true);
return Ok(response);
}
}
}
}
/// 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, C> {
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: &str) -> ThirdPartyLinkDeleteCall<'a, C> {
self._type_ = new_value.to_string();
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, C> {
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, C> {
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 common::Delegate,
) -> ThirdPartyLinkDeleteCall<'a, C> {
self._delegate = Some(new_value);
self
}
/// Set any additional parameter of the query string used in the request.
/// It should be used to set parameters 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<T>(mut self, name: T, value: T) -> ThirdPartyLinkDeleteCall<'a, C>
where
T: AsRef<str>,
{
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 youtube3::{YouTube, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_only()
/// # .enable_http2()
/// # .build();
///
/// # let executor = hyper_util::rt::TokioExecutor::new();
/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// # secret,
/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # yup_oauth2::client::CustomHyperClientBuilder::from(
/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
/// # ),
/// # ).build().await.unwrap();
///
/// # let client = hyper_util::client::legacy::Client::builder(
/// # hyper_util::rt::TokioExecutor::new()
/// # )
/// # .build(
/// # hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_or_http()
/// # .enable_http2()
/// # .build()
/// # );
/// # let mut hub = YouTube::new(client, auth);
/// // As the method needs a request, you would usually fill it with the desired information
/// // into the 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().insert(req)
/// .external_channel_id("kasd")
/// .doit().await;
/// # }
/// ```
pub struct ThirdPartyLinkInsertCall<'a, C>
where
C: 'a,
{
hub: &'a YouTube<C>,
_request: ThirdPartyLink,
_part: Vec<String>,
_external_channel_id: Option<String>,
_delegate: Option<&'a mut dyn common::Delegate>,
_additional_params: HashMap<String, String>,
}
impl<'a, C> common::CallBuilder for ThirdPartyLinkInsertCall<'a, C> {}
impl<'a, C> ThirdPartyLinkInsertCall<'a, C>
where
C: common::Connector,
{
/// Perform the operation you have build so far.
pub async fn doit(mut self) -> common::Result<(common::Response, ThirdPartyLink)> {
use std::borrow::Cow;
use std::io::{Read, Seek};
use common::{url::Params, ToParts};
use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
let mut dd = common::DefaultDelegate;
let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(common::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(common::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.is_empty() {
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(common::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 = serde_json::value::to_value(&self._request).expect("serde to work");
common::remove_json_null_values(&mut value);
let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
serde_json::to_writer(&mut dst, &value).unwrap();
dst
};
let request_size = request_value_reader
.seek(std::io::SeekFrom::End(0))
.unwrap();
request_value_reader
.seek(std::io::SeekFrom::Start(0))
.unwrap();
loop {
request_value_reader
.seek(std::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(common::to_body(
request_value_reader.get_ref().clone().into(),
));
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let common::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(common::Error::HttpError(err));
}
Ok(res) => {
let (mut parts, body) = res.into_parts();
let mut body = common::Body::new(body);
if !parts.status.is_success() {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let error = serde_json::from_str(&common::to_string(&bytes));
let response = common::to_response(parts, bytes.into());
if let common::Retry::After(d) =
dlg.http_failure(&response, error.as_ref().ok())
{
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(match error {
Ok(value) => common::Error::BadRequest(value),
_ => common::Error::Failure(response),
});
}
let response = {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let encoded = common::to_string(&bytes);
match serde_json::from_str(&encoded) {
Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
Err(error) => {
dlg.response_json_decode_error(&encoded, &error);
return Err(common::Error::JsonDecodeError(
encoded.to_string(),
error,
));
}
}
};
dlg.finished(true);
return Ok(response);
}
}
}
}
///
/// Sets the *request* 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, C> {
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, C> {
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, C> {
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 common::Delegate,
) -> ThirdPartyLinkInsertCall<'a, C> {
self._delegate = Some(new_value);
self
}
/// Set any additional parameter of the query string used in the request.
/// It should be used to set parameters 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<T>(mut self, name: T, value: T) -> ThirdPartyLinkInsertCall<'a, C>
where
T: AsRef<str>,
{
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 youtube3::{YouTube, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_only()
/// # .enable_http2()
/// # .build();
///
/// # let executor = hyper_util::rt::TokioExecutor::new();
/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// # secret,
/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # yup_oauth2::client::CustomHyperClientBuilder::from(
/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
/// # ),
/// # ).build().await.unwrap();
///
/// # let client = hyper_util::client::legacy::Client::builder(
/// # hyper_util::rt::TokioExecutor::new()
/// # )
/// # .build(
/// # hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_or_http()
/// # .enable_http2()
/// # .build()
/// # );
/// # let mut hub = YouTube::new(client, auth);
/// // You can configure optional parameters by calling 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!["justo".into()])
/// .type_("ea")
/// .linking_token("At")
/// .external_channel_id("erat")
/// .doit().await;
/// # }
/// ```
pub struct ThirdPartyLinkListCall<'a, C>
where
C: 'a,
{
hub: &'a YouTube<C>,
_part: Vec<String>,
_type_: Option<String>,
_linking_token: Option<String>,
_external_channel_id: Option<String>,
_delegate: Option<&'a mut dyn common::Delegate>,
_additional_params: HashMap<String, String>,
}
impl<'a, C> common::CallBuilder for ThirdPartyLinkListCall<'a, C> {}
impl<'a, C> ThirdPartyLinkListCall<'a, C>
where
C: common::Connector,
{
/// Perform the operation you have build so far.
pub async fn doit(mut self) -> common::Result<(common::Response, ThirdPartyLinkListResponse)> {
use std::borrow::Cow;
use std::io::{Read, Seek};
use common::{url::Params, ToParts};
use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
let mut dd = common::DefaultDelegate;
let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(common::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(common::Error::FieldClash(field));
}
}
let mut params = Params::with_capacity(6 + self._additional_params.len());
if !self._part.is_empty() {
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(common::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(common::to_body::<String>(None));
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let common::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(common::Error::HttpError(err));
}
Ok(res) => {
let (mut parts, body) = res.into_parts();
let mut body = common::Body::new(body);
if !parts.status.is_success() {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let error = serde_json::from_str(&common::to_string(&bytes));
let response = common::to_response(parts, bytes.into());
if let common::Retry::After(d) =
dlg.http_failure(&response, error.as_ref().ok())
{
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(match error {
Ok(value) => common::Error::BadRequest(value),
_ => common::Error::Failure(response),
});
}
let response = {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let encoded = common::to_string(&bytes);
match serde_json::from_str(&encoded) {
Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
Err(error) => {
dlg.response_json_decode_error(&encoded, &error);
return Err(common::Error::JsonDecodeError(
encoded.to_string(),
error,
));
}
}
};
dlg.finished(true);
return Ok(response);
}
}
}
}
/// 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, C> {
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: &str) -> ThirdPartyLinkListCall<'a, C> {
self._type_ = Some(new_value.to_string());
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, C> {
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, C> {
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 common::Delegate,
) -> ThirdPartyLinkListCall<'a, C> {
self._delegate = Some(new_value);
self
}
/// Set any additional parameter of the query string used in the request.
/// It should be used to set parameters 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<T>(mut self, name: T, value: T) -> ThirdPartyLinkListCall<'a, C>
where
T: AsRef<str>,
{
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 youtube3::{YouTube, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_only()
/// # .enable_http2()
/// # .build();
///
/// # let executor = hyper_util::rt::TokioExecutor::new();
/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// # secret,
/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # yup_oauth2::client::CustomHyperClientBuilder::from(
/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
/// # ),
/// # ).build().await.unwrap();
///
/// # let client = hyper_util::client::legacy::Client::builder(
/// # hyper_util::rt::TokioExecutor::new()
/// # )
/// # .build(
/// # hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_or_http()
/// # .enable_http2()
/// # .build()
/// # );
/// # let mut hub = YouTube::new(client, auth);
/// // As the method needs a request, you would usually fill it with the desired information
/// // into the 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("clita".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("vero")
/// .doit().await;
/// # }
/// ```
pub struct ThirdPartyLinkUpdateCall<'a, C>
where
C: 'a,
{
hub: &'a YouTube<C>,
_request: ThirdPartyLink,
_part: Vec<String>,
_external_channel_id: Option<String>,
_delegate: Option<&'a mut dyn common::Delegate>,
_additional_params: HashMap<String, String>,
}
impl<'a, C> common::CallBuilder for ThirdPartyLinkUpdateCall<'a, C> {}
impl<'a, C> ThirdPartyLinkUpdateCall<'a, C>
where
C: common::Connector,
{
/// Perform the operation you have build so far.
pub async fn doit(mut self) -> common::Result<(common::Response, ThirdPartyLink)> {
use std::borrow::Cow;
use std::io::{Read, Seek};
use common::{url::Params, ToParts};
use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
let mut dd = common::DefaultDelegate;
let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(common::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(common::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.is_empty() {
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(common::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 = serde_json::value::to_value(&self._request).expect("serde to work");
common::remove_json_null_values(&mut value);
let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
serde_json::to_writer(&mut dst, &value).unwrap();
dst
};
let request_size = request_value_reader
.seek(std::io::SeekFrom::End(0))
.unwrap();
request_value_reader
.seek(std::io::SeekFrom::Start(0))
.unwrap();
loop {
request_value_reader
.seek(std::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(common::to_body(
request_value_reader.get_ref().clone().into(),
));
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let common::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(common::Error::HttpError(err));
}
Ok(res) => {
let (mut parts, body) = res.into_parts();
let mut body = common::Body::new(body);
if !parts.status.is_success() {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let error = serde_json::from_str(&common::to_string(&bytes));
let response = common::to_response(parts, bytes.into());
if let common::Retry::After(d) =
dlg.http_failure(&response, error.as_ref().ok())
{
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(match error {
Ok(value) => common::Error::BadRequest(value),
_ => common::Error::Failure(response),
});
}
let response = {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let encoded = common::to_string(&bytes);
match serde_json::from_str(&encoded) {
Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
Err(error) => {
dlg.response_json_decode_error(&encoded, &error);
return Err(common::Error::JsonDecodeError(
encoded.to_string(),
error,
));
}
}
};
dlg.finished(true);
return Ok(response);
}
}
}
}
///
/// Sets the *request* 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, C> {
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, C> {
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, C> {
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 common::Delegate,
) -> ThirdPartyLinkUpdateCall<'a, C> {
self._delegate = Some(new_value);
self
}
/// Set any additional parameter of the query string used in the request.
/// It should be used to set parameters 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<T>(mut self, name: T, value: T) -> ThirdPartyLinkUpdateCall<'a, C>
where
T: AsRef<str>,
{
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 youtube3::{YouTube, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_only()
/// # .enable_http2()
/// # .build();
///
/// # let executor = hyper_util::rt::TokioExecutor::new();
/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// # secret,
/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # yup_oauth2::client::CustomHyperClientBuilder::from(
/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
/// # ),
/// # ).build().await.unwrap();
///
/// # let client = hyper_util::client::legacy::Client::builder(
/// # hyper_util::rt::TokioExecutor::new()
/// # )
/// # .build(
/// # hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_or_http()
/// # .enable_http2()
/// # .build()
/// # );
/// # let mut hub = YouTube::new(client, 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("nonumy")
/// .upload_resumable(fs::File::open("file.ext").unwrap(), "application/octet-stream".parse().unwrap()).await;
/// # }
/// ```
pub struct ThumbnailSetCall<'a, C>
where
C: 'a,
{
hub: &'a YouTube<C>,
_video_id: String,
_on_behalf_of_content_owner: Option<String>,
_delegate: Option<&'a mut dyn common::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>,
}
impl<'a, C> common::CallBuilder for ThumbnailSetCall<'a, C> {}
impl<'a, C> ThumbnailSetCall<'a, C>
where
C: common::Connector,
{
/// Perform the operation you have build so far.
async fn doit<RS>(
mut self,
mut reader: RS,
reader_mime_type: mime::Mime,
protocol: common::UploadProtocol,
) -> common::Result<(common::Response, ThumbnailSetResponse)>
where
RS: common::ReadSeek,
{
use std::borrow::Cow;
use std::io::{Read, Seek};
use common::{url::Params, ToParts};
use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
let mut dd = common::DefaultDelegate;
let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(common::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(common::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 == common::UploadProtocol::Resumable {
(
self.hub._root_url.clone() + "resumable/upload/youtube/v3/thumbnails/set",
"resumable",
)
} else if protocol == common::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 upload_url_from_server;
loop {
let token = match self
.hub
.auth
.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
.await
{
Ok(token) => token,
Err(e) => match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(common::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));
}
upload_url_from_server = true;
if protocol == common::UploadProtocol::Resumable {
req_builder = req_builder
.header("X-Upload-Content-Type", format!("{}", reader_mime_type));
}
let request = if protocol == common::UploadProtocol::Simple {
let size = reader.seek(std::io::SeekFrom::End(0)).unwrap();
reader.seek(std::io::SeekFrom::Start(0)).unwrap();
if size > 2097152 {
return Err(common::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(common::to_body(bytes.into()))
} else {
req_builder.body(common::to_body::<String>(None))
};
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let common::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(common::Error::HttpError(err));
}
Ok(res) => {
let (mut parts, body) = res.into_parts();
let mut body = common::Body::new(body);
if !parts.status.is_success() {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let error = serde_json::from_str(&common::to_string(&bytes));
let response = common::to_response(parts, bytes.into());
if let common::Retry::After(d) =
dlg.http_failure(&response, error.as_ref().ok())
{
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(match error {
Ok(value) => common::Error::BadRequest(value),
_ => common::Error::Failure(response),
});
}
if protocol == common::UploadProtocol::Resumable {
let size = reader.seek(std::io::SeekFrom::End(0)).unwrap();
reader.seek(std::io::SeekFrom::Start(0)).unwrap();
if size > 2097152 {
return Err(common::Error::UploadSizeLimitExceeded(size, 2097152));
}
let upload_result = {
let url_str = &parts
.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));
}
common::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(|| common::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(common::Error::Cancelled);
}
Some(Err(err)) => {
dlg.finished(false);
return Err(common::Error::HttpError(err));
}
Some(Ok(response)) => {
(parts, body) = response.into_parts();
if !parts.status.is_success() {
dlg.store_upload_url(None);
dlg.finished(false);
return Err(common::Error::Failure(
common::Response::from_parts(parts, body),
));
}
}
}
}
let response = {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let encoded = common::to_string(&bytes);
match serde_json::from_str(&encoded) {
Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
Err(error) => {
dlg.response_json_decode_error(&encoded, &error);
return Err(common::Error::JsonDecodeError(
encoded.to_string(),
error,
));
}
}
};
dlg.finished(true);
return Ok(response);
}
}
}
}
/// 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<RS>(
self,
resumeable_stream: RS,
mime_type: mime::Mime,
) -> common::Result<(common::Response, ThumbnailSetResponse)>
where
RS: common::ReadSeek,
{
self.doit(
resumeable_stream,
mime_type,
common::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<RS>(
self,
stream: RS,
mime_type: mime::Mime,
) -> common::Result<(common::Response, ThumbnailSetResponse)>
where
RS: common::ReadSeek,
{
self.doit(stream, mime_type, common::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, C> {
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, C> {
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 common::Delegate) -> ThumbnailSetCall<'a, C> {
self._delegate = Some(new_value);
self
}
/// Set any additional parameter of the query string used in the request.
/// It should be used to set parameters 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<T>(mut self, name: T, value: T) -> ThumbnailSetCall<'a, C>
where
T: AsRef<str>,
{
self._additional_params
.insert(name.as_ref().to_string(), value.as_ref().to_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<St>(mut self, scope: St) -> ThumbnailSetCall<'a, C>
where
St: AsRef<str>,
{
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<I, St>(mut self, scopes: I) -> ThumbnailSetCall<'a, C>
where
I: IntoIterator<Item = St>,
St: AsRef<str>,
{
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, C> {
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 youtube3::{YouTube, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_only()
/// # .enable_http2()
/// # .build();
///
/// # let executor = hyper_util::rt::TokioExecutor::new();
/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// # secret,
/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # yup_oauth2::client::CustomHyperClientBuilder::from(
/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
/// # ),
/// # ).build().await.unwrap();
///
/// # let client = hyper_util::client::legacy::Client::builder(
/// # hyper_util::rt::TokioExecutor::new()
/// # )
/// # .build(
/// # hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_or_http()
/// # .enable_http2()
/// # .build()
/// # );
/// # let mut hub = YouTube::new(client, auth);
/// // You can configure optional parameters by calling 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!["erat".into()])
/// .hl("erat")
/// .doit().await;
/// # }
/// ```
pub struct VideoAbuseReportReasonListCall<'a, C>
where
C: 'a,
{
hub: &'a YouTube<C>,
_part: Vec<String>,
_hl: Option<String>,
_delegate: Option<&'a mut dyn common::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>,
}
impl<'a, C> common::CallBuilder for VideoAbuseReportReasonListCall<'a, C> {}
impl<'a, C> VideoAbuseReportReasonListCall<'a, C>
where
C: common::Connector,
{
/// Perform the operation you have build so far.
pub async fn doit(
mut self,
) -> common::Result<(common::Response, VideoAbuseReportReasonListResponse)> {
use std::borrow::Cow;
use std::io::{Read, Seek};
use common::{url::Params, ToParts};
use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
let mut dd = common::DefaultDelegate;
let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(common::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(common::Error::FieldClash(field));
}
}
let mut params = Params::with_capacity(4 + self._additional_params.len());
if !self._part.is_empty() {
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::<Vec<_>>()[..])
.await
{
Ok(token) => token,
Err(e) => match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(common::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(common::to_body::<String>(None));
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let common::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(common::Error::HttpError(err));
}
Ok(res) => {
let (mut parts, body) = res.into_parts();
let mut body = common::Body::new(body);
if !parts.status.is_success() {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let error = serde_json::from_str(&common::to_string(&bytes));
let response = common::to_response(parts, bytes.into());
if let common::Retry::After(d) =
dlg.http_failure(&response, error.as_ref().ok())
{
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(match error {
Ok(value) => common::Error::BadRequest(value),
_ => common::Error::Failure(response),
});
}
let response = {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let encoded = common::to_string(&bytes);
match serde_json::from_str(&encoded) {
Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
Err(error) => {
dlg.response_json_decode_error(&encoded, &error);
return Err(common::Error::JsonDecodeError(
encoded.to_string(),
error,
));
}
}
};
dlg.finished(true);
return Ok(response);
}
}
}
}
/// 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, C> {
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, C> {
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 common::Delegate,
) -> VideoAbuseReportReasonListCall<'a, C> {
self._delegate = Some(new_value);
self
}
/// Set any additional parameter of the query string used in the request.
/// It should be used to set parameters 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<T>(mut self, name: T, value: T) -> VideoAbuseReportReasonListCall<'a, C>
where
T: AsRef<str>,
{
self._additional_params
.insert(name.as_ref().to_string(), value.as_ref().to_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<St>(mut self, scope: St) -> VideoAbuseReportReasonListCall<'a, C>
where
St: AsRef<str>,
{
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<I, St>(mut self, scopes: I) -> VideoAbuseReportReasonListCall<'a, C>
where
I: IntoIterator<Item = St>,
St: AsRef<str>,
{
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, C> {
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 youtube3::{YouTube, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_only()
/// # .enable_http2()
/// # .build();
///
/// # let executor = hyper_util::rt::TokioExecutor::new();
/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// # secret,
/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # yup_oauth2::client::CustomHyperClientBuilder::from(
/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
/// # ),
/// # ).build().await.unwrap();
///
/// # let client = hyper_util::client::legacy::Client::builder(
/// # hyper_util::rt::TokioExecutor::new()
/// # )
/// # .build(
/// # hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_or_http()
/// # .enable_http2()
/// # .build()
/// # );
/// # let mut hub = YouTube::new(client, auth);
/// // You can configure optional parameters by calling 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!["dolores".into()])
/// .region_code("ipsum")
/// .add_id("voluptua.")
/// .hl("eos")
/// .doit().await;
/// # }
/// ```
pub struct VideoCategoryListCall<'a, C>
where
C: 'a,
{
hub: &'a YouTube<C>,
_part: Vec<String>,
_region_code: Option<String>,
_id: Vec<String>,
_hl: Option<String>,
_delegate: Option<&'a mut dyn common::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>,
}
impl<'a, C> common::CallBuilder for VideoCategoryListCall<'a, C> {}
impl<'a, C> VideoCategoryListCall<'a, C>
where
C: common::Connector,
{
/// Perform the operation you have build so far.
pub async fn doit(mut self) -> common::Result<(common::Response, VideoCategoryListResponse)> {
use std::borrow::Cow;
use std::io::{Read, Seek};
use common::{url::Params, ToParts};
use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
let mut dd = common::DefaultDelegate;
let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(common::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(common::Error::FieldClash(field));
}
}
let mut params = Params::with_capacity(6 + self._additional_params.len());
if !self._part.is_empty() {
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.is_empty() {
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::<Vec<_>>()[..])
.await
{
Ok(token) => token,
Err(e) => match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(common::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(common::to_body::<String>(None));
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let common::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(common::Error::HttpError(err));
}
Ok(res) => {
let (mut parts, body) = res.into_parts();
let mut body = common::Body::new(body);
if !parts.status.is_success() {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let error = serde_json::from_str(&common::to_string(&bytes));
let response = common::to_response(parts, bytes.into());
if let common::Retry::After(d) =
dlg.http_failure(&response, error.as_ref().ok())
{
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(match error {
Ok(value) => common::Error::BadRequest(value),
_ => common::Error::Failure(response),
});
}
let response = {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let encoded = common::to_string(&bytes);
match serde_json::from_str(&encoded) {
Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
Err(error) => {
dlg.response_json_decode_error(&encoded, &error);
return Err(common::Error::JsonDecodeError(
encoded.to_string(),
error,
));
}
}
};
dlg.finished(true);
return Ok(response);
}
}
}
}
/// 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, C> {
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, C> {
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, C> {
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, C> {
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 common::Delegate,
) -> VideoCategoryListCall<'a, C> {
self._delegate = Some(new_value);
self
}
/// Set any additional parameter of the query string used in the request.
/// It should be used to set parameters 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<T>(mut self, name: T, value: T) -> VideoCategoryListCall<'a, C>
where
T: AsRef<str>,
{
self._additional_params
.insert(name.as_ref().to_string(), value.as_ref().to_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<St>(mut self, scope: St) -> VideoCategoryListCall<'a, C>
where
St: AsRef<str>,
{
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<I, St>(mut self, scopes: I) -> VideoCategoryListCall<'a, C>
where
I: IntoIterator<Item = St>,
St: AsRef<str>,
{
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, C> {
self._scopes.clear();
self
}
}
/// Returns the trainability status of a video.
///
/// A builder for the *get* method supported by a *videoTrainability* resource.
/// It is not used directly, but through a [`VideoTrainabilityMethods`] 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 youtube3::{YouTube, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_only()
/// # .enable_http2()
/// # .build();
///
/// # let executor = hyper_util::rt::TokioExecutor::new();
/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// # secret,
/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # yup_oauth2::client::CustomHyperClientBuilder::from(
/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
/// # ),
/// # ).build().await.unwrap();
///
/// # let client = hyper_util::client::legacy::Client::builder(
/// # hyper_util::rt::TokioExecutor::new()
/// # )
/// # .build(
/// # hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_or_http()
/// # .enable_http2()
/// # .build()
/// # );
/// # let mut hub = YouTube::new(client, auth);
/// // You can configure optional parameters by calling 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_trainability().get()
/// .id("duo")
/// .doit().await;
/// # }
/// ```
pub struct VideoTrainabilityGetCall<'a, C>
where
C: 'a,
{
hub: &'a YouTube<C>,
_id: Option<String>,
_delegate: Option<&'a mut dyn common::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>,
}
impl<'a, C> common::CallBuilder for VideoTrainabilityGetCall<'a, C> {}
impl<'a, C> VideoTrainabilityGetCall<'a, C>
where
C: common::Connector,
{
/// Perform the operation you have build so far.
pub async fn doit(mut self) -> common::Result<(common::Response, VideoTrainability)> {
use std::borrow::Cow;
use std::io::{Read, Seek};
use common::{url::Params, ToParts};
use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
let mut dd = common::DefaultDelegate;
let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(common::MethodInfo {
id: "youtube.videoTrainability.get",
http_method: hyper::Method::GET,
});
for &field in ["alt", "id"].iter() {
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Err(common::Error::FieldClash(field));
}
}
let mut params = Params::with_capacity(3 + self._additional_params.len());
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/videoTrainability";
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::<Vec<_>>()[..])
.await
{
Ok(token) => token,
Err(e) => match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(common::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(common::to_body::<String>(None));
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let common::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(common::Error::HttpError(err));
}
Ok(res) => {
let (mut parts, body) = res.into_parts();
let mut body = common::Body::new(body);
if !parts.status.is_success() {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let error = serde_json::from_str(&common::to_string(&bytes));
let response = common::to_response(parts, bytes.into());
if let common::Retry::After(d) =
dlg.http_failure(&response, error.as_ref().ok())
{
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(match error {
Ok(value) => common::Error::BadRequest(value),
_ => common::Error::Failure(response),
});
}
let response = {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let encoded = common::to_string(&bytes);
match serde_json::from_str(&encoded) {
Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
Err(error) => {
dlg.response_json_decode_error(&encoded, &error);
return Err(common::Error::JsonDecodeError(
encoded.to_string(),
error,
));
}
}
};
dlg.finished(true);
return Ok(response);
}
}
}
}
/// The ID of the video to retrieve.
///
/// Sets the *id* query property to the given value.
pub fn id(mut self, new_value: &str) -> VideoTrainabilityGetCall<'a, C> {
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 common::Delegate,
) -> VideoTrainabilityGetCall<'a, C> {
self._delegate = Some(new_value);
self
}
/// Set any additional parameter of the query string used in the request.
/// It should be used to set parameters 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<T>(mut self, name: T, value: T) -> VideoTrainabilityGetCall<'a, C>
where
T: AsRef<str>,
{
self._additional_params
.insert(name.as_ref().to_string(), value.as_ref().to_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<St>(mut self, scope: St) -> VideoTrainabilityGetCall<'a, C>
where
St: AsRef<str>,
{
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<I, St>(mut self, scopes: I) -> VideoTrainabilityGetCall<'a, C>
where
I: IntoIterator<Item = St>,
St: AsRef<str>,
{
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) -> VideoTrainabilityGetCall<'a, C> {
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 youtube3::{YouTube, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_only()
/// # .enable_http2()
/// # .build();
///
/// # let executor = hyper_util::rt::TokioExecutor::new();
/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// # secret,
/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # yup_oauth2::client::CustomHyperClientBuilder::from(
/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
/// # ),
/// # ).build().await.unwrap();
///
/// # let client = hyper_util::client::legacy::Client::builder(
/// # hyper_util::rt::TokioExecutor::new()
/// # )
/// # .build(
/// # hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_or_http()
/// # .enable_http2()
/// # .build()
/// # );
/// # let mut hub = YouTube::new(client, auth);
/// // You can configure optional parameters by calling 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("consetetur")
/// .doit().await;
/// # }
/// ```
pub struct VideoDeleteCall<'a, C>
where
C: 'a,
{
hub: &'a YouTube<C>,
_id: String,
_on_behalf_of_content_owner: Option<String>,
_delegate: Option<&'a mut dyn common::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>,
}
impl<'a, C> common::CallBuilder for VideoDeleteCall<'a, C> {}
impl<'a, C> VideoDeleteCall<'a, C>
where
C: common::Connector,
{
/// Perform the operation you have build so far.
pub async fn doit(mut self) -> common::Result<common::Response> {
use std::borrow::Cow;
use std::io::{Read, Seek};
use common::{url::Params, ToParts};
use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
let mut dd = common::DefaultDelegate;
let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(common::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(common::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::<Vec<_>>()[..])
.await
{
Ok(token) => token,
Err(e) => match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(common::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(common::to_body::<String>(None));
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let common::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(common::Error::HttpError(err));
}
Ok(res) => {
let (mut parts, body) = res.into_parts();
let mut body = common::Body::new(body);
if !parts.status.is_success() {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let error = serde_json::from_str(&common::to_string(&bytes));
let response = common::to_response(parts, bytes.into());
if let common::Retry::After(d) =
dlg.http_failure(&response, error.as_ref().ok())
{
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(match error {
Ok(value) => common::Error::BadRequest(value),
_ => common::Error::Failure(response),
});
}
let response = common::Response::from_parts(parts, body);
dlg.finished(true);
return Ok(response);
}
}
}
}
///
/// 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, C> {
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, C> {
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 common::Delegate) -> VideoDeleteCall<'a, C> {
self._delegate = Some(new_value);
self
}
/// Set any additional parameter of the query string used in the request.
/// It should be used to set parameters 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<T>(mut self, name: T, value: T) -> VideoDeleteCall<'a, C>
where
T: AsRef<str>,
{
self._additional_params
.insert(name.as_ref().to_string(), value.as_ref().to_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<St>(mut self, scope: St) -> VideoDeleteCall<'a, C>
where
St: AsRef<str>,
{
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<I, St>(mut self, scopes: I) -> VideoDeleteCall<'a, C>
where
I: IntoIterator<Item = St>,
St: AsRef<str>,
{
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, C> {
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 youtube3::{YouTube, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_only()
/// # .enable_http2()
/// # .build();
///
/// # let executor = hyper_util::rt::TokioExecutor::new();
/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// # secret,
/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # yup_oauth2::client::CustomHyperClientBuilder::from(
/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
/// # ),
/// # ).build().await.unwrap();
///
/// # let client = hyper_util::client::legacy::Client::builder(
/// # hyper_util::rt::TokioExecutor::new()
/// # )
/// # .build(
/// # hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_or_http()
/// # .enable_http2()
/// # .build()
/// # );
/// # let mut hub = YouTube::new(client, auth);
/// // You can configure optional parameters by calling 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!["et".into()])
/// .on_behalf_of_content_owner("clita")
/// .doit().await;
/// # }
/// ```
pub struct VideoGetRatingCall<'a, C>
where
C: 'a,
{
hub: &'a YouTube<C>,
_id: Vec<String>,
_on_behalf_of_content_owner: Option<String>,
_delegate: Option<&'a mut dyn common::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>,
}
impl<'a, C> common::CallBuilder for VideoGetRatingCall<'a, C> {}
impl<'a, C> VideoGetRatingCall<'a, C>
where
C: common::Connector,
{
/// Perform the operation you have build so far.
pub async fn doit(mut self) -> common::Result<(common::Response, VideoGetRatingResponse)> {
use std::borrow::Cow;
use std::io::{Read, Seek};
use common::{url::Params, ToParts};
use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
let mut dd = common::DefaultDelegate;
let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(common::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(common::Error::FieldClash(field));
}
}
let mut params = Params::with_capacity(4 + self._additional_params.len());
if !self._id.is_empty() {
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::<Vec<_>>()[..])
.await
{
Ok(token) => token,
Err(e) => match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(common::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(common::to_body::<String>(None));
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let common::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(common::Error::HttpError(err));
}
Ok(res) => {
let (mut parts, body) = res.into_parts();
let mut body = common::Body::new(body);
if !parts.status.is_success() {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let error = serde_json::from_str(&common::to_string(&bytes));
let response = common::to_response(parts, bytes.into());
if let common::Retry::After(d) =
dlg.http_failure(&response, error.as_ref().ok())
{
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(match error {
Ok(value) => common::Error::BadRequest(value),
_ => common::Error::Failure(response),
});
}
let response = {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let encoded = common::to_string(&bytes);
match serde_json::from_str(&encoded) {
Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
Err(error) => {
dlg.response_json_decode_error(&encoded, &error);
return Err(common::Error::JsonDecodeError(
encoded.to_string(),
error,
));
}
}
};
dlg.finished(true);
return Ok(response);
}
}
}
}
///
/// 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, C> {
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, C> {
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 common::Delegate,
) -> VideoGetRatingCall<'a, C> {
self._delegate = Some(new_value);
self
}
/// Set any additional parameter of the query string used in the request.
/// It should be used to set parameters 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<T>(mut self, name: T, value: T) -> VideoGetRatingCall<'a, C>
where
T: AsRef<str>,
{
self._additional_params
.insert(name.as_ref().to_string(), value.as_ref().to_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<St>(mut self, scope: St) -> VideoGetRatingCall<'a, C>
where
St: AsRef<str>,
{
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<I, St>(mut self, scopes: I) -> VideoGetRatingCall<'a, C>
where
I: IntoIterator<Item = St>,
St: AsRef<str>,
{
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, C> {
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 youtube3::{YouTube, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_only()
/// # .enable_http2()
/// # .build();
///
/// # let executor = hyper_util::rt::TokioExecutor::new();
/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// # secret,
/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # yup_oauth2::client::CustomHyperClientBuilder::from(
/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
/// # ),
/// # ).build().await.unwrap();
///
/// # let client = hyper_util::client::legacy::Client::builder(
/// # hyper_util::rt::TokioExecutor::new()
/// # )
/// # .build(
/// # hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_or_http()
/// # .enable_http2()
/// # .build()
/// # );
/// # let mut hub = YouTube::new(client, auth);
/// // As the method needs a request, you would usually fill it with the desired information
/// // into the 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(true)
/// .on_behalf_of_content_owner_channel("takimata")
/// .on_behalf_of_content_owner("erat")
/// .notify_subscribers(true)
/// .auto_levels(true)
/// .upload(fs::File::open("file.ext").unwrap(), "application/octet-stream".parse().unwrap()).await;
/// # }
/// ```
pub struct VideoInsertCall<'a, C>
where
C: 'a,
{
hub: &'a YouTube<C>,
_request: Video,
_part: Vec<String>,
_stabilize: Option<bool>,
_on_behalf_of_content_owner_channel: Option<String>,
_on_behalf_of_content_owner: Option<String>,
_notify_subscribers: Option<bool>,
_auto_levels: Option<bool>,
_delegate: Option<&'a mut dyn common::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>,
}
impl<'a, C> common::CallBuilder for VideoInsertCall<'a, C> {}
impl<'a, C> VideoInsertCall<'a, C>
where
C: common::Connector,
{
/// Perform the operation you have build so far.
async fn doit<RS>(
mut self,
mut reader: RS,
reader_mime_type: mime::Mime,
protocol: common::UploadProtocol,
) -> common::Result<(common::Response, Video)>
where
RS: common::ReadSeek,
{
use std::borrow::Cow;
use std::io::{Read, Seek};
use common::{url::Params, ToParts};
use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
let mut dd = common::DefaultDelegate;
let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(common::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(common::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.is_empty() {
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 == common::UploadProtocol::Resumable {
(
self.hub._root_url.clone() + "resumable/upload/youtube/v3/videos",
"resumable",
)
} else if protocol == common::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 = serde_json::value::to_value(&self._request).expect("serde to work");
common::remove_json_null_values(&mut value);
let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
serde_json::to_writer(&mut dst, &value).unwrap();
dst
};
let request_size = request_value_reader
.seek(std::io::SeekFrom::End(0))
.unwrap();
request_value_reader
.seek(std::io::SeekFrom::Start(0))
.unwrap();
let mut upload_url_from_server;
loop {
let token = match self
.hub
.auth
.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
.await
{
Ok(token) => token,
Err(e) => match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(common::Error::MissingToken(e));
}
},
};
request_value_reader
.seek(std::io::SeekFrom::Start(0))
.unwrap();
let mut req_result = {
let mut mp_reader: common::MultiPartReader = Default::default();
let (mut body_reader, content_type) = match protocol {
common::UploadProtocol::Simple => {
mp_reader.reserve_exact(2);
let size = reader.seek(std::io::SeekFrom::End(0)).unwrap();
reader.seek(std::io::SeekFrom::Start(0)).unwrap();
if size > 274877906944 {
return Err(common::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 std::io::Read + Send),
common::MultiPartReader::mime_type(),
)
}
_ => (
&mut request_value_reader as &mut (dyn std::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 == common::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(common::to_body(body_reader_bytes.into()));
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let common::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(common::Error::HttpError(err));
}
Ok(res) => {
let (mut parts, body) = res.into_parts();
let mut body = common::Body::new(body);
if !parts.status.is_success() {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let error = serde_json::from_str(&common::to_string(&bytes));
let response = common::to_response(parts, bytes.into());
if let common::Retry::After(d) =
dlg.http_failure(&response, error.as_ref().ok())
{
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(match error {
Ok(value) => common::Error::BadRequest(value),
_ => common::Error::Failure(response),
});
}
if protocol == common::UploadProtocol::Resumable {
let size = reader.seek(std::io::SeekFrom::End(0)).unwrap();
reader.seek(std::io::SeekFrom::Start(0)).unwrap();
if size > 274877906944 {
return Err(common::Error::UploadSizeLimitExceeded(size, 274877906944));
}
let upload_result = {
let url_str = &parts
.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));
}
common::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(|| common::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(common::Error::Cancelled);
}
Some(Err(err)) => {
dlg.finished(false);
return Err(common::Error::HttpError(err));
}
Some(Ok(response)) => {
(parts, body) = response.into_parts();
if !parts.status.is_success() {
dlg.store_upload_url(None);
dlg.finished(false);
return Err(common::Error::Failure(
common::Response::from_parts(parts, body),
));
}
}
}
}
let response = {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let encoded = common::to_string(&bytes);
match serde_json::from_str(&encoded) {
Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
Err(error) => {
dlg.response_json_decode_error(&encoded, &error);
return Err(common::Error::JsonDecodeError(
encoded.to_string(),
error,
));
}
}
};
dlg.finished(true);
return Ok(response);
}
}
}
}
/// 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<RS>(
self,
resumeable_stream: RS,
mime_type: mime::Mime,
) -> common::Result<(common::Response, Video)>
where
RS: common::ReadSeek,
{
self.doit(
resumeable_stream,
mime_type,
common::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<RS>(
self,
stream: RS,
mime_type: mime::Mime,
) -> common::Result<(common::Response, Video)>
where
RS: common::ReadSeek,
{
self.doit(stream, mime_type, common::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, C> {
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, C> {
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, C> {
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, C> {
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, C> {
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, C> {
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, C> {
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 common::Delegate) -> VideoInsertCall<'a, C> {
self._delegate = Some(new_value);
self
}
/// Set any additional parameter of the query string used in the request.
/// It should be used to set parameters 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<T>(mut self, name: T, value: T) -> VideoInsertCall<'a, C>
where
T: AsRef<str>,
{
self._additional_params
.insert(name.as_ref().to_string(), value.as_ref().to_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<St>(mut self, scope: St) -> VideoInsertCall<'a, C>
where
St: AsRef<str>,
{
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<I, St>(mut self, scopes: I) -> VideoInsertCall<'a, C>
where
I: IntoIterator<Item = St>,
St: AsRef<str>,
{
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, C> {
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 youtube3::{YouTube, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_only()
/// # .enable_http2()
/// # .build();
///
/// # let executor = hyper_util::rt::TokioExecutor::new();
/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// # secret,
/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # yup_oauth2::client::CustomHyperClientBuilder::from(
/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
/// # ),
/// # ).build().await.unwrap();
///
/// # let client = hyper_util::client::legacy::Client::builder(
/// # hyper_util::rt::TokioExecutor::new()
/// # )
/// # .build(
/// # hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_or_http()
/// # .enable_http2()
/// # .build()
/// # );
/// # let mut hub = YouTube::new(client, auth);
/// // You can configure optional parameters by calling 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!["Lorem".into()])
/// .video_category_id("At")
/// .region_code("diam")
/// .page_token("diam")
/// .on_behalf_of_content_owner("sed")
/// .my_rating("et")
/// .max_width(-17)
/// .max_results(17)
/// .max_height(-55)
/// .locale("ea")
/// .add_id("At")
/// .hl("sit")
/// .chart("sit")
/// .doit().await;
/// # }
/// ```
pub struct VideoListCall<'a, C>
where
C: 'a,
{
hub: &'a YouTube<C>,
_part: Vec<String>,
_video_category_id: Option<String>,
_region_code: Option<String>,
_page_token: Option<String>,
_on_behalf_of_content_owner: Option<String>,
_my_rating: Option<String>,
_max_width: Option<i32>,
_max_results: Option<u32>,
_max_height: Option<i32>,
_locale: Option<String>,
_id: Vec<String>,
_hl: Option<String>,
_chart: Option<String>,
_delegate: Option<&'a mut dyn common::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>,
}
impl<'a, C> common::CallBuilder for VideoListCall<'a, C> {}
impl<'a, C> VideoListCall<'a, C>
where
C: common::Connector,
{
/// Perform the operation you have build so far.
pub async fn doit(mut self) -> common::Result<(common::Response, VideoListResponse)> {
use std::borrow::Cow;
use std::io::{Read, Seek};
use common::{url::Params, ToParts};
use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
let mut dd = common::DefaultDelegate;
let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(common::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(common::Error::FieldClash(field));
}
}
let mut params = Params::with_capacity(15 + self._additional_params.len());
if !self._part.is_empty() {
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.is_empty() {
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::<Vec<_>>()[..])
.await
{
Ok(token) => token,
Err(e) => match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(common::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(common::to_body::<String>(None));
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let common::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(common::Error::HttpError(err));
}
Ok(res) => {
let (mut parts, body) = res.into_parts();
let mut body = common::Body::new(body);
if !parts.status.is_success() {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let error = serde_json::from_str(&common::to_string(&bytes));
let response = common::to_response(parts, bytes.into());
if let common::Retry::After(d) =
dlg.http_failure(&response, error.as_ref().ok())
{
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(match error {
Ok(value) => common::Error::BadRequest(value),
_ => common::Error::Failure(response),
});
}
let response = {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let encoded = common::to_string(&bytes);
match serde_json::from_str(&encoded) {
Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
Err(error) => {
dlg.response_json_decode_error(&encoded, &error);
return Err(common::Error::JsonDecodeError(
encoded.to_string(),
error,
));
}
}
};
dlg.finished(true);
return Ok(response);
}
}
}
}
/// 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, C> {
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, C> {
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, C> {
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, C> {
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, C> {
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: &str) -> VideoListCall<'a, C> {
self._my_rating = Some(new_value.to_string());
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, C> {
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, C> {
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, C> {
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, C> {
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, C> {
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, C> {
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: &str) -> VideoListCall<'a, C> {
self._chart = 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 common::Delegate) -> VideoListCall<'a, C> {
self._delegate = Some(new_value);
self
}
/// Set any additional parameter of the query string used in the request.
/// It should be used to set parameters 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<T>(mut self, name: T, value: T) -> VideoListCall<'a, C>
where
T: AsRef<str>,
{
self._additional_params
.insert(name.as_ref().to_string(), value.as_ref().to_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<St>(mut self, scope: St) -> VideoListCall<'a, C>
where
St: AsRef<str>,
{
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<I, St>(mut self, scopes: I) -> VideoListCall<'a, C>
where
I: IntoIterator<Item = St>,
St: AsRef<str>,
{
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, C> {
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 youtube3::{YouTube, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_only()
/// # .enable_http2()
/// # .build();
///
/// # let executor = hyper_util::rt::TokioExecutor::new();
/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// # secret,
/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # yup_oauth2::client::CustomHyperClientBuilder::from(
/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
/// # ),
/// # ).build().await.unwrap();
///
/// # let client = hyper_util::client::legacy::Client::builder(
/// # hyper_util::rt::TokioExecutor::new()
/// # )
/// # .build(
/// # hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_or_http()
/// # .enable_http2()
/// # .build()
/// # );
/// # let mut hub = YouTube::new(client, auth);
/// // You can configure optional parameters by calling 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", "rating")
/// .doit().await;
/// # }
/// ```
pub struct VideoRateCall<'a, C>
where
C: 'a,
{
hub: &'a YouTube<C>,
_id: String,
_rating: String,
_delegate: Option<&'a mut dyn common::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>,
}
impl<'a, C> common::CallBuilder for VideoRateCall<'a, C> {}
impl<'a, C> VideoRateCall<'a, C>
where
C: common::Connector,
{
/// Perform the operation you have build so far.
pub async fn doit(mut self) -> common::Result<common::Response> {
use std::borrow::Cow;
use std::io::{Read, Seek};
use common::{url::Params, ToParts};
use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
let mut dd = common::DefaultDelegate;
let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(common::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(common::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::<Vec<_>>()[..])
.await
{
Ok(token) => token,
Err(e) => match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(common::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(common::to_body::<String>(None));
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let common::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(common::Error::HttpError(err));
}
Ok(res) => {
let (mut parts, body) = res.into_parts();
let mut body = common::Body::new(body);
if !parts.status.is_success() {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let error = serde_json::from_str(&common::to_string(&bytes));
let response = common::to_response(parts, bytes.into());
if let common::Retry::After(d) =
dlg.http_failure(&response, error.as_ref().ok())
{
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(match error {
Ok(value) => common::Error::BadRequest(value),
_ => common::Error::Failure(response),
});
}
let response = common::Response::from_parts(parts, body);
dlg.finished(true);
return Ok(response);
}
}
}
}
///
/// 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, C> {
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: &str) -> VideoRateCall<'a, C> {
self._rating = new_value.to_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 common::Delegate) -> VideoRateCall<'a, C> {
self._delegate = Some(new_value);
self
}
/// Set any additional parameter of the query string used in the request.
/// It should be used to set parameters 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<T>(mut self, name: T, value: T) -> VideoRateCall<'a, C>
where
T: AsRef<str>,
{
self._additional_params
.insert(name.as_ref().to_string(), value.as_ref().to_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<St>(mut self, scope: St) -> VideoRateCall<'a, C>
where
St: AsRef<str>,
{
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<I, St>(mut self, scopes: I) -> VideoRateCall<'a, C>
where
I: IntoIterator<Item = St>,
St: AsRef<str>,
{
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, C> {
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 youtube3::{YouTube, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_only()
/// # .enable_http2()
/// # .build();
///
/// # let executor = hyper_util::rt::TokioExecutor::new();
/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// # secret,
/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # yup_oauth2::client::CustomHyperClientBuilder::from(
/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
/// # ),
/// # ).build().await.unwrap();
///
/// # let client = hyper_util::client::legacy::Client::builder(
/// # hyper_util::rt::TokioExecutor::new()
/// # )
/// # .build(
/// # hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_or_http()
/// # .enable_http2()
/// # .build()
/// # );
/// # let mut hub = YouTube::new(client, auth);
/// // As the method needs a request, you would usually fill it with the desired information
/// // into the 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("duo")
/// .doit().await;
/// # }
/// ```
pub struct VideoReportAbuseCall<'a, C>
where
C: 'a,
{
hub: &'a YouTube<C>,
_request: VideoAbuseReport,
_on_behalf_of_content_owner: Option<String>,
_delegate: Option<&'a mut dyn common::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>,
}
impl<'a, C> common::CallBuilder for VideoReportAbuseCall<'a, C> {}
impl<'a, C> VideoReportAbuseCall<'a, C>
where
C: common::Connector,
{
/// Perform the operation you have build so far.
pub async fn doit(mut self) -> common::Result<common::Response> {
use std::borrow::Cow;
use std::io::{Read, Seek};
use common::{url::Params, ToParts};
use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
let mut dd = common::DefaultDelegate;
let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(common::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(common::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 = serde_json::value::to_value(&self._request).expect("serde to work");
common::remove_json_null_values(&mut value);
let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
serde_json::to_writer(&mut dst, &value).unwrap();
dst
};
let request_size = request_value_reader
.seek(std::io::SeekFrom::End(0))
.unwrap();
request_value_reader
.seek(std::io::SeekFrom::Start(0))
.unwrap();
loop {
let token = match self
.hub
.auth
.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
.await
{
Ok(token) => token,
Err(e) => match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(common::Error::MissingToken(e));
}
},
};
request_value_reader
.seek(std::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(common::to_body(
request_value_reader.get_ref().clone().into(),
));
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let common::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(common::Error::HttpError(err));
}
Ok(res) => {
let (mut parts, body) = res.into_parts();
let mut body = common::Body::new(body);
if !parts.status.is_success() {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let error = serde_json::from_str(&common::to_string(&bytes));
let response = common::to_response(parts, bytes.into());
if let common::Retry::After(d) =
dlg.http_failure(&response, error.as_ref().ok())
{
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(match error {
Ok(value) => common::Error::BadRequest(value),
_ => common::Error::Failure(response),
});
}
let response = common::Response::from_parts(parts, body);
dlg.finished(true);
return Ok(response);
}
}
}
}
///
/// Sets the *request* property to the given value.
///
/// Even though 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, C> {
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, C> {
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 common::Delegate,
) -> VideoReportAbuseCall<'a, C> {
self._delegate = Some(new_value);
self
}
/// Set any additional parameter of the query string used in the request.
/// It should be used to set parameters 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<T>(mut self, name: T, value: T) -> VideoReportAbuseCall<'a, C>
where
T: AsRef<str>,
{
self._additional_params
.insert(name.as_ref().to_string(), value.as_ref().to_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<St>(mut self, scope: St) -> VideoReportAbuseCall<'a, C>
where
St: AsRef<str>,
{
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<I, St>(mut self, scopes: I) -> VideoReportAbuseCall<'a, C>
where
I: IntoIterator<Item = St>,
St: AsRef<str>,
{
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, C> {
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 youtube3::{YouTube, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_only()
/// # .enable_http2()
/// # .build();
///
/// # let executor = hyper_util::rt::TokioExecutor::new();
/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// # secret,
/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # yup_oauth2::client::CustomHyperClientBuilder::from(
/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
/// # ),
/// # ).build().await.unwrap();
///
/// # let client = hyper_util::client::legacy::Client::builder(
/// # hyper_util::rt::TokioExecutor::new()
/// # )
/// # .build(
/// # hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_or_http()
/// # .enable_http2()
/// # .build()
/// # );
/// # let mut hub = YouTube::new(client, auth);
/// // As the method needs a request, you would usually fill it with the desired information
/// // into the 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("elitr")
/// .doit().await;
/// # }
/// ```
pub struct VideoUpdateCall<'a, C>
where
C: 'a,
{
hub: &'a YouTube<C>,
_request: Video,
_part: Vec<String>,
_on_behalf_of_content_owner: Option<String>,
_delegate: Option<&'a mut dyn common::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>,
}
impl<'a, C> common::CallBuilder for VideoUpdateCall<'a, C> {}
impl<'a, C> VideoUpdateCall<'a, C>
where
C: common::Connector,
{
/// Perform the operation you have build so far.
pub async fn doit(mut self) -> common::Result<(common::Response, Video)> {
use std::borrow::Cow;
use std::io::{Read, Seek};
use common::{url::Params, ToParts};
use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
let mut dd = common::DefaultDelegate;
let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(common::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(common::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.is_empty() {
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 = serde_json::value::to_value(&self._request).expect("serde to work");
common::remove_json_null_values(&mut value);
let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
serde_json::to_writer(&mut dst, &value).unwrap();
dst
};
let request_size = request_value_reader
.seek(std::io::SeekFrom::End(0))
.unwrap();
request_value_reader
.seek(std::io::SeekFrom::Start(0))
.unwrap();
loop {
let token = match self
.hub
.auth
.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
.await
{
Ok(token) => token,
Err(e) => match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(common::Error::MissingToken(e));
}
},
};
request_value_reader
.seek(std::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(common::to_body(
request_value_reader.get_ref().clone().into(),
));
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let common::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(common::Error::HttpError(err));
}
Ok(res) => {
let (mut parts, body) = res.into_parts();
let mut body = common::Body::new(body);
if !parts.status.is_success() {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let error = serde_json::from_str(&common::to_string(&bytes));
let response = common::to_response(parts, bytes.into());
if let common::Retry::After(d) =
dlg.http_failure(&response, error.as_ref().ok())
{
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(match error {
Ok(value) => common::Error::BadRequest(value),
_ => common::Error::Failure(response),
});
}
let response = {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let encoded = common::to_string(&bytes);
match serde_json::from_str(&encoded) {
Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
Err(error) => {
dlg.response_json_decode_error(&encoded, &error);
return Err(common::Error::JsonDecodeError(
encoded.to_string(),
error,
));
}
}
};
dlg.finished(true);
return Ok(response);
}
}
}
}
///
/// Sets the *request* property to the given value.
///
/// Even though 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, C> {
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, C> {
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, C> {
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 common::Delegate) -> VideoUpdateCall<'a, C> {
self._delegate = Some(new_value);
self
}
/// Set any additional parameter of the query string used in the request.
/// It should be used to set parameters 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<T>(mut self, name: T, value: T) -> VideoUpdateCall<'a, C>
where
T: AsRef<str>,
{
self._additional_params
.insert(name.as_ref().to_string(), value.as_ref().to_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<St>(mut self, scope: St) -> VideoUpdateCall<'a, C>
where
St: AsRef<str>,
{
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<I, St>(mut self, scopes: I) -> VideoUpdateCall<'a, C>
where
I: IntoIterator<Item = St>,
St: AsRef<str>,
{
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, C> {
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 youtube3::{YouTube, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_only()
/// # .enable_http2()
/// # .build();
///
/// # let executor = hyper_util::rt::TokioExecutor::new();
/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// # secret,
/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # yup_oauth2::client::CustomHyperClientBuilder::from(
/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
/// # ),
/// # ).build().await.unwrap();
///
/// # let client = hyper_util::client::legacy::Client::builder(
/// # hyper_util::rt::TokioExecutor::new()
/// # )
/// # .build(
/// # hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_or_http()
/// # .enable_http2()
/// # .build()
/// # );
/// # let mut hub = YouTube::new(client, auth);
/// // As the method needs a request, you would usually fill it with the desired information
/// // into the 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("erat")
/// .upload_resumable(fs::File::open("file.ext").unwrap(), "application/octet-stream".parse().unwrap()).await;
/// # }
/// ```
pub struct WatermarkSetCall<'a, C>
where
C: 'a,
{
hub: &'a YouTube<C>,
_request: InvideoBranding,
_channel_id: String,
_on_behalf_of_content_owner: Option<String>,
_delegate: Option<&'a mut dyn common::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>,
}
impl<'a, C> common::CallBuilder for WatermarkSetCall<'a, C> {}
impl<'a, C> WatermarkSetCall<'a, C>
where
C: common::Connector,
{
/// Perform the operation you have build so far.
async fn doit<RS>(
mut self,
mut reader: RS,
reader_mime_type: mime::Mime,
protocol: common::UploadProtocol,
) -> common::Result<common::Response>
where
RS: common::ReadSeek,
{
use std::borrow::Cow;
use std::io::{Read, Seek};
use common::{url::Params, ToParts};
use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
let mut dd = common::DefaultDelegate;
let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(common::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(common::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 == common::UploadProtocol::Resumable {
(
self.hub._root_url.clone() + "resumable/upload/youtube/v3/watermarks/set",
"resumable",
)
} else if protocol == common::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 = serde_json::value::to_value(&self._request).expect("serde to work");
common::remove_json_null_values(&mut value);
let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
serde_json::to_writer(&mut dst, &value).unwrap();
dst
};
let request_size = request_value_reader
.seek(std::io::SeekFrom::End(0))
.unwrap();
request_value_reader
.seek(std::io::SeekFrom::Start(0))
.unwrap();
let mut upload_url_from_server;
loop {
let token = match self
.hub
.auth
.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
.await
{
Ok(token) => token,
Err(e) => match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(common::Error::MissingToken(e));
}
},
};
request_value_reader
.seek(std::io::SeekFrom::Start(0))
.unwrap();
let mut req_result = {
let mut mp_reader: common::MultiPartReader = Default::default();
let (mut body_reader, content_type) = match protocol {
common::UploadProtocol::Simple => {
mp_reader.reserve_exact(2);
let size = reader.seek(std::io::SeekFrom::End(0)).unwrap();
reader.seek(std::io::SeekFrom::Start(0)).unwrap();
if size > 10485760 {
return Err(common::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 std::io::Read + Send),
common::MultiPartReader::mime_type(),
)
}
_ => (
&mut request_value_reader as &mut (dyn std::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 == common::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(common::to_body(body_reader_bytes.into()));
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let common::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(common::Error::HttpError(err));
}
Ok(res) => {
let (mut parts, body) = res.into_parts();
let mut body = common::Body::new(body);
if !parts.status.is_success() {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let error = serde_json::from_str(&common::to_string(&bytes));
let response = common::to_response(parts, bytes.into());
if let common::Retry::After(d) =
dlg.http_failure(&response, error.as_ref().ok())
{
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(match error {
Ok(value) => common::Error::BadRequest(value),
_ => common::Error::Failure(response),
});
}
if protocol == common::UploadProtocol::Resumable {
let size = reader.seek(std::io::SeekFrom::End(0)).unwrap();
reader.seek(std::io::SeekFrom::Start(0)).unwrap();
if size > 10485760 {
return Err(common::Error::UploadSizeLimitExceeded(size, 10485760));
}
let upload_result = {
let url_str = &parts
.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));
}
common::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(|| common::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(common::Error::Cancelled);
}
Some(Err(err)) => {
dlg.finished(false);
return Err(common::Error::HttpError(err));
}
Some(Ok(response)) => {
(parts, body) = response.into_parts();
if !parts.status.is_success() {
dlg.store_upload_url(None);
dlg.finished(false);
return Err(common::Error::Failure(
common::Response::from_parts(parts, body),
));
}
}
}
}
let response = common::Response::from_parts(parts, body);
dlg.finished(true);
return Ok(response);
}
}
}
}
/// 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<RS>(
self,
resumeable_stream: RS,
mime_type: mime::Mime,
) -> common::Result<common::Response>
where
RS: common::ReadSeek,
{
self.doit(
resumeable_stream,
mime_type,
common::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<RS>(
self,
stream: RS,
mime_type: mime::Mime,
) -> common::Result<common::Response>
where
RS: common::ReadSeek,
{
self.doit(stream, mime_type, common::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, C> {
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, C> {
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, C> {
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 common::Delegate) -> WatermarkSetCall<'a, C> {
self._delegate = Some(new_value);
self
}
/// Set any additional parameter of the query string used in the request.
/// It should be used to set parameters 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<T>(mut self, name: T, value: T) -> WatermarkSetCall<'a, C>
where
T: AsRef<str>,
{
self._additional_params
.insert(name.as_ref().to_string(), value.as_ref().to_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<St>(mut self, scope: St) -> WatermarkSetCall<'a, C>
where
St: AsRef<str>,
{
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<I, St>(mut self, scopes: I) -> WatermarkSetCall<'a, C>
where
I: IntoIterator<Item = St>,
St: AsRef<str>,
{
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, C> {
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 youtube3::{YouTube, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_only()
/// # .enable_http2()
/// # .build();
///
/// # let executor = hyper_util::rt::TokioExecutor::new();
/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// # secret,
/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # yup_oauth2::client::CustomHyperClientBuilder::from(
/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
/// # ),
/// # ).build().await.unwrap();
///
/// # let client = hyper_util::client::legacy::Client::builder(
/// # hyper_util::rt::TokioExecutor::new()
/// # )
/// # .build(
/// # hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_or_http()
/// # .enable_http2()
/// # .build()
/// # );
/// # let mut hub = YouTube::new(client, auth);
/// // You can configure optional parameters by calling 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("et")
/// .doit().await;
/// # }
/// ```
pub struct WatermarkUnsetCall<'a, C>
where
C: 'a,
{
hub: &'a YouTube<C>,
_channel_id: String,
_on_behalf_of_content_owner: Option<String>,
_delegate: Option<&'a mut dyn common::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>,
}
impl<'a, C> common::CallBuilder for WatermarkUnsetCall<'a, C> {}
impl<'a, C> WatermarkUnsetCall<'a, C>
where
C: common::Connector,
{
/// Perform the operation you have build so far.
pub async fn doit(mut self) -> common::Result<common::Response> {
use std::borrow::Cow;
use std::io::{Read, Seek};
use common::{url::Params, ToParts};
use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
let mut dd = common::DefaultDelegate;
let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(common::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(common::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::<Vec<_>>()[..])
.await
{
Ok(token) => token,
Err(e) => match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(common::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(common::to_body::<String>(None));
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let common::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(common::Error::HttpError(err));
}
Ok(res) => {
let (mut parts, body) = res.into_parts();
let mut body = common::Body::new(body);
if !parts.status.is_success() {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let error = serde_json::from_str(&common::to_string(&bytes));
let response = common::to_response(parts, bytes.into());
if let common::Retry::After(d) =
dlg.http_failure(&response, error.as_ref().ok())
{
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(match error {
Ok(value) => common::Error::BadRequest(value),
_ => common::Error::Failure(response),
});
}
let response = common::Response::from_parts(parts, body);
dlg.finished(true);
return Ok(response);
}
}
}
}
///
/// 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, C> {
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, C> {
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 common::Delegate,
) -> WatermarkUnsetCall<'a, C> {
self._delegate = Some(new_value);
self
}
/// Set any additional parameter of the query string used in the request.
/// It should be used to set parameters 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<T>(mut self, name: T, value: T) -> WatermarkUnsetCall<'a, C>
where
T: AsRef<str>,
{
self._additional_params
.insert(name.as_ref().to_string(), value.as_ref().to_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<St>(mut self, scope: St) -> WatermarkUnsetCall<'a, C>
where
St: AsRef<str>,
{
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<I, St>(mut self, scopes: I) -> WatermarkUnsetCall<'a, C>
where
I: IntoIterator<Item = St>,
St: AsRef<str>,
{
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, C> {
self._scopes.clear();
self
}
}
/// Allows a user to load live chat through a server-streamed RPC.
///
/// A builder for the *v3.liveChat.messages.stream* method supported by a *youtube* resource.
/// It is not used directly, but through a [`YoutubeMethods`] instance.
///
/// **Settable Parts**
///
/// * *id*
/// * *snippet*
/// * *authorDetails*
///
/// # 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 youtube3::{YouTube, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_only()
/// # .enable_http2()
/// # .build();
///
/// # let executor = hyper_util::rt::TokioExecutor::new();
/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// # secret,
/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # yup_oauth2::client::CustomHyperClientBuilder::from(
/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
/// # ),
/// # ).build().await.unwrap();
///
/// # let client = hyper_util::client::legacy::Client::builder(
/// # hyper_util::rt::TokioExecutor::new()
/// # )
/// # .build(
/// # hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_or_http()
/// # .enable_http2()
/// # .build()
/// # );
/// # let mut hub = YouTube::new(client, auth);
/// // You can configure optional parameters by calling 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_live_chat_messages_stream()
/// .profile_image_size(50)
/// .add_part("rebum.")
/// .page_token("et")
/// .max_results(71)
/// .live_chat_id("Stet")
/// .hl("aliquyam")
/// .doit().await;
/// # }
/// ```
pub struct YoutubeV3LiveChatMessageStreamCall<'a, C>
where
C: 'a,
{
hub: &'a YouTube<C>,
_profile_image_size: Option<u32>,
_part: Vec<String>,
_page_token: Option<String>,
_max_results: Option<u32>,
_live_chat_id: Option<String>,
_hl: Option<String>,
_delegate: Option<&'a mut dyn common::Delegate>,
_additional_params: HashMap<String, String>,
_scopes: BTreeSet<String>,
}
impl<'a, C> common::CallBuilder for YoutubeV3LiveChatMessageStreamCall<'a, C> {}
impl<'a, C> YoutubeV3LiveChatMessageStreamCall<'a, C>
where
C: common::Connector,
{
/// Perform the operation you have build so far.
pub async fn doit(mut self) -> common::Result<(common::Response, LiveChatMessageListResponse)> {
use std::borrow::Cow;
use std::io::{Read, Seek};
use common::{url::Params, ToParts};
use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
let mut dd = common::DefaultDelegate;
let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(common::MethodInfo {
id: "youtube.youtube.v3.liveChat.messages.stream",
http_method: hyper::Method::GET,
});
for &field in [
"alt",
"profileImageSize",
"part",
"pageToken",
"maxResults",
"liveChatId",
"hl",
]
.iter()
{
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Err(common::Error::FieldClash(field));
}
}
let mut params = Params::with_capacity(8 + self._additional_params.len());
if let Some(value) = self._profile_image_size.as_ref() {
params.push("profileImageSize", value.to_string());
}
if !self._part.is_empty() {
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._live_chat_id.as_ref() {
params.push("liveChatId", value);
}
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/stream";
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::<Vec<_>>()[..])
.await
{
Ok(token) => token,
Err(e) => match dlg.token(e) {
Ok(token) => token,
Err(e) => {
dlg.finished(false);
return Err(common::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(common::to_body::<String>(None));
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let common::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(common::Error::HttpError(err));
}
Ok(res) => {
let (mut parts, body) = res.into_parts();
let mut body = common::Body::new(body);
if !parts.status.is_success() {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let error = serde_json::from_str(&common::to_string(&bytes));
let response = common::to_response(parts, bytes.into());
if let common::Retry::After(d) =
dlg.http_failure(&response, error.as_ref().ok())
{
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(match error {
Ok(value) => common::Error::BadRequest(value),
_ => common::Error::Failure(response),
});
}
let response = {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let encoded = common::to_string(&bytes);
match serde_json::from_str(&encoded) {
Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
Err(error) => {
dlg.response_json_decode_error(&encoded, &error);
return Err(common::Error::JsonDecodeError(
encoded.to_string(),
error,
));
}
}
};
dlg.finished(true);
return Ok(response);
}
}
}
}
/// 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,
) -> YoutubeV3LiveChatMessageStreamCall<'a, C> {
self._profile_image_size = Some(new_value);
self
}
/// The *part* parameter specifies the liveChatComment resource parts that the API response will include. Supported values are id, snippet, and authorDetails.
///
/// 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.
///
/// **Settable Parts**
///
/// * *id*
/// * *snippet*
/// * *authorDetails*
pub fn add_part(mut self, new_value: &str) -> YoutubeV3LiveChatMessageStreamCall<'a, C> {
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 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) -> YoutubeV3LiveChatMessageStreamCall<'a, C> {
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. Not used in the streaming RPC.
///
/// Sets the *max results* query property to the given value.
pub fn max_results(mut self, new_value: u32) -> YoutubeV3LiveChatMessageStreamCall<'a, C> {
self._max_results = Some(new_value);
self
}
/// The id of the live chat for which comments should be returned.
///
/// Sets the *live chat id* query property to the given value.
pub fn live_chat_id(mut self, new_value: &str) -> YoutubeV3LiveChatMessageStreamCall<'a, C> {
self._live_chat_id = Some(new_value.to_string());
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) -> YoutubeV3LiveChatMessageStreamCall<'a, C> {
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 common::Delegate,
) -> YoutubeV3LiveChatMessageStreamCall<'a, C> {
self._delegate = Some(new_value);
self
}
/// Set any additional parameter of the query string used in the request.
/// It should be used to set parameters 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<T>(mut self, name: T, value: T) -> YoutubeV3LiveChatMessageStreamCall<'a, C>
where
T: AsRef<str>,
{
self._additional_params
.insert(name.as_ref().to_string(), value.as_ref().to_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<St>(mut self, scope: St) -> YoutubeV3LiveChatMessageStreamCall<'a, C>
where
St: AsRef<str>,
{
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<I, St>(mut self, scopes: I) -> YoutubeV3LiveChatMessageStreamCall<'a, C>
where
I: IntoIterator<Item = St>,
St: AsRef<str>,
{
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) -> YoutubeV3LiveChatMessageStreamCall<'a, C> {
self._scopes.clear();
self
}
}
/// Retrieves a batch of VideoStat resources, possibly filtered.
///
/// A builder for the *v3.videos.batchGetStats* 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;
/// # async fn dox() {
/// # use youtube3::{YouTube, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_only()
/// # .enable_http2()
/// # .build();
///
/// # let executor = hyper_util::rt::TokioExecutor::new();
/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// # secret,
/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # yup_oauth2::client::CustomHyperClientBuilder::from(
/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
/// # ),
/// # ).build().await.unwrap();
///
/// # let client = hyper_util::client::legacy::Client::builder(
/// # hyper_util::rt::TokioExecutor::new()
/// # )
/// # .build(
/// # hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_or_http()
/// # .enable_http2()
/// # .build()
/// # );
/// # let mut hub = YouTube::new(client, auth);
/// // You can configure optional parameters by calling 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_videos_batch_get_stats()
/// .add_part("kasd")
/// .on_behalf_of_content_owner("Lorem")
/// .add_id("sit")
/// .doit().await;
/// # }
/// ```
pub struct YoutubeV3VideoBatchGetStatCall<'a, C>
where
C: 'a,
{
hub: &'a YouTube<C>,
_part: Vec<String>,
_on_behalf_of_content_owner: Option<String>,
_id: Vec<String>,
_delegate: Option<&'a mut dyn common::Delegate>,
_additional_params: HashMap<String, String>,
}
impl<'a, C> common::CallBuilder for YoutubeV3VideoBatchGetStatCall<'a, C> {}
impl<'a, C> YoutubeV3VideoBatchGetStatCall<'a, C>
where
C: common::Connector,
{
/// Perform the operation you have build so far.
pub async fn doit(mut self) -> common::Result<(common::Response, BatchGetStatsResponse)> {
use std::borrow::Cow;
use std::io::{Read, Seek};
use common::{url::Params, ToParts};
use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
let mut dd = common::DefaultDelegate;
let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(common::MethodInfo {
id: "youtube.youtube.v3.videos.batchGetStats",
http_method: hyper::Method::GET,
});
for &field in ["alt", "part", "onBehalfOfContentOwner", "id"].iter() {
if self._additional_params.contains_key(field) {
dlg.finished(false);
return Err(common::Error::FieldClash(field));
}
}
let mut params = Params::with_capacity(5 + self._additional_params.len());
if !self._part.is_empty() {
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 !self._id.is_empty() {
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/videos:batchGetStats";
match dlg.api_key() {
Some(value) => params.push("key", value),
None => {
dlg.finished(false);
return Err(common::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(common::to_body::<String>(None));
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let common::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(common::Error::HttpError(err));
}
Ok(res) => {
let (mut parts, body) = res.into_parts();
let mut body = common::Body::new(body);
if !parts.status.is_success() {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let error = serde_json::from_str(&common::to_string(&bytes));
let response = common::to_response(parts, bytes.into());
if let common::Retry::After(d) =
dlg.http_failure(&response, error.as_ref().ok())
{
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(match error {
Ok(value) => common::Error::BadRequest(value),
_ => common::Error::Failure(response),
});
}
let response = {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let encoded = common::to_string(&bytes);
match serde_json::from_str(&encoded) {
Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
Err(error) => {
dlg.response_json_decode_error(&encoded, &error);
return Err(common::Error::JsonDecodeError(
encoded.to_string(),
error,
));
}
}
};
dlg.finished(true);
return Ok(response);
}
}
}
}
/// Required. The `**part**` parameter specifies a comma-separated list of one or more `videoStat` 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 `videoStat` resource, the `statistics` property contains `view_count` and `like_count`. 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.
pub fn add_part(mut self, new_value: &str) -> YoutubeV3VideoBatchGetStatCall<'a, C> {
self._part.push(new_value.to_string());
self
}
/// Optional. **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,
) -> YoutubeV3VideoBatchGetStatCall<'a, C> {
self._on_behalf_of_content_owner = Some(new_value.to_string());
self
}
/// Required. 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) -> YoutubeV3VideoBatchGetStatCall<'a, C> {
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 common::Delegate,
) -> YoutubeV3VideoBatchGetStatCall<'a, C> {
self._delegate = Some(new_value);
self
}
/// Set any additional parameter of the query string used in the request.
/// It should be used to set parameters 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<T>(mut self, name: T, value: T) -> YoutubeV3VideoBatchGetStatCall<'a, C>
where
T: AsRef<str>,
{
self._additional_params
.insert(name.as_ref().to_string(), value.as_ref().to_string());
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 youtube3::{YouTube, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
///
/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_only()
/// # .enable_http2()
/// # .build();
///
/// # let executor = hyper_util::rt::TokioExecutor::new();
/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
/// # secret,
/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
/// # yup_oauth2::client::CustomHyperClientBuilder::from(
/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
/// # ),
/// # ).build().await.unwrap();
///
/// # let client = hyper_util::client::legacy::Client::builder(
/// # hyper_util::rt::TokioExecutor::new()
/// # )
/// # .build(
/// # hyper_rustls::HttpsConnectorBuilder::new()
/// # .with_native_roots()
/// # .unwrap()
/// # .https_or_http()
/// # .enable_http2()
/// # .build()
/// # );
/// # let mut hub = YouTube::new(client, auth);
/// // As the method needs a request, you would usually fill it with the desired information
/// // into the 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("kasd")
/// .doit().await;
/// # }
/// ```
pub struct YoutubeV3UpdateCommentThreadCall<'a, C>
where
C: 'a,
{
hub: &'a YouTube<C>,
_request: CommentThread,
_part: Vec<String>,
_delegate: Option<&'a mut dyn common::Delegate>,
_additional_params: HashMap<String, String>,
}
impl<'a, C> common::CallBuilder for YoutubeV3UpdateCommentThreadCall<'a, C> {}
impl<'a, C> YoutubeV3UpdateCommentThreadCall<'a, C>
where
C: common::Connector,
{
/// Perform the operation you have build so far.
pub async fn doit(mut self) -> common::Result<(common::Response, CommentThread)> {
use std::borrow::Cow;
use std::io::{Read, Seek};
use common::{url::Params, ToParts};
use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
let mut dd = common::DefaultDelegate;
let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
dlg.begin(common::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(common::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.is_empty() {
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(common::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 = serde_json::value::to_value(&self._request).expect("serde to work");
common::remove_json_null_values(&mut value);
let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
serde_json::to_writer(&mut dst, &value).unwrap();
dst
};
let request_size = request_value_reader
.seek(std::io::SeekFrom::End(0))
.unwrap();
request_value_reader
.seek(std::io::SeekFrom::Start(0))
.unwrap();
loop {
request_value_reader
.seek(std::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(common::to_body(
request_value_reader.get_ref().clone().into(),
));
client.request(request.unwrap()).await
};
match req_result {
Err(err) => {
if let common::Retry::After(d) = dlg.http_error(&err) {
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(common::Error::HttpError(err));
}
Ok(res) => {
let (mut parts, body) = res.into_parts();
let mut body = common::Body::new(body);
if !parts.status.is_success() {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let error = serde_json::from_str(&common::to_string(&bytes));
let response = common::to_response(parts, bytes.into());
if let common::Retry::After(d) =
dlg.http_failure(&response, error.as_ref().ok())
{
sleep(d).await;
continue;
}
dlg.finished(false);
return Err(match error {
Ok(value) => common::Error::BadRequest(value),
_ => common::Error::Failure(response),
});
}
let response = {
let bytes = common::to_bytes(body).await.unwrap_or_default();
let encoded = common::to_string(&bytes);
match serde_json::from_str(&encoded) {
Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
Err(error) => {
dlg.response_json_decode_error(&encoded, &error);
return Err(common::Error::JsonDecodeError(
encoded.to_string(),
error,
));
}
}
};
dlg.finished(true);
return Ok(response);
}
}
}
}
///
/// Sets the *request* property to the given value.
///
/// Even though 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, C> {
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, C> {
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 common::Delegate,
) -> YoutubeV3UpdateCommentThreadCall<'a, C> {
self._delegate = Some(new_value);
self
}
/// Set any additional parameter of the query string used in the request.
/// It should be used to set parameters 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<T>(mut self, name: T, value: T) -> YoutubeV3UpdateCommentThreadCall<'a, C>
where
T: AsRef<str>,
{
self._additional_params
.insert(name.as_ref().to_string(), value.as_ref().to_string());
self
}
}