Class: Morpheus::GroupsInterface

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

Instance Method Summary collapse

Instance Method Details

#create(options) ⇒ Object



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

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

#destroy(id) ⇒ Object



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

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

#get(options = nil, params = {}) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/morpheus/api/groups_interface.rb', line 12

def get(options=nil, params={})
  url = "#{@base_url}/api/groups"
  headers = { params: {}, authorization: "Bearer #{@access_token}" }

  if options.is_a?(Hash)
    headers[:params].merge!(options)
  elsif options.is_a?(Numeric)
    url = "#{@base_url}/api/groups/#{options}"
    headers[:params] = params
  elsif options.is_a?(String)
    headers[:params]['name'] = options
  end
  opts = {method: :get, url: url, headers: headers}
  execute(opts)
end

#list(params = {}) ⇒ Object



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

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

#update(id, options) ⇒ Object



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

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

#update_wiki(id, payload) ⇒ Object



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

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

#update_zones(id, options) ⇒ Object



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

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

#wiki(id, params) ⇒ Object



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

def wiki(id, params)
  url = "#{@base_url}/api/groups/#{id}/wiki"
  headers = { params: params, authorization: "Bearer #{@access_token}" }
  opts = {method: :get, url: url, headers: headers}
  execute(opts)
end