Class: E3DB::Config
- Inherits:
-
Dry::Struct
- Object
- Dry::Struct
- E3DB::Config
- Defined in:
- lib/e3db/config.rb
Overview
Configuration and credentials for E3DB.
Typically a configuration is loaded from a JSON file generated during registration via the E3DB administration console or command-line tool. To load a configuration from a JSON file, use Config.load.
Instance Attribute Summary collapse
-
#api_base_url ⇒ String
The base URL for the E3DB API service.
-
#api_key_id ⇒ String
The client's non-secret API key component.
-
#api_secret ⇒ String
The client's confidential API key component.
-
#auth_base_url ⇒ String
The base URL for the E3DB authentication service.
-
#client_id ⇒ String
The client's unique client identifier.
-
#logging ⇒ Boolean
Warning: Log output will contain confidential authentication tokens---do not enable in production if log output isn't confidential!.
-
#private_key ⇒ String
The client's Base64URL encoded Curve25519 private key.
-
#public_key ⇒ String
The client's Base64URL encoded Curve25519 public key.
-
#version ⇒ Int
The version number of the configuration format (currently 1).
Class Method Summary collapse
- .default ⇒ Object
-
.load(filename) ⇒ Config
Load configuration from a JSON file created during registration or with save.
- .load_profile(profile) ⇒ Object
Instance Attribute Details
#api_base_url ⇒ String
Returns the base URL for the E3DB API service.
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/e3db/config.rb', line 39 class Config < Dry::Struct attribute :version, Types::Int attribute :client_id, Types::String attribute :api_key_id, Types::String attribute :api_secret, Types::String attribute :public_key, Types::String attribute :private_key, Types::String attribute :api_url, Types::String.default(DEFAULT_API_URL) attribute :logging, Types::Bool # Load configuration from a JSON file created during registration # or with {E3DB::Config.save}. # # The configuration file should contain a single JSON object # with the following structure: # # { # "version": 1, # "client_id": "UUID", # "api_key_id": "API_KEY", # "api_secret": "API_SECRET", # "public_key": "PUBLIC_KEY", # "private_key": "PRIVATE_KEY", # "api_url": "URL", # } # # @param filename [String] pathname of JSON configuration to load # @return [Config] the configuration object loaded from the file def self.load(filename) json = JSON.parse(File.read(filename), symbolize_names: true) if json[:version] != 1 raise StandardError, "Unsupported config version: #{json[:version]}" end Config.new(json.merge(:logging => false)) end def self.default return self.load(File.join(Dir.home, '.tozny', 'e3db.json')) end def self.load_profile(profile) return self.load(File.join(Dir.home, '.tozny', profile, 'e3db.json')) end def logging=(value) @logging = value end end |
#api_key_id ⇒ String
Returns the client's non-secret API key component.
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/e3db/config.rb', line 39 class Config < Dry::Struct attribute :version, Types::Int attribute :client_id, Types::String attribute :api_key_id, Types::String attribute :api_secret, Types::String attribute :public_key, Types::String attribute :private_key, Types::String attribute :api_url, Types::String.default(DEFAULT_API_URL) attribute :logging, Types::Bool # Load configuration from a JSON file created during registration # or with {E3DB::Config.save}. # # The configuration file should contain a single JSON object # with the following structure: # # { # "version": 1, # "client_id": "UUID", # "api_key_id": "API_KEY", # "api_secret": "API_SECRET", # "public_key": "PUBLIC_KEY", # "private_key": "PRIVATE_KEY", # "api_url": "URL", # } # # @param filename [String] pathname of JSON configuration to load # @return [Config] the configuration object loaded from the file def self.load(filename) json = JSON.parse(File.read(filename), symbolize_names: true) if json[:version] != 1 raise StandardError, "Unsupported config version: #{json[:version]}" end Config.new(json.merge(:logging => false)) end def self.default return self.load(File.join(Dir.home, '.tozny', 'e3db.json')) end def self.load_profile(profile) return self.load(File.join(Dir.home, '.tozny', profile, 'e3db.json')) end def logging=(value) @logging = value end end |
#api_secret ⇒ String
Returns the client's confidential API key component.
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/e3db/config.rb', line 39 class Config < Dry::Struct attribute :version, Types::Int attribute :client_id, Types::String attribute :api_key_id, Types::String attribute :api_secret, Types::String attribute :public_key, Types::String attribute :private_key, Types::String attribute :api_url, Types::String.default(DEFAULT_API_URL) attribute :logging, Types::Bool # Load configuration from a JSON file created during registration # or with {E3DB::Config.save}. # # The configuration file should contain a single JSON object # with the following structure: # # { # "version": 1, # "client_id": "UUID", # "api_key_id": "API_KEY", # "api_secret": "API_SECRET", # "public_key": "PUBLIC_KEY", # "private_key": "PRIVATE_KEY", # "api_url": "URL", # } # # @param filename [String] pathname of JSON configuration to load # @return [Config] the configuration object loaded from the file def self.load(filename) json = JSON.parse(File.read(filename), symbolize_names: true) if json[:version] != 1 raise StandardError, "Unsupported config version: #{json[:version]}" end Config.new(json.merge(:logging => false)) end def self.default return self.load(File.join(Dir.home, '.tozny', 'e3db.json')) end def self.load_profile(profile) return self.load(File.join(Dir.home, '.tozny', profile, 'e3db.json')) end def logging=(value) @logging = value end end |
#auth_base_url ⇒ String
Returns the base URL for the E3DB authentication service.
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/e3db/config.rb', line 39 class Config < Dry::Struct attribute :version, Types::Int attribute :client_id, Types::String attribute :api_key_id, Types::String attribute :api_secret, Types::String attribute :public_key, Types::String attribute :private_key, Types::String attribute :api_url, Types::String.default(DEFAULT_API_URL) attribute :logging, Types::Bool # Load configuration from a JSON file created during registration # or with {E3DB::Config.save}. # # The configuration file should contain a single JSON object # with the following structure: # # { # "version": 1, # "client_id": "UUID", # "api_key_id": "API_KEY", # "api_secret": "API_SECRET", # "public_key": "PUBLIC_KEY", # "private_key": "PRIVATE_KEY", # "api_url": "URL", # } # # @param filename [String] pathname of JSON configuration to load # @return [Config] the configuration object loaded from the file def self.load(filename) json = JSON.parse(File.read(filename), symbolize_names: true) if json[:version] != 1 raise StandardError, "Unsupported config version: #{json[:version]}" end Config.new(json.merge(:logging => false)) end def self.default return self.load(File.join(Dir.home, '.tozny', 'e3db.json')) end def self.load_profile(profile) return self.load(File.join(Dir.home, '.tozny', profile, 'e3db.json')) end def logging=(value) @logging = value end end |
#client_id ⇒ String
Returns the client's unique client identifier.
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/e3db/config.rb', line 39 class Config < Dry::Struct attribute :version, Types::Int attribute :client_id, Types::String attribute :api_key_id, Types::String attribute :api_secret, Types::String attribute :public_key, Types::String attribute :private_key, Types::String attribute :api_url, Types::String.default(DEFAULT_API_URL) attribute :logging, Types::Bool # Load configuration from a JSON file created during registration # or with {E3DB::Config.save}. # # The configuration file should contain a single JSON object # with the following structure: # # { # "version": 1, # "client_id": "UUID", # "api_key_id": "API_KEY", # "api_secret": "API_SECRET", # "public_key": "PUBLIC_KEY", # "private_key": "PRIVATE_KEY", # "api_url": "URL", # } # # @param filename [String] pathname of JSON configuration to load # @return [Config] the configuration object loaded from the file def self.load(filename) json = JSON.parse(File.read(filename), symbolize_names: true) if json[:version] != 1 raise StandardError, "Unsupported config version: #{json[:version]}" end Config.new(json.merge(:logging => false)) end def self.default return self.load(File.join(Dir.home, '.tozny', 'e3db.json')) end def self.load_profile(profile) return self.load(File.join(Dir.home, '.tozny', profile, 'e3db.json')) end def logging=(value) @logging = value end end |
#logging ⇒ Boolean
Warning: Log output will contain confidential authentication tokens---do not enable in production if log output isn't confidential!
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/e3db/config.rb', line 39 class Config < Dry::Struct attribute :version, Types::Int attribute :client_id, Types::String attribute :api_key_id, Types::String attribute :api_secret, Types::String attribute :public_key, Types::String attribute :private_key, Types::String attribute :api_url, Types::String.default(DEFAULT_API_URL) attribute :logging, Types::Bool # Load configuration from a JSON file created during registration # or with {E3DB::Config.save}. # # The configuration file should contain a single JSON object # with the following structure: # # { # "version": 1, # "client_id": "UUID", # "api_key_id": "API_KEY", # "api_secret": "API_SECRET", # "public_key": "PUBLIC_KEY", # "private_key": "PRIVATE_KEY", # "api_url": "URL", # } # # @param filename [String] pathname of JSON configuration to load # @return [Config] the configuration object loaded from the file def self.load(filename) json = JSON.parse(File.read(filename), symbolize_names: true) if json[:version] != 1 raise StandardError, "Unsupported config version: #{json[:version]}" end Config.new(json.merge(:logging => false)) end def self.default return self.load(File.join(Dir.home, '.tozny', 'e3db.json')) end def self.load_profile(profile) return self.load(File.join(Dir.home, '.tozny', profile, 'e3db.json')) end def logging=(value) @logging = value end end |
#private_key ⇒ String
Returns the client's Base64URL encoded Curve25519 private key.
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/e3db/config.rb', line 39 class Config < Dry::Struct attribute :version, Types::Int attribute :client_id, Types::String attribute :api_key_id, Types::String attribute :api_secret, Types::String attribute :public_key, Types::String attribute :private_key, Types::String attribute :api_url, Types::String.default(DEFAULT_API_URL) attribute :logging, Types::Bool # Load configuration from a JSON file created during registration # or with {E3DB::Config.save}. # # The configuration file should contain a single JSON object # with the following structure: # # { # "version": 1, # "client_id": "UUID", # "api_key_id": "API_KEY", # "api_secret": "API_SECRET", # "public_key": "PUBLIC_KEY", # "private_key": "PRIVATE_KEY", # "api_url": "URL", # } # # @param filename [String] pathname of JSON configuration to load # @return [Config] the configuration object loaded from the file def self.load(filename) json = JSON.parse(File.read(filename), symbolize_names: true) if json[:version] != 1 raise StandardError, "Unsupported config version: #{json[:version]}" end Config.new(json.merge(:logging => false)) end def self.default return self.load(File.join(Dir.home, '.tozny', 'e3db.json')) end def self.load_profile(profile) return self.load(File.join(Dir.home, '.tozny', profile, 'e3db.json')) end def logging=(value) @logging = value end end |
#public_key ⇒ String
Returns the client's Base64URL encoded Curve25519 public key.
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/e3db/config.rb', line 39 class Config < Dry::Struct attribute :version, Types::Int attribute :client_id, Types::String attribute :api_key_id, Types::String attribute :api_secret, Types::String attribute :public_key, Types::String attribute :private_key, Types::String attribute :api_url, Types::String.default(DEFAULT_API_URL) attribute :logging, Types::Bool # Load configuration from a JSON file created during registration # or with {E3DB::Config.save}. # # The configuration file should contain a single JSON object # with the following structure: # # { # "version": 1, # "client_id": "UUID", # "api_key_id": "API_KEY", # "api_secret": "API_SECRET", # "public_key": "PUBLIC_KEY", # "private_key": "PRIVATE_KEY", # "api_url": "URL", # } # # @param filename [String] pathname of JSON configuration to load # @return [Config] the configuration object loaded from the file def self.load(filename) json = JSON.parse(File.read(filename), symbolize_names: true) if json[:version] != 1 raise StandardError, "Unsupported config version: #{json[:version]}" end Config.new(json.merge(:logging => false)) end def self.default return self.load(File.join(Dir.home, '.tozny', 'e3db.json')) end def self.load_profile(profile) return self.load(File.join(Dir.home, '.tozny', profile, 'e3db.json')) end def logging=(value) @logging = value end end |
#version ⇒ Int
Returns the version number of the configuration format (currently 1).
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/e3db/config.rb', line 39 class Config < Dry::Struct attribute :version, Types::Int attribute :client_id, Types::String attribute :api_key_id, Types::String attribute :api_secret, Types::String attribute :public_key, Types::String attribute :private_key, Types::String attribute :api_url, Types::String.default(DEFAULT_API_URL) attribute :logging, Types::Bool # Load configuration from a JSON file created during registration # or with {E3DB::Config.save}. # # The configuration file should contain a single JSON object # with the following structure: # # { # "version": 1, # "client_id": "UUID", # "api_key_id": "API_KEY", # "api_secret": "API_SECRET", # "public_key": "PUBLIC_KEY", # "private_key": "PRIVATE_KEY", # "api_url": "URL", # } # # @param filename [String] pathname of JSON configuration to load # @return [Config] the configuration object loaded from the file def self.load(filename) json = JSON.parse(File.read(filename), symbolize_names: true) if json[:version] != 1 raise StandardError, "Unsupported config version: #{json[:version]}" end Config.new(json.merge(:logging => false)) end def self.default return self.load(File.join(Dir.home, '.tozny', 'e3db.json')) end def self.load_profile(profile) return self.load(File.join(Dir.home, '.tozny', profile, 'e3db.json')) end def logging=(value) @logging = value end end |
Class Method Details
.default ⇒ Object
75 76 77 |
# File 'lib/e3db/config.rb', line 75 def self.default return self.load(File.join(Dir.home, '.tozny', 'e3db.json')) end |
.load(filename) ⇒ Config
Load configuration from a JSON file created during registration or with save.
The configuration file should contain a single JSON object with the following structure:
{ "version": 1, "client_id": "UUID", "api_key_id": "API_KEY", "api_secret": "API_SECRET", "public_key": "PUBLIC_KEY", "private_key": "PRIVATE_KEY", "api_url": "URL", }
67 68 69 70 71 72 73 |
# File 'lib/e3db/config.rb', line 67 def self.load(filename) json = JSON.parse(File.read(filename), symbolize_names: true) if json[:version] != 1 raise StandardError, "Unsupported config version: #{json[:version]}" end Config.new(json.merge(:logging => false)) end |
.load_profile(profile) ⇒ Object
79 80 81 |
# File 'lib/e3db/config.rb', line 79 def self.load_profile(profile) return self.load(File.join(Dir.home, '.tozny', profile, 'e3db.json')) end |