Class: Fog::Storage::K5::Real

Inherits:
Object
  • Object
show all
Includes:
K5::Shared, Utils
Defined in:
lib/fog/storage/k5/real.rb,
lib/fog/storage/k5/requests/get_object.rb,
lib/fog/storage/k5/requests/put_object.rb,
lib/fog/storage/k5/requests/list_objects.rb,
lib/fog/storage/k5/requests/delete_object.rb,
lib/fog/storage/k5/requests/list_containers.rb

Constant Summary

Constants included from K5::Shared

K5::Shared::K5_URL_SCHEME, K5::Shared::K5_URL_SUFFIX

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from K5::Shared

#build_url, #refresh_auth_token_if_expired

Methods included from Utils

#request

Constructor Details

#initialize(options = {}) ⇒ Real

Returns a new instance of Real.



10
11
12
13
14
15
# File 'lib/fog/storage/k5/real.rb', line 10

def initialize(options = {})
  refresh_credentials(options)

  url = build_url(url_type: K5_STORAGE_URL_TYPE)
  @connection = Fog::Core::Connection.new(url, false, params)
end

Instance Attribute Details

#k5_project_idObject (readonly)

Returns the value of attribute k5_project_id.



8
9
10
# File 'lib/fog/storage/k5/real.rb', line 8

def k5_project_id
  @k5_project_id
end

#k5_regionObject (readonly)

Returns the value of attribute k5_region.



8
9
10
# File 'lib/fog/storage/k5/real.rb', line 8

def k5_region
  @k5_region
end

Instance Method Details

#delete_object(container, object, _options = {}) ⇒ Object



5
6
7
8
9
10
11
# File 'lib/fog/storage/k5/requests/delete_object.rb', line 5

def delete_object(container, object, _options = {})
  request(
    method:  :DELETE,
    path:    "#{container}/#{object}",
    expects: 204,
  )
end

#get_object(container, object, _options = {}) ⇒ Object



5
6
7
8
9
10
11
# File 'lib/fog/storage/k5/requests/get_object.rb', line 5

def get_object(container, object, _options = {})
  request(
    method:  :GET,
    path:    "#{container}/#{object}",
    expects: 200,
  )
end

#list_containers(_options = {}) ⇒ Object



5
6
7
8
9
10
11
# File 'lib/fog/storage/k5/requests/list_containers.rb', line 5

def list_containers(_options = {})
  request(
    method:  :GET,
    path:    '/',
    expects: 200,
  )
end

#list_objects(container, _options = {}) ⇒ Object



5
6
7
8
9
10
11
# File 'lib/fog/storage/k5/requests/list_objects.rb', line 5

def list_objects(container, _options = {})
  request(
    method:  :GET,
    path:    container,
    expects: 200,
  )
end

#put_object(container, object, data, _options = {}) ⇒ Object



5
6
7
8
9
10
11
12
13
14
# File 'lib/fog/storage/k5/requests/put_object.rb', line 5

def put_object(container, object, data, _options = {})
  data   = Fog::Storage.parse_data(data)
  params = {
    method:  :PUT,
    path:    "#{container}/#{object}",
    expects: 201,
  }

  request(params.merge(data))
end