User:StasFomin/KatelloContacts

From Wiki4Intranet
< User:StasFomin
Revision as of 13:50, 29 December 2015 by StasFomin (Talk | contribs) (Created page with "<pre> 496503e8 app/controllers/katello/api/v2/subscriptions_controller.rb (Eric D. Helms 2013-10-11 21:39:25 -0400 1) module Katello f89b930e app/controllers/katello/api/...")

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
496503e8 app/controllers/katello/api/v2/subscriptions_controller.rb (Eric D. Helms    2013-10-11 21:39:25 -0400   1) module Katello
f89b930e app/controllers/katello/api/v2/subscriptions_controller.rb (Walden Raines    2014-10-09 11:37:27 -0400   2)   class Api::V2::SubscriptionsController < Api::V2::ApiController
6400e13a app/controllers/katello/api/v2/subscriptions_controller.rb (John Mitsch      2015-08-13 15:41:14 -0400   3)     include Katello::Concerns::FilteredAutoCompleteSearch
f89b930e app/controllers/katello/api/v2/subscriptions_controller.rb (Walden Raines    2014-10-09 11:37:27 -0400   4) 
f89b930e app/controllers/katello/api/v2/subscriptions_controller.rb (Walden Raines    2014-10-09 11:37:27 -0400   5)     before_filter :find_activation_key
f89b930e app/controllers/katello/api/v2/subscriptions_controller.rb (Walden Raines    2014-10-09 11:37:27 -0400   6)     before_filter :find_system
f89b930e app/controllers/katello/api/v2/subscriptions_controller.rb (Walden Raines    2014-10-09 11:37:27 -0400   7)     before_filter :find_optional_organization, :only => [:index, :available, :show]
f89b930e app/controllers/katello/api/v2/subscriptions_controller.rb (Walden Raines    2014-10-09 11:37:27 -0400   8)     before_filter :find_organization, :only => [:upload, :delete_manifest,
f89b930e app/controllers/katello/api/v2/subscriptions_controller.rb (Walden Raines    2014-10-09 11:37:27 -0400   9)                                                 :refresh_manifest, :manifest_history]
f89b930e app/controllers/katello/api/v2/subscriptions_controller.rb (Walden Raines    2014-10-09 11:37:27 -0400  10)     before_filter :find_provider
f89b930e app/controllers/katello/api/v2/subscriptions_controller.rb (Walden Raines    2014-10-09 11:37:27 -0400  11) 
3f1de643 app/controllers/katello/api/v2/subscriptions_controller.rb (David Davis      2015-01-13 15:05:33 -0500  12)     skip_before_filter :check_content_type, :only => [:upload]
3f1de643 app/controllers/katello/api/v2/subscriptions_controller.rb (David Davis      2015-01-13 15:05:33 -0500  13) 
f89b930e app/controllers/katello/api/v2/subscriptions_controller.rb (Walden Raines    2014-10-09 11:37:27 -0400  14)     resource_description do
f89b930e app/controllers/katello/api/v2/subscriptions_controller.rb (Walden Raines    2014-10-09 11:37:27 -0400  15)       description "Subscriptions management."
f89b930e app/controllers/katello/api/v2/subscriptions_controller.rb (Walden Raines    2014-10-09 11:37:27 -0400  16)       api_version 'v2'
f89b930e app/controllers/katello/api/v2/subscriptions_controller.rb (Walden Raines    2014-10-09 11:37:27 -0400  17)     end
6c532771 app/controllers/katello/api/v2/subscriptions_controller.rb (David Davis      2013-12-17 13:33:22 -0500  18) 
f89b930e app/controllers/katello/api/v2/subscriptions_controller.rb (Walden Raines    2014-10-09 11:37:27 -0400  19)     api :GET, "/organizations/:organization_id/subscriptions", N_("List organization subscriptions")
6400e13a app/controllers/katello/api/v2/subscriptions_controller.rb (John Mitsch      2015-08-13 15:41:14 -0400  20)     api :GET, "/subscriptions"
6400e13a app/controllers/katello/api/v2/subscriptions_controller.rb (John Mitsch      2015-08-13 15:41:14 -0400  21)     param_group :search, Api::V2::ApiController
f89b930e app/controllers/katello/api/v2/subscriptions_controller.rb (Walden Raines    2014-10-09 11:37:27 -0400  22)     param :organization_id, :number, :desc => N_("Organization ID"), :required => true
6400e13a app/controllers/katello/api/v2/subscriptions_controller.rb (John Mitsch      2015-08-13 15:41:14 -0400  23)     param :system_id, String, :desc => N_("UUID of a content host"), :required => false
f89b930e app/controllers/katello/api/v2/subscriptions_controller.rb (Walden Raines    2014-10-09 11:37:27 -0400  24)     param :activation_key_id, String, :desc => N_("Activation key ID"), :required => false
6400e13a app/controllers/katello/api/v2/subscriptions_controller.rb (John Mitsch      2015-08-13 15:41:14 -0400  25)     param :available_for, String, :desc => N_("Object to show subscriptions available for, either 'content_host' or 'activation_key'"), :required => false
6400e13a app/controllers/katello/api/v2/subscriptions_controller.rb (John Mitsch      2015-08-13 15:41:14 -0400  26)     param :match_system, :bool, :desc => N_("Return subscriptions that match content_host")
6400e13a app/controllers/katello/api/v2/subscriptions_controller.rb (John Mitsch      2015-08-13 15:41:14 -0400  27)     param :match_installed, :bool, :desc => N_("Return subscriptions that match installed products")
6400e13a app/controllers/katello/api/v2/subscriptions_controller.rb (John Mitsch      2015-08-13 15:41:14 -0400  28)     param :no_overlap, :bool, :desc => N_("Return subscriptions which do not overlap with a currently-attached subscription")
f89b930e app/controllers/katello/api/v2/subscriptions_controller.rb (Walden Raines    2014-10-09 11:37:27 -0400  29)     def index
6400e13a app/controllers/katello/api/v2/subscriptions_controller.rb (John Mitsch      2015-08-13 15:41:14 -0400  30)       respond(:collection => scoped_search(index_relation.uniq, :cp_id, :asc, :resource_class => Pool))
6400e13a app/controllers/katello/api/v2/subscriptions_controller.rb (John Mitsch      2015-08-13 15:41:14 -0400  31)     end
f89b930e app/controllers/katello/api/v2/subscriptions_controller.rb (Walden Raines    2014-10-09 11:37:27 -0400  32) 
6400e13a app/controllers/katello/api/v2/subscriptions_controller.rb (John Mitsch      2015-08-13 15:41:14 -0400  33)     def index_relation
6400e13a app/controllers/katello/api/v2/subscriptions_controller.rb (John Mitsch      2015-08-13 15:41:14 -0400  34)       return available_for_system if params[:available_for] == "content_host"
6400e13a app/controllers/katello/api/v2/subscriptions_controller.rb (John Mitsch      2015-08-13 15:41:14 -0400  35)       return available_for_activation_key if params[:available_for] == "activation_key"
6400e13a app/controllers/katello/api/v2/subscriptions_controller.rb (John Mitsch      2015-08-13 15:41:14 -0400  36)       collection = Pool.readable
64ffadb3 app/controllers/katello/api/v2/subscriptions_controller.rb (John Mitsch      2015-10-06 11:19:24 -0400  37)       collection = collection.where(:unmapped_guest => false)
6400e13a app/controllers/katello/api/v2/subscriptions_controller.rb (John Mitsch      2015-08-13 15:41:14 -0400  38)       collection = collection.get_for_organization(Organization.find(params[:organization_id])) if params[:organization_id]
6400e13a app/controllers/katello/api/v2/subscriptions_controller.rb (John Mitsch      2015-08-13 15:41:14 -0400  39)       collection
f89b930e app/controllers/katello/api/v2/subscriptions_controller.rb (Walden Raines    2014-10-09 11:37:27 -0400  40)     end
ead5ce9c app/controllers/api/v2/subscriptions_controller.rb         (Walden Raines    2013-09-12 12:32:53 -0400  41) 
f89b930e app/controllers/katello/api/v2/subscriptions_controller.rb (Walden Raines    2014-10-09 11:37:27 -0400  42)     api :GET, "/organizations/:organization_id/subscriptions/:id", N_("Show a subscription")
f89b930e app/controllers/katello/api/v2/subscriptions_controller.rb (Walden Raines    2014-10-09 11:37:27 -0400  43)     api :GET, "/subscriptions/:id", N_("Show a subscription")
f89b930e app/controllers/katello/api/v2/subscriptions_controller.rb (Walden Raines    2014-10-09 11:37:27 -0400  44)     param :organization_id, :number, :desc => N_("Organization identifier")
f89b930e app/controllers/katello/api/v2/subscriptions_controller.rb (Walden Raines    2014-10-09 11:37:27 -0400  45)     param :id, :number, :desc => N_("Subscription identifier"), :required => true
f89b930e app/controllers/katello/api/v2/subscriptions_controller.rb (Walden Raines    2014-10-09 11:37:27 -0400  46)     def show
6400e13a app/controllers/katello/api/v2/subscriptions_controller.rb (John Mitsch      2015-08-13 15:41:14 -0400  47)       @resource = Katello::Pool.with_identifier(params[:id])
05263360 app/controllers/katello/api/v2/subscriptions_controller.rb (John Mitsch      2015-11-30 09:42:04 -0500  48)       respond(:resource => @resource)
f89b930e app/controllers/katello/api/v2/subscriptions_controller.rb (Walden Raines    2014-10-09 11:37:27 -0400  49)     end
ead5ce9c app/controllers/api/v2/subscriptions_controller.rb         (Walden Raines    2013-09-12 12:32:53 -0400  50) 
f89b930e app/controllers/katello/api/v2/subscriptions_controller.rb (Walden Raines    2014-10-09 11:37:27 -0400  51)     def available
f89b930e app/controllers/katello/api/v2/subscriptions_controller.rb (Walden Raines    2014-10-09 11:37:27 -0400  52)       subscriptions = if @system
6400e13a app/controllers/katello/api/v2/subscriptions_controller.rb (John Mitsch      2015-08-13 15:41:14 -0400  53)                         available_for_system
f89b930e app/controllers/katello/api/v2/subscriptions_controller.rb (Walden Raines    2014-10-09 11:37:27 -0400  54)                       elsif @activation_key
6400e13a app/controllers/katello/api/v2/subscriptions_controller.rb (John Mitsch      2015-08-13 15:41:14 -0400  55)                         available_for_activation_key
f89b930e app/controllers/katello/api/v2/subscriptions_controller.rb (Walden Raines    2014-10-09 11:37:27 -0400  56)                       else
6400e13a app/controllers/katello/api/v2/subscriptions_controller.rb (John Mitsch      2015-08-13 15:41:14 -0400  57)                         Organization.find(params[:organization_id]).subscriptions if params[:organization_id]
f89b930e app/controllers/katello/api/v2/subscriptions_controller.rb (Walden Raines    2014-10-09 11:37:27 -0400  58)                       end
3fce5d39 app/controllers/katello/api/v2/subscriptions_controller.rb (David Davis      2014-03-24 09:46:05 -0400  59) 
6400e13a app/controllers/katello/api/v2/subscriptions_controller.rb (John Mitsch      2015-08-13 15:41:14 -0400  60)       respond_for_index(:collection => scoped_search(subscriptions.uniq, :cp_id, :asc, :resource_class => Pool), :template => "index")
cbca266a app/controllers/katello/api/v2/subscriptions_controller.rb (Manjiri Tapaswi  2013-12-16 17:25:09 -0500  61)     end
cbca266a app/controllers/katello/api/v2/subscriptions_controller.rb (Manjiri Tapaswi  2013-12-16 17:25:09 -0500  62) 
6400e13a app/controllers/katello/api/v2/subscriptions_controller.rb (John Mitsch      2015-08-13 15:41:14 -0400  63)     api :POST, "/systems/:system_id/subscriptions", N_("Add a subscription to a content host"), :deprecated => true
f89b930e app/controllers/katello/api/v2/subscriptions_controller.rb (Walden Raines    2014-10-09 11:37:27 -0400  64)     api :POST, "/activation_keys/:activation_key_id/subscriptions", N_("Add a subscription to an activation key")
f89b930e app/controllers/katello/api/v2/subscriptions_controller.rb (Walden Raines    2014-10-09 11:37:27 -0400  65)     param :id, String, :desc => N_("Subscription Pool uuid"), :required => false
6400e13a app/controllers/katello/api/v2/subscriptions_controller.rb (John Mitsch      2015-08-13 15:41:14 -0400  66)     param :system_id, String, :desc => N_("UUID of a content host"), :required => false
f89b930e app/controllers/katello/api/v2/subscriptions_controller.rb (Walden Raines    2014-10-09 11:37:27 -0400  67)     param :activation_key_id, String, :desc => N_("ID of the activation key"), :required => false
f89b930e app/controllers/katello/api/v2/subscriptions_controller.rb (Walden Raines    2014-10-09 11:37:27 -0400  68)     param :quantity, :number, :desc => N_("Quantity of this subscriptions to add"), :required => false
f89b930e app/controllers/katello/api/v2/subscriptions_controller.rb (Walden Raines    2014-10-09 11:37:27 -0400  69)     param :subscriptions, Array, :desc => N_("Array of subscriptions to add"), :required => false do
f89b930e app/controllers/katello/api/v2/subscriptions_controller.rb (Walden Raines    2014-10-09 11:37:27 -0400  70)       param :id, String, :desc => N_("Subscription Pool uuid"), :required => true
f89b930e app/controllers/katello/api/v2/subscriptions_controller.rb (Walden Raines    2014-10-09 11:37:27 -0400  71)       param :quantity, :number, :desc => N_("Quantity of this subscriptions to add"), :required => true
f89b930e app/controllers/katello/api/v2/subscriptions_controller.rb (Walden Raines    2014-10-09 11:37:27 -0400  72)     end
f89b930e app/controllers/katello/api/v2/subscriptions_controller.rb (Walden Raines    2014-10-09 11:37:27 -0400  73)     def create
33231f70 app/controllers/katello/api/v2/subscriptions_controller.rb (Christine Fouant 2015-11-10 14:22:41 -0500  74)       object = @system || @activation_key
f89b930e app/controllers/katello/api/v2/subscriptions_controller.rb (Walden Raines    2014-10-09 11:37:27 -0400  75) 
f89b930e app/controllers/katello/api/v2/subscriptions_controller.rb (Walden Raines    2014-10-09 11:37:27 -0400  76)       if params[:subscriptions]
6400e13a app/controllers/katello/api/v2/subscriptions_controller.rb (John Mitsch      2015-08-13 15:41:14 -0400  77)         params[:subscriptions].each do |sub|
6400e13a app/controllers/katello/api/v2/subscriptions_controller.rb (John Mitsch      2015-08-13 15:41:14 -0400  78)           subscription = Pool.find(sub[:id])
6400e13a app/controllers/katello/api/v2/subscriptions_controller.rb (John Mitsch      2015-08-13 15:41:14 -0400  79)           object.subscribe(subscription.cp_id, subscription[:quantity])
f89b930e app/controllers/katello/api/v2/subscriptions_controller.rb (Walden Raines    2014-10-09 11:37:27 -0400  80)         end
f89b930e app/controllers/katello/api/v2/subscriptions_controller.rb (Walden Raines    2014-10-09 11:37:27 -0400  81)       elsif params[:id] && params.key?(:quantity)
6400e13a app/controllers/katello/api/v2/subscriptions_controller.rb (John Mitsch      2015-08-13 15:41:14 -0400  82)         sub = subscription.find(params[:id])
6400e13a app/controllers/katello/api/v2/subscriptions_controller.rb (John Mitsch      2015-08-13 15:41:14 -0400  83)         object.subscribe(sub.cp_id, params[:quantity])
f89b930e app/controllers/katello/api/v2/subscriptions_controller.rb (Walden Raines    2014-10-09 11:37:27 -0400  84)       end
b43afd57 app/controllers/api/v2/subscriptions_controller.rb         (Martin Bačovský  2013-03-25 15:53:33 +0100  85) 
f89b930e app/controllers/katello/api/v2/subscriptions_controller.rb (Walden Raines    2014-10-09 11:37:27 -0400  86)       subscriptions = if @system
f89b930e app/controllers/katello/api/v2/subscriptions_controller.rb (Walden Raines    2014-10-09 11:37:27 -0400  87)                         index_system
f89b930e app/controllers/katello/api/v2/subscriptions_controller.rb (Walden Raines    2014-10-09 11:37:27 -0400  88)                       elsif @activation_key
f89b930e app/controllers/katello/api/v2/subscriptions_controller.rb (Walden Raines    2014-10-09 11:37:27 -0400  89)                         index_activation_key
f89b930e app/controllers/katello/api/v2/subscriptions_controller.rb (Walden Raines    2014-10-09 11:37:27 -0400  90)                       end
3fce5d39 app/controllers/katello/api/v2/subscriptions_controller.rb (David Davis      2014-03-24 09:46:05 -0400  91) 
f89b930e app/controllers/katello/api/v2/subscriptions_controller.rb (Walden Raines    2014-10-09 11:37:27 -0400  92)       respond_for_index(:collection => subscriptions, :template => 'index')
cbca266a app/controllers/katello/api/v2/subscriptions_controller.rb (Manjiri Tapaswi  2013-12-16 17:25:09 -0500  93)     end
b3116f18 app/controllers/api/v2/subscriptions_controller.rb         (Walden Raines    2013-08-14 16:50:41 -0400  94) 
f89b930e app/controllers/katello/api/v2/subscriptions_controller.rb (Walden Raines    2014-10-09 11:37:27 -0400  95)     api :DELETE, "/systems/:system_id/subscriptions/:id", N_("Unattach a subscription"), :deprecated => true
f89b930e app/controllers/katello/api/v2/subscriptions_controller.rb (Walden Raines    2014-10-09 11:37:27 -0400  96)     api :DELETE, "/activation_keys/:activation_key_id/subscriptions/:id", N_("Unattach a subscription")
f89b930e app/controllers/katello/api/v2/subscriptions_controller.rb (Walden Raines    2014-10-09 11:37:27 -0400  97)     param :id, String, :desc => N_("Subscription ID"), :required => false
6400e13a app/controllers/katello/api/v2/subscriptions_controller.rb (John Mitsch      2015-08-13 15:41:14 -0400  98)     param :system_id, String, :desc => N_("UUID of a content host")
f89b930e app/controllers/katello/api/v2/subscriptions_controller.rb (Walden Raines    2014-10-09 11:37:27 -0400  99)     param :activation_key_id, String, :desc => N_("activation key ID")
f89b930e app/controllers/katello/api/v2/subscriptions_controller.rb (Walden Raines    2014-10-09 11:37:27 -0400 100)     param :subscriptions, Array, :desc => N_("Array of subscriptions to add"), :required => false do
2cf41d8e app/controllers/katello/api/v2/subscriptions_controller.rb (Tom McKay        2015-04-02 14:16:02 -0400 101)       param :id, String, :desc => N_("Subscription Pool uuid")
f89b930e app/controllers/katello/api/v2/subscriptions_controller.rb (Walden Raines    2014-10-09 11:37:27 -0400 102)     end
f89b930e app/controllers/katello/api/v2/subscriptions_controller.rb (Walden Raines    2014-10-09 11:37:27 -0400 103)     def destroy
33231f70 app/controllers/katello/api/v2/subscriptions_controller.rb (Christine Fouant 2015-11-10 14:22:41 -0500 104)       object = @system || @activation_key
f89b930e app/controllers/katello/api/v2/subscriptions_controller.rb (Walden Raines    2014-10-09 11:37:27 -0400 105) 
6400e13a app/controllers/katello/api/v2/subscriptions_controller.rb (John Mitsch      2015-08-13 15:41:14 -0400 106)       if @system
f89b930e app/controllers/katello/api/v2/subscriptions_controller.rb (Walden Raines    2014-10-09 11:37:27 -0400 107)         params[:subscriptions].each do |subscription|
6400e13a app/controllers/katello/api/v2/subscriptions_controller.rb (John Mitsch      2015-08-13 15:41:14 -0400 108)           entitlement_id = @system.find_entitlement(subscription[:id])
6400e13a app/controllers/katello/api/v2/subscriptions_controller.rb (John Mitsch      2015-08-13 15:41:14 -0400 109)           object.unsubscribe(entitlement_id)
f89b930e app/controllers/katello/api/v2/subscriptions_controller.rb (Walden Raines    2014-10-09 11:37:27 -0400 110)         end
f89b930e app/controllers/katello/api/v2/subscriptions_controller.rb (Walden Raines    2014-10-09 11:37:27 -0400 111)       elsif params[:id]
f89b930e app/controllers/katello/api/v2/subscriptions_controller.rb (Walden Raines    2014-10-09 11:37:27 -0400 112)         object.unsubscribe(params[:id])
f89b930e app/controllers/katello/api/v2/subscriptions_controller.rb (Walden Raines    2014-10-09 11:37:27 -0400 113)       else
f89b930e app/controllers/katello/api/v2/subscriptions_controller.rb (Walden Raines    2014-10-09 11:37:27 -0400 114)         @system.unsubscribe_all
f89b930e app/controllers/katello/api/v2/subscriptions_controller.rb (Walden Raines    2014-10-09 11:37:27 -0400 115)       end
cbca266a app/controllers/katello/api/v2/subscriptions_controller.rb (Manjiri Tapaswi  2013-12-16 17:25:09 -0500 116) 
64ffadb3 app/controllers/katello/api/v2/subscriptions_controller.rb (John Mitsch      2015-10-06 11:19:24 -0400 117)       respond_for_index(:collection => scoped_search(import_subscriptions.uniq, :cp_id, :asc, :resource_class => Pool), :template => "index")
6c532771 app/controllers/katello/api/v2/subscriptions_controller.rb (David Davis      2013-12-17 13:33:22 -0500 118)     end
6c532771 app/controllers/katello/api/v2/subscriptions_controller.rb (David Davis      2013-12-17 13:33:22 -0500 119) 
f89b930e app/controllers/katello/api/v2/subscriptions_controller.rb (Walden Raines    2014-10-09 11:37:27 -0400 120)     api :POST, "/organizations/:organization_id/subscriptions/upload", N_("Upload a subscription manifest")
f89b930e app/controllers/katello/api/v2/subscriptions_controller.rb (Walden Raines    2014-10-09 11:37:27 -0400 121)     api :POST, "/subscriptions/upload", N_("Upload a subscription manifest")
f89b930e app/controllers/katello/api/v2/subscriptions_controller.rb (Walden Raines    2014-10-09 11:37:27 -0400 122)     param :organization_id, :number, :desc => N_("Organization id"), :required => true
f89b930e app/controllers/katello/api/v2/subscriptions_controller.rb (Walden Raines    2014-10-09 11:37:27 -0400 123)     param :content, File, :desc => N_("Subscription manifest file"), :required => true
f89b930e app/controllers/katello/api/v2/subscriptions_controller.rb (Walden Raines    2014-10-09 11:37:27 -0400 124)     param :repository_url, String, :desc => N_("repository url"), :required => false
f89b930e app/controllers/katello/api/v2/subscriptions_controller.rb (Walden Raines    2014-10-09 11:37:27 -0400 125)     def upload
f89b930e app/controllers/katello/api/v2/subscriptions_controller.rb (Walden Raines    2014-10-09 11:37:27 -0400 126)       fail HttpErrors::BadRequest, _("No manifest file uploaded") if params[:content].blank?
f89b930e app/controllers/katello/api/v2/subscriptions_controller.rb (Walden Raines    2014-10-09 11:37:27 -0400 127) 
f89b930e app/controllers/katello/api/v2/subscriptions_controller.rb (Walden Raines    2014-10-09 11:37:27 -0400 128)       begin
f89b930e app/controllers/katello/api/v2/subscriptions_controller.rb (Walden Raines    2014-10-09 11:37:27 -0400 129)         # candlepin requires that the file has a zip file extension
f89b930e app/controllers/katello/api/v2/subscriptions_controller.rb (Walden Raines    2014-10-09 11:37:27 -0400 130)         temp_file = File.new(File.join("#{Rails.root}/tmp", "import_#{SecureRandom.hex(10)}.zip"), 'wb+', 0600)
f89b930e app/controllers/katello/api/v2/subscriptions_controller.rb (Walden Raines    2014-10-09 11:37:27 -0400 131)         temp_file.write params[:content].read
f89b930e app/controllers/katello/api/v2/subscriptions_controller.rb (Walden Raines    2014-10-09 11:37:27 -0400 132)       ensure
f89b930e app/controllers/katello/api/v2/subscriptions_controller.rb (Walden Raines    2014-10-09 11:37:27 -0400 133)         temp_file.close
f89b930e app/controllers/katello/api/v2/subscriptions_controller.rb (Walden Raines    2014-10-09 11:37:27 -0400 134)       end
47dc17bb app/controllers/katello/api/v2/subscriptions_controller.rb (Adam Price       2014-04-07 16:01:39 -0400 135) 
f89b930e app/controllers/katello/api/v2/subscriptions_controller.rb (Walden Raines    2014-10-09 11:37:27 -0400 136)       # repository url
f89b930e app/controllers/katello/api/v2/subscriptions_controller.rb (Walden Raines    2014-10-09 11:37:27 -0400 137)       if repo_url = params[:repository_url]
f89b930e app/controllers/katello/api/v2/subscriptions_controller.rb (Walden Raines    2014-10-09 11:37:27 -0400 138)         @provider.repository_url = repo_url
f89b930e app/controllers/katello/api/v2/subscriptions_controller.rb (Walden Raines    2014-10-09 11:37:27 -0400 139)         @provider.save!
f89b930e app/controllers/katello/api/v2/subscriptions_controller.rb (Walden Raines    2014-10-09 11:37:27 -0400 140)       end
4367483f app/controllers/katello/api/v2/subscriptions_controller.rb (Bryan Kearney    2014-02-17 17:16:46 -0500 141) 
f89b930e app/controllers/katello/api/v2/subscriptions_controller.rb (Walden Raines    2014-10-09 11:37:27 -0400 142)       task = async_task(::Actions::Katello::Provider::ManifestImport, @provider, File.expand_path(temp_file.path), params[:force])
f89b930e app/controllers/katello/api/v2/subscriptions_controller.rb (Walden Raines    2014-10-09 11:37:27 -0400 143)       respond_for_async :resource => task
f89b930e app/controllers/katello/api/v2/subscriptions_controller.rb (Walden Raines    2014-10-09 11:37:27 -0400 144)     end
4367483f app/controllers/katello/api/v2/subscriptions_controller.rb (Bryan Kearney    2014-02-17 17:16:46 -0500 145) 
f89b930e app/controllers/katello/api/v2/subscriptions_controller.rb (Walden Raines    2014-10-09 11:37:27 -0400 146)     api :PUT, "/organizations/:organization_id/subscriptions/refresh_manifest", N_("Refresh previously imported manifest for Red Hat provider")
f89b930e app/controllers/katello/api/v2/subscriptions_controller.rb (Walden Raines    2014-10-09 11:37:27 -0400 147)     param :organization_id, :number, :desc => N_("Organization id"), :required => true
f89b930e app/controllers/katello/api/v2/subscriptions_controller.rb (Walden Raines    2014-10-09 11:37:27 -0400 148)     def refresh_manifest
f89b930e app/controllers/katello/api/v2/subscriptions_controller.rb (Walden Raines    2014-10-09 11:37:27 -0400 149)       details  = @provider.organization.owner_details
f89b930e app/controllers/katello/api/v2/subscriptions_controller.rb (Walden Raines    2014-10-09 11:37:27 -0400 150)       upstream = details['upstreamConsumer'].blank? ? {} : details['upstreamConsumer']
4367483f app/controllers/katello/api/v2/subscriptions_controller.rb (Bryan Kearney    2014-02-17 17:16:46 -0500 151) 
f89b930e app/controllers/katello/api/v2/subscriptions_controller.rb (Walden Raines    2014-10-09 11:37:27 -0400 152)       task = async_task(::Actions::Katello::Provider::ManifestRefresh, @provider, upstream)
f89b930e app/controllers/katello/api/v2/subscriptions_controller.rb (Walden Raines    2014-10-09 11:37:27 -0400 153)       respond_for_async :resource => task
f89b930e app/controllers/katello/api/v2/subscriptions_controller.rb (Walden Raines    2014-10-09 11:37:27 -0400 154)     end
6c532771 app/controllers/katello/api/v2/subscriptions_controller.rb (David Davis      2013-12-17 13:33:22 -0500 155) 
f89b930e app/controllers/katello/api/v2/subscriptions_controller.rb (Walden Raines    2014-10-09 11:37:27 -0400 156)     api :POST, "/organizations/:organization_id/subscriptions/delete_manifest", N_("Delete manifest from Red Hat provider")
f89b930e app/controllers/katello/api/v2/subscriptions_controller.rb (Walden Raines    2014-10-09 11:37:27 -0400 157)     param :organization_id, :number, :desc => N_("Organization id"), :required => true
f89b930e app/controllers/katello/api/v2/subscriptions_controller.rb (Walden Raines    2014-10-09 11:37:27 -0400 158)     def delete_manifest
f89b930e app/controllers/katello/api/v2/subscriptions_controller.rb (Walden Raines    2014-10-09 11:37:27 -0400 159)       task = async_task(::Actions::Katello::Provider::ManifestDelete, @provider)
f89b930e app/controllers/katello/api/v2/subscriptions_controller.rb (Walden Raines    2014-10-09 11:37:27 -0400 160)       respond_for_async :resource => task
f89b930e app/controllers/katello/api/v2/subscriptions_controller.rb (Walden Raines    2014-10-09 11:37:27 -0400 161)     end
ecf30424 app/controllers/katello/api/v2/subscriptions_controller.rb (Dustin Tsang     2014-04-28 21:18:13 -0400 162) 
f89b930e app/controllers/katello/api/v2/subscriptions_controller.rb (Walden Raines    2014-10-09 11:37:27 -0400 163)     api :GET, "/organizations/:organization_id/subscriptions/manifest_history", N_("obtain manifest history for subscriptions")
f89b930e app/controllers/katello/api/v2/subscriptions_controller.rb (Walden Raines    2014-10-09 11:37:27 -0400 164)     param :organization_id, :number, :desc => N_("Organization ID"), :required => true
f89b930e app/controllers/katello/api/v2/subscriptions_controller.rb (Walden Raines    2014-10-09 11:37:27 -0400 165)     def manifest_history
f89b930e app/controllers/katello/api/v2/subscriptions_controller.rb (Walden Raines    2014-10-09 11:37:27 -0400 166)       @manifest_history = @organization.manifest_history
f89b930e app/controllers/katello/api/v2/subscriptions_controller.rb (Walden Raines    2014-10-09 11:37:27 -0400 167)       respond_with_template_collection(params[:action], "subscriptions", collection: @manifest_history)
f89b930e app/controllers/katello/api/v2/subscriptions_controller.rb (Walden Raines    2014-10-09 11:37:27 -0400 168)     end
ead5ce9c app/controllers/api/v2/subscriptions_controller.rb         (Walden Raines    2013-09-12 12:32:53 -0400 169) 
6400e13a app/controllers/katello/api/v2/subscriptions_controller.rb (John Mitsch      2015-08-13 15:41:14 -0400 170)     api :GET, "/systems/:system_id/subscriptions/available", N_("List available subscriptions"), :deprecated => true
6400e13a app/controllers/katello/api/v2/subscriptions_controller.rb (John Mitsch      2015-08-13 15:41:14 -0400 171)     param :system_id, String, :desc => N_("UUID of a content host"), :required => true
6400e13a app/controllers/katello/api/v2/subscriptions_controller.rb (John Mitsch      2015-08-13 15:41:14 -0400 172)     param :match_system, :bool, :desc => N_("Return subscriptions that match a content host")
6400e13a app/controllers/katello/api/v2/subscriptions_controller.rb (John Mitsch      2015-08-13 15:41:14 -0400 173)     param :match_installed, :bool, :desc => N_("Return subscriptions that match installed products")
6400e13a app/controllers/katello/api/v2/subscriptions_controller.rb (John Mitsch      2015-08-13 15:41:14 -0400 174)     param :no_overlap, :bool, :desc => N_("Return subscriptions which do not overlap with a currently-attached subscription")
6400e13a app/controllers/katello/api/v2/subscriptions_controller.rb (John Mitsch      2015-08-13 15:41:14 -0400 175)     def available_for_system
6400e13a app/controllers/katello/api/v2/subscriptions_controller.rb (John Mitsch      2015-08-13 15:41:14 -0400 176)       params[:match_system] = ::Foreman::Cast.to_bool(params[:match_system]) if params[:match_system]
6400e13a app/controllers/katello/api/v2/subscriptions_controller.rb (John Mitsch      2015-08-13 15:41:14 -0400 177)       params[:match_installed] = ::Foreman::Cast.to_bool(params[:match_installed]) if params[:match_installed]
6400e13a app/controllers/katello/api/v2/subscriptions_controller.rb (John Mitsch      2015-08-13 15:41:14 -0400 178)       params[:no_overlap] = ::Foreman::Cast.to_bool(params[:no_overlap]) if params[:no_overlap]
6400e13a app/controllers/katello/api/v2/subscriptions_controller.rb (John Mitsch      2015-08-13 15:41:14 -0400 179)       pools = @system.filtered_pools(params[:match_system], params[:match_installed],
6400e13a app/controllers/katello/api/v2/subscriptions_controller.rb (John Mitsch      2015-08-13 15:41:14 -0400 180)                                      params[:no_overlap])
6400e13a app/controllers/katello/api/v2/subscriptions_controller.rb (John Mitsch      2015-08-13 15:41:14 -0400 181)       if pools
eb778097 app/controllers/katello/api/v2/subscriptions_controller.rb (Adam Price       2015-10-05 15:41:07 -0400 182)         available = pools.collect { |cp_pool| ::Katello::Pool.find_by(:cp_id => cp_pool['id']) }
6400e13a app/controllers/katello/api/v2/subscriptions_controller.rb (John Mitsch      2015-08-13 15:41:14 -0400 183)         available.compact!
6400e13a app/controllers/katello/api/v2/subscriptions_controller.rb (John Mitsch      2015-08-13 15:41:14 -0400 184)         available.select { |pool| pool.provider?(Organization.find(params[:organization_id])) }
6400e13a app/controllers/katello/api/v2/subscriptions_controller.rb (John Mitsch      2015-08-13 15:41:14 -0400 185)       end
6400e13a app/controllers/katello/api/v2/subscriptions_controller.rb (John Mitsch      2015-08-13 15:41:14 -0400 186) 
6400e13a app/controllers/katello/api/v2/subscriptions_controller.rb (John Mitsch      2015-08-13 15:41:14 -0400 187)       available || []
6400e13a app/controllers/katello/api/v2/subscriptions_controller.rb (John Mitsch      2015-08-13 15:41:14 -0400 188)     end
6400e13a app/controllers/katello/api/v2/subscriptions_controller.rb (John Mitsch      2015-08-13 15:41:14 -0400 189) 
f89b930e app/controllers/katello/api/v2/subscriptions_controller.rb (Walden Raines    2014-10-09 11:37:27 -0400 190)     protected
6c532771 app/controllers/katello/api/v2/subscriptions_controller.rb (David Davis      2013-12-17 13:33:22 -0500 191) 
f89b930e app/controllers/katello/api/v2/subscriptions_controller.rb (Walden Raines    2014-10-09 11:37:27 -0400 192)     def find_system
90504ad4 app/controllers/katello/api/v2/subscriptions_controller.rb (Chris Peters     2015-08-13 09:11:38 -0400 193)       @system = System.find_by!(:uuid => params[:system_id]) if params[:system_id]
f89b930e app/controllers/katello/api/v2/subscriptions_controller.rb (Walden Raines    2014-10-09 11:37:27 -0400 194)     end
cbca266a app/controllers/katello/api/v2/subscriptions_controller.rb (Manjiri Tapaswi  2013-12-16 17:25:09 -0500 195) 
f89b930e app/controllers/katello/api/v2/subscriptions_controller.rb (Walden Raines    2014-10-09 11:37:27 -0400 196)     def find_activation_key
90504ad4 app/controllers/katello/api/v2/subscriptions_controller.rb (Chris Peters     2015-08-13 09:11:38 -0400 197)       @activation_key = ActivationKey.find_by!(:id => params[:activation_key_id]) if params[:activation_key_id]
f89b930e app/controllers/katello/api/v2/subscriptions_controller.rb (Walden Raines    2014-10-09 11:37:27 -0400 198)     end
6c532771 app/controllers/katello/api/v2/subscriptions_controller.rb (David Davis      2013-12-17 13:33:22 -0500 199) 
f89b930e app/controllers/katello/api/v2/subscriptions_controller.rb (Walden Raines    2014-10-09 11:37:27 -0400 200)     def find_provider
f89b930e app/controllers/katello/api/v2/subscriptions_controller.rb (Walden Raines    2014-10-09 11:37:27 -0400 201)       @organization = @system.organization if @system
f89b930e app/controllers/katello/api/v2/subscriptions_controller.rb (Walden Raines    2014-10-09 11:37:27 -0400 202)       @organization = @activation_key.organization if @activation_key
f89b930e app/controllers/katello/api/v2/subscriptions_controller.rb (Walden Raines    2014-10-09 11:37:27 -0400 203)       @organization = @subscription.organization if @subscription
f89b930e app/controllers/katello/api/v2/subscriptions_controller.rb (Walden Raines    2014-10-09 11:37:27 -0400 204)       @provider = @organization.redhat_provider if @organization
f89b930e app/controllers/katello/api/v2/subscriptions_controller.rb (Walden Raines    2014-10-09 11:37:27 -0400 205)     end
cbca266a app/controllers/katello/api/v2/subscriptions_controller.rb (Manjiri Tapaswi  2013-12-16 17:25:09 -0500 206) 
6400e13a app/controllers/katello/api/v2/subscriptions_controller.rb (John Mitsch      2015-08-13 15:41:14 -0400 207)     private
6400e13a app/controllers/katello/api/v2/subscriptions_controller.rb (John Mitsch      2015-08-13 15:41:14 -0400 208) 
6400e13a app/controllers/katello/api/v2/subscriptions_controller.rb (John Mitsch      2015-08-13 15:41:14 -0400 209)     def resource_class
6400e13a app/controllers/katello/api/v2/subscriptions_controller.rb (John Mitsch      2015-08-13 15:41:14 -0400 210)       Pool
f89b930e app/controllers/katello/api/v2/subscriptions_controller.rb (Walden Raines    2014-10-09 11:37:27 -0400 211)     end
f89b930e app/controllers/katello/api/v2/subscriptions_controller.rb (Walden Raines    2014-10-09 11:37:27 -0400 212) 
6400e13a app/controllers/katello/api/v2/subscriptions_controller.rb (John Mitsch      2015-08-13 15:41:14 -0400 213)     def default_sort
6400e13a app/controllers/katello/api/v2/subscriptions_controller.rb (John Mitsch      2015-08-13 15:41:14 -0400 214)       %w(id desc)
6400e13a app/controllers/katello/api/v2/subscriptions_controller.rb (John Mitsch      2015-08-13 15:41:14 -0400 215)     end
cbca266a app/controllers/katello/api/v2/subscriptions_controller.rb (Manjiri Tapaswi  2013-12-16 17:25:09 -0500 216) 
64ffadb3 app/controllers/katello/api/v2/subscriptions_controller.rb (John Mitsch      2015-10-06 11:19:24 -0400 217)     def import_subscriptions
64ffadb3 app/controllers/katello/api/v2/subscriptions_controller.rb (John Mitsch      2015-10-06 11:19:24 -0400 218)       subscriptions = if @system
64ffadb3 app/controllers/katello/api/v2/subscriptions_controller.rb (John Mitsch      2015-10-06 11:19:24 -0400 219)                         index_system
64ffadb3 app/controllers/katello/api/v2/subscriptions_controller.rb (John Mitsch      2015-10-06 11:19:24 -0400 220)                       elsif @activation_key
64ffadb3 app/controllers/katello/api/v2/subscriptions_controller.rb (John Mitsch      2015-10-06 11:19:24 -0400 221)                         index_activation_key
64ffadb3 app/controllers/katello/api/v2/subscriptions_controller.rb (John Mitsch      2015-10-06 11:19:24 -0400 222)                       else
64ffadb3 app/controllers/katello/api/v2/subscriptions_controller.rb (John Mitsch      2015-10-06 11:19:24 -0400 223)                         index_organization
64ffadb3 app/controllers/katello/api/v2/subscriptions_controller.rb (John Mitsch      2015-10-06 11:19:24 -0400 224)                       end
64ffadb3 app/controllers/katello/api/v2/subscriptions_controller.rb (John Mitsch      2015-10-06 11:19:24 -0400 225)       cp_ids = subscriptions.collect { |x| x["id"] }
64ffadb3 app/controllers/katello/api/v2/subscriptions_controller.rb (John Mitsch      2015-10-06 11:19:24 -0400 226)       index_relation.where("cp_id not in (?)", cp_ids)
64ffadb3 app/controllers/katello/api/v2/subscriptions_controller.rb (John Mitsch      2015-10-06 11:19:24 -0400 227)     end
cbca266a app/controllers/katello/api/v2/subscriptions_controller.rb (Manjiri Tapaswi  2013-12-16 17:25:09 -0500 228) 
64ffadb3 app/controllers/katello/api/v2/subscriptions_controller.rb (John Mitsch      2015-10-06 11:19:24 -0400 229)     def index_system
64ffadb3 app/controllers/katello/api/v2/subscriptions_controller.rb (John Mitsch      2015-10-06 11:19:24 -0400 230)       Katello::Pool.import_all
64ffadb3 app/controllers/katello/api/v2/subscriptions_controller.rb (John Mitsch      2015-10-06 11:19:24 -0400 231)       @system.entitlements
f89b930e app/controllers/katello/api/v2/subscriptions_controller.rb (Walden Raines    2014-10-09 11:37:27 -0400 232)     end
cbca266a app/controllers/katello/api/v2/subscriptions_controller.rb (Manjiri Tapaswi  2013-12-16 17:25:09 -0500 233) 
f89b930e app/controllers/katello/api/v2/subscriptions_controller.rb (Walden Raines    2014-10-09 11:37:27 -0400 234)     def index_activation_key
64ffadb3 app/controllers/katello/api/v2/subscriptions_controller.rb (John Mitsch      2015-10-06 11:19:24 -0400 235)       @activation_key.subscriptions
64ffadb3 app/controllers/katello/api/v2/subscriptions_controller.rb (John Mitsch      2015-10-06 11:19:24 -0400 236)     end
64ffadb3 app/controllers/katello/api/v2/subscriptions_controller.rb (John Mitsch      2015-10-06 11:19:24 -0400 237) 
64ffadb3 app/controllers/katello/api/v2/subscriptions_controller.rb (John Mitsch      2015-10-06 11:19:24 -0400 238)     def index_organization
64ffadb3 app/controllers/katello/api/v2/subscriptions_controller.rb (John Mitsch      2015-10-06 11:19:24 -0400 239)       @organization.subscriptions
f89b930e app/controllers/katello/api/v2/subscriptions_controller.rb (Walden Raines    2014-10-09 11:37:27 -0400 240)     end
cbca266a app/controllers/katello/api/v2/subscriptions_controller.rb (Manjiri Tapaswi  2013-12-16 17:25:09 -0500 241) 
6400e13a app/controllers/katello/api/v2/subscriptions_controller.rb (John Mitsch      2015-08-13 15:41:14 -0400 242)     def available_for_activation_key
6400e13a app/controllers/katello/api/v2/subscriptions_controller.rb (John Mitsch      2015-08-13 15:41:14 -0400 243)       @activation_key.available_subscriptions
f89b930e app/controllers/katello/api/v2/subscriptions_controller.rb (Walden Raines    2014-10-09 11:37:27 -0400 244)     end
f89b930e app/controllers/katello/api/v2/subscriptions_controller.rb (Walden Raines    2014-10-09 11:37:27 -0400 245)   end
496503e8 app/controllers/katello/api/v2/subscriptions_controller.rb (Eric D. Helms    2013-10-11 21:39:25 -0400 246) end