Class: Fog::Storage::HP::SharedDirectories

Inherits:
Collection
  • Object
show all
Defined in:
lib/fog/hp/models/storage/shared_directories.rb

Instance Attribute Summary

Attributes inherited from Collection

#service

Instance Method Summary collapse

Methods inherited from Collection

#clear, #create, #destroy, #initialize, #inspect, #load, model, #model, #new, #reload, #table, #to_json

Methods included from Attributes::ClassMethods

#_load, #aliases, #attribute, #attributes, #identity, #ignore_attributes, #ignored_attributes

Methods included from Core::DeprecatedConnectionAccessors

#connection, #connection=, #prepare_service_value

Methods included from Attributes::InstanceMethods

#_dump, #attributes, #dup, #identity, #identity=, #merge_attributes, #new_record?, #persisted?, #requires, #requires_one

Constructor Details

This class inherits a constructor from Fog::Collection

Instance Method Details

#allObject



12
13
14
# File 'lib/fog/hp/models/storage/shared_directories.rb', line 12

def all
  nil
end

#get(url) ⇒ Object



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/fog/hp/models/storage/shared_directories.rb', line 31

def get(url)
  data = service.get_shared_container(url)
  shared_directory = new(:url => url)
  for key, value in data.headers
    if ['X-Container-Bytes-Used', 'X-Container-Object-Count'].include?(key)
      shared_directory.merge_attributes(key => value)
    end
  end
  # set the files for the directory
  shared_directory.files.instance_variable_set(:@loaded, true)
  data.body.each do |file|
    shared_directory.files << shared_directory.files.new(file)
  end

  shared_directory
# throws exception Fog::HP::Errors::Forbidden if insufficient access
rescue Fog::Storage::HP::NotFound
  nil
end

#head(url) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/fog/hp/models/storage/shared_directories.rb', line 16

def head(url)
  data = service.head_shared_container(url)
  shared_directory = new(:url => url)
  for key, value in data.headers
    if ['X-Container-Bytes-Used', 'X-Container-Object-Count'].include?(key)
      shared_directory.merge_attributes(key => value)
    end
  end

  shared_directory
# throws exception Fog::HP::Errors::Forbidden if insufficient access
rescue Fog::Storage::HP::NotFound
  nil
end