Class: ContainerExpirationPolicies::UpdateService

Inherits:
BaseContainerService show all
Includes:
Gitlab::Utils::StrongMemoize
Defined in:
app/services/container_expiration_policies/update_service.rb

Constant Summary collapse

ALLOWED_ATTRIBUTES =
%i[enabled cadence older_than keep_n name_regex name_regex_keep].freeze

Instance Attribute Summary

Attributes inherited from BaseContainerService

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

Instance Method Summary collapse

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 BaseContainerService

Instance Method Details

#executeObject



9
10
11
12
13
14
15
16
17
18
19
20
# File 'app/services/container_expiration_policies/update_service.rb', line 9

def execute
  return ServiceResponse.error(message: 'Access Denied', http_status: 403) unless allowed?

  if container_expiration_policy.update(container_expiration_policy_params)
    ServiceResponse.success(payload: { container_expiration_policy: container_expiration_policy })
  else
    ServiceResponse.error(
      message: container_expiration_policy.errors.full_messages.to_sentence || 'Bad request',
      http_status: 400
    )
  end
end