Class: Mutations::Ci::Job::ArtifactsDestroy

Inherits:
Base
  • Object
show all
Defined in:
app/graphql/mutations/ci/job/artifacts_destroy.rb

Constant Summary

Constants inherited from Base

Base::JobID

Constants inherited from BaseMutation

BaseMutation::ERROR_MESSAGE

Constants included from Gitlab::Graphql::Authorize::AuthorizeResource

Gitlab::Graphql::Authorize::AuthorizeResource::ConfigurationError, Gitlab::Graphql::Authorize::AuthorizeResource::RESOURCE_ACCESS_ERROR

Instance Method Summary collapse

Methods inherited from BaseMutation

#api_user?, authorization, authorized?, authorizes_object?, #current_user, #errors_on_object, #load_application_object, #read_only?, #ready?, #unauthorized_object

Methods included from Gitlab::Graphql::Authorize::AuthorizeResource

#authorize!, #authorized_find!, #authorized_resource?, #raise_resource_not_available_error!

Instance Method Details

#find_object(id:) ⇒ Object



21
22
23
# File 'app/graphql/mutations/ci/job/artifacts_destroy.rb', line 21

def find_object(id:)
  GlobalID::Locator.locate(id)
end

#resolve(id:) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'app/graphql/mutations/ci/job/artifacts_destroy.rb', line 25

def resolve(id:)
  job = authorized_find!(id: id)

  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
end