Class: LaunchDarklyApi::FeatureFlagsApi

Inherits:
Object
  • Object
show all
Defined in:
lib/launchdarkly_api/api/feature_flags_api.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_client = ApiClient.default) ⇒ FeatureFlagsApi

Returns a new instance of FeatureFlagsApi.



19
20
21
# File 'lib/launchdarkly_api/api/feature_flags_api.rb', line 19

def initialize(api_client = ApiClient.default)
  @api_client = api_client
end

Instance Attribute Details

#api_clientObject

Returns the value of attribute api_client.



17
18
19
# File 'lib/launchdarkly_api/api/feature_flags_api.rb', line 17

def api_client
  @api_client
end

Instance Method Details

#copy_feature_flag(project_key, feature_flag_key, flag_copy_config_post, opts = {}) ⇒ FeatureFlag

Copy feature flag The includedActions and excludedActions define the parts of the flag configuration that are copied or not copied. By default, the entire flag configuration is copied. You can have either `includedActions` or `excludedActions` but not both. Valid `includedActions` and `excludedActions` include: - `updateOn` - `updatePrerequisites` - `updateTargets` - `updateRules` - `updateFallthrough` - `updateOffVariation` The `source` and `target` must be JSON objects if using curl, specifying the environment key and (optional) current flag configuration version in that environment. For example: “`json { "key": "production", "currentVersion": 3 } “` If target is specified as above, the API will test to ensure that the current flag version in the `production` environment is `3`, and reject attempts to copy settings to `production` otherwise. You can use this to enforce optimistic locking on copy attempts.

Parameters:

  • project_key (String)

    The project key

  • feature_flag_key (String)

    The feature flag key. The key identifies the flag in your code.

  • flag_copy_config_post (FlagCopyConfigPost)
  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:



29
30
31
32
# File 'lib/launchdarkly_api/api/feature_flags_api.rb', line 29

def copy_feature_flag(project_key, feature_flag_key, flag_copy_config_post, opts = {})
  data, _status_code, _headers = copy_feature_flag_with_http_info(project_key, feature_flag_key, flag_copy_config_post, opts)
  data
end

#copy_feature_flag_with_http_info(project_key, feature_flag_key, flag_copy_config_post, opts = {}) ⇒ Array<(FeatureFlag, Integer, Hash)>

Copy feature flag The includedActions and excludedActions define the parts of the flag configuration that are copied or not copied. By default, the entire flag configuration is copied. You can have either &#x60;includedActions&#x60; or &#x60;excludedActions&#x60; but not both. Valid &#x60;includedActions&#x60; and &#x60;excludedActions&#x60; include: - &#x60;updateOn&#x60; - &#x60;updatePrerequisites&#x60; - &#x60;updateTargets&#x60; - &#x60;updateRules&#x60; - &#x60;updateFallthrough&#x60; - &#x60;updateOffVariation&#x60; The &#x60;source&#x60; and &#x60;target&#x60; must be JSON objects if using curl, specifying the environment key and (optional) current flag configuration version in that environment. For example: &#x60;&#x60;&#x60;json { &quot;key&quot;: &quot;production&quot;, &quot;currentVersion&quot;: 3 } &#x60;&#x60;&#x60; If target is specified as above, the API will test to ensure that the current flag version in the &#x60;production&#x60; environment is &#x60;3&#x60;, and reject attempts to copy settings to &#x60;production&#x60; otherwise. You can use this to enforce optimistic locking on copy attempts.

Parameters:

  • project_key (String)

    The project key

  • feature_flag_key (String)

    The feature flag key. The key identifies the flag in your code.

  • flag_copy_config_post (FlagCopyConfigPost)
  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (Array<(FeatureFlag, Integer, Hash)>)

    FeatureFlag data, response status code and response headers



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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
# File 'lib/launchdarkly_api/api/feature_flags_api.rb', line 41

def copy_feature_flag_with_http_info(project_key, feature_flag_key, flag_copy_config_post, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: FeatureFlagsApi.copy_feature_flag ...'
  end
  # verify the required parameter 'project_key' is set
  if @api_client.config.client_side_validation && project_key.nil?
    fail ArgumentError, "Missing the required parameter 'project_key' when calling FeatureFlagsApi.copy_feature_flag"
  end
  # verify the required parameter 'feature_flag_key' is set
  if @api_client.config.client_side_validation && feature_flag_key.nil?
    fail ArgumentError, "Missing the required parameter 'feature_flag_key' when calling FeatureFlagsApi.copy_feature_flag"
  end
  # verify the required parameter 'flag_copy_config_post' is set
  if @api_client.config.client_side_validation && flag_copy_config_post.nil?
    fail ArgumentError, "Missing the required parameter 'flag_copy_config_post' when calling FeatureFlagsApi.copy_feature_flag"
  end
  # resource path
  local_var_path = '/api/v2/flags/{projectKey}/{featureFlagKey}/copy'.sub('{' + 'projectKey' + '}', CGI.escape(project_key.to_s)).sub('{' + 'featureFlagKey' + '}', CGI.escape(feature_flag_key.to_s))

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json'])
  # HTTP header 'Content-Type'
  content_type = @api_client.select_header_content_type(['application/json'])
  if !content_type.nil?
      header_params['Content-Type'] = content_type
  end

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body] || @api_client.object_to_http_body(flag_copy_config_post)

  # return_type
  return_type = opts[:debug_return_type] || 'FeatureFlag'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['ApiKey']

  new_options = opts.merge(
    :operation => :"FeatureFlagsApi.copy_feature_flag",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: FeatureFlagsApi#copy_feature_flag\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#delete_feature_flag(project_key, feature_flag_key, opts = {}) ⇒ nil

Delete feature flag Delete a feature flag in all environments. Use with caution: only delete feature flags your application no longer uses.

Parameters:

  • project_key (String)

    The project key

  • feature_flag_key (String)

    The feature flag key. The key identifies the flag in your code.

  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (nil)


108
109
110
111
# File 'lib/launchdarkly_api/api/feature_flags_api.rb', line 108

def delete_feature_flag(project_key, feature_flag_key, opts = {})
  delete_feature_flag_with_http_info(project_key, feature_flag_key, opts)
  nil
end

#delete_feature_flag_with_http_info(project_key, feature_flag_key, opts = {}) ⇒ Array<(nil, Integer, Hash)>

Delete feature flag Delete a feature flag in all environments. Use with caution: only delete feature flags your application no longer uses.

Parameters:

  • project_key (String)

    The project key

  • feature_flag_key (String)

    The feature flag key. The key identifies the flag in your code.

  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (Array<(nil, Integer, Hash)>)

    nil, response status code and response headers



119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
# File 'lib/launchdarkly_api/api/feature_flags_api.rb', line 119

def delete_feature_flag_with_http_info(project_key, feature_flag_key, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: FeatureFlagsApi.delete_feature_flag ...'
  end
  # verify the required parameter 'project_key' is set
  if @api_client.config.client_side_validation && project_key.nil?
    fail ArgumentError, "Missing the required parameter 'project_key' when calling FeatureFlagsApi.delete_feature_flag"
  end
  # verify the required parameter 'feature_flag_key' is set
  if @api_client.config.client_side_validation && feature_flag_key.nil?
    fail ArgumentError, "Missing the required parameter 'feature_flag_key' when calling FeatureFlagsApi.delete_feature_flag"
  end
  # resource path
  local_var_path = '/api/v2/flags/{projectKey}/{featureFlagKey}'.sub('{' + 'projectKey' + '}', CGI.escape(project_key.to_s)).sub('{' + 'featureFlagKey' + '}', CGI.escape(feature_flag_key.to_s))

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json'])

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type]

  # auth_names
  auth_names = opts[:debug_auth_names] || ['ApiKey']

  new_options = opts.merge(
    :operation => :"FeatureFlagsApi.delete_feature_flag",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:DELETE, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: FeatureFlagsApi#delete_feature_flag\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#get_expiring_user_targets(project_key, environment_key, feature_flag_key, opts = {}) ⇒ ExpiringUserTargetGetResponse

Get expiring user targets for feature flag Get a list of user targets on a feature flag that are scheduled for removal.

Parameters:

  • project_key (String)

    The project key

  • environment_key (String)

    The environment key

  • feature_flag_key (String)

    The feature flag key

  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:



178
179
180
181
# File 'lib/launchdarkly_api/api/feature_flags_api.rb', line 178

def get_expiring_user_targets(project_key, environment_key, feature_flag_key, opts = {})
  data, _status_code, _headers = get_expiring_user_targets_with_http_info(project_key, environment_key, feature_flag_key, opts)
  data
end

#get_expiring_user_targets_with_http_info(project_key, environment_key, feature_flag_key, opts = {}) ⇒ Array<(ExpiringUserTargetGetResponse, Integer, Hash)>

Get expiring user targets for feature flag Get a list of user targets on a feature flag that are scheduled for removal.

Parameters:

  • project_key (String)

    The project key

  • environment_key (String)

    The environment key

  • feature_flag_key (String)

    The feature flag key

  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:



190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
# File 'lib/launchdarkly_api/api/feature_flags_api.rb', line 190

def get_expiring_user_targets_with_http_info(project_key, environment_key, feature_flag_key, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: FeatureFlagsApi.get_expiring_user_targets ...'
  end
  # verify the required parameter 'project_key' is set
  if @api_client.config.client_side_validation && project_key.nil?
    fail ArgumentError, "Missing the required parameter 'project_key' when calling FeatureFlagsApi.get_expiring_user_targets"
  end
  # verify the required parameter 'environment_key' is set
  if @api_client.config.client_side_validation && environment_key.nil?
    fail ArgumentError, "Missing the required parameter 'environment_key' when calling FeatureFlagsApi.get_expiring_user_targets"
  end
  # verify the required parameter 'feature_flag_key' is set
  if @api_client.config.client_side_validation && feature_flag_key.nil?
    fail ArgumentError, "Missing the required parameter 'feature_flag_key' when calling FeatureFlagsApi.get_expiring_user_targets"
  end
  # resource path
  local_var_path = '/api/v2/flags/{projectKey}/{featureFlagKey}/expiring-user-targets/{environmentKey}'.sub('{' + 'projectKey' + '}', CGI.escape(project_key.to_s)).sub('{' + 'environmentKey' + '}', CGI.escape(environment_key.to_s)).sub('{' + 'featureFlagKey' + '}', CGI.escape(feature_flag_key.to_s))

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json'])

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type] || 'ExpiringUserTargetGetResponse'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['ApiKey']

  new_options = opts.merge(
    :operation => :"FeatureFlagsApi.get_expiring_user_targets",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: FeatureFlagsApi#get_expiring_user_targets\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#get_feature_flag(project_key, feature_flag_key, opts = {}) ⇒ FeatureFlag

Get feature flag Get a single feature flag by key. By default, this returns the configurations for all environments. You can filter environments with the `env` query parameter. For example, setting `env=production` restricts the returned configurations to just the `production` environment.

Parameters:

  • project_key (String)

    The project key

  • feature_flag_key (String)

    The feature flag key

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :env (String)

    Filter configurations by environment

Returns:



253
254
255
256
# File 'lib/launchdarkly_api/api/feature_flags_api.rb', line 253

def get_feature_flag(project_key, feature_flag_key, opts = {})
  data, _status_code, _headers = get_feature_flag_with_http_info(project_key, feature_flag_key, opts)
  data
end

#get_feature_flag_status(project_key, environment_key, feature_flag_key, opts = {}) ⇒ FlagStatusRep

Get feature flag status Get the status for a particular feature flag.

Parameters:

  • project_key (String)

    The project key

  • environment_key (String)

    The environment key

  • feature_flag_key (String)

    The feature flag key

  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:



325
326
327
328
# File 'lib/launchdarkly_api/api/feature_flags_api.rb', line 325

def get_feature_flag_status(project_key, environment_key, feature_flag_key, opts = {})
  data, _status_code, _headers = get_feature_flag_status_with_http_info(project_key, environment_key, feature_flag_key, opts)
  data
end

#get_feature_flag_status_across_environments(project_key, feature_flag_key, opts = {}) ⇒ FeatureFlagStatusAcrossEnvironments

Get flag status across environments Get the status for a particular feature flag across environments.

Parameters:

  • project_key (String)

    The project key

  • feature_flag_key (String)

    The feature flag key

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :env (String)

    Optional environment filter

Returns:



400
401
402
403
# File 'lib/launchdarkly_api/api/feature_flags_api.rb', line 400

def get_feature_flag_status_across_environments(project_key, feature_flag_key, opts = {})
  data, _status_code, _headers = get_feature_flag_status_across_environments_with_http_info(project_key, feature_flag_key, opts)
  data
end

#get_feature_flag_status_across_environments_with_http_info(project_key, feature_flag_key, opts = {}) ⇒ Array<(FeatureFlagStatusAcrossEnvironments, Integer, Hash)>

Get flag status across environments Get the status for a particular feature flag across environments.

Parameters:

  • project_key (String)

    The project key

  • feature_flag_key (String)

    The feature flag key

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :env (String)

    Optional environment filter

Returns:



412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
# File 'lib/launchdarkly_api/api/feature_flags_api.rb', line 412

def get_feature_flag_status_across_environments_with_http_info(project_key, feature_flag_key, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: FeatureFlagsApi.get_feature_flag_status_across_environments ...'
  end
  # verify the required parameter 'project_key' is set
  if @api_client.config.client_side_validation && project_key.nil?
    fail ArgumentError, "Missing the required parameter 'project_key' when calling FeatureFlagsApi.get_feature_flag_status_across_environments"
  end
  # verify the required parameter 'feature_flag_key' is set
  if @api_client.config.client_side_validation && feature_flag_key.nil?
    fail ArgumentError, "Missing the required parameter 'feature_flag_key' when calling FeatureFlagsApi.get_feature_flag_status_across_environments"
  end
  # resource path
  local_var_path = '/api/v2/flag-status/{projectKey}/{featureFlagKey}'.sub('{' + 'projectKey' + '}', CGI.escape(project_key.to_s)).sub('{' + 'featureFlagKey' + '}', CGI.escape(feature_flag_key.to_s))

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'env'] = opts[:'env'] if !opts[:'env'].nil?

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json'])

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type] || 'FeatureFlagStatusAcrossEnvironments'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['ApiKey']

  new_options = opts.merge(
    :operation => :"FeatureFlagsApi.get_feature_flag_status_across_environments",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: FeatureFlagsApi#get_feature_flag_status_across_environments\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#get_feature_flag_status_with_http_info(project_key, environment_key, feature_flag_key, opts = {}) ⇒ Array<(FlagStatusRep, Integer, Hash)>

Get feature flag status Get the status for a particular feature flag.

Parameters:

  • project_key (String)

    The project key

  • environment_key (String)

    The environment key

  • feature_flag_key (String)

    The feature flag key

  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (Array<(FlagStatusRep, Integer, Hash)>)

    FlagStatusRep data, response status code and response headers



337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
# File 'lib/launchdarkly_api/api/feature_flags_api.rb', line 337

def get_feature_flag_status_with_http_info(project_key, environment_key, feature_flag_key, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: FeatureFlagsApi.get_feature_flag_status ...'
  end
  # verify the required parameter 'project_key' is set
  if @api_client.config.client_side_validation && project_key.nil?
    fail ArgumentError, "Missing the required parameter 'project_key' when calling FeatureFlagsApi.get_feature_flag_status"
  end
  # verify the required parameter 'environment_key' is set
  if @api_client.config.client_side_validation && environment_key.nil?
    fail ArgumentError, "Missing the required parameter 'environment_key' when calling FeatureFlagsApi.get_feature_flag_status"
  end
  # verify the required parameter 'feature_flag_key' is set
  if @api_client.config.client_side_validation && feature_flag_key.nil?
    fail ArgumentError, "Missing the required parameter 'feature_flag_key' when calling FeatureFlagsApi.get_feature_flag_status"
  end
  # resource path
  local_var_path = '/api/v2/flag-statuses/{projectKey}/{environmentKey}/{featureFlagKey}'.sub('{' + 'projectKey' + '}', CGI.escape(project_key.to_s)).sub('{' + 'environmentKey' + '}', CGI.escape(environment_key.to_s)).sub('{' + 'featureFlagKey' + '}', CGI.escape(feature_flag_key.to_s))

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json'])

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type] || 'FlagStatusRep'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['ApiKey']

  new_options = opts.merge(
    :operation => :"FeatureFlagsApi.get_feature_flag_status",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: FeatureFlagsApi#get_feature_flag_status\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#get_feature_flag_statuses(project_key, environment_key, opts = {}) ⇒ FeatureFlagStatuses

List feature flag statuses Get a list of statuses for all feature flags. The status includes the last time the feature flag was requested, as well as a state, which is one of the following: - `new`: the feature flag was created within the last seven days, and has not been requested yet - `active`: the feature flag was requested by your servers or clients within the last seven days - `inactive`: the feature flag was created more than seven days ago, and hasn't been requested by your servers or clients within the past seven days - `launched`: one variation of the feature flag has been rolled out to all your users for at least 7 days

Parameters:

  • project_key (String)

    The project key

  • environment_key (String)

    The environment key

  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:



471
472
473
474
# File 'lib/launchdarkly_api/api/feature_flags_api.rb', line 471

def get_feature_flag_statuses(project_key, environment_key, opts = {})
  data, _status_code, _headers = get_feature_flag_statuses_with_http_info(project_key, environment_key, opts)
  data
end

#get_feature_flag_statuses_with_http_info(project_key, environment_key, opts = {}) ⇒ Array<(FeatureFlagStatuses, Integer, Hash)>

List feature flag statuses Get a list of statuses for all feature flags. The status includes the last time the feature flag was requested, as well as a state, which is one of the following: - &#x60;new&#x60;: the feature flag was created within the last seven days, and has not been requested yet - &#x60;active&#x60;: the feature flag was requested by your servers or clients within the last seven days - &#x60;inactive&#x60;: the feature flag was created more than seven days ago, and hasn&#39;t been requested by your servers or clients within the past seven days - &#x60;launched&#x60;: one variation of the feature flag has been rolled out to all your users for at least 7 days

Parameters:

  • project_key (String)

    The project key

  • environment_key (String)

    The environment key

  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (Array<(FeatureFlagStatuses, Integer, Hash)>)

    FeatureFlagStatuses data, response status code and response headers



482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
# File 'lib/launchdarkly_api/api/feature_flags_api.rb', line 482

def get_feature_flag_statuses_with_http_info(project_key, environment_key, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: FeatureFlagsApi.get_feature_flag_statuses ...'
  end
  # verify the required parameter 'project_key' is set
  if @api_client.config.client_side_validation && project_key.nil?
    fail ArgumentError, "Missing the required parameter 'project_key' when calling FeatureFlagsApi.get_feature_flag_statuses"
  end
  # verify the required parameter 'environment_key' is set
  if @api_client.config.client_side_validation && environment_key.nil?
    fail ArgumentError, "Missing the required parameter 'environment_key' when calling FeatureFlagsApi.get_feature_flag_statuses"
  end
  # resource path
  local_var_path = '/api/v2/flag-statuses/{projectKey}/{environmentKey}'.sub('{' + 'projectKey' + '}', CGI.escape(project_key.to_s)).sub('{' + 'environmentKey' + '}', CGI.escape(environment_key.to_s))

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json'])

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type] || 'FeatureFlagStatuses'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['ApiKey']

  new_options = opts.merge(
    :operation => :"FeatureFlagsApi.get_feature_flag_statuses",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: FeatureFlagsApi#get_feature_flag_statuses\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#get_feature_flag_with_http_info(project_key, feature_flag_key, opts = {}) ⇒ Array<(FeatureFlag, Integer, Hash)>

Get feature flag Get a single feature flag by key. By default, this returns the configurations for all environments. You can filter environments with the &#x60;env&#x60; query parameter. For example, setting &#x60;env&#x3D;production&#x60; restricts the returned configurations to just the &#x60;production&#x60; environment.

Parameters:

  • project_key (String)

    The project key

  • feature_flag_key (String)

    The feature flag key

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :env (String)

    Filter configurations by environment

Returns:

  • (Array<(FeatureFlag, Integer, Hash)>)

    FeatureFlag data, response status code and response headers



265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
# File 'lib/launchdarkly_api/api/feature_flags_api.rb', line 265

def get_feature_flag_with_http_info(project_key, feature_flag_key, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: FeatureFlagsApi.get_feature_flag ...'
  end
  # verify the required parameter 'project_key' is set
  if @api_client.config.client_side_validation && project_key.nil?
    fail ArgumentError, "Missing the required parameter 'project_key' when calling FeatureFlagsApi.get_feature_flag"
  end
  # verify the required parameter 'feature_flag_key' is set
  if @api_client.config.client_side_validation && feature_flag_key.nil?
    fail ArgumentError, "Missing the required parameter 'feature_flag_key' when calling FeatureFlagsApi.get_feature_flag"
  end
  # resource path
  local_var_path = '/api/v2/flags/{projectKey}/{featureFlagKey}'.sub('{' + 'projectKey' + '}', CGI.escape(project_key.to_s)).sub('{' + 'featureFlagKey' + '}', CGI.escape(feature_flag_key.to_s))

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'env'] = opts[:'env'] if !opts[:'env'].nil?

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json'])

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type] || 'FeatureFlag'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['ApiKey']

  new_options = opts.merge(
    :operation => :"FeatureFlagsApi.get_feature_flag",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: FeatureFlagsApi#get_feature_flag\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#get_feature_flags(project_key, opts = {}) ⇒ FeatureFlags

List feature flags Get a list of all features in the given project. By default, each feature includes configurations for each environment. You can filter environments with the env query parameter. For example, setting `env=production` restricts the returned configurations to just your production environment. You can also filter feature flags by tag with the tag query parameter. We support the following fields for filters: - `query` is a string that matches against the flags' keys and names. It is not case sensitive. - `archived` is a boolean to filter the list to archived flags. When this is absent, only unarchived flags are returned. - `type` is a string allowing filtering to `temporary` or `permanent` flags. - `status` is a string allowing filtering to `new`, `inactive`, `active`, or `launched` flags in the specified environment. This filter also requires a `filterEnv` field to be set to a valid environment. For example: `filter=status:active,filterEnv:production`. - `tags` is a + separated list of tags. It filters the list to members who have all of the tags in the list. - `hasExperiment` is a boolean with values of true or false and returns any flags that have an attached metric. - `hasDataExport` is a boolean with values of true or false and returns any flags that are currently exporting data in the specified environment. This includes flags that are exporting data via Experimentation. This filter also requires a `filterEnv` field to be set to a valid environment key. e.g. `filter=hasExperiment:true,filterEnv:production` - `evaluated` is an object that contains a key of `after` and a value in Unix time in milliseconds. This returns all flags that have been evaluated since the time you specify in the environment provided. This filter also requires a `filterEnv` field to be set to a valid environment. For example: `filter=evaluated:1590768455282,filterEnv:production`. - `filterEnv` is a string with the key of a valid environment. The filterEnv field is used for filters that are environment specific. If there are multiple environment specific filters you should only declare this parameter once. For example: `filter=evaluated:1590768455282,filterEnv:production,status:active`. An example filter is `query:abc,tags:foo+bar`. This matches flags with the string `abc` in their key or name, ignoring case, which also have the tags `foo` and `bar`. By default, this returns all flags. You can page through the list with the `limit` parameter and by following the `first`, `prev`, `next`, and `last` links in the returned `_links` field. These links will not be present if the pages they refer to don't exist. For example, the `first` and `prev` links will be missing from the response on the first page.

Parameters:

  • project_key (String)

    The project key

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :env (String)

    Filter configurations by environment

  • :tag (String)

    Filter feature flags by tag

  • :limit (Integer)

    The number of feature flags to return. Defaults to -1, which returns all flags

  • :offset (Integer)

    Where to start in the list. Use this with pagination. For example, an offset of 10 skips the first ten items and then returns the next limit items

  • :archived (Boolean)

    A boolean to filter the list to archived flags. When this is absent, only unarchived flags will be returned

  • :summary (Boolean)

    By default in API version &gt;&#x3D; 1, flags will not include their list of prerequisites, targets or rules. Set summary&#x3D;0 to include these fields for each flag returned

  • :filter (String)

    A comma-separated list of filters. Each filter is of the form field:value

  • :sort (String)

    A comma-separated list of fields to sort by. Fields prefixed by a dash ( - ) sort in descending order

  • :compare (Boolean)

    A boolean to filter results by only flags that have differences between environments

Returns:



548
549
550
551
# File 'lib/launchdarkly_api/api/feature_flags_api.rb', line 548

def get_feature_flags(project_key, opts = {})
  data, _status_code, _headers = get_feature_flags_with_http_info(project_key, opts)
  data
end

#get_feature_flags_with_http_info(project_key, opts = {}) ⇒ Array<(FeatureFlags, Integer, Hash)>

List feature flags Get a list of all features in the given project. By default, each feature includes configurations for each environment. You can filter environments with the env query parameter. For example, setting &#x60;env&#x3D;production&#x60; restricts the returned configurations to just your production environment. You can also filter feature flags by tag with the tag query parameter. We support the following fields for filters: - &#x60;query&#x60; is a string that matches against the flags&#39; keys and names. It is not case sensitive. - &#x60;archived&#x60; is a boolean to filter the list to archived flags. When this is absent, only unarchived flags are returned. - &#x60;type&#x60; is a string allowing filtering to &#x60;temporary&#x60; or &#x60;permanent&#x60; flags. - &#x60;status&#x60; is a string allowing filtering to &#x60;new&#x60;, &#x60;inactive&#x60;, &#x60;active&#x60;, or &#x60;launched&#x60; flags in the specified environment. This filter also requires a &#x60;filterEnv&#x60; field to be set to a valid environment. For example: &#x60;filter&#x3D;status:active,filterEnv:production&#x60;. - &#x60;tags&#x60; is a + separated list of tags. It filters the list to members who have all of the tags in the list. - &#x60;hasExperiment&#x60; is a boolean with values of true or false and returns any flags that have an attached metric. - &#x60;hasDataExport&#x60; is a boolean with values of true or false and returns any flags that are currently exporting data in the specified environment. This includes flags that are exporting data via Experimentation. This filter also requires a &#x60;filterEnv&#x60; field to be set to a valid environment key. e.g. &#x60;filter&#x3D;hasExperiment:true,filterEnv:production&#x60; - &#x60;evaluated&#x60; is an object that contains a key of &#x60;after&#x60; and a value in Unix time in milliseconds. This returns all flags that have been evaluated since the time you specify in the environment provided. This filter also requires a &#x60;filterEnv&#x60; field to be set to a valid environment. For example: &#x60;filter&#x3D;evaluated:1590768455282,filterEnv:production&#x60;. - &#x60;filterEnv&#x60; is a string with the key of a valid environment. The filterEnv field is used for filters that are environment specific. If there are multiple environment specific filters you should only declare this parameter once. For example: &#x60;filter&#x3D;evaluated:1590768455282,filterEnv:production,status:active&#x60;. An example filter is &#x60;query:abc,tags:foo+bar&#x60;. This matches flags with the string &#x60;abc&#x60; in their key or name, ignoring case, which also have the tags &#x60;foo&#x60; and &#x60;bar&#x60;. By default, this returns all flags. You can page through the list with the &#x60;limit&#x60; parameter and by following the &#x60;first&#x60;, &#x60;prev&#x60;, &#x60;next&#x60;, and &#x60;last&#x60; links in the returned &#x60;_links&#x60; field. These links will not be present if the pages they refer to don&#39;t exist. For example, the &#x60;first&#x60; and &#x60;prev&#x60; links will be missing from the response on the first page.

Parameters:

  • project_key (String)

    The project key

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :env (String)

    Filter configurations by environment

  • :tag (String)

    Filter feature flags by tag

  • :limit (Integer)

    The number of feature flags to return. Defaults to -1, which returns all flags

  • :offset (Integer)

    Where to start in the list. Use this with pagination. For example, an offset of 10 skips the first ten items and then returns the next limit items

  • :archived (Boolean)

    A boolean to filter the list to archived flags. When this is absent, only unarchived flags will be returned

  • :summary (Boolean)

    By default in API version &gt;&#x3D; 1, flags will not include their list of prerequisites, targets or rules. Set summary&#x3D;0 to include these fields for each flag returned

  • :filter (String)

    A comma-separated list of filters. Each filter is of the form field:value

  • :sort (String)

    A comma-separated list of fields to sort by. Fields prefixed by a dash ( - ) sort in descending order

  • :compare (Boolean)

    A boolean to filter results by only flags that have differences between environments

Returns:

  • (Array<(FeatureFlags, Integer, Hash)>)

    FeatureFlags data, response status code and response headers



567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
# File 'lib/launchdarkly_api/api/feature_flags_api.rb', line 567

def get_feature_flags_with_http_info(project_key, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: FeatureFlagsApi.get_feature_flags ...'
  end
  # verify the required parameter 'project_key' is set
  if @api_client.config.client_side_validation && project_key.nil?
    fail ArgumentError, "Missing the required parameter 'project_key' when calling FeatureFlagsApi.get_feature_flags"
  end
  # resource path
  local_var_path = '/api/v2/flags/{projectKey}'.sub('{' + 'projectKey' + '}', CGI.escape(project_key.to_s))

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'env'] = opts[:'env'] if !opts[:'env'].nil?
  query_params[:'tag'] = opts[:'tag'] if !opts[:'tag'].nil?
  query_params[:'limit'] = opts[:'limit'] if !opts[:'limit'].nil?
  query_params[:'offset'] = opts[:'offset'] if !opts[:'offset'].nil?
  query_params[:'archived'] = opts[:'archived'] if !opts[:'archived'].nil?
  query_params[:'summary'] = opts[:'summary'] if !opts[:'summary'].nil?
  query_params[:'filter'] = opts[:'filter'] if !opts[:'filter'].nil?
  query_params[:'sort'] = opts[:'sort'] if !opts[:'sort'].nil?
  query_params[:'compare'] = opts[:'compare'] if !opts[:'compare'].nil?

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json'])

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type] || 'FeatureFlags'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['ApiKey']

  new_options = opts.merge(
    :operation => :"FeatureFlagsApi.get_feature_flags",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: FeatureFlagsApi#get_feature_flags\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#patch_expiring_user_targets(project_key, environment_key, feature_flag_key, patch_with_comment, opts = {}) ⇒ ExpiringUserTargetPatchResponse

Update expiring user targets on feature flag Update the list of user targets on a feature flag that are scheduled for removal.

Parameters:

  • project_key (String)

    The project key

  • environment_key (String)

    The environment key

  • feature_flag_key (String)

    The feature flag key

  • patch_with_comment (PatchWithComment)
  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:



632
633
634
635
# File 'lib/launchdarkly_api/api/feature_flags_api.rb', line 632

def patch_expiring_user_targets(project_key, environment_key, feature_flag_key, patch_with_comment, opts = {})
  data, _status_code, _headers = patch_expiring_user_targets_with_http_info(project_key, environment_key, feature_flag_key, patch_with_comment, opts)
  data
end

#patch_expiring_user_targets_with_http_info(project_key, environment_key, feature_flag_key, patch_with_comment, opts = {}) ⇒ Array<(ExpiringUserTargetPatchResponse, Integer, Hash)>

Update expiring user targets on feature flag Update the list of user targets on a feature flag that are scheduled for removal.

Parameters:

  • project_key (String)

    The project key

  • environment_key (String)

    The environment key

  • feature_flag_key (String)

    The feature flag key

  • patch_with_comment (PatchWithComment)
  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:



645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
# File 'lib/launchdarkly_api/api/feature_flags_api.rb', line 645

def patch_expiring_user_targets_with_http_info(project_key, environment_key, feature_flag_key, patch_with_comment, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: FeatureFlagsApi.patch_expiring_user_targets ...'
  end
  # verify the required parameter 'project_key' is set
  if @api_client.config.client_side_validation && project_key.nil?
    fail ArgumentError, "Missing the required parameter 'project_key' when calling FeatureFlagsApi.patch_expiring_user_targets"
  end
  # verify the required parameter 'environment_key' is set
  if @api_client.config.client_side_validation && environment_key.nil?
    fail ArgumentError, "Missing the required parameter 'environment_key' when calling FeatureFlagsApi.patch_expiring_user_targets"
  end
  # verify the required parameter 'feature_flag_key' is set
  if @api_client.config.client_side_validation && feature_flag_key.nil?
    fail ArgumentError, "Missing the required parameter 'feature_flag_key' when calling FeatureFlagsApi.patch_expiring_user_targets"
  end
  # verify the required parameter 'patch_with_comment' is set
  if @api_client.config.client_side_validation && patch_with_comment.nil?
    fail ArgumentError, "Missing the required parameter 'patch_with_comment' when calling FeatureFlagsApi.patch_expiring_user_targets"
  end
  # resource path
  local_var_path = '/api/v2/flags/{projectKey}/{featureFlagKey}/expiring-user-targets/{environmentKey}'.sub('{' + 'projectKey' + '}', CGI.escape(project_key.to_s)).sub('{' + 'environmentKey' + '}', CGI.escape(environment_key.to_s)).sub('{' + 'featureFlagKey' + '}', CGI.escape(feature_flag_key.to_s))

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json'])
  # HTTP header 'Content-Type'
  content_type = @api_client.select_header_content_type(['application/json'])
  if !content_type.nil?
      header_params['Content-Type'] = content_type
  end

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body] || @api_client.object_to_http_body(patch_with_comment)

  # return_type
  return_type = opts[:debug_return_type] || 'ExpiringUserTargetPatchResponse'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['ApiKey']

  new_options = opts.merge(
    :operation => :"FeatureFlagsApi.patch_expiring_user_targets",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:PATCH, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: FeatureFlagsApi#patch_expiring_user_targets\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#patch_feature_flag(project_key, feature_flag_key, patch_with_comment, opts = {}) ⇒ FeatureFlag

Update feature flag Perform a partial update to a feature flag. ## Using semantic patches on a feature flag To use a [semantic patch](/reference#updates-via-semantic-patches) on a feature flag resource, you must include a header in the request. If you call a semantic patch resource without this header, you will receive a `400` response because your semantic patch will be interpreted as a JSON patch. Use this header: “` Content-Type: application/json; domain-model=launchdarkly.semanticpatch “` The body of a semantic patch request takes the following three properties: 1. `comment` (string): (Optional) A description of the update. 1. `environmentKey` (string): (Required) The key of the LaunchDarkly environment. 1. `instructions` (array): (Required) The list of actions to be performed by the update. Each action in the list must be an object/hash table with a `kind` property that indicates the instruction. Depending on the `kind`, the API may require other parameters. When this is the case, add the parameters as additional fields to the instruction object. Read below for more information on the specific supported semantic patch instructions. If any instruction in the patch encounters an error, the error will be returned and the flag will not be changed. In general, instructions will silently do nothing if the flag is already in the state requested by the patch instruction. For example, `removeUserTargets` does nothing when the targets have already been removed. They will generally error if a parameter refers to something that does not exist, like a variation ID that doesn't correspond to a variation on the flag or a rule ID that doesn't belong to a rule on the flag. Other specific error conditions are noted in the instruction descriptions. ### Instructions #### `turnFlagOn` Sets the flag's targeting state to on. For example, to flip a flag on, use this request body: “`json { "environmentKey": "example-environment-key", "instructions": [ { "kind": "turnFlagOn" } ] } “` #### `turnFlagOff` Sets the flag's targeting state to off. For example, to flip a flag off, use this request body: “`json { "environmentKey": "example-environment-key", "instructions": [ { "kind": "turnFlagOff" } ] } “` #### `addUserTargets` Adds the user keys in `values` to the individual user targets for the variation specified by `variationId`. Returns an error if this causes the same user key to be targeted in multiple variations. ##### Parameters - `values`: list of user keys - `variationId`: ID of a variation on the flag #### `removeUserTargets` Removes the user keys in `values` to the individual user targets for the variation specified by `variationId`. Does nothing if the user keys are not targeted. ##### Parameters - `values`: list of user keys - `variationId`: ID of a variation on the flag #### `replaceUserTargets` Completely replaces the existing set of user targeting. All variations must be provided. Example: “`json { "kind": "replaceUserTargets", "targets": [ { "variationId": "variation-1", "values": ["blah", "foo", "bar"] }, { "variationId": "variation-2", "values": ["abc", "def"] } ] } “` ##### Parameters - `targets`: a list of user targeting #### `clearUserTargets` Removes all individual user targets from the variation specified by `variationId` ##### Parameters - `variationId`: ID of a variation on the flag #### `addPrerequisite` Adds the flag indicated by `key` with variation `variationId` as a prerequisite to the flag. ##### Parameters - `key`: flag key of another flag - `variationId`: ID of a variation of the flag with key `key` #### `removePrerequisite` Removes the prerequisite indicated by `key`. Does nothing if this prerequisite does not exist. ##### Parameters - `key`: flag key of an existing prerequisite #### `updatePrerequisite` Changes the prerequisite with flag key `key` to the variation indicated by `variationId`. Returns an error if this prerequisite does not exist. ##### Parameters - `key`: flag key of an existing prerequisite - `variationId`: ID of a variation of the flag with key `key` #### `replacePrerequisites` Completely replaces the existing set of prerequisites for a given flag. Example: “`json { "kind": "replacePrerequisites", "prerequisites": [ { "key": "flag-key", "variationId": "variation-1" }, { "key": "another-flag", "variationId": "variation-2" } ] } “` ##### Parameters - `prerequisites`: a list of prerequisites #### `addRule` Adds a new rule to the flag with the given `clauses` which serves the variation indicated by `variationId` or the percent rollout indicated by `rolloutWeights` and `rolloutBucketBy`. If `beforeRuleId` is set, the rule will be added in the list of rules before the indicated rule. Otherwise, the rule will be added to the end of the list. ##### Parameters - `clauses`: Array of clauses (see `addClauses`) - `beforeRuleId`: Optional ID of a rule in the flag - `variationId`: ID of a variation of the flag - `rolloutWeights`: Map of variationId to weight in thousandths of a percent (0-100000) - `rolloutBucketBy`: Optional user attribute #### `removeRule` Removes the targeting rule specified by `ruleId`. Does nothing if the rule does not exist. ##### Parameters - `ruleId`: ID of a rule in the flag #### `replaceRules` Completely replaces the existing rules for a given flag. Example: “`json { "kind": "replaceRules", "rules": [ { "variationId": "variation-1", "description": "myRule", "clauses": [ { "attribute": "segmentMatch", "op": "segmentMatch", "values": ["test"] } ], "trackEvents": true } ] } “` ##### Parameters - `rules`: a list of rules #### `addClauses` Adds the given clauses to the rule indicated by `ruleId`. ##### Parameters - `ruleId`: ID of a rule in the flag - `clauses`: Array of clause objects, with `attribute` (string), `op` (string), and `values` (array of strings, numbers, or dates) properties. #### `removeClauses` Removes the clauses specified by `clauseIds` from the rule indicated by `ruleId`. #### Parameters - `ruleId`: ID of a rule in the flag - `clauseIds`: Array of IDs of clauses in the rule #### `updateClause` Replaces the clause indicated by `ruleId` and `clauseId` with `clause`. ##### Parameters - `ruleId`: ID of a rule in the flag - `clauseId`: ID of a clause in that rule - `clause`: Clause object #### `addValuesToClause` Adds `values` to the values of the clause indicated by `ruleId` and `clauseId`. ##### Parameters - `ruleId`: ID of a rule in the flag - `clauseId`: ID of a clause in that rule - `values`: Array of strings #### `removeValuesFromClause` Removes `values` from the values of the clause indicated by `ruleId` and `clauseId`. ##### Parameters `ruleId`: ID of a rule in the flag `clauseId`: ID of a clause in that rule `values`: Array of strings #### `reorderRules` Rearranges the rules to match the order given in `ruleIds`. Will return an error if `ruleIds` does not match the current set of rules on the flag. ##### Parameters - `ruleIds`: Array of IDs of all rules in the flag #### `updateRuleVariationOrRollout` Updates what the rule indicated by `ruleId` serves if its clauses evaluate to true. Can either be a fixed variation indicated by `variationId` or a percent rollout indicated by `rolloutWeights` and `rolloutBucketBy`. ##### Parameters - `ruleId`: ID of a rule in the flag - `variationId`: ID of a variation of the flag or - `rolloutWeights`: Map of variationId to weight in thousandths of a percent (0-100000) - `rolloutBucketBy`: Optional user attribute #### `updateFallthroughVariationOrRollout` Updates the flag's fallthrough, which is served if none of the targeting rules match. Can either be a fixed variation indicated by `variationId` or a percent rollout indicated by `rolloutWeights` and `rolloutBucketBy`. ##### Parameters `variationId`: ID of a variation of the flag or `rolloutWeights`: Map of variationId to weight in thousandths of a percent (0-100000) `rolloutBucketBy`: Optional user attribute #### `updateOffVariation` Updates the variation served when the flag's targeting is off to the variation indicated by `variationId`. ##### Parameters `variationId`: ID of a variation of the flag ### Example “`json { "environmentKey": "production", "instructions": [ { "kind": "turnFlagOn" }, { "kind": "turnFlagOff" }, { "kind": "addUserTargets", "variationId": "8bfb304e-d516-47e5-8727-e7f798e8992d", "values": ["userId", "userId2"] }, { "kind": "removeUserTargets", "variationId": "8bfb304e-d516-47e5-8727-e7f798e8992d", "values": ["userId3", "userId4"] }, { "kind": "updateFallthroughVariationOrRollout", "rolloutWeights": { "variationId": 50000, "variationId2": 50000 }, "rolloutBucketBy": null }, { "kind": "addRule", "clauses": [ { "attribute": "segmentMatch", "negate": false, "values": ["test-segment"] } ], "variationId": null, "rolloutWeights": { "variationId": 50000, "variationId2": 50000 }, "rolloutBucketBy": "key" }, { "kind": "removeRule", "ruleId": "99f12464-a429-40fc-86cc-b27612188955" }, { "kind": "reorderRules", "ruleIds": ["2f72974e-de68-4243-8dd3-739582147a1f", "8bfb304e-d516-47e5-8727-e7f798e8992d"] }, { "kind": "addClauses", "ruleId": "1134", "clauses": [ { "attribute": "email", "op": "in", "negate": false, "values": ["test@test.com"] } ] }, { "kind": "removeClauses", "ruleId": "1242529", "clauseIds": ["8bfb304e-d516-47e5-8727-e7f798e8992d"] }, { "kind": "updateClause", "ruleId": "2f72974e-de68-4243-8dd3-739582147a1f", "clauseId": "309845", "clause": { "attribute": "segmentMatch", "negate": false, "values": ["test-segment"] } }, { "kind": "updateRuleVariationOrRollout", "ruleId": "2342", "rolloutWeights": null, "rolloutBucketBy": null }, { "kind": "updateOffVariation", "variationId": "3242453" }, { "kind": "addPrerequisite", "variationId": "234235", "key": "flagKey2" }, { "kind": "updatePrerequisite", "variationId": "234235", "key": "flagKey2" }, { "kind": "removePrerequisite", "key": "flagKey" } ] } “` ## Using JSON Patches on a feature flag If you do not include the header described above, you can use [JSON patch](/reference#updates-via-json-patch). When using the update feature flag endpoint to add individual users to a specific variation, there are two different patch documents, depending on whether users are already being individually targeted for the variation. If a flag variation already has users individually targeted, the path for the JSON Patch operation is: “`json { "op": "add", "path": "/environments/devint/targets/0/values/-", "value": "TestClient10" } “` If a flag variation does not already have users individually targeted, the path for the JSON Patch operation is: “`json [ { "op": "add", "path": "/environments/devint/targets/-", "value": { "variation": 0, "values": ["TestClient10"] } } ] “` ## Required approvals If a request attempts to alter a flag configuration in an environment where approvals are required for the flag, the request will fail with a 405. Changes to the flag configuration in that environment will required creating an [approval request](/tag/Approvals) or a [workflow](/tag/Workflows-(beta)). This behavior can be bypassed by users and access tokens that have a [custom role](docs.launchdarkly.com/home/members/custom-roles) with permission to perform the `bypassRequiredApproval` action on the flag. ## Conflicts If a flag configuration change made through this endpoint would cause a pending scheduled change or approval request to fail, this endpoint will return a 400. You can ignore this check by adding an `ignoreConflicts` query parameter set to `true`.

Parameters:

  • project_key (String)

    The project key

  • feature_flag_key (String)

    The feature flag key. The key identifies the flag in your code.

  • patch_with_comment (PatchWithComment)
  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:



717
718
719
720
# File 'lib/launchdarkly_api/api/feature_flags_api.rb', line 717

def patch_feature_flag(project_key, feature_flag_key, patch_with_comment, opts = {})
  data, _status_code, _headers = patch_feature_flag_with_http_info(project_key, feature_flag_key, patch_with_comment, opts)
  data
end

#patch_feature_flag_with_http_info(project_key, feature_flag_key, patch_with_comment, opts = {}) ⇒ Array<(FeatureFlag, Integer, Hash)>

Update feature flag Perform a partial update to a feature flag. ## Using semantic patches on a feature flag To use a [semantic patch](/reference#updates-via-semantic-patches) on a feature flag resource, you must include a header in the request. If you call a semantic patch resource without this header, you will receive a &#x60;400&#x60; response because your semantic patch will be interpreted as a JSON patch. Use this header: &#x60;&#x60;&#x60; Content-Type: application/json; domain-model&#x3D;launchdarkly.semanticpatch &#x60;&#x60;&#x60; The body of a semantic patch request takes the following three properties: 1. &#x60;comment&#x60; (string): (Optional) A description of the update. 1. &#x60;environmentKey&#x60; (string): (Required) The key of the LaunchDarkly environment. 1. &#x60;instructions&#x60; (array): (Required) The list of actions to be performed by the update. Each action in the list must be an object/hash table with a &#x60;kind&#x60; property that indicates the instruction. Depending on the &#x60;kind&#x60;, the API may require other parameters. When this is the case, add the parameters as additional fields to the instruction object. Read below for more information on the specific supported semantic patch instructions. If any instruction in the patch encounters an error, the error will be returned and the flag will not be changed. In general, instructions will silently do nothing if the flag is already in the state requested by the patch instruction. For example, &#x60;removeUserTargets&#x60; does nothing when the targets have already been removed. They will generally error if a parameter refers to something that does not exist, like a variation ID that doesn&#39;t correspond to a variation on the flag or a rule ID that doesn&#39;t belong to a rule on the flag. Other specific error conditions are noted in the instruction descriptions. ### Instructions #### &#x60;turnFlagOn&#x60; Sets the flag&#39;s targeting state to on. For example, to flip a flag on, use this request body: &#x60;&#x60;&#x60;json { &quot;environmentKey&quot;: &quot;example-environment-key&quot;, &quot;instructions&quot;: [ { &quot;kind&quot;: &quot;turnFlagOn&quot; } ] } &#x60;&#x60;&#x60; #### &#x60;turnFlagOff&#x60; Sets the flag&#39;s targeting state to off. For example, to flip a flag off, use this request body: &#x60;&#x60;&#x60;json { &quot;environmentKey&quot;: &quot;example-environment-key&quot;, &quot;instructions&quot;: [ { &quot;kind&quot;: &quot;turnFlagOff&quot; } ] } &#x60;&#x60;&#x60; #### &#x60;addUserTargets&#x60; Adds the user keys in &#x60;values&#x60; to the individual user targets for the variation specified by &#x60;variationId&#x60;. Returns an error if this causes the same user key to be targeted in multiple variations. ##### Parameters - &#x60;values&#x60;: list of user keys - &#x60;variationId&#x60;: ID of a variation on the flag #### &#x60;removeUserTargets&#x60; Removes the user keys in &#x60;values&#x60; to the individual user targets for the variation specified by &#x60;variationId&#x60;. Does nothing if the user keys are not targeted. ##### Parameters - &#x60;values&#x60;: list of user keys - &#x60;variationId&#x60;: ID of a variation on the flag #### &#x60;replaceUserTargets&#x60; Completely replaces the existing set of user targeting. All variations must be provided. Example: &#x60;&#x60;&#x60;json { &quot;kind&quot;: &quot;replaceUserTargets&quot;, &quot;targets&quot;: [ { &quot;variationId&quot;: &quot;variation-1&quot;, &quot;values&quot;: [&quot;blah&quot;, &quot;foo&quot;, &quot;bar&quot;] }, { &quot;variationId&quot;: &quot;variation-2&quot;, &quot;values&quot;: [&quot;abc&quot;, &quot;def&quot;] } ] } &#x60;&#x60;&#x60; ##### Parameters - &#x60;targets&#x60;: a list of user targeting #### &#x60;clearUserTargets&#x60; Removes all individual user targets from the variation specified by &#x60;variationId&#x60; ##### Parameters - &#x60;variationId&#x60;: ID of a variation on the flag #### &#x60;addPrerequisite&#x60; Adds the flag indicated by &#x60;key&#x60; with variation &#x60;variationId&#x60; as a prerequisite to the flag. ##### Parameters - &#x60;key&#x60;: flag key of another flag - &#x60;variationId&#x60;: ID of a variation of the flag with key &#x60;key&#x60; #### &#x60;removePrerequisite&#x60; Removes the prerequisite indicated by &#x60;key&#x60;. Does nothing if this prerequisite does not exist. ##### Parameters - &#x60;key&#x60;: flag key of an existing prerequisite #### &#x60;updatePrerequisite&#x60; Changes the prerequisite with flag key &#x60;key&#x60; to the variation indicated by &#x60;variationId&#x60;. Returns an error if this prerequisite does not exist. ##### Parameters - &#x60;key&#x60;: flag key of an existing prerequisite - &#x60;variationId&#x60;: ID of a variation of the flag with key &#x60;key&#x60; #### &#x60;replacePrerequisites&#x60; Completely replaces the existing set of prerequisites for a given flag. Example: &#x60;&#x60;&#x60;json { &quot;kind&quot;: &quot;replacePrerequisites&quot;, &quot;prerequisites&quot;: [ { &quot;key&quot;: &quot;flag-key&quot;, &quot;variationId&quot;: &quot;variation-1&quot; }, { &quot;key&quot;: &quot;another-flag&quot;, &quot;variationId&quot;: &quot;variation-2&quot; } ] } &#x60;&#x60;&#x60; ##### Parameters - &#x60;prerequisites&#x60;: a list of prerequisites #### &#x60;addRule&#x60; Adds a new rule to the flag with the given &#x60;clauses&#x60; which serves the variation indicated by &#x60;variationId&#x60; or the percent rollout indicated by &#x60;rolloutWeights&#x60; and &#x60;rolloutBucketBy&#x60;. If &#x60;beforeRuleId&#x60; is set, the rule will be added in the list of rules before the indicated rule. Otherwise, the rule will be added to the end of the list. ##### Parameters - &#x60;clauses&#x60;: Array of clauses (see &#x60;addClauses&#x60;) - &#x60;beforeRuleId&#x60;: Optional ID of a rule in the flag - &#x60;variationId&#x60;: ID of a variation of the flag - &#x60;rolloutWeights&#x60;: Map of variationId to weight in thousandths of a percent (0-100000) - &#x60;rolloutBucketBy&#x60;: Optional user attribute #### &#x60;removeRule&#x60; Removes the targeting rule specified by &#x60;ruleId&#x60;. Does nothing if the rule does not exist. ##### Parameters - &#x60;ruleId&#x60;: ID of a rule in the flag #### &#x60;replaceRules&#x60; Completely replaces the existing rules for a given flag. Example: &#x60;&#x60;&#x60;json { &quot;kind&quot;: &quot;replaceRules&quot;, &quot;rules&quot;: [ { &quot;variationId&quot;: &quot;variation-1&quot;, &quot;description&quot;: &quot;myRule&quot;, &quot;clauses&quot;: [ { &quot;attribute&quot;: &quot;segmentMatch&quot;, &quot;op&quot;: &quot;segmentMatch&quot;, &quot;values&quot;: [&quot;test&quot;] } ], &quot;trackEvents&quot;: true } ] } &#x60;&#x60;&#x60; ##### Parameters - &#x60;rules&#x60;: a list of rules #### &#x60;addClauses&#x60; Adds the given clauses to the rule indicated by &#x60;ruleId&#x60;. ##### Parameters - &#x60;ruleId&#x60;: ID of a rule in the flag - &#x60;clauses&#x60;: Array of clause objects, with &#x60;attribute&#x60; (string), &#x60;op&#x60; (string), and &#x60;values&#x60; (array of strings, numbers, or dates) properties. #### &#x60;removeClauses&#x60; Removes the clauses specified by &#x60;clauseIds&#x60; from the rule indicated by &#x60;ruleId&#x60;. #### Parameters - &#x60;ruleId&#x60;: ID of a rule in the flag - &#x60;clauseIds&#x60;: Array of IDs of clauses in the rule #### &#x60;updateClause&#x60; Replaces the clause indicated by &#x60;ruleId&#x60; and &#x60;clauseId&#x60; with &#x60;clause&#x60;. ##### Parameters - &#x60;ruleId&#x60;: ID of a rule in the flag - &#x60;clauseId&#x60;: ID of a clause in that rule - &#x60;clause&#x60;: Clause object #### &#x60;addValuesToClause&#x60; Adds &#x60;values&#x60; to the values of the clause indicated by &#x60;ruleId&#x60; and &#x60;clauseId&#x60;. ##### Parameters - &#x60;ruleId&#x60;: ID of a rule in the flag - &#x60;clauseId&#x60;: ID of a clause in that rule - &#x60;values&#x60;: Array of strings #### &#x60;removeValuesFromClause&#x60; Removes &#x60;values&#x60; from the values of the clause indicated by &#x60;ruleId&#x60; and &#x60;clauseId&#x60;. ##### Parameters &#x60;ruleId&#x60;: ID of a rule in the flag &#x60;clauseId&#x60;: ID of a clause in that rule &#x60;values&#x60;: Array of strings #### &#x60;reorderRules&#x60; Rearranges the rules to match the order given in &#x60;ruleIds&#x60;. Will return an error if &#x60;ruleIds&#x60; does not match the current set of rules on the flag. ##### Parameters - &#x60;ruleIds&#x60;: Array of IDs of all rules in the flag #### &#x60;updateRuleVariationOrRollout&#x60; Updates what the rule indicated by &#x60;ruleId&#x60; serves if its clauses evaluate to true. Can either be a fixed variation indicated by &#x60;variationId&#x60; or a percent rollout indicated by &#x60;rolloutWeights&#x60; and &#x60;rolloutBucketBy&#x60;. ##### Parameters - &#x60;ruleId&#x60;: ID of a rule in the flag - &#x60;variationId&#x60;: ID of a variation of the flag or - &#x60;rolloutWeights&#x60;: Map of variationId to weight in thousandths of a percent (0-100000) - &#x60;rolloutBucketBy&#x60;: Optional user attribute #### &#x60;updateFallthroughVariationOrRollout&#x60; Updates the flag&#39;s fallthrough, which is served if none of the targeting rules match. Can either be a fixed variation indicated by &#x60;variationId&#x60; or a percent rollout indicated by &#x60;rolloutWeights&#x60; and &#x60;rolloutBucketBy&#x60;. ##### Parameters &#x60;variationId&#x60;: ID of a variation of the flag or &#x60;rolloutWeights&#x60;: Map of variationId to weight in thousandths of a percent (0-100000) &#x60;rolloutBucketBy&#x60;: Optional user attribute #### &#x60;updateOffVariation&#x60; Updates the variation served when the flag&#39;s targeting is off to the variation indicated by &#x60;variationId&#x60;. ##### Parameters &#x60;variationId&#x60;: ID of a variation of the flag ### Example &#x60;&#x60;&#x60;json { &quot;environmentKey&quot;: &quot;production&quot;, &quot;instructions&quot;: [ { &quot;kind&quot;: &quot;turnFlagOn&quot; }, { &quot;kind&quot;: &quot;turnFlagOff&quot; }, { &quot;kind&quot;: &quot;addUserTargets&quot;, &quot;variationId&quot;: &quot;8bfb304e-d516-47e5-8727-e7f798e8992d&quot;, &quot;values&quot;: [&quot;userId&quot;, &quot;userId2&quot;] }, { &quot;kind&quot;: &quot;removeUserTargets&quot;, &quot;variationId&quot;: &quot;8bfb304e-d516-47e5-8727-e7f798e8992d&quot;, &quot;values&quot;: [&quot;userId3&quot;, &quot;userId4&quot;] }, { &quot;kind&quot;: &quot;updateFallthroughVariationOrRollout&quot;, &quot;rolloutWeights&quot;: { &quot;variationId&quot;: 50000, &quot;variationId2&quot;: 50000 }, &quot;rolloutBucketBy&quot;: null }, { &quot;kind&quot;: &quot;addRule&quot;, &quot;clauses&quot;: [ { &quot;attribute&quot;: &quot;segmentMatch&quot;, &quot;negate&quot;: false, &quot;values&quot;: [&quot;test-segment&quot;] } ], &quot;variationId&quot;: null, &quot;rolloutWeights&quot;: { &quot;variationId&quot;: 50000, &quot;variationId2&quot;: 50000 }, &quot;rolloutBucketBy&quot;: &quot;key&quot; }, { &quot;kind&quot;: &quot;removeRule&quot;, &quot;ruleId&quot;: &quot;99f12464-a429-40fc-86cc-b27612188955&quot; }, { &quot;kind&quot;: &quot;reorderRules&quot;, &quot;ruleIds&quot;: [&quot;2f72974e-de68-4243-8dd3-739582147a1f&quot;, &quot;8bfb304e-d516-47e5-8727-e7f798e8992d&quot;] }, { &quot;kind&quot;: &quot;addClauses&quot;, &quot;ruleId&quot;: &quot;1134&quot;, &quot;clauses&quot;: [ { &quot;attribute&quot;: &quot;email&quot;, &quot;op&quot;: &quot;in&quot;, &quot;negate&quot;: false, &quot;values&quot;: [&quot;test@test.com&quot;] } ] }, { &quot;kind&quot;: &quot;removeClauses&quot;, &quot;ruleId&quot;: &quot;1242529&quot;, &quot;clauseIds&quot;: [&quot;8bfb304e-d516-47e5-8727-e7f798e8992d&quot;] }, { &quot;kind&quot;: &quot;updateClause&quot;, &quot;ruleId&quot;: &quot;2f72974e-de68-4243-8dd3-739582147a1f&quot;, &quot;clauseId&quot;: &quot;309845&quot;, &quot;clause&quot;: { &quot;attribute&quot;: &quot;segmentMatch&quot;, &quot;negate&quot;: false, &quot;values&quot;: [&quot;test-segment&quot;] } }, { &quot;kind&quot;: &quot;updateRuleVariationOrRollout&quot;, &quot;ruleId&quot;: &quot;2342&quot;, &quot;rolloutWeights&quot;: null, &quot;rolloutBucketBy&quot;: null }, { &quot;kind&quot;: &quot;updateOffVariation&quot;, &quot;variationId&quot;: &quot;3242453&quot; }, { &quot;kind&quot;: &quot;addPrerequisite&quot;, &quot;variationId&quot;: &quot;234235&quot;, &quot;key&quot;: &quot;flagKey2&quot; }, { &quot;kind&quot;: &quot;updatePrerequisite&quot;, &quot;variationId&quot;: &quot;234235&quot;, &quot;key&quot;: &quot;flagKey2&quot; }, { &quot;kind&quot;: &quot;removePrerequisite&quot;, &quot;key&quot;: &quot;flagKey&quot; } ] } &#x60;&#x60;&#x60; ## Using JSON Patches on a feature flag If you do not include the header described above, you can use [JSON patch](/reference#updates-via-json-patch). When using the update feature flag endpoint to add individual users to a specific variation, there are two different patch documents, depending on whether users are already being individually targeted for the variation. If a flag variation already has users individually targeted, the path for the JSON Patch operation is: &#x60;&#x60;&#x60;json { &quot;op&quot;: &quot;add&quot;, &quot;path&quot;: &quot;/environments/devint/targets/0/values/-&quot;, &quot;value&quot;: &quot;TestClient10&quot; } &#x60;&#x60;&#x60; If a flag variation does not already have users individually targeted, the path for the JSON Patch operation is: &#x60;&#x60;&#x60;json [ { &quot;op&quot;: &quot;add&quot;, &quot;path&quot;: &quot;/environments/devint/targets/-&quot;, &quot;value&quot;: { &quot;variation&quot;: 0, &quot;values&quot;: [&quot;TestClient10&quot;] } } ] &#x60;&#x60;&#x60; ## Required approvals If a request attempts to alter a flag configuration in an environment where approvals are required for the flag, the request will fail with a 405. Changes to the flag configuration in that environment will required creating an [approval request](/tag/Approvals) or a [workflow](/tag/Workflows-(beta)). This behavior can be bypassed by users and access tokens that have a [custom role](docs.launchdarkly.com/home/members/custom-roles) with permission to perform the &#x60;bypassRequiredApproval&#x60; action on the flag. ## Conflicts If a flag configuration change made through this endpoint would cause a pending scheduled change or approval request to fail, this endpoint will return a 400. You can ignore this check by adding an &#x60;ignoreConflicts&#x60; query parameter set to &#x60;true&#x60;.

Parameters:

  • project_key (String)

    The project key

  • feature_flag_key (String)

    The feature flag key. The key identifies the flag in your code.

  • patch_with_comment (PatchWithComment)
  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (Array<(FeatureFlag, Integer, Hash)>)

    FeatureFlag data, response status code and response headers



729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
# File 'lib/launchdarkly_api/api/feature_flags_api.rb', line 729

def patch_feature_flag_with_http_info(project_key, feature_flag_key, patch_with_comment, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: FeatureFlagsApi.patch_feature_flag ...'
  end
  # verify the required parameter 'project_key' is set
  if @api_client.config.client_side_validation && project_key.nil?
    fail ArgumentError, "Missing the required parameter 'project_key' when calling FeatureFlagsApi.patch_feature_flag"
  end
  # verify the required parameter 'feature_flag_key' is set
  if @api_client.config.client_side_validation && feature_flag_key.nil?
    fail ArgumentError, "Missing the required parameter 'feature_flag_key' when calling FeatureFlagsApi.patch_feature_flag"
  end
  # verify the required parameter 'patch_with_comment' is set
  if @api_client.config.client_side_validation && patch_with_comment.nil?
    fail ArgumentError, "Missing the required parameter 'patch_with_comment' when calling FeatureFlagsApi.patch_feature_flag"
  end
  # resource path
  local_var_path = '/api/v2/flags/{projectKey}/{featureFlagKey}'.sub('{' + 'projectKey' + '}', CGI.escape(project_key.to_s)).sub('{' + 'featureFlagKey' + '}', CGI.escape(feature_flag_key.to_s))

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json'])
  # HTTP header 'Content-Type'
  content_type = @api_client.select_header_content_type(['application/json'])
  if !content_type.nil?
      header_params['Content-Type'] = content_type
  end

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body] || @api_client.object_to_http_body(patch_with_comment)

  # return_type
  return_type = opts[:debug_return_type] || 'FeatureFlag'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['ApiKey']

  new_options = opts.merge(
    :operation => :"FeatureFlagsApi.patch_feature_flag",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:PATCH, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: FeatureFlagsApi#patch_feature_flag\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#post_feature_flag(project_key, feature_flag_body, opts = {}) ⇒ FeatureFlag

Create a feature flag Create a feature flag with the given name, key, and variations

Parameters:

  • project_key (String)

    The project key

  • feature_flag_body (FeatureFlagBody)
  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :clone (String)

    The key of the feature flag to be cloned. The key identifies the flag in your code. For example, setting &#x60;clone&#x3D;flagKey&#x60; copies the full targeting configuration for all environments, including &#x60;on/off&#x60; state, from the original flag to the new flag.

Returns:



797
798
799
800
# File 'lib/launchdarkly_api/api/feature_flags_api.rb', line 797

def post_feature_flag(project_key, feature_flag_body, opts = {})
  data, _status_code, _headers = post_feature_flag_with_http_info(project_key, feature_flag_body, opts)
  data
end

#post_feature_flag_with_http_info(project_key, feature_flag_body, opts = {}) ⇒ Array<(FeatureFlag, Integer, Hash)>

Create a feature flag Create a feature flag with the given name, key, and variations

Parameters:

  • project_key (String)

    The project key

  • feature_flag_body (FeatureFlagBody)
  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :clone (String)

    The key of the feature flag to be cloned. The key identifies the flag in your code. For example, setting &#x60;clone&#x3D;flagKey&#x60; copies the full targeting configuration for all environments, including &#x60;on/off&#x60; state, from the original flag to the new flag.

Returns:

  • (Array<(FeatureFlag, Integer, Hash)>)

    FeatureFlag data, response status code and response headers



809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
# File 'lib/launchdarkly_api/api/feature_flags_api.rb', line 809

def post_feature_flag_with_http_info(project_key, feature_flag_body, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: FeatureFlagsApi.post_feature_flag ...'
  end
  # verify the required parameter 'project_key' is set
  if @api_client.config.client_side_validation && project_key.nil?
    fail ArgumentError, "Missing the required parameter 'project_key' when calling FeatureFlagsApi.post_feature_flag"
  end
  # verify the required parameter 'feature_flag_body' is set
  if @api_client.config.client_side_validation && feature_flag_body.nil?
    fail ArgumentError, "Missing the required parameter 'feature_flag_body' when calling FeatureFlagsApi.post_feature_flag"
  end
  # resource path
  local_var_path = '/api/v2/flags/{projectKey}'.sub('{' + 'projectKey' + '}', CGI.escape(project_key.to_s))

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'clone'] = opts[:'clone'] if !opts[:'clone'].nil?

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json'])
  # HTTP header 'Content-Type'
  content_type = @api_client.select_header_content_type(['application/json'])
  if !content_type.nil?
      header_params['Content-Type'] = content_type
  end

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body] || @api_client.object_to_http_body(feature_flag_body)

  # return_type
  return_type = opts[:debug_return_type] || 'FeatureFlag'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['ApiKey']

  new_options = opts.merge(
    :operation => :"FeatureFlagsApi.post_feature_flag",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: FeatureFlagsApi#post_feature_flag\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end