Class: EvoleapLicensing::ServerControlManager
- Inherits:
-
Object
- Object
- EvoleapLicensing::ServerControlManager
- Defined in:
- lib/evoleap_licensing/server_control_manager.rb
Instance Attribute Summary collapse
-
#product_id ⇒ Object
readonly
Returns the value of attribute product_id.
-
#public_key ⇒ Object
readonly
Returns the value of attribute public_key.
-
#server_state ⇒ Object
readonly
Returns the value of attribute server_state.
-
#strategy ⇒ Object
readonly
Returns the value of attribute strategy.
-
#version ⇒ Object
readonly
Returns the value of attribute version.
Instance Method Summary collapse
-
#initialize(product_id:, version:, public_key:, strategy: nil, server_state: nil) ⇒ ServerControlManager
constructor
A new instance of ServerControlManager.
-
#register(license_key:, instance_identity:) ⇒ Object
Register the server instance with the licensing service.
-
#validate_instance(instance_identity:) ⇒ Object
Validate the server instance against the licensing service.
-
#web_client=(client) ⇒ Object
For testing: allow injecting a custom web client.
Constructor Details
#initialize(product_id:, version:, public_key:, strategy: nil, server_state: nil) ⇒ ServerControlManager
Returns a new instance of ServerControlManager.
7 8 9 10 11 12 13 14 |
# File 'lib/evoleap_licensing/server_control_manager.rb', line 7 def initialize(product_id:, version:, public_key:, strategy: nil, server_state: nil) @product_id = product_id @version = version @public_key = public_key @strategy = strategy || ControlStrategy.default @server_state = server_state || ServerState.new @client = WebClient.new end |
Instance Attribute Details
#product_id ⇒ Object (readonly)
Returns the value of attribute product_id.
5 6 7 |
# File 'lib/evoleap_licensing/server_control_manager.rb', line 5 def product_id @product_id end |
#public_key ⇒ Object (readonly)
Returns the value of attribute public_key.
5 6 7 |
# File 'lib/evoleap_licensing/server_control_manager.rb', line 5 def public_key @public_key end |
#server_state ⇒ Object (readonly)
Returns the value of attribute server_state.
5 6 7 |
# File 'lib/evoleap_licensing/server_control_manager.rb', line 5 def server_state @server_state end |
#strategy ⇒ Object (readonly)
Returns the value of attribute strategy.
5 6 7 |
# File 'lib/evoleap_licensing/server_control_manager.rb', line 5 def strategy @strategy end |
#version ⇒ Object (readonly)
Returns the value of attribute version.
5 6 7 |
# File 'lib/evoleap_licensing/server_control_manager.rb', line 5 def version @version end |
Instance Method Details
#register(license_key:, instance_identity:) ⇒ Object
Register the server instance with the licensing service. Returns a RegistrationResult.
18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/evoleap_licensing/server_control_manager.rb', line 18 def register(license_key:, instance_identity:) ControlManagerHelper.register(@server_state) do WebService.register_instance( product_id: @product_id, license_key: license_key, hardware_identity: instance_identity.to_api_format, public_key: @public_key, client: @client ) end end |
#validate_instance(instance_identity:) ⇒ Object
Validate the server instance against the licensing service. Returns an InstanceValidity.
32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/evoleap_licensing/server_control_manager.rb', line 32 def validate_instance(instance_identity:) ControlManagerHelper.validate_instance(@strategy, @server_state) do WebService.validate_instance( product_id: @product_id, instance_id: @server_state.instance_guid, version: @version, hardware_identity: instance_identity.to_api_format, public_key: @public_key, client: @client ) end end |
#web_client=(client) ⇒ Object
For testing: allow injecting a custom web client
46 47 48 |
# File 'lib/evoleap_licensing/server_control_manager.rb', line 46 def web_client=(client) @client = client end |