google-api-client 0.9.5 → 0.9.6
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/google-api-client.gemspec +4 -3
- data/lib/google/api_client/client_secrets.rb +1 -1
- data/lib/google/apis/core/download.rb +10 -1
- data/lib/google/apis/core/json_representation.rb +2 -2
- data/lib/google/apis/version.rb +1 -1
- data/samples/cli/.env +4 -0
- data/samples/web/.env +2 -0
- data/samples/web/views/home.erb +0 -1
- metadata +5 -71
- data/api_names_out.yaml +0 -28434
- data/generated/google/apis/sheets_v1.rb +0 -43
- data/generated/google/apis/sheets_v1/classes.rb +0 -4542
- data/generated/google/apis/sheets_v1/representations.rb +0 -1703
- data/generated/google/apis/sheets_v1/service.rb +0 -363
- data/script/generate +0 -105
- data/script/package +0 -8
- data/script/release +0 -15
- data/spec/fixtures/files/api_names.yaml +0 -3
- data/spec/fixtures/files/auth_stored_credentials.json +0 -8
- data/spec/fixtures/files/child/.gitignore +0 -0
- data/spec/fixtures/files/client_secrets.json +0 -1
- data/spec/fixtures/files/invalid.json +0 -1
- data/spec/fixtures/files/test.blah +0 -1
- data/spec/fixtures/files/test.txt +0 -1
- data/spec/fixtures/files/test_api.json +0 -440
- data/spec/google/api_client/auth/storage_spec.rb +0 -120
- data/spec/google/api_client/auth/storages/file_store_spec.rb +0 -39
- data/spec/google/api_client/auth/storages/redis_store_spec.rb +0 -68
- data/spec/google/api_client/client_secrets_spec.rb +0 -389
- data/spec/google/apis/core/api_command_spec.rb +0 -209
- data/spec/google/apis/core/batch_spec.rb +0 -142
- data/spec/google/apis/core/download_spec.rb +0 -103
- data/spec/google/apis/core/hashable_spec.rb +0 -60
- data/spec/google/apis/core/http_command_spec.rb +0 -303
- data/spec/google/apis/core/json_representation_spec.rb +0 -199
- data/spec/google/apis/core/service_spec.rb +0 -313
- data/spec/google/apis/core/upload_spec.rb +0 -300
- data/spec/google/apis/generated_spec.rb +0 -27
- data/spec/google/apis/generator/generator_spec.rb +0 -324
- data/spec/google/apis/logging_spec.rb +0 -100
- data/spec/google/apis/options_spec.rb +0 -40
- data/spec/integration_tests/adsense_spec.rb +0 -29
- data/spec/integration_tests/drive_spec.rb +0 -35
- data/spec/integration_tests/pubsub_spec.rb +0 -48
- data/spec/integration_tests/url_shortener_spec.rb +0 -45
- data/spec/spec_helper.rb +0 -153
- data/spec/spec_helper/load_path_spec.rb +0 -33
@@ -1,40 +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 'spec_helper'
|
16
|
-
require 'google/apis/options'
|
17
|
-
|
18
|
-
RSpec.describe Google::Apis::RequestOptions do
|
19
|
-
let(:options) { Google::Apis::RequestOptions.new }
|
20
|
-
|
21
|
-
it 'should not merge nil values' do
|
22
|
-
options.retries = 1
|
23
|
-
expect(options.merge(authorization: 'foo').retries).to eql 1
|
24
|
-
end
|
25
|
-
|
26
|
-
it 'should merge non-nil values' do
|
27
|
-
options.retries = 1
|
28
|
-
expect(options.merge(authorization: 'foo').authorization).to eql 'foo'
|
29
|
-
end
|
30
|
-
|
31
|
-
it 'should merge from options' do
|
32
|
-
opts = Google::Apis::RequestOptions.new
|
33
|
-
opts.authorization = 'foo'
|
34
|
-
expect(options.merge(opts).authorization).to eql 'foo'
|
35
|
-
end
|
36
|
-
|
37
|
-
it 'should allow nil in merge' do
|
38
|
-
expect(options.merge(nil)).to be_an_instance_of(Google::Apis::RequestOptions)
|
39
|
-
end
|
40
|
-
end
|
@@ -1,29 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'google/apis/adsense_v1_4'
|
3
|
-
require 'googleauth'
|
4
|
-
|
5
|
-
Adsense = Google::Apis::AdsenseV1_4
|
6
|
-
|
7
|
-
RSpec.describe Google::Apis::AdsenseV1_4, :if => run_integration_tests? do
|
8
|
-
|
9
|
-
before(:context) do
|
10
|
-
#WebMock.allow_net_connect!
|
11
|
-
@adsense = Adsense::AdSenseService.new
|
12
|
-
#@adsense.authorization = Google::Auth.get_application_default([Adsense::AUTH_ADSENSE])
|
13
|
-
#@adsense.authorization.sub = 'cb@travelingnuker.com'
|
14
|
-
#@adsense.authorization.fetch_access_token!
|
15
|
-
end
|
16
|
-
|
17
|
-
it 'should download a report with multiple dimensions' do
|
18
|
-
pending "Not enabled for test account"
|
19
|
-
report = @adsense.generate_report( Date.today.to_s, Date.today.to_s, dimension: ["DATE", "AD_UNIT_NAME"] )
|
20
|
-
|
21
|
-
report_header_names = report.headers.map { |h| h.name }
|
22
|
-
expect(report_header_names).to include('DATE')
|
23
|
-
expect(report_header_names).to include('AD_UNIT_NAME')
|
24
|
-
end
|
25
|
-
|
26
|
-
after(:context) do
|
27
|
-
#WebMock.disable_net_connect!
|
28
|
-
end
|
29
|
-
end
|
@@ -1,35 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'google/apis/drive_v2'
|
3
|
-
require 'googleauth'
|
4
|
-
require 'fileutils'
|
5
|
-
|
6
|
-
Drive = Google::Apis::DriveV2
|
7
|
-
|
8
|
-
RSpec.describe Google::Apis::DriveV2, :if => run_integration_tests? do
|
9
|
-
|
10
|
-
before(:context) do
|
11
|
-
WebMock.allow_net_connect!
|
12
|
-
@drive = Drive::DriveService.new
|
13
|
-
@drive.authorization = Google::Auth.get_application_default([Drive::AUTH_DRIVE])
|
14
|
-
end
|
15
|
-
|
16
|
-
it 'should upload and download files' do
|
17
|
-
# Insert a file
|
18
|
-
content_path = File.join(FIXTURES_DIR, 'files', 'test_api.json')
|
19
|
-
file = @drive.insert_file({title: 'test_file.txt'}, upload_source: content_path)
|
20
|
-
puts "Created file #{file.title} (#{file.id})"
|
21
|
-
|
22
|
-
# Read it back
|
23
|
-
tmp = @drive.get_file(file.id, download_dest: Tempfile.new('drive'))
|
24
|
-
|
25
|
-
# Delete it
|
26
|
-
@drive.delete_file(file.id)
|
27
|
-
puts "File deleted"
|
28
|
-
|
29
|
-
expect(FileUtils.compare_file(content_path, tmp)).to be_truthy
|
30
|
-
end
|
31
|
-
|
32
|
-
after(:context) do
|
33
|
-
WebMock.disable_net_connect!
|
34
|
-
end
|
35
|
-
end
|
@@ -1,48 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'google/apis/pubsub_v1'
|
3
|
-
require 'googleauth'
|
4
|
-
|
5
|
-
Pubsub = Google::Apis::PubsubV1
|
6
|
-
|
7
|
-
RSpec.describe Google::Apis::PubsubV1, :if => run_integration_tests? do
|
8
|
-
|
9
|
-
before(:context) do
|
10
|
-
WebMock.allow_net_connect!
|
11
|
-
project = ENV['GOOGLE_PROJECT_ID']
|
12
|
-
@topic_name = "projects/#{project}/topics/test"
|
13
|
-
@subscription_name = "projects/#{project}/subscriptions/test"
|
14
|
-
|
15
|
-
@pubsub = Pubsub::PubsubService.new
|
16
|
-
@pubsub.authorization = Google::Auth.get_application_default([Pubsub::AUTH_PUBSUB])
|
17
|
-
@pubsub.create_topic(@topic_name)
|
18
|
-
@pubsub.create_subscription(@subscription_name, Pubsub::Subscription.new(topic: @topic_name))
|
19
|
-
end
|
20
|
-
|
21
|
-
it 'should publish & receive messages' do
|
22
|
-
# Publish messages
|
23
|
-
request = Pubsub::PublishRequest.new(messages: [])
|
24
|
-
request.messages << Pubsub::Message.new(attributes: { "language" => "en" }, data: 'Hello')
|
25
|
-
request.messages << Pubsub::Message.new(attributes: { "language" => "en" }, data: 'World')
|
26
|
-
@pubsub.publish_topic(@topic_name, request)
|
27
|
-
|
28
|
-
# Pull messages
|
29
|
-
response = @pubsub.pull_subscription(@subscription_name, Pubsub::PullRequest.new(max_messages: 5))
|
30
|
-
response.received_messages.each do |received_message|
|
31
|
-
data = received_message.message.data
|
32
|
-
puts "Received #{data}"
|
33
|
-
end
|
34
|
-
|
35
|
-
# Acknowledge receipt
|
36
|
-
ack_ids = response.received_messages.map{ |msg| msg.ack_id }
|
37
|
-
@pubsub.acknowledge_subscription(@subscription_name, Pubsub::AcknowledgeRequest.new(ack_ids: ack_ids))
|
38
|
-
|
39
|
-
expect(response.received_messages.length).to eq 2
|
40
|
-
end
|
41
|
-
|
42
|
-
after(:context) do
|
43
|
-
@pubsub.delete_subscription(@subscription_name)
|
44
|
-
@pubsub.delete_topic(@topic_name)
|
45
|
-
WebMock.disable_net_connect!
|
46
|
-
end
|
47
|
-
|
48
|
-
end
|
@@ -1,45 +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 'spec_helper'
|
16
|
-
require 'google/apis/urlshortener_v1'
|
17
|
-
require 'googleauth'
|
18
|
-
|
19
|
-
Urlshortener = Google::Apis::UrlshortenerV1
|
20
|
-
|
21
|
-
RSpec.describe Google::Apis::UrlshortenerV1, :if => run_integration_tests? do
|
22
|
-
|
23
|
-
before(:context) do
|
24
|
-
WebMock.allow_net_connect!
|
25
|
-
@shortener = Urlshortener::UrlshortenerService.new
|
26
|
-
@shortener.authorization = Google::Auth.get_application_default([Urlshortener::AUTH_URLSHORTENER])
|
27
|
-
end
|
28
|
-
|
29
|
-
it 'should shorten URLs in a batch' do
|
30
|
-
@urls = []
|
31
|
-
callback = lambda { |url, err| @urls << url unless url.nil? }
|
32
|
-
@shortener.batch do |shortener|
|
33
|
-
shortener.insert_url(Urlshortener::Url.new(long_url: 'https://example.com/foo'), &callback)
|
34
|
-
shortener.insert_url(Urlshortener::Url.new(long_url: 'https://example.com/bar'), &callback)
|
35
|
-
shortener.insert_url(Urlshortener::Url.new(long_url: 'https://example.com/baz'), &callback)
|
36
|
-
end
|
37
|
-
puts @urls.inspect
|
38
|
-
expect(@urls.length).to eq 3
|
39
|
-
end
|
40
|
-
|
41
|
-
after(:context) do
|
42
|
-
WebMock.disable_net_connect!
|
43
|
-
end
|
44
|
-
|
45
|
-
end
|
data/spec/spec_helper.rb
DELETED
@@ -1,153 +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
|
-
SPEC_DIR = File.expand_path(File.dirname(__FILE__))
|
16
|
-
ROOT_DIR = File.expand_path(File.join(SPEC_DIR, '..'))
|
17
|
-
LIB_DIR = File.expand_path(File.join(ROOT_DIR, 'lib'))
|
18
|
-
GENERATED_DIR = File.expand_path(File.join(ROOT_DIR, 'generated'))
|
19
|
-
THIRD_PARTY_DIR = File.expand_path(File.join(ROOT_DIR, 'third_party'))
|
20
|
-
FIXTURES_DIR = File.expand_path(File.join(SPEC_DIR, 'fixtures'))
|
21
|
-
|
22
|
-
$LOAD_PATH.uniq!
|
23
|
-
|
24
|
-
if defined?(JRUBY_VERSION)
|
25
|
-
puts 'Skipping coverage on JRuby'
|
26
|
-
else
|
27
|
-
# set up coverage
|
28
|
-
require 'simplecov'
|
29
|
-
require 'coveralls'
|
30
|
-
|
31
|
-
SimpleCov.formatters = [
|
32
|
-
Coveralls::SimpleCov::Formatter,
|
33
|
-
SimpleCov::Formatter::HTMLFormatter
|
34
|
-
]
|
35
|
-
SimpleCov.start do
|
36
|
-
add_filter '/spec/'
|
37
|
-
add_filter '/generated/'
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
require 'rspec'
|
42
|
-
require 'webmock/rspec'
|
43
|
-
require 'fakefs/spec_helpers'
|
44
|
-
require 'json_spec'
|
45
|
-
require 'logging'
|
46
|
-
require 'rspec/logging_helper'
|
47
|
-
require 'google/apis'
|
48
|
-
require 'google/apis/core/base_service'
|
49
|
-
|
50
|
-
# Configure RSpec to capture log messages for each test. The output from the
|
51
|
-
# logs will be stored in the @log_output variable. It is a StringIO instance.
|
52
|
-
RSpec.configure do |config|
|
53
|
-
include RSpec::LoggingHelper
|
54
|
-
config.include FakeFS::SpecHelpers, fakefs: true
|
55
|
-
config.include JsonSpec::Helpers
|
56
|
-
config.include WebMock::API
|
57
|
-
config.capture_log_messages
|
58
|
-
|
59
|
-
Google::Apis.logger.level = Logger::DEBUG
|
60
|
-
WebMock::Config.instance.query_values_notation = :flat_array
|
61
|
-
end
|
62
|
-
|
63
|
-
[JsonSpec::Matchers::BeJsonEql,
|
64
|
-
JsonSpec::Matchers::IncludeJson,
|
65
|
-
JsonSpec::Matchers::HaveJsonType,
|
66
|
-
JsonSpec::Matchers::HaveJsonSize,
|
67
|
-
JsonSpec::Matchers::HaveJsonPath].each do |klass|
|
68
|
-
klass.send(:alias_method, :===, :matches?)
|
69
|
-
end
|
70
|
-
|
71
|
-
RSpec.shared_context 'HTTP client' do
|
72
|
-
let(:client) do
|
73
|
-
Google::Apis::Core::BaseService.new('', '').client
|
74
|
-
end
|
75
|
-
end
|
76
|
-
|
77
|
-
module TestHelpers
|
78
|
-
include WebMock::API
|
79
|
-
include WebMock::Matchers
|
80
|
-
end
|
81
|
-
|
82
|
-
# Enable retries for tests
|
83
|
-
Google::Apis::RequestOptions.default.retries = 5
|
84
|
-
|
85
|
-
# Allow testing different adapters
|
86
|
-
Google::Apis::ClientOptions.default.use_net_http = true if ENV['USE_NET_HTTP']
|
87
|
-
# Temporarily patch WebMock to allow chunked responses for Net::HTTP
|
88
|
-
module Net
|
89
|
-
module WebMockHTTPResponse
|
90
|
-
def eval_chunk(chunk)
|
91
|
-
chunk if chunk.is_a?(String)
|
92
|
-
chunk.read if chunk.is_a?(IO)
|
93
|
-
chunk.call if chunk.is_a?(Proc)
|
94
|
-
fail chunk if chunk.is_a?(Class)
|
95
|
-
chunk
|
96
|
-
end
|
97
|
-
|
98
|
-
def read_body(dest = nil, &block)
|
99
|
-
if !(defined?(@__read_body_previously_called).nil?) && @__read_body_previously_called
|
100
|
-
return super
|
101
|
-
end
|
102
|
-
return @body if dest.nil? && block.nil?
|
103
|
-
fail ArgumentError.new('both arg and block given for HTTP method') if dest && block
|
104
|
-
return nil if @body.nil?
|
105
|
-
|
106
|
-
dest ||= ::Net::ReadAdapter.new(block)
|
107
|
-
body_parts = Array(@body)
|
108
|
-
body_parts.each do |chunk|
|
109
|
-
chunk = eval_chunk(chunk)
|
110
|
-
dest << chunk
|
111
|
-
end
|
112
|
-
@body = dest
|
113
|
-
ensure
|
114
|
-
# allow subsequent calls to #read_body to proceed as normal, without our hack...
|
115
|
-
@__read_body_previously_called = true
|
116
|
-
end
|
117
|
-
end
|
118
|
-
end
|
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
|
-
|
151
|
-
def run_integration_tests?
|
152
|
-
ENV['GOOGLE_APPLICATION_CREDENTIALS'] && ENV['GOOGLE_PROJECT_ID']
|
153
|
-
end
|
@@ -1,33 +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 'spec_helper'
|
16
|
-
|
17
|
-
RSpec.describe $LOAD_PATH do
|
18
|
-
it('should contain SPEC_DIR') do
|
19
|
-
expect($LOAD_PATH).to include(SPEC_DIR)
|
20
|
-
end
|
21
|
-
|
22
|
-
it('should contain LIB_DIR') do
|
23
|
-
expect($LOAD_PATH).to include(LIB_DIR)
|
24
|
-
end
|
25
|
-
|
26
|
-
it('should contain GENERATED_DIR') do
|
27
|
-
expect($LOAD_PATH).to include(GENERATED_DIR)
|
28
|
-
end
|
29
|
-
|
30
|
-
it('should contain THIRD_PARTY_DIR') do
|
31
|
-
expect($LOAD_PATH).to include(THIRD_PARTY_DIR)
|
32
|
-
end
|
33
|
-
end
|