diff --git a/gen/youtube3/README.md b/gen/youtube3/README.md index b501f65f86f..8cbdbcab0df 100644 --- a/gen/youtube3/README.md +++ b/gen/youtube3/README.md @@ -51,12 +51,13 @@ let r = hub.resource().activity(...).doit() Or specifically ... ```ignore -let r = hub.videos().rate(...).doit() -let r = hub.videos().getRating(...).doit() -let r = hub.videos().list(...).doit() -let r = hub.videos().insert(...).doit() -let r = hub.videos().update(...).doit() -let r = hub.videos().delete(...).doit() +let r = hub.live_broadcasts().control(...).doit() +let r = hub.live_broadcasts().insert(...).doit() +let r = hub.live_broadcasts().list(...).doit() +let r = hub.live_broadcasts().transition(...).doit() +let r = hub.live_broadcasts().update(...).doit() +let r = hub.live_broadcasts().delete(...).doit() +let r = hub.live_broadcasts().bind(...).doit() ``` The `resource()` and `activity(...)` calls create [builders][builder-pattern]. The second one dealing with `Activities` diff --git a/gen/youtube3/src/lib.rs b/gen/youtube3/src/lib.rs index c02f069b45a..27f5da85e32 100644 --- a/gen/youtube3/src/lib.rs +++ b/gen/youtube3/src/lib.rs @@ -48,12 +48,13 @@ //! Or specifically ... //! //! ```ignore -//! let r = hub.videos().rate(...).doit() -//! let r = hub.videos().getRating(...).doit() -//! let r = hub.videos().list(...).doit() -//! let r = hub.videos().insert(...).doit() -//! let r = hub.videos().update(...).doit() -//! let r = hub.videos().delete(...).doit() +//! let r = hub.live_broadcasts().control(...).doit() +//! let r = hub.live_broadcasts().insert(...).doit() +//! let r = hub.live_broadcasts().list(...).doit() +//! let r = hub.live_broadcasts().transition(...).doit() +//! let r = hub.live_broadcasts().update(...).doit() +//! let r = hub.live_broadcasts().delete(...).doit() +//! let r = hub.live_broadcasts().bind(...).doit() //! ``` //! //! The `resource()` and `activity(...)` calls create [builders][builder-pattern]. The second one dealing with `Activities` @@ -126,7 +127,7 @@ use std::marker::PhantomData; use std::borrow::BorrowMut; use std::cell::RefCell; use std::default::Default; -use std::io::{Read, Seek} +use std::io::{Read, Seek}; pub use cmn::{Hub, ResourceMethodsBuilder, MethodBuilder, Resource, Part, ResponseResult, RequestValue, NestedType}; @@ -589,7 +590,9 @@ impl Part for ChannelAuditDetails {} /// This type is used in activities, which are methods you may call on this type or where 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 (none) /// * update (request|response) +/// * list (none) /// * insert (request|response) /// /// @@ -1102,6 +1105,8 @@ impl Part for InvideoPromotion {} /// /// * insert (request|response) /// * update (request|response) +/// * list (none) +/// * delete (none) /// /// #[derive(RustcEncodable, RustcDecodable, Default, Clone)] @@ -1223,7 +1228,7 @@ impl Part for ChannelSectionSnippet {} #[derive(RustcEncodable, RustcDecodable, Default, Clone)] pub struct ChannelContentDetails { /// no description provided - pub related_playlists: HashMap, + pub related_playlists: HashMap, /// The googlePlusUserId object identifies the Google+ profile ID associated with this channel. pub google_plus_user_id: Option, } @@ -1389,7 +1394,13 @@ impl Part for ActivityContentDetails {} /// A i18nRegion resource identifies a region where YouTube is available. /// -/// This type is not used in any activity, and only used as *part* of another schema. +/// # Activities +/// +/// This type is used in activities, which are methods you may call on this type or where this type is involved in. +/// The list links the activity name, along with information about where it is used (one of *request* and *response*). +/// +/// * list (none) +/// /// #[derive(RustcEncodable, RustcDecodable, Default, Clone)] pub struct I18nRegion { @@ -1403,7 +1414,7 @@ pub struct I18nRegion { pub id: Option, } -impl Part for I18nRegion {} +impl Resource for I18nRegion {} /// The contentOwnerDetails object encapsulates channel data that is relevant for YouTube Partners linked with the channel. @@ -2098,8 +2109,10 @@ impl Part for LocalizedProperty {} /// /// * control (response) /// * insert (request|response) -/// * update (request|response) +/// * list (none) /// * transition (response) +/// * update (request|response) +/// * delete (none) /// * bind (response) /// /// @@ -2653,7 +2666,9 @@ impl ResponseResult for ChannelListResponse {} /// This type is used in activities, which are methods you may call on this type or where 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 (none) /// * update (request|response) +/// * list (none) /// * insert (request|response) /// /// @@ -3115,7 +3130,13 @@ impl Part for ActivityContentDetailsBulletin {} /// An i18nLanguage resource identifies a UI language currently supported by YouTube. /// -/// This type is not used in any activity, and only used as *part* of another schema. +/// # Activities +/// +/// This type is used in activities, which are methods you may call on this type or where this type is involved in. +/// The list links the activity name, along with information about where it is used (one of *request* and *response*). +/// +/// * list (none) +/// /// #[derive(RustcEncodable, RustcDecodable, Default, Clone)] pub struct I18nLanguage { @@ -3129,7 +3150,7 @@ pub struct I18nLanguage { pub id: Option, } -impl Part for I18nLanguage {} +impl Resource for I18nLanguage {} /// There is no detailed description. @@ -3426,7 +3447,7 @@ impl Part for PageInfo {} /// This type is not used in any activity, and only used as *part* of another schema. /// #[derive(RustcEncodable, RustcDecodable, Default, Clone)] -pub struct ChannelContentDetailsRelatedplaylists { +pub struct ChannelContentDetailsRelatedPlaylists { /// 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, /// 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. @@ -3439,8 +3460,8 @@ pub struct ChannelContentDetailsRelatedplaylists { pub watch_later: Option, } -impl NestedType for ChannelContentDetailsRelatedplaylists {} -impl Part for ChannelContentDetailsRelatedplaylists {} +impl NestedType for ChannelContentDetailsRelatedPlaylists {} +impl Part for ChannelContentDetailsRelatedPlaylists {} @@ -3941,8 +3962,8 @@ impl<'a, C, NC, A> VideoMethodsBuilder<'a, C, NC, A> { /// Create a builder to help you perform the following task: /// /// Retrieves the ratings that the authorized user gave to a list of specified videos. - pub fn get_rating(&self, id: &str) -> VideoGetratingMethodBuilder<'a, C, NC, A> { - VideoGetratingMethodBuilder { + pub fn get_rating(&self, id: &str) -> VideoGetRatingMethodBuilder<'a, C, NC, A> { + VideoGetRatingMethodBuilder { hub: self.hub, _id: id.to_string(), _on_behalf_of_content_owner: Default::default(), @@ -6511,7 +6532,7 @@ impl<'a, C, NC, A> VideoRateMethodBuilder<'a, C, NC, A> { /// // TODO: show how to handle the result ! /// # } /// ``` -pub struct VideoGetratingMethodBuilder<'a, C, NC, A> +pub struct VideoGetRatingMethodBuilder<'a, C, NC, A> where NC: 'a, C: 'a, A: 'a, { @@ -6521,9 +6542,9 @@ pub struct VideoGetratingMethodBuilder<'a, C, NC, A> _on_behalf_of_content_owner: Option, } -impl<'a, C, NC, A> MethodBuilder for VideoGetratingMethodBuilder<'a, C, NC, A> {} +impl<'a, C, NC, A> MethodBuilder for VideoGetRatingMethodBuilder<'a, C, NC, A> {} -impl<'a, C, NC, A> VideoGetratingMethodBuilder<'a, C, NC, A> { +impl<'a, C, NC, A> VideoGetRatingMethodBuilder<'a, C, NC, A> { /// Perform the operation you have build so far. @@ -6539,7 +6560,7 @@ impl<'a, C, NC, A> VideoGetratingMethodBuilder<'a, C, NC, A> { /// we provide this method for API completeness. /// /// The id parameter specifies a comma-separated list of the YouTube video ID(s) for the resource(s) for which you are retrieving rating data. In a video resource, the id property specifies the video's ID. - pub fn id(mut self, new_value: &str) -> VideoGetratingMethodBuilder<'a, C, NC, A> { + pub fn id(mut self, new_value: &str) -> VideoGetRatingMethodBuilder<'a, C, NC, A> { self._id = new_value.to_string(); return self; } @@ -6549,7 +6570,7 @@ impl<'a, C, NC, A> VideoGetratingMethodBuilder<'a, C, NC, A> { /// 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. - pub fn on_behalf_of_content_owner(mut self, new_value: &str) -> VideoGetratingMethodBuilder<'a, C, NC, A> { + pub fn on_behalf_of_content_owner(mut self, new_value: &str) -> VideoGetRatingMethodBuilder<'a, C, NC, A> { self._on_behalf_of_content_owner = Some(new_value.to_string()); return self; } diff --git a/src/mako/lib.rs.mako b/src/mako/lib.rs.mako index 36e6bdd2f26..2ece8110965 100644 --- a/src/mako/lib.rs.mako +++ b/src/mako/lib.rs.mako @@ -32,7 +32,7 @@ use std::marker::PhantomData; use std::borrow::BorrowMut; use std::cell::RefCell; use std::default::Default; -use std::io::{Read, Seek} +use std::io::{Read, Seek}; pub use cmn::{Hub, ResourceMethodsBuilder, MethodBuilder, Resource, Part, ResponseResult, RequestValue, NestedType}; diff --git a/src/mako/lib/lib.mako b/src/mako/lib/lib.mako index b6359dbdf00..a9144ce6c9b 100644 --- a/src/mako/lib/lib.mako +++ b/src/mako/lib/lib.mako @@ -1,6 +1,6 @@ <%! from util import (activity_split, put_and, md_italic, split_camelcase_s, canonical_type_name, rust_test_fn_invisible, rust_doc_test_norun, rust_doc_comment, markdown_rust_block, - unindent_first_by) %>\ + unindent_first_by, mangle_ident) %>\ <%namespace name="util" file="util.mako"/>\ ## If rust-doc is True, examples will be made to work for rust doc tests. Otherwise they are set @@ -47,7 +47,7 @@ Or specifically ... ```ignore % for an, a in c.sta_map[fr.id].iteritems(): <% resource, activity = activity_split(an) %>\ -let r = hub.${resource}().${activity}(...).${api.terms.action}() +let r = hub.${mangle_ident(resource)}().${activity}(...).${api.terms.action}() % endfor ``` diff --git a/src/mako/lib/schema.mako b/src/mako/lib/schema.mako index 80398d09190..21b8dd6d6fd 100644 --- a/src/mako/lib/schema.mako +++ b/src/mako/lib/schema.mako @@ -5,7 +5,7 @@ ## 's' contains the schema structure from json to build <%def name="new(s, c)">\ <% - assert s.type == "object" + ## assert s.type == "object" markers = schema_markers(s, c) %>\ <%block filter="rust_doc_comment">\ diff --git a/src/mako/lib/util.py b/src/mako/lib/util.py index c59e6eee64b..2e6b9f4cfe5 100644 --- a/src/mako/lib/util.py +++ b/src/mako/lib/util.py @@ -16,6 +16,8 @@ 'double' : 'f64', 'float' : 'f32', 'int32' : 'i32', + 'int64' : 'i64', + 'uint64' : 'u64', 'array' : 'Vec', 'string' : 'String', 'object' : 'HashMap'} @@ -23,8 +25,11 @@ _words = [w.strip(',') for w in "Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.".split(' ')] RUST_TYPE_RND_MAP = {'bool': lambda: str(bool(randint(0, 1))).lower(), 'u32' : lambda: randint(0, 100), + 'u64' : lambda: randint(0, 100), 'f64' : lambda: random(), + 'f32' : lambda: random(), 'i32' : lambda: randint(-101, -1), + 'i64' : lambda: randint(-101, -1), 'String': lambda: '"%s"' % choice(_words), } TREF = '$ref' @@ -218,7 +223,7 @@ def canonical_type_name(s): return s[:1].upper() + s[1:] def nested_type_name(sn, pn): - return sn + pn.capitalize() + return sn + canonical_type_name(pn) # Make properties which are reserved keywords usable def mangle_ident(n): @@ -273,7 +278,7 @@ def nested_type(nt): # return True if this property is actually a nested type def is_nested_type_property(t): - return 'type' in t and t.type == 'object' and 'properties' in t + return 'type' in t and t.type == 'object' and 'properties' in t or ('items' in t and 'properties' in t.items) # Return True if the schema is nested def is_nested_type(s): @@ -295,16 +300,24 @@ def is_pod_property(p): # return an iterator yielding fake-schemas that identify a nested type def iter_nested_types(schemas): - for s in schemas.values(): - if 'properties' not in s: - continue - for pn, p in s.properties.iteritems(): + def iter_nested_properties(prefix, properties): + for pn, p in properties.iteritems(): if is_nested_type_property(p): ns = p.copy() - ns.id = nested_type_name(s.id, pn) + ns.id = nested_type_name(prefix, pn) ns[NESTED_TYPE_MARKER] = True + if 'items' in p: + ns.update(p.items.iteritems()) yield ns + for np in iter_nested_properties(prefix + canonical_type_name(pn), ns.properties): + yield np + # can be recursive ... # end for ach property + for s in schemas.values(): + if 'properties' not in s: + continue + for np in iter_nested_properties(s.id, s.properties): + yield np # end for aech schma # Return sorted type names of all markers applicable to the given schema @@ -353,7 +366,7 @@ def to_fqan(name, resource, method): # videos -> Video def activity_name_to_type_name(an): - return an.capitalize()[:-1] + return canonical_type_name(an)[:-1] # yields (resource, activity, activity_data) def iter_acitivities(c): @@ -552,7 +565,7 @@ def mb_type_params_s(m): # return type name for a method on the given resource def mb_type(r, m): - return "%s%sMethodBuilder" % (singular(canonical_type_name(r)), m.capitalize()) + return "%s%sMethodBuilder" % (singular(canonical_type_name(r)), canonical_type_name(m)) def hub_type(canonicalName): return canonical_type_name(canonicalName)