GithubHelp home page GithubHelp logo

shettytejas / azure_app_config Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 0.0 30 KB

An unofficial Ruby library for Azure App Configuration.

Home Page: https://rubygems.org/gems/azure_app_config

License: MIT License

Ruby 99.33% Shell 0.67%
api-rest app-config azure wrapper-library ruby ruby-gem

azure_app_config's Introduction

AzureAppConfig

An unofficial Ruby library for Azure App Configuration.

Installation

Install the gem and add to the application's Gemfile by executing:

$ bundle add azure_app_config

If bundler is not being used to manage dependencies, install the gem by executing:

$ gem install azure_app_config

Usage

Setup

You'll need to first set up some environment variables in order to use the gem.

AZURE_APP_CONFIG_STORE_NAME = "somestore" // The name of the store to use. This would be used to build the url to the store (https://somestore.azconfig.io)
AZURE_APP_CONFIG_CREDENTIAL = "Id" // The credential (ID) to use. (Find this in App Configuration > Settings > Access Keys).
AZURE_APP_CONFIG_SECRET = "some_secret" // The secret to use. (Find this in App Configuration > Settings > Access Keys).
AZURE_APP_CONFIG_API_VERSION = "1.0" // The API version to use. Defaults to 1.0.
AZURE_APP_CONFIG_KEY_PREFIX = ".appconfig.featureflag/" // The key prefix to use. Defaults to ".appconfig.featureflag/"

Examples

require "azure_app_config"

# Fetch all keys

AzureAppConfig::Base.keys # => ["key1", "key2", "key3", "key4", "key12"]
AzureAppConfig::Base.keys(name: ["key1", "key2"]) # => ["key1", "key2"]
AzureAppConfig::Base.keys(name: "key1*") # => ["key1", "key12"]

# Fetch a single key-value pair

AzureAppConfig::Base.fetch("key1") # => { etag: "...", id: ".appconfig.featureflag/key1", label: nil, value: { enabled: true, ...}, ...}
AzureAppConfig::Base.fetch("key1", label: 'prod') # => { etag: "...", id: ".appconfig.featureflag/key1", label: "prod", value: { enabled: true, ...}, ...}
AzureAppConfig::Base.fetch("non_existent", label: 'prod') # => AzureAppConfig::NotFoundError

# Fetches all key-value pairs

AzureAppConfig::Base.all # => [{ etag: "...", id: ".appconfig.featureflag/key1", label: nil, value: { enabled: true, ...}, ...}, { etag: "...", id: ".appconfig.featureflag/key2", label: nil, value: { enabled: true, ...}, ...}, ...]
AzureAppConfig::Base.all(name: "key1*") # => [{ etag: "...", id: ".appconfig.featureflag/key1", label: nil, value: { enabled: true, ...}, ...}, ...]
AzureAppConfig::Base.all(name: "key1*", label: "prod") # => [{ etag: "...", id: ".appconfig.featureflag/key1", label: "prod", value: { enabled: true, ...}, ...}, { etag: "...", id: ".appconfig.featureflag/key12", label: "prod", value: { enabled: true, ...}, ...}, ...]
AzureAppConfig::Base.all(name: ["key1", "key2"], label: "prod") # => [{ etag: "...", id: ".appconfig.featureflag/key1", label: "prod", value: { enabled: true, ...}, ...}, { etag: "...", id: ".appconfig.featureflag/key2", label: "prod", value: { enabled: true, ...}, ...}, ...]

# Fetches all labels
AzureAppConfig::Base.labels # => [null, "prod", "test"] # null indicates the default (blank) label.
AzureAppConfig::Base.labels(name: "p*") # => ["prod"]
AzureAppConfig::Base.labels(name: ["prod", "test"]) # => ["prod", "test"]


# Check if a key is enabled

AzureAppConfig::Base.enabled?("key1") # => true
AzureAppConfig::Base.enabled?("key2", label: 'prod') # => false (even if the key is non-existent)

# Check if a key is disabled

AzureAppConfig::Base.disabled?("key1") # => false
AzureAppConfig::Base.disabled?("key2", label: 'prod') # => true (even if the key is non-existent)

Development

After checking out the repo, run bin/setup to install dependencies. Then, run rake spec 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.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/shettytejas/azure_app_config. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the code of conduct.

License

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

Code of Conduct

Everyone interacting in the AzureAppConfig project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.

azure_app_config's People

Contributors

shettytejas avatar

Stargazers

 avatar

Watchers

 avatar

azure_app_config's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.