mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
use Excon's idempotent option for gets and lists
This commit is contained in:
parent
411b5b1728
commit
8b9e491072
21 changed files with 44 additions and 22 deletions
|
@ -2,17 +2,19 @@ module Fog
|
||||||
module Joyent
|
module Joyent
|
||||||
class Analytics
|
class Analytics
|
||||||
class Real
|
class Real
|
||||||
def describe_analytics
|
def describe_analytics(force = false)
|
||||||
|
@describe_analytics = nil if force
|
||||||
@describe_analytics ||= request(
|
@describe_analytics ||= request(
|
||||||
:path => "#{@joyent_username}/analytics",
|
:path => "#{@joyent_username}/analytics",
|
||||||
:method => "GET",
|
:method => "GET",
|
||||||
:expects => 200
|
:expects => 200,
|
||||||
|
:idempotent => true
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
class Mock
|
class Mock
|
||||||
def describe_analytics
|
def describe_analytics(force = false)
|
||||||
response = Excon::Response.new
|
response = Excon::Response.new
|
||||||
response.status = 200
|
response.status = 200
|
||||||
response.body = self.data[:describe_analytics]
|
response.body = self.data[:describe_analytics]
|
||||||
|
|
|
@ -6,7 +6,8 @@ module Fog
|
||||||
request(
|
request(
|
||||||
:path => "#{@joyent_username}/analytics/instrumentations/#{id}",
|
:path => "#{@joyent_username}/analytics/instrumentations/#{id}",
|
||||||
:method => "GET",
|
:method => "GET",
|
||||||
:expects => 200
|
:expects => 200,
|
||||||
|
:idempotent => true
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -7,6 +7,7 @@ module Fog
|
||||||
:path => url,
|
:path => url,
|
||||||
:method => 'GET',
|
:method => 'GET',
|
||||||
:expects => 200,
|
:expects => 200,
|
||||||
|
:idempotent => true,
|
||||||
:query => {
|
:query => {
|
||||||
:ndatapoints => ndatapoints,
|
:ndatapoints => ndatapoints,
|
||||||
:start_time => requested_start_time.to_i,
|
:start_time => requested_start_time.to_i,
|
||||||
|
|
|
@ -6,7 +6,8 @@ module Fog
|
||||||
request(
|
request(
|
||||||
:path => "#{@joyent_username}/analytics/instrumentations",
|
:path => "#{@joyent_username}/analytics/instrumentations",
|
||||||
:method => "GET",
|
:method => "GET",
|
||||||
:expects => 200
|
:expects => 200,
|
||||||
|
:idempotent => true
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -18,7 +18,8 @@ module Fog
|
||||||
def get_dataset
|
def get_dataset
|
||||||
request(
|
request(
|
||||||
:method => "GET",
|
:method => "GET",
|
||||||
:path => "/my/datasets"
|
:path => "/my/datasets",
|
||||||
|
:idempotent => true
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -19,7 +19,8 @@ module Fog
|
||||||
request(
|
request(
|
||||||
:method => "GET",
|
:method => "GET",
|
||||||
:path => "/#{@joyent_username}/images/#{id}",
|
:path => "/#{@joyent_username}/images/#{id}",
|
||||||
:expects => 200
|
:expects => 200,
|
||||||
|
:idempotent => true
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -20,7 +20,8 @@ module Fog
|
||||||
request(
|
request(
|
||||||
:method => "GET",
|
:method => "GET",
|
||||||
:path => "/my/keys/#{keyid}",
|
:path => "/my/keys/#{keyid}",
|
||||||
:expects => 200
|
:expects => 200,
|
||||||
|
:idempotent => true
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -20,7 +20,8 @@ module Fog
|
||||||
request(
|
request(
|
||||||
:method => "GET",
|
:method => "GET",
|
||||||
:path => "/my/machines/#{uuid}",
|
:path => "/my/machines/#{uuid}",
|
||||||
:expects => [200, 410]
|
:expects => [200, 410],
|
||||||
|
:idempotent => true
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -15,7 +15,8 @@ module Fog
|
||||||
|
|
||||||
request(
|
request(
|
||||||
:path => "/my/machines/#{machine_id}/metadata",
|
:path => "/my/machines/#{machine_id}/metadata",
|
||||||
:query => query
|
:query => query,
|
||||||
|
:idempotent => true
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,8 @@ module Fog
|
||||||
def get_machine_snapshot(machine_id, snapshot_name)
|
def get_machine_snapshot(machine_id, snapshot_name)
|
||||||
request(
|
request(
|
||||||
:path => "/my/machines/#{machine_id}/snapshots/#{snapshot_name}",
|
:path => "/my/machines/#{machine_id}/snapshots/#{snapshot_name}",
|
||||||
:method => "GET"
|
:method => "GET",
|
||||||
|
:idempotent => true
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -9,7 +9,8 @@ module Fog
|
||||||
:path => "/my/machines/#{machine_id}/tags/#{tagname}",
|
:path => "/my/machines/#{machine_id}/tags/#{tagname}",
|
||||||
:method => "GET",
|
:method => "GET",
|
||||||
:headers => {"Accept" => "text/plain"},
|
:headers => {"Accept" => "text/plain"},
|
||||||
:expects => 200
|
:expects => 200,
|
||||||
|
:idempotent => true
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,8 @@ module Fog
|
||||||
request(
|
request(
|
||||||
:method => "GET",
|
:method => "GET",
|
||||||
:path => "/my/packages/#{name}",
|
:path => "/my/packages/#{name}",
|
||||||
:expects => 200
|
:expects => 200,
|
||||||
|
:idempotent => true
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,8 @@ module Fog
|
||||||
request(
|
request(
|
||||||
:expects => 200,
|
:expects => 200,
|
||||||
:method => :'GET',
|
:method => :'GET',
|
||||||
:path => '/my/datacenters'
|
:path => '/my/datacenters',
|
||||||
|
:idempotent => true
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
end # Real
|
end # Real
|
||||||
|
|
|
@ -15,7 +15,8 @@ module Fog
|
||||||
def list_datasets
|
def list_datasets
|
||||||
request(
|
request(
|
||||||
:method => "GET",
|
:method => "GET",
|
||||||
:path => "/my/datasets"
|
:path => "/my/datasets",
|
||||||
|
:idempotent => true
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -16,7 +16,8 @@ module Fog
|
||||||
request(
|
request(
|
||||||
:method => "GET",
|
:method => "GET",
|
||||||
:path => "/#{@joyent_username}/images",
|
:path => "/#{@joyent_username}/images",
|
||||||
:expects => 200
|
:expects => 200,
|
||||||
|
:idempotent => true
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -15,7 +15,8 @@ module Fog
|
||||||
request(
|
request(
|
||||||
:expects => 200,
|
:expects => 200,
|
||||||
:method => :'GET',
|
:method => :'GET',
|
||||||
:path => '/my/keys'
|
:path => '/my/keys',
|
||||||
|
:idempotent => true
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
end # Real
|
end # Real
|
||||||
|
|
|
@ -5,7 +5,8 @@ module Fog
|
||||||
def list_machine_snapshots(machine_id)
|
def list_machine_snapshots(machine_id)
|
||||||
request(
|
request(
|
||||||
:method => "GET",
|
:method => "GET",
|
||||||
:path => "/my/machines/#{machine_id}/snapshots"
|
:path => "/my/machines/#{machine_id}/snapshots",
|
||||||
|
:idempotent => true
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -7,7 +7,8 @@ module Fog
|
||||||
request(
|
request(
|
||||||
:path => "/my/machines/#{machine_id}/tags",
|
:path => "/my/machines/#{machine_id}/tags",
|
||||||
:method => "GET",
|
:method => "GET",
|
||||||
:expects => 200
|
:expects => 200,
|
||||||
|
:idempotent => true
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -17,7 +17,8 @@ module Fog
|
||||||
:path => "/my/machines",
|
:path => "/my/machines",
|
||||||
:method => "GET",
|
:method => "GET",
|
||||||
:query => options,
|
:query => options,
|
||||||
:expects => 200
|
:expects => 200,
|
||||||
|
:idempotent => true
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -17,7 +17,8 @@ module Fog
|
||||||
:path => "/my/networks",
|
:path => "/my/networks",
|
||||||
:method => "GET",
|
:method => "GET",
|
||||||
:query => options,
|
:query => options,
|
||||||
:expects => 200
|
:expects => 200,
|
||||||
|
:idempotent => true
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -25,7 +25,8 @@ module Fog
|
||||||
request(
|
request(
|
||||||
:path => "/my/packages",
|
:path => "/my/packages",
|
||||||
:method => "GET",
|
:method => "GET",
|
||||||
:expects => 200
|
:expects => 200,
|
||||||
|
:idempotent => true
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
end # Real
|
end # Real
|
||||||
|
|
Loading…
Reference in a new issue