Class: A2A::Types::SecurityScheme
- Defined in:
- lib/a2a/types/security.rb
Overview
Base class for security schemes (discriminated union)
Security schemes define how authentication and authorization should be handled for agent interactions.
Direct Known Subclasses
ApiKeySecurityScheme, HttpSecurityScheme, MutualTlsSecurityScheme, OAuth2SecurityScheme, OpenIdConnectSecurityScheme
Instance Attribute Summary collapse
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Class Method Summary collapse
-
.from_h(hash) ⇒ SecurityScheme
Create a security scheme from a hash (factory method).
Instance Method Summary collapse
-
#initialize(type:) ⇒ SecurityScheme
constructor
protected
A new instance of SecurityScheme.
- #validate! ⇒ Object private
Methods inherited from BaseModel
#==, #camelize, from_json, #hash, #to_h, #to_json, underscore, #valid?, #validate_array_type, #validate_inclusion, #validate_required, #validate_type
Constructor Details
#initialize(type:) ⇒ SecurityScheme (protected)
Returns a new instance of SecurityScheme.
41 42 43 44 |
# File 'lib/a2a/types/security.rb', line 41 def initialize(type:) @type = type validate! end |
Instance Attribute Details
#type ⇒ Object (readonly)
Returns the value of attribute type.
12 13 14 |
# File 'lib/a2a/types/security.rb', line 12 def type @type end |
Class Method Details
.from_h(hash) ⇒ SecurityScheme
Create a security scheme from a hash (factory method)
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/a2a/types/security.rb', line 19 def self.from_h(hash) return nil if hash.nil? type = hash[:type] || hash["type"] case type when SECURITY_TYPE_API_KEY ApiKeySecurityScheme.from_h(hash) when SECURITY_TYPE_HTTP HttpSecurityScheme.from_h(hash) when SECURITY_TYPE_OAUTH2 OAuth2SecurityScheme.from_h(hash) when SECURITY_TYPE_OPENID_CONNECT OpenIdConnectSecurityScheme.from_h(hash) when SECURITY_TYPE_MUTUAL_TLS MutualTlsSecurityScheme.from_h(hash) else raise ArgumentError, "Unknown security scheme type: #{type}" end end |
Instance Method Details
#validate! ⇒ Object (private)
48 49 50 51 |
# File 'lib/a2a/types/security.rb', line 48 def validate! validate_required(:type) validate_inclusion(:type, VALID_SECURITY_TYPES) end |