mirror of
https://github.com/OMGeeky/google-apis-rs.git
synced 2026-01-06 19:45:20 +01:00
refactor(lib): move resource builder into own lib
As the code is likely to grow far more complex, it's required to move it as long as it is easy to do so.
This commit is contained in:
@@ -3093,6 +3093,7 @@ impl Part for ChannelContentDetailsRelatedplaylists {}
|
||||
// MethodBuilders ###
|
||||
// #################
|
||||
|
||||
|
||||
/// A builder providing access to all methods supported on *i18nLanguage* resources.
|
||||
/// It is usually not used directly, but through the `YouTube` hub.
|
||||
///
|
||||
@@ -3137,6 +3138,10 @@ pub struct I18nLanguagesMethodBuilder<'a, C, NC, A>
|
||||
}
|
||||
|
||||
impl<'a, C, NC, A> MethodBuilder for I18nLanguagesMethodBuilder<'a, C, NC, A> {}
|
||||
|
||||
|
||||
|
||||
|
||||
/// A builder providing access to all methods supported on *channelBanner* resources.
|
||||
/// It is usually not used directly, but through the `YouTube` hub.
|
||||
///
|
||||
@@ -3181,6 +3186,10 @@ pub struct ChannelBannersMethodBuilder<'a, C, NC, A>
|
||||
}
|
||||
|
||||
impl<'a, C, NC, A> MethodBuilder for ChannelBannersMethodBuilder<'a, C, NC, A> {}
|
||||
|
||||
|
||||
|
||||
|
||||
/// A builder providing access to all methods supported on *channelSection* resources.
|
||||
/// It is usually not used directly, but through the `YouTube` hub.
|
||||
///
|
||||
@@ -3225,6 +3234,10 @@ pub struct ChannelSectionsMethodBuilder<'a, C, NC, A>
|
||||
}
|
||||
|
||||
impl<'a, C, NC, A> MethodBuilder for ChannelSectionsMethodBuilder<'a, C, NC, A> {}
|
||||
|
||||
|
||||
|
||||
|
||||
/// A builder providing access to all methods supported on *guideCategorie* resources.
|
||||
/// It is usually not used directly, but through the `YouTube` hub.
|
||||
///
|
||||
@@ -3269,6 +3282,10 @@ pub struct GuideCategoriesMethodBuilder<'a, C, NC, A>
|
||||
}
|
||||
|
||||
impl<'a, C, NC, A> MethodBuilder for GuideCategoriesMethodBuilder<'a, C, NC, A> {}
|
||||
|
||||
|
||||
|
||||
|
||||
/// A builder providing access to all methods supported on *playlist* resources.
|
||||
/// It is usually not used directly, but through the `YouTube` hub.
|
||||
///
|
||||
@@ -3313,6 +3330,10 @@ pub struct PlaylistsMethodBuilder<'a, C, NC, A>
|
||||
}
|
||||
|
||||
impl<'a, C, NC, A> MethodBuilder for PlaylistsMethodBuilder<'a, C, NC, A> {}
|
||||
|
||||
|
||||
|
||||
|
||||
/// A builder providing access to all methods supported on *thumbnail* resources.
|
||||
/// It is usually not used directly, but through the `YouTube` hub.
|
||||
///
|
||||
@@ -3357,6 +3378,10 @@ pub struct ThumbnailsMethodBuilder<'a, C, NC, A>
|
||||
}
|
||||
|
||||
impl<'a, C, NC, A> MethodBuilder for ThumbnailsMethodBuilder<'a, C, NC, A> {}
|
||||
|
||||
|
||||
|
||||
|
||||
/// A builder providing access to all methods supported on *video* resources.
|
||||
/// It is usually not used directly, but through the `YouTube` hub.
|
||||
///
|
||||
@@ -3401,6 +3426,10 @@ pub struct VideosMethodBuilder<'a, C, NC, A>
|
||||
}
|
||||
|
||||
impl<'a, C, NC, A> MethodBuilder for VideosMethodBuilder<'a, C, NC, A> {}
|
||||
|
||||
|
||||
|
||||
|
||||
/// A builder providing access to all methods supported on *subscription* resources.
|
||||
/// It is usually not used directly, but through the `YouTube` hub.
|
||||
///
|
||||
@@ -3445,6 +3474,10 @@ pub struct SubscriptionsMethodBuilder<'a, C, NC, A>
|
||||
}
|
||||
|
||||
impl<'a, C, NC, A> MethodBuilder for SubscriptionsMethodBuilder<'a, C, NC, A> {}
|
||||
|
||||
|
||||
|
||||
|
||||
/// A builder providing access to all methods supported on *search* resources.
|
||||
/// It is usually not used directly, but through the `YouTube` hub.
|
||||
///
|
||||
@@ -3489,6 +3522,10 @@ pub struct SearchMethodBuilder<'a, C, NC, A>
|
||||
}
|
||||
|
||||
impl<'a, C, NC, A> MethodBuilder for SearchMethodBuilder<'a, C, NC, A> {}
|
||||
|
||||
|
||||
|
||||
|
||||
/// A builder providing access to all methods supported on *i18nRegion* resources.
|
||||
/// It is usually not used directly, but through the `YouTube` hub.
|
||||
///
|
||||
@@ -3533,6 +3570,10 @@ pub struct I18nRegionsMethodBuilder<'a, C, NC, A>
|
||||
}
|
||||
|
||||
impl<'a, C, NC, A> MethodBuilder for I18nRegionsMethodBuilder<'a, C, NC, A> {}
|
||||
|
||||
|
||||
|
||||
|
||||
/// A builder providing access to all methods supported on *liveStream* resources.
|
||||
/// It is usually not used directly, but through the `YouTube` hub.
|
||||
///
|
||||
@@ -3577,6 +3618,10 @@ pub struct LiveStreamsMethodBuilder<'a, C, NC, A>
|
||||
}
|
||||
|
||||
impl<'a, C, NC, A> MethodBuilder for LiveStreamsMethodBuilder<'a, C, NC, A> {}
|
||||
|
||||
|
||||
|
||||
|
||||
/// A builder providing access to all methods supported on *channel* resources.
|
||||
/// It is usually not used directly, but through the `YouTube` hub.
|
||||
///
|
||||
@@ -3621,6 +3666,10 @@ pub struct ChannelsMethodBuilder<'a, C, NC, A>
|
||||
}
|
||||
|
||||
impl<'a, C, NC, A> MethodBuilder for ChannelsMethodBuilder<'a, C, NC, A> {}
|
||||
|
||||
|
||||
|
||||
|
||||
/// A builder providing access to all methods supported on *playlistItem* resources.
|
||||
/// It is usually not used directly, but through the `YouTube` hub.
|
||||
///
|
||||
@@ -3665,6 +3714,10 @@ pub struct PlaylistItemsMethodBuilder<'a, C, NC, A>
|
||||
}
|
||||
|
||||
impl<'a, C, NC, A> MethodBuilder for PlaylistItemsMethodBuilder<'a, C, NC, A> {}
|
||||
|
||||
|
||||
|
||||
|
||||
/// A builder providing access to all methods supported on *watermark* resources.
|
||||
/// It is usually not used directly, but through the `YouTube` hub.
|
||||
///
|
||||
@@ -3709,6 +3762,10 @@ pub struct WatermarksMethodBuilder<'a, C, NC, A>
|
||||
}
|
||||
|
||||
impl<'a, C, NC, A> MethodBuilder for WatermarksMethodBuilder<'a, C, NC, A> {}
|
||||
|
||||
|
||||
|
||||
|
||||
/// A builder providing access to all methods supported on *liveBroadcast* resources.
|
||||
/// It is usually not used directly, but through the `YouTube` hub.
|
||||
///
|
||||
@@ -3753,6 +3810,10 @@ pub struct LiveBroadcastsMethodBuilder<'a, C, NC, A>
|
||||
}
|
||||
|
||||
impl<'a, C, NC, A> MethodBuilder for LiveBroadcastsMethodBuilder<'a, C, NC, A> {}
|
||||
|
||||
|
||||
|
||||
|
||||
/// A builder providing access to all methods supported on *videoCategorie* resources.
|
||||
/// It is usually not used directly, but through the `YouTube` hub.
|
||||
///
|
||||
@@ -3797,6 +3858,10 @@ pub struct VideoCategoriesMethodBuilder<'a, C, NC, A>
|
||||
}
|
||||
|
||||
impl<'a, C, NC, A> MethodBuilder for VideoCategoriesMethodBuilder<'a, C, NC, A> {}
|
||||
|
||||
|
||||
|
||||
|
||||
/// A builder providing access to all methods supported on *activitie* resources.
|
||||
/// It is usually not used directly, but through the `YouTube` hub.
|
||||
///
|
||||
@@ -3842,3 +3907,28 @@ pub struct ActivitiesMethodBuilder<'a, C, NC, A>
|
||||
|
||||
impl<'a, C, NC, A> MethodBuilder for ActivitiesMethodBuilder<'a, C, NC, A> {}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// ###################
|
||||
// CallBuilders ###
|
||||
// #################
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,19 +1,19 @@
|
||||
<%
|
||||
from util import (iter_nested_types, new_context, rust_comment, rust_doc_comment,
|
||||
rust_module_doc_comment, rust_doc_test_norun, canonical_type_name,
|
||||
mb_type, singular, rust_test_fn_invisible, put_and)
|
||||
rust_module_doc_comment, mb_type, hub_type)
|
||||
nested_schemas = list(iter_nested_types(schemas))
|
||||
|
||||
c = new_context(resources)
|
||||
|
||||
hub_type = canonical_type_name(canonicalName)
|
||||
hub_type = hub_type(canonicalName)
|
||||
|
||||
%>\
|
||||
<%namespace name="lib" file="lib/lib.mako"/>\
|
||||
<%namespace name="mutil" file="lib/util.mako"/>\
|
||||
<%namespace name="util" file="lib/util.mako"/>\
|
||||
<%namespace name="rbuild" file="lib/rbuild.mako"/>\
|
||||
<%namespace name="schema" file="lib/schema.mako"/>\
|
||||
<%block filter="rust_comment">\
|
||||
<%mutil:gen_info source="${self.uri}" />\
|
||||
<%util:gen_info source="${self.uri}" />\
|
||||
</%block>
|
||||
|
||||
<%block filter="rust_module_doc_comment">\
|
||||
@@ -97,33 +97,17 @@ ${schema.new(s, c)}
|
||||
// MethodBuilders ###
|
||||
// #################
|
||||
|
||||
% for resource, methods in c.rta_map.iteritems():
|
||||
/// A builder providing access to all methods supported on *${singular(resource)}* resources.
|
||||
/// It is usually not used directly, but through the `${hub_type}` hub.
|
||||
///
|
||||
/// # Example
|
||||
///
|
||||
/// Instantiate a resource builder
|
||||
///
|
||||
<%block filter="rust_doc_test_norun, rust_doc_comment">\
|
||||
${mutil.test_prelude()}\
|
||||
% for resource in c.rta_map:
|
||||
${rbuild.new(resource, c)}
|
||||
|
||||
<%block filter="rust_test_fn_invisible">\
|
||||
${lib.test_hub(canonical_type_name(canonicalName))}\
|
||||
|
||||
// Usually you wouldn't stick this into a variable, but keep calling `MethodBuilders`
|
||||
// like ${put_and(sorted('`%s(...)`' % f for f in methods))}
|
||||
let rb = hub.${resource}();
|
||||
</%block>
|
||||
</%block>
|
||||
pub struct ${mb_type(resource)}<'a, C, NC, A>
|
||||
where NC: 'a,
|
||||
C: 'a,
|
||||
A: 'a, {
|
||||
|
||||
hub: &'a ${hub_type}<C, NC, A>
|
||||
}
|
||||
|
||||
impl<'a, C, NC, A> MethodBuilder for ${mb_type(resource)}<'a, C, NC, A> {}
|
||||
% endfor
|
||||
|
||||
|
||||
// ###################
|
||||
// CallBuilders ###
|
||||
// #################
|
||||
|
||||
% for resource in c.rta_map:
|
||||
|
||||
% endfor
|
||||
40
src/mako/lib/rbuild.mako
Normal file
40
src/mako/lib/rbuild.mako
Normal file
@@ -0,0 +1,40 @@
|
||||
<%!
|
||||
from util import (put_and, rust_test_fn_invisible, rust_doc_test_norun, rust_doc_comment,
|
||||
mb_type, singular, hub_type)
|
||||
%>\
|
||||
<%namespace name="util" file="util.mako"/>\
|
||||
<%namespace name="lib" file="lib.mako"/>\
|
||||
|
||||
## Creates a Resource builder type
|
||||
###############################################################################################
|
||||
###############################################################################################
|
||||
<%def name="new(resource, c)">\
|
||||
<% hub_type_name = hub_type(canonicalName) %>
|
||||
/// A builder providing access to all methods supported on *${singular(resource)}* resources.
|
||||
/// It is usually not used directly, but through the `${hub_type_name}` hub.
|
||||
///
|
||||
/// # Example
|
||||
///
|
||||
/// Instantiate a resource builder
|
||||
///
|
||||
<%block filter="rust_doc_test_norun, rust_doc_comment">\
|
||||
${util.test_prelude()}\
|
||||
|
||||
<%block filter="rust_test_fn_invisible">\
|
||||
${lib.test_hub(hub_type_name)}\
|
||||
|
||||
// Usually you wouldn't stick this into a variable, but keep calling `MethodBuilders`
|
||||
// like ${put_and(sorted('`%s(...)`' % f for f in c.rta_map[resource]))}
|
||||
let rb = hub.${resource}();
|
||||
</%block>
|
||||
</%block>
|
||||
pub struct ${mb_type(resource)}<'a, C, NC, A>
|
||||
where NC: 'a,
|
||||
C: 'a,
|
||||
A: 'a, {
|
||||
|
||||
hub: &'a ${hub_type_name}<C, NC, A>
|
||||
}
|
||||
|
||||
impl<'a, C, NC, A> MethodBuilder for ${mb_type(resource)}<'a, C, NC, A> {}
|
||||
</%def>
|
||||
@@ -313,3 +313,6 @@ def library_name(name, version):
|
||||
# return type name of a resource builder, from a resource name
|
||||
def mb_type(r):
|
||||
return "%sMethodBuilder" % canonical_type_name(r)
|
||||
|
||||
def hub_type(canonicalName):
|
||||
return canonical_type_name(canonicalName)
|
||||
|
||||
Reference in New Issue
Block a user