Class: Harbor2Client::LabelApi

Inherits:
Object
  • Object
show all
Defined in:
lib/harbor2_client/api/label_api.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_client = ApiClient.default) ⇒ LabelApi

Returns a new instance of LabelApi.



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

def api_client
  @api_client
end

Instance Method Details

#create_label(label, opts = {}) ⇒ nil

Post creates a label This endpoint let user creates a label.

Parameters:

  • label

    The json object of label.

  • 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/label_api.rb', line 28

def create_label(label, opts = {})
  create_label_with_http_info(label, opts)
  nil
end

#create_label_with_http_info(label, opts = {}) ⇒ Array<(nil, Fixnum, Hash)>

Post creates a label This endpoint let user creates a label.

Parameters:

  • label

    The json object of label.

  • 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/label_api.rb', line 39

def create_label_with_http_info(label, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: LabelApi.create_label ...'
  end
  # verify the required parameter 'label' is set
  if @api_client.config.client_side_validation && label.nil?
    fail ArgumentError, "Missing the required parameter 'label' when calling LabelApi.create_label"
  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 LabelApi.create_label, the character length must be great than or equal to 1.'
  end

  # resource path
  local_var_path = '/labels'

  # 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(label)
  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: LabelApi#create_label\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#delete_label(label_id, opts = {}) ⇒ nil

Delete the label specified by ID. Delete the label specified by ID.

Parameters:

  • label_id

    Label ID

  • 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/label_api.rb', line 88

def delete_label(label_id, opts = {})
  delete_label_with_http_info(label_id, opts)
  nil
end

#delete_label_with_http_info(label_id, opts = {}) ⇒ Array<(nil, Fixnum, Hash)>

Delete the label specified by ID. Delete the label specified by ID.

Parameters:

  • label_id

    Label ID

  • 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/label_api.rb', line 99

def delete_label_with_http_info(label_id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: LabelApi.delete_label ...'
  end
  # verify the required parameter 'label_id' is set
  if @api_client.config.client_side_validation && label_id.nil?
    fail ArgumentError, "Missing the required parameter 'label_id' when calling LabelApi.delete_label"
  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 LabelApi.delete_label, the character length must be great than or equal to 1.'
  end

  # resource path
  local_var_path = '/labels/{label_id}'.sub('{' + 'label_id' + '}', label_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: LabelApi#delete_label\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#get_label_by_id(label_id, opts = {}) ⇒ Label

Get the label specified by ID. This endpoint let user get the label by specific ID.

Parameters:

  • label_id

    Label ID

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

    the optional parameters

Options Hash (opts):

  • :x_request_id (String)

    An unique ID for the request

Returns:



148
149
150
151
# File 'lib/harbor2_client/api/label_api.rb', line 148

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

#get_label_by_id_with_http_info(label_id, opts = {}) ⇒ Array<(Label, Fixnum, Hash)>

Get the label specified by ID. This endpoint let user get the label by specific ID.

Parameters:

  • label_id

    Label ID

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

    the optional parameters

Options Hash (opts):

  • :x_request_id (String)

    An unique ID for the request

Returns:

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

    Label data, response status code and response headers



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
195
196
197
198
199
200
201
202
# File 'lib/harbor2_client/api/label_api.rb', line 159

def get_label_by_id_with_http_info(label_id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: LabelApi.get_label_by_id ...'
  end
  # verify the required parameter 'label_id' is set
  if @api_client.config.client_side_validation && label_id.nil?
    fail ArgumentError, "Missing the required parameter 'label_id' when calling LabelApi.get_label_by_id"
  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 LabelApi.get_label_by_id, the character length must be great than or equal to 1.'
  end

  # resource path
  local_var_path = '/labels/{label_id}'.sub('{' + 'label_id' + '}', label_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 => 'Label')
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: LabelApi#get_label_by_id\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#list_labels(opts = {}) ⇒ Array<Label>

List labels according to the query strings. This endpoint let user list labels by name, scope and project_id

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)

  • :name (String)

    The label name.

  • :scope (String)

    The label scope. Valid values are g and p. g for global labels and p for project labels.

  • :project_id (Integer)

    Relevant project ID, required when scope is p.

Returns:



215
216
217
218
# File 'lib/harbor2_client/api/label_api.rb', line 215

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

#list_labels_with_http_info(opts = {}) ⇒ Array<(Array<Label>, Fixnum, Hash)>

List labels according to the query strings. This endpoint let user list labels by name, scope and project_id

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

  • :name (String)

    The label name.

  • :scope (String)

    The label scope. Valid values are g and p. g for global labels and p for project labels.

  • :project_id (Integer)

    Relevant project ID, required when scope is p.

Returns:

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

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



232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
# File 'lib/harbor2_client/api/label_api.rb', line 232

def list_labels_with_http_info(opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: LabelApi.list_labels ...'
  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 LabelApi.list_labels, 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 LabelApi.list_labels, must be smaller than or equal to 100.'
  end

  # resource path
  local_var_path = '/labels'

  # 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?
  query_params[:'name'] = opts[:'name'] if !opts[:'name'].nil?
  query_params[:'scope'] = opts[:'scope'] if !opts[:'scope'].nil?
  query_params[:'project_id'] = opts[:'project_id'] if !opts[:'project_id'].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<Label>')
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: LabelApi#list_labels\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#update_label(label_id, label, opts = {}) ⇒ nil

Update the label properties. This endpoint let user update label properties.

Parameters:

  • label_id

    Label ID

  • label

    The updated label json object.

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

    the optional parameters

Options Hash (opts):

  • :x_request_id (String)

    An unique ID for the request

Returns:

  • (nil)


290
291
292
293
# File 'lib/harbor2_client/api/label_api.rb', line 290

def update_label(label_id, label, opts = {})
  update_label_with_http_info(label_id, label, opts)
  nil
end

#update_label_with_http_info(label_id, label, opts = {}) ⇒ Array<(nil, Fixnum, Hash)>

Update the label properties. This endpoint let user update label properties.

Parameters:

  • label_id

    Label ID

  • label

    The updated label json object.

  • 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



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

def update_label_with_http_info(label_id, label, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: LabelApi.update_label ...'
  end
  # verify the required parameter 'label_id' is set
  if @api_client.config.client_side_validation && label_id.nil?
    fail ArgumentError, "Missing the required parameter 'label_id' when calling LabelApi.update_label"
  end
  # verify the required parameter 'label' is set
  if @api_client.config.client_side_validation && label.nil?
    fail ArgumentError, "Missing the required parameter 'label' when calling LabelApi.update_label"
  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 LabelApi.update_label, the character length must be great than or equal to 1.'
  end

  # resource path
  local_var_path = '/labels/{label_id}'.sub('{' + 'label_id' + '}', label_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(label)
  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: LabelApi#update_label\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end