diff --git a/bin/google-api b/bin/google-api
index 0af0f6b40..150a6dd45 100755
--- a/bin/google-api
+++ b/bin/google-api
@@ -401,7 +401,7 @@ HTML
def list
api = options[:api]
unless api
- STDERR.puts('No service name supplied.')
+ STDERR.puts('No API name supplied.')
exit(1)
end
client = Google::APIClient.new(:authorization => nil)
diff --git a/lib/google/api_client.rb b/lib/google/api_client.rb
index 1b6150727..2e062ac4d 100644
--- a/lib/google/api_client.rb
+++ b/lib/google/api_client.rb
@@ -219,11 +219,9 @@ module Google
# @return [Addressable::URI] The URI of the directory document.
def directory_uri
template = Addressable::Template.new(
- "https://{host}/discovery/v0.3/directory"
+ "https://{host}/discovery/v1/apis"
)
- return template.expand({
- "host" => self.host
- })
+ return template.expand({"host" => self.host})
end
##
@@ -250,8 +248,8 @@ module Google
version = version || 'v1'
return @discovery_uris["#{api}:#{version}"] ||= (begin
template = Addressable::Template.new(
- "https://{host}/discovery/v0.3/describe/" +
- "{api}/{version}"
+ "https://{host}/discovery/v1/apis/" +
+ "{api}/{version}/rest"
)
template.expand({
"host" => self.host,
diff --git a/lib/google/api_client/discovery.rb b/lib/google/api_client/discovery.rb
index 88a0a6ef8..4e2f37096 100644
--- a/lib/google/api_client/discovery.rb
+++ b/lib/google/api_client/discovery.rb
@@ -101,20 +101,20 @@ module Google
end
##
- # Returns the base URI for this version of the service.
+ # Returns the base URI for the discovery document.
#
- # @return [Addressable::URI] The base URI that methods are joined to.
+ # @return [Addressable::URI] The base URI.
attr_reader :document_base
##
# Returns the base URI for this version of the service.
#
# @return [Addressable::URI] The base URI that methods are joined to.
- def rest_base
- if @discovery_document['restBasePath']
- return @rest_base ||= (
+ def method_base
+ if @discovery_document['basePath']
+ return @method_base ||= (
self.document_base +
- Addressable::URI.parse(@discovery_document['restBasePath'])
+ Addressable::URI.parse(@discovery_document['basePath'])
).normalize
else
return nil
@@ -126,13 +126,13 @@ module Google
#
# @param [Addressable::URI, #to_str, String] new_base
# The new base URI to use for the service.
- def rest_base=(new_rest_base)
- @rest_base = Addressable::URI.parse(new_rest_base)
+ def method_base=(new_method_base)
+ @method_base = Addressable::URI.parse(new_method_base)
self.resources.each do |resource|
- resource.rest_base = @rest_base
+ resource.method_base = @method_base
end
self.methods.each do |method|
- method.rest_base = @rest_base
+ method.method_base = @method_base
end
end
@@ -144,7 +144,7 @@ module Google
def resources
return @resources ||= (
(@discovery_document['resources'] || []).inject([]) do |accu, (k, v)|
- accu << ::Google::APIClient::Resource.new(self.rest_base, k, v)
+ accu << ::Google::APIClient::Resource.new(self.method_base, k, v)
accu
end
)
@@ -158,7 +158,7 @@ module Google
def methods
return @methods ||= (
(@discovery_document['methods'] || []).inject([]) do |accu, (k, v)|
- accu << ::Google::APIClient::Method.new(self.rest_base, k, v)
+ accu << ::Google::APIClient::Method.new(self.method_base, k, v)
accu
end
)
@@ -176,7 +176,7 @@ module Google
return @hash ||= (begin
methods_hash = {}
self.methods.each do |method|
- methods_hash[method.rpc_method] = method
+ methods_hash[method.id] = method
end
self.resources.each do |resource|
methods_hash.merge!(resource.to_h)
@@ -191,7 +191,7 @@ module Google
# @return [String] The service's state, as a String
.
def inspect
sprintf(
- "#<%s:%#0x NAME:%s>", self.class.to_s, self.object_id, self.name
+ "#<%s:%#0x ID:%s>", self.class.to_s, self.object_id, self.id
)
end
end
@@ -211,8 +211,8 @@ module Google
# The section of the discovery document that applies to this resource.
#
# @return [Google::APIClient::Resource] The constructed resource object.
- def initialize(rest_base, resource_name, discovery_document)
- @rest_base = rest_base
+ def initialize(method_base, resource_name, discovery_document)
+ @method_base = method_base
@name = resource_name
@discovery_document = discovery_document
metaclass = (class <String.
def inspect
sprintf(
- "#<%s:%#0x NAME:%s>",
- self.class.to_s, self.object_id, self.rpc_method
+ "#<%s:%#0x ID:%s>",
+ self.class.to_s, self.object_id, self.id
)
end
end
diff --git a/spec/google/api_client/discovery_spec.rb b/spec/google/api_client/discovery_spec.rb
index fce06fd49..bff4685ce 100644
--- a/spec/google/api_client/discovery_spec.rb
+++ b/spec/google/api_client/discovery_spec.rb
@@ -70,7 +70,7 @@ describe Google::APIClient do
it 'should correctly determine the discovery URI' do
@client.discovery_uri('prediction').should ===
- 'https://www.googleapis.com/discovery/v0.3/describe/prediction/v1'
+ 'https://www.googleapis.com/discovery/v1/apis/prediction/v1/rest'
end
it 'should correctly generate API objects' do
@@ -157,7 +157,7 @@ describe Google::APIClient do
it 'should allow modification to the base URIs for testing purposes' do
prediction = @client.discovered_api('prediction', 'v1')
- prediction.rest_base =
+ prediction.method_base =
'https://testing-domain.googleapis.com/prediction/v1/'
request = @client.generate_request(
prediction.training.insert,
@@ -227,7 +227,7 @@ describe Google::APIClient do
it 'should correctly determine the discovery URI' do
@client.discovery_uri('buzz').should ===
- 'https://www.googleapis.com/discovery/v0.3/describe/buzz/v1'
+ 'https://www.googleapis.com/discovery/v1/apis/buzz/v1/rest'
end
it 'should find APIs that are in the discovery document' do
@@ -318,7 +318,7 @@ describe Google::APIClient do
it 'should correctly determine the discovery URI' do
@client.discovery_uri('latitude').should ===
- 'https://www.googleapis.com/discovery/v0.3/describe/latitude/v1'
+ 'https://www.googleapis.com/discovery/v1/apis/latitude/v1/rest'
end
it 'should find APIs that are in the discovery document' do
@@ -383,7 +383,7 @@ describe Google::APIClient do
it 'should correctly determine the discovery URI' do
@client.discovery_uri('moderator').should ===
- 'https://www.googleapis.com/discovery/v0.3/describe/moderator/v1'
+ 'https://www.googleapis.com/discovery/v1/apis/moderator/v1/rest'
end
it 'should find APIs that are in the discovery document' do