Sha256: 5ed538fd331c02c8098c54ee525b062d25b75f51968261033c2e6904ae619027

Contents?: true

Size: 1.28 KB

Versions: 3

Compression:

Stored size: 1.28 KB

Contents

module ForemanSalt
  module Api
    module V2
      class SaltStatesController < ::ForemanSalt::Api::V2::BaseController
        before_filter :find_resource, :except => [:index, :create]

        api :GET, '/salt_states', N_('List all Salt states')
        def index
          @salt_states = resource_scope_for_index
        end

        api :GET, '/salt_states/:id/', N_('Show a state')
        param :id, :identifier_dottable, :required => true
        def show
        end

        def_param_group :state do
          param :state, Hash, :required => true, :action_aware => true do
            param :name, String, :required => true, :desc => N_('Name of the Salt state')
          end
        end

        api :POST, '/salt_states', N_('Create a state')
        param_group :state, :as => :create
        def create
          @salt_state = SaltModule.new(params[:state])
          process_response @salt_state.save
        end

        api :DELETE, '/salt_states/:id/', N_('Destroy a state')
        param :id, :identifier_dottable, :required => true
        def destroy
          process_response @salt_state.destroy
        end

        def controller_permission
          'salt_modules'
        end

        def resource_class
          ForemanSalt::SaltModule
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
foreman_salt-2.0.2 app/controllers/foreman_salt/api/v2/salt_states_controller.rb
foreman_salt-2.0.1 app/controllers/foreman_salt/api/v2/salt_states_controller.rb
foreman_salt-2.0.0 app/controllers/foreman_salt/api/v2/salt_states_controller.rb