Skip to content

Commit

Permalink
fix(activities): now the map is complete
Browse files Browse the repository at this point in the history
It's quite nice - next up is marker traits !
  • Loading branch information
Byron committed Mar 3, 2015
1 parent ba98bee commit f4030f0
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 5 deletions.
18 changes: 15 additions & 3 deletions gen/youtube3/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,8 @@ pub struct PlaylistLocalization {
/// # Activities
///
/// * youtube.playlists.insert
/// * youtube.playlists.delete
/// * youtube.playlists.list
/// * youtube.playlists.update
///
///
Expand Down Expand Up @@ -754,7 +756,7 @@ pub struct ChannelSectionSnippet {
#[derive(RustcEncodable, RustcDecodable, Default, Clone)]
pub struct ChannelContentDetails {
/// no description provided
pub relatedPlaylists: HashMap<String, ChannelContentDetailsRelatedPlaylists>,
pub relatedPlaylists: HashMap<String, ChannelContentDetailsRelatedplaylists>,
/// The googlePlusUserId object identifies the Google+ profile ID associated with this channel.
pub googlePlusUserId: Option<String>,
}
Expand Down Expand Up @@ -974,8 +976,12 @@ pub struct SubscriptionContentDetails {
///
/// # Activities
///
/// * youtube.videos.rate
/// * youtube.videos.getRating
/// * youtube.videos.list
/// * youtube.videos.insert
/// * youtube.videos.update
/// * youtube.videos.delete
///
///
#[derive(RustcEncodable, RustcDecodable, Default, Clone)]
Expand Down Expand Up @@ -1149,6 +1155,8 @@ pub struct PromotedItemId {
/// # Activities
///
/// * youtube.subscriptions.insert
/// * youtube.subscriptions.list
/// * youtube.subscriptions.delete
///
///
#[derive(RustcEncodable, RustcDecodable, Default, Clone)]
Expand Down Expand Up @@ -1483,7 +1491,10 @@ pub struct VideoFileDetailsVideoStream {

/// A thumbnail is an image representing a YouTube resource.
///
/// This schema type is not used in any activity, and only used as *part* of another schema.
/// # Activities
///
/// * youtube.thumbnails.set
///
///
#[derive(RustcEncodable, RustcDecodable, Default, Clone)]
pub struct Thumbnail {
Expand All @@ -1499,6 +1510,7 @@ pub struct Thumbnail {
///
/// # Activities
///
/// * youtube.channels.list
/// * youtube.channels.update
///
///
Expand Down Expand Up @@ -2488,7 +2500,7 @@ pub struct PageInfo {
/// This schema 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<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.
Expand Down
24 changes: 22 additions & 2 deletions src/mako/lib/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
'string' : 'String',
'object' : 'HashMap'}
TREF = '$ref'
INS_METHOD = 'insert'
DEL_METHOD = 'delete'

# ==============================================================================
## @name Filters
Expand Down Expand Up @@ -58,7 +60,7 @@ def put_and(l):


def nested_type_name(sn, pn):
return sn + pn[:1].upper() + pn[1:]
return sn + pn.capitalize()

# Make properties which are reserved keywords usable
def mangle_ident(n):
Expand Down Expand Up @@ -150,16 +152,34 @@ def build_activity_mappings(activities):
t = m.get(in_out_type_name, None)
if t is None:
continue

tn = to_rust_type(None, None, t, allow_optionals=False)
info = res.setdefault(tn, dict())
io_info = info.setdefault(m.id, [])
io_info.append(in_out_type_name)
# end for each io type

# handle delete/getrating/(possibly others)
# delete: has no response or request
# getrating: response is a 'SomethingResult', which is still related to activities name
# the latter is used to deduce the resource name
an, _ = activity_split(m.id)
# videos -> Video
an = an.capitalize()[:-1]
info = res.setdefault(an, dict())
if m.id not in info:
io_info = info.setdefault(m.id, [])
io_info.append([])
# end handle other cases
# end for each method
# end for each activity
return res, fqan

# return (name, method)
def activity_split(fqan):
t = fqan.split('.')
assert len(t) == 3
return t[1:]

## -- End Activity Utilities -- @}


Expand Down

0 comments on commit f4030f0

Please sign in to comment.