Class: ChefLicensing::RestfulClient::Base
- Inherits:
-
Object
- Object
- ChefLicensing::RestfulClient::Base
- Defined in:
- lib/chef-licensing/restful_client/base.rb
Overview
Base class to handle all License Server endpoints
Direct Known Subclasses
Constant Summary collapse
- END_POINTS =
{ FEATURE_BY_NAME: "license-service/featurebyname", FEATURE_BY_ID: "license-service/featurebyid", ENTITLEMENT_BY_NAME: "license-service/entitlementbyname", ENTITLEMENT_BY_ID: "license-service/entitlementbyid", }.freeze
- CURRENT_ENDPOINT_VERSION =
2- REQUEST_LIMIT =
5
Instance Method Summary collapse
- #client(params = {}) ⇒ Object
- #describe(params = {}) ⇒ Object
- #entitlement_by_id(payload) ⇒ Object
- #entitlement_by_name(payload) ⇒ Object
- #feature_by_id(payload) ⇒ Object
- #feature_by_name(payload) ⇒ Object
-
#initialize ⇒ Base
constructor
A new instance of Base.
- #list_licenses(params = {}) ⇒ Object
- #validate(license) ⇒ Object
Constructor Details
#initialize ⇒ Base
Returns a new instance of Base.
27 28 29 30 31 |
# File 'lib/chef-licensing/restful_client/base.rb', line 27 def initialize raise MissingAPICredentialsError, "Missing credential in config: Set in block chef_license_server or use environment variable CHEF_LICENSE_SERVER or pass through argument --chef-license-server" if ChefLicensing::Config.license_server_url.nil? @logger = ChefLicensing::Config.logger end |
Instance Method Details
#client(params = {}) ⇒ Object
53 54 55 |
# File 'lib/chef-licensing/restful_client/base.rb', line 53 def client(params = {}) invoke_get_api(self.class::END_POINTS[:CLIENT], { licenseId: params[:license_keys], entitlementId: params[:entitlement_id] }) end |
#describe(params = {}) ⇒ Object
57 58 59 |
# File 'lib/chef-licensing/restful_client/base.rb', line 57 def describe(params = {}) invoke_get_api(self.class::END_POINTS[:DESCRIBE], { licenseId: params[:license_keys], entitlementId: params[:entitlement_id] }) end |
#entitlement_by_id(payload) ⇒ Object
49 50 51 |
# File 'lib/chef-licensing/restful_client/base.rb', line 49 def entitlement_by_id(payload) invoke_post_api(self.class::END_POINTS[:ENTITLEMENT_BY_ID], payload) end |
#entitlement_by_name(payload) ⇒ Object
45 46 47 |
# File 'lib/chef-licensing/restful_client/base.rb', line 45 def entitlement_by_name(payload) invoke_post_api(self.class::END_POINTS[:ENTITLEMENT_BY_NAME], payload) end |
#feature_by_id(payload) ⇒ Object
41 42 43 |
# File 'lib/chef-licensing/restful_client/base.rb', line 41 def feature_by_id(payload) invoke_post_api(self.class::END_POINTS[:FEATURE_BY_ID], payload) end |
#feature_by_name(payload) ⇒ Object
37 38 39 |
# File 'lib/chef-licensing/restful_client/base.rb', line 37 def feature_by_name(payload) invoke_post_api(self.class::END_POINTS[:FEATURE_BY_NAME], payload) end |
#list_licenses(params = {}) ⇒ Object
61 62 63 |
# File 'lib/chef-licensing/restful_client/base.rb', line 61 def list_licenses(params = {}) invoke_get_api(self.class::END_POINTS[:LIST_LICENSES]) end |
#validate(license) ⇒ Object
33 34 35 |
# File 'lib/chef-licensing/restful_client/base.rb', line 33 def validate(license) invoke_get_api(self.class::END_POINTS[:VALIDATE], { licenseId: license, version: CURRENT_ENDPOINT_VERSION }) end |