Sha256: 842e24d239228289b1a594577d16b01d3862b5b5ef1eaea29927b345e66aa986

Contents?: true

Size: 1.68 KB

Versions: 2

Compression:

Stored size: 1.68 KB

Contents

module ForemanPuppet
  module Api
    module V2
      class ConfigGroupsController < BaseController
        include ForemanPuppet::Parameters::ConfigGroup

        wrap_parameters ConfigGroup, include: config_group_params_filter.accessible_attributes(parameter_filter_context)

        before_action :find_resource, only: %i[show update destroy]

        api :GET, '/config_groups', N_('List of config groups')
        param_group :search_and_pagination, ::Api::V2::BaseController
        add_scoped_search_description_for(ConfigGroup)

        def index
          @config_groups = resource_scope_for_index
        end

        api :GET, '/config_groups/:id/', N_('Show a config group')
        param :id, :identifier, required: true

        def show
        end

        def_param_group :config_group do
          param :config_group, Hash, required: true, action_aware: true do
            param :name, String, required: true
            param :puppetclass_ids, Array
          end
        end

        api :POST, '/config_groups/', N_('Create a config group')
        param_group :config_group, as: :create

        def create
          @config_group = ConfigGroup.new(config_group_params)
          process_response @config_group.save
        end

        api :PUT, '/config_groups/:id/', N_('Update a config group')
        param :id, String, required: true
        param_group :config_group

        def update
          process_response @config_group.update(config_group_params)
        end

        api :DELETE, '/config_groups/:id/', N_('Delete a config group')
        param :id, String, required: true

        def destroy
          process_response @config_group.destroy
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
foreman_puppet-0.0.2 app/controllers/foreman_puppet/api/v2/config_groups_controller.rb
foreman_puppet-0.0.1 app/controllers/foreman_puppet/api/v2/config_groups_controller.rb