ConfigStore

A Ruby ConfigStore client implementation.

Installation

Add this line to your application's Gemfile:

gem 'configstore'

And then execute:

$ bundle

Or install it yourself as:

$ gem install configstore

Usage

You can initialize a new Client for ConfigStore using

client = ConfigStore::Client.new(token: <your_token_secret>, base_url: <gifnoc_server_url>)

The Client has 4 main components:

  • Accounts
  • Namespaces
  • Records
  • Tokens

Accounts

Accounts are the top level entity in ConfigStore. It’s used to isolate different users of the system, making ConfigStore safely multi-tenanted. Only the admin account can perform account operations.

The following operations are supported:

  accounts = client.list_accounts # list all accounts, returns an array of ConfigStore::Account
  ,  = client. # create an account, returns an array with two entries, the ConfigStore::Account, and the associated ConfigStore::Token
   = client.() # get a specific account, returns ConfigStore::Account
  client.() # delete an account

Namespaces

Records are namespaced to allow a degree of separation between different users of the system within a single account. Access to namespaces is not regulated (like accounts).

The following operations are supported:

  namespaces = client.list_namespaces # list all namespaces, returns an array of ConfigStore::Namespace
  namespace = client.create_namespace(new_namespace) # create a namespace, returns a ConfigStore::Namespace
  namespace = client.get_namespace(namespace_uuid) # get a specific namespace, returns ConfigStore::Namespace
  namespace = client.update_namespace(namespace_uuid, new_namespace) # update an existing namespace, returns a ConfigStore::Namespace
  client.delete_namespace(namespace_uuid) # delete a namespace

Records

A single configuration item. A Record holds the following attributes: key, raw_value, uuid, metadata, created_at, updated_at, last_access. When you create a new instance of Record you can specify the Base64 encoded raw_value directly, or use the value= setter method that will encode the value for you.

The following operations are supported:

  records = client.list_records(namespace_uuid) # list all the records of a namespace, returns an array of ConfigStore::Record
  record = client.create_record(namespace_uuid, new_record) # create a record inside a namespace, returns a ConfigStore::Record
  record = client.get_record(namespace_uuid, record_key) # get a specific record, returns ConfigStore::Record
  record = client.update_record(namespace_uuid, record_key, new_record) # update an existing record inside a namespace, returns a ConfigStore::Record
  client.delete_record(namespace_uuid, record_key) # delete a record from a namespace

Tokens

Accounts are identified by tokens. An account can have many tokens. Tokens can have expiry dates and are identified with a UUID. Callers to the ConfigStore API will use a token’s secret in the call to identify themselves.

The following operations are supported:

  tokens = client.list_tokens # list all tokens, returns an array of ConfigStore::Token
  token = client.create_token(new_token) # create a token, returns a ConfigStore::Token
  token = client.get_token(token_uuid) # get a specific token, returns ConfigStore::Token
  token = client.update_token(token_uuid, new_token) # update an existing token, returns a ConfigStore::Token
  client.delete_token(token_uuid) # delete a token

Development

After checking out the repo, run bin/setup to install dependencies. Then, run rake test to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.

To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, and then run bundle exec rake release, which will create a git tag for the version, push git commits and tags, and push the .gem file to rubygems.org.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/cloud66-oss/configstore-ruby.

License

The gem is available as open source under the terms of the Apache 2.0 License.