Class: LaunchDarklyApi::UsersApi

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_client = ApiClient.default) ⇒ UsersApi

Returns a new instance of UsersApi.



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

def api_client
  @api_client
end

Instance Method Details

#delete_user(project_key, environment_key, user_key, opts = {}) ⇒ nil

Delete user Delete a user by key

Parameters:

  • project_key (String)

    The project key

  • environment_key (String)

    The environment key

  • user_key (String)

    The user key

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

    the optional parameters

Returns:

  • (nil)


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

def delete_user(project_key, environment_key, user_key, opts = {})
  delete_user_with_http_info(project_key, environment_key, user_key, opts)
  nil
end

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

Delete user Delete a user by key

Parameters:

  • project_key (String)

    The project key

  • environment_key (String)

    The environment key

  • user_key (String)

    The user 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/users_api.rb', line 41

def delete_user_with_http_info(project_key, environment_key, user_key, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: UsersApi.delete_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 UsersApi.delete_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 UsersApi.delete_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 UsersApi.delete_user"
  end
  # resource path
  local_var_path = '/api/v2/users/{projectKey}/{environmentKey}/{userKey}'.sub('{' + 'projectKey' + '}', CGI.escape(project_key.to_s)).sub('{' + 'environmentKey' + '}', CGI.escape(environment_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]

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

  new_options = opts.merge(
    :operation => :"UsersApi.delete_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(:DELETE, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: UsersApi#delete_user\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#get_search_users(project_key, environment_key, opts = {}) ⇒ Users

Find users Search users in LaunchDarkly based on their last active date, a user attribute filter set, or a search query. An example user attribute filter set is ‘filter=firstName:Anna,activeTrial:false`. This matches users that have the user attribute `firstName` set to `Anna`, that also have the attribute `activeTrial` set to `false`. To paginate through results, follow the `next` link in the `_links` object. To learn more, read [Representations](/#section/Representations). > ### `offset` is deprecated > > `offset` is deprecated and will be removed in a future API version. You can still use `offset` and `limit` for pagination, but we recommend you use `sort` and `searchAfter` instead. `searchAfter` allows you to page through more than 10,000 users, but `offset` and `limit` do not.

Parameters:

  • project_key (String)

    The project key

  • environment_key (String)

    The environment key

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

    the optional parameters

Options Hash (opts):

  • :q (String)

    Full-text search for users based on name, first name, last name, e-mail address, or key

  • :limit (Integer)

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

  • :offset (Integer)

    Specifies the first item to return in the collection

  • :after (Integer)

    A unix epoch time in milliseconds specifying the maximum last time a user requested a feature flag from LaunchDarkly

  • :sort (String)

    Specifies a field by which to sort. LaunchDarkly supports the &#x60;userKey&#x60; and &#x60;lastSeen&#x60; fields. Fields prefixed by a dash ( - ) sort in descending order.

  • :search_after (String)

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

  • :filter (String)

    A comma-separated list of user attribute filters. Each filter is in the form of attributeKey:attributeValue

Returns:



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

def get_search_users(project_key, environment_key, opts = {})
  data, _status_code, _headers = get_search_users_with_http_info(project_key, environment_key, opts)
  data
end

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

Find users Search users in LaunchDarkly based on their last active date, a user attribute filter set, or a search query. An example user attribute filter set is &#x60;filter&#x3D;firstName:Anna,activeTrial:false&#x60;. This matches users that have the user attribute &#x60;firstName&#x60; set to &#x60;Anna&#x60;, that also have the attribute &#x60;activeTrial&#x60; set to &#x60;false&#x60;. To paginate through results, follow the &#x60;next&#x60; link in the &#x60;_links&#x60; object. To learn more, read [Representations](/#section/Representations). &gt; ### &#x60;offset&#x60; is deprecated &gt; &gt; &#x60;offset&#x60; is deprecated and will be removed in a future API version. You can still use &#x60;offset&#x60; and &#x60;limit&#x60; for pagination, but we recommend you use &#x60;sort&#x60; and &#x60;searchAfter&#x60; instead. &#x60;searchAfter&#x60; allows you to page through more than 10,000 users, but &#x60;offset&#x60; and &#x60;limit&#x60; do not.

Parameters:

  • project_key (String)

    The project key

  • environment_key (String)

    The environment key

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

    the optional parameters

Options Hash (opts):

  • :q (String)

    Full-text search for users based on name, first name, last name, e-mail address, or key

  • :limit (Integer)

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

  • :offset (Integer)

    Specifies the first item to return in the collection

  • :after (Integer)

    A unix epoch time in milliseconds specifying the maximum last time a user requested a feature flag from LaunchDarkly

  • :sort (String)

    Specifies a field by which to sort. LaunchDarkly supports the &#x60;userKey&#x60; and &#x60;lastSeen&#x60; fields. Fields prefixed by a dash ( - ) sort in descending order.

  • :search_after (String)

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

  • :filter (String)

    A comma-separated list of user attribute filters. Each filter is in the form of attributeKey:attributeValue

Returns:

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

    Users data, response status code and response headers



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
# File 'lib/launchdarkly_api/api/users_api.rb', line 128

def get_search_users_with_http_info(project_key, environment_key, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: UsersApi.get_search_users ...'
  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 UsersApi.get_search_users"
  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 UsersApi.get_search_users"
  end
  # resource path
  local_var_path = '/api/v2/user-search/{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] || {}
  query_params[:'q'] = opts[:'q'] if !opts[:'q'].nil?
  query_params[:'limit'] = opts[:'limit'] if !opts[:'limit'].nil?
  query_params[:'offset'] = opts[:'offset'] if !opts[:'offset'].nil?
  query_params[:'after'] = opts[:'after'] if !opts[:'after'].nil?
  query_params[:'sort'] = opts[:'sort'] if !opts[:'sort'].nil?
  query_params[:'searchAfter'] = opts[:'search_after'] if !opts[:'search_after'].nil?
  query_params[:'filter'] = opts[:'filter'] if !opts[:'filter'].nil?

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

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

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

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

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

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

#get_user(project_key, environment_key, user_key, opts = {}) ⇒ UserRecord

Get user Get a user by key. The ‘user` object contains all attributes sent in `variation` calls for that key.

Parameters:

  • project_key (String)

    The project key

  • environment_key (String)

    The environment key

  • user_key (String)

    The user key

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

    the optional parameters

Returns:



194
195
196
197
# File 'lib/launchdarkly_api/api/users_api.rb', line 194

def get_user(project_key, environment_key, user_key, opts = {})
  data, _status_code, _headers = get_user_with_http_info(project_key, environment_key, user_key, opts)
  data
end

#get_user_with_http_info(project_key, environment_key, user_key, opts = {}) ⇒ Array<(UserRecord, Integer, Hash)>

Get user Get a user by key. The &#x60;user&#x60; object contains all attributes sent in &#x60;variation&#x60; calls for that key.

Parameters:

  • project_key (String)

    The project key

  • environment_key (String)

    The environment key

  • user_key (String)

    The user key

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

    the optional parameters

Returns:

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

    UserRecord data, response status code and response headers



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

def get_user_with_http_info(project_key, environment_key, user_key, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: UsersApi.get_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 UsersApi.get_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 UsersApi.get_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 UsersApi.get_user"
  end
  # resource path
  local_var_path = '/api/v2/users/{projectKey}/{environmentKey}/{userKey}'.sub('{' + 'projectKey' + '}', CGI.escape(project_key.to_s)).sub('{' + 'environmentKey' + '}', CGI.escape(environment_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] || 'UserRecord'

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

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

#get_users(project_key, environment_key, opts = {}) ⇒ Users

List users List all users in the environment. Includes the total count of users. In each page, there is up to ‘limit` users returned. The default is 20. This is useful for exporting all users in the system for further analysis. To paginate through, follow the `next` link in the `_links` object, as [described in Representations](/#section/Representations).

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 number of elements to return per page

  • :search_after (String)

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

Returns:



270
271
272
273
# File 'lib/launchdarkly_api/api/users_api.rb', line 270

def get_users(project_key, environment_key, opts = {})
  data, _status_code, _headers = get_users_with_http_info(project_key, environment_key, opts)
  data
end

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

List users List all users in the environment. Includes the total count of users. In each page, there is up to &#x60;limit&#x60; users returned. The default is 20. This is useful for exporting all users in the system for further analysis. To paginate through, follow the &#x60;next&#x60; link in the &#x60;_links&#x60; object, as [described in Representations](/#section/Representations).

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 number of elements to return per page

  • :search_after (String)

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

Returns:

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

    Users data, response status code and response headers



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

def get_users_with_http_info(project_key, environment_key, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: UsersApi.get_users ...'
  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 UsersApi.get_users"
  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 UsersApi.get_users"
  end
  # resource path
  local_var_path = '/api/v2/users/{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] || {}
  query_params[:'limit'] = opts[:'limit'] if !opts[:'limit'].nil?
  query_params[:'searchAfter'] = opts[:'search_after'] if !opts[:'search_after'].nil?

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

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

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

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

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

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