Class: A2A::AgentInterface
- Inherits:
-
Object
- Object
- A2A::AgentInterface
- Defined in:
- lib/a2a/agent_interface.rb
Constant Summary collapse
- JSONRPC =
"JSONRPC"- GRPC =
"GRPC"- HTTP_JSON =
"HTTP+JSON"- VALID_BINDINGS =
[JSONRPC, GRPC, HTTP_JSON].freeze
Instance Attribute Summary collapse
-
#protocol_binding ⇒ Object
readonly
Returns the value of attribute protocol_binding.
-
#protocol_version ⇒ Object
readonly
Returns the value of attribute protocol_version.
-
#tenant ⇒ Object
readonly
Returns the value of attribute tenant.
-
#url ⇒ Object
readonly
Returns the value of attribute url.
Class Method Summary collapse
Instance Method Summary collapse
- #grpc? ⇒ Boolean
- #http_json? ⇒ Boolean
-
#initialize(url:, protocol_binding:, protocol_version:, tenant: nil) ⇒ AgentInterface
constructor
A new instance of AgentInterface.
- #json_rpc? ⇒ Boolean
- #to_h ⇒ Object
Constructor Details
#initialize(url:, protocol_binding:, protocol_version:, tenant: nil) ⇒ AgentInterface
Returns a new instance of AgentInterface.
13 14 15 16 17 18 19 20 21 22 |
# File 'lib/a2a/agent_interface.rb', line 13 def initialize(url:, protocol_binding:, protocol_version:, tenant: nil) unless VALID_BINDINGS.include?(protocol_binding) raise ArgumentError, "protocol_binding must be one of #{VALID_BINDINGS.join(', ')}" end @url = url @protocol_binding = protocol_binding @protocol_version = protocol_version @tenant = tenant end |
Instance Attribute Details
#protocol_binding ⇒ Object (readonly)
Returns the value of attribute protocol_binding.
5 6 7 |
# File 'lib/a2a/agent_interface.rb', line 5 def protocol_binding @protocol_binding end |
#protocol_version ⇒ Object (readonly)
Returns the value of attribute protocol_version.
5 6 7 |
# File 'lib/a2a/agent_interface.rb', line 5 def protocol_version @protocol_version end |
#tenant ⇒ Object (readonly)
Returns the value of attribute tenant.
5 6 7 |
# File 'lib/a2a/agent_interface.rb', line 5 def tenant @tenant end |
#url ⇒ Object (readonly)
Returns the value of attribute url.
5 6 7 |
# File 'lib/a2a/agent_interface.rb', line 5 def url @url end |
Class Method Details
.from_h(hash) ⇒ Object
24 25 26 27 28 29 30 31 |
# File 'lib/a2a/agent_interface.rb', line 24 def self.from_h(hash) new( url: hash.fetch("url"), protocol_binding: hash.fetch("protocolBinding"), protocol_version: hash.fetch("protocolVersion"), tenant: hash["tenant"] ) end |
Instance Method Details
#grpc? ⇒ Boolean
46 47 48 |
# File 'lib/a2a/agent_interface.rb', line 46 def grpc? protocol_binding == GRPC end |
#http_json? ⇒ Boolean
50 51 52 |
# File 'lib/a2a/agent_interface.rb', line 50 def http_json? protocol_binding == HTTP_JSON end |
#json_rpc? ⇒ Boolean
42 43 44 |
# File 'lib/a2a/agent_interface.rb', line 42 def json_rpc? protocol_binding == JSONRPC end |
#to_h ⇒ Object
33 34 35 36 37 38 39 40 |
# File 'lib/a2a/agent_interface.rb', line 33 def to_h { "url" => url, "protocolBinding" => protocol_binding, "protocolVersion" => protocol_version, "tenant" => tenant }.compact end |