Class: LaunchDarklyApi::ContextsApi

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_client = ApiClient.default) ⇒ ContextsApi

Returns a new instance of ContextsApi.



19
20
21
# File 'lib/launchdarkly_api/api/contexts_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/contexts_api.rb', line 17

def api_client
  @api_client
end

Instance Method Details

#delete_context_instances(project_key, environment_key, id, opts = {}) ⇒ nil

Delete context instances Delete context instances by ID.

Parameters:

  • project_key (String)

    The project key

  • environment_key (String)

    The environment key

  • id (String)

    The context instance ID

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

    the optional parameters

Returns:

  • (nil)


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

def delete_context_instances(project_key, environment_key, id, opts = {})
  delete_context_instances_with_http_info(project_key, environment_key, id, opts)
  nil
end

#delete_context_instances_with_http_info(project_key, environment_key, id, opts = {}) ⇒ Array<(nil, Integer, Hash)>

Delete context instances Delete context instances by ID.

Parameters:

  • project_key (String)

    The project key

  • environment_key (String)

    The environment key

  • id (String)

    The context instance ID

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

    the optional parameters

Returns:

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

    nil, 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
# File 'lib/launchdarkly_api/api/contexts_api.rb', line 41

def delete_context_instances_with_http_info(project_key, environment_key, id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: ContextsApi.delete_context_instances ...'
  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 ContextsApi.delete_context_instances"
  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 ContextsApi.delete_context_instances"
  end
  # verify the required parameter 'id' is set
  if @api_client.config.client_side_validation && id.nil?
    fail ArgumentError, "Missing the required parameter 'id' when calling ContextsApi.delete_context_instances"
  end
  # resource path
  local_var_path = '/api/v2/projects/{projectKey}/environments/{environmentKey}/context-instances/{id}'.sub('{' + 'projectKey' + '}', CGI.escape(project_key.to_s)).sub('{' + 'environmentKey' + '}', CGI.escape(environment_key.to_s)).sub('{' + 'id' + '}', CGI.escape(id.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 => :"ContextsApi.delete_context_instances",
    :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: ContextsApi#delete_context_instances\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#evaluate_context_instance(project_key, environment_key, request_body, opts = {}) ⇒ ContextInstanceEvaluations

Evaluate flags for context instance Evaluate flags for a context instance, for example, to determine the expected flag variation. **Do not use this API instead of an SDK.** The LaunchDarkly SDKs are specialized for the tasks of evaluating feature flags in your application at scale and generating analytics events based on those evaluations. This API is not designed for that use case. Any evaluations you perform with this API will not be reflected in features such as flag statuses and flag insights. Context instances evaluated by this API will not appear in the Contexts list. To learn more, read [Comparing LaunchDarkly’s SDKs and REST API](docs.launchdarkly.com/guide/api/comparing-sdk-rest-api).

Parameters:

  • project_key (String)

    The project key

  • environment_key (String)

    The environment key

  • request_body (Hash<String, Object>)
  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :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 items in the list, up to the query &#x60;limit&#x60;.

  • :sort (String)

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

  • :filter (String)

    A comma-separated list of filters. Each filter is of the form field:value. Supports the same filters as the List Feature Flags API.

Returns:



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

def evaluate_context_instance(project_key, environment_key, request_body, opts = {})
  data, _status_code, _headers = evaluate_context_instance_with_http_info(project_key, environment_key, request_body, opts)
  data
end

#evaluate_context_instance_with_http_info(project_key, environment_key, request_body, opts = {}) ⇒ Array<(ContextInstanceEvaluations, Integer, Hash)>

Evaluate flags for context instance Evaluate flags for a context instance, for example, to determine the expected flag variation. **Do not use this API instead of an SDK.** The LaunchDarkly SDKs are specialized for the tasks of evaluating feature flags in your application at scale and generating analytics events based on those evaluations. This API is not designed for that use case. Any evaluations you perform with this API will not be reflected in features such as flag statuses and flag insights. Context instances evaluated by this API will not appear in the Contexts list. To learn more, read [Comparing LaunchDarkly&#39;s SDKs and REST API](docs.launchdarkly.com/guide/api/comparing-sdk-rest-api).

Parameters:

  • project_key (String)

    The project key

  • environment_key (String)

    The environment key

  • request_body (Hash<String, Object>)
  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :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 items in the list, up to the query &#x60;limit&#x60;.

  • :sort (String)

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

  • :filter (String)

    A comma-separated list of filters. Each filter is of the form field:value. Supports the same filters as the List Feature Flags API.

Returns:

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

    ContextInstanceEvaluations data, response status code and response headers



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
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
# File 'lib/launchdarkly_api/api/contexts_api.rb', line 124

def evaluate_context_instance_with_http_info(project_key, environment_key, request_body, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: ContextsApi.evaluate_context_instance ...'
  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 ContextsApi.evaluate_context_instance"
  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 ContextsApi.evaluate_context_instance"
  end
  # verify the required parameter 'request_body' is set
  if @api_client.config.client_side_validation && request_body.nil?
    fail ArgumentError, "Missing the required parameter 'request_body' when calling ContextsApi.evaluate_context_instance"
  end
  # resource path
  local_var_path = '/api/v2/projects/{projectKey}/environments/{environmentKey}/flags/evaluate'.sub('{' + 'projectKey' + '}', CGI.escape(project_key.to_s)).sub('{' + 'environmentKey' + '}', CGI.escape(environment_key.to_s))

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'limit'] = opts[:'limit'] if !opts[:'limit'].nil?
  query_params[:'offset'] = opts[:'offset'] if !opts[:'offset'].nil?
  query_params[:'sort'] = opts[:'sort'] if !opts[:'sort'].nil?
  query_params[:'filter'] = opts[:'filter'] if !opts[:'filter'].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(request_body)

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

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

  new_options = opts.merge(
    :operation => :"ContextsApi.evaluate_context_instance",
    :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: ContextsApi#evaluate_context_instance\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#get_context_attribute_names(project_key, environment_key, opts = {}) ⇒ ContextAttributeNamesCollection

Get context attribute names Get context attribute names.

Parameters:

  • project_key (String)

    The project key

  • environment_key (String)

    The environment key

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

    the optional parameters

Options Hash (opts):

  • :filter (String)

    A comma-separated list of context filters. This endpoint only accepts &#x60;kind&#x60; filters, with the &#x60;equals&#x60; operator, and &#x60;name&#x60; filters, with the &#x60;startsWith&#x60; operator. To learn more about the filter syntax, read [Filtering contexts and context instances](/tag/Contexts-(beta)#filtering-contexts-and-context-instances).

Returns:



196
197
198
199
# File 'lib/launchdarkly_api/api/contexts_api.rb', line 196

def get_context_attribute_names(project_key, environment_key, opts = {})
  data, _status_code, _headers = get_context_attribute_names_with_http_info(project_key, environment_key, opts)
  data
end

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

Get context attribute names Get context attribute names.

Parameters:

  • project_key (String)

    The project key

  • environment_key (String)

    The environment key

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

    the optional parameters

Options Hash (opts):

  • :filter (String)

    A comma-separated list of context filters. This endpoint only accepts &#x60;kind&#x60; filters, with the &#x60;equals&#x60; operator, and &#x60;name&#x60; filters, with the &#x60;startsWith&#x60; operator. To learn more about the filter syntax, read [Filtering contexts and context instances](/tag/Contexts-(beta)#filtering-contexts-and-context-instances).

Returns:



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
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
# File 'lib/launchdarkly_api/api/contexts_api.rb', line 208

def get_context_attribute_names_with_http_info(project_key, environment_key, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: ContextsApi.get_context_attribute_names ...'
  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 ContextsApi.get_context_attribute_names"
  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 ContextsApi.get_context_attribute_names"
  end
  # resource path
  local_var_path = '/api/v2/projects/{projectKey}/environments/{environmentKey}/context-attributes'.sub('{' + 'projectKey' + '}', CGI.escape(project_key.to_s)).sub('{' + 'environmentKey' + '}', CGI.escape(environment_key.to_s))

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'filter'] = opts[:'filter'] if !opts[:'filter'].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] || 'ContextAttributeNamesCollection'

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

  new_options = opts.merge(
    :operation => :"ContextsApi.get_context_attribute_names",
    :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: ContextsApi#get_context_attribute_names\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#get_context_attribute_values(project_key, environment_key, attribute_name, opts = {}) ⇒ ContextAttributeValuesCollection

Get context attribute values Get context attribute values.

Parameters:

  • project_key (String)

    The project key

  • environment_key (String)

    The environment key

  • attribute_name (String)

    The attribute name

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

    the optional parameters

Options Hash (opts):

  • :filter (String)

    A comma-separated list of context filters. This endpoint only accepts &#x60;kind&#x60; filters, with the &#x60;equals&#x60; operator, and &#x60;value&#x60; filters, with the &#x60;startsWith&#x60; operator. To learn more about the filter syntax, read [Filtering contexts and context instances](/tag/Contexts-(beta)#filtering-contexts-and-context-instances).

Returns:



269
270
271
272
# File 'lib/launchdarkly_api/api/contexts_api.rb', line 269

def get_context_attribute_values(project_key, environment_key, attribute_name, opts = {})
  data, _status_code, _headers = get_context_attribute_values_with_http_info(project_key, environment_key, attribute_name, opts)
  data
end

#get_context_attribute_values_with_http_info(project_key, environment_key, attribute_name, opts = {}) ⇒ Array<(ContextAttributeValuesCollection, Integer, Hash)>

Get context attribute values Get context attribute values.

Parameters:

  • project_key (String)

    The project key

  • environment_key (String)

    The environment key

  • attribute_name (String)

    The attribute name

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

    the optional parameters

Options Hash (opts):

  • :filter (String)

    A comma-separated list of context filters. This endpoint only accepts &#x60;kind&#x60; filters, with the &#x60;equals&#x60; operator, and &#x60;value&#x60; filters, with the &#x60;startsWith&#x60; operator. To learn more about the filter syntax, read [Filtering contexts and context instances](/tag/Contexts-(beta)#filtering-contexts-and-context-instances).

Returns:



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
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
# File 'lib/launchdarkly_api/api/contexts_api.rb', line 282

def get_context_attribute_values_with_http_info(project_key, environment_key, attribute_name, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: ContextsApi.get_context_attribute_values ...'
  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 ContextsApi.get_context_attribute_values"
  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 ContextsApi.get_context_attribute_values"
  end
  # verify the required parameter 'attribute_name' is set
  if @api_client.config.client_side_validation && attribute_name.nil?
    fail ArgumentError, "Missing the required parameter 'attribute_name' when calling ContextsApi.get_context_attribute_values"
  end
  # resource path
  local_var_path = '/api/v2/projects/{projectKey}/environments/{environmentKey}/context-attributes/{attributeName}'.sub('{' + 'projectKey' + '}', CGI.escape(project_key.to_s)).sub('{' + 'environmentKey' + '}', CGI.escape(environment_key.to_s)).sub('{' + 'attributeName' + '}', CGI.escape(attribute_name.to_s))

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'filter'] = opts[:'filter'] if !opts[:'filter'].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] || 'ContextAttributeValuesCollection'

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

  new_options = opts.merge(
    :operation => :"ContextsApi.get_context_attribute_values",
    :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: ContextsApi#get_context_attribute_values\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#get_context_instances(project_key, environment_key, id, opts = {}) ⇒ ContextInstances

Get context instances Get context instances by ID.

Parameters:

  • project_key (String)

    The project key

  • environment_key (String)

    The environment key

  • id (String)

    The context instance ID

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

    the optional parameters

Options Hash (opts):

  • :limit (Integer)

    Specifies the maximum number of context instances to return (max: 50, default: 20)

  • :continuation_token (String)

    Limits results to context instances with sort values after the value specified. You can use this for pagination, however, we recommend using the &#x60;next&#x60; link we provide instead.

  • :sort (String)

    Specifies a field by which to sort. LaunchDarkly supports sorting by timestamp in ascending order by specifying &#x60;ts&#x60; for this value, or descending order by specifying &#x60;-ts&#x60;.

  • :filter (String)

    A comma-separated list of context filters. This endpoint only accepts an &#x60;applicationId&#x60; filter. To learn more about the filter syntax, read [Filtering contexts and context instances](/tag/Contexts-(beta)#filtering-contexts-and-context-instances).

  • :include_total_count (Boolean)

    Specifies whether to include or omit the total count of matching context instances. Defaults to true.

Returns:



351
352
353
354
# File 'lib/launchdarkly_api/api/contexts_api.rb', line 351

def get_context_instances(project_key, environment_key, id, opts = {})
  data, _status_code, _headers = get_context_instances_with_http_info(project_key, environment_key, id, opts)
  data
end

#get_context_instances_with_http_info(project_key, environment_key, id, opts = {}) ⇒ Array<(ContextInstances, Integer, Hash)>

Get context instances Get context instances by ID.

Parameters:

  • project_key (String)

    The project key

  • environment_key (String)

    The environment key

  • id (String)

    The context instance ID

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

    the optional parameters

Options Hash (opts):

  • :limit (Integer)

    Specifies the maximum number of context instances to return (max: 50, default: 20)

  • :continuation_token (String)

    Limits results to context instances with sort values after the value specified. You can use this for pagination, however, we recommend using the &#x60;next&#x60; link we provide instead.

  • :sort (String)

    Specifies a field by which to sort. LaunchDarkly supports sorting by timestamp in ascending order by specifying &#x60;ts&#x60; for this value, or descending order by specifying &#x60;-ts&#x60;.

  • :filter (String)

    A comma-separated list of context filters. This endpoint only accepts an &#x60;applicationId&#x60; filter. To learn more about the filter syntax, read [Filtering contexts and context instances](/tag/Contexts-(beta)#filtering-contexts-and-context-instances).

  • :include_total_count (Boolean)

    Specifies whether to include or omit the total count of matching context instances. Defaults to true.

Returns:

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

    ContextInstances data, response status code and response headers



368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
# File 'lib/launchdarkly_api/api/contexts_api.rb', line 368

def get_context_instances_with_http_info(project_key, environment_key, id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: ContextsApi.get_context_instances ...'
  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 ContextsApi.get_context_instances"
  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 ContextsApi.get_context_instances"
  end
  # verify the required parameter 'id' is set
  if @api_client.config.client_side_validation && id.nil?
    fail ArgumentError, "Missing the required parameter 'id' when calling ContextsApi.get_context_instances"
  end
  # resource path
  local_var_path = '/api/v2/projects/{projectKey}/environments/{environmentKey}/context-instances/{id}'.sub('{' + 'projectKey' + '}', CGI.escape(project_key.to_s)).sub('{' + 'environmentKey' + '}', CGI.escape(environment_key.to_s)).sub('{' + 'id' + '}', CGI.escape(id.to_s))

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'limit'] = opts[:'limit'] if !opts[:'limit'].nil?
  query_params[:'continuationToken'] = opts[:'continuation_token'] if !opts[:'continuation_token'].nil?
  query_params[:'sort'] = opts[:'sort'] if !opts[:'sort'].nil?
  query_params[:'filter'] = opts[:'filter'] if !opts[:'filter'].nil?
  query_params[:'includeTotalCount'] = opts[:'include_total_count'] if !opts[:'include_total_count'].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] || 'ContextInstances'

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

  new_options = opts.merge(
    :operation => :"ContextsApi.get_context_instances",
    :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: ContextsApi#get_context_instances\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#get_contexts(project_key, environment_key, kind, key, opts = {}) ⇒ Contexts

Get contexts Get contexts based on kind and key.

Parameters:

  • project_key (String)

    The project key

  • environment_key (String)

    The environment key

  • kind (String)

    The context kind

  • key (String)

    The context key

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

    the optional parameters

Options Hash (opts):

  • :limit (Integer)

    Specifies the maximum number of items in the collection to return (max: 50, default: 20)

  • :continuation_token (String)

    Limits results to contexts with sort values after the value specified. You can use this for pagination, however, we recommend using the &#x60;next&#x60; link we provide instead.

  • :sort (String)

    Specifies a field by which to sort. LaunchDarkly supports sorting by timestamp in ascending order by specifying &#x60;ts&#x60; for this value, or descending order by specifying &#x60;-ts&#x60;.

  • :filter (String)

    A comma-separated list of context filters. This endpoint only accepts an &#x60;applicationId&#x60; filter. To learn more about the filter syntax, read [Filtering contexts and context instances](/tag/Contexts-(beta)#filtering-contexts-and-context-instances).

  • :include_total_count (Boolean)

    Specifies whether to include or omit the total count of matching contexts. Defaults to true.

Returns:



442
443
444
445
# File 'lib/launchdarkly_api/api/contexts_api.rb', line 442

def get_contexts(project_key, environment_key, kind, key, opts = {})
  data, _status_code, _headers = get_contexts_with_http_info(project_key, environment_key, kind, key, opts)
  data
end

#get_contexts_with_http_info(project_key, environment_key, kind, key, opts = {}) ⇒ Array<(Contexts, Integer, Hash)>

Get contexts Get contexts based on kind and key.

Parameters:

  • project_key (String)

    The project key

  • environment_key (String)

    The environment key

  • kind (String)

    The context kind

  • key (String)

    The context key

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

    the optional parameters

Options Hash (opts):

  • :limit (Integer)

    Specifies the maximum number of items in the collection to return (max: 50, default: 20)

  • :continuation_token (String)

    Limits results to contexts with sort values after the value specified. You can use this for pagination, however, we recommend using the &#x60;next&#x60; link we provide instead.

  • :sort (String)

    Specifies a field by which to sort. LaunchDarkly supports sorting by timestamp in ascending order by specifying &#x60;ts&#x60; for this value, or descending order by specifying &#x60;-ts&#x60;.

  • :filter (String)

    A comma-separated list of context filters. This endpoint only accepts an &#x60;applicationId&#x60; filter. To learn more about the filter syntax, read [Filtering contexts and context instances](/tag/Contexts-(beta)#filtering-contexts-and-context-instances).

  • :include_total_count (Boolean)

    Specifies whether to include or omit the total count of matching contexts. Defaults to true.

Returns:

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

    Contexts data, response status code and response headers



460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
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
# File 'lib/launchdarkly_api/api/contexts_api.rb', line 460

def get_contexts_with_http_info(project_key, environment_key, kind, key, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: ContextsApi.get_contexts ...'
  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 ContextsApi.get_contexts"
  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 ContextsApi.get_contexts"
  end
  # verify the required parameter 'kind' is set
  if @api_client.config.client_side_validation && kind.nil?
    fail ArgumentError, "Missing the required parameter 'kind' when calling ContextsApi.get_contexts"
  end
  # verify the required parameter 'key' is set
  if @api_client.config.client_side_validation && key.nil?
    fail ArgumentError, "Missing the required parameter 'key' when calling ContextsApi.get_contexts"
  end
  # resource path
  local_var_path = '/api/v2/projects/{projectKey}/environments/{environmentKey}/contexts/{kind}/{key}'.sub('{' + 'projectKey' + '}', CGI.escape(project_key.to_s)).sub('{' + 'environmentKey' + '}', CGI.escape(environment_key.to_s)).sub('{' + 'kind' + '}', CGI.escape(kind.to_s)).sub('{' + 'key' + '}', CGI.escape(key.to_s))

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'limit'] = opts[:'limit'] if !opts[:'limit'].nil?
  query_params[:'continuationToken'] = opts[:'continuation_token'] if !opts[:'continuation_token'].nil?
  query_params[:'sort'] = opts[:'sort'] if !opts[:'sort'].nil?
  query_params[:'filter'] = opts[:'filter'] if !opts[:'filter'].nil?
  query_params[:'includeTotalCount'] = opts[:'include_total_count'] if !opts[:'include_total_count'].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] || 'Contexts'

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

  new_options = opts.merge(
    :operation => :"ContextsApi.get_contexts",
    :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: ContextsApi#get_contexts\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#search_context_instances(project_key, environment_key, context_instance_search, opts = {}) ⇒ ContextInstances

Search for context instances

Search for context instances.  You can use either the query parameters or the request body parameters. If both are provided, there is an error.  To learn more about the filter syntax, read [Filtering contexts and context instances](/tag/Contexts-(beta)#filtering-contexts-and-context-instances). To learn more about context instances, read [Understanding context instances](https://docs.launchdarkly.com/home/contexts#understanding-context-instances).

Parameters:

  • project_key (String)

    The project key

  • environment_key (String)

    The environment key

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

    the optional parameters

Options Hash (opts):

  • :limit (Integer)

    Specifies the maximum number of items in the collection to return (max: 50, default: 20)

  • :continuation_token (String)

    Limits results to context instances with sort values after the value specified. You can use this for pagination, however, we recommend using the &#x60;next&#x60; link we provide instead.

  • :sort (String)

    Specifies a field by which to sort. LaunchDarkly supports sorting by timestamp in ascending order by specifying &#x60;ts&#x60; for this value, or descending order by specifying &#x60;-ts&#x60;.

  • :filter (String)

    A comma-separated list of context filters. This endpoint only accepts an &#x60;applicationId&#x60; filter. To learn more about the filter syntax, read [Filtering contexts and context instances](/tag/Contexts-(beta)#filtering-contexts-and-context-instances).

  • :include_total_count (Boolean)

    Specifies whether to include or omit the total count of matching context instances. Defaults to true.

Returns:



537
538
539
540
# File 'lib/launchdarkly_api/api/contexts_api.rb', line 537

def search_context_instances(project_key, environment_key, context_instance_search, opts = {})
  data, _status_code, _headers = search_context_instances_with_http_info(project_key, environment_key, context_instance_search, opts)
  data
end

#search_context_instances_with_http_info(project_key, environment_key, context_instance_search, opts = {}) ⇒ Array<(ContextInstances, Integer, Hash)>

Search for context instances

Search for context instances.  You can use either the query parameters or the request body parameters. If both are provided, there is an error.  To learn more about the filter syntax, read [Filtering contexts and context instances](/tag/Contexts-(beta)#filtering-contexts-and-context-instances). To learn more about context instances, read [Understanding context instances](https://docs.launchdarkly.com/home/contexts#understanding-context-instances).

Parameters:

  • project_key (String)

    The project key

  • environment_key (String)

    The environment key

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

    the optional parameters

Options Hash (opts):

  • :limit (Integer)

    Specifies the maximum number of items in the collection to return (max: 50, default: 20)

  • :continuation_token (String)

    Limits results to context instances with sort values after the value specified. You can use this for pagination, however, we recommend using the &#x60;next&#x60; link we provide instead.

  • :sort (String)

    Specifies a field by which to sort. LaunchDarkly supports sorting by timestamp in ascending order by specifying &#x60;ts&#x60; for this value, or descending order by specifying &#x60;-ts&#x60;.

  • :filter (String)

    A comma-separated list of context filters. This endpoint only accepts an &#x60;applicationId&#x60; filter. To learn more about the filter syntax, read [Filtering contexts and context instances](/tag/Contexts-(beta)#filtering-contexts-and-context-instances).

  • :include_total_count (Boolean)

    Specifies whether to include or omit the total count of matching context instances. Defaults to true.

Returns:

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

    ContextInstances data, response status code and response headers



554
555
556
557
558
559
560
561
562
563
564
565
566
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
# File 'lib/launchdarkly_api/api/contexts_api.rb', line 554

def search_context_instances_with_http_info(project_key, environment_key, context_instance_search, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: ContextsApi.search_context_instances ...'
  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 ContextsApi.search_context_instances"
  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 ContextsApi.search_context_instances"
  end
  # verify the required parameter 'context_instance_search' is set
  if @api_client.config.client_side_validation && context_instance_search.nil?
    fail ArgumentError, "Missing the required parameter 'context_instance_search' when calling ContextsApi.search_context_instances"
  end
  # resource path
  local_var_path = '/api/v2/projects/{projectKey}/environments/{environmentKey}/context-instances/search'.sub('{' + 'projectKey' + '}', CGI.escape(project_key.to_s)).sub('{' + 'environmentKey' + '}', CGI.escape(environment_key.to_s))

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'limit'] = opts[:'limit'] if !opts[:'limit'].nil?
  query_params[:'continuationToken'] = opts[:'continuation_token'] if !opts[:'continuation_token'].nil?
  query_params[:'sort'] = opts[:'sort'] if !opts[:'sort'].nil?
  query_params[:'filter'] = opts[:'filter'] if !opts[:'filter'].nil?
  query_params[:'includeTotalCount'] = opts[:'include_total_count'] if !opts[:'include_total_count'].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(context_instance_search)

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

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

  new_options = opts.merge(
    :operation => :"ContextsApi.search_context_instances",
    :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: ContextsApi#search_context_instances\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#search_contexts(project_key, environment_key, context_search, opts = {}) ⇒ Contexts

Search for contexts

Search for contexts.  You can use either the query parameters or the request body parameters. If both are provided, there is an error.  To learn more about the filter syntax, read [Filtering contexts and context instances](/tag/Contexts-(beta)#filtering-contexts-and-context-instances). To learn more about contexts, read [Understanding contexts and context kinds](https://docs.launchdarkly.com/home/contexts#understanding-contexts-and-context-kinds).

Parameters:

  • project_key (String)

    The project key

  • environment_key (String)

    The environment key

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

    the optional parameters

Options Hash (opts):

  • :limit (Integer)

    Specifies the maximum number of items in the collection to return (max: 50, default: 20)

  • :continuation_token (String)

    Limits results to contexts with sort values after the value specified. You can use this for pagination, however, we recommend using the &#x60;next&#x60; link we provide instead.

  • :sort (String)

    Specifies a field by which to sort. LaunchDarkly supports sorting by timestamp in ascending order by specifying &#x60;ts&#x60; for this value, or descending order by specifying &#x60;-ts&#x60;.

  • :filter (String)

    A comma-separated list of context filters. To learn more about the filter syntax, read [Filtering contexts and context instances](/tag/Contexts-(beta)#filtering-contexts-and-context-instances).

  • :include_total_count (Boolean)

    Specifies whether to include or omit the total count of matching contexts. Defaults to true.

Returns:



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

def search_contexts(project_key, environment_key, context_search, opts = {})
  data, _status_code, _headers = search_contexts_with_http_info(project_key, environment_key, context_search, opts)
  data
end

#search_contexts_with_http_info(project_key, environment_key, context_search, opts = {}) ⇒ Array<(Contexts, Integer, Hash)>

Search for contexts

Search for contexts.  You can use either the query parameters or the request body parameters. If both are provided, there is an error.  To learn more about the filter syntax, read [Filtering contexts and context instances](/tag/Contexts-(beta)#filtering-contexts-and-context-instances). To learn more about contexts, read [Understanding contexts and context kinds](https://docs.launchdarkly.com/home/contexts#understanding-contexts-and-context-kinds).

Parameters:

  • project_key (String)

    The project key

  • environment_key (String)

    The environment key

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

    the optional parameters

Options Hash (opts):

  • :limit (Integer)

    Specifies the maximum number of items in the collection to return (max: 50, default: 20)

  • :continuation_token (String)

    Limits results to contexts with sort values after the value specified. You can use this for pagination, however, we recommend using the &#x60;next&#x60; link we provide instead.

  • :sort (String)

    Specifies a field by which to sort. LaunchDarkly supports sorting by timestamp in ascending order by specifying &#x60;ts&#x60; for this value, or descending order by specifying &#x60;-ts&#x60;.

  • :filter (String)

    A comma-separated list of context filters. To learn more about the filter syntax, read [Filtering contexts and context instances](/tag/Contexts-(beta)#filtering-contexts-and-context-instances).

  • :include_total_count (Boolean)

    Specifies whether to include or omit the total count of matching contexts. Defaults to true.

Returns:

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

    Contexts data, response status code and response headers



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
709
710
711
712
713
# File 'lib/launchdarkly_api/api/contexts_api.rb', line 649

def search_contexts_with_http_info(project_key, environment_key, context_search, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: ContextsApi.search_contexts ...'
  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 ContextsApi.search_contexts"
  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 ContextsApi.search_contexts"
  end
  # verify the required parameter 'context_search' is set
  if @api_client.config.client_side_validation && context_search.nil?
    fail ArgumentError, "Missing the required parameter 'context_search' when calling ContextsApi.search_contexts"
  end
  # resource path
  local_var_path = '/api/v2/projects/{projectKey}/environments/{environmentKey}/contexts/search'.sub('{' + 'projectKey' + '}', CGI.escape(project_key.to_s)).sub('{' + 'environmentKey' + '}', CGI.escape(environment_key.to_s))

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'limit'] = opts[:'limit'] if !opts[:'limit'].nil?
  query_params[:'continuationToken'] = opts[:'continuation_token'] if !opts[:'continuation_token'].nil?
  query_params[:'sort'] = opts[:'sort'] if !opts[:'sort'].nil?
  query_params[:'filter'] = opts[:'filter'] if !opts[:'filter'].nil?
  query_params[:'includeTotalCount'] = opts[:'include_total_count'] if !opts[:'include_total_count'].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(context_search)

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

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

  new_options = opts.merge(
    :operation => :"ContextsApi.search_contexts",
    :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: ContextsApi#search_contexts\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end