google-api-client 0.9.pre4 → 0.9.pre5

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 (76) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +1 -1
  3. data/CHANGELOG.md +9 -0
  4. data/README.md +11 -1
  5. data/api_names.yaml +1 -0
  6. data/api_names_out.yaml +163 -98
  7. data/generated/google/apis/admin_datatransfer_v1.rb +1 -1
  8. data/generated/google/apis/analytics_v3.rb +1 -1
  9. data/generated/google/apis/analytics_v3/classes.rb +7 -0
  10. data/generated/google/apis/analytics_v3/representations.rb +1 -0
  11. data/generated/google/apis/analytics_v3/service.rb +42 -0
  12. data/generated/google/apis/appstate_v1.rb +1 -1
  13. data/generated/google/apis/bigquery_v2.rb +1 -1
  14. data/generated/google/apis/bigquery_v2/classes.rb +23 -66
  15. data/generated/google/apis/bigquery_v2/representations.rb +1 -17
  16. data/generated/google/apis/bigquery_v2/service.rb +6 -6
  17. data/generated/google/apis/cloudbilling_v1.rb +1 -1
  18. data/generated/google/apis/cloudmonitoring_v2beta2.rb +1 -1
  19. data/generated/google/apis/deploymentmanager_v2.rb +1 -1
  20. data/generated/google/apis/deploymentmanager_v2/classes.rb +5 -4
  21. data/generated/google/apis/doubleclicksearch_v2.rb +1 -1
  22. data/generated/google/apis/drive_v2.rb +1 -1
  23. data/generated/google/apis/drive_v2/service.rb +4 -3
  24. data/generated/google/apis/drive_v3.rb +1 -1
  25. data/generated/google/apis/games_configuration_v1configuration.rb +1 -1
  26. data/generated/google/apis/games_management_v1management.rb +1 -1
  27. data/generated/google/apis/games_v1.rb +1 -1
  28. data/generated/google/apis/genomics_v1.rb +1 -1
  29. data/generated/google/apis/gmail_v1.rb +1 -1
  30. data/generated/google/apis/gmail_v1/classes.rb +2 -2
  31. data/generated/google/apis/plus_domains_v1.rb +1 -1
  32. data/generated/google/apis/plus_v1.rb +1 -1
  33. data/generated/google/apis/plus_v1/classes.rb +0 -497
  34. data/generated/google/apis/plus_v1/representations.rb +0 -121
  35. data/generated/google/apis/plus_v1/service.rb +0 -101
  36. data/generated/google/apis/replicapoolupdater_v1beta1.rb +1 -1
  37. data/generated/google/apis/replicapoolupdater_v1beta1/classes.rb +4 -4
  38. data/generated/google/apis/webmasters_v3.rb +3 -3
  39. data/generated/google/apis/webmasters_v3/service.rb +2 -2
  40. data/generated/google/apis/youtube_v3.rb +1 -1
  41. data/generated/google/apis/youtube_v3/classes.rb +942 -64
  42. data/generated/google/apis/youtube_v3/representations.rb +307 -0
  43. data/generated/google/apis/youtube_v3/service.rb +443 -1
  44. data/google-api-client.gemspec +1 -0
  45. data/lib/google/apis/core/api_command.rb +2 -2
  46. data/lib/google/apis/core/base_service.rb +2 -0
  47. data/lib/google/apis/core/http_client_adapter.rb +82 -0
  48. data/lib/google/apis/core/http_command.rb +16 -1
  49. data/lib/google/apis/core/json_representation.rb +3 -2
  50. data/lib/google/apis/core/upload.rb +7 -1
  51. data/lib/google/apis/options.rb +4 -2
  52. data/lib/google/apis/version.rb +1 -1
  53. data/samples/Gemfile +7 -0
  54. data/samples/README.md +51 -0
  55. data/samples/google-api-samples +32 -0
  56. data/samples/lib/base_cli.rb +94 -0
  57. data/samples/lib/samples/analytics.rb +62 -0
  58. data/samples/lib/samples/calendar.rb +83 -0
  59. data/samples/lib/samples/drive.rb +82 -0
  60. data/samples/lib/samples/gmail.rb +50 -0
  61. data/samples/lib/samples/pubsub.rb +114 -0
  62. data/samples/lib/samples/translate.rb +44 -0
  63. data/samples/lib/samples/you_tube.rb +44 -0
  64. data/spec/google/apis/core/api_command_spec.rb +39 -0
  65. data/spec/google/apis/core/http_command_spec.rb +9 -0
  66. data/spec/google/apis/core/upload_spec.rb +14 -0
  67. data/spec/google/apis/options_spec.rb +0 -8
  68. data/spec/integration_tests/adsense_spec.rb +1 -0
  69. data/spec/integration_tests/pubsub_spec.rb +3 -3
  70. data/spec/integration_tests/url_shortener_spec.rb +14 -0
  71. data/spec/spec_helper.rb +33 -6
  72. data/{samples/translate/translate.rb → spec/spec_helper/load_path_spec.rb} +15 -6
  73. metadata +30 -6
  74. data/samples/calendar/calendar.rb +0 -43
  75. data/samples/drive/drive.rb +0 -47
  76. data/samples/pubsub/pubsub.rb +0 -51
@@ -272,4 +272,13 @@ RSpec.describe Google::Apis::Core::HttpCommand do
272
272
  command.query['a'] = [1,2,3]
273
273
  command.execute(client)
274
274
  end
275
+
276
+ it 'should send falsey query parameters' do
277
+ stub_request(:get, 'https://www.googleapis.com/zoo/animals?a=0&b=false')
278
+ .to_return(status: [200, ''])
279
+ command = Google::Apis::Core::HttpCommand.new(:get, 'https://www.googleapis.com/zoo/animals')
280
+ command.query['a'] = 0
281
+ command.query['b'] = false
282
+ command.execute(client)
283
+ end
275
284
  end
@@ -129,6 +129,20 @@ RSpec.describe Google::Apis::Core::RawUploadCommand do
129
129
  end
130
130
  end
131
131
 
132
+ context('with Tempfile input') do
133
+ let(:file) do
134
+ temp_file = Tempfile.new("tempfile")
135
+ temp_file.write("Hello world\n")
136
+ temp_file.rewind
137
+ temp_file
138
+ end
139
+ include_examples 'should upload'
140
+
141
+ it 'should not close stream' do
142
+ expect(file.closed?).to be false
143
+ end
144
+ end
145
+
132
146
  context('with file path input') do
133
147
  let(:file) { File.join(FIXTURES_DIR, 'files', 'test.txt') }
134
148
  include_examples 'should upload'
@@ -37,12 +37,4 @@ RSpec.describe Google::Apis::RequestOptions do
37
37
  it 'should allow nil in merge' do
38
38
  expect(options.merge(nil)).to be_an_instance_of(Google::Apis::RequestOptions)
39
39
  end
40
-
41
- it 'should override default options' do
42
- Google::Apis::RequestOptions.default.header = 'Content-Length: 50'
43
- opts = Google::Apis::RequestOptions.new
44
- opts.header = 'Content-Length: 70'
45
- expect(options.merge(opts).header).to eq 'Content-Length: 70'
46
- end
47
-
48
40
  end
@@ -15,6 +15,7 @@ RSpec.describe Google::Apis::AdsenseV1_4, :if => run_integration_tests? do
15
15
  end
16
16
 
17
17
  it 'should download a report with multiple dimensions' do
18
+ pending "Not enabled for test account"
18
19
  report = @adsense.generate_report( Date.today.to_s, Date.today.to_s, dimension: ["DATE", "AD_UNIT_NAME"] )
19
20
 
20
21
  report_header_names = report.headers.map { |h| h.name }
@@ -1,10 +1,10 @@
1
1
  require 'spec_helper'
2
- require 'google/apis/pubsub_v1beta2'
2
+ require 'google/apis/pubsub_v1'
3
3
  require 'googleauth'
4
4
 
5
- Pubsub = Google::Apis::PubsubV1beta2
5
+ Pubsub = Google::Apis::PubsubV1
6
6
 
7
- RSpec.describe Google::Apis::PubsubV1beta2, :if => run_integration_tests? do
7
+ RSpec.describe Google::Apis::PubsubV1, :if => run_integration_tests? do
8
8
 
9
9
  before(:context) do
10
10
  WebMock.allow_net_connect!
@@ -1,3 +1,17 @@
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
+
1
15
  require 'spec_helper'
2
16
  require 'google/apis/urlshortener_v1'
3
17
  require 'googleauth'
data/spec/spec_helper.rb CHANGED
@@ -19,13 +19,8 @@ GENERATED_DIR = File.expand_path(File.join(ROOT_DIR, 'generated'))
19
19
  THIRD_PARTY_DIR = File.expand_path(File.join(ROOT_DIR, 'third_party'))
20
20
  FIXTURES_DIR = File.expand_path(File.join(SPEC_DIR, 'fixtures'))
21
21
 
22
- $LOAD_PATH.unshift(SPEC_DIR)
23
- $LOAD_PATH.unshift(LIB_DIR)
24
- $LOAD_PATH.unshift(GENERATED_DIR)
25
- $LOAD_PATH.unshift(THIRD_PARTY_DIR)
26
22
  $LOAD_PATH.uniq!
27
23
 
28
-
29
24
  if defined?(JRUBY_VERSION)
30
25
  puts 'Skipping coverage on JRuby'
31
26
  else
@@ -87,11 +82,12 @@ end
87
82
  # Enable retries for tests
88
83
  Google::Apis::RequestOptions.default.retries = 5
89
84
 
85
+ # Allow testing different adapters
86
+ Google::Apis::ClientOptions.default.use_net_http = true if ENV['USE_NET_HTTP']
90
87
  # Temporarily patch WebMock to allow chunked responses for Net::HTTP
91
88
  module Net
92
89
  module WebMockHTTPResponse
93
90
  def eval_chunk(chunk)
94
- puts chunk.is_a? Exception
95
91
  chunk if chunk.is_a?(String)
96
92
  chunk.read if chunk.is_a?(IO)
97
93
  chunk.call if chunk.is_a?(Proc)
@@ -121,6 +117,37 @@ module Net
121
117
  end
122
118
  end
123
119
 
120
+ class WebMockHTTPClient
121
+ def eval_chunk(chunk)
122
+ chunk if chunk.is_a?(String)
123
+ chunk.read if chunk.is_a?(IO)
124
+ chunk.call if chunk.is_a?(Proc)
125
+ fail HTTPClient::TimeoutError if chunk == ::Timeout::Error
126
+ fail chunk if chunk.is_a?(Class)
127
+ chunk
128
+ end
129
+
130
+ def build_httpclient_response(webmock_response, stream = false, req_header = nil, &block)
131
+ body = stream ? StringIO.new(webmock_response.body) : webmock_response.body
132
+ response = HTTP::Message.new_response(body, req_header)
133
+ response.header.init_response(webmock_response.status[0])
134
+ response.reason = webmock_response.status[1]
135
+ webmock_response.headers.to_a.each { |name, value| response.header.set(name, value) }
136
+
137
+ raise HTTPClient::TimeoutError if webmock_response.should_timeout
138
+ webmock_response.raise_error_if_any
139
+
140
+ body_parts = Array(webmock_response.body)
141
+ body_parts.each do |chunk|
142
+ chunk = eval_chunk(chunk)
143
+ block.call(response, chunk) if block
144
+ end
145
+
146
+ response
147
+ end
148
+ end
149
+
150
+
124
151
  def run_integration_tests?
125
152
  ENV['GOOGLE_APPLICATION_CREDENTIALS'] && ENV['GOOGLE_PROJECT_ID']
126
153
  end
@@ -12,13 +12,22 @@
12
12
  # See the License for the specific language governing permissions and
13
13
  # limitations under the License.
14
14
 
15
+ require 'spec_helper'
15
16
 
16
- require 'google/apis/translate_v2'
17
+ RSpec.describe $LOAD_PATH do
18
+ it('should contain SPEC_DIR') do
19
+ expect($LOAD_PATH).to include(SPEC_DIR)
20
+ end
17
21
 
18
- Translate = Google::Apis::TranslateV2
22
+ it('should contain LIB_DIR') do
23
+ expect($LOAD_PATH).to include(LIB_DIR)
24
+ end
19
25
 
20
- translate = Translate::TranslateService.new
21
- translate.key = ARGV[0] || 'YOUR_API_KEY'
26
+ it('should contain GENERATED_DIR') do
27
+ expect($LOAD_PATH).to include(GENERATED_DIR)
28
+ end
22
29
 
23
- result = translate.list_translations(source: 'en', target: 'es', q: 'Hello world!')
24
- puts result.translations.first.translated_text
30
+ it('should contain THIRD_PARTY_DIR') do
31
+ expect($LOAD_PATH).to include(THIRD_PARTY_DIR)
32
+ end
33
+ 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.pre4
4
+ version: 0.9.pre5
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: 2015-12-17 00:00:00.000000000 Z
14
+ date: 2016-01-08 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: representable
@@ -139,6 +139,20 @@ dependencies:
139
139
  - - "~>"
140
140
  - !ruby/object:Gem::Version
141
141
  version: '0.19'
142
+ - !ruby/object:Gem::Dependency
143
+ name: httpclient
144
+ requirement: !ruby/object:Gem::Requirement
145
+ requirements:
146
+ - - "~>"
147
+ - !ruby/object:Gem::Version
148
+ version: '2.7'
149
+ type: :runtime
150
+ prerelease: false
151
+ version_requirements: !ruby/object:Gem::Requirement
152
+ requirements:
153
+ - - "~>"
154
+ - !ruby/object:Gem::Version
155
+ version: '2.7'
142
156
  - !ruby/object:Gem::Dependency
143
157
  name: memoist
144
158
  requirement: !ruby/object:Gem::Requirement
@@ -551,6 +565,7 @@ files:
551
565
  - lib/google/apis/core/batch.rb
552
566
  - lib/google/apis/core/download.rb
553
567
  - lib/google/apis/core/hashable.rb
568
+ - lib/google/apis/core/http_client_adapter.rb
554
569
  - lib/google/apis/core/http_command.rb
555
570
  - lib/google/apis/core/json_representation.rb
556
571
  - lib/google/apis/core/logging.rb
@@ -577,10 +592,17 @@ files:
577
592
  - rakelib/rubocop.rake
578
593
  - rakelib/spec.rake
579
594
  - rakelib/yard.rake
580
- - samples/calendar/calendar.rb
581
- - samples/drive/drive.rb
582
- - samples/pubsub/pubsub.rb
583
- - samples/translate/translate.rb
595
+ - samples/Gemfile
596
+ - samples/README.md
597
+ - samples/google-api-samples
598
+ - samples/lib/base_cli.rb
599
+ - samples/lib/samples/analytics.rb
600
+ - samples/lib/samples/calendar.rb
601
+ - samples/lib/samples/drive.rb
602
+ - samples/lib/samples/gmail.rb
603
+ - samples/lib/samples/pubsub.rb
604
+ - samples/lib/samples/translate.rb
605
+ - samples/lib/samples/you_tube.rb
584
606
  - script/generate
585
607
  - script/package
586
608
  - script/release
@@ -613,6 +635,7 @@ files:
613
635
  - spec/integration_tests/pubsub_spec.rb
614
636
  - spec/integration_tests/url_shortener_spec.rb
615
637
  - spec/spec_helper.rb
638
+ - spec/spec_helper/load_path_spec.rb
616
639
  - third_party/hurley_patches.rb
617
640
  homepage: https://github.com/google/google-api-ruby-client
618
641
  licenses:
@@ -670,4 +693,5 @@ test_files:
670
693
  - spec/integration_tests/pubsub_spec.rb
671
694
  - spec/integration_tests/url_shortener_spec.rb
672
695
  - spec/spec_helper.rb
696
+ - spec/spec_helper/load_path_spec.rb
673
697
  has_rdoc:
@@ -1,43 +0,0 @@
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 'googleauth'
16
- require 'google/apis/calendar_v3'
17
-
18
- Calendar = Google::Apis::CalendarV3
19
-
20
- calendar = Calendar::CalendarService.new
21
- calendar.authorization = Google::Auth.get_application_default([Calendar::AUTH_CALENDAR])
22
-
23
- # Create an event, adding any emails listed in the command line as attendees
24
- event = Calendar::Event.new(summary: 'A sample event',
25
- location: '1600 Amphitheatre Parkway, Mountain View, CA 94045',
26
- attendees: ARGV.map { |email| Calendar::EventAttendee.new(email: email) },
27
- start: Calendar::EventDateTime.new(date_time: DateTime.parse('2015-12-31T20:00:00')),
28
- end: Calendar::EventDateTime.new(date_time: DateTime.parse('2016-01-01T02:00:00')))
29
- event = calendar.insert_event('primary', event, send_notifications: true)
30
- puts "Created event '#{event.summary}' (#{event.id})"
31
-
32
- # List upcoming events
33
- events = calendar.list_events('primary', max_results: 10, single_events: true,
34
- order_by: 'startTime', time_min: Time.now.iso8601)
35
- puts "Upcoming events:"
36
- events.items.each do |event|
37
- start = event.start.date || event.start.date_time
38
- puts "- #{event.summary} (#{start}) (ID: #{event.id})"
39
- end
40
-
41
- # Delete the event we created earlier
42
- calendar.delete_event('primary', event.id, send_notifications: true)
43
- puts "Event deleted"
@@ -1,47 +0,0 @@
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
- # Pass all auth variables to .env file
16
- # Read more about auth on https://developers.google.com/drive/web/about-auth
17
- # For example, in my case I added GOOGLE_APPLICATION_CREDENTIALS=credentials.json
18
-
19
- require 'dotenv'
20
- Dotenv.load
21
-
22
- require 'tempfile'
23
- require 'googleauth'
24
- require 'google/apis/drive_v2'
25
-
26
- Drive = Google::Apis::DriveV2
27
-
28
- drive = Drive::DriveService.new
29
- drive.authorization = Google::Auth.get_application_default([Drive::AUTH_DRIVE])
30
-
31
- # Insert a file
32
- file = drive.insert_file({title: 'drive.rb'}, upload_source: __FILE__)
33
- puts "Created file #{file.title} (#{file.id})"
34
-
35
- # Search for it
36
- files = drive.list_files(q: "title = 'drive.rb'")
37
- puts "Search results:"
38
- files.items.each do |file|
39
- puts "- File: #{file.title} (#{file.id})"
40
- end
41
-
42
- # Read it back
43
- tmp = drive.get_file(file.id, download_dest: Tempfile.new('drive'))
44
-
45
- # Delete it
46
- drive.delete_file(file.id)
47
- puts "File deleted"
@@ -1,51 +0,0 @@
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 'googleauth'
16
- require 'google/apis/pubsub_v1'
17
-
18
- Pubsub = Google::Apis::PubsubV1
19
-
20
- pubsub = Pubsub::PubsubService.new
21
- pubsub.authorization = Google::Auth.get_application_default([Pubsub::AUTH_PUBSUB])
22
-
23
- project = ARGV[0] || 'YOUR_PROJECT_NAME'
24
-
25
- topic = "projects/#{project}/topics/foo"
26
- subscription = "projects/#{project}/subscriptions/bar"
27
-
28
- # Create topic & subscription
29
- pubsub.create_topic(topic)
30
- pubsub.create_subscription(subscription, Pubsub::Subscription.new(topic: topic))
31
-
32
- # Publish messages
33
- request = Pubsub::PublishRequest.new(messages: [])
34
- request.messages << Pubsub::Message.new(attributes: { "language" => "en" }, data: 'Hello')
35
- request.messages << Pubsub::Message.new(attributes: { "language" => "en" }, data: 'World')
36
- pubsub.publish_topic(topic, request)
37
-
38
- # Pull messages
39
- response = pubsub.pull_subscription(subscription, Pubsub::PullRequest.new(max_messages: 5))
40
- response.received_messages.each do |received_message|
41
- data = received_message.message.data
42
- puts "Received #{data}"
43
- end
44
-
45
- # Acknowledge receipt
46
- ack_ids = response.received_messages.map{ |msg| msg.ack_id }
47
- pubsub.acknowledge_subscription(subscription, Pubsub::AcknowledgeRequest.new(ack_ids: ack_ids))
48
-
49
- # Delete the subscription & topic
50
- pubsub.delete_subscription(subscription)
51
- pubsub.delete_topic(topic)