Sha256: cae1d485547d11403747df7e552d8fad7136215c379c1f29d495fda5ba59b04a

Contents?: true

Size: 1.71 KB

Versions: 4

Compression:

Stored size: 1.71 KB

Contents

# frozen_string_literal: true

module ForemanAcd
  module Api
    module V2
      # API controller for App Definitions
      class AppDefinitionsController < ::ForemanAcd::Api::V2::BaseController
        include ::ForemanAcd::Concerns::AppDefinitionParameters

        before_action :find_resource, :except => [:index, :create]

        api :GET, '/app_definitions/:id', N_('Show application definition')
        param :id, :identifier, :required => true
        def show; end

        api :GET, '/app_definitions', N_('List application definitions')
        param_group :search_and_pagination, ::Api::V2::BaseController
        add_scoped_search_description_for(AppDefinition)
        def index
          @app_definitions = resource_scope_for_index
        end

        def_param_group :app_definition do
          param :app_definition, Hash, :required => true, :action_aware => true do
            param :name, String, :required => true
            param :description, String, :required => true
            param :services, String, :required => true
          end
        end

        api :POST, '/app_definitions', N_('Create a application definition')
        param_group :app_definition, :as => :create
        def create
          @app_definition = AppDefinition.new(app_definition_params)
          process_response @app_definition.save
        end

        api :DELETE, '/app_definitions/:id', N_('Deletes application definition')
        param :id, :identifier, :required => true
        def destroy
          process_response @app_definition.destroy
        end

        def controller_permission
          'app_definitions'
        end

        def resource_class
          ForemanAcd::AppDefinition
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
foreman_acd-0.5.0 app/controllers/foreman_acd/api/v2/app_definitions_controller.rb
foreman_acd-0.4.0 app/controllers/foreman_acd/api/v2/app_definitions_controller.rb
foreman_acd-0.3.0 app/controllers/foreman_acd/api/v2/app_definitions_controller.rb
foreman_acd-0.2.1 app/controllers/foreman_acd/api/v2/app_definitions_controller.rb