From a5e675e7a958327938a31ec38ddebfaf58af9f42 Mon Sep 17 00:00:00 2001 From: Sebastian Thiel Date: Mon, 2 Mar 2015 19:07:15 +0100 Subject: [PATCH 01/12] feat(schema): generating valid rust from schemas It's very nice, even though there is some more work to be done here. It's just the beginning ... . --- src/mako/lib.rs.mako | 20 ++++++++++- src/mako/lib/schema.mako | 25 +++++++++++++ src/mako/lib/util.py | 76 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 120 insertions(+), 1 deletion(-) create mode 100644 src/mako/lib/schema.mako diff --git a/src/mako/lib.rs.mako b/src/mako/lib.rs.mako index cf73e30c59..fefa2571ec 100644 --- a/src/mako/lib.rs.mako +++ b/src/mako/lib.rs.mako @@ -1,9 +1,27 @@ <% import util %>\ <%namespace name="lib" file="lib/lib.mako"/>\ <%namespace name="mutil" file="lib/util.mako"/>\ +<%namespace name="schema" file="lib/schema.mako"/>\ <%block filter="util.rust_module_doc_comment">\ <%lib:docs />\ +#![allow(non_snake_case)] + extern crate cmn; extern crate "rustc-serialize" as rustc_serialize; -extern crate "yup-oauth2" as oauth2; \ No newline at end of file +extern crate "yup-oauth2" as oauth2; + +use std::default::Default; +use std::collections::HashMap; + +## SCHEMAS - normal ones +% for s in schemas.values(): +${schema.new(s)} +% endfor + +## SCHEMAS - nested +## some schemas are only used once and basically internal types. +## We have to find them and process them as normal types +% for s in util.iter_nested_types(schemas): +${schema.new(s)} +% endfor \ No newline at end of file diff --git a/src/mako/lib/schema.mako b/src/mako/lib/schema.mako new file mode 100644 index 0000000000..d24c2a1b73 --- /dev/null +++ b/src/mako/lib/schema.mako @@ -0,0 +1,25 @@ +<%! import util %>\ +## Create new schema with everything. +## 's' contains the schema structure from json to build +<%def name="new(s)">\ +<% assert s.type == "object" %>\ +<%block filter="util.rust_doc_comment">\ +${doc(s)}\ + +#[derive(RustcEncodable, RustcDecodable, Default, Clone)] +pub struct ${s.id}\ +% if 'properties' in s: + { +% for pn, p in s.properties.iteritems(): + ${p.get('description', 'no description provided') | util.rust_doc_comment} + pub ${util.mangle_ident(pn)}: ${util.to_rust_type(s.id, pn, p)}, +% endfor +} +% else: +; +% endif + + +<%def name="doc(s)">\ +${s.get('description', 'There is no detailed description.')} + \ No newline at end of file diff --git a/src/mako/lib/util.py b/src/mako/lib/util.py index 94e4f331d0..926d55ef23 100644 --- a/src/mako/lib/util.py +++ b/src/mako/lib/util.py @@ -1,6 +1,18 @@ import re re_linestart = re.compile('^', flags=re.MULTILINE) +USE_FORMAT = 'use_format_field' +TYPE_MAP = {'boolean' : 'bool', + 'integer' : USE_FORMAT, + 'number' : USE_FORMAT, + 'uint32' : 'u32', + 'double' : 'f64', + 'int32' : 'i32', + 'array' : 'Vec', + 'string' : 'String', + 'object' : 'HashMap'} +TREF = '$ref' + # rust module doc comment filter def rust_module_doc_comment(s): return re_linestart.sub('//! ', s) @@ -29,3 +41,67 @@ def estr(l): # build a full library name (non-canonical) def library_name(name, version): return name + to_api_version(version) + + +def nested_type_name(sn, pn): + return sn + pn[:1].upper() + pn[1:] + +# Make properties which are reserved keywords usable +def mangle_ident(n): + if n == 'type': + return n + '_' + return n + +# map a json type to an rust type +# sn = schema name +# pn = property name +# t = type dict +def to_rust_type(sn, pn, t, allow_optionals=True): + def nested_type(nt): + if nt.get('items', None) is not None: + nt = nt.items + elif nt.get('additionalProperties'): + nt = nt.additionalProperties + else: + assert(is_nested_type(nt)) + # It's a nested type - we take it literally like $ref, but generate a name for the type ourselves + # This of course assumes + return nested_type_name(sn, pn) + return to_rust_type(sn, pn, nt, allow_optionals=False) + + # unconditionally handle $ref types, which should point to another schema. + if TREF in t: + tn = t[TREF] + if allow_optionals: + return "Option<%s>" % tn + return tn + try: + rust_type = TYPE_MAP[t.type] + if t.type == 'array': + rust_type = "%s<%s>" % (rust_type, nested_type(t)) + elif t.type == 'object': + rust_type = "%s" % (rust_type, nested_type(t)) + elif rust_type == USE_FORMAT: + rust_type = TYPE_MAP[t.format] + return rust_type + except KeyError as err: + raise AssertionError("%s: Property type '%s' unknown - add new type mapping: %s" % (str(err), t.type, str(t))) + except AttributeError as err: + raise AssertionError("%s: unknown dict layout: %s" % (str(err), t)) + +def is_nested_type(t): + return 'type' in t and t.type == 'object' and 'additionalProperties' not in t + +# 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(): + if is_nested_type(p): + ns = p.copy() + ns.id = nested_type_name(s.id, pn) + yield ns + # end for ach property + # end for aech schma + From 49c2ffb8e0f02698657aba46a7b34981258c6e35 Mon Sep 17 00:00:00 2001 From: Sebastian Thiel Date: Mon, 2 Mar 2015 19:18:06 +0100 Subject: [PATCH 02/12] fix(schema): now docs look good too --- src/mako/lib/schema.mako | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mako/lib/schema.mako b/src/mako/lib/schema.mako index d24c2a1b73..b5764c43ec 100644 --- a/src/mako/lib/schema.mako +++ b/src/mako/lib/schema.mako @@ -21,5 +21,5 @@ pub struct ${s.id}\ <%def name="doc(s)">\ -${s.get('description', 'There is no detailed description.')} +${s.get('description', 'There is no detailed description.')}\ \ No newline at end of file From ddb48a4303a7a0653898e9eea69b3d358a14fa0c Mon Sep 17 00:00:00 2001 From: Sebastian Thiel Date: Mon, 2 Mar 2015 19:23:34 +0100 Subject: [PATCH 03/12] fix(schema): make all pods optionals. That way, json conversions will always work, which is probably what we desire (especially when handling server answers). --- src/mako/lib/util.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/mako/lib/util.py b/src/mako/lib/util.py index 926d55ef23..3ea372689b 100644 --- a/src/mako/lib/util.py +++ b/src/mako/lib/util.py @@ -76,13 +76,18 @@ def to_rust_type(sn, pn, t, allow_optionals=True): return "Option<%s>" % tn return tn try: + is_pod = True rust_type = TYPE_MAP[t.type] if t.type == 'array': rust_type = "%s<%s>" % (rust_type, nested_type(t)) + is_pod = False elif t.type == 'object': rust_type = "%s" % (rust_type, nested_type(t)) + is_pod = False elif rust_type == USE_FORMAT: rust_type = TYPE_MAP[t.format] + if is_pod and allow_optionals: + return "Option<%s>" % rust_type return rust_type except KeyError as err: raise AssertionError("%s: Property type '%s' unknown - add new type mapping: %s" % (str(err), t.type, str(t))) From d8edf1dcd46c6f7ae27e6f61b8aa1dea071a44a0 Mon Sep 17 00:00:00 2001 From: Sebastian Thiel Date: Mon, 2 Mar 2015 19:50:12 +0100 Subject: [PATCH 04/12] feat(youtube): first generated result ... ... just to keep track on how it changes over time. --- gen/youtube3/LICENSE.md | 25 + gen/youtube3/README.md | 11 + gen/youtube3/cargo.toml | 29 + gen/youtube3/src/lib.rs | 2021 +++++++++++++++++++++++++++++++++++++++ src/mako/lib.rs.mako | 1 - 5 files changed, 2086 insertions(+), 1 deletion(-) create mode 100644 gen/youtube3/LICENSE.md create mode 100644 gen/youtube3/README.md create mode 100644 gen/youtube3/cargo.toml create mode 100644 gen/youtube3/src/lib.rs diff --git a/gen/youtube3/LICENSE.md b/gen/youtube3/LICENSE.md new file mode 100644 index 0000000000..17daa1e3b3 --- /dev/null +++ b/gen/youtube3/LICENSE.md @@ -0,0 +1,25 @@ +The MIT License (MIT) +===================== + +Copyright © `2015` `Sebastian Thiel` + +Permission is hereby granted, free of charge, to any person +obtaining a copy of this software and associated documentation +files (the “Software”), to deal in the Software without +restriction, including without limitation the rights to use, +copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the +Software is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS IN THE SOFTWARE. diff --git a/gen/youtube3/README.md b/gen/youtube3/README.md new file mode 100644 index 0000000000..03ea76a32e --- /dev/null +++ b/gen/youtube3/README.md @@ -0,0 +1,11 @@ +The `youtube3` library allows access to all features of *YouTube*. + +TODO: Library level fully fledged documentation, incuding **summary** and **usage**. +And another line, for testing + +# License +The **youtube3** library was generated by Sebastian Thiel, and is placed +under the *MIT* license. +You can read the full text at the repository's [license file][repo-license]. + +[repo-license]: https://github.com/Byron/google-apis-rsLICENSE.md diff --git a/gen/youtube3/cargo.toml b/gen/youtube3/cargo.toml new file mode 100644 index 0000000000..1f9355d97e --- /dev/null +++ b/gen/youtube3/cargo.toml @@ -0,0 +1,29 @@ +# DO NOT EDIT ! +# This file was generated automatically by 'src/mako/cargo.toml.mako' +# DO NOT EDIT ! +[package] + +name = "youtube3" +version = "0.0.1" +authors = ["Sebastian Thiel "] +description = "A complete library to interact with YouTube (protocol v3)" +repository = "https://github.com/Byron/google-apis-rs/gen/youtube3" +homepage = "https://developers.google.com/youtube/v3" +documentation = "http://byron.github.io/google-apis-rs" +license = "MIT" +keywords = ["youtube", "google", "protocol", "web", "api"] + +[dependencies] +# Just to get hyper to work ! +openssl = "= 0.4.3" +# Just to get hyper to work ! +cookie = "= 0.1.13" +hyper = "*" +rustc-serialize = "*" +yup-oauth2 = "*" + +[dependencies.cmn] +path = "../.." + +[dev-dependencies] +yup-hyper-mock = "*" diff --git a/gen/youtube3/src/lib.rs b/gen/youtube3/src/lib.rs new file mode 100644 index 0000000000..f4953d8054 --- /dev/null +++ b/gen/youtube3/src/lib.rs @@ -0,0 +1,2021 @@ +//! TODO: Library level fully fledged documentation, incuding **summary** and **usage**. +//! And another line, for testing +//! +#![allow(non_snake_case)] + +extern crate cmn; +extern crate "rustc-serialize" as rustc_serialize; +extern crate "yup-oauth2" as oauth2; + +use std::default::Default; +use std::collections::HashMap; + +/// There is no detailed description. +#[derive(RustcEncodable, RustcDecodable, Default, Clone)] +pub struct VideoConversionPings { + /// Pings that the app shall fire for a video (authenticated by biscotti cookie). Each ping has a context, in which the app must fire the ping, and a url identifying the ping. + pub pings: Vec, +} + +/// There is no detailed description. +#[derive(RustcEncodable, RustcDecodable, Default, Clone)] +pub struct SubscriptionListResponse { + /// Serialized EventId of the request which produced this response. + pub eventId: Option, + /// The token that can be used as the value of the pageToken parameter to retrieve the next page in the result set. + pub nextPageToken: Option, + /// Identifies what kind of resource this is. Value: the fixed string "youtube#subscriptionListResponse". + pub kind: Option, + /// The visitorId identifies the visitor. + pub visitorId: Option, + /// A list of subscriptions that match the request criteria. + pub items: Vec, + /// no description provided + pub tokenPagination: Option, + /// Etag of this resource. + pub etag: Option, + /// The token that can be used as the value of the pageToken parameter to retrieve the previous page in the result set. + pub prevPageToken: Option, + /// no description provided + pub pageInfo: Option, +} + +/// Information about a resource that received a positive (like) rating. +#[derive(RustcEncodable, RustcDecodable, Default, Clone)] +pub struct ActivityContentDetailsLike { + /// The resourceId object contains information that identifies the rated resource. + pub resourceId: Option, +} + +/// There is no detailed description. +#[derive(RustcEncodable, RustcDecodable, Default, Clone)] +pub struct LiveBroadcastSnippet { + /// The date and time that the broadcast actually ended. This information is only available once the broadcast's state is complete. The value is specified in ISO 8601 (YYYY-MM-DDThh:mm:ss.sZ) format. + pub actualEndTime: Option, + /// The broadcast's description. As with the title, you can set this field by modifying the broadcast resource or by setting the description field of the corresponding video resource. + pub description: Option, + /// The broadcast's title. Note that the broadcast represents exactly one YouTube video. You can set this field by modifying the broadcast resource or by setting the title field of the corresponding video resource. + pub title: Option, + /// The ID that YouTube uses to uniquely identify the channel that is publishing the broadcast. + pub channelId: Option, + /// The date and time that the broadcast was added to YouTube's live broadcast schedule. The value is specified in ISO 8601 (YYYY-MM-DDThh:mm:ss.sZ) format. + pub publishedAt: Option, + /// The date and time that the broadcast is scheduled to start. The value is specified in ISO 8601 (YYYY-MM-DDThh:mm:ss.sZ) format. + pub scheduledStartTime: Option, + /// The date and time that the broadcast actually started. This information is only available once the broadcast's state is live. The value is specified in ISO 8601 (YYYY-MM-DDThh:mm:ss.sZ) format. + pub actualStartTime: Option, + /// The date and time that the broadcast is scheduled to end. The value is specified in ISO 8601 (YYYY-MM-DDThh:mm:ss.sZ) format. + pub scheduledEndTime: Option, + /// A map of thumbnail images associated with the broadcast. For each nested object in this object, the key is the name of the thumbnail image, and the value is an object that contains other information about the thumbnail. + pub thumbnails: Option, +} + +/// Describes original video file properties, including technical details about audio and video streams, but also metadata information like content length, digitization time, or geotagging information. +#[derive(RustcEncodable, RustcDecodable, Default, Clone)] +pub struct VideoFileDetails { + /// The uploaded video file's combined (video and audio) bitrate in bits per second. + pub bitrateBps: Option, + /// The uploaded video file's container format. + pub container: Option, + /// Geographic coordinates that identify the place where the uploaded video was recorded. Coordinates are defined using WGS 84. + pub recordingLocation: Option, + /// The uploaded file's type as detected by YouTube's video processing engine. Currently, YouTube only processes video files, but this field is present whether a video file or another type of file was uploaded. + pub fileType: Option, + /// The date and time when the uploaded video file was created. The value is specified in ISO 8601 format. Currently, the following ISO 8601 formats are supported: +/// - Date only: YYYY-MM-DD +/// - Naive time: YYYY-MM-DDTHH:MM:SS +/// - Time with timezone: YYYY-MM-DDTHH:MM:SS+HH:MM + pub creationTime: Option, + /// The length of the uploaded video in milliseconds. + pub durationMs: Option, + /// The uploaded file's name. This field is present whether a video file or another type of file was uploaded. + pub fileName: Option, + /// The uploaded file's size in bytes. This field is present whether a video file or another type of file was uploaded. + pub fileSize: Option, + /// A list of video streams contained in the uploaded video file. Each item in the list contains detailed metadata about a video stream. + pub videoStreams: Vec, + /// A list of audio streams contained in the uploaded video file. Each item in the list contains detailed metadata about an audio stream. + pub audioStreams: Vec, +} + +/// Playlist localization setting +#[derive(RustcEncodable, RustcDecodable, Default, Clone)] +pub struct PlaylistLocalization { + /// The localized strings for playlist's description. + pub description: Option, + /// The localized strings for playlist's title. + pub title: Option, +} + +/// A playlist resource represents a YouTube playlist. A playlist is a collection of videos that can be viewed sequentially and shared with other users. A playlist can contain up to 200 videos, and YouTube does not limit the number of playlists that each user creates. By default, playlists are publicly visible to other users, but playlists can be public or private. +/// +/// YouTube also uses playlists to identify special collections of videos for a channel, such as: +/// - uploaded videos +/// - favorite videos +/// - positively rated (liked) videos +/// - watch history +/// - watch later To be more specific, these lists are associated with a channel, which is a collection of a person, group, or company's videos, playlists, and other YouTube information. You can retrieve the playlist IDs for each of these lists from the channel resource for a given channel. +/// +/// You can then use the playlistItems.list method to retrieve any of those lists. You can also add or remove items from those lists by calling the playlistItems.insert and playlistItems.delete methods. +#[derive(RustcEncodable, RustcDecodable, Default, Clone)] +pub struct Playlist { + /// The status object contains status information for the playlist. + pub status: Option, + /// Identifies what kind of resource this is. Value: the fixed string "youtube#playlist". + pub kind: Option, + /// The contentDetails object contains information like video count. + pub contentDetails: Option, + /// The snippet object contains basic details about the playlist, such as its title and description. + pub snippet: Option, + /// The player object contains information that you would use to play the playlist in an embedded player. + pub player: Option, + /// Etag of this resource. + pub etag: Option, + /// The ID that YouTube uses to uniquely identify the playlist. + pub id: Option, + /// Localizations for different languages + pub localizations: HashMap, +} + +/// There is no detailed description. +#[derive(RustcEncodable, RustcDecodable, Default, Clone)] +pub struct PlaylistItemListResponse { + /// Serialized EventId of the request which produced this response. + pub eventId: Option, + /// The token that can be used as the value of the pageToken parameter to retrieve the next page in the result set. + pub nextPageToken: Option, + /// Identifies what kind of resource this is. Value: the fixed string "youtube#playlistItemListResponse". + pub kind: Option, + /// The visitorId identifies the visitor. + pub visitorId: Option, + /// A list of playlist items that match the request criteria. + pub items: Vec, + /// no description provided + pub tokenPagination: Option, + /// Etag of this resource. + pub etag: Option, + /// The token that can be used as the value of the pageToken parameter to retrieve the previous page in the result set. + pub prevPageToken: Option, + /// no description provided + pub pageInfo: Option, +} + +/// A pair Property / Value. +#[derive(RustcEncodable, RustcDecodable, Default, Clone)] +pub struct PropertyValue { + /// A property. + pub property: Option, + /// The property's value. + pub value: Option, +} + +/// Describes a temporal position of a visual widget inside a video. +#[derive(RustcEncodable, RustcDecodable, Default, Clone)] +pub struct InvideoTiming { + /// Defines the time at which the promotion will appear. Depending on the value of type the value of the offsetMs field will represent a time offset from the start or from the end of the video, expressed in milliseconds. + pub offsetMs: Option, + /// Describes a timing type. If the value is offsetFromStart, then the offsetMs field represents an offset from the start of the video. If the value is offsetFromEnd, then the offsetMs field represents an offset from the end of the video. + pub type_: Option, + /// Defines the duration in milliseconds for which the promotion should be displayed. If missing, the client should use the default. + pub durationMs: Option, +} + +/// Basic details about a playlist, including title, description and thumbnails. +#[derive(RustcEncodable, RustcDecodable, Default, Clone)] +pub struct PlaylistSnippet { + /// The playlist's description. + pub description: Option, + /// Keyword tags associated with the playlist. + pub tags: Vec, + /// The ID that YouTube uses to uniquely identify the channel that published the playlist. + pub channelId: Option, + /// The date and time that the playlist was created. The value is specified in ISO 8601 (YYYY-MM-DDThh:mm:ss.sZ) format. + pub publishedAt: Option, + /// The channel title of the channel that the video belongs to. + pub channelTitle: Option, + /// The playlist's title. + pub title: Option, + /// The language of the playlist's default title and description. + pub defaultLanguage: Option, + /// Localized title and description, read-only. + pub localized: Option, + /// A map of thumbnail images associated with the playlist. For each object in the map, the key is the name of the thumbnail image, and the value is an object that contains other information about the thumbnail. + pub thumbnails: Option, +} + +/// The auditDetails object encapsulates channel data that is relevant for YouTube Partners during the audit process. +#[derive(RustcEncodable, RustcDecodable, Default, Clone)] +pub struct ChannelAuditDetails { + /// Whether or not the channel has any copyright strikes. + pub copyrightStrikesGoodStanding: Option, + /// Whether or not the channel respects the community guidelines. + pub communityGuidelinesGoodStanding: Option, + /// Whether or not the channel has any unresolved claims. + pub contentIdClaimsGoodStanding: Option, + /// Describes the general state of the channel. This field will always show if there are any issues whatsoever with the channel. Currently this field represents the result of the logical and operation over the community guidelines good standing, the copyright strikes good standing and the content ID claims good standing, but this may change in the future. + pub overallGoodStanding: Option, +} + +/// A live stream describes a live ingestion point. +#[derive(RustcEncodable, RustcDecodable, Default, Clone)] +pub struct LiveStream { + /// The status object contains information about live stream's status. + pub status: Option, + /// The snippet object contains basic details about the stream, including its channel, title, and description. + pub snippet: Option, + /// Identifies what kind of resource this is. Value: the fixed string "youtube#liveStream". + pub kind: Option, + /// Etag of this resource. + pub etag: Option, + /// The content_details object contains information about the stream, including the closed captions ingestion URL. + pub contentDetails: Option, + /// The cdn object defines the live stream's content delivery network (CDN) settings. These settings provide details about the manner in which you stream your content to YouTube. + pub cdn: Option, + /// The ID that YouTube assigns to uniquely identify the stream. + pub id: Option, +} + +/// There is no detailed description. +#[derive(RustcEncodable, RustcDecodable, Default, Clone)] +pub struct ThumbnailSetResponse { + /// Serialized EventId of the request which produced this response. + pub eventId: Option, + /// A list of thumbnails. + pub items: Vec, + /// Identifies what kind of resource this is. Value: the fixed string "youtube#thumbnailSetResponse". + pub kind: Option, + /// Etag of this resource. + pub etag: Option, + /// The visitorId identifies the visitor. + pub visitorId: Option, +} + +/// Information about the uploaded video. +#[derive(RustcEncodable, RustcDecodable, Default, Clone)] +pub struct ActivityContentDetailsUpload { + /// The ID that YouTube uses to uniquely identify the uploaded video. + pub videoId: Option, +} + +/// Branding properties for the channel view. +#[derive(RustcEncodable, RustcDecodable, Default, Clone)] +pub struct ChannelSettings { + /// Specifies the channel description. + pub description: Option, + /// Specifies the channel title. + pub title: Option, + /// Whether user-submitted comments left on the channel page need to be approved by the channel owner to be publicly visible. + pub moderateComments: Option, + /// Whether the tab to browse the videos should be displayed. + pub showBrowseView: Option, + /// Title for the featured channels tab. + pub featuredChannelsTitle: Option, + /// no description provided + pub defaultLanguage: Option, + /// The trailer of the channel, for users that are not subscribers. + pub unsubscribedTrailer: Option, + /// The list of featured channels. + pub featuredChannelsUrls: Vec, + /// A prominent color that can be rendered on this channel page. + pub profileColor: Option, + /// Which content tab users should see when viewing the channel. + pub defaultTab: Option, + /// Lists keywords associated with the channel, comma-separated. + pub keywords: Option, + /// Whether related channels should be proposed. + pub showRelatedChannels: Option, + /// The ID for a Google Analytics account to track and measure traffic to the channels. + pub trackingAnalyticsAccountId: Option, +} + +/// Statistics about the video, such as the number of times the video was viewed or liked. +#[derive(RustcEncodable, RustcDecodable, Default, Clone)] +pub struct VideoStatistics { + /// The number of comments for the video. + pub commentCount: Option, + /// The number of times the video has been viewed. + pub viewCount: Option, + /// The number of users who currently have the video marked as a favorite video. + pub favoriteCount: Option, + /// The number of users who have indicated that they disliked the video by giving it a negative rating. + pub dislikeCount: Option, + /// The number of users who have indicated that they liked the video by giving it a positive rating. + pub likeCount: Option, +} + +/// Brief description of the live stream cdn settings. +#[derive(RustcEncodable, RustcDecodable, Default, Clone)] +pub struct CdnSettings { + /// The format of the video stream that you are sending to Youtube. + pub format: Option, + /// The ingestionInfo object contains information that YouTube provides that you need to transmit your RTMP or HTTP stream to YouTube. + pub ingestionInfo: Option, + /// The method or protocol used to transmit the video stream. + pub ingestionType: Option, +} + +/// There is no detailed description. +#[derive(RustcEncodable, RustcDecodable, Default, Clone)] +pub struct VideoGetRatingResponse { + /// Serialized EventId of the request which produced this response. + pub eventId: Option, + /// A list of ratings that match the request criteria. + pub items: Vec, + /// Identifies what kind of resource this is. Value: the fixed string "youtube#videoGetRatingResponse". + pub kind: Option, + /// Etag of this resource. + pub etag: Option, + /// The visitorId identifies the visitor. + pub visitorId: Option, +} + +/// Basic details about a video category, such as its localized title. +#[derive(RustcEncodable, RustcDecodable, Default, Clone)] +pub struct VideoCategorySnippet { + /// no description provided + pub assignable: Option, + /// The YouTube channel that created the video category. + pub channelId: Option, + /// The video category's title. + pub title: Option, +} + +/// Details about a resource which was added to a channel. +#[derive(RustcEncodable, RustcDecodable, Default, Clone)] +pub struct ActivityContentDetailsChannelItem { + /// The resourceId object contains information that identifies the resource that was added to the channel. + pub resourceId: Option, +} + +/// Basic details about an i18n language, such as language code and human-readable name. +#[derive(RustcEncodable, RustcDecodable, Default, Clone)] +pub struct I18nLanguageSnippet { + /// The human-readable name of the language in the language itself. + pub name: Option, + /// A short BCP-47 code that uniquely identifies a language. + pub hl: Option, +} + +/// Basic details about a subscription, including title, description and thumbnails of the subscribed item. +#[derive(RustcEncodable, RustcDecodable, Default, Clone)] +pub struct SubscriptionSnippet { + /// A map of thumbnail images associated with the video. For each object in the map, the key is the name of the thumbnail image, and the value is an object that contains other information about the thumbnail. + pub thumbnails: Option, + /// The subscription's title. + pub title: Option, + /// The id object contains information about the channel that the user subscribed to. + pub resourceId: Option, + /// The subscription's details. + pub description: Option, + /// The ID that YouTube uses to uniquely identify the subscriber's channel. + pub channelId: Option, + /// The date and time that the subscription was created. The value is specified in ISO 8601 (YYYY-MM-DDThh:mm:ss.sZ) format. + pub publishedAt: Option, + /// Channel title for the channel that the subscription belongs to. + pub channelTitle: Option, +} + +/// Details about a channelsection, including playlists and channels. +#[derive(RustcEncodable, RustcDecodable, Default, Clone)] +pub struct ChannelSectionContentDetails { + /// The channel ids for type multiple_channels. + pub channels: Vec, + /// The playlist ids for type single_playlist and multiple_playlists. For singlePlaylist, only one playlistId is allowed. + pub playlists: Vec, +} + +/// There is no detailed description. +#[derive(RustcEncodable, RustcDecodable, Default, Clone)] +pub struct I18nRegionListResponse { + /// Serialized EventId of the request which produced this response. + pub eventId: Option, + /// A list of regions where YouTube is available. In this map, the i18n region ID is the map key, and its value is the corresponding i18nRegion resource. + pub items: Vec, + /// Identifies what kind of resource this is. Value: the fixed string "youtube#i18nRegionListResponse". + pub kind: Option, + /// Etag of this resource. + pub etag: Option, + /// The visitorId identifies the visitor. + pub visitorId: Option, +} + +/// There is no detailed description. +#[derive(RustcEncodable, RustcDecodable, Default, Clone)] +pub struct LiveStreamListResponse { + /// Serialized EventId of the request which produced this response. + pub eventId: Option, + /// The token that can be used as the value of the pageToken parameter to retrieve the next page in the result set. + pub nextPageToken: Option, + /// Identifies what kind of resource this is. Value: the fixed string "youtube#liveStreamListResponse". + pub kind: Option, + /// The visitorId identifies the visitor. + pub visitorId: Option, + /// A list of live streams that match the request criteria. + pub items: Vec, + /// no description provided + pub tokenPagination: Option, + /// Etag of this resource. + pub etag: Option, + /// The token that can be used as the value of the pageToken parameter to retrieve the previous page in the result set. + pub prevPageToken: Option, + /// no description provided + pub pageInfo: Option, +} + +/// Describes a single promoted item. +#[derive(RustcEncodable, RustcDecodable, Default, Clone)] +pub struct PromotedItem { + /// The temporal position within the video where the promoted item will be displayed. If present, it overrides the default timing. + pub timing: Option, + /// If true, the content owner's name will be used when displaying the promotion. This field can only be set when the update is made on behalf of the content owner. + pub promotedByContentOwner: Option, + /// A custom message to display for this promotion. This field is currently ignored unless the promoted item is a website. + pub customMessage: Option, + /// Identifies the promoted item. + pub id: Option, +} + +/// Branding properties of a YouTube channel. +#[derive(RustcEncodable, RustcDecodable, Default, Clone)] +pub struct ChannelBrandingSettings { + /// Branding properties for branding images. + pub image: Option, + /// Branding properties for the watch page. + pub watch: Option, + /// Branding properties for the channel view. + pub channel: Option, + /// Additional experimental branding properties. + pub hints: Vec, +} + +/// There is no detailed description. +#[derive(RustcEncodable, RustcDecodable, Default, Clone)] +pub struct PlaylistListResponse { + /// Serialized EventId of the request which produced this response. + pub eventId: Option, + /// The token that can be used as the value of the pageToken parameter to retrieve the next page in the result set. + pub nextPageToken: Option, + /// Identifies what kind of resource this is. Value: the fixed string "youtube#playlistListResponse". + pub kind: Option, + /// The visitorId identifies the visitor. + pub visitorId: Option, + /// A list of playlists that match the request criteria. + pub items: Vec, + /// no description provided + pub tokenPagination: Option, + /// Etag of this resource. + pub etag: Option, + /// The token that can be used as the value of the pageToken parameter to retrieve the previous page in the result set. + pub prevPageToken: Option, + /// no description provided + pub pageInfo: Option, +} + +/// There is no detailed description. +#[derive(RustcEncodable, RustcDecodable, Default, Clone)] +pub struct InvideoBranding { + /// no description provided + pub targetChannelId: Option, + /// no description provided + pub position: Option, + /// no description provided + pub imageUrl: Option, + /// no description provided + pub timing: Option, + /// no description provided + pub imageBytes: Option, +} + +/// Information about the playlist item's privacy status. +#[derive(RustcEncodable, RustcDecodable, Default, Clone)] +pub struct PlaylistItemStatus { + /// This resource's privacy status. + pub privacyStatus: Option, +} + +/// Pings that the app shall fire (authenticated by biscotti cookie). Each ping has a context, in which the app must fire the ping, and a url identifying the ping. +#[derive(RustcEncodable, RustcDecodable, Default, Clone)] +pub struct ChannelConversionPing { + /// Defines the context of the ping. + pub context: Option, + /// The url (without the schema) that the player shall send the ping to. It's at caller's descretion to decide which schema to use (http vs https) Example of a returned url: //googleads.g.doubleclick.net/pagead/ viewthroughconversion/962985656/?data=path%3DtHe_path%3Btype%3D cview%3Butuid%3DGISQtTNGYqaYl4sKxoVvKA&labe=default The caller must append biscotti authentication (ms param in case of mobile, for example) to this ping. + pub conversionUrl: Option, +} + +/// Describes an invideo promotion campaign consisting of multiple promoted items. A campaign belongs to a single channel_id. +#[derive(RustcEncodable, RustcDecodable, Default, Clone)] +pub struct InvideoPromotion { + /// The default temporal position within the video where the promoted item will be displayed. Can be overriden by more specific timing in the item. + pub defaultTiming: Option, + /// List of promoted items in decreasing priority. + pub items: Vec, + /// Indicates whether the channel's promotional campaign uses "smart timing." This feature attempts to show promotions at a point in the video when they are more likely to be clicked and less likely to disrupt the viewing experience. This feature also picks up a single promotion to show on each video. + pub useSmartTiming: Option, + /// The spatial position within the video where the promoted item will be displayed. + pub position: Option, +} + +/// A playlistItem resource identifies another resource, such as a video, that is included in a playlist. In addition, the playlistItem resource contains details about the included resource that pertain specifically to how that resource is used in that playlist. +/// +/// YouTube uses playlists to identify special collections of videos for a channel, such as: +/// - uploaded videos +/// - favorite videos +/// - positively rated (liked) videos +/// - watch history +/// - watch later To be more specific, these lists are associated with a channel, which is a collection of a person, group, or company's videos, playlists, and other YouTube information. +/// +/// You can retrieve the playlist IDs for each of these lists from the channel resource for a given channel. You can then use the playlistItems.list method to retrieve any of those lists. You can also add or remove items from those lists by calling the playlistItems.insert and playlistItems.delete methods. For example, if a user gives a positive rating to a video, you would insert that video into the liked videos playlist for that user's channel. +#[derive(RustcEncodable, RustcDecodable, Default, Clone)] +pub struct PlaylistItem { + /// The status object contains information about the playlist item's privacy status. + pub status: Option, + /// The snippet object contains basic details about the playlist item, such as its title and position in the playlist. + pub snippet: Option, + /// Identifies what kind of resource this is. Value: the fixed string "youtube#playlistItem". + pub kind: Option, + /// Etag of this resource. + pub etag: Option, + /// The contentDetails object is included in the resource if the included item is a YouTube video. The object contains additional information about the video. + pub contentDetails: Option, + /// The ID that YouTube uses to uniquely identify the playlist item. + pub id: Option, +} + +/// There is no detailed description. +#[derive(RustcEncodable, RustcDecodable, Default, Clone)] +pub struct GuideCategoryListResponse { + /// Serialized EventId of the request which produced this response. + pub eventId: Option, + /// The token that can be used as the value of the pageToken parameter to retrieve the next page in the result set. + pub nextPageToken: Option, + /// Identifies what kind of resource this is. Value: the fixed string "youtube#guideCategoryListResponse". + pub kind: Option, + /// The visitorId identifies the visitor. + pub visitorId: Option, + /// A list of categories that can be associated with YouTube channels. In this map, the category ID is the map key, and its value is the corresponding guideCategory resource. + pub items: Vec, + /// no description provided + pub tokenPagination: Option, + /// Etag of this resource. + pub etag: Option, + /// The token that can be used as the value of the pageToken parameter to retrieve the previous page in the result set. + pub prevPageToken: Option, + /// no description provided + pub pageInfo: Option, +} + +/// Localized versions of certain video properties (e.g. title). +#[derive(RustcEncodable, RustcDecodable, Default, Clone)] +pub struct VideoLocalization { + /// Localized version of the video's description. + pub description: Option, + /// Localized version of the video's title. + pub title: Option, +} + +/// Basic details about a channel section, including title, style and position. +#[derive(RustcEncodable, RustcDecodable, Default, Clone)] +pub struct ChannelSectionSnippet { + /// The style of the channel section. + pub style: Option, + /// Localized title, read-only. + pub localized: Option, + /// The channel section's title for multiple_playlists and multiple_channels. + pub title: Option, + /// The position of the channel section in the channel. + pub position: Option, + /// The ID that YouTube uses to uniquely identify the channel that published the channel section. + pub channelId: Option, + /// The type of the channel section. + pub type_: Option, + /// The language of the channel section's default title and description. + pub defaultLanguage: Option, +} + +/// Details about the content of a channel. +#[derive(RustcEncodable, RustcDecodable, Default, Clone)] +pub struct ChannelContentDetails { + /// no description provided + pub relatedPlaylists: HashMap, + /// The googlePlusUserId object identifies the Google+ profile ID associated with this channel. + pub googlePlusUserId: Option, +} + +/// Stub token pagination template to suppress results. +#[derive(RustcEncodable, RustcDecodable, Default, Clone)] +pub struct TokenPagination; + +/// There is no detailed description. +#[derive(RustcEncodable, RustcDecodable, Default, Clone)] +pub struct PlaylistItemContentDetails { + /// A user-generated note for this item. + pub note: Option, + /// The time, measured in seconds from the start of the video, when the video should start playing. (The playlist owner can specify the times when the video should start and stop playing when the video is played in the context of the playlist.) The default value is 0. + pub startAt: Option, + /// The time, measured in seconds from the start of the video, when the video should stop playing. (The playlist owner can specify the times when the video should start and stop playing when the video is played in the context of the playlist.) By default, assume that the video.endTime is the end of the video. + pub endAt: Option, + /// The ID that YouTube uses to uniquely identify a video. To retrieve the video resource, set the id query parameter to this value in your API request. + pub videoId: Option, +} + +/// Internal representation of thumbnails for a YouTube resource. +#[derive(RustcEncodable, RustcDecodable, Default, Clone)] +pub struct ThumbnailDetails { + /// The default image for this resource. + pub default: Option, + /// The high quality image for this resource. + pub high: Option, + /// The medium quality image for this resource. + pub medium: Option, + /// The maximum resolution quality image for this resource. + pub maxres: Option, + /// The standard quality image for this resource. + pub standard: Option, +} + +/// Details about monetization of a YouTube Video. +#[derive(RustcEncodable, RustcDecodable, Default, Clone)] +pub struct VideoMonetizationDetails { + /// The value of access indicates whether the video can be monetized or not. + pub access: Option, +} + +/// Information that identifies the recommended resource. +#[derive(RustcEncodable, RustcDecodable, Default, Clone)] +pub struct ActivityContentDetailsRecommendation { + /// The resourceId object contains information that identifies the recommended resource. + pub resourceId: Option, + /// The reason that the resource is recommended to the user. + pub reason: Option, + /// The seedResourceId object contains information about the resource that caused the recommendation. + pub seedResourceId: Option, +} + +/// Recording information associated with the video. +#[derive(RustcEncodable, RustcDecodable, Default, Clone)] +pub struct VideoRecordingDetails { + /// The date and time when the video was recorded. The value is specified in ISO 8601 (YYYY-MM-DDThh:mm:ss.sssZ) format. + pub recordingDate: Option, + /// The text description of the location where the video was recorded. + pub locationDescription: Option, + /// The geolocation information associated with the video. + pub location: Option, +} + +/// Information about a channel that a user subscribed to. +#[derive(RustcEncodable, RustcDecodable, Default, Clone)] +pub struct ActivityContentDetailsSubscription { + /// The resourceId object contains information that identifies the resource that the user subscribed to. + pub resourceId: Option, +} + +/// The conversionPings object encapsulates information about conversion pings that need to be respected by the channel. +#[derive(RustcEncodable, RustcDecodable, Default, Clone)] +pub struct ChannelConversionPings { + /// Pings that the app shall fire (authenticated by biscotti cookie). Each ping has a context, in which the app must fire the ping, and a url identifying the ping. + pub pings: Vec, +} + +/// Details about the content of an activity: the video that was shared, the channel that was subscribed to, etc. +#[derive(RustcEncodable, RustcDecodable, Default, Clone)] +pub struct ActivityContentDetails { + /// The comment object contains information about a resource that received a comment. This property is only present if the snippet.type is comment. + pub comment: Option, + /// The playlistItem object contains information about a new playlist item. This property is only present if the snippet.type is playlistItem. + pub playlistItem: Option, + /// The like object contains information about a resource that received a positive (like) rating. This property is only present if the snippet.type is like. + pub like: Option, + /// The promotedItem object contains details about a resource which is being promoted. This property is only present if the snippet.type is promotedItem. + pub promotedItem: Option, + /// The recommendation object contains information about a recommended resource. This property is only present if the snippet.type is recommendation. + pub recommendation: Option, + /// The favorite object contains information about a video that was marked as a favorite video. This property is only present if the snippet.type is favorite. + pub favorite: Option, + /// The upload object contains information about the uploaded video. This property is only present if the snippet.type is upload. + pub upload: Option, + /// The social object contains details about a social network post. This property is only present if the snippet.type is social. + pub social: Option, + /// The channelItem object contains details about a resource which was added to a channel. This property is only present if the snippet.type is channelItem. + pub channelItem: Option, + /// The bulletin object contains details about a channel bulletin post. This object is only present if the snippet.type is bulletin. + pub bulletin: Option, + /// The subscription object contains information about a channel that a user subscribed to. This property is only present if the snippet.type is subscription. + pub subscription: Option, +} + +/// A i18nRegion resource identifies a region where YouTube is available. +#[derive(RustcEncodable, RustcDecodable, Default, Clone)] +pub struct I18nRegion { + /// The snippet object contains basic details about the i18n region, such as region code and human-readable name. + pub snippet: Option, + /// Identifies what kind of resource this is. Value: the fixed string "youtube#i18nRegion". + pub kind: Option, + /// Etag of this resource. + pub etag: Option, + /// The ID that YouTube uses to uniquely identify the i18n region. + pub id: Option, +} + +/// The contentOwnerDetails object encapsulates channel data that is relevant for YouTube Partners linked with the channel. +#[derive(RustcEncodable, RustcDecodable, Default, Clone)] +pub struct ChannelContentOwnerDetails { + /// The ID of the content owner linked to the channel. + pub contentOwner: Option, + /// The date and time of when the channel was linked to the content owner. The value is specified in ISO 8601 (YYYY-MM-DDThh:mm:ss.sZ) format. + pub timeLinked: Option, +} + +/// Describes processing status and progress and availability of some other Video resource parts. +#[derive(RustcEncodable, RustcDecodable, Default, Clone)] +pub struct VideoProcessingDetails { + /// This value indicates whether file details are available for the uploaded video. You can retrieve a video's file details by requesting the fileDetails part in your videos.list() request. + pub fileDetailsAvailability: Option, + /// This value indicates whether video editing suggestions, which might improve video quality or the playback experience, are available for the video. You can retrieve these suggestions by requesting the suggestions part in your videos.list() request. + pub editorSuggestionsAvailability: Option, + /// The video's processing status. This value indicates whether YouTube was able to process the video or if the video is still being processed. + pub processingStatus: Option, + /// This value indicates whether the video processing engine has generated suggestions that might improve YouTube's ability to process the the video, warnings that explain video processing problems, or errors that cause video processing problems. You can retrieve these suggestions by requesting the suggestions part in your videos.list() request. + pub processingIssuesAvailability: Option, + /// The reason that YouTube failed to process the video. This property will only have a value if the processingStatus property's value is failed. + pub processingFailureReason: Option, + /// This value indicates whether thumbnail images have been generated for the video. + pub thumbnailsAvailability: Option, + /// The processingProgress object contains information about the progress YouTube has made in processing the video. The values are really only relevant if the video's processing status is processing. + pub processingProgress: Option, + /// This value indicates whether keyword (tag) suggestions are available for the video. Tags can be added to a video's metadata to make it easier for other users to find the video. You can retrieve these suggestions by requesting the suggestions part in your videos.list() request. + pub tagSuggestionsAvailability: Option, +} + +/// There is no detailed description. +#[derive(RustcEncodable, RustcDecodable, Default, Clone)] +pub struct LiveBroadcastStatus { + /// The broadcast's recording status. + pub recordingStatus: Option, + /// The broadcast's privacy status. Note that the broadcast represents exactly one YouTube video, so the privacy settings are identical to those supported for videos. In addition, you can set this field by modifying the broadcast resource or by setting the privacyStatus field of the corresponding video resource. + pub privacyStatus: Option, + /// The broadcast's status. The status can be updated using the API's liveBroadcasts.transition method. + pub lifeCycleStatus: Option, + /// Priority of the live broadcast event (internal state). + pub liveBroadcastPriority: Option, +} + +/// Details about the content to witch a subscription refers. +#[derive(RustcEncodable, RustcDecodable, Default, Clone)] +pub struct SubscriptionContentDetails { + /// The number of new items in the subscription since its content was last read. + pub newItemCount: Option, + /// The type of activity this subscription is for (only uploads, everything). + pub activityType: Option, + /// The approximate number of items that the subscription points to. + pub totalItemCount: Option, +} + +/// A video resource represents a YouTube video. +#[derive(RustcEncodable, RustcDecodable, Default, Clone)] +pub struct Video { + /// The status object contains information about the video's uploading, processing, and privacy statuses. + pub status: Option, + /// The topicDetails object encapsulates information about Freebase topics associated with the video. + pub topicDetails: Option, + /// The monetizationDetails object encapsulates information about the monetization status of the video. + pub monetizationDetails: Option, + /// The suggestions object encapsulates suggestions that identify opportunities to improve the video quality or the metadata for the uploaded video. This data can only be retrieved by the video owner. + pub suggestions: Option, + /// Age restriction details related to a video. + pub ageGating: Option, + /// The fileDetails object encapsulates information about the video file that was uploaded to YouTube, including the file's resolution, duration, audio and video codecs, stream bitrates, and more. This data can only be retrieved by the video owner. + pub fileDetails: Option, + /// The player object contains information that you would use to play the video in an embedded player. + pub player: Option, + /// The ID that YouTube uses to uniquely identify the video. + pub id: Option, + /// List with all localizations. + pub localizations: HashMap, + /// The liveStreamingDetails object contains metadata about a live video broadcast. The object will only be present in a video resource if the video is an upcoming, live, or completed live broadcast. + pub liveStreamingDetails: Option, + /// The processingProgress object encapsulates information about YouTube's progress in processing the uploaded video file. The properties in the object identify the current processing status and an estimate of the time remaining until YouTube finishes processing the video. This part also indicates whether different types of data or content, such as file details or thumbnail images, are available for the video. +/// +/// The processingProgress object is designed to be polled so that the video uploaded can track the progress that YouTube has made in processing the uploaded video file. This data can only be retrieved by the video owner. + pub processingDetails: Option, + /// Identifies what kind of resource this is. Value: the fixed string "youtube#video". + pub kind: Option, + /// The statistics object contains statistics about the video. + pub statistics: Option, + /// The contentDetails object contains information about the video content, including the length of the video and its aspect ratio. + pub contentDetails: Option, + /// The conversionPings object encapsulates information about url pings that need to be respected by the App in different video contexts. + pub conversionPings: Option, + /// The snippet object contains basic details about the video, such as its title, description, and category. + pub snippet: Option, + /// Etag of this resource. + pub etag: Option, + /// The projectDetails object contains information about the project specific video metadata. + pub projectDetails: Option, + /// The recordingDetails object encapsulates information about the location, date and address where the video was recorded. + pub recordingDetails: Option, +} + +/// Geographical coordinates of a point, in WGS84. +#[derive(RustcEncodable, RustcDecodable, Default, Clone)] +pub struct GeoPoint { + /// Latitude in degrees. + pub latitude: Option, + /// Altitude above the reference ellipsoid, in meters. + pub altitude: Option, + /// Longitude in degrees. + pub longitude: Option, +} + +/// There is no detailed description. +#[derive(RustcEncodable, RustcDecodable, Default, Clone)] +pub struct VideoAgeGating { + /// Age-restricted trailers. For redband trailers and adult-rated video-games. Only users aged 18+ can view the content. The the field is true the content is restricted to viewers aged 18+. Otherwise The field won't be present. + pub restricted: Option, + /// Indicates whether or not the video has alcoholic beverage content. Only users of legal purchasing age in a particular country, as identified by ICAP, can view the content. + pub alcoholContent: Option, + /// Video game rating, if any. + pub videoGameRating: Option, +} + +/// Player to be used for a video playback. +#[derive(RustcEncodable, RustcDecodable, Default, Clone)] +pub struct VideoPlayer { + /// An