Class: A2A::Types::AgentInterface
- Defined in:
- lib/a2a/types/agent_card.rb
Overview
Represents an agent interface
Interfaces define the transport protocols and URLs that can be used to communicate with the agent.
Instance Attribute Summary collapse
-
#transport ⇒ Object
readonly
Returns the value of attribute transport.
-
#url ⇒ Object
readonly
Returns the value of attribute url.
Instance Method Summary collapse
-
#initialize(transport:, url:) ⇒ AgentInterface
constructor
Initialize a new agent interface.
-
#secure? ⇒ Boolean
Check if this is a secure interface (HTTPS).
-
#uses_transport?(transport_type) ⇒ Boolean
Check if this interface uses the specified transport.
- #validate! ⇒ Object private
-
#validate_url_format ⇒ Object
private
Validate URL format.
Methods inherited from BaseModel
#==, #camelize, from_h, from_json, #hash, #to_h, #to_json, underscore, #valid?, #validate_array_type, #validate_inclusion, #validate_required, #validate_type
Constructor Details
#initialize(transport:, url:) ⇒ AgentInterface
Initialize a new agent interface
395 396 397 398 399 |
# File 'lib/a2a/types/agent_card.rb', line 395 def initialize(transport:, url:) @transport = transport @url = url validate! end |
Instance Attribute Details
#transport ⇒ Object (readonly)
Returns the value of attribute transport.
388 389 390 |
# File 'lib/a2a/types/agent_card.rb', line 388 def transport @transport end |
#url ⇒ Object (readonly)
Returns the value of attribute url.
388 389 390 |
# File 'lib/a2a/types/agent_card.rb', line 388 def url @url end |
Instance Method Details
#secure? ⇒ Boolean
Check if this is a secure interface (HTTPS)
414 415 416 |
# File 'lib/a2a/types/agent_card.rb', line 414 def secure? @url.start_with?("https://") end |
#uses_transport?(transport_type) ⇒ Boolean
Check if this interface uses the specified transport
406 407 408 |
# File 'lib/a2a/types/agent_card.rb', line 406 def uses_transport?(transport_type) @transport == transport_type end |
#validate! ⇒ Object (private)
420 421 422 423 424 425 |
# File 'lib/a2a/types/agent_card.rb', line 420 def validate! validate_required(:transport, :url) validate_inclusion(:transport, VALID_TRANSPORTS) validate_type(:url, String) validate_url_format end |
#validate_url_format ⇒ Object (private)
Validate URL format
429 430 431 432 433 434 |
# File 'lib/a2a/types/agent_card.rb', line 429 def validate_url_format uri = URI.parse(@url) raise ArgumentError, "url must be a valid HTTP or HTTPS URL" unless uri.is_a?(URI::HTTP) || uri.is_a?(URI::HTTPS) rescue URI::InvalidURIError raise ArgumentError, "url must be a valid URL" end |