diff options
Diffstat (limited to 'app/controllers/concerns/harbor/artifact.rb')
-rw-r--r-- | app/controllers/concerns/harbor/artifact.rb | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/app/controllers/concerns/harbor/artifact.rb b/app/controllers/concerns/harbor/artifact.rb new file mode 100644 index 00000000000..c9d7d26fbb9 --- /dev/null +++ b/app/controllers/concerns/harbor/artifact.rb @@ -0,0 +1,41 @@ +# frozen_string_literal: true + +module Harbor + module Artifact + def index + respond_to do |format| + format.json do + artifacts + end + end + end + + private + + def query_params + params.permit(:repository_id, :search, :sort, :page, :limit) + end + + def query + Gitlab::Harbor::Query.new(container.harbor_integration, query_params) + end + + def artifacts + unless query.valid? + return render( + json: { message: 'Invalid parameters', errors: query.errors }, + status: :unprocessable_entity + ) + end + + artifacts_json = ::Integrations::HarborSerializers::ArtifactSerializer.new + .with_pagination(request, response) + .represent(query.artifacts) + render json: artifacts_json + end + + def container + raise NotImplementedError + end + end +end |