1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00

better operation APIs

This commit is contained in:
Nat Welch 2013-04-29 13:57:04 -07:00
parent e8248d0a90
commit da39beb75c
6 changed files with 33 additions and 56 deletions

View file

@ -27,7 +27,6 @@ module Fog
request :get_image
request :get_machine_type
request :get_network
request :get_operation
request :get_zone
request :delete_disk

View file

@ -1,30 +0,0 @@
module Fog
module Compute
class Google
class Mock
def get_operation(operation_name)
Fog::Mock.not_implemented
end
end
class Real
def get_operation(operation_name)
api_method = @compute.operations.get
parameters = {
'project' => @project,
'operation' => operation_name
}
result = self.build_result(api_method, parameters)
response = self.build_response(result)
end
end
end
end
end

View file

@ -11,8 +11,16 @@ module Fog
end
class Real
# https://developers.google.com/compute/docs/reference/latest/globalOperations
def list_global_operations
api_method = @compute.global_operations.list
parameters = {
'project' => @project
}
result = self.build_result(api_method, parameters)
response = self.build_response(result)
end
end
end

View file

@ -12,7 +12,15 @@ module Fog
class Real
def list_zone_operations
def list_zone_operations(zone)
api_method = @compute.zone_operations.list
parameters = {
'zone' => zone,
'project' => @project,
}
result = self.build_result(api_method, parameters)
response = self.build_response(result)
end
end
end

View file

@ -66,6 +66,7 @@ Shindo.tests('Fog::Compute[:google] | disk requests', ['google']) do
disk_size = '2'
zone_name = 'us-central1-a'
# These will all fail if errors happen on insert
tests("#insert_disk").formats(@insert_disk_format) do
@google.insert_disk(disk_name, disk_size, zone_name).body
end

View file

@ -2,52 +2,43 @@ Shindo.tests('Fog::Compute[:google] | operation requests', ['google']) do
@google = Fog::Compute[:google]
@get_operation_format = {
@list_global_operations_format = {
'kind' => String,
'id' => String,
'items' => [{
'kind' => String,
'error' => { 'errors' => [] },
'id' => String,
'selfLink' => String,
'name' => String,
'operationType' => String,
'targetLink' => String,
'targetId' => String,
'status' => String,
'user' => String,
'progress' => Integer,
'insertTime' => String,
'startTime' => String,
'httpErrorStatusCode' => Integer,
'httpErrorMessage' => String,
'operationType' => String
}
@list_global_operations_format = {
'kind' => String,
'id' => String,
'endTime' => String,
'selfLink' => String,
}],
'selfLink' => String,
'nextPageToken' => String,
'items' => []
}
@list_zone_operations_format = {
'kind' => String,
'id' => String,
'selfLink' => String,
'nextPageToken' => String,
'items' => []
#'items' => []
}
tests('success') do
tests("#get_operation").formats(@get_operation_format) do
operation_name = @google.list_global_operations.body["items"][0]["name"]
@google.get_operation(operation_name).body
end
tests("#list_global_operations").formats(@list_global_operations_format) do
@google.list_global_operations.body
end
tests("#list_zone_operations").formats(@list_zone_operations_format) do
@google.list_zone_operations.body
zone_name = @google.list_zones.body["items"][0]["name"]
@google.list_zone_operations(zone_name).body
end
end