azure_app_config 1.0 → 1.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ca31d8def3eb4908170c40b02bcf288cb3ba1a6d27d1be782c18e47e1065d468
4
- data.tar.gz: e41cff20281b14a61eec5374eeea7f03db5deb9cd1d51cfc36c16e081509feee
3
+ metadata.gz: e62c425fc7ab56bcabb477aad0b2d4a4e1b4b91e966ebb0887a93815d76c00ea
4
+ data.tar.gz: bcba151efadc9ca4f64bc3c42dd8750ffbf5a0fb54ff95ee3bcc63f7cec318ed
5
5
  SHA512:
6
- metadata.gz: 301e730cc2910c2af53ce757aaedc10de4d39a7e441653d243388d0a66916149378096a0672515cd964b153b909f5c17c83bba1bf40925714f1fb1040f661fba
7
- data.tar.gz: 6ce71b81c891c4124591285ff9e3360a5dffa0cf3f5fd6f989ca7d1550aae095e0f00b608d9e9ea00285c21794fe28e0409a075df6cbd1020d74600067e9c36c
6
+ metadata.gz: 7e826927fdfff3b95edf8fb2ad0f407eb7fb488ea3511b3cc31d6c8bd79b06f4dfa8bdc3f41368ec5454faa38bc171385cffed486ad90c08f501a473e766ac76
7
+ data.tar.gz: b4d116a20c8bf561dd053b7acdfb891a700cf46650a1bcc45604cc1a2d6716c28ff2d9a6cbdd89d000acdb1e3e33963b72d4363a972b943df274e1a1622e578d
data/README.md CHANGED
@@ -1,34 +1,81 @@
1
1
  # AzureAppConfig
2
2
 
3
- TODO: Delete this and the text below, and describe your gem
4
-
5
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/azure_app_config`. To experiment with that code, run `bin/console` for an interactive prompt.
3
+ An unofficial Ruby library for Azure App Configuration.
6
4
 
7
5
  ## Installation
8
6
 
9
- TODO: Replace `UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG` with your gem name right after releasing it to RubyGems.org. Please do not do it earlier due to security reasons. Alternatively, replace this section with instructions to install your gem from git if you don't plan to release to RubyGems.org.
10
-
11
7
  Install the gem and add to the application's Gemfile by executing:
12
8
 
13
- $ bundle add UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG
9
+ $ bundle add azure_app_config
14
10
 
15
11
  If bundler is not being used to manage dependencies, install the gem by executing:
16
12
 
17
- $ gem install UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG
13
+ $ gem install azure_app_config
18
14
 
19
15
  ## Usage
20
16
 
21
- TODO: Write usage instructions here
17
+ ### Setup
18
+
19
+ You'll need to first set up some environment variables in order to use the gem.
20
+
21
+ ```ENV
22
+ 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)
23
+ AZURE_APP_CONFIG_CREDENTIAL = "Id" // The credential (ID) to use. (Find this in App Configuration > Settings > Access Keys).
24
+ AZURE_APP_CONFIG_SECRET = "some_secret" // The secret to use. (Find this in App Configuration > Settings > Access Keys).
25
+ AZURE_APP_CONFIG_API_VERSION = "1.0" // The API version to use. Defaults to 1.0.
26
+ AZURE_APP_CONFIG_KEY_PREFIX = ".appconfig.featureflag/" // The key prefix to use. Defaults to ".appconfig.featureflag/"
27
+ ```
28
+
29
+ ### Examples
30
+
31
+ ```ruby
32
+ require "azure_app_config"
33
+
34
+ # Fetch all keys
35
+
36
+ AzureAppConfig::Base.keys # => ["key1", "key2", "key3", "key4", "key12"]
37
+ AzureAppConfig::Base.keys(name: ["key1", "key2"]) # => ["key1", "key2"]
38
+ AzureAppConfig::Base.keys(name: "key1*") # => ["key1", "key12"]
39
+
40
+ # Fetch a single key-value pair
41
+
42
+ AzureAppConfig::Base.fetch("key1") # => { etag: "...", id: ".appconfig.featureflag/key1", label: nil, value: { enabled: true, ...}, ...}
43
+ AzureAppConfig::Base.fetch("key1", label: 'prod') # => { etag: "...", id: ".appconfig.featureflag/key1", label: "prod", value: { enabled: true, ...}, ...}
44
+ AzureAppConfig::Base.fetch("non_existent", label: 'prod') # => AzureAppConfig::NotFoundError
45
+
46
+ # Fetches all key-value pairs
47
+
48
+ AzureAppConfig::Base.all # => [{ etag: "...", id: ".appconfig.featureflag/key1", label: nil, value: { enabled: true, ...}, ...}, { etag: "...", id: ".appconfig.featureflag/key2", label: nil, value: { enabled: true, ...}, ...}, ...]
49
+ AzureAppConfig::Base.all(name: "key1*") # => [{ etag: "...", id: ".appconfig.featureflag/key1", label: nil, value: { enabled: true, ...}, ...}, ...]
50
+ 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, ...}, ...}, ...]
51
+ 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, ...}, ...}, ...]
52
+
53
+ # Fetches all labels
54
+ AzureAppConfig::Base.labels # => [null, "prod", "test"] # null indicates the default (blank) label.
55
+ AzureAppConfig::Base.labels(name: "p*") # => ["prod"]
56
+ AzureAppConfig::Base.labels(name: ["prod", "test"]) # => ["prod", "test"]
57
+
58
+
59
+ # Check if a key is enabled
60
+
61
+ AzureAppConfig::Base.enabled?("key1") # => true
62
+ AzureAppConfig::Base.enabled?("key2", label: 'prod') # => false (even if the key is non-existent)
63
+
64
+ # Check if a key is disabled
65
+
66
+ AzureAppConfig::Base.disabled?("key1") # => false
67
+ AzureAppConfig::Base.disabled?("key2", label: 'prod') # => true (even if the key is non-existent)
68
+ ```
22
69
 
23
70
  ## Development
24
71
 
25
72
  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.
26
73
 
27
- 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 the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
74
+ To install this gem onto your local machine, run `bundle exec rake install`.
28
75
 
29
76
  ## Contributing
30
77
 
31
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/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](https://github.com/[USERNAME]/azure_app_config/blob/master/CODE_OF_CONDUCT.md).
78
+ 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](https://github.com/shettytejas/azure_app_config/blob/master/CODE_OF_CONDUCT.md).
32
79
 
33
80
  ## License
34
81
 
@@ -36,4 +83,4 @@ The gem is available as open source under the terms of the [MIT License](https:/
36
83
 
37
84
  ## Code of Conduct
38
85
 
39
- Everyone interacting in the AzureAppConfig project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/azure_app_config/blob/master/CODE_OF_CONDUCT.md).
86
+ Everyone interacting in the AzureAppConfig project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/shettytejas/azure_app_config/blob/master/CODE_OF_CONDUCT.md).
@@ -0,0 +1,51 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://inbox.azconfig.io/labels?api-version=1.0&name=prod,test
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ X-Ms-Date:
11
+ - Tue, 09 Jan 2024 18:07:42 GMT
12
+ X-Ms-Content-Sha256:
13
+ - 47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU=
14
+ Authorization:
15
+ - HMAC-SHA256 Credential=TjvF&SignedHeaders=x-ms-date;host;x-ms-content-sha256&Signature=BT7vCF9rfrZpCsRXR7m2QyQxWhq0q92nlIJgujpTuPM=
16
+ Accept-Encoding:
17
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
18
+ Accept:
19
+ - "*/*"
20
+ User-Agent:
21
+ - Ruby
22
+ Host:
23
+ - inbox.azconfig.io
24
+ response:
25
+ status:
26
+ code: 200
27
+ message: OK
28
+ headers:
29
+ Date:
30
+ - Tue, 09 Jan 2024 18:07:42 GMT
31
+ Content-Type:
32
+ - application/vnd.microsoft.appconfig.labelset+json; charset=utf-8
33
+ Transfer-Encoding:
34
+ - chunked
35
+ Connection:
36
+ - keep-alive
37
+ Sync-Token:
38
+ - zAJw6V16=NjoxMyM1NDI0NTQ2;sn=5424546
39
+ X-Ms-Request-Id:
40
+ - 78a45bb3-131a-4128-882d-64afbd2a0da6
41
+ X-Ms-Correlation-Request-Id:
42
+ - 78a45bb3-131a-4128-882d-64afbd2a0da6
43
+ Strict-Transport-Security:
44
+ - max-age=31536000; includeSubDomains
45
+ Access-Control-Allow-Origin:
46
+ - "*"
47
+ body:
48
+ encoding: UTF-8
49
+ string: '{"items":[{"name":"prod"},{"name":"test"}]}'
50
+ recorded_at: Tue, 09 Jan 2024 18:07:42 GMT
51
+ recorded_with: VCR 6.2.0
@@ -0,0 +1,51 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://inbox.azconfig.io/labels?api-version=1.0&name=p*
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ X-Ms-Date:
11
+ - Tue, 09 Jan 2024 18:07:17 GMT
12
+ X-Ms-Content-Sha256:
13
+ - 47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU=
14
+ Authorization:
15
+ - HMAC-SHA256 Credential=TjvF&SignedHeaders=x-ms-date;host;x-ms-content-sha256&Signature=tZLdY/9jghuYIThY9JyEc5mQuPfI2pSiEfyjtAdhrr4=
16
+ Accept-Encoding:
17
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
18
+ Accept:
19
+ - "*/*"
20
+ User-Agent:
21
+ - Ruby
22
+ Host:
23
+ - inbox.azconfig.io
24
+ response:
25
+ status:
26
+ code: 200
27
+ message: OK
28
+ headers:
29
+ Date:
30
+ - Tue, 09 Jan 2024 18:07:17 GMT
31
+ Content-Type:
32
+ - application/vnd.microsoft.appconfig.labelset+json; charset=utf-8
33
+ Transfer-Encoding:
34
+ - chunked
35
+ Connection:
36
+ - keep-alive
37
+ Sync-Token:
38
+ - zAJw6V16=NjoxMyM1NDI0NTQ2;sn=5424546
39
+ X-Ms-Request-Id:
40
+ - 17520fc2-db00-4a52-8e1e-1ca89c30ce32
41
+ X-Ms-Correlation-Request-Id:
42
+ - 17520fc2-db00-4a52-8e1e-1ca89c30ce32
43
+ Strict-Transport-Security:
44
+ - max-age=31536000; includeSubDomains
45
+ Access-Control-Allow-Origin:
46
+ - "*"
47
+ body:
48
+ encoding: UTF-8
49
+ string: '{"items":[{"name":"prod"}]}'
50
+ recorded_at: Tue, 09 Jan 2024 18:07:17 GMT
51
+ recorded_with: VCR 6.2.0
@@ -0,0 +1,51 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://inbox.azconfig.io/labels?api-version=1.0&name=*
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ X-Ms-Date:
11
+ - Tue, 09 Jan 2024 18:03:48 GMT
12
+ X-Ms-Content-Sha256:
13
+ - 47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU=
14
+ Authorization:
15
+ - HMAC-SHA256 Credential=TjvF&SignedHeaders=x-ms-date;host;x-ms-content-sha256&Signature=N9CYXeOBBH17GWPlFtWGDYvMSocSlHH6uMTVZZ+CbnE=
16
+ Accept-Encoding:
17
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
18
+ Accept:
19
+ - "*/*"
20
+ User-Agent:
21
+ - Ruby
22
+ Host:
23
+ - inbox.azconfig.io
24
+ response:
25
+ status:
26
+ code: 200
27
+ message: OK
28
+ headers:
29
+ Date:
30
+ - Tue, 09 Jan 2024 18:03:49 GMT
31
+ Content-Type:
32
+ - application/vnd.microsoft.appconfig.labelset+json; charset=utf-8
33
+ Transfer-Encoding:
34
+ - chunked
35
+ Connection:
36
+ - keep-alive
37
+ Sync-Token:
38
+ - zAJw6V16=NjoxMyM1NDI0NTQ2;sn=5424546
39
+ X-Ms-Request-Id:
40
+ - 59a9f83f-cd5d-48d9-9e55-d8740c3fc7c0
41
+ X-Ms-Correlation-Request-Id:
42
+ - 59a9f83f-cd5d-48d9-9e55-d8740c3fc7c0
43
+ Strict-Transport-Security:
44
+ - max-age=31536000; includeSubDomains
45
+ Access-Control-Allow-Origin:
46
+ - "*"
47
+ body:
48
+ encoding: UTF-8
49
+ string: '{"items":[{"name":null},{"name":"prod"},{"name":"test"}]}'
50
+ recorded_at: Tue, 09 Jan 2024 18:03:49 GMT
51
+ recorded_with: VCR 6.2.0
@@ -37,6 +37,14 @@ module AzureAppConfig
37
37
  parse_fetch_response response
38
38
  end
39
39
 
40
+ def labels(name: nil)
41
+ name, = normalise_parameters(name: name, label: nil)
42
+ path = "/labels"
43
+
44
+ query_params = URI.encode_www_form(name: name.join(","))
45
+ parse_labels_response client.get(path, query_params)
46
+ end
47
+
40
48
  def keys(name: nil)
41
49
  name, = normalise_parameters(name: name, label: nil)
42
50
  path = "/keys"
@@ -120,5 +128,9 @@ module AzureAppConfig
120
128
  data = JSON.parse(response.body)
121
129
  data["items"].map { |item| item["name"].gsub(key_prefix, "") }
122
130
  end
131
+
132
+ def parse_labels_response(response)
133
+ JSON.parse(response.body)["items"].map { |item| item["name"] }
134
+ end
123
135
  end
124
136
  end
@@ -3,7 +3,7 @@
3
3
  require_relative "azure_app_config/base"
4
4
 
5
5
  module AzureAppConfig
6
- VERSION = "1.0"
6
+ VERSION = "1.1.1"
7
7
 
8
8
  class InvalidTypeError < StandardError; end
9
9
  class ExceededLimitError < StandardError; end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: azure_app_config
3
3
  version: !ruby/object:Gem::Version
4
- version: '1.0'
4
+ version: 1.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tejas Shetty
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-01-09 00:00:00.000000000 Z
11
+ date: 2024-05-19 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: An unofficial Azure App Configuration API Client written in Ruby.
14
14
  email:
@@ -38,6 +38,9 @@ files:
38
38
  - fixtures/vcr_cassettes/keys/with_name_param_as_array.yml
39
39
  - fixtures/vcr_cassettes/keys/with_name_param_as_string.yml
40
40
  - fixtures/vcr_cassettes/keys/without_name_param.yml
41
+ - fixtures/vcr_cassettes/labels/with_name_param_as_array.yml
42
+ - fixtures/vcr_cassettes/labels/with_name_param_as_string.yml
43
+ - fixtures/vcr_cassettes/labels/without_name_param.yml
41
44
  - lib/azure_app_config.rb
42
45
  - lib/azure_app_config/base.rb
43
46
  - lib/azure_app_config/client.rb