Class: Morpheus::LicenseInterface

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

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of LicenseInterface.



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

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

#apply(key) ⇒ Object



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

def apply(key)
	url = "#{@base_url}/api/license"
	headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
	payload = {license: key}
	response = Morpheus::RestClient.execute(method: :post, url: url,
                           timeout: 30, headers: headers, payload: payload.to_json, verify_ssl: false)
	JSON.parse(response.to_s)
end

#getObject



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

def get()
	url = "#{@base_url}/api/license"
	headers = { params: {}, authorization: "Bearer #{@access_token}" }
	response = Morpheus::RestClient.execute(method: :get, url: url,
                           timeout: 30, headers: headers, verify_ssl: false)
	JSON.parse(response.to_s)
end