From d2e51b4e7d4cb5a18cb08b2aed9c0d8ffff14b22 Mon Sep 17 00:00:00 2001 From: Steve Bazyl Date: Fri, 11 Mar 2016 14:43:51 -0800 Subject: [PATCH] Update changelog, readme, & version for next 0.9.4 release --- CHANGELOG.md | 5 +++++ README.md | 29 +++++++++++++++++++++++++++-- lib/google/apis/version.rb | 2 +- 3 files changed, 33 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 41f7a87a4..1d9872197 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +# 0.9.4 +* Add `service.fetch_all` helper for automatically retrieving paged results +* Add IAM v1 & Cloud Resource Manager v1 APIs +* Update generated APIs + # 0.9.3 * Drop ActiveSupport an MultiJson as dependencies. Active support is still included in the Gemfile and is needed to run the code generator. diff --git a/README.md b/README.md index 4d3a1ec1b..d0679432a 100644 --- a/README.md +++ b/README.md @@ -38,7 +38,7 @@ require 'google/apis/drive_v2' Drive = Google::Apis::DriveV2 # Alias the module drive = Drive::DriveService.new -drive.authorization = authorization # See Googleauth or Signet libraries +drive.authorization = ... # See Googleauth or Signet libraries # Search for files in Drive (first page only) files = drive.list_files(q: "title contains 'finances'") @@ -107,6 +107,32 @@ end This calling style is required when making batch requests as responses are not available until the entire batch is complete. +### Paging + +To fetch multiple pages of data, use the `fetch_all` method to wrap the paged query. This returns an +`Enumerable` that automatically fetches additional pages as needed. + +```ruby +# List all calendar events +now = Time.now.iso8601 +items = calendar.fetch_all do |token| + calendar.list_events('primary', + single_events: true, + order_by: 'startTime', + time_min: now, + page_token: token) +end +items.each { |event| puts event.summary } +``` + +For APIs that use a field other than `items` to contain the results, an alternate field name can be supplied. + +```ruby +# List all files in Drive +items = drive.fetch_all(items: :files) { |token| drive.list_files(page_token: token) } +items.each { |file| puts file.name } +``` + ### Batches Multiple requests can be batched together into a single HTTP request to reduce overhead. Batched calls are executed @@ -240,7 +266,6 @@ A URL can also be specified: ## TODO * ETag support (if-not-modified) -* Auto-paging results (maybe) * Caching * Model validations diff --git a/lib/google/apis/version.rb b/lib/google/apis/version.rb index 3d77214d4..8fbc6a9cd 100644 --- a/lib/google/apis/version.rb +++ b/lib/google/apis/version.rb @@ -15,7 +15,7 @@ module Google module Apis # Client library version - VERSION = '0.9.3' + VERSION = '0.9.4' # Current operating system # @private