Class: RubyLLM::MCP::Auth::ClientInfo
- Inherits:
-
Object
- Object
- RubyLLM::MCP::Auth::ClientInfo
- Defined in:
- lib/ruby_llm/mcp/auth.rb
Overview
Registered client information from authorization server
Instance Attribute Summary collapse
-
#client_id ⇒ Object
readonly
Returns the value of attribute client_id.
-
#client_id_issued_at ⇒ Object
readonly
Returns the value of attribute client_id_issued_at.
-
#client_secret ⇒ Object
readonly
Returns the value of attribute client_secret.
-
#client_secret_expires_at ⇒ Object
readonly
Returns the value of attribute client_secret_expires_at.
-
#metadata ⇒ Object
readonly
Returns the value of attribute metadata.
Class Method Summary collapse
-
.from_h(data) ⇒ ClientInfo
Deserialize from hash.
Instance Method Summary collapse
-
#client_secret_expired? ⇒ Boolean
Check if client secret has expired.
-
#initialize(client_id:, client_secret: nil, client_id_issued_at: nil, client_secret_expires_at: nil, metadata: nil) ⇒ ClientInfo
constructor
A new instance of ClientInfo.
-
#to_h ⇒ Hash
Serialize to hash.
Constructor Details
#initialize(client_id:, client_secret: nil, client_id_issued_at: nil, client_secret_expires_at: nil, metadata: nil) ⇒ ClientInfo
Returns a new instance of ClientInfo.
165 166 167 168 169 170 171 172 |
# File 'lib/ruby_llm/mcp/auth.rb', line 165 def initialize(client_id:, client_secret: nil, client_id_issued_at: nil, client_secret_expires_at: nil, metadata: nil) @client_id = client_id @client_secret = client_secret @client_id_issued_at = client_id_issued_at @client_secret_expires_at = client_secret_expires_at @metadata = end |
Instance Attribute Details
#client_id ⇒ Object (readonly)
Returns the value of attribute client_id.
163 164 165 |
# File 'lib/ruby_llm/mcp/auth.rb', line 163 def client_id @client_id end |
#client_id_issued_at ⇒ Object (readonly)
Returns the value of attribute client_id_issued_at.
163 164 165 |
# File 'lib/ruby_llm/mcp/auth.rb', line 163 def client_id_issued_at @client_id_issued_at end |
#client_secret ⇒ Object (readonly)
Returns the value of attribute client_secret.
163 164 165 |
# File 'lib/ruby_llm/mcp/auth.rb', line 163 def client_secret @client_secret end |
#client_secret_expires_at ⇒ Object (readonly)
Returns the value of attribute client_secret_expires_at.
163 164 165 |
# File 'lib/ruby_llm/mcp/auth.rb', line 163 def client_secret_expires_at @client_secret_expires_at end |
#metadata ⇒ Object (readonly)
Returns the value of attribute metadata.
163 164 165 |
# File 'lib/ruby_llm/mcp/auth.rb', line 163 def @metadata end |
Class Method Details
.from_h(data) ⇒ ClientInfo
Deserialize from hash
197 198 199 200 201 202 203 204 205 206 207 208 209 210 |
# File 'lib/ruby_llm/mcp/auth.rb', line 197 def self.from_h(data) = data[:metadata] || data["metadata"] = if ClientMetadata.new(**.transform_keys(&:to_sym)) end new( client_id: data[:client_id] || data["client_id"], client_secret: data[:client_secret] || data["client_secret"], client_id_issued_at: data[:client_id_issued_at] || data["client_id_issued_at"], client_secret_expires_at: data[:client_secret_expires_at] || data["client_secret_expires_at"], metadata: ) end |
Instance Method Details
#client_secret_expired? ⇒ Boolean
Check if client secret has expired
176 177 178 179 180 |
# File 'lib/ruby_llm/mcp/auth.rb', line 176 def client_secret_expired? return false unless @client_secret_expires_at Time.now.to_i >= @client_secret_expires_at end |
#to_h ⇒ Hash
Serialize to hash
184 185 186 187 188 189 190 191 192 |
# File 'lib/ruby_llm/mcp/auth.rb', line 184 def to_h { client_id: @client_id, client_secret: @client_secret, client_id_issued_at: @client_id_issued_at, client_secret_expires_at: @client_secret_expires_at, metadata: @metadata&.to_h } end |