Class: Katello::Api::V2::CapsuleContentController

Inherits:
ApiController
  • Object
show all
Defined in:
app/controllers/katello/api/v2/capsule_content_controller.rb

Instance Method Summary collapse

Methods inherited from ApiController

#check_katello_agent_not_disabled, #deprecate_katello_agent, #empty_search_query?, #full_result_response, #katello_agent_removal_release, #resource_class, #scoped_search, #skip_session

Methods included from Rendering

#respond_for_async, #respond_for_bulk_async, #respond_for_create, #respond_for_destroy, #respond_for_index, #respond_for_show, #respond_for_status, #respond_for_update, #respond_with_template, #respond_with_template_collection, #respond_with_template_resource, #try_specific_collection_template, #try_specific_resource_template

Methods included from Katello::Api::Version2

#api_version

Instance Method Details

#add_lifecycle_environmentObject



40
41
42
43
# File 'app/controllers/katello/api/v2/capsule_content_controller.rb', line 40

def add_lifecycle_environment
  @capsule.add_lifecycle_environment(@environment)
  respond_for_lifecycle_environments_index(@capsule.lifecycle_environments)
end

#available_lifecycle_environmentsObject



33
34
35
36
# File 'app/controllers/katello/api/v2/capsule_content_controller.rb', line 33

def available_lifecycle_environments
  environments = @capsule.available_lifecycle_environments(params[:organization_id]).readable
  respond_for_lifecycle_environments_index(environments)
end

#cancel_syncObject



81
82
83
84
85
86
87
88
# File 'app/controllers/katello/api/v2/capsule_content_controller.rb', line 81

def cancel_sync
  tasks = @capsule.cancel_sync
  if tasks.empty?
    render_message _('There\'s no running synchronization for this smart proxy.')
  else
    render_message _('Trying to cancel the synchronization...')
  end
end

#lifecycle_environmentsObject



25
26
27
28
29
# File 'app/controllers/katello/api/v2/capsule_content_controller.rb', line 25

def lifecycle_environments
  environments = @capsule.lifecycle_environments
  environment_org_scope = params[:organization_id] ? environments.where(organization_id: params[:organization_id]) : environments
  respond_for_lifecycle_environments_index(environment_org_scope)
end

#reclaim_spaceObject



92
93
94
95
96
# File 'app/controllers/katello/api/v2/capsule_content_controller.rb', line 92

def reclaim_space
  find_capsule(true)
  task = async_task(::Actions::Pulp3::CapsuleContent::ReclaimSpace, @capsule)
  respond_for_async :resource => task
end

#remove_lifecycle_environmentObject



47
48
49
50
# File 'app/controllers/katello/api/v2/capsule_content_controller.rb', line 47

def remove_lifecycle_environment
  @capsule.remove_lifecycle_environment(@environment)
  respond_for_lifecycle_environments_index(@capsule.lifecycle_environments)
end

#syncObject



58
59
60
61
62
63
64
65
66
67
68
69
70
# File 'app/controllers/katello/api/v2/capsule_content_controller.rb', line 58

def sync
  find_environment if params[:environment_id]
  find_content_view if params[:content_view_id]
  find_repository if params[:repository_id]
   = ::Foreman::Cast.to_bool(params[:skip_metadata_check])
  task = async_task(::Actions::Katello::CapsuleContent::Sync,
                    @capsule,
                    :environment_id => @environment.try(:id),
                    :content_view_id => @content_view.try(:id),
                    :repository_id => @repository.try(:id),
                    :skip_metadata_check => )
  respond_for_async :resource => task
end

#sync_statusObject



75
76
77
# File 'app/controllers/katello/api/v2/capsule_content_controller.rb', line 75

def sync_status
  @lifecycle_environments = @organization ? @capsule.lifecycle_environments.where(organization_id: @organization.id) : @capsule.lifecycle_environments
end