Sha256: d727fb91d3fb0e219f22b97385e06db4cab8c1837626fe81ef03fcd12b46a315

Contents?: true

Size: 1.74 KB

Versions: 31

Compression:

Stored size: 1.74 KB

Contents

module Api
  module V2
    class RemoteExecutionFeaturesController < ::Api::V2::BaseController
      include ::Api::Version2
      include ::Foreman::Controller::Parameters::RemoteExecutionFeature

      before_action :find_resource, :only => %w{show update}

      api :GET, '/remote_execution_features/', N_('List remote execution features')
      def index
        @remote_execution_features = resource_scope
      end

      api :GET, '/remote_execution_features/:id', N_('Show remote execution feature')
      param :id, :identifier, :required => true
      def show
      end

      def_param_group :remote_execution_feature do
        param :remote_execution_feature, Hash, :required => true, :action_aware => true do
          param :job_template_id, :identifier, :required => true, :desc => N_('Job template ID to be used for the feature')
        end
      end

      api :PUT, '/remote_execution_features/:id', N_('Update a job template')
      param :id, :identifier, :required => true
      param_group :remote_execution_feature
      def update
        process_response @remote_execution_feature.update(remote_execution_feature_params)
      end

      api :GET, '/api/hosts/:id/available_remote_execution_features', N_('List available remote execution features for a host')
      param :id, :identifier, :required => true
      def available_remote_execution_features
        host = Host.find(params[:id])
        @remote_execution_features = resource_scope
        @permissions = {:can_run_job => (authorized_for(controller: :job_invocations, action: :create) && (!host.infrastructure_host? || User.current.can?(:execute_jobs_on_infrastructure_hosts))) }
      end

      private

      def parent_scope
        resource_class.where(nil)
      end
    end
  end
end

Version data entries

31 entries across 31 versions & 1 rubygems

Version Path
foreman_remote_execution-13.2.7 app/controllers/api/v2/remote_execution_features_controller.rb
foreman_remote_execution-15.0.0 app/controllers/api/v2/remote_execution_features_controller.rb
foreman_remote_execution-14.1.4 app/controllers/api/v2/remote_execution_features_controller.rb
foreman_remote_execution-14.1.3 app/controllers/api/v2/remote_execution_features_controller.rb
foreman_remote_execution-14.1.2 app/controllers/api/v2/remote_execution_features_controller.rb
foreman_remote_execution-14.1.1 app/controllers/api/v2/remote_execution_features_controller.rb
foreman_remote_execution-14.1.0 app/controllers/api/v2/remote_execution_features_controller.rb
foreman_remote_execution-14.0.2 app/controllers/api/v2/remote_execution_features_controller.rb
foreman_remote_execution-14.0.1 app/controllers/api/v2/remote_execution_features_controller.rb
foreman_remote_execution-13.2.6 app/controllers/api/v2/remote_execution_features_controller.rb
foreman_remote_execution-14.0.0 app/controllers/api/v2/remote_execution_features_controller.rb
foreman_remote_execution-13.2.5 app/controllers/api/v2/remote_execution_features_controller.rb
foreman_remote_execution-13.2.4 app/controllers/api/v2/remote_execution_features_controller.rb
foreman_remote_execution-13.2.3 app/controllers/api/v2/remote_execution_features_controller.rb
foreman_remote_execution-13.2.2 app/controllers/api/v2/remote_execution_features_controller.rb
foreman_remote_execution-12.0.7 app/controllers/api/v2/remote_execution_features_controller.rb
foreman_remote_execution-13.2.1 app/controllers/api/v2/remote_execution_features_controller.rb
foreman_remote_execution-13.2.0 app/controllers/api/v2/remote_execution_features_controller.rb
foreman_remote_execution-10.1.3 app/controllers/api/v2/remote_execution_features_controller.rb
foreman_remote_execution-13.0.0 app/controllers/api/v2/remote_execution_features_controller.rb