Skip to content

Commit f4030f0

Browse files
committed
fix(activities): now the map is complete
It's quite nice - next up is marker traits !
1 parent ba98bee commit f4030f0

2 files changed

Lines changed: 37 additions & 5 deletions

File tree

gen/youtube3/src/lib.rs

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,8 @@ pub struct PlaylistLocalization {
147147
/// # Activities
148148
///
149149
/// * youtube.playlists.insert
150+
/// * youtube.playlists.delete
151+
/// * youtube.playlists.list
150152
/// * youtube.playlists.update
151153
///
152154
///
@@ -754,7 +756,7 @@ pub struct ChannelSectionSnippet {
754756
#[derive(RustcEncodable, RustcDecodable, Default, Clone)]
755757
pub struct ChannelContentDetails {
756758
/// no description provided
757-
pub relatedPlaylists: HashMap<String, ChannelContentDetailsRelatedPlaylists>,
759+
pub relatedPlaylists: HashMap<String, ChannelContentDetailsRelatedplaylists>,
758760
/// The googlePlusUserId object identifies the Google+ profile ID associated with this channel.
759761
pub googlePlusUserId: Option<String>,
760762
}
@@ -974,8 +976,12 @@ pub struct SubscriptionContentDetails {
974976
///
975977
/// # Activities
976978
///
979+
/// * youtube.videos.rate
980+
/// * youtube.videos.getRating
981+
/// * youtube.videos.list
977982
/// * youtube.videos.insert
978983
/// * youtube.videos.update
984+
/// * youtube.videos.delete
979985
///
980986
///
981987
#[derive(RustcEncodable, RustcDecodable, Default, Clone)]
@@ -1149,6 +1155,8 @@ pub struct PromotedItemId {
11491155
/// # Activities
11501156
///
11511157
/// * youtube.subscriptions.insert
1158+
/// * youtube.subscriptions.list
1159+
/// * youtube.subscriptions.delete
11521160
///
11531161
///
11541162
#[derive(RustcEncodable, RustcDecodable, Default, Clone)]
@@ -1483,7 +1491,10 @@ pub struct VideoFileDetailsVideoStream {
14831491

14841492
/// A thumbnail is an image representing a YouTube resource.
14851493
///
1486-
/// This schema type is not used in any activity, and only used as *part* of another schema.
1494+
/// # Activities
1495+
///
1496+
/// * youtube.thumbnails.set
1497+
///
14871498
///
14881499
#[derive(RustcEncodable, RustcDecodable, Default, Clone)]
14891500
pub struct Thumbnail {
@@ -1499,6 +1510,7 @@ pub struct Thumbnail {
14991510
///
15001511
/// # Activities
15011512
///
1513+
/// * youtube.channels.list
15021514
/// * youtube.channels.update
15031515
///
15041516
///
@@ -2488,7 +2500,7 @@ pub struct PageInfo {
24882500
/// This schema type is not used in any activity, and only used as *part* of another schema.
24892501
///
24902502
#[derive(RustcEncodable, RustcDecodable, Default, Clone)]
2491-
pub struct ChannelContentDetailsRelatedPlaylists {
2503+
pub struct ChannelContentDetailsRelatedplaylists {
24922504
/// 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.
24932505
pub uploads: Option<String>,
24942506
/// 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.

src/mako/lib/util.py

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
'string' : 'String',
1515
'object' : 'HashMap'}
1616
TREF = '$ref'
17+
INS_METHOD = 'insert'
18+
DEL_METHOD = 'delete'
1719

1820
# ==============================================================================
1921
## @name Filters
@@ -58,7 +60,7 @@ def put_and(l):
5860

5961

6062
def nested_type_name(sn, pn):
61-
return sn + pn[:1].upper() + pn[1:]
63+
return sn + pn.capitalize()
6264

6365
# Make properties which are reserved keywords usable
6466
def mangle_ident(n):
@@ -150,16 +152,34 @@ def build_activity_mappings(activities):
150152
t = m.get(in_out_type_name, None)
151153
if t is None:
152154
continue
153-
154155
tn = to_rust_type(None, None, t, allow_optionals=False)
155156
info = res.setdefault(tn, dict())
156157
io_info = info.setdefault(m.id, [])
157158
io_info.append(in_out_type_name)
158159
# end for each io type
160+
161+
# handle delete/getrating/(possibly others)
162+
# delete: has no response or request
163+
# getrating: response is a 'SomethingResult', which is still related to activities name
164+
# the latter is used to deduce the resource name
165+
an, _ = activity_split(m.id)
166+
# videos -> Video
167+
an = an.capitalize()[:-1]
168+
info = res.setdefault(an, dict())
169+
if m.id not in info:
170+
io_info = info.setdefault(m.id, [])
171+
io_info.append([])
172+
# end handle other cases
159173
# end for each method
160174
# end for each activity
161175
return res, fqan
162176

177+
# return (name, method)
178+
def activity_split(fqan):
179+
t = fqan.split('.')
180+
assert len(t) == 3
181+
return t[1:]
182+
163183
## -- End Activity Utilities -- @}
164184

165185

0 commit comments

Comments
 (0)