Class: ChefLicensing::Api::Describe
- Inherits:
-
Object
- Object
- ChefLicensing::Api::Describe
- Defined in:
- lib/chef-licensing/api/describe.rb
Instance Attribute Summary collapse
-
#license_keys ⇒ Object
readonly
Returns the value of attribute license_keys.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(opts = {}) ⇒ Describe
constructor
A new instance of Describe.
- #list ⇒ Object
Constructor Details
#initialize(opts = {}) ⇒ Describe
Returns a new instance of Describe.
18 19 20 21 |
# File 'lib/chef-licensing/api/describe.rb', line 18 def initialize(opts = {}) @license_keys = opts[:license_keys] || raise(ArgumentError, "Missing Params: `license_keys`") @restful_client = opts[:restful_client] ? opts[:restful_client].new : ChefLicensing::RestfulClient::V1.new end |
Instance Attribute Details
#license_keys ⇒ Object (readonly)
Returns the value of attribute license_keys.
10 11 12 |
# File 'lib/chef-licensing/api/describe.rb', line 10 def license_keys @license_keys end |
Class Method Details
.list(opts = {}) ⇒ Object
13 14 15 |
# File 'lib/chef-licensing/api/describe.rb', line 13 def list(opts = {}) new(opts).list end |
Instance Method Details
#list ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/chef-licensing/api/describe.rb', line 23 def list response_data = get_describe_api_response_data list_of_licenses = [] response_data.license.each do |license| # license object created to be fed to parser license_object = OpenStruct.new({ "license" => license, "assets" => response_data.Assets, "features" => response_data.Features, "software" => response_data.Software, }) list_of_licenses << ChefLicensing::License.new( data: license_object, product_name: ChefLicensing::Config.chef_product_name, api_parser: ChefLicensing::Api::Parser::Describe ) end # returns list of license data model object list_of_licenses end |