Class: Morpheus::UsersInterface

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

Instance Method Summary collapse

Methods inherited from APIClient

#accounts, #app_templates, #apps, #archive_buckets, #archive_files, #auth, #clouds, #containers, #custom_instance_types, #dashboard, #deploy, #deployments, #dry, #dry_run, #execute, #groups, #image_builder, #instance_types, #instances, #key_pairs, #license, #load_balancers, #logs, #monitoring, #option_type_lists, #option_types, #options, #provision_types, #roles, #security_group_rules, #security_groups, #servers, #set_ssl_verification_enabled, #setup, #ssl_verification_enabled?, #task_sets, #tasks, #users, #virtual_images, #whoami

Constructor Details

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

Returns a new instance of UsersInterface.



4
5
6
7
8
9
# File 'lib/morpheus/api/users_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

#available_roles(account_id, id = nil, options = {}) ⇒ Object



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

def available_roles(, id=nil, options={})
  url = build_url(, id) + "/available-roles"
  headers = { params: {}, authorization: "Bearer #{@access_token}" }
  headers[:params].merge!(options)
  opts = {method: :get, url: url, timeout: 10, headers: headers}
  execute(opts)
end

#create(account_id, options) ⇒ Object



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

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

#destroy(account_id, id) ⇒ Object



58
59
60
61
62
63
# File 'lib/morpheus/api/users_interface.rb', line 58

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

#feature_permissions(account_id, id) ⇒ Object



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

def feature_permissions(, id)
  url = build_url(, id) + "/feature-permissions"
  headers = { params: {}, authorization: "Bearer #{@access_token}" }
  opts = {method: :get, url: url, timeout: 10, headers: headers}
  execute(opts)
end

#get(account_id, id) ⇒ Object



11
12
13
14
15
16
17
# File 'lib/morpheus/api/users_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}" }
  opts = {method: :get, url: url, timeout: 10, headers: headers}
  execute(opts)
end

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



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

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

#update(account_id, id, options) ⇒ Object



50
51
52
53
54
55
56
# File 'lib/morpheus/api/users_interface.rb', line 50

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