From 70ea612f19fbe7e1ef0a01b0d399fb357a46c390 Mon Sep 17 00:00:00 2001 From: Sebastian Thiel Date: Thu, 5 Mar 2015 11:07:43 +0100 Subject: [PATCH] fix(builders): fixed part handling,it compiles now What's missing is docs, which will see some work now. I guess it will be best to hide all the prelude from the user, to allow him to focus on what's important here. --- gen/youtube3/src/lib.rs | 662 ++++++++++++++++++++++++++------------- src/mako/lib.rs.mako | 2 +- src/mako/lib/mbuild.mako | 8 +- src/mako/lib/rbuild.mako | 4 +- src/mako/lib/schema.mako | 26 +- src/mako/lib/util.py | 3 +- 6 files changed, 476 insertions(+), 229 deletions(-) diff --git a/gen/youtube3/src/lib.rs b/gen/youtube3/src/lib.rs index 30f479b5cd3..0c195c837c0 100644 --- a/gen/youtube3/src/lib.rs +++ b/gen/youtube3/src/lib.rs @@ -114,7 +114,7 @@ use std::borrow::BorrowMut; use std::cell::RefCell; use std::default::Default; -pub use cmn::{Hub, ResourceMethodsBuilder, MethodBuilder, Resource, Part, ResponseResult, RequestResult, NestedType}; +pub use cmn::{Hub, ResourceMethodsBuilder, MethodBuilder, Resource, Part, ResponseResult, RequestValue, NestedType}; // ######## // HUB ### @@ -414,6 +414,24 @@ impl RequestValue for Playlist {} impl Resource for Playlist {} impl ResponseResult for Playlist {} +impl 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.status.is_some() { r = r + "status,"; } + if self.kind.is_some() { r = r + "kind,"; } + if self.content_details.is_some() { r = r + "contentDetails,"; } + if self.snippet.is_some() { r = r + "snippet,"; } + if self.player.is_some() { r = r + "player,"; } + if self.etag.is_some() { r = r + "etag,"; } + if self.id.is_some() { r = r + "id,"; } + if self.localizations.len() > 0 { r = r + "localizations,"; } + r.pop(); + r + } +} /// There is no detailed description. /// @@ -563,6 +581,23 @@ impl RequestValue for LiveStream {} impl Resource for LiveStream {} impl ResponseResult for LiveStream {} +impl 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.status.is_some() { r = r + "status,"; } + if self.snippet.is_some() { r = r + "snippet,"; } + if self.kind.is_some() { r = r + "kind,"; } + if self.etag.is_some() { r = r + "etag,"; } + if self.content_details.is_some() { r = r + "contentDetails,"; } + if self.cdn.is_some() { r = r + "cdn,"; } + if self.id.is_some() { r = r + "id,"; } + r.pop(); + r + } +} /// There is no detailed description. /// @@ -952,6 +987,21 @@ pub struct InvideoBranding { impl RequestValue for InvideoBranding {} +impl InvideoBranding { + /// 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.target_channel_id.is_some() { r = r + "targetChannelId,"; } + if self.position.is_some() { r = r + "position,"; } + if self.image_url.is_some() { r = r + "imageUrl,"; } + if self.timing.is_some() { r = r + "timing,"; } + if self.image_bytes.is_some() { r = r + "imageBytes,"; } + r.pop(); + r + } +} /// Information about the playlist item's privacy status. /// @@ -1040,6 +1090,22 @@ impl RequestValue for PlaylistItem {} impl Resource for PlaylistItem {} impl ResponseResult for PlaylistItem {} +impl 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.status.is_some() { r = r + "status,"; } + if self.snippet.is_some() { r = r + "snippet,"; } + if self.kind.is_some() { r = r + "kind,"; } + if self.etag.is_some() { r = r + "etag,"; } + if self.content_details.is_some() { r = r + "contentDetails,"; } + if self.id.is_some() { r = r + "id,"; } + r.pop(); + r + } +} /// There is no detailed description. /// @@ -1447,6 +1513,35 @@ impl RequestValue for Video {} impl Resource for Video {} impl ResponseResult for Video {} +impl 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.status.is_some() { r = r + "status,"; } + if self.topic_details.is_some() { r = r + "topicDetails,"; } + if self.monetization_details.is_some() { r = r + "monetizationDetails,"; } + if self.suggestions.is_some() { r = r + "suggestions,"; } + if self.age_gating.is_some() { r = r + "ageGating,"; } + if self.file_details.is_some() { r = r + "fileDetails,"; } + if self.player.is_some() { r = r + "player,"; } + if self.id.is_some() { r = r + "id,"; } + if self.localizations.len() > 0 { r = r + "localizations,"; } + if self.live_streaming_details.is_some() { r = r + "liveStreamingDetails,"; } + if self.processing_details.is_some() { r = r + "processingDetails,"; } + if self.kind.is_some() { r = r + "kind,"; } + if self.statistics.is_some() { r = r + "statistics,"; } + if self.content_details.is_some() { r = r + "contentDetails,"; } + if self.conversion_pings.is_some() { r = r + "conversionPings,"; } + if self.snippet.is_some() { r = r + "snippet,"; } + if self.etag.is_some() { r = r + "etag,"; } + if self.project_details.is_some() { r = r + "projectDetails,"; } + if self.recording_details.is_some() { r = r + "recordingDetails,"; } + r.pop(); + r + } +} /// Geographical coordinates of a point, in WGS84. /// @@ -1629,6 +1724,22 @@ impl RequestValue for Subscription {} impl Resource for Subscription {} impl ResponseResult for Subscription {} +impl 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.snippet.is_some() { r = r + "snippet,"; } + if self.kind.is_some() { r = r + "kind,"; } + if self.etag.is_some() { r = r + "etag,"; } + if self.content_details.is_some() { r = r + "contentDetails,"; } + if self.subscriber_snippet.is_some() { r = r + "subscriberSnippet,"; } + if self.id.is_some() { r = r + "id,"; } + r.pop(); + r + } +} /// Basic details about an i18n region, such as region code and human-readable name. /// @@ -1978,6 +2089,22 @@ impl RequestValue for LiveBroadcast {} impl Resource for LiveBroadcast {} impl ResponseResult for LiveBroadcast {} +impl 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.status.is_some() { r = r + "status,"; } + if self.snippet.is_some() { r = r + "snippet,"; } + if self.kind.is_some() { r = r + "kind,"; } + if self.etag.is_some() { r = r + "etag,"; } + if self.content_details.is_some() { r = r + "contentDetails,"; } + if self.id.is_some() { r = r + "id,"; } + r.pop(); + r + } +} /// Information about a video stream. /// @@ -2076,6 +2203,30 @@ impl RequestValue for Channel {} impl Resource for Channel {} impl ResponseResult for Channel {} +impl 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.status.is_some() { r = r + "status,"; } + if self.invideo_promotion.is_some() { r = r + "invideoPromotion,"; } + if self.kind.is_some() { r = r + "kind,"; } + if self.statistics.is_some() { r = r + "statistics,"; } + if self.content_owner_details.is_some() { r = r + "contentOwnerDetails,"; } + if self.topic_details.is_some() { r = r + "topicDetails,"; } + if self.content_details.is_some() { r = r + "contentDetails,"; } + if self.branding_settings.is_some() { r = r + "brandingSettings,"; } + if self.conversion_pings.is_some() { r = r + "conversionPings,"; } + if self.snippet.is_some() { r = r + "snippet,"; } + if self.audit_details.is_some() { r = r + "auditDetails,"; } + if self.etag.is_some() { r = r + "etag,"; } + if self.id.is_some() { r = r + "id,"; } + if self.localizations.len() > 0 { r = r + "localizations,"; } + r.pop(); + r + } +} /// Statistics about a channel: number of subscribers, number of videos in the channel, etc. /// @@ -2492,6 +2643,22 @@ impl RequestValue for ChannelSection {} impl Resource for ChannelSection {} impl ResponseResult for ChannelSection {} +impl 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.snippet.is_some() { r = r + "snippet,"; } + if self.kind.is_some() { r = r + "kind,"; } + if self.etag.is_some() { r = r + "etag,"; } + if self.content_details.is_some() { r = r + "contentDetails,"; } + if self.id.is_some() { r = r + "id,"; } + if self.localizations.len() > 0 { r = r + "localizations,"; } + r.pop(); + r + } +} /// There is no detailed description. /// @@ -2763,6 +2930,21 @@ pub struct Activity { impl RequestValue for Activity {} impl ResponseResult for Activity {} +impl Activity { + /// 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.snippet.is_some() { r = r + "snippet,"; } + if self.content_details.is_some() { r = r + "contentDetails,"; } + if self.kind.is_some() { r = r + "kind,"; } + if self.etag.is_some() { r = r + "etag,"; } + if self.id.is_some() { r = r + "id,"; } + r.pop(); + r + } +} /// Basic details about a subscription's subscriber including title, description, channel ID and thumbnails. /// @@ -3159,6 +3341,19 @@ pub struct ChannelBannerResource { impl RequestValue for ChannelBannerResource {} impl ResponseResult for ChannelBannerResource {} +impl ChannelBannerResource { + /// 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.url.is_some() { r = r + "url,"; } + if self.kind.is_some() { r = r + "kind,"; } + if self.etag.is_some() { r = r + "etag,"; } + r.pop(); + r + } +} /// There is no detailed description. /// @@ -3322,9 +3517,10 @@ impl<'a, C, NC, A> ChannelBannerMethodsBuilder<'a, C, NC, A> { /// - Call the channelBanners.insert method to upload the binary image data to YouTube. The image must have a 16:9 aspect ratio and be at least 2120x1192 pixels. /// - Extract the url property's value from the response that the API returns for step 1. /// - Call the channels.update method to update the channel's branding settings. Set the brandingSettings.image.bannerExternalUrl property's value to the URL obtained in step 2. - pub fn insert(&self) -> ChannelBannerInsertMethodBuilder<'a, C, NC, A> { + pub fn insert(&self, request: &ChannelBannerResource) -> ChannelBannerInsertMethodBuilder<'a, C, NC, A> { ChannelBannerInsertMethodBuilder { hub: self.hub, + _request: request.clone(), _on_behalf_of_content_owner: Default::default(), } } @@ -4294,9 +4490,10 @@ impl<'a, C, NC, A> WatermarkMethodsBuilder<'a, C, NC, A> { /// Create a builder to help you perform the following task: /// /// Uploads a watermark image to YouTube and sets it for a channel. - pub fn set(&self, channel_id: &str) -> WatermarkSetMethodBuilder<'a, C, NC, A> { + pub fn set(&self, request: &InvideoBranding, channel_id: &str) -> WatermarkSetMethodBuilder<'a, C, NC, A> { WatermarkSetMethodBuilder { hub: self.hub, + _request: request.clone(), _channel_id: channel_id.to_string(), _on_behalf_of_content_owner: Default::default(), } @@ -4580,10 +4777,11 @@ impl<'a, C, NC, A> ActivityMethodsBuilder<'a, C, NC, A> { /// Posts a bulletin for a specific channel. (The user submitting the request must be authorized to act on the channel's behalf.) /// /// Note: Even though an activity resource can contain information about actions like a user rating a video or marking a video as a favorite, you need to use other API methods to generate those activity resources. For example, you would use the API's videos.rate() method to rate a video and the playlistItems.insert() method to mark a video as a favorite. - pub fn insert(&self, part: &str) -> ActivityInsertMethodBuilder<'a, C, NC, A> { + pub fn insert(&self, request: &Activity) -> ActivityInsertMethodBuilder<'a, C, NC, A> { ActivityInsertMethodBuilder { hub: self.hub, - _part: part.to_string(), + _request: request.clone(), + _part: request.to_parts(), } } } @@ -4637,8 +4835,8 @@ pub struct I18nLanguageListMethodBuilder<'a, C, NC, A> A: 'a, { hub: &'a YouTube, - _part: String, - _hl: Option, + _part: String, + _hl: Option, } impl<'a, C, NC, A> MethodBuilder for I18nLanguageListMethodBuilder<'a, C, NC, A> {} @@ -4718,7 +4916,8 @@ pub struct ChannelBannerInsertMethodBuilder<'a, C, NC, A> A: 'a, { hub: &'a YouTube, - _on_behalf_of_content_owner: Option, + _request: ChannelBannerResource, + _on_behalf_of_content_owner: Option, } impl<'a, C, NC, A> MethodBuilder for ChannelBannerInsertMethodBuilder<'a, C, NC, A> {} @@ -4732,6 +4931,15 @@ impl<'a, C, NC, A> ChannelBannerInsertMethodBuilder<'a, C, NC, A> { } + /// Sets the *request* property to the given value. + /// + /// Even though the property as already been set when instantiating this call, + /// we provide this method for API completeness. + /// + pub fn request(&mut self, new_value: &ChannelBannerResource) -> &mut ChannelBannerInsertMethodBuilder<'a, C, NC, A> { + self._request = new_value.clone(); + return self; + } /// Sets the *on behalf of content owner* query property to the given value. /// /// @@ -4786,11 +4994,11 @@ pub struct ChannelSectionListMethodBuilder<'a, C, NC, A> A: 'a, { hub: &'a YouTube, - _part: String, - _on_behalf_of_content_owner: Option, - _mine: Option, - _id: Option, - _channel_id: Option, + _part: String, + _on_behalf_of_content_owner: Option, + _mine: Option, + _id: Option, + _channel_id: Option, } impl<'a, C, NC, A> MethodBuilder for ChannelSectionListMethodBuilder<'a, C, NC, A> {} @@ -4894,10 +5102,10 @@ pub struct ChannelSectionInsertMethodBuilder<'a, C, NC, A> A: 'a, { hub: &'a YouTube, - _request: ChannelSection, - _part: String, - _on_behalf_of_content_owner_channel: Option, - _on_behalf_of_content_owner: Option, + _request: ChannelSection, + _part: String, + _on_behalf_of_content_owner_channel: Option, + _on_behalf_of_content_owner: Option, } impl<'a, C, NC, A> MethodBuilder for ChannelSectionInsertMethodBuilder<'a, C, NC, A> {} @@ -5001,8 +5209,8 @@ pub struct ChannelSectionDeleteMethodBuilder<'a, C, NC, A> A: 'a, { hub: &'a YouTube, - _id: String, - _on_behalf_of_content_owner: Option, + _id: String, + _on_behalf_of_content_owner: Option, } impl<'a, C, NC, A> MethodBuilder for ChannelSectionDeleteMethodBuilder<'a, C, NC, A> {} @@ -5080,9 +5288,9 @@ pub struct ChannelSectionUpdateMethodBuilder<'a, C, NC, A> A: 'a, { hub: &'a YouTube, - _request: ChannelSection, - _part: String, - _on_behalf_of_content_owner: Option, + _request: ChannelSection, + _part: String, + _on_behalf_of_content_owner: Option, } impl<'a, C, NC, A> MethodBuilder for ChannelSectionUpdateMethodBuilder<'a, C, NC, A> {} @@ -5174,10 +5382,10 @@ pub struct GuideCategoryListMethodBuilder<'a, C, NC, A> A: 'a, { hub: &'a YouTube, - _part: String, - _region_code: Option, - _id: Option, - _hl: Option, + _part: String, + _region_code: Option, + _id: Option, + _hl: Option, } impl<'a, C, NC, A> MethodBuilder for GuideCategoryListMethodBuilder<'a, C, NC, A> {} @@ -5271,10 +5479,10 @@ pub struct PlaylistInsertMethodBuilder<'a, C, NC, A> A: 'a, { hub: &'a YouTube, - _request: Playlist, - _part: String, - _on_behalf_of_content_owner_channel: Option, - _on_behalf_of_content_owner: Option, + _request: Playlist, + _part: String, + _on_behalf_of_content_owner_channel: Option, + _on_behalf_of_content_owner: Option, } impl<'a, C, NC, A> MethodBuilder for PlaylistInsertMethodBuilder<'a, C, NC, A> {} @@ -5378,14 +5586,14 @@ pub struct PlaylistListMethodBuilder<'a, C, NC, A> A: 'a, { hub: &'a YouTube, - _part: String, - _page_token: Option, - _on_behalf_of_content_owner_channel: Option, - _on_behalf_of_content_owner: Option, - _mine: Option, - _max_results: Option, - _id: Option, - _channel_id: Option, + _part: String, + _page_token: Option, + _on_behalf_of_content_owner_channel: Option, + _on_behalf_of_content_owner: Option, + _mine: Option, + _max_results: Option, + _id: Option, + _channel_id: Option, } impl<'a, C, NC, A> MethodBuilder for PlaylistListMethodBuilder<'a, C, NC, A> {} @@ -5517,8 +5725,8 @@ pub struct PlaylistDeleteMethodBuilder<'a, C, NC, A> A: 'a, { hub: &'a YouTube, - _id: String, - _on_behalf_of_content_owner: Option, + _id: String, + _on_behalf_of_content_owner: Option, } impl<'a, C, NC, A> MethodBuilder for PlaylistDeleteMethodBuilder<'a, C, NC, A> {} @@ -5596,9 +5804,9 @@ pub struct PlaylistUpdateMethodBuilder<'a, C, NC, A> A: 'a, { hub: &'a YouTube, - _request: Playlist, - _part: String, - _on_behalf_of_content_owner: Option, + _request: Playlist, + _part: String, + _on_behalf_of_content_owner: Option, } impl<'a, C, NC, A> MethodBuilder for PlaylistUpdateMethodBuilder<'a, C, NC, A> {} @@ -5692,8 +5900,8 @@ pub struct ThumbnailSetMethodBuilder<'a, C, NC, A> A: 'a, { hub: &'a YouTube, - _video_id: String, - _on_behalf_of_content_owner: Option, + _video_id: String, + _on_behalf_of_content_owner: Option, } impl<'a, C, NC, A> MethodBuilder for ThumbnailSetMethodBuilder<'a, C, NC, A> {} @@ -5769,17 +5977,17 @@ pub struct VideoListMethodBuilder<'a, C, NC, A> A: 'a, { hub: &'a YouTube, - _part: String, - _video_category_id: Option, - _region_code: Option, - _page_token: Option, - _on_behalf_of_content_owner: Option, - _my_rating: Option, - _max_results: Option, - _locale: Option, - _id: Option, - _hl: Option, - _chart: Option, + _part: String, + _video_category_id: Option, + _region_code: Option, + _page_token: Option, + _on_behalf_of_content_owner: Option, + _my_rating: Option, + _max_results: Option, + _locale: Option, + _id: Option, + _hl: Option, + _chart: Option, } impl<'a, C, NC, A> MethodBuilder for VideoListMethodBuilder<'a, C, NC, A> {} @@ -5935,9 +6143,9 @@ pub struct VideoRateMethodBuilder<'a, C, NC, A> A: 'a, { hub: &'a YouTube, - _id: String, - _rating: String, - _on_behalf_of_content_owner: Option, + _id: String, + _rating: String, + _on_behalf_of_content_owner: Option, } impl<'a, C, NC, A> MethodBuilder for VideoRateMethodBuilder<'a, C, NC, A> {} @@ -6025,8 +6233,8 @@ pub struct VideoGetratingMethodBuilder<'a, C, NC, A> A: 'a, { hub: &'a YouTube, - _id: String, - _on_behalf_of_content_owner: Option, + _id: String, + _on_behalf_of_content_owner: Option, } impl<'a, C, NC, A> MethodBuilder for VideoGetratingMethodBuilder<'a, C, NC, A> {} @@ -6104,8 +6312,8 @@ pub struct VideoDeleteMethodBuilder<'a, C, NC, A> A: 'a, { hub: &'a YouTube, - _id: String, - _on_behalf_of_content_owner: Option, + _id: String, + _on_behalf_of_content_owner: Option, } impl<'a, C, NC, A> MethodBuilder for VideoDeleteMethodBuilder<'a, C, NC, A> {} @@ -6183,9 +6391,9 @@ pub struct VideoUpdateMethodBuilder<'a, C, NC, A> A: 'a, { hub: &'a YouTube, - _request: Video, - _part: String, - _on_behalf_of_content_owner: Option, + _request: Video, + _part: String, + _on_behalf_of_content_owner: Option, } impl<'a, C, NC, A> MethodBuilder for VideoUpdateMethodBuilder<'a, C, NC, A> {} @@ -6281,13 +6489,13 @@ pub struct VideoInsertMethodBuilder<'a, C, NC, A> A: 'a, { hub: &'a YouTube, - _request: Video, - _part: String, - _stabilize: Option, - _on_behalf_of_content_owner_channel: Option, - _on_behalf_of_content_owner: Option, - _notify_subscribers: Option, - _auto_levels: Option, + _request: Video, + _part: String, + _stabilize: Option, + _on_behalf_of_content_owner_channel: Option, + _on_behalf_of_content_owner: Option, + _notify_subscribers: Option, + _auto_levels: Option, } impl<'a, C, NC, A> MethodBuilder for VideoInsertMethodBuilder<'a, C, NC, A> {} @@ -6415,8 +6623,8 @@ pub struct SubscriptionInsertMethodBuilder<'a, C, NC, A> A: 'a, { hub: &'a YouTube, - _request: Subscription, - _part: String, + _request: Subscription, + _part: String, } impl<'a, C, NC, A> MethodBuilder for SubscriptionInsertMethodBuilder<'a, C, NC, A> {} @@ -6498,17 +6706,17 @@ pub struct SubscriptionListMethodBuilder<'a, C, NC, A> A: 'a, { hub: &'a YouTube, - _part: String, - _page_token: Option, - _order: Option, - _on_behalf_of_content_owner_channel: Option, - _on_behalf_of_content_owner: Option, - _my_subscribers: Option, - _mine: Option, - _max_results: Option, - _id: Option, - _for_channel_id: Option, - _channel_id: Option, + _part: String, + _page_token: Option, + _order: Option, + _on_behalf_of_content_owner_channel: Option, + _on_behalf_of_content_owner: Option, + _my_subscribers: Option, + _mine: Option, + _max_results: Option, + _id: Option, + _for_channel_id: Option, + _channel_id: Option, } impl<'a, C, NC, A> MethodBuilder for SubscriptionListMethodBuilder<'a, C, NC, A> {} @@ -6664,7 +6872,7 @@ pub struct SubscriptionDeleteMethodBuilder<'a, C, NC, A> A: 'a, { hub: &'a YouTube, - _id: String, + _id: String, } impl<'a, C, NC, A> MethodBuilder for SubscriptionDeleteMethodBuilder<'a, C, NC, A> {} @@ -6732,36 +6940,36 @@ pub struct SearchListMethodBuilder<'a, C, NC, A> A: 'a, { hub: &'a YouTube, - _part: String, - _video_type: Option, - _video_syndicated: Option, - _video_license: Option, - _video_embeddable: Option, - _video_duration: Option, - _video_dimension: Option, - _video_definition: Option, - _video_category_id: Option, - _video_caption: Option, - _type_: Option, - _topic_id: Option, - _safe_search: Option, - _relevance_language: Option, - _related_to_video_id: Option, - _region_code: Option, - _q: Option, - _published_before: Option, - _published_after: Option, - _page_token: Option, - _order: Option, - _on_behalf_of_content_owner: Option, - _max_results: Option, - _location_radius: Option, - _location: Option, - _for_mine: Option, - _for_content_owner: Option, - _event_type: Option, - _channel_type: Option, - _channel_id: Option, + _part: String, + _video_type: Option, + _video_syndicated: Option, + _video_license: Option, + _video_embeddable: Option, + _video_duration: Option, + _video_dimension: Option, + _video_definition: Option, + _video_category_id: Option, + _video_caption: Option, + _type_: Option, + _topic_id: Option, + _safe_search: Option, + _relevance_language: Option, + _related_to_video_id: Option, + _region_code: Option, + _q: Option, + _published_before: Option, + _published_after: Option, + _page_token: Option, + _order: Option, + _on_behalf_of_content_owner: Option, + _max_results: Option, + _location_radius: Option, + _location: Option, + _for_mine: Option, + _for_content_owner: Option, + _event_type: Option, + _channel_type: Option, + _channel_id: Option, } impl<'a, C, NC, A> MethodBuilder for SearchListMethodBuilder<'a, C, NC, A> {} @@ -7067,8 +7275,8 @@ pub struct I18nRegionListMethodBuilder<'a, C, NC, A> A: 'a, { hub: &'a YouTube, - _part: String, - _hl: Option, + _part: String, + _hl: Option, } impl<'a, C, NC, A> MethodBuilder for I18nRegionListMethodBuilder<'a, C, NC, A> {} @@ -7144,10 +7352,10 @@ pub struct LiveStreamUpdateMethodBuilder<'a, C, NC, A> A: 'a, { hub: &'a YouTube, - _request: LiveStream, - _part: String, - _on_behalf_of_content_owner_channel: Option, - _on_behalf_of_content_owner: Option, + _request: LiveStream, + _part: String, + _on_behalf_of_content_owner_channel: Option, + _on_behalf_of_content_owner: Option, } impl<'a, C, NC, A> MethodBuilder for LiveStreamUpdateMethodBuilder<'a, C, NC, A> {} @@ -7253,9 +7461,9 @@ pub struct LiveStreamDeleteMethodBuilder<'a, C, NC, A> A: 'a, { hub: &'a YouTube, - _id: String, - _on_behalf_of_content_owner_channel: Option, - _on_behalf_of_content_owner: Option, + _id: String, + _on_behalf_of_content_owner_channel: Option, + _on_behalf_of_content_owner: Option, } impl<'a, C, NC, A> MethodBuilder for LiveStreamDeleteMethodBuilder<'a, C, NC, A> {} @@ -7345,13 +7553,13 @@ pub struct LiveStreamListMethodBuilder<'a, C, NC, A> A: 'a, { hub: &'a YouTube, - _part: String, - _page_token: Option, - _on_behalf_of_content_owner_channel: Option, - _on_behalf_of_content_owner: Option, - _mine: Option, - _max_results: Option, - _id: Option, + _part: String, + _page_token: Option, + _on_behalf_of_content_owner_channel: Option, + _on_behalf_of_content_owner: Option, + _mine: Option, + _max_results: Option, + _id: Option, } impl<'a, C, NC, A> MethodBuilder for LiveStreamListMethodBuilder<'a, C, NC, A> {} @@ -7473,10 +7681,10 @@ pub struct LiveStreamInsertMethodBuilder<'a, C, NC, A> A: 'a, { hub: &'a YouTube, - _request: LiveStream, - _part: String, - _on_behalf_of_content_owner_channel: Option, - _on_behalf_of_content_owner: Option, + _request: LiveStream, + _part: String, + _on_behalf_of_content_owner_channel: Option, + _on_behalf_of_content_owner: Option, } impl<'a, C, NC, A> MethodBuilder for LiveStreamInsertMethodBuilder<'a, C, NC, A> {} @@ -7580,9 +7788,9 @@ pub struct ChannelUpdateMethodBuilder<'a, C, NC, A> A: 'a, { hub: &'a YouTube, - _request: Channel, - _part: String, - _on_behalf_of_content_owner: Option, + _request: Channel, + _part: String, + _on_behalf_of_content_owner: Option, } impl<'a, C, NC, A> MethodBuilder for ChannelUpdateMethodBuilder<'a, C, NC, A> {} @@ -7674,16 +7882,16 @@ pub struct ChannelListMethodBuilder<'a, C, NC, A> A: 'a, { hub: &'a YouTube, - _part: String, - _page_token: Option, - _on_behalf_of_content_owner: Option, - _my_subscribers: Option, - _mine: Option, - _max_results: Option, - _managed_by_me: Option, - _id: Option, - _for_username: Option, - _category_id: Option, + _part: String, + _page_token: Option, + _on_behalf_of_content_owner: Option, + _my_subscribers: Option, + _mine: Option, + _max_results: Option, + _managed_by_me: Option, + _id: Option, + _for_username: Option, + _category_id: Option, } impl<'a, C, NC, A> MethodBuilder for ChannelListMethodBuilder<'a, C, NC, A> {} @@ -7825,7 +8033,7 @@ pub struct PlaylistItemDeleteMethodBuilder<'a, C, NC, A> A: 'a, { hub: &'a YouTube, - _id: String, + _id: String, } impl<'a, C, NC, A> MethodBuilder for PlaylistItemDeleteMethodBuilder<'a, C, NC, A> {} @@ -7893,13 +8101,13 @@ pub struct PlaylistItemListMethodBuilder<'a, C, NC, A> A: 'a, { hub: &'a YouTube, - _part: String, - _video_id: Option, - _playlist_id: Option, - _page_token: Option, - _on_behalf_of_content_owner: Option, - _max_results: Option, - _id: Option, + _part: String, + _video_id: Option, + _playlist_id: Option, + _page_token: Option, + _on_behalf_of_content_owner: Option, + _max_results: Option, + _id: Option, } impl<'a, C, NC, A> MethodBuilder for PlaylistItemListMethodBuilder<'a, C, NC, A> {} @@ -8019,9 +8227,9 @@ pub struct PlaylistItemInsertMethodBuilder<'a, C, NC, A> A: 'a, { hub: &'a YouTube, - _request: PlaylistItem, - _part: String, - _on_behalf_of_content_owner: Option, + _request: PlaylistItem, + _part: String, + _on_behalf_of_content_owner: Option, } impl<'a, C, NC, A> MethodBuilder for PlaylistItemInsertMethodBuilder<'a, C, NC, A> {} @@ -8113,8 +8321,8 @@ pub struct PlaylistItemUpdateMethodBuilder<'a, C, NC, A> A: 'a, { hub: &'a YouTube, - _request: PlaylistItem, - _part: String, + _request: PlaylistItem, + _part: String, } impl<'a, C, NC, A> MethodBuilder for PlaylistItemUpdateMethodBuilder<'a, C, NC, A> {} @@ -8198,8 +8406,9 @@ pub struct WatermarkSetMethodBuilder<'a, C, NC, A> A: 'a, { hub: &'a YouTube, - _channel_id: String, - _on_behalf_of_content_owner: Option, + _request: InvideoBranding, + _channel_id: String, + _on_behalf_of_content_owner: Option, } impl<'a, C, NC, A> MethodBuilder for WatermarkSetMethodBuilder<'a, C, NC, A> {} @@ -8213,6 +8422,15 @@ impl<'a, C, NC, A> WatermarkSetMethodBuilder<'a, C, NC, A> { } + /// Sets the *request* property to the given value. + /// + /// Even though the property as already been set when instantiating this call, + /// we provide this method for API completeness. + /// + pub fn request(&mut self, new_value: &InvideoBranding) -> &mut WatermarkSetMethodBuilder<'a, C, NC, A> { + self._request = new_value.clone(); + return self; + } /// Sets the *channel id* query property to the given value. /// /// Even though the property as already been set when instantiating this call, @@ -8275,8 +8493,8 @@ pub struct WatermarkUnsetMethodBuilder<'a, C, NC, A> A: 'a, { hub: &'a YouTube, - _channel_id: String, - _on_behalf_of_content_owner: Option, + _channel_id: String, + _on_behalf_of_content_owner: Option, } impl<'a, C, NC, A> MethodBuilder for WatermarkUnsetMethodBuilder<'a, C, NC, A> {} @@ -8352,13 +8570,13 @@ pub struct LiveBroadcastControlMethodBuilder<'a, C, NC, A> A: 'a, { hub: &'a YouTube, - _id: String, - _part: String, - _walltime: Option, - _on_behalf_of_content_owner_channel: Option, - _on_behalf_of_content_owner: Option, - _offset_time_ms: Option, - _display_slate: Option, + _id: String, + _part: String, + _walltime: Option, + _on_behalf_of_content_owner_channel: Option, + _on_behalf_of_content_owner: Option, + _offset_time_ms: Option, + _display_slate: Option, } impl<'a, C, NC, A> MethodBuilder for LiveBroadcastControlMethodBuilder<'a, C, NC, A> {} @@ -8486,10 +8704,10 @@ pub struct LiveBroadcastUpdateMethodBuilder<'a, C, NC, A> A: 'a, { hub: &'a YouTube, - _request: LiveBroadcast, - _part: String, - _on_behalf_of_content_owner_channel: Option, - _on_behalf_of_content_owner: Option, + _request: LiveBroadcast, + _part: String, + _on_behalf_of_content_owner_channel: Option, + _on_behalf_of_content_owner: Option, } impl<'a, C, NC, A> MethodBuilder for LiveBroadcastUpdateMethodBuilder<'a, C, NC, A> {} @@ -8595,10 +8813,10 @@ pub struct LiveBroadcastInsertMethodBuilder<'a, C, NC, A> A: 'a, { hub: &'a YouTube, - _request: LiveBroadcast, - _part: String, - _on_behalf_of_content_owner_channel: Option, - _on_behalf_of_content_owner: Option, + _request: LiveBroadcast, + _part: String, + _on_behalf_of_content_owner_channel: Option, + _on_behalf_of_content_owner: Option, } impl<'a, C, NC, A> MethodBuilder for LiveBroadcastInsertMethodBuilder<'a, C, NC, A> {} @@ -8702,11 +8920,11 @@ pub struct LiveBroadcastBindMethodBuilder<'a, C, NC, A> A: 'a, { hub: &'a YouTube, - _id: String, - _part: String, - _stream_id: Option, - _on_behalf_of_content_owner_channel: Option, - _on_behalf_of_content_owner: Option, + _id: String, + _part: String, + _stream_id: Option, + _on_behalf_of_content_owner_channel: Option, + _on_behalf_of_content_owner: Option, } impl<'a, C, NC, A> MethodBuilder for LiveBroadcastBindMethodBuilder<'a, C, NC, A> {} @@ -8814,14 +9032,14 @@ pub struct LiveBroadcastListMethodBuilder<'a, C, NC, A> A: 'a, { hub: &'a YouTube, - _part: String, - _page_token: Option, - _on_behalf_of_content_owner_channel: Option, - _on_behalf_of_content_owner: Option, - _mine: Option, - _max_results: Option, - _id: Option, - _broadcast_status: Option, + _part: String, + _page_token: Option, + _on_behalf_of_content_owner_channel: Option, + _on_behalf_of_content_owner: Option, + _mine: Option, + _max_results: Option, + _id: Option, + _broadcast_status: Option, } impl<'a, C, NC, A> MethodBuilder for LiveBroadcastListMethodBuilder<'a, C, NC, A> {} @@ -8951,9 +9169,9 @@ pub struct LiveBroadcastDeleteMethodBuilder<'a, C, NC, A> A: 'a, { hub: &'a YouTube, - _id: String, - _on_behalf_of_content_owner_channel: Option, - _on_behalf_of_content_owner: Option, + _id: String, + _on_behalf_of_content_owner_channel: Option, + _on_behalf_of_content_owner: Option, } impl<'a, C, NC, A> MethodBuilder for LiveBroadcastDeleteMethodBuilder<'a, C, NC, A> {} @@ -9043,11 +9261,11 @@ pub struct LiveBroadcastTransitionMethodBuilder<'a, C, NC, A> A: 'a, { hub: &'a YouTube, - _broadcast_status: String, - _id: String, - _part: String, - _on_behalf_of_content_owner_channel: Option, - _on_behalf_of_content_owner: Option, + _broadcast_status: String, + _id: String, + _part: String, + _on_behalf_of_content_owner_channel: Option, + _on_behalf_of_content_owner: Option, } impl<'a, C, NC, A> MethodBuilder for LiveBroadcastTransitionMethodBuilder<'a, C, NC, A> {} @@ -9157,10 +9375,10 @@ pub struct VideoCategoryListMethodBuilder<'a, C, NC, A> A: 'a, { hub: &'a YouTube, - _part: String, - _region_code: Option, - _id: Option, - _hl: Option, + _part: String, + _region_code: Option, + _id: Option, + _hl: Option, } impl<'a, C, NC, A> MethodBuilder for VideoCategoryListMethodBuilder<'a, C, NC, A> {} @@ -9252,15 +9470,15 @@ pub struct ActivityListMethodBuilder<'a, C, NC, A> A: 'a, { hub: &'a YouTube, - _part: String, - _region_code: Option, - _published_before: Option, - _published_after: Option, - _page_token: Option, - _mine: Option, - _max_results: Option, - _home: Option, - _channel_id: Option, + _part: String, + _region_code: Option, + _published_before: Option, + _published_after: Option, + _page_token: Option, + _mine: Option, + _max_results: Option, + _home: Option, + _channel_id: Option, } impl<'a, C, NC, A> MethodBuilder for ActivityListMethodBuilder<'a, C, NC, A> {} @@ -9396,7 +9614,8 @@ pub struct ActivityInsertMethodBuilder<'a, C, NC, A> A: 'a, { hub: &'a YouTube, - _part: String, + _request: Activity, + _part: String, } impl<'a, C, NC, A> MethodBuilder for ActivityInsertMethodBuilder<'a, C, NC, A> {} @@ -9410,6 +9629,15 @@ impl<'a, C, NC, A> ActivityInsertMethodBuilder<'a, C, NC, A> { } + /// Sets the *request* property to the given value. + /// + /// Even though the property as already been set when instantiating this call, + /// we provide this method for API completeness. + /// + pub fn request(&mut self, new_value: &Activity) -> &mut ActivityInsertMethodBuilder<'a, C, NC, A> { + self._request = new_value.clone(); + return self; + } /// Sets the *part* query property to the given value. /// /// Even though the *parts* list is automatically derived from *Resource* passed in diff --git a/src/mako/lib.rs.mako b/src/mako/lib.rs.mako index e10c1acc7fd..639ce71af3c 100644 --- a/src/mako/lib.rs.mako +++ b/src/mako/lib.rs.mako @@ -34,7 +34,7 @@ use std::borrow::BorrowMut; use std::cell::RefCell; use std::default::Default; -pub use cmn::{Hub, ResourceMethodsBuilder, MethodBuilder, Resource, Part, ResponseResult, RequestResult, NestedType}; +pub use cmn::{Hub, ResourceMethodsBuilder, MethodBuilder, Resource, Part, ResponseResult, RequestValue, NestedType}; // ######## // HUB ### diff --git a/src/mako/lib/mbuild.mako b/src/mako/lib/mbuild.mako index cc26b052489..370ff3ca3e6 100644 --- a/src/mako/lib/mbuild.mako +++ b/src/mako/lib/mbuild.mako @@ -3,7 +3,7 @@ rb_type, mb_type, singular, hub_type, to_fqan, indent_all_but_first_by, method_params, activity_rust_type, mangle_ident, activity_input_type, get_word, split_camelcase_s, property, is_pod_property, TREF, method_io, IO_REQUEST, - RESOURCE_MARKER, schema_to_required_property, rust_copy_value_s, is_required_property) + schema_to_required_property, rust_copy_value_s, is_required_property) %>\ <%namespace name="util" file="util.mako"/>\ <%namespace name="lib" file="lib.mako"/>\ @@ -18,7 +18,7 @@ # an identifier for a property. We prefix them to prevent clashes with the setters ThisType = mb_type(resource, method) + "<'a, C, NC, A>" - request_resource = method_io(schemas, c, m, IO_REQUEST, RESOURCE_MARKER) + request_resource = method_io(schemas, c, m, IO_REQUEST) params = method_params(m) if request_resource: params.insert(0, schema_to_required_property(request_resource, 'request')) @@ -60,9 +60,9 @@ pub struct ${ThisType} % for p in params: ${property(p.name)}:\ % if is_required_property(p): - ${activity_rust_type(p, allow_optionals=False)}, + ${activity_rust_type(p, allow_optionals=False)}, % else: - ${activity_rust_type(p)}, + ${activity_rust_type(p)}, % endif % endfor } diff --git a/src/mako/lib/rbuild.mako b/src/mako/lib/rbuild.mako index 0a5cfab66d2..ff538fff5f8 100644 --- a/src/mako/lib/rbuild.mako +++ b/src/mako/lib/rbuild.mako @@ -1,7 +1,7 @@ <%! from util import (put_and, rust_test_fn_invisible, rust_doc_test_norun, rust_doc_comment, rb_type, singular, hub_type, mangle_ident, mb_type, method_params, property, - to_fqan, indent_all_but_first_by, RESOURCE_MARKER, schema_markers, + to_fqan, indent_all_but_first_by, schema_markers, activity_input_type, TREF, method_io, IO_REQUEST, schema_to_required_property, rust_copy_value_s, is_required_property) %>\ @@ -54,7 +54,7 @@ impl<'a, C, NC, A> ${ThisType} { # skip part if we have a request resource. Only resources can have parts # that we can easily deduce - request_resource = method_io(schemas, c, m, IO_REQUEST, RESOURCE_MARKER) + request_resource = method_io(schemas, c, m, IO_REQUEST) params = method_params(m) REQUEST_RESOURCE_PROPERTY_NAME = 'request' if request_resource: diff --git a/src/mako/lib/schema.mako b/src/mako/lib/schema.mako index c7003bfbbd8..80398d09190 100644 --- a/src/mako/lib/schema.mako +++ b/src/mako/lib/schema.mako @@ -1,5 +1,5 @@ <%! from util import (schema_markers, rust_doc_comment, mangle_ident, to_rust_type, put_and, - IO_TYPES, activity_split, enclose_in) + IO_TYPES, activity_split, enclose_in, REQUEST_MARKER) %>\ ## Create new schema with everything. ## 's' contains the schema structure from json to build @@ -28,8 +28,28 @@ pub struct ${s.id}\ impl ${marker_trait} for ${s.id} {} % endfor -% if RESOURCE_MARKER in markers: - +% if REQUEST_MARKER in markers: +impl ${s.id} { + /// 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(); + % for pn, p in s.properties.iteritems(): +<% + mn = 'self.' + mangle_ident(pn) + rt = to_rust_type(s.id, pn, p) + check = 'is_some()' + if rt.startswith('Vec') or rt.startswith('HashMap'): + check = 'len() > 0' +%>\ + if ${mn}.${check} { r = r + "${pn},"; } + % endfor + ## remove (possibly non-existing) trailing comma + r.pop(); + r + } +} % endif diff --git a/src/mako/lib/util.py b/src/mako/lib/util.py index 9d310c21374..8f123ed5ecc 100644 --- a/src/mako/lib/util.py +++ b/src/mako/lib/util.py @@ -26,7 +26,6 @@ REQUEST_PRIORITY = 100 REQUEST_MARKER = 'RequestValue' -RESOURCE_MARKER = 'Resource' # ============================================================================== ## @name Filters @@ -256,7 +255,7 @@ def schema_markers(s, c): # it should have at least one activity that matches it's type to qualify for the Resource trait for fqan, iot in activities.iteritems(): if activity_name_to_type_name(activity_split(fqan)[0]).lower() == s.id.lower(): - res.add(RESOURCE_MARKER) + res.add('Resource') if IO_RESPONSE in iot: res.add('ResponseResult') if IO_REQUEST in iot: