Class: Packages::Cleanup::UpdatePolicyService

Inherits:
BaseProjectService show all
Defined in:
app/services/packages/cleanup/update_policy_service.rb

Constant Summary collapse

ALLOWED_ATTRIBUTES =
%i[keep_n_duplicated_package_files].freeze

Instance Attribute Summary

Attributes inherited from BaseProjectService

#project

Attributes inherited from BaseContainerService

#container, #current_user, #group, #params, #project

Instance Method Summary collapse

Methods inherited from BaseProjectService

#initialize

Methods inherited from BaseContainerService

#group_container?, #initialize, #namespace_container?, #project_container?, #project_group

Methods included from BaseServiceUtility

#deny_visibility_level, #event_service, #log_error, #log_info, #notification_service, #system_hook_service, #todo_service, #visibility_level

Methods included from Gitlab::Allowable

#can?

Constructor Details

This class inherits a constructor from BaseProjectService

Instance Method Details

#executeObject



8
9
10
11
12
13
14
15
16
# File 'app/services/packages/cleanup/update_policy_service.rb', line 8

def execute
  return ServiceResponse.error(message: 'Access denied') unless allowed?

  if policy.update(policy_params)
    ServiceResponse.success(payload: { packages_cleanup_policy: policy })
  else
    ServiceResponse.error(message: policy.errors.full_messages.to_sentence || 'Bad request')
  end
end