Class: Morpheus::PricesInterface

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

Instance Method Summary collapse

Instance Method Details

#base_pathObject



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

def base_path
  "/api/prices"
end

#create(payload) ⇒ Object



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

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

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



36
37
38
39
40
# File 'lib/morpheus/api/prices_interface.rb', line 36

def deactivate(id, params={})
  url = "#{base_path}/#{id}/deactivate"
  headers = { :params => params, :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
  execute(method: :put, url: url, headers: headers)
end

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



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

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

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



48
49
50
51
52
# File 'lib/morpheus/api/prices_interface.rb', line 48

def get_datastore(id, params={})
  url = "#{base_path}/datastores/#{id}"
  headers = { params: params, authorization: "Bearer #{@access_token}" }
  execute(method: :get, url: url, headers: headers)
end

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



60
61
62
63
64
# File 'lib/morpheus/api/prices_interface.rb', line 60

def get_volume_type(id, params={})
  url = "#{base_path}/volume-types/#{id}"
  headers = { params: params, authorization: "Bearer #{@access_token}" }
  execute(method: :get, url: url, headers: headers)
end

#list(params = {}) ⇒ Object



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

def list(params={})
  url = base_path
  if params['ids']
    url = "#{url}?#{params.delete('ids').collect {|id| "id=#{id}"}.join('&')}"
  end
  headers = { params: params, authorization: "Bearer #{@access_token}" }
  execute(method: :get, url: url, headers: headers)
end

#list_currencies(params = {}) ⇒ Object



66
67
68
69
70
# File 'lib/morpheus/api/prices_interface.rb', line 66

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

#list_datastores(params = {}) ⇒ Object



42
43
44
45
46
# File 'lib/morpheus/api/prices_interface.rb', line 42

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

#list_volume_types(params = {}) ⇒ Object



54
55
56
57
58
# File 'lib/morpheus/api/prices_interface.rb', line 54

def list_volume_types(params={})
  url = "#{base_path}/volume-types"
  headers = { params: params, authorization: "Bearer #{@access_token}" }
  execute(method: :get, url: url, headers: headers)
end

#update(id, payload) ⇒ Object



30
31
32
33
34
# File 'lib/morpheus/api/prices_interface.rb', line 30

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