summaryrefslogtreecommitdiff
path: root/app/graphql/mutations/ci/job/artifacts_destroy.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/graphql/mutations/ci/job/artifacts_destroy.rb')
-rw-r--r--app/graphql/mutations/ci/job/artifacts_destroy.rb38
1 files changed, 38 insertions, 0 deletions
diff --git a/app/graphql/mutations/ci/job/artifacts_destroy.rb b/app/graphql/mutations/ci/job/artifacts_destroy.rb
new file mode 100644
index 00000000000..c27ab9c4d89
--- /dev/null
+++ b/app/graphql/mutations/ci/job/artifacts_destroy.rb
@@ -0,0 +1,38 @@
+# frozen_string_literal: true
+
+module Mutations
+ module Ci
+ module Job
+ class ArtifactsDestroy < Base
+ graphql_name 'JobArtifactsDestroy'
+
+ authorize :destroy_artifacts
+
+ field :job,
+ Types::Ci::JobType,
+ null: true,
+ description: 'Job with artifacts to be deleted.'
+
+ field :destroyed_artifacts_count,
+ GraphQL::Types::Int,
+ null: false,
+ description: 'Number of artifacts deleted.'
+
+ def find_object(id: )
+ GlobalID::Locator.locate(id)
+ end
+
+ def resolve(id:)
+ job = authorized_find!(id: id)
+
+ result = ::Ci::JobArtifacts::DestroyBatchService.new(job.job_artifacts, pick_up_at: Time.current).execute
+ {
+ job: job,
+ destroyed_artifacts_count: result[:destroyed_artifacts_count],
+ errors: Array(result[:errors])
+ }
+ end
+ end
+ end
+ end
+end