Class: Api::V2::SccProductsController
- Inherits:
-
BaseController
- Object
- BaseController
- Api::V2::SccProductsController
- Includes:
- Api::Version2, Foreman::Controller::AutoCompleteSearch
- Defined in:
- app/controllers/api/v2/scc_products_controller.rb
Instance Method Summary collapse
Instance Method Details
#index ⇒ Object
31 32 33 34 35 |
# File 'app/controllers/api/v2/scc_products_controller.rb', line 31 def index scope = resource_scope_for_index scope = scope.where.not(:product_id => nil) if ::Foreman::Cast.to_bool(params[:subscribed_only]) @scc_products = scope end |
#metadata_subtotal ⇒ Object
17 18 19 20 21 22 23 |
# File 'app/controllers/api/v2/scc_products_controller.rb', line 17 def if @scc_products.present? @scc_products.count else super end end |
#show ⇒ Object
40 41 |
# File 'app/controllers/api/v2/scc_products_controller.rb', line 40 def show end |
#subscribe ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'app/controllers/api/v2/scc_products_controller.rb', line 46 def subscribe subcribe_task = ForemanTasks.async_task(::Actions::SccManager::SubscribeProduct, @scc_product, {}) if @scc_product respond_to do |format| if subcribe_task format.json { render json: subcribe_task.to_json, status: :ok } else format.json { render json: 'Failed to subscribe product'.to_json, status: :not_found } end end rescue ::Foreman::Exception => e render json: { error: ('Failed to add task to queue: %s' % e).to_s }, status: :unprocessable_entity rescue ForemanTasks::Lock::LockConflict => e render json: { error: ('Lock on SCC account already taken: %s' % e).to_s }, status: :unprocessable_entity end |