Class: ChefLicensing::Api::LicenseSoftwareEntitlement

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(license_keys: [], software_entitlement_name: nil, software_entitlement_id: nil, restful_client: ChefLicensing::RestfulClient::V1) ⇒ LicenseSoftwareEntitlement

Returns a new instance of LicenseSoftwareEntitlement.

Raises:

  • (ArgumentError)


12
13
14
15
16
17
18
19
20
# File 'lib/chef-licensing/api/license_software_entitlement.rb', line 12

def initialize(license_keys: [], software_entitlement_name: nil, software_entitlement_id: nil, restful_client: ChefLicensing::RestfulClient::V1)
  @license_keys = license_keys
  @entitlement_id = software_entitlement_id
  @entitlement_name = software_entitlement_name

  raise ArgumentError, "Either of `software_entitlement_id` or `software_entitlement_name` should be provided" if software_entitlement_name.nil? && software_entitlement_id.nil?

  @restful_client = restful_client.new
end

Instance Attribute Details

#license_keysObject (readonly)

Returns the value of attribute license_keys.



6
7
8
# File 'lib/chef-licensing/api/license_software_entitlement.rb', line 6

def license_keys
  @license_keys
end

Class Method Details

.check!(license_keys: [], software_entitlement_name: nil, software_entitlement_id: nil) ⇒ Object



8
9
10
# File 'lib/chef-licensing/api/license_software_entitlement.rb', line 8

def self.check!(license_keys: [], software_entitlement_name: nil, software_entitlement_id: nil)
  new(license_keys: license_keys, software_entitlement_name: software_entitlement_name, software_entitlement_id: software_entitlement_id).check!
end

Instance Method Details

#check!Object



22
23
24
25
# File 'lib/chef-licensing/api/license_software_entitlement.rb', line 22

def check!
  response = make_request
  response.data.entitled || raise(ChefLicensing::SoftwareNotEntitled)
end