Class: Morpheus::UserSourcesInterface

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

Instance Method Summary collapse

Instance Method Details

#activate(account_id, id, options) ⇒ Object



44
45
46
47
48
49
50
# File 'lib/morpheus/api/user_sources_interface.rb', line 44

def activate(, id, options)
  url = build_url(, id) + "/activate"
  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

#create(account_id, options) ⇒ Object



21
22
23
24
25
26
27
# File 'lib/morpheus/api/user_sources_interface.rb', line 21

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

#deactivate(account_id, id, options) ⇒ Object



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

def deactivate(, id, options)
  url = build_url(, id) + "/deactivate"
  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

#destroy(account_id, id) ⇒ Object



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

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

#get(account_id, id) ⇒ Object



5
6
7
8
9
10
11
# File 'lib/morpheus/api/user_sources_interface.rb', line 5

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

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

move me to my own interface class



77
78
79
80
81
82
# File 'lib/morpheus/api/user_sources_interface.rb', line 77

def get_type(id, params={})
  url = "#{@base_url}/api/user-source-types/#{id}"
  headers = { params: params, authorization: "Bearer #{@access_token}" }
  opts = {method: :get, url: url, timeout: 10, headers: headers}
  execute(opts)
end

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



13
14
15
16
17
18
19
# File 'lib/morpheus/api/user_sources_interface.rb', line 13

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

#list_types(params = {}) ⇒ Object

move me to my own interface class



69
70
71
72
73
74
# File 'lib/morpheus/api/user_sources_interface.rb', line 69

def list_types(params={})
  url = "#{@base_url}/api/user-source-types"
  headers = { params: params, authorization: "Bearer #{@access_token}" }
  opts = {method: :get, url: url, timeout: 10, headers: headers}
  execute(opts)
end

#update(account_id, id, options) ⇒ Object



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

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

#update_subdomain(account_id, id, options) ⇒ Object



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

def update_subdomain(, id, options)
  url = build_url(, id) + "/subdomain"
  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