Class: Morpheus::LibraryClusterPackagesInterface

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

Instance Method Summary collapse

Instance Method Details

#create(payload) ⇒ Object



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

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

#destroy(id, payload = {}) ⇒ Object



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

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

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



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

def get(id, params={})
  raise "#{self.class}.get() passed a blank id!" if id.to_s == ''
  url = "#{@base_url}/api/library/cluster-packages/#{id}"
  headers = { params: params, authorization: "Bearer #{@access_token}" }
  opts = {method: :get, url: url, headers: headers}
  execute(opts)
end

#list(params = {}) ⇒ Object



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

def list(params={})
  url = "#{@base_url}/api/library/cluster-packages"
  params['sort'] = 'name'
  headers = { params: params, authorization: "Bearer #{@access_token}" }
  opts = {method: :get, url: url, headers: headers}
  execute(opts)
end

#update(id, payload) ⇒ Object



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

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

#update_logo(id, logo_file, dark_logo_file = nil) ⇒ Object



42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/morpheus/api/library_cluster_packages_interface.rb', line 42

def (id, logo_file, dark_logo_file=nil)
  url = "#{@base_url}/api/library/cluster-packages/#{id}"
  headers = { :params => {}, :authorization => "Bearer #{@access_token}"}
  payload = {}
  payload["clusterPackage"] = {}
  if logo_file
    payload["clusterPackage"]["logo"] = logo_file
  end
  if dark_logo_file
    payload["clusterPackage"]["darkLogo"] = dark_logo_file
  end
  if logo_file.is_a?(File) || dark_logo_file.is_a?(File)
    payload[:multipart] = true
  else
    headers['Content-Type'] = 'application/x-www-form-urlencoded'
  end
  execute(method: :put, url: url, headers: headers, payload: payload)
end