Class: Fastly::UserApi

Inherits:
Object
  • Object
show all
Defined in:
lib/fastly/api/user_api.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_client = ApiClient.default) ⇒ UserApi

Returns a new instance of UserApi.



17
18
19
# File 'lib/fastly/api/user_api.rb', line 17

def initialize(api_client = ApiClient.default)
  @api_client = api_client
end

Instance Attribute Details

#api_clientObject

Returns the value of attribute api_client.



15
16
17
# File 'lib/fastly/api/user_api.rb', line 15

def api_client
  @api_client
end

Instance Method Details

#create_user(opts = {}) ⇒ UserResponse

Create a user Create a user.

Parameters:

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

    a customizable set of options

Options Hash (opts):

  • :login (String)
  • :name (String)

    The real life name of the user.

  • :limit_services (Boolean)

    Indicates that the user has limited access to the customer's services.

  • :locked (Boolean)

    Indicates whether the is account is locked for editing or not.

  • :require_new_password (Boolean)

    Indicates if a new password is required at next login.

  • :role (RoleUser)
  • :two_factor_auth_enabled (Boolean)

    Indicates if 2FA is enabled on the user.

  • :two_factor_setup_required (Boolean)

    Indicates if 2FA is required by the user's customer account.

Returns:



31
32
33
34
# File 'lib/fastly/api/user_api.rb', line 31

def create_user(opts = {})
  data, _status_code, _headers = create_user_with_http_info(opts)
  data
end

#create_user_with_http_info(opts = {}) ⇒ Array<(UserResponse, Integer, Hash)>

Create a user Create a user.

Parameters:

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

    a customizable set of options

Options Hash (opts):

  • :login (String)
  • :name (String)

    The real life name of the user.

  • :limit_services (Boolean)

    Indicates that the user has limited access to the customer&#39;s services.

  • :locked (Boolean)

    Indicates whether the is account is locked for editing or not.

  • :require_new_password (Boolean)

    Indicates if a new password is required at next login.

  • :role (RoleUser)
  • :two_factor_auth_enabled (Boolean)

    Indicates if 2FA is enabled on the user.

  • :two_factor_setup_required (Boolean)

    Indicates if 2FA is required by the user&#39;s customer account.

Returns:

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

    UserResponse data, response status code and response headers



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
101
102
103
# File 'lib/fastly/api/user_api.rb', line 47

def create_user_with_http_info(opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: UserApi.create_user ...'
  end
  # unbox the parameters from the hash
  # resource path
  local_var_path = '/user'

  # 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/x-www-form-urlencoded'])
  if !content_type.nil?
      header_params['Content-Type'] = content_type
  end

  # form parameters
  form_params = opts[:form_params] || {}
  form_params['login'] = opts[:'login'] if !opts[:'login'].nil?
  form_params['name'] = opts[:'name'] if !opts[:'name'].nil?
  form_params['limit_services'] = opts[:'limit_services'] if !opts[:'limit_services'].nil?
  form_params['locked'] = opts[:'locked'] if !opts[:'locked'].nil?
  form_params['require_new_password'] = opts[:'require_new_password'] if !opts[:'require_new_password'].nil?
  form_params['role'] = opts[:'role'] if !opts[:'role'].nil?
  form_params['two_factor_auth_enabled'] = opts[:'two_factor_auth_enabled'] if !opts[:'two_factor_auth_enabled'].nil?
  form_params['two_factor_setup_required'] = opts[:'two_factor_setup_required'] if !opts[:'two_factor_setup_required'].nil?

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

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

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

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

#delete_user(opts = {}) ⇒ InlineResponse200

Delete a user Delete a user.

Parameters:

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

    a customizable set of options

Options Hash (opts):

  • :user_id (String)

    Alphanumeric string identifying the user. (required)

Returns:



109
110
111
112
# File 'lib/fastly/api/user_api.rb', line 109

def delete_user(opts = {})
  data, _status_code, _headers = delete_user_with_http_info(opts)
  data
end

#delete_user_with_http_info(opts = {}) ⇒ Array<(InlineResponse200, Integer, Hash)>

Delete a user Delete a user.

Parameters:

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

    a customizable set of options

Options Hash (opts):

  • :user_id (String)

    Alphanumeric string identifying the user. (required)

Returns:

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

    InlineResponse200 data, response status code and response headers



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
# File 'lib/fastly/api/user_api.rb', line 118

def delete_user_with_http_info(opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: UserApi.delete_user ...'
  end
  # unbox the parameters from the hash
  user_id = opts[:'user_id']
  # verify the required parameter 'user_id' is set
  if @api_client.config.client_side_validation && user_id.nil?
    fail ArgumentError, "Missing the required parameter 'user_id' when calling UserApi.delete_user"
  end
  # resource path
  local_var_path = '/user/{user_id}'.sub('{' + 'user_id' + '}', CGI.escape(user_id.to_s))

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

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

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

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

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

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

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

#get_current_user(opts = {}) ⇒ UserResponse

Get the current user Get the logged in user.

Returns:



171
172
173
174
# File 'lib/fastly/api/user_api.rb', line 171

def get_current_user(opts = {})
  data, _status_code, _headers = get_current_user_with_http_info(opts)
  data
end

#get_current_user_with_http_info(opts = {}) ⇒ Array<(UserResponse, Integer, Hash)>

Get the current user Get the logged in user.

Returns:

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

    UserResponse data, response status code and response headers



179
180
181
182
183
184
185
186
187
188
189
190
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
# File 'lib/fastly/api/user_api.rb', line 179

def get_current_user_with_http_info(opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: UserApi.get_current_user ...'
  end
  # unbox the parameters from the hash
  # resource path
  local_var_path = '/current_user'

  # 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] || 'UserResponse'

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

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

#get_user(opts = {}) ⇒ UserResponse

Get a user Get a specific user.

Parameters:

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

    a customizable set of options

Options Hash (opts):

  • :user_id (String)

    Alphanumeric string identifying the user. (required)

Returns:



228
229
230
231
# File 'lib/fastly/api/user_api.rb', line 228

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

#get_user_with_http_info(opts = {}) ⇒ Array<(UserResponse, Integer, Hash)>

Get a user Get a specific user.

Parameters:

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

    a customizable set of options

Options Hash (opts):

  • :user_id (String)

    Alphanumeric string identifying the user. (required)

Returns:

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

    UserResponse data, response status code and response headers



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
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
# File 'lib/fastly/api/user_api.rb', line 237

def get_user_with_http_info(opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: UserApi.get_user ...'
  end
  # unbox the parameters from the hash
  user_id = opts[:'user_id']
  # verify the required parameter 'user_id' is set
  if @api_client.config.client_side_validation && user_id.nil?
    fail ArgumentError, "Missing the required parameter 'user_id' when calling UserApi.get_user"
  end
  # resource path
  local_var_path = '/user/{user_id}'.sub('{' + 'user_id' + '}', CGI.escape(user_id.to_s))

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

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

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

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

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

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

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

#request_password_reset(opts = {}) ⇒ InlineResponse200

Request a password reset Requests a password reset for the specified user.

Parameters:

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

    a customizable set of options

Options Hash (opts):

  • :user_login (String)

    The login associated with the user (typically, an email address). (required)

Returns:



291
292
293
294
# File 'lib/fastly/api/user_api.rb', line 291

def request_password_reset(opts = {})
  data, _status_code, _headers = request_password_reset_with_http_info(opts)
  data
end

#request_password_reset_with_http_info(opts = {}) ⇒ Array<(InlineResponse200, Integer, Hash)>

Request a password reset Requests a password reset for the specified user.

Parameters:

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

    a customizable set of options

Options Hash (opts):

  • :user_login (String)

    The login associated with the user (typically, an email address). (required)

Returns:

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

    InlineResponse200 data, response status code and response headers



300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
# File 'lib/fastly/api/user_api.rb', line 300

def request_password_reset_with_http_info(opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: UserApi.request_password_reset ...'
  end
  # unbox the parameters from the hash
   = opts[:'user_login']
  # verify the required parameter 'user_login' is set
  if @api_client.config.client_side_validation && .nil?
    fail ArgumentError, "Missing the required parameter 'user_login' when calling UserApi.request_password_reset"
  end
  # resource path
  local_var_path = '/user/{user_login}/password/request_reset'.sub('{' + 'user_login' + '}', CGI.escape(.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] || 'InlineResponse200'

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

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

#update_user(opts = {}) ⇒ UserResponse

Update a user Update a user. Only users with the role of ‘superuser` can make changes to other users on the account. Non-superusers may use this endpoint to make changes to their own account. Two-factor attributes are not editable via this endpoint.

Parameters:

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

    a customizable set of options

Options Hash (opts):

  • :user_id (String)

    Alphanumeric string identifying the user. (required)

  • :login (String)
  • :name (String)

    The real life name of the user.

  • :limit_services (Boolean)

    Indicates that the user has limited access to the customer&#39;s services.

  • :locked (Boolean)

    Indicates whether the is account is locked for editing or not.

  • :require_new_password (Boolean)

    Indicates if a new password is required at next login.

  • :role (RoleUser)
  • :two_factor_auth_enabled (Boolean)

    Indicates if 2FA is enabled on the user.

  • :two_factor_setup_required (Boolean)

    Indicates if 2FA is required by the user&#39;s customer account.

Returns:



362
363
364
365
# File 'lib/fastly/api/user_api.rb', line 362

def update_user(opts = {})
  data, _status_code, _headers = update_user_with_http_info(opts)
  data
end

#update_user_password(opts = {}) ⇒ UserResponse

Update the user’s password Update the user’s password to a new one.

Parameters:

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

    a customizable set of options

Options Hash (opts):

  • :old_password (String)

    The user&#39;s current password.

  • :new_password (String)

    The user&#39;s new password.

Returns:



447
448
449
450
# File 'lib/fastly/api/user_api.rb', line 447

def update_user_password(opts = {})
  data, _status_code, _headers = update_user_password_with_http_info(opts)
  data
end

#update_user_password_with_http_info(opts = {}) ⇒ Array<(UserResponse, Integer, Hash)>

Update the user&#39;s password Update the user&#39;s password to a new one.

Parameters:

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

    a customizable set of options

Options Hash (opts):

  • :old_password (String)

    The user&#39;s current password.

  • :new_password (String)

    The user&#39;s new password.

Returns:

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

    UserResponse data, response status code and response headers



457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
# File 'lib/fastly/api/user_api.rb', line 457

def update_user_password_with_http_info(opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: UserApi.update_user_password ...'
  end
  # unbox the parameters from the hash
  # resource path
  local_var_path = '/current_user/password'

  # 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/x-www-form-urlencoded'])
  if !content_type.nil?
      header_params['Content-Type'] = content_type
  end

  # form parameters
  form_params = opts[:form_params] || {}
  form_params['old_password'] = opts[:'old_password'] if !opts[:'old_password'].nil?
  form_params['new_password'] = opts[:'new_password'] if !opts[:'new_password'].nil?

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

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

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

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

#update_user_with_http_info(opts = {}) ⇒ Array<(UserResponse, Integer, Hash)>

Update a user Update a user. Only users with the role of &#x60;superuser&#x60; can make changes to other users on the account. Non-superusers may use this endpoint to make changes to their own account. Two-factor attributes are not editable via this endpoint.

Parameters:

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

    a customizable set of options

Options Hash (opts):

  • :user_id (String)

    Alphanumeric string identifying the user. (required)

  • :login (String)
  • :name (String)

    The real life name of the user.

  • :limit_services (Boolean)

    Indicates that the user has limited access to the customer&#39;s services.

  • :locked (Boolean)

    Indicates whether the is account is locked for editing or not.

  • :require_new_password (Boolean)

    Indicates if a new password is required at next login.

  • :role (RoleUser)
  • :two_factor_auth_enabled (Boolean)

    Indicates if 2FA is enabled on the user.

  • :two_factor_setup_required (Boolean)

    Indicates if 2FA is required by the user&#39;s customer account.

Returns:

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

    UserResponse data, response status code and response headers



379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
# File 'lib/fastly/api/user_api.rb', line 379

def update_user_with_http_info(opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: UserApi.update_user ...'
  end
  # unbox the parameters from the hash
  user_id = opts[:'user_id']
  # verify the required parameter 'user_id' is set
  if @api_client.config.client_side_validation && user_id.nil?
    fail ArgumentError, "Missing the required parameter 'user_id' when calling UserApi.update_user"
  end
  # resource path
  local_var_path = '/user/{user_id}'.sub('{' + 'user_id' + '}', CGI.escape(user_id.to_s))

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

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

  # form parameters
  form_params = opts[:form_params] || {}
  form_params['login'] = opts[:'login'] if !opts[:'login'].nil?
  form_params['name'] = opts[:'name'] if !opts[:'name'].nil?
  form_params['limit_services'] = opts[:'limit_services'] if !opts[:'limit_services'].nil?
  form_params['locked'] = opts[:'locked'] if !opts[:'locked'].nil?
  form_params['require_new_password'] = opts[:'require_new_password'] if !opts[:'require_new_password'].nil?
  form_params['role'] = opts[:'role'] if !opts[:'role'].nil?
  form_params['two_factor_auth_enabled'] = opts[:'two_factor_auth_enabled'] if !opts[:'two_factor_auth_enabled'].nil?
  form_params['two_factor_setup_required'] = opts[:'two_factor_setup_required'] if !opts[:'two_factor_setup_required'].nil?

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

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

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

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