google-api-client 0.9 → 0.9.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (59) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +4 -0
  3. data/Gemfile +5 -0
  4. data/README.md +1 -1
  5. data/api_names.yaml +1 -1
  6. data/api_names_out.yaml +14 -8
  7. data/generated/google/apis/adexchangebuyer_v1_3.rb +1 -1
  8. data/generated/google/apis/androidpublisher_v2/classes.rb +1 -1
  9. data/generated/google/apis/androidpublisher_v2/representations.rb +2 -2
  10. data/generated/google/apis/androidpublisher_v2/service.rb +4 -4
  11. data/generated/google/apis/appstate_v1.rb +1 -1
  12. data/generated/google/apis/bigquery_v2.rb +1 -1
  13. data/generated/google/apis/books_v1.rb +1 -1
  14. data/generated/google/apis/books_v1/classes.rb +50 -0
  15. data/generated/google/apis/books_v1/representations.rb +8 -0
  16. data/generated/google/apis/books_v1/service.rb +16 -4
  17. data/generated/google/apis/calendar_v3.rb +1 -1
  18. data/generated/google/apis/compute_beta.rb +1 -1
  19. data/generated/google/apis/compute_beta/classes.rb +141 -93
  20. data/generated/google/apis/compute_beta/representations.rb +1 -0
  21. data/generated/google/apis/compute_beta/service.rb +65 -58
  22. data/generated/google/apis/compute_v1.rb +1 -1
  23. data/generated/google/apis/compute_v1/classes.rb +83 -55
  24. data/generated/google/apis/compute_v1/service.rb +59 -52
  25. data/generated/google/apis/content_v2.rb +1 -1
  26. data/generated/google/apis/content_v2/classes.rb +1 -1
  27. data/generated/google/apis/drive_v2.rb +1 -1
  28. data/generated/google/apis/drive_v3.rb +1 -1
  29. data/generated/google/apis/games_configuration_v1configuration.rb +1 -1
  30. data/generated/google/apis/games_management_v1management.rb +1 -1
  31. data/generated/google/apis/games_v1.rb +1 -1
  32. data/generated/google/apis/genomics_v1.rb +1 -1
  33. data/generated/google/apis/plus_domains_v1.rb +1 -1
  34. data/generated/google/apis/plus_v1.rb +1 -1
  35. data/generated/google/apis/youtube_v3.rb +1 -1
  36. data/generated/google/apis/youtube_v3/classes.rb +9 -61
  37. data/generated/google/apis/youtube_v3/representations.rb +1 -26
  38. data/lib/google/apis/core/upload.rb +1 -0
  39. data/lib/google/apis/version.rb +1 -1
  40. data/samples/{Gemfile → cli/Gemfile} +1 -1
  41. data/samples/{README.md → cli/README.md} +0 -0
  42. data/samples/{google-api-samples → cli/google-api-samples} +0 -0
  43. data/samples/{lib → cli/lib}/base_cli.rb +0 -0
  44. data/samples/{lib → cli/lib}/samples/analytics.rb +0 -0
  45. data/samples/{lib → cli/lib}/samples/calendar.rb +0 -0
  46. data/samples/{lib → cli/lib}/samples/drive.rb +0 -0
  47. data/samples/{lib → cli/lib}/samples/gmail.rb +0 -0
  48. data/samples/{lib → cli/lib}/samples/pubsub.rb +0 -0
  49. data/samples/{lib → cli/lib}/samples/translate.rb +0 -0
  50. data/samples/{lib → cli/lib}/samples/you_tube.rb +0 -0
  51. data/samples/web/Gemfile +7 -0
  52. data/samples/web/README.md +44 -0
  53. data/samples/web/app.rb +120 -0
  54. data/samples/web/views/calendar.erb +34 -0
  55. data/samples/web/views/drive.erb +33 -0
  56. data/samples/web/views/home.erb +35 -0
  57. data/samples/web/views/layout.erb +40 -0
  58. data/spec/google/api_client/client_secrets_spec.rb +300 -1
  59. metadata +20 -13
@@ -25,7 +25,7 @@ module Google
25
25
  # @see https://developers.google.com/+/domains/
26
26
  module PlusDomainsV1
27
27
  VERSION = 'V1'
28
- REVISION = '20160112'
28
+ REVISION = '20160118'
29
29
 
30
30
  # View your circles and the people and pages in them
31
31
  AUTH_PLUS_CIRCLES_READ = 'https://www.googleapis.com/auth/plus.circles.read'
@@ -25,7 +25,7 @@ module Google
25
25
  # @see https://developers.google.com/+/api/
26
26
  module PlusV1
27
27
  VERSION = 'V1'
28
- REVISION = '20160112'
28
+ REVISION = '20160118'
29
29
 
30
30
  # Know your basic profile info and list of people in your circles.
31
31
  AUTH_PLUS_LOGIN = 'https://www.googleapis.com/auth/plus.login'
@@ -25,7 +25,7 @@ module Google
25
25
  # @see https://developers.google.com/youtube/v3
26
26
  module YoutubeV3
27
27
  VERSION = 'V3'
28
- REVISION = '20160106'
28
+ REVISION = '20160111'
29
29
 
30
30
  # Manage your YouTube account
31
31
  AUTH_YOUTUBE = 'https://www.googleapis.com/auth/youtube'
@@ -2295,7 +2295,7 @@ module Google
2295
2295
  end
2296
2296
 
2297
2297
  # Ratings schemes. The country-specific ratings are mostly for movies and shows.
2298
- # NEXT_ID: 66
2298
+ # NEXT_ID: 67
2299
2299
  class ContentRating
2300
2300
  include Google::Apis::Core::Hashable
2301
2301
 
@@ -2417,6 +2417,12 @@ module Google
2417
2417
  # @return [Array<String>]
2418
2418
  attr_accessor :djctq_rating_reasons
2419
2419
 
2420
+ # Rating system in Turkey - Evaluation and Classification Board of the Ministry
2421
+ # of Culture and Tourism
2422
+ # Corresponds to the JSON property `ecbmctRating`
2423
+ # @return [String]
2424
+ attr_accessor :ecbmct_rating
2425
+
2420
2426
  # The video's rating in Estonia.
2421
2427
  # Corresponds to the JSON property `eefilmRating`
2422
2428
  # @return [String]
@@ -2681,6 +2687,7 @@ module Google
2681
2687
  @czfilm_rating = args[:czfilm_rating] unless args[:czfilm_rating].nil?
2682
2688
  @djctq_rating = args[:djctq_rating] unless args[:djctq_rating].nil?
2683
2689
  @djctq_rating_reasons = args[:djctq_rating_reasons] unless args[:djctq_rating_reasons].nil?
2690
+ @ecbmct_rating = args[:ecbmct_rating] unless args[:ecbmct_rating].nil?
2684
2691
  @eefilm_rating = args[:eefilm_rating] unless args[:eefilm_rating].nil?
2685
2692
  @egfilm_rating = args[:egfilm_rating] unless args[:egfilm_rating].nil?
2686
2693
  @eirin_rating = args[:eirin_rating] unless args[:eirin_rating].nil?
@@ -6516,12 +6523,6 @@ module Google
6516
6523
  # @return [Google::Apis::YoutubeV3::VideoContentDetails]
6517
6524
  attr_accessor :content_details
6518
6525
 
6519
- # The conversionPings object encapsulates information about url pings that need
6520
- # to be respected by the App in different video contexts.
6521
- # Corresponds to the JSON property `conversionPings`
6522
- # @return [Google::Apis::YoutubeV3::VideoConversionPings]
6523
- attr_accessor :conversion_pings
6524
-
6525
6526
  # Etag of this resource.
6526
6527
  # Corresponds to the JSON property `etag`
6527
6528
  # @return [String]
@@ -6617,7 +6618,6 @@ module Google
6617
6618
  def update!(**args)
6618
6619
  @age_gating = args[:age_gating] unless args[:age_gating].nil?
6619
6620
  @content_details = args[:content_details] unless args[:content_details].nil?
6620
- @conversion_pings = args[:conversion_pings] unless args[:conversion_pings].nil?
6621
6621
  @etag = args[:etag] unless args[:etag].nil?
6622
6622
  @file_details = args[:file_details] unless args[:file_details].nil?
6623
6623
  @id = args[:id] unless args[:id].nil?
@@ -7009,7 +7009,7 @@ module Google
7009
7009
  attr_accessor :caption
7010
7010
 
7011
7011
  # Ratings schemes. The country-specific ratings are mostly for movies and shows.
7012
- # NEXT_ID: 66
7012
+ # NEXT_ID: 67
7013
7013
  # Corresponds to the JSON property `contentRating`
7014
7014
  # @return [Google::Apis::YoutubeV3::ContentRating]
7015
7015
  attr_accessor :content_rating
@@ -7100,58 +7100,6 @@ module Google
7100
7100
  end
7101
7101
  end
7102
7102
 
7103
- #
7104
- class VideoConversionPing
7105
- include Google::Apis::Core::Hashable
7106
-
7107
- # Defines the context of the ping.
7108
- # Corresponds to the JSON property `context`
7109
- # @return [String]
7110
- attr_accessor :context
7111
-
7112
- # The url (without the schema) that the app shall send the ping to. It's at
7113
- # caller's descretion to decide which schema to use (http vs https) Example of a
7114
- # returned url: //googleads.g.doubleclick.net/pagead/ viewthroughconversion/
7115
- # 962985656/?data=path%3DtHe_path%3Btype%3D like%3Butuid%
7116
- # 3DGISQtTNGYqaYl4sKxoVvKA%3Bytvid%3DUrIaJUvIQDg&labe=default The caller must
7117
- # append biscotti authentication (ms param in case of mobile, for example) to
7118
- # this ping.
7119
- # Corresponds to the JSON property `conversionUrl`
7120
- # @return [String]
7121
- attr_accessor :conversion_url
7122
-
7123
- def initialize(**args)
7124
- update!(**args)
7125
- end
7126
-
7127
- # Update properties of this object
7128
- def update!(**args)
7129
- @context = args[:context] unless args[:context].nil?
7130
- @conversion_url = args[:conversion_url] unless args[:conversion_url].nil?
7131
- end
7132
- end
7133
-
7134
- #
7135
- class VideoConversionPings
7136
- include Google::Apis::Core::Hashable
7137
-
7138
- # Pings that the app shall fire for a video (authenticated by biscotti cookie).
7139
- # Each ping has a context, in which the app must fire the ping, and a url
7140
- # identifying the ping.
7141
- # Corresponds to the JSON property `pings`
7142
- # @return [Array<Google::Apis::YoutubeV3::VideoConversionPing>]
7143
- attr_accessor :pings
7144
-
7145
- def initialize(**args)
7146
- update!(**args)
7147
- end
7148
-
7149
- # Update properties of this object
7150
- def update!(**args)
7151
- @pings = args[:pings] unless args[:pings].nil?
7152
- end
7153
- end
7154
-
7155
7103
  # Describes original video file properties, including technical details about
7156
7104
  # audio and video streams, but also metadata information like content length,
7157
7105
  # digitization time, or geotagging information.
@@ -606,14 +606,6 @@ module Google
606
606
  class Representation < Google::Apis::Core::JsonRepresentation; end
607
607
  end
608
608
 
609
- class VideoConversionPing
610
- class Representation < Google::Apis::Core::JsonRepresentation; end
611
- end
612
-
613
- class VideoConversionPings
614
- class Representation < Google::Apis::Core::JsonRepresentation; end
615
- end
616
-
617
609
  class VideoFileDetails
618
610
  class Representation < Google::Apis::Core::JsonRepresentation; end
619
611
  end
@@ -1348,6 +1340,7 @@ module Google
1348
1340
  property :czfilm_rating, as: 'czfilmRating'
1349
1341
  property :djctq_rating, as: 'djctqRating'
1350
1342
  collection :djctq_rating_reasons, as: 'djctqRatingReasons'
1343
+ property :ecbmct_rating, as: 'ecbmctRating'
1351
1344
  property :eefilm_rating, as: 'eefilmRating'
1352
1345
  property :egfilm_rating, as: 'egfilmRating'
1353
1346
  property :eirin_rating, as: 'eirinRating'
@@ -2415,8 +2408,6 @@ module Google
2415
2408
 
2416
2409
  property :content_details, as: 'contentDetails', class: Google::Apis::YoutubeV3::VideoContentDetails, decorator: Google::Apis::YoutubeV3::VideoContentDetails::Representation
2417
2410
 
2418
- property :conversion_pings, as: 'conversionPings', class: Google::Apis::YoutubeV3::VideoConversionPings, decorator: Google::Apis::YoutubeV3::VideoConversionPings::Representation
2419
-
2420
2411
  property :etag, as: 'etag'
2421
2412
  property :file_details, as: 'fileDetails', class: Google::Apis::YoutubeV3::VideoFileDetails, decorator: Google::Apis::YoutubeV3::VideoFileDetails::Representation
2422
2413
 
@@ -2572,22 +2563,6 @@ module Google
2572
2563
  end
2573
2564
  end
2574
2565
 
2575
- class VideoConversionPing
2576
- # @private
2577
- class Representation < Google::Apis::Core::JsonRepresentation
2578
- property :context, as: 'context'
2579
- property :conversion_url, as: 'conversionUrl'
2580
- end
2581
- end
2582
-
2583
- class VideoConversionPings
2584
- # @private
2585
- class Representation < Google::Apis::Core::JsonRepresentation
2586
- collection :pings, as: 'pings', class: Google::Apis::YoutubeV3::VideoConversionPing, decorator: Google::Apis::YoutubeV3::VideoConversionPing::Representation
2587
-
2588
- end
2589
- end
2590
-
2591
2566
  class VideoFileDetails
2592
2567
  # @private
2593
2568
  class Representation < Google::Apis::Core::JsonRepresentation
@@ -18,6 +18,7 @@ require 'google/apis/core/api_command'
18
18
  require 'google/apis/errors'
19
19
  require 'addressable/uri'
20
20
  require 'mime-types'
21
+ require "tempfile"
21
22
 
22
23
  module Google
23
24
  module Apis
@@ -15,7 +15,7 @@
15
15
  module Google
16
16
  module Apis
17
17
  # Client library version
18
- VERSION = '0.9'
18
+ VERSION = '0.9.1'
19
19
 
20
20
  # Current operating system
21
21
  # @private
@@ -1,6 +1,6 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
- gem 'google-api-client', '~> 0.9.pre4'
3
+ gem 'google-api-client', '~> 0.9'
4
4
  gem 'thor', '~> 0.19'
5
5
  gem 'os', '~> 0.9'
6
6
  gem 'rmail', '~> 1.1'
File without changes
File without changes
@@ -0,0 +1,7 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gem 'google-api-client', '~> 0.9'
4
+ gem 'google-id-token', '~> 1.3'
5
+ gem 'sinatra', '~> 1.4'
6
+ gem 'redis', '~> 3.2'
7
+ gem 'dotenv'
@@ -0,0 +1,44 @@
1
+ # API Samples
2
+
3
+ This directory contains a simple Sinatra web app illustrating how to use the client
4
+ in a server-side web environment.
5
+
6
+ It illustrates a few key concepts:
7
+
8
+ * Using [Google Sign-in](https://developers.google.com/identity) for authentication.
9
+ * Using the [googleauth gem](https://github.com/google/google-auth-library-ruby) to
10
+ request incremental authorization as more permissions are needed.
11
+
12
+ # Setup
13
+
14
+ * Create a project at https://console.developers.google.com
15
+ * Go to the `API Manager` and enable the `Drive` and `Calendar` APIs
16
+ * Go to `Credentials` and create a new OAuth Client ID of type 'Web application'
17
+ * Use `http://localhost:4567/oauth2callback` as the redirect URL
18
+ * Use `http://localhost:4567` as the JavaScript origin
19
+
20
+ Additional details on how to enable APIs and create credentials can be
21
+ found in the help guide in the console.
22
+
23
+ ## Example Environment Settings
24
+
25
+ For convenience, application credentials can be read from the shell environment
26
+ or placed in a .env file.
27
+
28
+ After setup, your .env file might look something like:
29
+
30
+ ```
31
+ GOOGLE_CLIENT_ID=479164972499-i7j6av7bp2s4on5ltb7pjXXXXXXXXXX.apps.googleusercontent.com
32
+ GOOGLE_CLIENT_SECRET=JBotCTG5biFWGzXXXXXXXXXX
33
+ ```
34
+
35
+ # Running the samples
36
+
37
+ To start the server, run
38
+
39
+ ```
40
+ ruby app.rb
41
+ ```
42
+
43
+ Open `http://localhost:4567/` in your browser to explore the sample.
44
+
@@ -0,0 +1,120 @@
1
+ # Copyright 2015 Google Inc.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ require 'sinatra'
16
+ require 'googleauth'
17
+ require 'googleauth/stores/redis_token_store'
18
+ require 'google/apis/drive_v3'
19
+ require 'google/apis/calendar_v3'
20
+ require 'google-id-token'
21
+ require 'dotenv'
22
+
23
+ LOGIN_URL = '/'
24
+
25
+ configure do
26
+ Dotenv.load
27
+
28
+ Google::Apis::ClientOptions.default.application_name = 'Ruby client samples'
29
+ Google::Apis::ClientOptions.default.application_version = '0.9'
30
+ Google::Apis::RequestOptions.default.retries = 3
31
+
32
+ enable :sessions
33
+ set :show_exceptions, false
34
+ set :client_id, Google::Auth::ClientId.new(ENV['GOOGLE_CLIENT_ID'],
35
+ ENV['GOOGLE_CLIENT_SECRET'])
36
+ set :token_store, Google::Auth::Stores::RedisTokenStore.new(redis: Redis.new)
37
+ end
38
+
39
+ helpers do
40
+ # Returns credentials authorized for the requested scopes. If no credentials are available,
41
+ # redirects the user to authorize access.
42
+ def credentials_for(scope)
43
+ authorizer = Google::Auth::WebUserAuthorizer.new(settings.client_id, scope, settings.token_store)
44
+ user_id = session[:user_id]
45
+ redirect LOGIN_URL if user_id.nil?
46
+ credentials = authorizer.get_credentials(user_id, request)
47
+ if credentials.nil?
48
+ redirect authorizer.get_authorization_url(login_hint: user_id, request: request)
49
+ end
50
+ credentials
51
+ end
52
+
53
+ def resize(url, width)
54
+ url.sub(/s220/, sprintf('s%d', width))
55
+ end
56
+ end
57
+
58
+ # Home page
59
+ get('/') do
60
+ @client_id = settings.client_id.id
61
+ erb :home
62
+ end
63
+
64
+ # Log in the user by validating the identity token generated by the Google Sign-In button.
65
+ # This checks that the token is signed by Google, current, and is intended for this application.
66
+ #
67
+ post('/signin') do
68
+ audience = settings.client_id.id
69
+ # Important: The google-id-token gem is not production ready. If using, consider fetching and
70
+ # supplying the valid keys separately rather than using the built-in certificate fetcher.
71
+ validator = GoogleIDToken::Validator.new
72
+ claim = validator.check(params['id_token'], audience, audience)
73
+ if claim
74
+ session[:user_id] = claim['sub']
75
+ session[:user_email] = claim['email']
76
+ 200
77
+ else
78
+ logger.info('No valid identity token present')
79
+ 401
80
+ end
81
+ end
82
+
83
+ # Retrieve the 10 most recently modified files in Google Drive
84
+ get('/drive') do
85
+ drive = Google::Apis::DriveV3::DriveService.new
86
+ drive.authorization = credentials_for(Google::Apis::DriveV3::AUTH_DRIVE)
87
+ @result = drive.list_files(page_size: 10,
88
+ fields: 'files(name,modified_time,web_view_link),next_page_token')
89
+ erb :drive
90
+ end
91
+
92
+ # Retrieve the next 10 upcoming events from Google Calendar
93
+ get('/calendar') do
94
+ calendar = Google::Apis::CalendarV3::CalendarService.new
95
+ calendar.authorization = credentials_for(Google::Apis::CalendarV3::AUTH_CALENDAR)
96
+ calendar_id = 'primary'
97
+ @result = calendar.list_events(calendar_id,
98
+ max_results: 10,
99
+ single_events: true,
100
+ order_by: 'startTime',
101
+ time_min: Time.now.iso8601)
102
+ erb :calendar
103
+ end
104
+
105
+
106
+ # Callback for authorization requests. This saves the autorization code and
107
+ # redirects back to the URL that originally requested authorization. The code is
108
+ # redeemed on the next request.
109
+ #
110
+ # Important: While the deferred approach is generally easier, it doesn't play well
111
+ # with developer mode and sinatra's default cookie-based session implementation. Changes to the
112
+ # session state are lost if the page doesn't render due to error, which can lead to further
113
+ # errors indicating the code has already been redeemed.
114
+ #
115
+ # Disabling show_exceptions or using a different session provider (E.g. Rack::Session::Memcache)
116
+ # avoids the issue.
117
+ get('/oauth2callback') do
118
+ target_url = Google::Auth::WebUserAuthorizer.handle_auth_callback_deferred(request)
119
+ redirect target_url
120
+ end
@@ -0,0 +1,34 @@
1
+ <%#
2
+ # Copyright 2016 Google Inc.
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+ %>
16
+ <section>
17
+ <h5>Next 10 events</h5>
18
+ <table class="">
19
+ <thead>
20
+ <tr>
21
+ <th class="">Time</th>
22
+ <th class="">Summary</th>
23
+ </tr>
24
+ </thead>
25
+ <tbody>
26
+ <% @result.items.each do |event| %>
27
+ <tr>
28
+ <td class=""><%= event.start.date_time || event.start.date %></td>
29
+ <td class=""><%= event.summary %></td>
30
+ </tr>
31
+ <% end %>
32
+ </tbody>
33
+ </table>
34
+ </section>