Class: Fog::Storage::AzureRM::Container

Inherits:
Model
  • Object
show all
Defined in:
lib/fog/azurerm/models/storage/container.rb

Overview

This class is giving implementation of create and delete a container.

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.parse(container) ⇒ Object



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/fog/azurerm/models/storage/container.rb', line 37

def self.parse(container)
  hash = {}
  if container.is_a? Hash
    hash['name'] = container['name']
    hash['metadata'] = container['metadata']
    return hash unless container.key?('properties')

    hash['last_modified'] = container['properties']['last_modified']
    hash['etag'] = container['properties']['etag']
    hash['lease_duration'] = container['properties']['lease_duration']
    hash['lease_status'] = container['properties']['lease_status']
    hash['lease_state'] = container['properties']['lease_state']
  else
    hash['name'] = container.name
    hash['metadata'] = container.
    return hash unless container.respond_to?('properties')

    hash['last_modified'] = container.properties[:last_modified]
    hash['etag'] = container.properties[:etag]
    hash['lease_duration'] = container.properties[:lease_duration]
    hash['lease_status'] = container.properties[:lease_status]
    hash['lease_state'] = container.properties[:lease_state]
  end
  hash
end

Instance Method Details

#create(options = {}) ⇒ Object Also known as: save



15
16
17
18
# File 'lib/fog/azurerm/models/storage/container.rb', line 15

def create(options = {})
  requires :name
  merge_attributes(Container.parse(service.create_container(name, options)))
end

#destroy(options = {}) ⇒ Object



32
33
34
35
# File 'lib/fog/azurerm/models/storage/container.rb', line 32

def destroy(options = {})
  requires :name
  service.delete_container name, options
end

#get_access_control_list(options = {}) ⇒ Object



27
28
29
30
# File 'lib/fog/azurerm/models/storage/container.rb', line 27

def get_access_control_list(options = {})
  requires :name
  merge_attributes(Container.parse(service.get_container_access_control_list(name, options)[0]))
end

#get_properties(options = { metadata: true }) ⇒ Object



22
23
24
25
# File 'lib/fog/azurerm/models/storage/container.rb', line 22

def get_properties(options = { metadata: true })
  requires :name
  merge_attributes(Container.parse(service.get_container_properties(name, options)))
end