2012-10-19 01:33:20 -04:00
|
|
|
require 'fog/core/collection'
|
|
|
|
require 'fog/hp/models/storage/shared_directory'
|
|
|
|
|
|
|
|
module Fog
|
|
|
|
module Storage
|
|
|
|
class HP
|
|
|
|
|
|
|
|
class SharedDirectories < Fog::Collection
|
|
|
|
|
|
|
|
model Fog::Storage::HP::SharedDirectory
|
|
|
|
|
2012-10-26 01:44:08 -04:00
|
|
|
def all
|
|
|
|
nil
|
|
|
|
end
|
|
|
|
|
2012-10-19 01:33:20 -04:00
|
|
|
def head(url)
|
2013-01-18 15:08:27 -05:00
|
|
|
data = service.head_shared_container(url)
|
2012-10-19 01:33:20 -04:00
|
|
|
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
|
2012-10-30 15:06:56 -04:00
|
|
|
# throws exception Fog::HP::Errors::Forbidden if insufficient access
|
|
|
|
rescue Fog::Storage::HP::NotFound
|
2012-10-19 01:33:20 -04:00
|
|
|
nil
|
|
|
|
end
|
|
|
|
|
|
|
|
def get(url)
|
2013-01-18 15:08:27 -05:00
|
|
|
data = service.get_shared_container(url)
|
2012-10-19 01:33:20 -04:00
|
|
|
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
|
2012-10-30 15:06:56 -04:00
|
|
|
# throws exception Fog::HP::Errors::Forbidden if insufficient access
|
|
|
|
rescue Fog::Storage::HP::NotFound
|
2012-10-19 01:33:20 -04:00
|
|
|
nil
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|