Class: LaunchDarklyApi::ExperimentsApi

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_client = ApiClient.default) ⇒ ExperimentsApi

Returns a new instance of ExperimentsApi.



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

def api_client
  @api_client
end

Instance Method Details

#create_experiment(project_key, environment_key, experiment_post, opts = {}) ⇒ Experiment

Create experiment Create an experiment. To run this experiment, you'll need to create an iteration and then update the experiment with the startIteration instruction. ### Experiment types Use the type field to specify the experiment type: experiment (default), mab (multi-armed bandit), or holdout. For multi-armed bandit experiments, set reallocationFrequencyMillis on the iteration to control how often traffic is reallocated across variations. ### Results analysis Use the methodology field to specify the results analysis approach: bayesian (default) or frequentist. Use the dataSource field to specify the source of metric data: launchdarkly (default), snowflake, or databricks. Use the analysisConfig field to customize analysis settings such as the Bayesian threshold, significance threshold, or multiple comparison correction method. To learn more, read Creating experiments.

Parameters:

  • project_key (String)

    The project key

  • environment_key (String)

    The environment key

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

    the optional parameters

Returns:



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

def create_experiment(project_key, environment_key, experiment_post, opts = {})
  data, _status_code, _headers = create_experiment_with_http_info(project_key, environment_key, experiment_post, opts)
  data
end

#create_experiment_with_http_info(project_key, environment_key, experiment_post, opts = {}) ⇒ Array<(Experiment, Integer, Hash)>

Create experiment Create an experiment. To run this experiment, you'll need to create an iteration and then update the experiment with the `startIteration` instruction. ### Experiment types Use the `type` field to specify the experiment type: `experiment` (default), `mab` (multi-armed bandit), or `holdout`. For multi-armed bandit experiments, set `reallocationFrequencyMillis` on the iteration to control how often traffic is reallocated across variations. ### Results analysis Use the `methodology` field to specify the results analysis approach: `bayesian` (default) or `frequentist`. Use the `dataSource` field to specify the source of metric data: `launchdarkly` (default), `snowflake`, or `databricks`. Use the `analysisConfig` field to customize analysis settings such as the Bayesian threshold, significance threshold, or multiple comparison correction method. To learn more, read Creating experiments.

Parameters:

  • project_key (String)

    The project key

  • environment_key (String)

    The environment key

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

    the optional parameters

Returns:

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

    Experiment data, response status code and response headers



41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
# File 'lib/launchdarkly_api/api/experiments_api.rb', line 41

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

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

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
  # 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(experiment_post)

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

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

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

#create_iteration(project_key, environment_key, experiment_key, iteration_input, opts = {}) ⇒ IterationRep

Create iteration

Deprecated: This endpoint will be removed in a future version. Use the updateExperimentFields and saveAndStartNewIteration instructions on Update experiment instead. Create an experiment iteration. Experiment iterations let you record experiments in individual blocks of time. Initially, iterations are created with a status of not_started and appear in the draftIteration field of an experiment. To start or stop an iteration, update the experiment with the startIteration or stopIteration instruction. To learn more, read Start experiment iterations.

Parameters:

  • project_key (String)

    The project key

  • environment_key (String)

    The environment key

  • experiment_key (String)

    The experiment key

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

    the optional parameters

Returns:



110
111
112
113
# File 'lib/launchdarkly_api/api/experiments_api.rb', line 110

def create_iteration(project_key, environment_key, experiment_key, iteration_input, opts = {})
  data, _status_code, _headers = create_iteration_with_http_info(project_key, environment_key, experiment_key, iteration_input, opts)
  data
end

#create_iteration_with_http_info(project_key, environment_key, experiment_key, iteration_input, opts = {}) ⇒ Array<(IterationRep, Integer, Hash)>

Create iteration > Deprecated: This endpoint will be removed in a future version. Use the `updateExperimentFields` and `saveAndStartNewIteration` instructions on Update experiment instead. Create an experiment iteration. Experiment iterations let you record experiments in individual blocks of time. Initially, iterations are created with a status of `not_started` and appear in the `draftIteration` field of an experiment. To start or stop an iteration, update the experiment with the `startIteration` or `stopIteration` instruction. To learn more, read Start experiment iterations.

Parameters:

  • project_key (String)

    The project key

  • environment_key (String)

    The environment key

  • experiment_key (String)

    The experiment key

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

    the optional parameters

Returns:

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

    IterationRep data, response status code and response headers



123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
# File 'lib/launchdarkly_api/api/experiments_api.rb', line 123

def create_iteration_with_http_info(project_key, environment_key, experiment_key, iteration_input, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: ExperimentsApi.create_iteration ...'
  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 ExperimentsApi.create_iteration"
  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 ExperimentsApi.create_iteration"
  end
  # verify the required parameter 'experiment_key' is set
  if @api_client.config.client_side_validation && experiment_key.nil?
    fail ArgumentError, "Missing the required parameter 'experiment_key' when calling ExperimentsApi.create_iteration"
  end
  # verify the required parameter 'iteration_input' is set
  if @api_client.config.client_side_validation && iteration_input.nil?
    fail ArgumentError, "Missing the required parameter 'iteration_input' when calling ExperimentsApi.create_iteration"
  end
  # resource path
  local_var_path = '/api/v2/projects/{projectKey}/environments/{environmentKey}/experiments/{experimentKey}/iterations'.sub('{' + 'projectKey' + '}', CGI.escape(project_key.to_s)).sub('{' + 'environmentKey' + '}', CGI.escape(environment_key.to_s)).sub('{' + 'experimentKey' + '}', CGI.escape(experiment_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']) unless header_params['Accept']
  # 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(iteration_input)

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

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

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

#get_experiment(project_key, environment_key, experiment_key, opts = {}) ⇒ Experiment

Get experiment Get details about an experiment. ### Expanding the experiment response LaunchDarkly supports five fields for expanding the "Get experiment" response. By default, these fields are not included in the response. To expand the response, append the expand query parameter and add a comma-separated list with any of the following fields: - previousIterations includes all iterations prior to the current iteration. By default only the current iteration is included in the response. - draftIteration includes the iteration which has not been started yet, if any. - secondaryMetrics includes secondary metrics. By default only the primary metric is included in the response. - treatments includes all treatment and parameter details. By default treatment data is not included in the response. - analysisConfig includes the analysis configuration for the experiment, such as the Bayesian threshold or significance threshold. For example, expand=draftIteration,treatments includes the draftIteration and treatments fields in the response. If fields that you request with the expand query parameter are empty, they are not included in the response.

Parameters:

  • project_key (String)

    The project key

  • environment_key (String)

    The environment key

  • experiment_key (String)

    The experiment key

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

    the optional parameters

Options Hash (opts):

  • :expand (String)

    A comma-separated list of properties that can reveal additional information in the response. Supported fields are explained above.

Returns:



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

def get_experiment(project_key, environment_key, experiment_key, opts = {})
  data, _status_code, _headers = get_experiment_with_http_info(project_key, environment_key, experiment_key, opts)
  data
end

#get_experiment_with_http_info(project_key, environment_key, experiment_key, opts = {}) ⇒ Array<(Experiment, Integer, Hash)>

Get experiment Get details about an experiment. ### Expanding the experiment response LaunchDarkly supports five fields for expanding the &quot;Get experiment&quot; response. By default, these fields are not included in the response. To expand the response, append the `expand` query parameter and add a comma-separated list with any of the following fields: - `previousIterations` includes all iterations prior to the current iteration. By default only the current iteration is included in the response. - `draftIteration` includes the iteration which has not been started yet, if any. - `secondaryMetrics` includes secondary metrics. By default only the primary metric is included in the response. - `treatments` includes all treatment and parameter details. By default treatment data is not included in the response. - `analysisConfig` includes the analysis configuration for the experiment, such as the Bayesian threshold or significance threshold. For example, `expand=draftIteration,treatments` includes the `draftIteration` and `treatments` fields in the response. If fields that you request with the `expand` query parameter are empty, they are not included in the response.

Parameters:

  • project_key (String)

    The project key

  • environment_key (String)

    The environment key

  • experiment_key (String)

    The experiment key

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

    the optional parameters

Options Hash (opts):

  • :expand (String)

    A comma-separated list of properties that can reveal additional information in the response. Supported fields are explained above.

Returns:

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

    Experiment data, response status code and response headers



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
260
261
262
263
264
# File 'lib/launchdarkly_api/api/experiments_api.rb', line 209

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

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

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

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

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

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

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

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

#get_experimentation_settings(project_key, opts = {}) ⇒ RandomizationSettingsRep

Get experimentation settings Get current experimentation settings for the given project

Parameters:

  • project_key (String)

    The project key

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

    the optional parameters

Returns:



271
272
273
274
# File 'lib/launchdarkly_api/api/experiments_api.rb', line 271

def get_experimentation_settings(project_key, opts = {})
  data, _status_code, _headers = get_experimentation_settings_with_http_info(project_key, opts)
  data
end

#get_experimentation_settings_with_http_info(project_key, opts = {}) ⇒ Array<(RandomizationSettingsRep, Integer, Hash)>

Get experimentation settings Get current experimentation settings for the given project

Parameters:

  • project_key (String)

    The project key

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

    the optional parameters

Returns:

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

    RandomizationSettingsRep data, response status code and response headers



281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
# File 'lib/launchdarkly_api/api/experiments_api.rb', line 281

def get_experimentation_settings_with_http_info(project_key, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: ExperimentsApi.get_experimentation_settings ...'
  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 ExperimentsApi.get_experimentation_settings"
  end
  # resource path
  local_var_path = '/api/v2/projects/{projectKey}/experimentation-settings'.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']) unless header_params['Accept']

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

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

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

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

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

#get_experiments(project_key, environment_key, opts = {}) ⇒ ExperimentCollectionRep

Get experiments Get details about all experiments in an environment. ### Filtering experiments LaunchDarkly supports the filter query param for filtering, with the following fields: - flagKey filters for only experiments that use the flag with the given key. - metricKey filters for only experiments that use the metric with the given key. - status filters for only experiments with an iteration with the given status. An iteration can have the status not_started, running or stopped. For example, filter=flagKey:my-flag,status:running,metricKey:page-load-ms filters for experiments for the given flag key and the given metric key which have a currently running iteration. ### Expanding the experiments response LaunchDarkly supports five fields for expanding the "Get experiments" response. By default, these fields are not included in the response. To expand the response, append the expand query parameter and add a comma-separated list with any of the following fields: - previousIterations includes all iterations prior to the current iteration. By default only the current iteration is included in the response. - draftIteration includes the iteration which has not been started yet, if any. - secondaryMetrics includes secondary metrics. By default only the primary metric is included in the response. - treatments includes all treatment and parameter details. By default treatment data is not included in the response. - analysisConfig includes the analysis configuration for the experiment, such as the Bayesian threshold or significance threshold. For example, expand=draftIteration,treatments includes the draftIteration and treatments fields in the response. If fields that you request with the expand query parameter are empty, they are not included in the response.

Parameters:

  • project_key (String)

    The project key

  • environment_key (String)

    The environment key

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

    the optional parameters

Options Hash (opts):

  • :limit (Integer)

    The maximum number of experiments to return. Defaults to 20.

  • :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 `limit`.

  • :filter (String)

    A comma-separated list of filters. Each filter is of the form `field:value`. Supported fields are explained above.

  • :expand (String)

    A comma-separated list of properties that can reveal additional information in the response. Supported fields are explained above.

  • :lifecycle_state (String)

    A comma-separated list of experiment archived states. Supports `archived`, `active`, or both. Defaults to `active` experiments.

Returns:



340
341
342
343
# File 'lib/launchdarkly_api/api/experiments_api.rb', line 340

def get_experiments(project_key, environment_key, opts = {})
  data, _status_code, _headers = get_experiments_with_http_info(project_key, environment_key, opts)
  data
end

#get_experiments_any_env(project_key, opts = {}) ⇒ ExperimentCollectionRep

Get experiments any environment Get a list of experiments from across all environments in the project

Parameters:

  • project_key (String)

    The project key

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

    the optional parameters

Options Hash (opts):

  • :limit (Integer)

    The maximum number of experiments to return. Defaults to 20.

  • :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 `limit`.

  • :filter (String)

    A comma-separated list of filters. Each filter is of the form `field:value`. Supported fields are explained above.

  • :expand (String)

    A comma-separated list of properties that can reveal additional information in the response. Supported fields are explained above.

  • :lifecycle_state (String)

    A comma-separated list of experiment archived states. Supports `archived`, `active`, or both. Defaults to `active` experiments.

Returns:



423
424
425
426
# File 'lib/launchdarkly_api/api/experiments_api.rb', line 423

def get_experiments_any_env(project_key, opts = {})
  data, _status_code, _headers = get_experiments_any_env_with_http_info(project_key, opts)
  data
end

#get_experiments_any_env_with_http_info(project_key, opts = {}) ⇒ Array<(ExperimentCollectionRep, Integer, Hash)>

Get experiments any environment Get a list of experiments from across all environments in the project

Parameters:

  • project_key (String)

    The project key

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

    the optional parameters

Options Hash (opts):

  • :limit (Integer)

    The maximum number of experiments to return. Defaults to 20.

  • :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 `limit`.

  • :filter (String)

    A comma-separated list of filters. Each filter is of the form `field:value`. Supported fields are explained above.

  • :expand (String)

    A comma-separated list of properties that can reveal additional information in the response. Supported fields are explained above.

  • :lifecycle_state (String)

    A comma-separated list of experiment archived states. Supports `archived`, `active`, or both. Defaults to `active` experiments.

Returns:

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

    ExperimentCollectionRep data, response status code and response headers



438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
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
# File 'lib/launchdarkly_api/api/experiments_api.rb', line 438

def get_experiments_any_env_with_http_info(project_key, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: ExperimentsApi.get_experiments_any_env ...'
  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 ExperimentsApi.get_experiments_any_env"
  end
  # resource path
  local_var_path = '/api/v2/projects/{projectKey}/experiments'.sub('{' + 'projectKey' + '}', CGI.escape(project_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[:'filter'] = opts[:'filter'] if !opts[:'filter'].nil?
  query_params[:'expand'] = opts[:'expand'] if !opts[:'expand'].nil?
  query_params[:'lifecycleState'] = opts[:'lifecycle_state'] if !opts[:'lifecycle_state'].nil?

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

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

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

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

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

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

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

Get experiments Get details about all experiments in an environment. ### Filtering experiments LaunchDarkly supports the `filter` query param for filtering, with the following fields: - `flagKey` filters for only experiments that use the flag with the given key. - `metricKey` filters for only experiments that use the metric with the given key. - `status` filters for only experiments with an iteration with the given status. An iteration can have the status `not_started`, `running` or `stopped`. For example, `filter=flagKey:my-flag,status:running,metricKey:page-load-ms` filters for experiments for the given flag key and the given metric key which have a currently running iteration. ### Expanding the experiments response LaunchDarkly supports five fields for expanding the &quot;Get experiments&quot; response. By default, these fields are not included in the response. To expand the response, append the `expand` query parameter and add a comma-separated list with any of the following fields: - `previousIterations` includes all iterations prior to the current iteration. By default only the current iteration is included in the response. - `draftIteration` includes the iteration which has not been started yet, if any. - `secondaryMetrics` includes secondary metrics. By default only the primary metric is included in the response. - `treatments` includes all treatment and parameter details. By default treatment data is not included in the response. - `analysisConfig` includes the analysis configuration for the experiment, such as the Bayesian threshold or significance threshold. For example, `expand=draftIteration,treatments` includes the `draftIteration` and `treatments` fields in the response. If fields that you request with the `expand` query parameter are empty, they are not included in the response.

Parameters:

  • project_key (String)

    The project key

  • environment_key (String)

    The environment key

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

    the optional parameters

Options Hash (opts):

  • :limit (Integer)

    The maximum number of experiments to return. Defaults to 20.

  • :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 `limit`.

  • :filter (String)

    A comma-separated list of filters. Each filter is of the form `field:value`. Supported fields are explained above.

  • :expand (String)

    A comma-separated list of properties that can reveal additional information in the response. Supported fields are explained above.

  • :lifecycle_state (String)

    A comma-separated list of experiment archived states. Supports `archived`, `active`, or both. Defaults to `active` experiments.

Returns:

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

    ExperimentCollectionRep data, response status code and response headers



356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
# File 'lib/launchdarkly_api/api/experiments_api.rb', line 356

def get_experiments_with_http_info(project_key, environment_key, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: ExperimentsApi.get_experiments ...'
  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 ExperimentsApi.get_experiments"
  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 ExperimentsApi.get_experiments"
  end
  # resource path
  local_var_path = '/api/v2/projects/{projectKey}/environments/{environmentKey}/experiments'.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[:'filter'] = opts[:'filter'] if !opts[:'filter'].nil?
  query_params[:'expand'] = opts[:'expand'] if !opts[:'expand'].nil?
  query_params[:'lifecycleState'] = opts[:'lifecycle_state'] if !opts[:'lifecycle_state'].nil?

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

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

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

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

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

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

#patch_experiment(project_key, environment_key, experiment_key, experiment_patch_input, opts = {}) ⇒ Experiment

Patch experiment Update an experiment. Updating an experiment uses the semantic patch format. To make a semantic patch request, you must append domain-model=launchdarkly.semanticpatch to your Content-Type header. To learn more, read Updates using semantic patch. ### Instructions Semantic patch requests support the following kind instructions for updating experiments. #### updateName > Deprecated: updateName will be removed in a future version. Use updateExperimentFields instead. Updates the experiment name. ##### Parameters - value: The new name. Here's an example: json { \"instructions\": [{ \"kind\": \"updateName\", \"value\": \"Example updated experiment name\" }] } #### updateDescription > Deprecated: updateDescription will be removed in a future version. Use updateExperimentFields instead. Updates the experiment description. ##### Parameters - value: The new description. Here's an example: json { \"instructions\": [{ \"kind\": \"updateDescription\", \"value\": \"Example updated description\" }] } #### updateExperimentFields Updates one or more fields on an experiment or its current iteration. Each field update specifies an operation (add, update, or remove) and an optional value. Which fields are mutable depends on the current iteration status. To discover which fields and operations are allowed, expand mutableFieldsByStatus on the Get experiment response. ##### Parameters - value: An object mapping field names to field updates. Each field update has the following properties: - operation: The operation to perform. One of add, update, or remove. - value: The new value for the field. Required for add and update operations. To find which fields are supported and which operations are allowed for each iteration status, expand mutableFieldsByStatus on the Get experiment response. Here's an example: json { \"instructions\": [{ \"kind\": \"updateExperimentFields\", \"value\": { \"name\": { \"operation\": \"update\", \"value\": \"Updated experiment name\" }, \"tags\": { \"operation\": \"add\", \"value\": [\"tag1\", \"tag2\"] } } }] } #### saveAndStartNewIteration Stops the current running iteration, creates a new iteration from it, optionally applies field updates, and starts the new iteration. This is a convenience instruction that combines stopping, updating, and starting in a single operation. ##### Parameters - changeJustification: (Optional) The reason for stopping and starting a new iteration. - value: (Optional) An object mapping field names to field updates, using the same format as updateExperimentFields. These updates are applied to the new iteration before it is started. Here's an example: json { \"instructions\": [{ \"kind\": \"saveAndStartNewIteration\", \"changeJustification\": \"Adjusting hypothesis based on early results\", \"value\": { \"hypothesis\": { \"operation\": \"update\", \"value\": \"Updated hypothesis text\" } } }] } #### startIteration Starts a new iteration for this experiment. You must create a new iteration before calling this instruction. An iteration may not be started until it meets the following criteria: * Its associated flag is toggled on and is not archived * Its randomizationUnit is set * At least one of its treatments has a non-zero allocationPercent ##### Parameters - changeJustification: The reason for starting a new iteration. Required when you call startIteration on an already running experiment, otherwise optional. Here's an example: json { \"instructions\": [{ \"kind\": \"startIteration\", \"changeJustification\": \"It's time to start a new iteration\" }] } #### stopIteration Stops the current iteration for this experiment. ##### Parameters - winningTreatmentId: The ID of the winning treatment. Treatment IDs are returned as part of the Get experiment response. They are the _id of each element in the treatments array. - winningReason: The reason for the winner Here's an example: json { \"instructions\": [{ \"kind\": \"stopIteration\", \"winningTreatmentId\": \"3a548ec2-72ac-4e59-8518-5c24f5609ccf\", \"winningReason\": \"Example reason to stop the iteration\" }] } #### archiveExperiment Archives this experiment. Archived experiments are hidden by default in the LaunchDarkly user interface. You cannot start new iterations for archived experiments. Here's an example: json { \"instructions\": [{ \"kind\": \"archiveExperiment\" }] } #### restoreExperiment Restores an archived experiment. After restoring an experiment, you can start new iterations for it again. Here's an example: json { \"instructions\": [{ \"kind\": \"restoreExperiment\" }] }

Parameters:

  • project_key (String)

    The project key

  • environment_key (String)

    The environment key

  • experiment_key (String)

    The experiment key

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

    the optional parameters

Returns:



499
500
501
502
# File 'lib/launchdarkly_api/api/experiments_api.rb', line 499

def patch_experiment(project_key, environment_key, experiment_key, experiment_patch_input, opts = {})
  data, _status_code, _headers = patch_experiment_with_http_info(project_key, environment_key, experiment_key, experiment_patch_input, opts)
  data
end

#patch_experiment_with_http_info(project_key, environment_key, experiment_key, experiment_patch_input, opts = {}) ⇒ Array<(Experiment, Integer, Hash)>

Patch experiment Update an experiment. Updating an experiment uses the semantic patch format. To make a semantic patch request, you must append `domain-model=launchdarkly.semanticpatch` to your `Content-Type` header. To learn more, read Updates using semantic patch. ### Instructions Semantic patch requests support the following `kind` instructions for updating experiments. #### updateName > Deprecated: `updateName` will be removed in a future version. Use `updateExperimentFields` instead. Updates the experiment name. ##### Parameters - `value`: The new name. Here's an example: ```json { &quot;instructions&quot;: [{ &quot;kind&quot;: &quot;updateName&quot;, &quot;value&quot;: &quot;Example updated experiment name&quot; }] } ``` #### updateDescription > Deprecated: `updateDescription` will be removed in a future version. Use `updateExperimentFields` instead. Updates the experiment description. ##### Parameters - `value`: The new description. Here's an example: ```json { &quot;instructions&quot;: [{ &quot;kind&quot;: &quot;updateDescription&quot;, &quot;value&quot;: &quot;Example updated description&quot; }] } ``` #### updateExperimentFields Updates one or more fields on an experiment or its current iteration. Each field update specifies an operation (`add`, `update`, or `remove`) and an optional value. Which fields are mutable depends on the current iteration status. To discover which fields and operations are allowed, expand `mutableFieldsByStatus` on the Get experiment response. ##### Parameters - `value`: An object mapping field names to field updates. Each field update has the following properties: - `operation`: The operation to perform. One of `add`, `update`, or `remove`. - `value`: The new value for the field. Required for `add` and `update` operations. To find which fields are supported and which operations are allowed for each iteration status, expand `mutableFieldsByStatus` on the Get experiment response. Here's an example: ```json { &quot;instructions&quot;: [{ &quot;kind&quot;: &quot;updateExperimentFields&quot;, &quot;value&quot;: { &quot;name&quot;: { &quot;operation&quot;: &quot;update&quot;, &quot;value&quot;: &quot;Updated experiment name&quot; }, &quot;tags&quot;: { &quot;operation&quot;: &quot;add&quot;, &quot;value&quot;: [&quot;tag1&quot;, &quot;tag2&quot;] } } }] } ``` #### saveAndStartNewIteration Stops the current running iteration, creates a new iteration from it, optionally applies field updates, and starts the new iteration. This is a convenience instruction that combines stopping, updating, and starting in a single operation. ##### Parameters - `changeJustification`: (Optional) The reason for stopping and starting a new iteration. - `value`: (Optional) An object mapping field names to field updates, using the same format as `updateExperimentFields`. These updates are applied to the new iteration before it is started. Here's an example: ```json { &quot;instructions&quot;: [{ &quot;kind&quot;: &quot;saveAndStartNewIteration&quot;, &quot;changeJustification&quot;: &quot;Adjusting hypothesis based on early results&quot;, &quot;value&quot;: { &quot;hypothesis&quot;: { &quot;operation&quot;: &quot;update&quot;, &quot;value&quot;: &quot;Updated hypothesis text&quot; } } }] } ``` #### startIteration Starts a new iteration for this experiment. You must create a new iteration before calling this instruction. An iteration may not be started until it meets the following criteria: * Its associated flag is toggled on and is not archived * Its `randomizationUnit` is set * At least one of its `treatments` has a non-zero `allocationPercent` ##### Parameters - `changeJustification`: The reason for starting a new iteration. Required when you call `startIteration` on an already running experiment, otherwise optional. Here's an example: ```json { &quot;instructions&quot;: [{ &quot;kind&quot;: &quot;startIteration&quot;, &quot;changeJustification&quot;: &quot;It's time to start a new iteration&quot; }] } ``` #### stopIteration Stops the current iteration for this experiment. ##### Parameters - `winningTreatmentId`: The ID of the winning treatment. Treatment IDs are returned as part of the Get experiment response. They are the `_id` of each element in the `treatments` array. - `winningReason`: The reason for the winner Here's an example: ```json { &quot;instructions&quot;: [{ &quot;kind&quot;: &quot;stopIteration&quot;, &quot;winningTreatmentId&quot;: &quot;3a548ec2-72ac-4e59-8518-5c24f5609ccf&quot;, &quot;winningReason&quot;: &quot;Example reason to stop the iteration&quot; }] } ``` #### archiveExperiment Archives this experiment. Archived experiments are hidden by default in the LaunchDarkly user interface. You cannot start new iterations for archived experiments. Here's an example: ```json { &quot;instructions&quot;: [{ &quot;kind&quot;: &quot;archiveExperiment&quot; }] } ``` #### restoreExperiment Restores an archived experiment. After restoring an experiment, you can start new iterations for it again. Here's an example: ```json { &quot;instructions&quot;: [{ &quot;kind&quot;: &quot;restoreExperiment&quot; }] } ```

Parameters:

  • project_key (String)

    The project key

  • environment_key (String)

    The environment key

  • experiment_key (String)

    The experiment key

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

    the optional parameters

Returns:

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

    Experiment data, response status code and response headers



512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
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
# File 'lib/launchdarkly_api/api/experiments_api.rb', line 512

def patch_experiment_with_http_info(project_key, environment_key, experiment_key, experiment_patch_input, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: ExperimentsApi.patch_experiment ...'
  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 ExperimentsApi.patch_experiment"
  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 ExperimentsApi.patch_experiment"
  end
  # verify the required parameter 'experiment_key' is set
  if @api_client.config.client_side_validation && experiment_key.nil?
    fail ArgumentError, "Missing the required parameter 'experiment_key' when calling ExperimentsApi.patch_experiment"
  end
  # verify the required parameter 'experiment_patch_input' is set
  if @api_client.config.client_side_validation && experiment_patch_input.nil?
    fail ArgumentError, "Missing the required parameter 'experiment_patch_input' when calling ExperimentsApi.patch_experiment"
  end
  # resource path
  local_var_path = '/api/v2/projects/{projectKey}/environments/{environmentKey}/experiments/{experimentKey}'.sub('{' + 'projectKey' + '}', CGI.escape(project_key.to_s)).sub('{' + 'environmentKey' + '}', CGI.escape(environment_key.to_s)).sub('{' + 'experimentKey' + '}', CGI.escape(experiment_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']) unless header_params['Accept']
  # 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(experiment_patch_input)

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

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

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

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

#put_experimentation_settings(project_key, randomization_settings_put, opts = {}) ⇒ RandomizationSettingsRep

Update experimentation settings Update experimentation settings for the given project

Parameters:

  • project_key (String)

    The project key

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

    the optional parameters

Returns:



583
584
585
586
# File 'lib/launchdarkly_api/api/experiments_api.rb', line 583

def put_experimentation_settings(project_key, randomization_settings_put, opts = {})
  data, _status_code, _headers = put_experimentation_settings_with_http_info(project_key, randomization_settings_put, opts)
  data
end

#put_experimentation_settings_with_http_info(project_key, randomization_settings_put, opts = {}) ⇒ Array<(RandomizationSettingsRep, Integer, Hash)>

Update experimentation settings Update experimentation settings for the given project

Parameters:

  • project_key (String)

    The project key

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

    the optional parameters

Returns:

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

    RandomizationSettingsRep data, response status code and response headers



594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
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
# File 'lib/launchdarkly_api/api/experiments_api.rb', line 594

def put_experimentation_settings_with_http_info(project_key, randomization_settings_put, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: ExperimentsApi.put_experimentation_settings ...'
  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 ExperimentsApi.put_experimentation_settings"
  end
  # verify the required parameter 'randomization_settings_put' is set
  if @api_client.config.client_side_validation && randomization_settings_put.nil?
    fail ArgumentError, "Missing the required parameter 'randomization_settings_put' when calling ExperimentsApi.put_experimentation_settings"
  end
  # resource path
  local_var_path = '/api/v2/projects/{projectKey}/experimentation-settings'.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']) unless header_params['Accept']
  # 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(randomization_settings_put)

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

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

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