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](launchdarkly.com/docs/guides/api/comparing-sdk-rest-api). ### Filtering LaunchDarkly supports the ‘filter` query param for filtering, with the following fields: - `query` filters for a string that matches against the flags’ keys and names. It is not case sensitive. For example: ‘filter=query equals dark-mode`. - `tags` filters the list to flags that have all of the tags in the list. For example: `filter=tags contains ["beta","q1"]`. You can also apply multiple filters at once. For example, setting `filter=query equals dark-mode, tags contains ["beta","q1"]` matches flags which match the key or name `dark-mode` and are tagged `beta` and `q1`.

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 &#x60;field operator value&#x60;. Supported fields are explained above.

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](launchdarkly.com/docs/guides/api/comparing-sdk-rest-api). ### Filtering LaunchDarkly supports the &#x60;filter&#x60; query param for filtering, with the following fields: - &#x60;query&#x60; filters for a string that matches against the flags&#39; keys and names. It is not case sensitive. For example: &#x60;filter&#x3D;query equals dark-mode&#x60;. - &#x60;tags&#x60; filters the list to flags that have all of the tags in the list. For example: &#x60;filter&#x3D;tags contains [&quot;beta&quot;,&quot;q1&quot;]&#x60;. You can also apply multiple filters at once. For example, setting &#x60;filter&#x3D;query equals dark-mode, tags contains [&quot;beta&quot;,&quot;q1&quot;]&#x60; matches flags which match the key or name &#x60;dark-mode&#x60; and are tagged &#x60;beta&#x60; and &#x60;q1&#x60;.

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 &#x60;field operator value&#x60;. Supported fields are explained above.

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](launchdarkly.com/docs/ld-docs/api/contexts#filtering-contexts-and-context-instances).

  • :limit (Integer)

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

Returns:



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

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](launchdarkly.com/docs/ld-docs/api/contexts#filtering-contexts-and-context-instances).

  • :limit (Integer)

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

Returns:



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
260
261
262
# File 'lib/launchdarkly_api/api/contexts_api.rb', line 210

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?
  query_params[:'limit'] = opts[:'limit'] if !opts[:'limit'].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](launchdarkly.com/docs/ld-docs/api/contexts#filtering-contexts-and-context-instances).

  • :limit (Integer)

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

Returns:



273
274
275
276
# File 'lib/launchdarkly_api/api/contexts_api.rb', line 273

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](launchdarkly.com/docs/ld-docs/api/contexts#filtering-contexts-and-context-instances).

  • :limit (Integer)

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

Returns:



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
338
339
340
341
342
343
# File 'lib/launchdarkly_api/api/contexts_api.rb', line 287

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?
  query_params[:'limit'] = opts[:'limit'] if !opts[:'limit'].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](launchdarkly.com/docs/ld-docs/api/contexts#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:



357
358
359
360
# File 'lib/launchdarkly_api/api/contexts_api.rb', line 357

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](launchdarkly.com/docs/ld-docs/api/contexts#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



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
428
429
430
431
432
433
# File 'lib/launchdarkly_api/api/contexts_api.rb', line 374

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_context_kinds_by_project_key(project_key, opts = {}) ⇒ ContextKindsCollectionRep

Get context kinds Get all context kinds for a given project.

Parameters:

  • project_key (String)

    The project key

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

    the optional parameters

Returns:



440
441
442
443
# File 'lib/launchdarkly_api/api/contexts_api.rb', line 440

def get_context_kinds_by_project_key(project_key, opts = {})
  data, _status_code, _headers = get_context_kinds_by_project_key_with_http_info(project_key, opts)
  data
end

#get_context_kinds_by_project_key_with_http_info(project_key, opts = {}) ⇒ Array<(ContextKindsCollectionRep, Integer, Hash)>

Get context kinds Get all context kinds for a given project.

Parameters:

  • project_key (String)

    The project key

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

    the optional parameters

Returns:

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

    ContextKindsCollectionRep data, response status code and response headers



450
451
452
453
454
455
456
457
458
459
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
# File 'lib/launchdarkly_api/api/contexts_api.rb', line 450

def get_context_kinds_by_project_key_with_http_info(project_key, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: ContextsApi.get_context_kinds_by_project_key ...'
  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_kinds_by_project_key"
  end
  # resource path
  local_var_path = '/api/v2/projects/{projectKey}/context-kinds'.sub('{' + 'projectKey' + '}', CGI.escape(project_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] || 'ContextKindsCollectionRep'

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

  new_options = opts.merge(
    :operation => :"ContextsApi.get_context_kinds_by_project_key",
    :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_kinds_by_project_key\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](launchdarkly.com/docs/ld-docs/api/contexts#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:



511
512
513
514
# File 'lib/launchdarkly_api/api/contexts_api.rb', line 511

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](launchdarkly.com/docs/ld-docs/api/contexts#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



529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
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
# File 'lib/launchdarkly_api/api/contexts_api.rb', line 529

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

#put_context_kind(project_key, key, upsert_context_kind_payload, opts = {}) ⇒ UpsertResponseRep

Create or update context kind Create or update a context kind by key. Only the included fields will be updated.

Parameters:

  • project_key (String)

    The project key

  • key (String)

    The context kind key

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

    the optional parameters

Returns:



601
602
603
604
# File 'lib/launchdarkly_api/api/contexts_api.rb', line 601

def put_context_kind(project_key, key, upsert_context_kind_payload, opts = {})
  data, _status_code, _headers = put_context_kind_with_http_info(project_key, key, upsert_context_kind_payload, opts)
  data
end

#put_context_kind_with_http_info(project_key, key, upsert_context_kind_payload, opts = {}) ⇒ Array<(UpsertResponseRep, Integer, Hash)>

Create or update context kind Create or update a context kind by key. Only the included fields will be updated.

Parameters:

  • project_key (String)

    The project key

  • key (String)

    The context kind key

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

    the optional parameters

Returns:

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

    UpsertResponseRep data, response status code and response headers



613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
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
# File 'lib/launchdarkly_api/api/contexts_api.rb', line 613

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

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

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

  new_options = opts.merge(
    :operation => :"ContextsApi.put_context_kind",
    :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(:PUT, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: ContextsApi#put_context_kind\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](https://launchdarkly.com/docs/api/contexts#filtering-contexts-and-context-instances). To learn more about context instances, read [Context instances](https://launchdarkly.com/docs/home/observability/multi-contexts#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](launchdarkly.com/docs/ld-docs/api/contexts#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:



686
687
688
689
# File 'lib/launchdarkly_api/api/contexts_api.rb', line 686

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](https://launchdarkly.com/docs/api/contexts#filtering-contexts-and-context-instances). To learn more about context instances, read [Context instances](https://launchdarkly.com/docs/home/observability/multi-contexts#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](launchdarkly.com/docs/ld-docs/api/contexts#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



703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
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
# File 'lib/launchdarkly_api/api/contexts_api.rb', line 703

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](https://launchdarkly.com/docs/api/contexts#filtering-contexts-and-context-instances). To learn more about contexts, read [Contexts and context kinds](https://launchdarkly.com/docs/home/observability/contexts#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](launchdarkly.com/docs/ld-docs/api/contexts#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:



781
782
783
784
# File 'lib/launchdarkly_api/api/contexts_api.rb', line 781

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](https://launchdarkly.com/docs/api/contexts#filtering-contexts-and-context-instances). To learn more about contexts, read [Contexts and context kinds](https://launchdarkly.com/docs/home/observability/contexts#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](launchdarkly.com/docs/ld-docs/api/contexts#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



798
799
800
801
802
803
804
805
806
807
808
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
# File 'lib/launchdarkly_api/api/contexts_api.rb', line 798

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