Class: Services::ServiceDefinitionsController

Inherits:
ServiceDefinitionBaseController show all
Defined in:
app/controllers/services/service_definitions_controller.rb

Constant Summary

Constants inherited from ApplicationController

ApplicationController::MAX_LIST_LENGTH

Instance Attribute Summary

Attributes inherited from ServiceDefinitionBaseController

#parent, #service_definition

Instance Method Summary collapse

Instance Method Details

#createObject



18
19
20
21
22
23
24
25
# File 'app/controllers/services/service_definitions_controller.rb', line 18

def create
  svc_def = CreateServiceDefinitionContext.call(parent, safe_sd_params, safe_cred_params)
  if svc_def.errors.empty?
    render json: { id: svc_def.id }
  else
    render json: { validation_error: svc_def.errors.full_messages }, status: 403
  end
end

#destroyObject



36
37
38
39
# File 'app/controllers/services/service_definitions_controller.rb', line 36

def destroy
  service_definition.destroy
  render json: { id: service_definition.id }
end

#indexObject



10
11
12
# File 'app/controllers/services/service_definitions_controller.rb', line 10

def index
  @service_definitions = parent.service_definitions.includes(:credentials).limit(MAX_LIST_LENGTH)
end

#showObject



14
15
16
# File 'app/controllers/services/service_definitions_controller.rb', line 14

def show
  # Nothing necessary
end

#updateObject



27
28
29
30
31
32
33
34
# File 'app/controllers/services/service_definitions_controller.rb', line 27

def update
  UpdateServiceDefinitionContext.call(service_definition, safe_sd_params, safe_cred_params)
  if service_definition.errors.empty?
    render json: { id: service_definition.id }
  else
    render json: { validation_error: service_definition.errors.full_messages }, status: 403
  end
end