google-api-client 0.9.3 → 0.9.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (121) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +5 -0
  3. data/README.md +28 -3
  4. data/api_names.yaml +1 -0
  5. data/api_names_out.yaml +418 -0
  6. data/generated/google/apis/adexchangebuyer_v1_4.rb +1 -1
  7. data/generated/google/apis/adsense_v1_4.rb +2 -3
  8. data/generated/google/apis/adsense_v1_4/service.rb +1 -2
  9. data/generated/google/apis/adsensehost_v4_1.rb +3 -3
  10. data/generated/google/apis/adsensehost_v4_1/service.rb +2 -2
  11. data/generated/google/apis/analytics_v3.rb +2 -2
  12. data/generated/google/apis/analytics_v3/classes.rb +42 -0
  13. data/generated/google/apis/analytics_v3/representations.rb +6 -0
  14. data/generated/google/apis/analytics_v3/service.rb +3 -3
  15. data/generated/google/apis/androidenterprise_v1.rb +1 -1
  16. data/generated/google/apis/appsactivity_v1.rb +1 -1
  17. data/generated/google/apis/appsactivity_v1/classes.rb +16 -0
  18. data/generated/google/apis/appsactivity_v1/representations.rb +2 -0
  19. data/generated/google/apis/appstate_v1.rb +1 -1
  20. data/generated/google/apis/bigquery_v2.rb +1 -1
  21. data/generated/google/apis/bigquery_v2/classes.rb +200 -13
  22. data/generated/google/apis/bigquery_v2/representations.rb +54 -0
  23. data/generated/google/apis/books_v1.rb +1 -1
  24. data/generated/google/apis/books_v1/classes.rb +6 -0
  25. data/generated/google/apis/books_v1/representations.rb +1 -0
  26. data/generated/google/apis/books_v1/service.rb +4 -1
  27. data/generated/google/apis/calendar_v3.rb +1 -1
  28. data/generated/google/apis/cloudbuild_v1.rb +2 -3
  29. data/generated/google/apis/cloudbuild_v1/classes.rb +7 -0
  30. data/generated/google/apis/cloudbuild_v1/representations.rb +1 -0
  31. data/generated/google/apis/cloudbuild_v1/service.rb +1 -2
  32. data/generated/google/apis/clouddebugger_v2.rb +2 -2
  33. data/generated/google/apis/clouddebugger_v2/classes.rb +8 -1
  34. data/generated/google/apis/clouddebugger_v2/representations.rb +1 -0
  35. data/generated/google/apis/clouddebugger_v2/service.rb +26 -6
  36. data/generated/google/apis/cloudlatencytest_v2.rb +2 -2
  37. data/generated/google/apis/cloudlatencytest_v2/service.rb +1 -1
  38. data/generated/google/apis/cloudmonitoring_v2beta2.rb +2 -2
  39. data/generated/google/apis/cloudmonitoring_v2beta2/service.rb +1 -1
  40. data/generated/google/apis/cloudresourcemanager_v1.rb +38 -0
  41. data/generated/google/apis/cloudresourcemanager_v1/classes.rb +355 -0
  42. data/generated/google/apis/cloudresourcemanager_v1/representations.rb +181 -0
  43. data/generated/google/apis/cloudresourcemanager_v1/service.rb +373 -0
  44. data/generated/google/apis/cloudresourcemanager_v1beta1.rb +1 -1
  45. data/generated/google/apis/clouduseraccounts_beta.rb +3 -2
  46. data/generated/google/apis/clouduseraccounts_beta/classes.rb +52 -30
  47. data/generated/google/apis/clouduseraccounts_beta/representations.rb +1 -0
  48. data/generated/google/apis/clouduseraccounts_beta/service.rb +110 -57
  49. data/generated/google/apis/compute_beta.rb +1 -1
  50. data/generated/google/apis/compute_beta/classes.rb +324 -101
  51. data/generated/google/apis/compute_beta/representations.rb +78 -0
  52. data/generated/google/apis/compute_beta/service.rb +1599 -208
  53. data/generated/google/apis/compute_v1.rb +1 -1
  54. data/generated/google/apis/compute_v1/classes.rb +96 -79
  55. data/generated/google/apis/compute_v1/service.rb +199 -169
  56. data/generated/google/apis/content_v2.rb +2 -2
  57. data/generated/google/apis/content_v2/classes.rb +6 -0
  58. data/generated/google/apis/content_v2/representations.rb +1 -0
  59. data/generated/google/apis/content_v2/service.rb +1 -1
  60. data/generated/google/apis/deploymentmanager_v2.rb +1 -1
  61. data/generated/google/apis/deploymentmanager_v2/classes.rb +6 -6
  62. data/generated/google/apis/deploymentmanager_v2/service.rb +10 -10
  63. data/generated/google/apis/doubleclickbidmanager_v1.rb +1 -1
  64. data/generated/google/apis/doubleclicksearch_v2.rb +2 -2
  65. data/generated/google/apis/doubleclicksearch_v2/service.rb +1 -1
  66. data/generated/google/apis/drive_v2.rb +1 -1
  67. data/generated/google/apis/drive_v3.rb +1 -1
  68. data/generated/google/apis/games_configuration_v1configuration.rb +1 -1
  69. data/generated/google/apis/games_management_v1management.rb +1 -1
  70. data/generated/google/apis/games_v1.rb +1 -1
  71. data/generated/google/apis/games_v1/classes.rb +9 -2
  72. data/generated/google/apis/games_v1/representations.rb +1 -0
  73. data/generated/google/apis/genomics_v1.rb +4 -5
  74. data/generated/google/apis/genomics_v1/classes.rb +51 -0
  75. data/generated/google/apis/genomics_v1/representations.rb +17 -0
  76. data/generated/google/apis/genomics_v1/service.rb +44 -8
  77. data/generated/google/apis/gmail_v1.rb +2 -2
  78. data/generated/google/apis/gmail_v1/classes.rb +19 -0
  79. data/generated/google/apis/gmail_v1/representations.rb +13 -0
  80. data/generated/google/apis/gmail_v1/service.rb +43 -2
  81. data/generated/google/apis/iam_v1.rb +36 -0
  82. data/generated/google/apis/iam_v1/classes.rb +665 -0
  83. data/generated/google/apis/iam_v1/representations.rb +325 -0
  84. data/generated/google/apis/iam_v1/service.rb +520 -0
  85. data/generated/google/apis/identitytoolkit_v3.rb +1 -1
  86. data/generated/google/apis/identitytoolkit_v3/classes.rb +306 -0
  87. data/generated/google/apis/identitytoolkit_v3/representations.rb +85 -0
  88. data/generated/google/apis/identitytoolkit_v3/service.rb +42 -1
  89. data/generated/google/apis/pagespeedonline_v2.rb +2 -2
  90. data/generated/google/apis/pagespeedonline_v2/service.rb +1 -1
  91. data/generated/google/apis/plus_domains_v1.rb +1 -1
  92. data/generated/google/apis/plus_v1.rb +1 -1
  93. data/generated/google/apis/prediction_v1_6.rb +1 -1
  94. data/generated/google/apis/prediction_v1_6/classes.rb +1 -1
  95. data/generated/google/apis/qpx_express_v1.rb +2 -2
  96. data/generated/google/apis/qpx_express_v1/service.rb +1 -1
  97. data/generated/google/apis/replicapoolupdater_v1beta1.rb +2 -3
  98. data/generated/google/apis/replicapoolupdater_v1beta1/service.rb +1 -2
  99. data/generated/google/apis/reseller_v1.rb +2 -2
  100. data/generated/google/apis/reseller_v1/service.rb +1 -1
  101. data/generated/google/apis/site_verification_v1.rb +2 -2
  102. data/generated/google/apis/site_verification_v1/service.rb +1 -1
  103. data/generated/google/apis/storage_v1.rb +2 -2
  104. data/generated/google/apis/storage_v1/service.rb +1 -1
  105. data/generated/google/apis/tagmanager_v1.rb +2 -2
  106. data/generated/google/apis/tagmanager_v1/service.rb +1 -1
  107. data/generated/google/apis/vision_v1.rb +1 -1
  108. data/generated/google/apis/vision_v1/classes.rb +2 -2
  109. data/generated/google/apis/youtube_analytics_v1.rb +2 -2
  110. data/generated/google/apis/youtube_analytics_v1/service.rb +1 -1
  111. data/generated/google/apis/youtube_v3.rb +1 -1
  112. data/generated/google/apis/youtube_v3/classes.rb +8 -0
  113. data/generated/google/apis/youtube_v3/representations.rb +1 -0
  114. data/generated/google/apis/youtubereporting_v1.rb +3 -3
  115. data/generated/google/apis/youtubereporting_v1/classes.rb +1 -2
  116. data/generated/google/apis/youtubereporting_v1/service.rb +4 -4
  117. data/lib/google/apis/core/base_service.rb +84 -6
  118. data/lib/google/apis/version.rb +1 -1
  119. data/script/generate +2 -0
  120. data/spec/google/apis/core/service_spec.rb +66 -0
  121. metadata +10 -2
@@ -22,7 +22,7 @@ module Google
22
22
  module SiteVerificationV1
23
23
  # Google Site Verification API
24
24
  #
25
- # Lets you programatically verify ownership of websites or domains with Google.
25
+ # Verifies ownership of websites or domains with Google.
26
26
  #
27
27
  # @example
28
28
  # require 'google/apis/site_verification_v1'
@@ -20,12 +20,12 @@ module Google
20
20
  module Apis
21
21
  # Cloud Storage JSON API
22
22
  #
23
- # Lets you store and retrieve potentially-large, immutable data objects.
23
+ # Stores and retrieves potentially large, immutable data objects.
24
24
  #
25
25
  # @see https://developers.google.com/storage/docs/json_api/
26
26
  module StorageV1
27
27
  VERSION = 'V1'
28
- REVISION = '20160210'
28
+ REVISION = '20160304'
29
29
 
30
30
  # View and manage your data across Google Cloud Platform services
31
31
  AUTH_CLOUD_PLATFORM = 'https://www.googleapis.com/auth/cloud-platform'
@@ -22,7 +22,7 @@ module Google
22
22
  module StorageV1
23
23
  # Cloud Storage JSON API
24
24
  #
25
- # Lets you store and retrieve potentially-large, immutable data objects.
25
+ # Stores and retrieves potentially large, immutable data objects.
26
26
  #
27
27
  # @example
28
28
  # require 'google/apis/storage_v1'
@@ -20,12 +20,12 @@ module Google
20
20
  module Apis
21
21
  # Tag Manager API
22
22
  #
23
- # API for accessing Tag Manager accounts and containers.
23
+ # Accesses Tag Manager accounts and containers.
24
24
  #
25
25
  # @see https://developers.google.com/tag-manager/api/v1/
26
26
  module TagmanagerV1
27
27
  VERSION = 'V1'
28
- REVISION = '20160209'
28
+ REVISION = '20160310'
29
29
 
30
30
  # Delete your Google Tag Manager containers
31
31
  AUTH_TAGMANAGER_DELETE_CONTAINERS = 'https://www.googleapis.com/auth/tagmanager.delete.containers'
@@ -22,7 +22,7 @@ module Google
22
22
  module TagmanagerV1
23
23
  # Tag Manager API
24
24
  #
25
- # API for accessing Tag Manager accounts and containers.
25
+ # Accesses Tag Manager accounts and containers.
26
26
  #
27
27
  # @example
28
28
  # require 'google/apis/tagmanager_v1'
@@ -28,7 +28,7 @@ module Google
28
28
  # @see https://cloud.google.com/vision/
29
29
  module VisionV1
30
30
  VERSION = 'V1'
31
- REVISION = '20160223'
31
+ REVISION = '20160308'
32
32
 
33
33
  # View and manage your data across Google Cloud Platform services
34
34
  AUTH_CLOUD_PLATFORM = 'https://www.googleapis.com/auth/cloud-platform'
@@ -757,7 +757,7 @@ module Google
757
757
  # @return [Google::Apis::VisionV1::BoundingPoly]
758
758
  attr_accessor :bounding_poly
759
759
 
760
- # The location information for the recognized entity. Multiple
760
+ # The location information for the detected entity. Multiple
761
761
  # <code>LocationInfo</code> elements can be present since one location may
762
762
  # indicate the location of the scene in the query image, and another the
763
763
  # location of the place where the query image was taken. Location information
@@ -766,7 +766,7 @@ module Google
766
766
  # @return [Array<Google::Apis::VisionV1::LocationInfo>]
767
767
  attr_accessor :locations
768
768
 
769
- # The accuracy of the entity recognition in an image.
769
+ # The accuracy of the entity detection in an image.
770
770
  # For example, for an image containing 'Eiffel Tower,' this field represents
771
771
  # the confidence that there is a tower in the query image. Range [0, 1].
772
772
  # Corresponds to the JSON property `confidence`
@@ -20,12 +20,12 @@ module Google
20
20
  module Apis
21
21
  # YouTube Analytics API
22
22
  #
23
- # Retrieve your YouTube Analytics reports.
23
+ # Retrieves your YouTube Analytics reports.
24
24
  #
25
25
  # @see http://developers.google.com/youtube/analytics/
26
26
  module YoutubeAnalyticsV1
27
27
  VERSION = 'V1'
28
- REVISION = '20160204'
28
+ REVISION = '20160301'
29
29
 
30
30
  # Manage your YouTube account
31
31
  AUTH_YOUTUBE = 'https://www.googleapis.com/auth/youtube'
@@ -22,7 +22,7 @@ module Google
22
22
  module YoutubeAnalyticsV1
23
23
  # YouTube Analytics API
24
24
  #
25
- # Retrieve your YouTube Analytics reports.
25
+ # Retrieves your YouTube Analytics reports.
26
26
  #
27
27
  # @example
28
28
  # require 'google/apis/youtube_analytics_v1'
@@ -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 = '20160201'
28
+ REVISION = '20160222'
29
29
 
30
30
  # Manage your YouTube account
31
31
  AUTH_YOUTUBE = 'https://www.googleapis.com/auth/youtube'
@@ -925,6 +925,7 @@ module Google
925
925
  attr_accessor :localizations
926
926
 
927
927
  # Basic details about a channel, including title, description and thumbnails.
928
+ # Next available id: 15.
928
929
  # Corresponds to the JSON property `snippet`
929
930
  # @return [Google::Apis::YoutubeV3::ChannelSnippet]
930
931
  attr_accessor :snippet
@@ -1711,6 +1712,7 @@ module Google
1711
1712
  end
1712
1713
 
1713
1714
  # Basic details about a channel, including title, description and thumbnails.
1715
+ # Next available id: 15.
1714
1716
  class ChannelSnippet
1715
1717
  include Google::Apis::Core::Hashable
1716
1718
 
@@ -1719,6 +1721,11 @@ module Google
1719
1721
  # @return [String]
1720
1722
  attr_accessor :country
1721
1723
 
1724
+ # The custom url of the channel.
1725
+ # Corresponds to the JSON property `customUrl`
1726
+ # @return [String]
1727
+ attr_accessor :custom_url
1728
+
1722
1729
  # The language of the channel's default title and description.
1723
1730
  # Corresponds to the JSON property `defaultLanguage`
1724
1731
  # @return [String]
@@ -1757,6 +1764,7 @@ module Google
1757
1764
  # Update properties of this object
1758
1765
  def update!(**args)
1759
1766
  @country = args[:country] if args.key?(:country)
1767
+ @custom_url = args[:custom_url] if args.key?(:custom_url)
1760
1768
  @default_language = args[:default_language] if args.key?(:default_language)
1761
1769
  @description = args[:description] if args.key?(:description)
1762
1770
  @localized = args[:localized] if args.key?(:localized)
@@ -1494,6 +1494,7 @@ module Google
1494
1494
  # @private
1495
1495
  class Representation < Google::Apis::Core::JsonRepresentation
1496
1496
  property :country, as: 'country'
1497
+ property :custom_url, as: 'customUrl'
1497
1498
  property :default_language, as: 'defaultLanguage'
1498
1499
  property :description, as: 'description'
1499
1500
  property :localized, as: 'localized', class: Google::Apis::YoutubeV3::ChannelLocalization, decorator: Google::Apis::YoutubeV3::ChannelLocalization::Representation
@@ -20,13 +20,13 @@ module Google
20
20
  module Apis
21
21
  # YouTube Reporting API
22
22
  #
23
- # An API to schedule reporting jobs and download the resulting bulk data reports
24
- # about YouTube channels, videos etc. in the form of CSV files.
23
+ # Schedules reporting jobs and downloads the resulting bulk data reports about
24
+ # YouTube channels, videos, etc. in the form of CSV files.
25
25
  #
26
26
  # @see https://developers.google.com/youtube/reporting/v1/reports/
27
27
  module YoutubereportingV1
28
28
  VERSION = 'V1'
29
- REVISION = '20151026'
29
+ REVISION = '20160301'
30
30
 
31
31
  # View monetary and non-monetary YouTube Analytics reports for your YouTube content
32
32
  AUTH_YT_ANALYTICS_MONETARY_READONLY = 'https://www.googleapis.com/auth/yt-analytics-monetary.readonly'
@@ -107,8 +107,7 @@ module Google
107
107
  # @return [String]
108
108
  attr_accessor :report_type_id
109
109
 
110
- # The name of the job (max. 100 characters). TODO(lanthaler) Clarify what this
111
- # will actually be used for
110
+ # The name of the job (max. 100 characters).
112
111
  # Corresponds to the JSON property `name`
113
112
  # @return [String]
114
113
  attr_accessor :name
@@ -22,8 +22,8 @@ module Google
22
22
  module YoutubereportingV1
23
23
  # YouTube Reporting API
24
24
  #
25
- # An API to schedule reporting jobs and download the resulting bulk data reports
26
- # about YouTube channels, videos etc. in the form of CSV files.
25
+ # Schedules reporting jobs and downloads the resulting bulk data reports about
26
+ # YouTube channels, videos, etc. in the form of CSV files.
27
27
  #
28
28
  # @example
29
29
  # require 'google/apis/youtubereporting_v1'
@@ -50,8 +50,8 @@ module Google
50
50
  # Method for media download. Download is supported on the URI `/v1/media/`+name`?
51
51
  # alt=media`.
52
52
  # @param [String] resource_name
53
- # Name of the media that is being downloaded. See [][ByteStream.ReadRequest.
54
- # resource_name].
53
+ # Name of the media that is being downloaded. See ByteStream.ReadRequest.
54
+ # resource_name.
55
55
  # @param [String] fields
56
56
  # Selector specifying which fields to include in a partial response.
57
57
  # @param [String] quota_user
@@ -28,6 +28,53 @@ require 'hurley/addressable'
28
28
  module Google
29
29
  module Apis
30
30
  module Core
31
+ # Helper class for enumerating over a result set requiring multiple fetches
32
+ class PagedResults
33
+ include Enumerable
34
+
35
+ attr_reader :last_result
36
+
37
+ # @param [BaseService] service
38
+ # Current service instance
39
+ # @param [Fixnum] max
40
+ # Maximum number of items to iterate over. Nil if no limit
41
+ # @param [Boolean] cache
42
+ # True (default) if results should be cached so multiple iterations can be used.
43
+ # @param [Symbol] items
44
+ # Name of the field in the result containing the items. Defaults to :items
45
+ def initialize(service, max: nil, items: :items, cache: true, &block)
46
+ @service = service
47
+ @block = block
48
+ @max = max
49
+ @items_field = items
50
+ if cache
51
+ @result_cache = Hash.new do |h, k|
52
+ h[k] = @block.call(k, @service)
53
+ end
54
+ @fetch_proc = Proc.new { |token| @result_cache[token] }
55
+ else
56
+ @fetch_proc = Proc.new { |token| @block.call(token, @service) }
57
+ end
58
+ end
59
+
60
+ # Iterates over result set, fetching additional pages as needed
61
+ def each
62
+ page_token = nil
63
+ item_count = 0
64
+ loop do
65
+ @last_result = @fetch_proc.call(page_token)
66
+ for item in @last_result.send(@items_field)
67
+ item_count = item_count + 1
68
+ break if @max && item_count > @max
69
+ yield item
70
+ end
71
+ break if @max && item_count >= @max
72
+ break if @last_result.next_page_token.nil? || @last_result.next_page_token == page_token
73
+ page_token = @last_result.next_page_token
74
+ end
75
+ end
76
+ end
77
+
31
78
  # Base service for all APIs. Not to be used directly.
32
79
  #
33
80
  class BaseService
@@ -90,12 +137,12 @@ module Google
90
137
  # request to the server.
91
138
  #
92
139
  # @example
93
- # service.batch do |service|
94
- # service.get_item(id1) do |res, err|
140
+ # service.batch do |s|
141
+ # s.get_item(id1) do |res, err|
95
142
  # # process response for 1st call
96
143
  # end
97
144
  # # ...
98
- # service.get_item(idN) do |res, err|
145
+ # s.get_item(idN) do |res, err|
99
146
  # # process response for Nth call
100
147
  # end
101
148
  # end
@@ -122,12 +169,12 @@ module Google
122
169
  # files, use single requests which use a resumable upload protocol.
123
170
  #
124
171
  # @example
125
- # service.batch do |service|
126
- # service.insert_item(upload_source: 'file1.txt') do |res, err|
172
+ # service.batch do |s|
173
+ # s.insert_item(upload_source: 'file1.txt') do |res, err|
127
174
  # # process response for 1st call
128
175
  # end
129
176
  # # ...
130
- # service.insert_item(upload_source: 'fileN.txt') do |res, err|
177
+ # s.insert_item(upload_source: 'fileN.txt') do |res, err|
131
178
  # # process response for Nth call
132
179
  # end
133
180
  # end
@@ -191,6 +238,37 @@ module Google
191
238
  execute_or_queue_command(command, &block)
192
239
  end
193
240
 
241
+ # Executes a given query with paging, automatically retrieving
242
+ # additional pages as necessary. Requires a block that returns the
243
+ # result set of a page. The current page token is supplied as an argument
244
+ # to the block.
245
+ #
246
+ # Note: The returned enumerable also contains a `last_result` field
247
+ # containing the full result of the last query executed.
248
+ #
249
+ # @param [Fixnum] max
250
+ # Maximum number of items to iterate over. Defaults to nil -- no upper bound.
251
+ # @param [Symbol] items
252
+ # Name of the field in the result containing the items. Defaults to :items
253
+ # @param [Boolean] cache
254
+ # True (default) if results should be cached so multiple iterations can be used.
255
+ # @return [Enumerble]
256
+ # @yield [token, service]
257
+ # Current page token & service instance
258
+ # @yieldparam [String] token
259
+ # Current page token to be used in the query
260
+ # @yieldparm [service]
261
+ # Current service instance
262
+ # @since 0.9.4
263
+ #
264
+ # @example Retrieve all files,
265
+ # file_list = service.fetch_all { |token, s| s.list_files(page_token: token) }
266
+ # file_list.each { |f| ... }
267
+ def fetch_all(max: nil, items: :items, cache: true, &block)
268
+ fail "fetch_all may not be used inside a batch" if batch?
269
+ return PagedResults.new(self, max: max, items: items, cache: cache, &block)
270
+ end
271
+
194
272
  protected
195
273
 
196
274
  # Create a new upload command.
@@ -15,7 +15,7 @@
15
15
  module Google
16
16
  module Apis
17
17
  # Client library version
18
- VERSION = '0.9.3'
18
+ VERSION = '0.9.4'
19
19
 
20
20
  # Current operating system
21
21
  # @private
@@ -30,6 +30,7 @@ APIS=(adexchangebuyer:v1.4 \
30
30
  cloudlatencytest:v2 \
31
31
  cloudmonitoring:v2beta2 \
32
32
  cloudresourcemanager:v1beta1 \
33
+ cloudresourcemanager:v1 \
33
34
  cloudtrace:v1 \
34
35
  clouduseraccounts:beta \
35
36
  compute:v1 \
@@ -58,6 +59,7 @@ APIS=(adexchangebuyer:v1.4 \
58
59
  gmail:v1 \
59
60
  groupsmigration:v1 \
60
61
  groupssettings:v1 \
62
+ iam:v1 \
61
63
  identitytoolkit:v3 \
62
64
  kgsearch:v1 \
63
65
  licensing:v1 \
@@ -17,6 +17,7 @@ require 'google/apis/options'
17
17
  require 'google/apis/core/base_service'
18
18
  require 'google/apis/core/json_representation'
19
19
  require 'hurley/test'
20
+ require 'ostruct'
20
21
 
21
22
  RSpec.describe Google::Apis::Core::BaseService do
22
23
  include TestHelpers
@@ -243,5 +244,70 @@ EOF
243
244
  end
244
245
  end.to raise_error(Google::Apis::ClientError)
245
246
  end
247
+
248
+ context 'with fetch_all' do
249
+ let(:responses) do
250
+ data = {}
251
+ data[nil] = OpenStruct.new(next_page_token: 'p1', items: ['a', 'b', 'c'], alt_items: [1, 2 , 3])
252
+ data['p1'] = OpenStruct.new(next_page_token: 'p2', items: ['d', 'e', 'f'], alt_items: [4, 5, 6])
253
+ data['p2'] = OpenStruct.new(next_page_token: nil, items: ['g', 'h', 'i'], alt_items: [7,8, 9])
254
+ data
255
+ end
256
+
257
+ let(:items) { service.fetch_all { |token| responses[token] } }
258
+
259
+ it 'should fetch pages until next page token is nil' do
260
+ expect(items).to contain_exactly('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i')
261
+ end
262
+
263
+ it 'should stop on repeated page token' do
264
+ responses['p2'].next_page_token = 'p2'
265
+ expect(items).to contain_exactly('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i')
266
+ end
267
+
268
+ it 'should allow selecting another field for items' do
269
+ expect(service.fetch_all(items: :alt_items) { |token| responses[token] } ).to contain_exactly(1, 2, 3, 4, 5, 6, 7, 8, 9)
270
+ end
271
+
272
+ it 'should allow limiting the number of items to fetch' do
273
+ expect(service.fetch_all(max: 5) { |token| responses[token] } ).to contain_exactly('a', 'b', 'c', 'd', 'e')
274
+ end
275
+
276
+ it 'should yield the next token' do
277
+ expect do |b|
278
+ service.fetch_all do |token|
279
+ b.to_proc.call(token)
280
+ responses[token]
281
+ end.count
282
+ end.to yield_successive_args(nil, 'p1', 'p2')
283
+ end
284
+
285
+ it 'should cache results' do
286
+ count = 0
287
+ items = service.fetch_all do |token|
288
+ count = count + 1
289
+ responses[token]
290
+ end
291
+
292
+ items.each{ |i| puts i }
293
+ items.each{ |i| puts i }
294
+
295
+ expect(count).to eq 3
296
+ end
297
+
298
+ it 'should allow disabling caching' do
299
+ count = 0
300
+ items = service.fetch_all(cache: false) do |token|
301
+ count = count + 1
302
+ responses[token]
303
+ end
304
+
305
+ items.each{ |i| puts i }
306
+ items.each{ |i| puts i }
307
+
308
+ expect(count).to eq 6
309
+ end
310
+
311
+ end
246
312
  end
247
313
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: google-api-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.3
4
+ version: 0.9.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Steven Bazyl
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2016-02-26 00:00:00.000000000 Z
14
+ date: 2016-03-11 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: representable
@@ -275,6 +275,10 @@ files:
275
275
  - generated/google/apis/cloudmonitoring_v2beta2/classes.rb
276
276
  - generated/google/apis/cloudmonitoring_v2beta2/representations.rb
277
277
  - generated/google/apis/cloudmonitoring_v2beta2/service.rb
278
+ - generated/google/apis/cloudresourcemanager_v1.rb
279
+ - generated/google/apis/cloudresourcemanager_v1/classes.rb
280
+ - generated/google/apis/cloudresourcemanager_v1/representations.rb
281
+ - generated/google/apis/cloudresourcemanager_v1/service.rb
278
282
  - generated/google/apis/cloudresourcemanager_v1beta1.rb
279
283
  - generated/google/apis/cloudresourcemanager_v1beta1/classes.rb
280
284
  - generated/google/apis/cloudresourcemanager_v1beta1/representations.rb
@@ -407,6 +411,10 @@ files:
407
411
  - generated/google/apis/groupssettings_v1/classes.rb
408
412
  - generated/google/apis/groupssettings_v1/representations.rb
409
413
  - generated/google/apis/groupssettings_v1/service.rb
414
+ - generated/google/apis/iam_v1.rb
415
+ - generated/google/apis/iam_v1/classes.rb
416
+ - generated/google/apis/iam_v1/representations.rb
417
+ - generated/google/apis/iam_v1/service.rb
410
418
  - generated/google/apis/identitytoolkit_v3.rb
411
419
  - generated/google/apis/identitytoolkit_v3/classes.rb
412
420
  - generated/google/apis/identitytoolkit_v3/representations.rb