Class: Namespaces::PackageSettings::UpdateService

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

Constant Summary collapse

ALLOWED_ATTRIBUTES =
%i[maven_duplicates_allowed
maven_duplicate_exception_regex
generic_duplicates_allowed
generic_duplicate_exception_regex].freeze

Instance Attribute Summary

Attributes inherited from BaseContainerService

#container, #current_user, #params

Instance Method Summary collapse

Methods included from Gitlab::Utils::StrongMemoize

#clear_memoization, #strong_memoize, #strong_memoized?

Methods inherited from BaseContainerService

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

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


13
14
15
16
17
18
19
20
21
22
23
24
# File 'app/services/namespaces/package_settings/update_service.rb', line 13

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

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