Class: Legion::Extensions::Llm::Inventory::ProbeToken

Inherits:
Data
  • Object
show all
Defined in:
lib/legion/extensions/llm/inventory/probe_token.rb

Overview

A single-use safe-readiness probe token. Carries no secret. See 11.2.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(token_id:, instance_key:, publisher_token_id:, started_availability_revision:, started_at:) ⇒ ProbeToken

Returns a new instance of ProbeToken.



98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
# File 'lib/legion/extensions/llm/inventory/probe_token.rb', line 98

def initialize(token_id:, instance_key:, publisher_token_id:, started_availability_revision:, started_at:)
  raise Errors::ValidationError, 'instance_key must be an InstanceKey' unless instance_key.is_a?(Identity::InstanceKey)
  raise Errors::ValidationError, 'token_id must be a probe:v1: String' unless token_id.to_s.start_with?('probe:v1:')
  raise Errors::ValidationError, 'publisher_token_id must be a ptok:v1: String' unless publisher_token_id.is_a?(::String) && publisher_token_id.start_with?('ptok:v1:')
  unless started_availability_revision.is_a?(::Integer) && !started_availability_revision.negative?
    raise Errors::ValidationError, 'started_availability_revision must be a nonnegative Integer'
  end
  raise Errors::ValidationError, 'started_at must be a Time' unless started_at.is_a?(::Time)

  super(
    token_id: token_id.dup.freeze, instance_key: instance_key,
    publisher_token_id: publisher_token_id.dup.freeze,
    started_availability_revision: started_availability_revision, started_at: started_at.dup.freeze
  )
end

Instance Attribute Details

#instance_keyObject (readonly)

Returns the value of attribute instance_key

Returns:

  • (Object)

    the current value of instance_key



89
90
91
# File 'lib/legion/extensions/llm/inventory/probe_token.rb', line 89

def instance_key
  @instance_key
end

#publisher_token_idObject (readonly)

Returns the value of attribute publisher_token_id

Returns:

  • (Object)

    the current value of publisher_token_id



89
90
91
# File 'lib/legion/extensions/llm/inventory/probe_token.rb', line 89

def publisher_token_id
  @publisher_token_id
end

#started_atObject (readonly)

Returns the value of attribute started_at

Returns:

  • (Object)

    the current value of started_at



89
90
91
# File 'lib/legion/extensions/llm/inventory/probe_token.rb', line 89

def started_at
  @started_at
end

#started_availability_revisionObject (readonly)

Returns the value of attribute started_availability_revision

Returns:

  • (Object)

    the current value of started_availability_revision



89
90
91
# File 'lib/legion/extensions/llm/inventory/probe_token.rb', line 89

def started_availability_revision
  @started_availability_revision
end

#token_idObject (readonly)

Returns the value of attribute token_id

Returns:

  • (Object)

    the current value of token_id



89
90
91
# File 'lib/legion/extensions/llm/inventory/probe_token.rb', line 89

def token_id
  @token_id
end

Class Method Details

.issue(instance_key:, publisher_token_id:, started_availability_revision:, started_at:) ⇒ Object



90
91
92
93
94
95
96
# File 'lib/legion/extensions/llm/inventory/probe_token.rb', line 90

def self.issue(instance_key:, publisher_token_id:, started_availability_revision:, started_at:)
  new(
    token_id: "probe:v1:#{::SecureRandom.uuid}", instance_key: instance_key,
    publisher_token_id: publisher_token_id, started_availability_revision: started_availability_revision,
    started_at: started_at
  )
end