Class: Gitlab::Harbor::Client
- Inherits:
-
Object
- Object
- Gitlab::Harbor::Client
- Defined in:
- lib/gitlab/harbor/client.rb
Constant Summary collapse
- Error =
Class.new(StandardError)
- ConfigError =
Class.new(Error)
- RESPONSE_SIZE_LIMIT =
1.megabyte
- RESPONSE_MEMORY_SIZE_LIMIT =
RESPONSE_SIZE_LIMIT * 5
Instance Attribute Summary collapse
-
#integration ⇒ Object
readonly
Returns the value of attribute integration.
Instance Method Summary collapse
- #check_project_availability ⇒ Object
- #get_artifacts(params) ⇒ Object
- #get_repositories(params) ⇒ Object
- #get_tags(params) ⇒ Object
-
#initialize(integration) ⇒ Client
constructor
A new instance of Client.
Constructor Details
#initialize(integration) ⇒ Client
Returns a new instance of Client.
14 15 16 17 18 |
# File 'lib/gitlab/harbor/client.rb', line 14 def initialize(integration) raise ConfigError, 'Please check your integration configuration.' unless integration @integration = integration end |
Instance Attribute Details
#integration ⇒ Object (readonly)
Returns the value of attribute integration.
12 13 14 |
# File 'lib/gitlab/harbor/client.rb', line 12 def integration @integration end |
Instance Method Details
#check_project_availability ⇒ Object
20 21 22 23 24 25 |
# File 'lib/gitlab/harbor/client.rb', line 20 def check_project_availability = { headers: headers.merge!(Accept: 'application/json') } response = Integrations::Clients::HTTP.head(url("projects?project_name=#{integration.project_name}"), ) { success: response.success? } end |
#get_artifacts(params) ⇒ Object
31 32 33 34 |
# File 'lib/gitlab/harbor/client.rb', line 31 def get_artifacts(params) repository_name = params.delete(:repository_name) get(url("projects/#{integration.project_name}/repositories/#{repository_name}/artifacts"), params) end |
#get_repositories(params) ⇒ Object
27 28 29 |
# File 'lib/gitlab/harbor/client.rb', line 27 def get_repositories(params) get(url("projects/#{integration.project_name}/repositories"), params) end |
#get_tags(params) ⇒ Object
36 37 38 39 40 41 42 43 |
# File 'lib/gitlab/harbor/client.rb', line 36 def (params) repository_name = params.delete(:repository_name) artifact_name = params.delete(:artifact_name) get( url("projects/#{integration.project_name}/repositories/#{repository_name}/artifacts/#{artifact_name}/tags"), params ) end |