Module: Fog::Storage::HP::Utils

Included in:
Mock, Real
Defined in:
lib/fog/hp/storage.rb

Instance Method Summary collapse

Instance Method Details

#acl_to_header(acl) ⇒ Object



56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/fog/hp/storage.rb', line 56

def acl_to_header(acl)
  header = {}
  case acl
    when "private"
      header['X-Container-Read']  = ""
      header['X-Container-Write'] = ""
    when "public-read"
      header['X-Container-Read']  = ".r:*,.rlistings"
    when "public-write"
      header['X-Container-Write'] = "*"
    when "public-read-write"
      header['X-Container-Read']  = ".r:*,.rlistings"
      header['X-Container-Write'] = "*"
  end
  header
end

#cdnObject



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

def cdn
  unless @hp_cdn_uri.nil?
    @cdn ||= Fog::CDN.new(
      :provider       => 'HP',
      :hp_account_id  => @hp_account_id,
      :hp_secret_key  => @hp_secret_key,
      :hp_auth_uri    => @hp_auth_uri,
      :hp_cdn_uri     => @hp_cdn_uri,
      :hp_tenant_id   => @hp_tenant_id,
      :connection_options => @connection_options
    )
    if @cdn.enabled?
      @cdn
    end
  else
    nil
  end
end

#header_to_acl(read_header = nil, write_header = nil) ⇒ Object



73
74
75
76
77
78
79
80
81
82
83
84
# File 'lib/fog/hp/storage.rb', line 73

def header_to_acl(read_header=nil, write_header=nil)
  acl = nil
  if read_header.nil? && write_header.nil?
    acl = nil
  elsif !read_header.nil? && read_header.include?(".r:*") && write_header.nil?
    acl = "public-read"
  elsif !write_header.nil? && write_header.include?("*") && read_header.nil?
    acl = "public-write"
  elsif !read_header.nil? && read_header.include?(".r:*") && !write_header.nil? && write_header.include?("*")
    acl = "public-read-write"
  end
end

#urlObject



52
53
54
# File 'lib/fog/hp/storage.rb', line 52

def url
  "#{@scheme}://#{@host}:#{@port}#{@path}"
end