Class: Harbor2Client::ImmutableApi

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_client = ApiClient.default) ⇒ ImmutableApi

Returns a new instance of ImmutableApi.



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

def api_client
  @api_client
end

Instance Method Details

#create_immu_rule(project_name_or_id, immutable_rule, opts = {}) ⇒ nil

Add an immutable tag rule to current project This endpoint add an immutable tag rule to the project

Parameters:

  • project_name_or_id

    The name or id of the project

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

    the optional parameters

Options Hash (opts):

  • :x_request_id (String)

    An unique ID for the request

  • :x_is_resource_name (BOOLEAN)

    The flag to indicate whether the parameter which supports both name and id in the path is the name of the resource. When the X-Is-Resource-Name is false and the parameter can be converted to an integer, the parameter will be as an id, otherwise, it will be as a name. (default to false)

Returns:

  • (nil)


30
31
32
33
# File 'lib/harbor2_client/api/immutable_api.rb', line 30

def create_immu_rule(project_name_or_id, immutable_rule, opts = {})
  create_immu_rule_with_http_info(project_name_or_id, immutable_rule, opts)
  nil
end

#create_immu_rule_with_http_info(project_name_or_id, immutable_rule, opts = {}) ⇒ Array<(nil, Fixnum, Hash)>

Add an immutable tag rule to current project This endpoint add an immutable tag rule to the project

Parameters:

  • project_name_or_id

    The name or id of the project

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

    the optional parameters

Options Hash (opts):

  • :x_request_id (String)

    An unique ID for the request

  • :x_is_resource_name (BOOLEAN)

    The flag to indicate whether the parameter which supports both name and id in the path is the name of the resource. When the X-Is-Resource-Name is false and the parameter can be converted to an integer, the parameter will be as an id, otherwise, it will be as a name.

Returns:

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

    nil, response status code and response headers



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

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

  # resource path
  local_var_path = '/projects/{project_name_or_id}/immutabletagrules'.sub('{' + 'project_name_or_id' + '}', project_name_or_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?
  header_params[:'X-Is-Resource-Name'] = opts[:'x_is_resource_name'] if !opts[:'x_is_resource_name'].nil?

  # form parameters
  form_params = {}

  # http body (model)
  post_body = @api_client.object_to_http_body(immutable_rule)
  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: ImmutableApi#create_immu_rule\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#delete_immu_rule(project_name_or_id, immutable_rule_id, opts = {}) ⇒ nil

Delete the immutable tag rule.

Parameters:

  • project_name_or_id

    The name or id of the project

  • immutable_rule_id

    The ID of the immutable rule

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

    the optional parameters

Options Hash (opts):

  • :x_request_id (String)

    An unique ID for the request

  • :x_is_resource_name (BOOLEAN)

    The flag to indicate whether the parameter which supports both name and id in the path is the name of the resource. When the X-Is-Resource-Name is false and the parameter can be converted to an integer, the parameter will be as an id, otherwise, it will be as a name. (default to false)

Returns:

  • (nil)


98
99
100
101
# File 'lib/harbor2_client/api/immutable_api.rb', line 98

def delete_immu_rule(project_name_or_id, immutable_rule_id, opts = {})
  delete_immu_rule_with_http_info(project_name_or_id, immutable_rule_id, opts)
  nil
end

#delete_immu_rule_with_http_info(project_name_or_id, immutable_rule_id, opts = {}) ⇒ Array<(nil, Fixnum, Hash)>

Delete the immutable tag rule.

Parameters:

  • project_name_or_id

    The name or id of the project

  • immutable_rule_id

    The ID of the immutable rule

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

    the optional parameters

Options Hash (opts):

  • :x_request_id (String)

    An unique ID for the request

  • :x_is_resource_name (BOOLEAN)

    The flag to indicate whether the parameter which supports both name and id in the path is the name of the resource. When the X-Is-Resource-Name is false and the parameter can be converted to an integer, the parameter will be as an id, otherwise, it will be as a name.

Returns:

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

    nil, response status code and response headers



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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
# File 'lib/harbor2_client/api/immutable_api.rb', line 110

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

  # resource path
  local_var_path = '/projects/{project_name_or_id}/immutabletagrules/{immutable_rule_id}'.sub('{' + 'project_name_or_id' + '}', project_name_or_id.to_s).sub('{' + 'immutable_rule_id' + '}', immutable_rule_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?
  header_params[:'X-Is-Resource-Name'] = opts[:'x_is_resource_name'] if !opts[:'x_is_resource_name'].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: ImmutableApi#delete_immu_rule\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#list_immu_rules(project_name_or_id, opts = {}) ⇒ Array<ImmutableRule>

List all immutable tag rules of current project This endpoint returns the immutable tag rules of a project

Parameters:

  • project_name_or_id

    The name or id of the project

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

    the optional parameters

Options Hash (opts):

  • :x_request_id (String)

    An unique ID for the request

  • :x_is_resource_name (BOOLEAN)

    The flag to indicate whether the parameter which supports both name and id in the path is the name of the resource. When the X-Is-Resource-Name is false and the parameter can be converted to an integer, the parameter will be as an id, otherwise, it will be as a name. (default to false)

  • :page (Integer)

    The page number (default to 1)

  • :page_size (Integer)

    The size of per page (default to 10)

  • :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;

Returns:



169
170
171
172
# File 'lib/harbor2_client/api/immutable_api.rb', line 169

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

#list_immu_rules_with_http_info(project_name_or_id, opts = {}) ⇒ Array<(Array<ImmutableRule>, Fixnum, Hash)>

List all immutable tag rules of current project This endpoint returns the immutable tag rules of a project

Parameters:

  • project_name_or_id

    The name or id of the project

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

    the optional parameters

Options Hash (opts):

  • :x_request_id (String)

    An unique ID for the request

  • :x_is_resource_name (BOOLEAN)

    The flag to indicate whether the parameter which supports both name and id in the path is the name of the resource. When the X-Is-Resource-Name is false and the parameter can be converted to an integer, the parameter will be as an id, otherwise, it will be as a name.

  • :page (Integer)

    The page number

  • :page_size (Integer)

    The size of per page

  • :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;

Returns:

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

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



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
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
# File 'lib/harbor2_client/api/immutable_api.rb', line 185

def list_immu_rules_with_http_info(project_name_or_id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: ImmutableApi.list_immu_rules ...'
  end
  # verify the required parameter 'project_name_or_id' is set
  if @api_client.config.client_side_validation && project_name_or_id.nil?
    fail ArgumentError, "Missing the required parameter 'project_name_or_id' when calling ImmutableApi.list_immu_rules"
  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 ImmutableApi.list_immu_rules, 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 ImmutableApi.list_immu_rules, must be smaller than or equal to 100.'
  end

  # resource path
  local_var_path = '/projects/{project_name_or_id}/immutabletagrules'.sub('{' + 'project_name_or_id' + '}', project_name_or_id.to_s)

  # query parameters
  query_params = {}
  query_params[:'page'] = opts[:'page'] if !opts[:'page'].nil?
  query_params[:'page_size'] = opts[:'page_size'] if !opts[:'page_size'].nil?
  query_params[:'q'] = opts[:'q'] if !opts[:'q'].nil?
  query_params[:'sort'] = opts[:'sort'] if !opts[:'sort'].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?
  header_params[:'X-Is-Resource-Name'] = opts[:'x_is_resource_name'] if !opts[:'x_is_resource_name'].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<ImmutableRule>')
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: ImmutableApi#list_immu_rules\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#update_immu_rule(project_name_or_id, immutable_rule_id, immutable_rule, opts = {}) ⇒ nil

Update the immutable tag rule or enable or disable the rule

Parameters:

  • project_name_or_id

    The name or id of the project

  • immutable_rule_id

    The ID of the immutable rule

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

    the optional parameters

Options Hash (opts):

  • :x_request_id (String)

    An unique ID for the request

  • :x_is_resource_name (BOOLEAN)

    The flag to indicate whether the parameter which supports both name and id in the path is the name of the resource. When the X-Is-Resource-Name is false and the parameter can be converted to an integer, the parameter will be as an id, otherwise, it will be as a name. (default to false)

Returns:

  • (nil)


246
247
248
249
# File 'lib/harbor2_client/api/immutable_api.rb', line 246

def update_immu_rule(project_name_or_id, immutable_rule_id, immutable_rule, opts = {})
  update_immu_rule_with_http_info(project_name_or_id, immutable_rule_id, immutable_rule, opts)
  nil
end

#update_immu_rule_with_http_info(project_name_or_id, immutable_rule_id, immutable_rule, opts = {}) ⇒ Array<(nil, Fixnum, Hash)>

Update the immutable tag rule or enable or disable the rule

Parameters:

  • project_name_or_id

    The name or id of the project

  • immutable_rule_id

    The ID of the immutable rule

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

    the optional parameters

Options Hash (opts):

  • :x_request_id (String)

    An unique ID for the request

  • :x_is_resource_name (BOOLEAN)

    The flag to indicate whether the parameter which supports both name and id in the path is the name of the resource. When the X-Is-Resource-Name is false and the parameter can be converted to an integer, the parameter will be as an id, otherwise, it will be as a name.

Returns:

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

    nil, response status code and response headers



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

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

  # resource path
  local_var_path = '/projects/{project_name_or_id}/immutabletagrules/{immutable_rule_id}'.sub('{' + 'project_name_or_id' + '}', project_name_or_id.to_s).sub('{' + 'immutable_rule_id' + '}', immutable_rule_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?
  header_params[:'X-Is-Resource-Name'] = opts[:'x_is_resource_name'] if !opts[:'x_is_resource_name'].nil?

  # form parameters
  form_params = {}

  # http body (model)
  post_body = @api_client.object_to_http_body(immutable_rule)
  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: ImmutableApi#update_immu_rule\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end