Class: Morpheus::StorageDatastoresInterface

Inherits:
APIClient
  • Object
show all
Defined in:
lib/morpheus/api/storage_datastores_interface.rb

Instance Method Summary collapse

Instance Method Details

#base_pathObject



5
6
7
# File 'lib/morpheus/api/storage_datastores_interface.rb', line 5

def base_path
  "#{@base_url}/api/data-stores"
end

#create(options) ⇒ Object



31
32
33
34
35
36
# File 'lib/morpheus/api/storage_datastores_interface.rb', line 31

def create(options)
  url = "#{@base_url}/api/data-stores"
  headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
  payload = options
  execute(method: :post, url: url, headers: headers, payload: payload.to_json)
end

#get(id, params = {}) ⇒ Object



9
10
11
12
13
14
15
# File 'lib/morpheus/api/storage_datastores_interface.rb', line 9

def get(id, params={})
  raise "#{self.class}.get() passed a blank id!" if id.to_s == ''
  url = "#{@base_url}/api/data-stores/#{id}"
  headers = { params: params, authorization: "Bearer #{@access_token}" }
  opts = {method: :get, url: url, headers: headers}
  execute(opts)
end

#list(params = {}) ⇒ Object



17
18
19
20
21
22
# File 'lib/morpheus/api/storage_datastores_interface.rb', line 17

def list(params={})
  url = base_path
  headers = { params: params, authorization: "Bearer #{@access_token}" }
  opts = {method: :get, url: url, headers: headers}
  execute(opts)
end

#load_type_options(datastore_type) ⇒ Object



24
25
26
27
28
29
# File 'lib/morpheus/api/storage_datastores_interface.rb', line 24

def load_type_options(datastore_type)
  url = "/api/data-stores/#{datastore_type}/option-types"
  headers = { params: {}, authorization: "Bearer #{@access_token}" }
  opts = {method: :get, url: url, headers: headers}
  execute(opts)
end

#update(id, payload) ⇒ Object



38
39
40
41
42
43
# File 'lib/morpheus/api/storage_datastores_interface.rb', line 38

def update(id, payload)
  url = "#{@base_url}/api/data-stores/#{id}"
  headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
  opts = {method: :put, url: url, headers: headers, payload: payload.to_json}
  execute(opts)
end