Class: Clusters::AgentTokens::CreateService
- Inherits:
-
BaseContainerService
- Object
- BaseContainerService
- Clusters::AgentTokens::CreateService
- Defined in:
- app/services/clusters/agent_tokens/create_service.rb
Constant Summary collapse
- ALLOWED_PARAMS =
%i[agent_id description name].freeze
Instance Attribute Summary
Attributes inherited from BaseContainerService
#container, #current_user, #params
Instance Method Summary collapse
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
Constructor Details
This class inherits a constructor from BaseContainerService
Instance Method Details
#execute ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'app/services/clusters/agent_tokens/create_service.rb', line 8 def execute return unless current_user.can?(:create_cluster, container) token = ::Clusters::AgentToken.new(filtered_params.merge(created_by_user: current_user)) if token.save log_activity_event!(token) ServiceResponse.success(payload: { secret: token.token, token: token }) else ServiceResponse.error(message: token.errors.) end end |