2022-10-11 01:57:18 +05:30
|
|
|
# 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.'
|
|
|
|
|
2023-01-13 00:05:48 +05:30
|
|
|
def find_object(id:)
|
2022-10-11 01:57:18 +05:30
|
|
|
GlobalID::Locator.locate(id)
|
|
|
|
end
|
|
|
|
|
|
|
|
def resolve(id:)
|
|
|
|
job = authorized_find!(id: id)
|
|
|
|
|
2022-11-25 23:54:43 +05:30
|
|
|
result = ::Ci::JobArtifacts::DeleteService.new(job).execute
|
|
|
|
|
|
|
|
if result.success?
|
|
|
|
{
|
|
|
|
job: job,
|
|
|
|
destroyed_artifacts_count: result.payload[:destroyed_artifacts_count],
|
|
|
|
errors: Array(result.payload[:errors])
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
job: job,
|
|
|
|
destroyed_artifacts_count: 0,
|
|
|
|
errors: Array(result.message)
|
|
|
|
}
|
|
|
|
end
|
2022-10-11 01:57:18 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|