Class: Morpheus::RolesInterface

Inherits:
APIClient show all
Defined in:
lib/morpheus/api/roles_interface.rb

Instance Method Summary collapse

Methods inherited from APIClient

#accounts, #app_templates, #apps, #auth, #clouds, #custom_instance_types, #dashboard, #deploy, #deployments, #dry, #dry_run, #execute, #groups, #instance_types, #instances, #key_pairs, #license, #load_balancers, #logs, #options, #provision_types, #roles, #security_group_rules, #security_groups, #servers, #setup, #task_sets, #tasks, #users, #virtual_images, #whoami

Constructor Details

#initialize(access_token, refresh_token, expires_at = nil, base_url = nil) ⇒ RolesInterface

Returns a new instance of RolesInterface.



4
5
6
7
8
9
# File 'lib/morpheus/api/roles_interface.rb', line 4

def initialize(access_token, refresh_token, expires_at = nil, base_url=nil) 
  @access_token = access_token
  @refresh_token = refresh_token
  @base_url = base_url
  @expires_at = expires_at
end

Instance Method Details

#create(account_id, options) ⇒ Object



26
27
28
29
30
31
# File 'lib/morpheus/api/roles_interface.rb', line 26

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

#destroy(account_id, id) ⇒ Object



40
41
42
43
44
# File 'lib/morpheus/api/roles_interface.rb', line 40

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

#get(account_id, id) ⇒ Object



11
12
13
14
15
16
17
# File 'lib/morpheus/api/roles_interface.rb', line 11

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

#list(account_id, options = {}) ⇒ Object



19
20
21
22
23
24
# File 'lib/morpheus/api/roles_interface.rb', line 19

def list(, options={})
  url = build_url()
  headers = { params: {}, authorization: "Bearer #{@access_token}" }
  headers[:params].merge!(options)
  execute(method: :get, url: url, headers: headers)
end

#update(account_id, id, options) ⇒ Object



33
34
35
36
37
38
# File 'lib/morpheus/api/roles_interface.rb', line 33

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

#update_cloud(account_id, id, options) ⇒ Object



67
68
69
70
71
72
# File 'lib/morpheus/api/roles_interface.rb', line 67

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

#update_group(account_id, id, options) ⇒ Object



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

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

#update_instance_type(account_id, id, options) ⇒ Object



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

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

#update_permission(account_id, id, options) ⇒ Object



46
47
48
49
50
51
# File 'lib/morpheus/api/roles_interface.rb', line 46

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