lib/google/compute/client.rb in knife-google-1.1.0 vs lib/google/compute/client.rb in knife-google-1.2.0
- old
+ new
@@ -15,21 +15,22 @@
# limitations under the License.
require 'google/api_client'
require 'multi_json'
require 'google/compute/resource_collection'
+require 'knife-google/version'
module Google
module Compute
class Client
DEFAULT_FILE = '~/.google-compute.json'
attr_reader :dispatcher
def initialize(authorization, project, credential_file)
- api_client = Google::APIClient.new(:application_name=>'google-compute-ruby-client')
+ api_client = Google::APIClient.new(:application_name => 'knife-google', :application_version => Knife::Google::VERSION)
api_client.authorization = authorization
api_client.auto_refresh_token = true
@project = project
@credential_file = credential_file
@dispatcher = APIDispatcher.new(:project=>project,:api_client=>api_client)
@@ -63,11 +64,11 @@
"https://www.googleapis.com/auth/devstorage.read_write",
"https://www.googleapis.com/auth/devstorage.write_only",
"https://www.googleapis.com/auth/userinfo.email"]
redirect_uri = 'urn:ietf:wg:oauth:2.0:oob'
- api_client = Google::APIClient.new(:application_name=>'google-compute-ruby-client')
+ api_client = Google::APIClient.new(:application_name => 'knife-google', :application_version => Knife::Google::VERSION)
api_client.authorization.scope = scope
api_client.authorization.client_id = client_id
api_client.authorization.client_secret = client_secret
api_client.authorization.redirect_uri = redirect_uri
@@ -123,14 +124,10 @@
def instances
CreatableResourceCollection.new(:resource_class => Google::Compute::Server, :dispatcher=>@dispatcher)
end
- def kernels
- ListableResourceCollection.new(:resource_class => Google::Compute::Kernel,:dispatcher=>@dispatcher)
- end
-
def machine_types
ListableResourceCollection.new(:resource_class => Google::Compute::MachineType,:dispatcher=>@dispatcher)
end
def networks
@@ -139,14 +136,22 @@
def globalOperations
DeletableResourceCollection.new(:resource_class => Google::Compute::GlobalOperation, :dispatcher=>@dispatcher)
end
+ def regionOperations
+ DeletableResourceCollection.new(:resource_class => Google::Compute::RegionOperation, :dispatcher=>@dispatcher)
+ end
+
def zoneOperations
DeletableResourceCollection.new(:resource_class => Google::Compute::ZoneOperation, :dispatcher=>@dispatcher)
end
+ def regions
+ ListableResourceCollection.new(:resource_class => Google::Compute::Region, :dispatcher=>@dispatcher)
+ end
+
def zones
ListableResourceCollection.new(:resource_class => Google::Compute::Zone, :dispatcher=>@dispatcher)
end
def snapshots
@@ -160,10 +165,10 @@
@project= opts[:project]
@api_client = opts[:api_client]
end
def compute
- @compute ||= @api_client.discovered_api('compute','v1beta15')
+ @compute ||= @api_client.discovered_api('compute','v1')
end
def dispatch(opts)
begin
unless opts[:parameters].has_key?(:project)