Sha256: f6466b2c7f6e82c8137d5e547c1fe46ebcf487b0746dc752d29d5849be715f0a

Contents?: true

Size: 1.64 KB

Versions: 201

Compression:

Stored size: 1.64 KB

Contents

module Katello
  class Api::V2::SyncController < Api::V2::ApiController
    before_action :find_optional_organization, :only => [:index]
    before_action :find_object, :only => [:index]
    before_action :ensure_library, :only => [:index]

    api :GET, "/organizations/:organization_id/products/:product_id/sync", N_("Get status of repo synchronisation for given product")
    api :GET, "/repositories/:repository_id/sync", N_("Get status of synchronisation for given repository")
    def index
      respond_for_async(:resource => @obj.sync_status)
    end

    private

    # used in unit tests
    def find_object
      if params.key?(:product_id)
        @obj = find_product
      elsif params.key?(:repository_id)
        @obj = find_repository
      else
        fail HttpErrors::NotFound, N_("Couldn't find subject of synchronization") if @obj.nil?
      end
      @obj
    end

    def find_product
      fail _("Organization required") if @organization.nil?
      @product = Product.syncable.find_by_cp_id(params[:product_id], @organization)
      fail HttpErrors::NotFound, _("Couldn't find product with id '%s'") % params[:product_id] if @product.nil?
      @product
    end

    def find_repository
      @repository = Repository.syncable.find_by(:id => params[:repository_id])
      fail HttpErrors::NotFound, _("Couldn't find repository '%s'") % params[:repository_id] if @repository.nil?
      @repository
    end

    def ensure_library
      unless @repository.nil?
        fail HttpErrors::NotFound, _("You can check sync status for repositories only in the library lifecycle environment.'") unless @repository.environment.library?
      end
    end
  end
end

Version data entries

201 entries across 201 versions & 1 rubygems

Version Path
katello-4.9.2 app/controllers/katello/api/v2/sync_controller.rb
katello-4.8.4 app/controllers/katello/api/v2/sync_controller.rb
katello-4.9.1 app/controllers/katello/api/v2/sync_controller.rb
katello-4.8.3 app/controllers/katello/api/v2/sync_controller.rb
katello-4.9.0 app/controllers/katello/api/v2/sync_controller.rb
katello-4.7.6 app/controllers/katello/api/v2/sync_controller.rb
katello-4.8.2 app/controllers/katello/api/v2/sync_controller.rb
katello-4.9.0.rc2 app/controllers/katello/api/v2/sync_controller.rb
katello-4.9.0.rc1 app/controllers/katello/api/v2/sync_controller.rb
katello-4.8.1 app/controllers/katello/api/v2/sync_controller.rb
katello-4.7.5 app/controllers/katello/api/v2/sync_controller.rb
katello-4.8.0 app/controllers/katello/api/v2/sync_controller.rb
katello-4.8.0.rc2 app/controllers/katello/api/v2/sync_controller.rb
katello-4.7.4 app/controllers/katello/api/v2/sync_controller.rb
katello-4.8.0.rc1 app/controllers/katello/api/v2/sync_controller.rb
katello-4.7.3 app/controllers/katello/api/v2/sync_controller.rb
katello-4.7.2 app/controllers/katello/api/v2/sync_controller.rb
katello-4.7.1 app/controllers/katello/api/v2/sync_controller.rb
katello-4.6.2.1 app/controllers/katello/api/v2/sync_controller.rb
katello-4.6.2 app/controllers/katello/api/v2/sync_controller.rb