Class: Momento::CredentialProvider
- Inherits:
-
Object
- Object
- Momento::CredentialProvider
- Defined in:
- lib/momento/auth/credential_provider.rb
Overview
Contains the information required for a Momento client to connect to and authenticate with Momento services.
Defined Under Namespace
Classes: AuthTokenData
Instance Attribute Summary collapse
-
#api_key ⇒ Object
readonly
Returns the value of attribute api_key.
-
#cache_endpoint ⇒ Object
readonly
Returns the value of attribute cache_endpoint.
-
#control_endpoint ⇒ Object
readonly
Returns the value of attribute control_endpoint.
Class Method Summary collapse
-
.from_env_var(env_var_name) ⇒ Momento::CredentialProvider
Creates a CredentialProvider from a Momento API key loaded from an environment variable.
-
.from_string(api_key) ⇒ Momento::CredentialProvider
Creates a CredentialProvider from a Momento API key.
Instance Attribute Details
#api_key ⇒ Object (readonly)
Returns the value of attribute api_key.
7 8 9 |
# File 'lib/momento/auth/credential_provider.rb', line 7 def api_key @api_key end |
#cache_endpoint ⇒ Object (readonly)
Returns the value of attribute cache_endpoint.
7 8 9 |
# File 'lib/momento/auth/credential_provider.rb', line 7 def cache_endpoint @cache_endpoint end |
#control_endpoint ⇒ Object (readonly)
Returns the value of attribute control_endpoint.
7 8 9 |
# File 'lib/momento/auth/credential_provider.rb', line 7 def control_endpoint @control_endpoint end |
Class Method Details
.from_env_var(env_var_name) ⇒ Momento::CredentialProvider
Creates a CredentialProvider from a Momento API key loaded from an environment variable.
13 14 15 16 17 18 |
# File 'lib/momento/auth/credential_provider.rb', line 13 def self.from_env_var(env_var_name) api_key = ENV.fetch(env_var_name) { raise Momento::Error::InvalidArgumentError, "Env var #{env_var_name} must be set" } new(api_key) end |
.from_string(api_key) ⇒ Momento::CredentialProvider
Creates a CredentialProvider from a Momento API key
24 25 26 27 28 |
# File 'lib/momento/auth/credential_provider.rb', line 24 def self.from_string(api_key) raise Momento::Error::InvalidArgumentError, 'Auth token string cannot be empty' if api_key.empty? new(api_key) end |