Sha256: 0fe42204c8d46563251b7de00ee22b28f2fd9cc48a5b6b6f6bf5a78814c5acd4

Contents?: true

Size: 1.56 KB

Versions: 15

Compression:

Stored size: 1.56 KB

Contents

module Api
  module V2
    # API controller for Ansible Roles
    class AnsibleRolesController < ::Api::V2::BaseController
      include ::Api::Version2

      before_action :find_resource, :only => [:show, :destroy]
      before_action :find_proxy, :only => [:import, :obsolete]
      before_action :create_importer, :only => [:import, :obsolete]

      api :GET, '/ansible/ansible_roles/:id', N_('Show role')
      param :id, :identifier, :required => true
      def show; end

      api :GET, '/ansible/ansible_roles', N_('List Ansible roles')
      param_group :search_and_pagination, ::Api::V2::BaseController
      def index
        @ansible_roles = resource_scope_for_index
      end

      api :DELETE, '/ansible/ansible_roles/:id', N_('Deletes Ansible role')
      param :id, :identifier, :required => true
      def destroy
        process_response @ansible_role.destroy
      end

      api :POST, '/ansible/ansible_roles/import', N_('Import Ansible roles')
      param :proxy, Hash, N_('Smart Proxy to import from')
      def import
        @imported = @importer.import!
      end

      api :POST, '/ansible/ansible_roles/obsolete', N_('Obsolete Ansible roles')
      param :proxy, Hash, N_('Smart Proxy to import from')
      def obsolete
        @obsoleted = @importer.obsolete!
      end

      private

      def find_proxy
        return nil unless params[:proxy]
        @proxy = SmartProxy.authorized(:view_smart_proxies).find(params[:proxy])
      end

      def create_importer
        @importer = ForemanAnsible::ApiRolesImporter.new(@proxy)
      end
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
foreman_ansible-2.0.4 app/controllers/api/v2/ansible_roles_controller.rb
foreman_ansible-2.0.3 app/controllers/api/v2/ansible_roles_controller.rb
foreman_ansible-2.0.2 app/controllers/api/v2/ansible_roles_controller.rb
foreman_ansible-1.5.2 app/controllers/api/v2/ansible_roles_controller.rb
foreman_ansible-1.5.1 app/controllers/api/v2/ansible_roles_controller.rb
foreman_ansible-1.5.0 app/controllers/api/v2/ansible_roles_controller.rb
foreman_ansible-2.1.0 app/controllers/api/v2/ansible_roles_controller.rb
foreman_ansible-2.0.1 app/controllers/api/v2/ansible_roles_controller.rb
foreman_ansible-2.0.0 app/controllers/api/v2/ansible_roles_controller.rb
foreman_ansible-1.4.6 app/controllers/api/v2/ansible_roles_controller.rb
foreman_ansible-1.4.5 app/controllers/api/v2/ansible_roles_controller.rb
foreman_ansible-1.4.3 app/controllers/api/v2/ansible_roles_controller.rb
foreman_ansible-1.4.2 app/controllers/api/v2/ansible_roles_controller.rb
foreman_ansible-1.4.1 app/controllers/api/v2/ansible_roles_controller.rb
foreman_ansible-1.4.0 app/controllers/api/v2/ansible_roles_controller.rb