Class: LaunchDarklyApi::SegmentsApi

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_client = ApiClient.default) ⇒ SegmentsApi

Returns a new instance of SegmentsApi.



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

def api_client
  @api_client
end

Instance Method Details

#delete_segment(project_key, environment_key, segment_key, opts = {}) ⇒ nil

Delete segment Delete a user segment.

Parameters:

  • project_key (String)

    The project key

  • environment_key (String)

    The environment key

  • segment_key (String)

    The segment key

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

    the optional parameters

Returns:

  • (nil)


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

def delete_segment(project_key, environment_key, segment_key, opts = {})
  delete_segment_with_http_info(project_key, environment_key, segment_key, opts)
  nil
end

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

Delete segment Delete a user segment.

Parameters:

  • project_key (String)

    The project key

  • environment_key (String)

    The environment key

  • segment_key (String)

    The segment key

  • 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/segments_api.rb', line 41

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

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

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

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

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

  # return_type
  return_type = opts[:debug_return_type]

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

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

#get_expiring_user_targets_for_segment(project_key, environment_key, segment_key, opts = {}) ⇒ ExpiringUserTargetGetResponse

Get expiring user targets for segment Get a list of a segment’s user targets that are scheduled for removal.

Parameters:

  • project_key (String)

    The project key

  • environment_key (String)

    The environment key

  • segment_key (String)

    The segment key

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

    the optional parameters

Returns:



104
105
106
107
# File 'lib/launchdarkly_api/api/segments_api.rb', line 104

def get_expiring_user_targets_for_segment(project_key, environment_key, segment_key, opts = {})
  data, _status_code, _headers = get_expiring_user_targets_for_segment_with_http_info(project_key, environment_key, segment_key, opts)
  data
end

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

Get expiring user targets for segment Get a list of a segment&#39;s user targets that are scheduled for removal.

Parameters:

  • project_key (String)

    The project key

  • environment_key (String)

    The environment key

  • segment_key (String)

    The segment key

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

    the optional parameters

Returns:



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

def get_expiring_user_targets_for_segment_with_http_info(project_key, environment_key, segment_key, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: SegmentsApi.get_expiring_user_targets_for_segment ...'
  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 SegmentsApi.get_expiring_user_targets_for_segment"
  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 SegmentsApi.get_expiring_user_targets_for_segment"
  end
  # verify the required parameter 'segment_key' is set
  if @api_client.config.client_side_validation && segment_key.nil?
    fail ArgumentError, "Missing the required parameter 'segment_key' when calling SegmentsApi.get_expiring_user_targets_for_segment"
  end
  # resource path
  local_var_path = '/api/v2/segments/{projectKey}/{segmentKey}/expiring-user-targets/{environmentKey}'.sub('{' + 'projectKey' + '}', CGI.escape(project_key.to_s)).sub('{' + 'environmentKey' + '}', CGI.escape(environment_key.to_s)).sub('{' + 'segmentKey' + '}', CGI.escape(segment_key.to_s))

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

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

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

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

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

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

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

#get_segment(project_key, environment_key, segment_key, opts = {}) ⇒ UserSegment

Get segment Get a single user segment by key.

Parameters:

  • project_key (String)

    The project key

  • environment_key (String)

    The environment key

  • segment_key (String)

    The segment key

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

    the optional parameters

Returns:



179
180
181
182
# File 'lib/launchdarkly_api/api/segments_api.rb', line 179

def get_segment(project_key, environment_key, segment_key, opts = {})
  data, _status_code, _headers = get_segment_with_http_info(project_key, environment_key, segment_key, opts)
  data
end

#get_segment_membership_for_user(project_key, environment_key, segment_key, user_key, opts = {}) ⇒ BigSegmentTarget

Get Big Segment membership for user Get the membership status (included/excluded) for a given user in this Big Segment. This operation does not support standard segments.

Parameters:

  • project_key (String)

    The project key

  • environment_key (String)

    The environment key

  • segment_key (String)

    The segment key

  • user_key (String)

    The user key

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

    the optional parameters

Returns:



255
256
257
258
# File 'lib/launchdarkly_api/api/segments_api.rb', line 255

def get_segment_membership_for_user(project_key, environment_key, segment_key, user_key, opts = {})
  data, _status_code, _headers = get_segment_membership_for_user_with_http_info(project_key, environment_key, segment_key, user_key, opts)
  data
end

#get_segment_membership_for_user_with_http_info(project_key, environment_key, segment_key, user_key, opts = {}) ⇒ Array<(BigSegmentTarget, Integer, Hash)>

Get Big Segment membership for user Get the membership status (included/excluded) for a given user in this Big Segment. This operation does not support standard segments.

Parameters:

  • project_key (String)

    The project key

  • environment_key (String)

    The environment key

  • segment_key (String)

    The segment key

  • user_key (String)

    The user key

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

    the optional parameters

Returns:

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

    BigSegmentTarget data, response status code and response headers



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

def get_segment_membership_for_user_with_http_info(project_key, environment_key, segment_key, user_key, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: SegmentsApi.get_segment_membership_for_user ...'
  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 SegmentsApi.get_segment_membership_for_user"
  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 SegmentsApi.get_segment_membership_for_user"
  end
  # verify the required parameter 'segment_key' is set
  if @api_client.config.client_side_validation && segment_key.nil?
    fail ArgumentError, "Missing the required parameter 'segment_key' when calling SegmentsApi.get_segment_membership_for_user"
  end
  # verify the required parameter 'user_key' is set
  if @api_client.config.client_side_validation && user_key.nil?
    fail ArgumentError, "Missing the required parameter 'user_key' when calling SegmentsApi.get_segment_membership_for_user"
  end
  # resource path
  local_var_path = '/api/v2/segments/{projectKey}/{environmentKey}/{segmentKey}/users/{userKey}'.sub('{' + 'projectKey' + '}', CGI.escape(project_key.to_s)).sub('{' + 'environmentKey' + '}', CGI.escape(environment_key.to_s)).sub('{' + 'segmentKey' + '}', CGI.escape(segment_key.to_s)).sub('{' + 'userKey' + '}', CGI.escape(user_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] || 'BigSegmentTarget'

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

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

#get_segment_with_http_info(project_key, environment_key, segment_key, opts = {}) ⇒ Array<(UserSegment, Integer, Hash)>

Get segment Get a single user segment by key.

Parameters:

  • project_key (String)

    The project key

  • environment_key (String)

    The environment key

  • segment_key (String)

    The segment key

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

    the optional parameters

Returns:

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

    UserSegment data, response status code and response headers



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

def get_segment_with_http_info(project_key, environment_key, segment_key, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: SegmentsApi.get_segment ...'
  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 SegmentsApi.get_segment"
  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 SegmentsApi.get_segment"
  end
  # verify the required parameter 'segment_key' is set
  if @api_client.config.client_side_validation && segment_key.nil?
    fail ArgumentError, "Missing the required parameter 'segment_key' when calling SegmentsApi.get_segment"
  end
  # resource path
  local_var_path = '/api/v2/segments/{projectKey}/{environmentKey}/{segmentKey}'.sub('{' + 'projectKey' + '}', CGI.escape(project_key.to_s)).sub('{' + 'environmentKey' + '}', CGI.escape(environment_key.to_s)).sub('{' + 'segmentKey' + '}', CGI.escape(segment_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] || 'UserSegment'

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

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

#get_segments(project_key, environment_key, opts = {}) ⇒ UserSegments

List segments Get a list of all user segments in the given project.

Parameters:

  • project_key (String)

    The project key

  • environment_key (String)

    The environment key

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

    the optional parameters

Returns:



334
335
336
337
# File 'lib/launchdarkly_api/api/segments_api.rb', line 334

def get_segments(project_key, environment_key, opts = {})
  data, _status_code, _headers = get_segments_with_http_info(project_key, environment_key, opts)
  data
end

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

List segments Get a list of all user segments in the given project.

Parameters:

  • project_key (String)

    The project key

  • environment_key (String)

    The environment key

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

    the optional parameters

Returns:

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

    UserSegments data, response status code and response headers



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

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

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

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

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

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

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

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

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

#patch_expiring_user_targets_for_segment(project_key, environment_key, segment_key, patch_segment_request, opts = {}) ⇒ ExpiringUserTargetPatchResponse

Update expiring user targets for segment

Update expiring user targets for a segment. Updating a user target expiration 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](/reference#updates-using-semantic-patch).  If the request is well-formed but any of its instructions failed to process, this operation returns status code `200`. In this case, the response `errors` array will be non-empty.  ### Instructions  Semantic patch requests support the following `kind` instructions for updating user targets.  #### addExpireUserTargetDate  Schedules a date and time when LaunchDarkly will remove a user from segment targeting.  ##### Parameters  - `targetType`: A segment's target type, must be either `included` or `excluded`. - `userKey`: The user key. - `value`: The date when the user should expire from the segment targeting, in Unix milliseconds.  #### updateExpireUserTargetDate  Updates the date and time when LaunchDarkly will remove a user from segment targeting.  ##### Parameters  - `targetType`: A segment's target type, must be either `included` or `excluded`. - `userKey`: The user key. - `value`: The new date when the user should expire from the segment targeting, in Unix milliseconds. - `version`: The segment version.  #### removeExpireUserTargetDate  Removes the scheduled expiration for the user in the segment.  ##### Parameters  - `targetType`: A segment's target type, must be either `included` or `excluded`. - `userKey`: The user key.

Parameters:

  • project_key (String)

    The project key

  • environment_key (String)

    The environment key

  • segment_key (String)

    The segment key

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

    the optional parameters

Returns:



405
406
407
408
# File 'lib/launchdarkly_api/api/segments_api.rb', line 405

def patch_expiring_user_targets_for_segment(project_key, environment_key, segment_key, patch_segment_request, opts = {})
  data, _status_code, _headers = patch_expiring_user_targets_for_segment_with_http_info(project_key, environment_key, segment_key, patch_segment_request, opts)
  data
end

#patch_expiring_user_targets_for_segment_with_http_info(project_key, environment_key, segment_key, patch_segment_request, opts = {}) ⇒ Array<(ExpiringUserTargetPatchResponse, Integer, Hash)>

Update expiring user targets for segment

Update expiring user targets for a segment. Updating a user target expiration uses the semantic patch format.  To make a semantic patch request, you must append &#x60;domain-model&#x3D;launchdarkly.semanticpatch&#x60; to your &#x60;Content-Type&#x60; header. To learn more, read [Updates using semantic patch](/reference#updates-using-semantic-patch).  If the request is well-formed but any of its instructions failed to process, this operation returns status code &#x60;200&#x60;. In this case, the response &#x60;errors&#x60; array will be non-empty.  ### Instructions  Semantic patch requests support the following &#x60;kind&#x60; instructions for updating user targets.  #### addExpireUserTargetDate  Schedules a date and time when LaunchDarkly will remove a user from segment targeting.  ##### Parameters  - &#x60;targetType&#x60;: A segment&#39;s target type, must be either &#x60;included&#x60; or &#x60;excluded&#x60;. - &#x60;userKey&#x60;: The user key. - &#x60;value&#x60;: The date when the user should expire from the segment targeting, in Unix milliseconds.  #### updateExpireUserTargetDate  Updates the date and time when LaunchDarkly will remove a user from segment targeting.  ##### Parameters  - &#x60;targetType&#x60;: A segment&#39;s target type, must be either &#x60;included&#x60; or &#x60;excluded&#x60;. - &#x60;userKey&#x60;: The user key. - &#x60;value&#x60;: The new date when the user should expire from the segment targeting, in Unix milliseconds. - &#x60;version&#x60;: The segment version.  #### removeExpireUserTargetDate  Removes the scheduled expiration for the user in the segment.  ##### Parameters  - &#x60;targetType&#x60;: A segment&#39;s target type, must be either &#x60;included&#x60; or &#x60;excluded&#x60;. - &#x60;userKey&#x60;: The user key.

Parameters:

  • project_key (String)

    The project key

  • environment_key (String)

    The environment key

  • segment_key (String)

    The segment key

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

    the optional parameters

Returns:



418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
# File 'lib/launchdarkly_api/api/segments_api.rb', line 418

def patch_expiring_user_targets_for_segment_with_http_info(project_key, environment_key, segment_key, patch_segment_request, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: SegmentsApi.patch_expiring_user_targets_for_segment ...'
  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 SegmentsApi.patch_expiring_user_targets_for_segment"
  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 SegmentsApi.patch_expiring_user_targets_for_segment"
  end
  # verify the required parameter 'segment_key' is set
  if @api_client.config.client_side_validation && segment_key.nil?
    fail ArgumentError, "Missing the required parameter 'segment_key' when calling SegmentsApi.patch_expiring_user_targets_for_segment"
  end
  # verify the required parameter 'patch_segment_request' is set
  if @api_client.config.client_side_validation && patch_segment_request.nil?
    fail ArgumentError, "Missing the required parameter 'patch_segment_request' when calling SegmentsApi.patch_expiring_user_targets_for_segment"
  end
  # resource path
  local_var_path = '/api/v2/segments/{projectKey}/{segmentKey}/expiring-user-targets/{environmentKey}'.sub('{' + 'projectKey' + '}', CGI.escape(project_key.to_s)).sub('{' + 'environmentKey' + '}', CGI.escape(environment_key.to_s)).sub('{' + 'segmentKey' + '}', CGI.escape(segment_key.to_s))

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

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

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

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

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

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

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

#patch_segment(project_key, environment_key, segment_key, patch_with_comment, opts = {}) ⇒ UserSegment

Patch segment Update a user segment. The request body must be a valid semantic patch, JSON patch, or JSON merge patch. ### Using semantic patches on a segment 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](/reference#updates-using-semantic-patch). The body of a semantic patch request for updating segments requires an `environmentKey` in addition to `instructions` and an optional `comment`. The body of the request takes the following properties: * `comment` (string): (Optional) A description of the update. * `environmentKey` (string): (Required) The key of the LaunchDarkly environment. * `instructions` (array): (Required) A list of actions the update should perform. Each action in the list must be an object with a `kind` property that indicates the instruction. If the action requires parameters, you must include those parameters as additional fields in the object. ### Instructions Semantic patch requests support the following `kind` instructions for updating segments. #### addIncludedUsers Adds user keys to the individual user targets included in the segment. Returns an error if this causes the same user key to be both included and excluded. ##### Parameters - `values`: List of user keys. #### addExcludedUsers Adds user keys to the individual user targets excluded from the segment. Returns an error if this causes the same user key to be both included and excluded. ##### Parameters - `values`: List of user keys. #### removeIncludedUsers Removes user keys from the individual user targets included in the segment. ##### Parameters - `values`: List of user keys. #### removeExcludedUsers Removes user keys from the individual user targets excluded from the segment. ##### Parameters - `values`: List of user keys. #### updateName Updates the name of the segment. ##### Parameters - `value`: Name of the segment. ## Using JSON patches on a segment You can also use JSON patch. To learn more, read [Updates using JSON patches](/reference#updates-using-json-patch). For example, to update the description for a segment, use the following request body: “`json { "patch": [ { "op": "replace", "path": "/description", "value": "new description" } ] } “` To update fields in the segment that are arrays, set the `path` to the name of the field and then append `/<array index>`. Using `/0` adds the new entry to the beginning of the array. For example, to add a rule to a segment, use the following request body: “`json { "patch":[ { "op": "add", "path": "/rules/0", "value": { "clauses": [{ "attribute": "email", "op": "endsWith", "values": [".edu"], "negate": false }] } } ] } “` To add or remove users from segments, we recommend using semantic patch. Semantic patch for segments includes specific `instructions` for adding and removing both included and excluded users.

Parameters:

  • project_key (String)

    The project key

  • environment_key (String)

    The environment key

  • segment_key (String)

    The segment key

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

    the optional parameters

Returns:



491
492
493
494
# File 'lib/launchdarkly_api/api/segments_api.rb', line 491

def patch_segment(project_key, environment_key, segment_key, patch_with_comment, opts = {})
  data, _status_code, _headers = patch_segment_with_http_info(project_key, environment_key, segment_key, patch_with_comment, opts)
  data
end

#patch_segment_with_http_info(project_key, environment_key, segment_key, patch_with_comment, opts = {}) ⇒ Array<(UserSegment, Integer, Hash)>

Patch segment Update a user segment. The request body must be a valid semantic patch, JSON patch, or JSON merge patch. ### Using semantic patches on a segment To make a semantic patch request, you must append &#x60;domain-model&#x3D;launchdarkly.semanticpatch&#x60; to your &#x60;Content-Type&#x60; header. To learn more, read [Updates using semantic patch](/reference#updates-using-semantic-patch). The body of a semantic patch request for updating segments requires an &#x60;environmentKey&#x60; in addition to &#x60;instructions&#x60; and an optional &#x60;comment&#x60;. The body of the request takes the following properties: * &#x60;comment&#x60; (string): (Optional) A description of the update. * &#x60;environmentKey&#x60; (string): (Required) The key of the LaunchDarkly environment. * &#x60;instructions&#x60; (array): (Required) A list of actions the update should perform. Each action in the list must be an object with a &#x60;kind&#x60; property that indicates the instruction. If the action requires parameters, you must include those parameters as additional fields in the object. ### Instructions Semantic patch requests support the following &#x60;kind&#x60; instructions for updating segments. #### addIncludedUsers Adds user keys to the individual user targets included in the segment. Returns an error if this causes the same user key to be both included and excluded. ##### Parameters - &#x60;values&#x60;: List of user keys. #### addExcludedUsers Adds user keys to the individual user targets excluded from the segment. Returns an error if this causes the same user key to be both included and excluded. ##### Parameters - &#x60;values&#x60;: List of user keys. #### removeIncludedUsers Removes user keys from the individual user targets included in the segment. ##### Parameters - &#x60;values&#x60;: List of user keys. #### removeExcludedUsers Removes user keys from the individual user targets excluded from the segment. ##### Parameters - &#x60;values&#x60;: List of user keys. #### updateName Updates the name of the segment. ##### Parameters - &#x60;value&#x60;: Name of the segment. ## Using JSON patches on a segment You can also use JSON patch. To learn more, read [Updates using JSON patches](/reference#updates-using-json-patch). For example, to update the description for a segment, use the following request body: &#x60;&#x60;&#x60;json { &quot;patch&quot;: [ { &quot;op&quot;: &quot;replace&quot;, &quot;path&quot;: &quot;/description&quot;, &quot;value&quot;: &quot;new description&quot; } ] } &#x60;&#x60;&#x60; To update fields in the segment that are arrays, set the &#x60;path&#x60; to the name of the field and then append &#x60;/&lt;array index&gt;&#x60;. Using &#x60;/0&#x60; adds the new entry to the beginning of the array. For example, to add a rule to a segment, use the following request body: &#x60;&#x60;&#x60;json { &quot;patch&quot;:[ { &quot;op&quot;: &quot;add&quot;, &quot;path&quot;: &quot;/rules/0&quot;, &quot;value&quot;: { &quot;clauses&quot;: [{ &quot;attribute&quot;: &quot;email&quot;, &quot;op&quot;: &quot;endsWith&quot;, &quot;values&quot;: [&quot;.edu&quot;], &quot;negate&quot;: false }] } } ] } &#x60;&#x60;&#x60; To add or remove users from segments, we recommend using semantic patch. Semantic patch for segments includes specific &#x60;instructions&#x60; for adding and removing both included and excluded users.

Parameters:

  • project_key (String)

    The project key

  • environment_key (String)

    The environment key

  • segment_key (String)

    The segment key

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

    the optional parameters

Returns:

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

    UserSegment data, response status code and response headers



504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
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
# File 'lib/launchdarkly_api/api/segments_api.rb', line 504

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

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

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

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

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

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

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

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

#post_segment(project_key, environment_key, segment_body, opts = {}) ⇒ UserSegment

Create segment Create a new user segment.

Parameters:

  • project_key (String)

    The project key

  • environment_key (String)

    The environment key

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

    the optional parameters

Returns:



576
577
578
579
# File 'lib/launchdarkly_api/api/segments_api.rb', line 576

def post_segment(project_key, environment_key, segment_body, opts = {})
  data, _status_code, _headers = post_segment_with_http_info(project_key, environment_key, segment_body, opts)
  data
end

#post_segment_with_http_info(project_key, environment_key, segment_body, opts = {}) ⇒ Array<(UserSegment, Integer, Hash)>

Create segment Create a new user segment.

Parameters:

  • project_key (String)

    The project key

  • environment_key (String)

    The environment key

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

    the optional parameters

Returns:

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

    UserSegment data, response status code and response headers



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

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

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

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

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

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

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

#update_big_segment_targets(project_key, environment_key, segment_key, segment_user_state, opts = {}) ⇒ nil

Update targets on a Big Segment Update targets included or excluded in a Big Segment.

Parameters:

  • project_key (String)

    The project key

  • environment_key (String)

    The environment key

  • segment_key (String)

    The segment key

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

    the optional parameters

Returns:

  • (nil)


657
658
659
660
# File 'lib/launchdarkly_api/api/segments_api.rb', line 657

def update_big_segment_targets(project_key, environment_key, segment_key, segment_user_state, opts = {})
  update_big_segment_targets_with_http_info(project_key, environment_key, segment_key, segment_user_state, opts)
  nil
end

#update_big_segment_targets_with_http_info(project_key, environment_key, segment_key, segment_user_state, opts = {}) ⇒ Array<(nil, Integer, Hash)>

Update targets on a Big Segment Update targets included or excluded in a Big Segment.

Parameters:

  • project_key (String)

    The project key

  • environment_key (String)

    The environment key

  • segment_key (String)

    The segment key

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

    the optional parameters

Returns:

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

    nil, response status code and response headers



670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
# File 'lib/launchdarkly_api/api/segments_api.rb', line 670

def update_big_segment_targets_with_http_info(project_key, environment_key, segment_key, segment_user_state, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: SegmentsApi.update_big_segment_targets ...'
  end
  # verify the required parameter 'project_key' is set
  if @api_client.config.client_side_validation && project_key.nil?
    fail ArgumentError, "Missing the required parameter 'project_key' when calling SegmentsApi.update_big_segment_targets"
  end
  # verify the required parameter 'environment_key' is set
  if @api_client.config.client_side_validation && environment_key.nil?
    fail ArgumentError, "Missing the required parameter 'environment_key' when calling SegmentsApi.update_big_segment_targets"
  end
  # verify the required parameter 'segment_key' is set
  if @api_client.config.client_side_validation && segment_key.nil?
    fail ArgumentError, "Missing the required parameter 'segment_key' when calling SegmentsApi.update_big_segment_targets"
  end
  # verify the required parameter 'segment_user_state' is set
  if @api_client.config.client_side_validation && segment_user_state.nil?
    fail ArgumentError, "Missing the required parameter 'segment_user_state' when calling SegmentsApi.update_big_segment_targets"
  end
  # resource path
  local_var_path = '/api/v2/segments/{projectKey}/{environmentKey}/{segmentKey}/users'.sub('{' + 'projectKey' + '}', CGI.escape(project_key.to_s)).sub('{' + 'environmentKey' + '}', CGI.escape(environment_key.to_s)).sub('{' + 'segmentKey' + '}', CGI.escape(segment_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(segment_user_state)

  # return_type
  return_type = opts[:debug_return_type]

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

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

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