launchdarkly_api_helper 0.6.0 → 0.7.0

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: abb4c77aacd498e9201d80704cf76ace0ba1b212cb5c5b03048f7001b67a67e8
4
- data.tar.gz: ad9a07e50ecf11c8bb9c2fc83dc7fffef0d5a79b5ad4214e5827e6775b07be40
3
+ metadata.gz: cc0c1b25efd8bceafce66fca401b054433d58bd16057952a5af5454f71c723aa
4
+ data.tar.gz: 2366bb57ed059ea241df1488c3300fd2ccd2f7803a03a04dd90915c199f7fab4
5
5
  SHA512:
6
- metadata.gz: ab867dfc84d5a8cf1828efb1f195ce497456aac14ba46cecd71862cf5353c77c421d350ad4d44283dc114abf9e587e5792e86119037dc06f06eab35b8a2bc50c
7
- data.tar.gz: 6206c419f1eafd0095626e743b08aec2f98b4f16a2d39eac0861966dba002b5932473cbc379100e1d7877e53cf41abd23e9fc481cc42377cf4f33e13d321c5d0
6
+ metadata.gz: 31921892456f509b895c2119873daa5b6a9d8d566baacc6721f1e5b307d7413156e7100dd8a890606621433305ea43def942d86d0ab01fe98ef660febd55f51f
7
+ data.tar.gz: 8ed558e1a93bf0f3e1b42b17ea767f700436b73438aa48eb02de30598f0683c020f98a97172e39249a6c474a0cbcac7c85d806b47a4095c59cf336264b1cd985
data/README.md CHANGED
@@ -1,4 +1,12 @@
1
- # LaunchdarklyApiHelper ![alt_text](https://badge.fury.io/rb/launchdarkly_api_helper.svg)
1
+ # LaunchdarklyApiHelper
2
+ <div>
3
+ <a href="https://rubygems.org/gems/launchdarkly_api_helper">
4
+ <img alt="GEM Version" src="https://img.shields.io/gem/v/launchdarkly_api_helper?color=38C160&logo=ruby&logoColor=FE1616">
5
+ </a>
6
+ <a href="https://rubygems.org/gems/launchdarkly_api_helper">
7
+ <img alt="Gem Downloads" src="https://img.shields.io/gem/dt/launchdarkly_api_helper?color=38C160&logo=ruby&logoColor=FE1616">
8
+ </a>
9
+ </div>
2
10
 
3
11
  [LaunchDarklyApiHelper](https://rubygems.org/gems/launchdarkly_api_helper) provides you a way to access your [Launch Darkly](https://apidocs.launchdarkly.com/) account using [API token](https://app.launchdarkly.com/settings/authorization/tokens/new) to view, edit or delete them accordingly.
4
12
 
@@ -27,7 +35,7 @@ To perform any operations such as add, remove, replace, move, copy, test you sho
27
35
  ```ruby
28
36
  parameters:
29
37
  access_token (*required): this token will be used to send all requests to LaunchDarkly (string)
30
- project_name: provide project name of your organistaion (NOTE: for most, it should be `default` unless you have made some explicit changes)
38
+ project_name: provide project name of your organization (NOTE: for most, it should be `default` unless you have made some explicit changes)
31
39
  log_file: all logs will be written to file 'launchdarkly.log' by default if no file name specified (string)
32
40
 
33
41
  # set your LD API token and log file to capture logs
@@ -261,7 +269,8 @@ def ld_add_values_to_clause(env, flag, clause_name, clause_value)
261
269
  end
262
270
 
263
271
  @return parameter: (response of feature flag details)
264
- response = "https://app.launchdarkly.com/api/v2/flags/default/#{flag}?env=#{env}" (string)
272
+ response = "https://app.launchdarkly.com/api/v2/flags/default/#{flag}?env=#{env}"
273
+ response[rule_at_index]['clauses'][clause_at_index]['values'] (string)
265
274
  ```
266
275
 
267
276
  ```ruby
@@ -277,7 +286,8 @@ def ld_remove_values_from_clause(env, flag, clause_name, clause_value)
277
286
  end
278
287
 
279
288
  @return parameter: (response of feature flag details)
280
- response = "https://app.launchdarkly.com/api/v2/flags/default/#{flag}?env=#{env}" (string)
289
+ response = "https://app.launchdarkly.com/api/v2/flags/default/#{flag}?env=#{env}"
290
+ response[rule_at_index]['clauses'][clause_at_index]['values'] (string)
281
291
  ```
282
292
 
283
293
  ```ruby
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module LaunchdarklyApiHelper
4
- VERSION = '0.6.0'
4
+ VERSION = '0.7.0'
5
5
  end
@@ -25,145 +25,61 @@
25
25
  require_relative 'launchdarkly_api_helper/constants'
26
26
  require_relative 'launchdarkly_api_helper/launchdarkly_api_helper_class'
27
27
 
28
- # All methods related to launch darkly api are defined here
28
+ # LaunchDarklyApiHelper provides you a way to access your Launch Darkly account using API token to view, edit or delete them accordingly.
29
29
  module LaunchdarklyApiHelper
30
30
  class Error < StandardError; end
31
31
 
32
- # == LaunchDarkly REST API
33
- # https://apidocs.launchdarkly.com/
34
- # == To perform any operations such as add, remove, replace, move, copy, test you should have a working knowledge of JSON Patch
35
- # https://datatracker.ietf.org/doc/html/rfc6902
36
-
32
+ # set your LD API token and log file to capture logs
37
33
  def ld_access_token(access_token, project_name = 'default', log_file = 'launchdarkly.log')
38
34
  @launchdarkly_helper = LaunchdarklyApiHelperClass.new(access_token, project_name, log_file)
39
35
  end
40
36
 
41
- # == Get feature flag
42
- # https://apidocs.launchdarkly.com/tag/Feature-flags#operation/getFeatureFlag
43
- #
44
- # == GET REQUEST
45
- # https://app.launchdarkly.com/api/v2/flags/default/developer_flag_for_regression
46
- #
47
- # == key (*required)
48
- # env, flag
49
- #
50
- # == Here, 'developer_flag_for_regression' is the feature flag name and default is our Project name - eg. AmitSinghBisht
51
- # == By default, this returns the configurations for all environments
52
- # == You can filter environments with the env query parameter. For example, setting env=staging restricts the returned configurations to just the staging environment
53
- # https://app.launchdarkly.com/api/v2/flags/default/developer_flag_for_regression?env=staging
54
-
37
+ # this method will give you entire details about a flag for that particular environment
55
38
  def ld_fetch_flag_details(env, flag)
56
39
  @launchdarkly_helper.fetch_flag_details(env, flag)
57
40
  end
58
41
 
59
- # == Get toggle status feature flag
60
- #
61
- # == key (*required)
62
- # env, flag
63
- #
64
- # response = https://app.launchdarkly.com/api/v2/flags/default/developer_flag_for_regression?env=staging
65
- # grab the value of the ['environments'][env]['on'] obtained from the above response
66
-
42
+ # this method will return the status of the flag, whether it is on or off viz set to true or false
67
43
  def ld_fetch_flag_toggle_status(env, flag)
68
44
  @launchdarkly_helper.fetch_flag_toggle_status(env, flag)
69
45
  end
70
46
 
71
- # == Create a feature flag
72
- # https://apidocs.launchdarkly.com/tag/Feature-flags/#operation/postFeatureFlag
73
- #
74
- # == POST REQUEST
75
- # https://app.launchdarkly.com/api/v2/flags/default
76
- #
77
- # Here, default is our Project name - Browserstack
78
- #
79
- # key (*required): A unique key used to reference the flag in your code (string)
80
- #
81
- # name (*required): A human-friendly name for the feature flag (string)
82
- #
83
- # description: Description of the feature flag. Defaults to an empty string (string)
84
- #
85
- # tags: Tags for the feature flag. Defaults to an empty array (Array of strings)
86
- #
87
- # variations: An array of possible variations for the flag. The variation values must be unique. If omitted, two boolean variations of true and false will be used (Array of objects)
88
- #
89
- # defaults
90
- # * onVariation (*required): The index, from the array of variations for this flag, of the variation to serve by default when targeting is on (integer)
91
- # * offVariation (*required): The index, from the array of variations for this flag, of the variation to serve by default when targeting is off (integer)
92
- #
93
- # {
94
- # "key": "developer_flag_for_regression",
95
- # "name": "developer_flag_for_regression",
96
- # "description": "developer_flag_for_regression is created via regression
97
- # api on 18_10_2022",
98
- # "tags": [
99
- # "created_via_regression_api_on_18_10_2022"
100
- # ],
101
- # "variations": [
102
- # {
103
- # "age": 10
104
- # },
105
- # {
106
- # "age": 20
107
- # }
108
- # ],
109
- # "defaults": {
110
- # "onVariation": 1,
111
- # "offVariation": 0
112
- # }
113
- # }
114
- #
115
- # Above code will create a key 'developer_flag_for_regression' with name as 'developer_flag_for_regression' and description as 'developer_flag_for_regression is created via regression api on 18_10_2022'
116
- #
117
- # Variations are provided while creating key, by default variation is a boolean value (true and false). once flag with a specific variation is created, its type cannot be modified later, hence choose your variation type smartly (Boolean, String, Number, JSON) In above example we are creating a flag with JSON type and its two values are 'age': 10 and 'age': 20
118
- #
119
- # Also, variation has by default two values, and you must also define two variations while creating your own custom feature flag
120
- #
121
- # Default will specify which variation to serve when flag is on or off. In above example when flag is turned on, '1' variation is served [Note: 0 and 1 are index position], so variations at first index ie variations[1] will be served when flag is turned on ie 'age': 20
122
-
47
+ # this method will create a new feature flag, NOTE: feature falg are created at global level and environment resides inside feature flag
123
48
  def ld_create_flag(key, name = key, description = key, tags = ['created_via_regression_api'])
124
49
  @launchdarkly_helper.create_flag(key, name, description, tags)
125
50
  end
126
51
 
127
- # == Update feature flag
128
- # https://apidocs.launchdarkly.com/tag/Feature-flags#operation/patchFeatureFlag
129
- #
130
- # == PATCH REQUEST
131
- # https://app.launchdarkly.com/api/v2/flags/default/developer_flag_for_regression
132
- #
133
- # key (*required)
134
- #
135
- # == Here, 'developer_flag_for_regression' is the flag key and default is our Project name - Browserstack
136
- # == You can update any parameter of feature flag using this method
137
-
52
+ # this method will be used to toggle status of feature flag either on / off for a particular environment
138
53
  def ld_toggle_specific_environment(env, flag, flag_value = true)
139
54
  @launchdarkly_helper.toggle_specific_environment(env, flag, flag_value)
140
55
  end
141
56
 
142
- # == Get status of feature flag
143
- # https://apidocs.launchdarkly.com/tag/Feature-flags#operation/patchFeatureFlag
144
- #
145
- # [fetch_flag_toggle_status_response, feature_flag_variation_index_response, feature_flag_variation_value_response, feature_flag_variation_name_response]
146
-
57
+ # this method will get important parameters from the response
147
58
  def ld_flag_variation_served(env, flag)
148
59
  @launchdarkly_helper.flag_variation_served(env, flag)
149
60
  end
150
61
 
62
+ # this method will return the index of rules and clauses by searching for clause_name in response
151
63
  def ld_rules_clauses_index(env, flag, clause_name)
152
64
  @launchdarkly_helper.rules_clauses_index(env, flag, clause_name)
153
65
  end
154
66
 
67
+ # this method will return values inside a particular clause by searching for clause_name in response
155
68
  def ld_get_values_from_clauses(env, flag, clause_name)
156
69
  @launchdarkly_helper.get_values_from_clauses(env, flag, clause_name)
157
70
  end
158
71
 
72
+ # this method will help you to add a value to a particular clause by searching for clause_name in response
159
73
  def ld_add_values_to_clause(env, flag, clause_name, clause_value)
160
74
  @launchdarkly_helper.add_values_to_clause(env, flag, clause_name, clause_value)
161
75
  end
162
76
 
77
+ # this method will help you to remove a value to a particular clause by searching for clause_name in response
163
78
  def ld_remove_values_from_clause(env, flag, clause_name, clause_value)
164
79
  @launchdarkly_helper.remove_values_from_clause(env, flag, clause_name, clause_value)
165
80
  end
166
81
 
82
+ # this method will delete a feature flag in launchdarkly (NOTE: env resided inside flag which means flag is parent, so deleting a feature flag will delete it from all environment)
167
83
  def ld_delete_flag(flag)
168
84
  @launchdarkly_helper.delete_flag(flag)
169
85
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: launchdarkly_api_helper
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - amit-singh-bisht
@@ -10,7 +10,8 @@ bindir: exe
10
10
  cert_chain: []
11
11
  date: 2022-11-19 00:00:00.000000000 Z
12
12
  dependencies: []
13
- description: Write a longer description or delete this line.
13
+ description: LaunchDarklyApiHelper provides you a way to access your Launch Darkly
14
+ account using API token to view, edit or delete them accordingly. https://amit-singh-bisht.github.io/launchdarkly_api_helper_ruby/
14
15
  email:
15
16
  - bishtamitsingh98@gmail.com
16
17
  executables: []
@@ -52,5 +53,6 @@ requirements: []
52
53
  rubygems_version: 3.2.3
53
54
  signing_key:
54
55
  specification_version: 4
55
- summary: Write a short summary, because RubyGems requires one.
56
+ summary: LaunchDarklyApiHelper provides you a way to access your Launch Darkly account
57
+ using API token to view, edit or delete them accordingly. https://amit-singh-bisht.github.io/launchdarkly_api_helper_ruby/
56
58
  test_files: []