Class: Openstack::Client::Storage

Inherits:
Object
  • Object
show all
Includes:
ActiveModel::Model, Helpers::HTTPSClient
Defined in:
lib/openstack/client/storage.rb,
lib/openstack/client/storage/get_object.rb,
lib/openstack/client/storage/put_object.rb,
lib/openstack/client/storage/list_objects.rb,
lib/openstack/client/storage/delete_object.rb,
lib/openstack/client/storage/object_store_url.rb,
lib/openstack/client/storage/bulk_delete_objects.rb,
lib/openstack/client/storage/get_object_by_range.rb,
lib/openstack/client/storage/create_temporary_uri.rb,
lib/openstack/client/storage/show_object_metadata.rb

Overview

:reek:IrresponsibleModule

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Helpers::HTTPSClient

#https_client

Constructor Details

#initialize(authenticator:, container:, region:) ⇒ Storage

Returns a new instance of Storage.



21
22
23
24
25
# File 'lib/openstack/client/storage.rb', line 21

def initialize(authenticator:, container:, region:)
  @authenticator = authenticator
  @container = container
  @region = region
end

Instance Attribute Details

#authenticatorObject (readonly)

Returns the value of attribute authenticator.



11
12
13
# File 'lib/openstack/client/storage.rb', line 11

def authenticator
  @authenticator
end

#containerObject (readonly)

Returns the value of attribute container.



11
12
13
# File 'lib/openstack/client/storage.rb', line 11

def container
  @container
end

#regionObject (readonly)

Returns the value of attribute region.



11
12
13
# File 'lib/openstack/client/storage.rb', line 11

def region
  @region
end

Instance Method Details

#bulk_delete_objects(key_collection) ⇒ Object



101
102
103
104
105
106
107
# File 'lib/openstack/client/storage.rb', line 101

def bulk_delete_objects(key_collection)
  https_client.request(
    prepare_request do
      BulkDeleteObjects.new(uri: uri, keys: key_collection).request
    end
  )
end

#create_temporary_uri(key, http_method, **options) ⇒ Object



89
90
91
92
93
94
95
# File 'lib/openstack/client/storage.rb', line 89

def create_temporary_uri(key, http_method, **options)
  CreateTemporaryURI.new(
    uri: absolute_uri(key),
    http_method: http_method,
    options: options
  ).generate
end

#delete_object(key) ⇒ Object



65
66
67
68
69
70
71
# File 'lib/openstack/client/storage.rb', line 65

def delete_object(key)
  https_client.request(
    prepare_request do
      DeleteObject.new(uri: absolute_uri(key)).request
    end
  )
end

#get_object(key, **options) ⇒ Object



35
36
37
38
39
40
41
# File 'lib/openstack/client/storage.rb', line 35

def get_object(key, **options)
  https_client.request(
    prepare_request do
      GetObject.new(uri: absolute_uri(key), options: options).request
    end
  )
end

#get_object_by_range(key, range, **options) ⇒ Object



43
44
45
46
47
48
49
50
51
# File 'lib/openstack/client/storage.rb', line 43

def get_object_by_range(key, range, **options)
  https_client.request(
    prepare_request do
      GetObjectByRange.new(
        uri: absolute_uri(key), range: range, options: options
      ).request
    end
  )
end

#list_objects(**options) ⇒ Object



81
82
83
84
85
86
87
# File 'lib/openstack/client/storage.rb', line 81

def list_objects(**options)
  https_client.request(
    prepare_request do
      ListObjects.new(uri: uri, options: options).request
    end
  )
end

#put_object(key, io, checksum: nil) ⇒ Object



53
54
55
56
57
58
59
60
61
62
63
# File 'lib/openstack/client/storage.rb', line 53

def put_object(key, io, checksum: nil)
  https_client.request(
    prepare_request do
      PutObject.new(
        io: io,
        uri: absolute_uri(key),
        checksum: checksum
      ).request
    end
  )
end

#show_object_metadata(key) ⇒ Object



73
74
75
76
77
78
79
# File 'lib/openstack/client/storage.rb', line 73

def (key)
  https_client.request(
    prepare_request do
      .new(uri: absolute_uri(key)).request
    end
  )
end

#temporary_url(key, http_method, **options) ⇒ Object



97
98
99
# File 'lib/openstack/client/storage.rb', line 97

def temporary_url(key, http_method, **options)
  create_temporary_uri(key, http_method, options).to_s
end

#uriObject



27
28
29
30
31
32
33
# File 'lib/openstack/client/storage.rb', line 27

def uri
  URI(ObjectStoreURL.new(
    authenticator: authenticator,
    container: container,
    region: region
  ).call)
end