Class: Harbor2Client::UserApi

Inherits:
Object
  • Object
show all
Defined in:
lib/harbor2_client/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.



19
20
21
# File 'lib/harbor2_client/api/user_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/harbor2_client/api/user_api.rb', line 17

def api_client
  @api_client
end

Instance Method Details

#create_user(user_req, opts = {}) ⇒ nil

Create a local user. This API can be used only when the authentication mode is for local DB. When self registration is disabled.

Parameters:

  • user_req

    The new user

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

    the optional parameters

Options Hash (opts):

  • :x_request_id (String)

    An unique ID for the request

Returns:

  • (nil)


28
29
30
31
# File 'lib/harbor2_client/api/user_api.rb', line 28

def create_user(user_req, opts = {})
  create_user_with_http_info(user_req, opts)
  nil
end

#create_user_with_http_info(user_req, opts = {}) ⇒ Array<(nil, Fixnum, Hash)>

Create a local user. This API can be used only when the authentication mode is for local DB. When self registration is disabled.

Parameters:

  • user_req

    The new user

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

    the optional parameters

Options Hash (opts):

  • :x_request_id (String)

    An unique ID for the request

Returns:

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

    nil, response status code and response headers



39
40
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
# File 'lib/harbor2_client/api/user_api.rb', line 39

def create_user_with_http_info(user_req, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: UserApi.create_user ...'
  end
  # verify the required parameter 'user_req' is set
  if @api_client.config.client_side_validation && user_req.nil?
    fail ArgumentError, "Missing the required parameter 'user_req' when calling UserApi.create_user"
  end
  if @api_client.config.client_side_validation && !opts[:'x_request_id'].nil? && opts[:'x_request_id'].to_s.length < 1
    fail ArgumentError, 'invalid value for "opts[:"x_request_id"]" when calling UserApi.create_user, the character length must be great than or equal to 1.'
  end

  # resource path
  local_var_path = '/users'

  # query parameters
  query_params = {}

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

  # form parameters
  form_params = {}

  # http body (model)
  post_body = @api_client.object_to_http_body(user_req)
  auth_names = ['basic']
  data, status_code, headers = @api_client.call_api(:POST, local_var_path,
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names)
  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(user_id, opts = {}) ⇒ nil

Mark a registered user as be removed. This endpoint let administrator of Harbor mark a registered user as removed.It actually won’t be deleted from DB.

Parameters:

  • user_id

    User ID for marking as to be removed.

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

    the optional parameters

Options Hash (opts):

  • :x_request_id (String)

    An unique ID for the request

Returns:

  • (nil)


88
89
90
91
# File 'lib/harbor2_client/api/user_api.rb', line 88

def delete_user(user_id, opts = {})
  delete_user_with_http_info(user_id, opts)
  nil
end

#delete_user_with_http_info(user_id, opts = {}) ⇒ Array<(nil, Fixnum, Hash)>

Mark a registered user as be removed. This endpoint let administrator of Harbor mark a registered user as removed.It actually won&#39;t be deleted from DB.

Parameters:

  • user_id

    User ID for marking as to be removed.

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

    the optional parameters

Options Hash (opts):

  • :x_request_id (String)

    An unique ID for the request

Returns:

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

    nil, response status code and response headers



99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
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
# File 'lib/harbor2_client/api/user_api.rb', line 99

def delete_user_with_http_info(user_id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: UserApi.delete_user ...'
  end
  # 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
  if @api_client.config.client_side_validation && !opts[:'x_request_id'].nil? && opts[:'x_request_id'].to_s.length < 1
    fail ArgumentError, 'invalid value for "opts[:"x_request_id"]" when calling UserApi.delete_user, the character length must be great than or equal to 1.'
  end

  # resource path
  local_var_path = '/users/{user_id}'.sub('{' + 'user_id' + '}', user_id.to_s)

  # query parameters
  query_params = {}

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

  # form parameters
  form_params = {}

  # http body (model)
  post_body = nil
  auth_names = ['basic']
  data, status_code, headers = @api_client.call_api(:DELETE, local_var_path,
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names)
  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_info(opts = {}) ⇒ UserResp

Get current user info.

Parameters:

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

    the optional parameters

Options Hash (opts):

  • :x_request_id (String)

    An unique ID for the request

Returns:



146
147
148
149
# File 'lib/harbor2_client/api/user_api.rb', line 146

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

#get_current_user_info_with_http_info(opts = {}) ⇒ Array<(UserResp, Fixnum, Hash)>

Get current user info.

Parameters:

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

    the optional parameters

Options Hash (opts):

  • :x_request_id (String)

    An unique ID for the request

Returns:

  • (Array<(UserResp, Fixnum, Hash)>)

    UserResp data, response status code and response headers



155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
# File 'lib/harbor2_client/api/user_api.rb', line 155

def (opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: UserApi.get_current_user_info ...'
  end
  if @api_client.config.client_side_validation && !opts[:'x_request_id'].nil? && opts[:'x_request_id'].to_s.length < 1
    fail ArgumentError, 'invalid value for "opts[:"x_request_id"]" when calling UserApi.get_current_user_info, the character length must be great than or equal to 1.'
  end

  # resource path
  local_var_path = '/users/current'

  # query parameters
  query_params = {}

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

  # form parameters
  form_params = {}

  # http body (model)
  post_body = nil
  auth_names = ['basic']
  data, status_code, headers = @api_client.call_api(:GET, local_var_path,
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => 'UserResp')
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: UserApi#get_current_user_info\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#get_current_user_permissions(opts = {}) ⇒ Array<Permission>

Get current user permissions.

Parameters:

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

    the optional parameters

Options Hash (opts):

  • :x_request_id (String)

    An unique ID for the request

  • :scope (String)

    The scope for the permission

  • :relative (BOOLEAN)

    If true, the resources in the response are relative to the scope, eg for resource &#39;/project/1/repository&#39; if relative is &#39;true&#39; then the resource in response will be &#39;repository&#39;.

Returns:



201
202
203
204
# File 'lib/harbor2_client/api/user_api.rb', line 201

def get_current_user_permissions(opts = {})
  data, _status_code, _headers = get_current_user_permissions_with_http_info(opts)
  data
end

#get_current_user_permissions_with_http_info(opts = {}) ⇒ Array<(Array<Permission>, Fixnum, Hash)>

Get current user permissions.

Parameters:

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

    the optional parameters

Options Hash (opts):

  • :x_request_id (String)

    An unique ID for the request

  • :scope (String)

    The scope for the permission

  • :relative (BOOLEAN)

    If true, the resources in the response are relative to the scope, eg for resource &#39;/project/1/repository&#39; if relative is &#39;true&#39; then the resource in response will be &#39;repository&#39;.

Returns:

  • (Array<(Array<Permission>, Fixnum, Hash)>)

    Array<Permission> data, response status code and response headers



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

def get_current_user_permissions_with_http_info(opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: UserApi.get_current_user_permissions ...'
  end
  if @api_client.config.client_side_validation && !opts[:'x_request_id'].nil? && opts[:'x_request_id'].to_s.length < 1
    fail ArgumentError, 'invalid value for "opts[:"x_request_id"]" when calling UserApi.get_current_user_permissions, the character length must be great than or equal to 1.'
  end

  # resource path
  local_var_path = '/users/current/permissions'

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

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

  # form parameters
  form_params = {}

  # http body (model)
  post_body = nil
  auth_names = ['basic']
  data, status_code, headers = @api_client.call_api(:GET, local_var_path,
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => 'Array<Permission>')
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: UserApi#get_current_user_permissions\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#get_user(user_id, opts = {}) ⇒ UserResp

Get a user’s profile.

Parameters:

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

    the optional parameters

Options Hash (opts):

  • :x_request_id (String)

    An unique ID for the request

Returns:



259
260
261
262
# File 'lib/harbor2_client/api/user_api.rb', line 259

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

#get_user_with_http_info(user_id, opts = {}) ⇒ Array<(UserResp, Fixnum, Hash)>

Get a user&#39;s profile.

Parameters:

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

    the optional parameters

Options Hash (opts):

  • :x_request_id (String)

    An unique ID for the request

Returns:

  • (Array<(UserResp, Fixnum, Hash)>)

    UserResp data, response status code and response headers



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

def get_user_with_http_info(user_id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: UserApi.get_user ...'
  end
  # 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
  if @api_client.config.client_side_validation && !opts[:'x_request_id'].nil? && opts[:'x_request_id'].to_s.length < 1
    fail ArgumentError, 'invalid value for "opts[:"x_request_id"]" when calling UserApi.get_user, the character length must be great than or equal to 1.'
  end

  # resource path
  local_var_path = '/users/{user_id}'.sub('{' + 'user_id' + '}', user_id.to_s)

  # query parameters
  query_params = {}

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

  # form parameters
  form_params = {}

  # http body (model)
  post_body = nil
  auth_names = ['basic']
  data, status_code, headers = @api_client.call_api(:GET, local_var_path,
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => 'UserResp')
  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

#list_users(opts = {}) ⇒ Array<UserResp>

List users

Parameters:

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

    the optional parameters

Options Hash (opts):

  • :x_request_id (String)

    An unique ID for the request

  • :q (String)

    Query string to query resources. Supported query patterns are &quot;exact match(k&#x3D;v)&quot;, &quot;fuzzy match(k&#x3D;~v)&quot;, &quot;range(k&#x3D;)&quot;, &quot;list with union releationship(k&#x3D;v2 v3)&quot; and &quot;list with intersetion relationship(k&#x3D;(v1 v2 v3))&quot;. The value of range and list can be string(enclosed by &quot; or &#39;), integer or time(in format &quot;2020-04-09 02:36:00&quot;). All of these query patterns should be put in the query string &quot;q&#x3D;xxx&quot; and splitted by &quot;,&quot;. e.g. q&#x3D;k1&#x3D;v1,k2&#x3D;~v2,k3&#x3D;

  • :sort (String)

    Sort the resource list in ascending or descending order. e.g. sort by field1 in ascending orderr and field2 in descending order with &quot;sort&#x3D;field1,-field2&quot;

  • :page (Integer)

    The page number (default to 1)

  • :page_size (Integer)

    The size of per page (default to 10)

Returns:



321
322
323
324
# File 'lib/harbor2_client/api/user_api.rb', line 321

def list_users(opts = {})
  data, _status_code, _headers = list_users_with_http_info(opts)
  data
end

#list_users_with_http_info(opts = {}) ⇒ Array<(Array<UserResp>, Fixnum, Hash)>

List users

Parameters:

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

    the optional parameters

Options Hash (opts):

  • :x_request_id (String)

    An unique ID for the request

  • :q (String)

    Query string to query resources. Supported query patterns are &quot;exact match(k&#x3D;v)&quot;, &quot;fuzzy match(k&#x3D;~v)&quot;, &quot;range(k&#x3D;)&quot;, &quot;list with union releationship(k&#x3D;v2 v3)&quot; and &quot;list with intersetion relationship(k&#x3D;(v1 v2 v3))&quot;. The value of range and list can be string(enclosed by &quot; or &#39;), integer or time(in format &quot;2020-04-09 02:36:00&quot;). All of these query patterns should be put in the query string &quot;q&#x3D;xxx&quot; and splitted by &quot;,&quot;. e.g. q&#x3D;k1&#x3D;v1,k2&#x3D;~v2,k3&#x3D;

  • :sort (String)

    Sort the resource list in ascending or descending order. e.g. sort by field1 in ascending orderr and field2 in descending order with &quot;sort&#x3D;field1,-field2&quot;

  • :page (Integer)

    The page number

  • :page_size (Integer)

    The size of per page

Returns:

  • (Array<(Array<UserResp>, Fixnum, Hash)>)

    Array<UserResp> data, response status code and response headers



334
335
336
337
338
339
340
341
342
343
344
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
# File 'lib/harbor2_client/api/user_api.rb', line 334

def list_users_with_http_info(opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: UserApi.list_users ...'
  end
  if @api_client.config.client_side_validation && !opts[:'x_request_id'].nil? && opts[:'x_request_id'].to_s.length < 1
    fail ArgumentError, 'invalid value for "opts[:"x_request_id"]" when calling UserApi.list_users, the character length must be great than or equal to 1.'
  end

  if @api_client.config.client_side_validation && !opts[:'page_size'].nil? && opts[:'page_size'] > 100
    fail ArgumentError, 'invalid value for "opts[:"page_size"]" when calling UserApi.list_users, must be smaller than or equal to 100.'
  end

  # resource path
  local_var_path = '/users'

  # query parameters
  query_params = {}
  query_params[:'q'] = opts[:'q'] if !opts[:'q'].nil?
  query_params[:'sort'] = opts[:'sort'] if !opts[:'sort'].nil?
  query_params[:'page'] = opts[:'page'] if !opts[:'page'].nil?
  query_params[:'page_size'] = opts[:'page_size'] if !opts[:'page_size'].nil?

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

  # form parameters
  form_params = {}

  # http body (model)
  post_body = nil
  auth_names = ['basic']
  data, status_code, headers = @api_client.call_api(:GET, local_var_path,
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => 'Array<UserResp>')
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: UserApi#list_users\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#search_users(username, opts = {}) ⇒ Array<UserSearchRespItem>

Search users by username This endpoint is to search the users by username. It’s open for all authenticated requests.

Parameters:

  • username

    Username for filtering results.

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

    the optional parameters

Options Hash (opts):

  • :x_request_id (String)

    An unique ID for the request

  • :page (Integer)

    The page number (default to 1)

  • :page_size (Integer)

    The size of per page (default to 10)

Returns:



390
391
392
393
# File 'lib/harbor2_client/api/user_api.rb', line 390

def search_users(username, opts = {})
  data, _status_code, _headers = search_users_with_http_info(username, opts)
  data
end

#search_users_with_http_info(username, opts = {}) ⇒ Array<(Array<UserSearchRespItem>, Fixnum, Hash)>

Search users by username This endpoint is to search the users by username. It&#39;s open for all authenticated requests.

Parameters:

  • username

    Username for filtering results.

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

    the optional parameters

Options Hash (opts):

  • :x_request_id (String)

    An unique ID for the request

  • :page (Integer)

    The page number

  • :page_size (Integer)

    The size of per page

Returns:

  • (Array<(Array<UserSearchRespItem>, Fixnum, Hash)>)

    Array<UserSearchRespItem> data, response status code and response headers



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
441
442
443
444
445
446
447
448
449
450
451
452
453
# File 'lib/harbor2_client/api/user_api.rb', line 403

def search_users_with_http_info(username, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: UserApi.search_users ...'
  end
  # verify the required parameter 'username' is set
  if @api_client.config.client_side_validation && username.nil?
    fail ArgumentError, "Missing the required parameter 'username' when calling UserApi.search_users"
  end
  if @api_client.config.client_side_validation && !opts[:'x_request_id'].nil? && opts[:'x_request_id'].to_s.length < 1
    fail ArgumentError, 'invalid value for "opts[:"x_request_id"]" when calling UserApi.search_users, the character length must be great than or equal to 1.'
  end

  if @api_client.config.client_side_validation && !opts[:'page_size'].nil? && opts[:'page_size'] > 100
    fail ArgumentError, 'invalid value for "opts[:"page_size"]" when calling UserApi.search_users, must be smaller than or equal to 100.'
  end

  # resource path
  local_var_path = '/users/search'

  # query parameters
  query_params = {}
  query_params[:'username'] = username
  query_params[:'page'] = opts[:'page'] if !opts[:'page'].nil?
  query_params[:'page_size'] = opts[:'page_size'] if !opts[:'page_size'].nil?

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

  # form parameters
  form_params = {}

  # http body (model)
  post_body = nil
  auth_names = ['basic']
  data, status_code, headers = @api_client.call_api(:GET, local_var_path,
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => 'Array<UserSearchRespItem>')
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: UserApi#search_users\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#set_cli_secret(user_id, secret, opts = {}) ⇒ nil

Set CLI secret for a user. This endpoint let user generate a new CLI secret for himself. This API only works when auth mode is set to ‘OIDC’. Once this API returns with successful status, the old secret will be invalid, as there will be only one CLI secret for a user.

Parameters:

  • user_id

    User ID

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

    the optional parameters

Options Hash (opts):

  • :x_request_id (String)

    An unique ID for the request

Returns:

  • (nil)


461
462
463
464
# File 'lib/harbor2_client/api/user_api.rb', line 461

def set_cli_secret(user_id, secret, opts = {})
  set_cli_secret_with_http_info(user_id, secret, opts)
  nil
end

#set_cli_secret_with_http_info(user_id, secret, opts = {}) ⇒ Array<(nil, Fixnum, Hash)>

Set CLI secret for a user. This endpoint let user generate a new CLI secret for himself. This API only works when auth mode is set to &#39;OIDC&#39;. Once this API returns with successful status, the old secret will be invalid, as there will be only one CLI secret for a user.

Parameters:

  • user_id

    User ID

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

    the optional parameters

Options Hash (opts):

  • :x_request_id (String)

    An unique ID for the request

Returns:

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

    nil, response status code and response headers



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
508
509
510
511
512
513
514
515
516
517
518
519
# File 'lib/harbor2_client/api/user_api.rb', line 473

def set_cli_secret_with_http_info(user_id, secret, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: UserApi.set_cli_secret ...'
  end
  # 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.set_cli_secret"
  end
  # verify the required parameter 'secret' is set
  if @api_client.config.client_side_validation && secret.nil?
    fail ArgumentError, "Missing the required parameter 'secret' when calling UserApi.set_cli_secret"
  end
  if @api_client.config.client_side_validation && !opts[:'x_request_id'].nil? && opts[:'x_request_id'].to_s.length < 1
    fail ArgumentError, 'invalid value for "opts[:"x_request_id"]" when calling UserApi.set_cli_secret, the character length must be great than or equal to 1.'
  end

  # resource path
  local_var_path = '/users/{user_id}/cli_secret'.sub('{' + 'user_id' + '}', user_id.to_s)

  # query parameters
  query_params = {}

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

  # form parameters
  form_params = {}

  # http body (model)
  post_body = @api_client.object_to_http_body(secret)
  auth_names = ['basic']
  data, status_code, headers = @api_client.call_api(:PUT, local_var_path,
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: UserApi#set_cli_secret\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#set_user_sys_admin(user_id, sysadmin_flag, opts = {}) ⇒ nil

Update a registered user to change to be an administrator of Harbor.

Parameters:

  • user_id
  • sysadmin_flag

    Toggle a user to admin or not.

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

    the optional parameters

Options Hash (opts):

  • :x_request_id (String)

    An unique ID for the request

Returns:

  • (nil)


526
527
528
529
# File 'lib/harbor2_client/api/user_api.rb', line 526

def set_user_sys_admin(user_id, sysadmin_flag, opts = {})
  set_user_sys_admin_with_http_info(user_id, sysadmin_flag, opts)
  nil
end

#set_user_sys_admin_with_http_info(user_id, sysadmin_flag, opts = {}) ⇒ Array<(nil, Fixnum, Hash)>

Update a registered user to change to be an administrator of Harbor.

Parameters:

  • user_id
  • sysadmin_flag

    Toggle a user to admin or not.

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

    the optional parameters

Options Hash (opts):

  • :x_request_id (String)

    An unique ID for the request

Returns:

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

    nil, response status code and response headers



537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
# File 'lib/harbor2_client/api/user_api.rb', line 537

def set_user_sys_admin_with_http_info(user_id, sysadmin_flag, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: UserApi.set_user_sys_admin ...'
  end
  # 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.set_user_sys_admin"
  end
  # verify the required parameter 'sysadmin_flag' is set
  if @api_client.config.client_side_validation && sysadmin_flag.nil?
    fail ArgumentError, "Missing the required parameter 'sysadmin_flag' when calling UserApi.set_user_sys_admin"
  end
  if @api_client.config.client_side_validation && !opts[:'x_request_id'].nil? && opts[:'x_request_id'].to_s.length < 1
    fail ArgumentError, 'invalid value for "opts[:"x_request_id"]" when calling UserApi.set_user_sys_admin, the character length must be great than or equal to 1.'
  end

  # resource path
  local_var_path = '/users/{user_id}/sysadmin'.sub('{' + 'user_id' + '}', user_id.to_s)

  # query parameters
  query_params = {}

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

  # form parameters
  form_params = {}

  # http body (model)
  post_body = @api_client.object_to_http_body(sysadmin_flag)
  auth_names = ['basic']
  data, status_code, headers = @api_client.call_api(:PUT, local_var_path,
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: UserApi#set_user_sys_admin\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#update_user_password(user_id, password, opts = {}) ⇒ nil

Change the password on a user that already exists. This endpoint is for user to update password. Users with the admin role can change any user’s password. Regular users can change only their own password.

Parameters:

  • user_id
  • password

    Password to be updated, the attribute &#39;old_password&#39; is optional when the API is called by the system administrator.

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

    the optional parameters

Options Hash (opts):

  • :x_request_id (String)

    An unique ID for the request

Returns:

  • (nil)


591
592
593
594
# File 'lib/harbor2_client/api/user_api.rb', line 591

def update_user_password(user_id, password, opts = {})
  update_user_password_with_http_info(user_id, password, opts)
  nil
end

#update_user_password_with_http_info(user_id, password, opts = {}) ⇒ Array<(nil, Fixnum, Hash)>

Change the password on a user that already exists. This endpoint is for user to update password. Users with the admin role can change any user&#39;s password. Regular users can change only their own password.

Parameters:

  • user_id
  • password

    Password to be updated, the attribute &#39;old_password&#39; is optional when the API is called by the system administrator.

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

    the optional parameters

Options Hash (opts):

  • :x_request_id (String)

    An unique ID for the request

Returns:

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

    nil, response status code and response headers



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/harbor2_client/api/user_api.rb', line 603

def update_user_password_with_http_info(user_id, password, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: UserApi.update_user_password ...'
  end
  # 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_password"
  end
  # verify the required parameter 'password' is set
  if @api_client.config.client_side_validation && password.nil?
    fail ArgumentError, "Missing the required parameter 'password' when calling UserApi.update_user_password"
  end
  if @api_client.config.client_side_validation && !opts[:'x_request_id'].nil? && opts[:'x_request_id'].to_s.length < 1
    fail ArgumentError, 'invalid value for "opts[:"x_request_id"]" when calling UserApi.update_user_password, the character length must be great than or equal to 1.'
  end

  # resource path
  local_var_path = '/users/{user_id}/password'.sub('{' + 'user_id' + '}', user_id.to_s)

  # query parameters
  query_params = {}

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

  # form parameters
  form_params = {}

  # http body (model)
  post_body = @api_client.object_to_http_body(password)
  auth_names = ['basic']
  data, status_code, headers = @api_client.call_api(:PUT, local_var_path,
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names)
  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_profile(user_id, profile, opts = {}) ⇒ nil

Update user’s profile.

Parameters:

  • user_id

    Registered user ID

  • profile

    Only email, realname and comment can be modified.

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

    the optional parameters

Options Hash (opts):

  • :x_request_id (String)

    An unique ID for the request

Returns:

  • (nil)


656
657
658
659
# File 'lib/harbor2_client/api/user_api.rb', line 656

def (user_id, profile, opts = {})
  (user_id, profile, opts)
  nil
end

#update_user_profile_with_http_info(user_id, profile, opts = {}) ⇒ Array<(nil, Fixnum, Hash)>

Update user&#39;s profile.

Parameters:

  • user_id

    Registered user ID

  • profile

    Only email, realname and comment can be modified.

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

    the optional parameters

Options Hash (opts):

  • :x_request_id (String)

    An unique ID for the request

Returns:

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

    nil, response status code and response headers



667
668
669
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
# File 'lib/harbor2_client/api/user_api.rb', line 667

def (user_id, profile, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: UserApi.update_user_profile ...'
  end
  # 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_profile"
  end
  # verify the required parameter 'profile' is set
  if @api_client.config.client_side_validation && profile.nil?
    fail ArgumentError, "Missing the required parameter 'profile' when calling UserApi.update_user_profile"
  end
  if @api_client.config.client_side_validation && !opts[:'x_request_id'].nil? && opts[:'x_request_id'].to_s.length < 1
    fail ArgumentError, 'invalid value for "opts[:"x_request_id"]" when calling UserApi.update_user_profile, the character length must be great than or equal to 1.'
  end

  # resource path
  local_var_path = '/users/{user_id}'.sub('{' + 'user_id' + '}', user_id.to_s)

  # query parameters
  query_params = {}

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

  # form parameters
  form_params = {}

  # http body (model)
  post_body = @api_client.object_to_http_body(profile)
  auth_names = ['basic']
  data, status_code, headers = @api_client.call_api(:PUT, local_var_path,
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: UserApi#update_user_profile\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end