Class: ChefLicensing::Api::ListLicenses

Inherits:
Object
  • Object
show all
Defined in:
lib/chef-licensing/api/list_licenses.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(opts = {}) ⇒ ListLicenses

Returns a new instance of ListLicenses.



14
15
16
# File 'lib/chef-licensing/api/list_licenses.rb', line 14

def initialize(opts = {})
  @restful_client = opts[:restful_client] ? opts[:restful_client].new : ChefLicensing::RestfulClient::V1.new
end

Class Method Details

.info(opts = {}) ⇒ Object



9
10
11
# File 'lib/chef-licensing/api/list_licenses.rb', line 9

def info(opts = {})
  new(opts).info
end

Instance Method Details

#infoObject



18
19
20
21
22
23
# File 'lib/chef-licensing/api/list_licenses.rb', line 18

def info
  response = restful_client.list_licenses
  raise ChefLicensing::ListLicensesError.new(response.message, response.status_code) unless response.status_code == 200 && response.data

  response.data
end