Class: Rackspace::StorageApi
Instance Attribute Summary collapse
-
#api ⇒ Object
readonly
Returns the value of attribute api.
Attributes inherited from Api
Instance Method Summary collapse
- #create(params) ⇒ Object
- #destroy(name) ⇒ Object
- #find_by_id(volume_id) ⇒ Object
- #find_by_name(name) ⇒ Object
-
#initialize(rackspace_credentials) ⇒ StorageApi
constructor
A new instance of StorageApi.
Constructor Details
#initialize(rackspace_credentials) ⇒ StorageApi
Returns a new instance of StorageApi.
5 6 7 8 |
# File 'lib/rackspace/storage_api.rb', line 5 def initialize(rackspace_credentials) super rackspace_credentials @api ||= Fog::Rackspace::BlockStorage.new(rackspace_credentials) end |
Instance Attribute Details
#api ⇒ Object (readonly)
Returns the value of attribute api.
3 4 5 |
# File 'lib/rackspace/storage_api.rb', line 3 def api @api end |
Instance Method Details
#create(params) ⇒ Object
18 19 20 21 22 23 24 25 26 27 |
# File 'lib/rackspace/storage_api.rb', line 18 def create(params) name = params.fetch(:name) api.volumes.create( size: params.fetch(:size), display_name: name, volume_type: params.fetch(:volume_type), ) wait_for(name) end |
#destroy(name) ⇒ Object
29 30 31 |
# File 'lib/rackspace/storage_api.rb', line 29 def destroy(name) find_by_name(name).destroy end |
#find_by_id(volume_id) ⇒ Object
14 15 16 |
# File 'lib/rackspace/storage_api.rb', line 14 def find_by_id(volume_id) api.get_volume volume_id end |
#find_by_name(name) ⇒ Object
10 11 12 |
# File 'lib/rackspace/storage_api.rb', line 10 def find_by_name(name) api.volumes.detect { |v| v.display_name == name } end |