Class: ForemanKatelloEngine::Api::EnvironmentsController

Inherits:
Api::V2::BaseController
  • Object
show all
Defined in:
app/controllers/foreman_katello_engine/api/environments_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'app/controllers/foreman_katello_engine/api/environments_controller.rb', line 14

def create
  begin
    organization = Organization.find(params[:org_id]) if params[:org_id].present?
    @environment = ForemanKatelloEngine::Environment.create!(params[:org],
                                                             params[:env],
                                                             params[:content_view],
                                                             params[:content_view_id]) do |env|
      env.organizations << organization if organization
    end
  rescue ForemanKatelloEngine::Environment::Conflict => e
    render_error 'standard_error', :status => 409, :locals => { :exception => e }
    return
  rescue ArgumentError => e
    render_error 'standard_error', :status => 422, :locals => { :exception => e }
    return
  end
  render :template => "api/v1/environments/show"
end

#showObject



5
6
7
8
9
10
11
12
# File 'app/controllers/foreman_katello_engine/api/environments_controller.rb', line 5

def show
  @environment = ForemanKatelloEngine::Environment.find(params[:org], params[:env], params[:content_view])
  if @environment
    render :template => "api/v1/environments/show"
  else
    render_error 'not_found', :status => :not_found
  end
end