Class: RedhatAccess::Api::AttachmentsController

Inherits:
ApiController show all
Defined in:
app/controllers/redhat_access/api/attachments_controller.rb

Instance Method Summary collapse

Methods inherited from ApiController

#api_request?, #http_error_response

Instance Method Details

#api_versionObject



35
36
37
# File 'app/controllers/redhat_access/api/attachments_controller.rb', line 35

def api_version
  'v1'
end

#createObject



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

def create
  data = params[:attach_payload]
  begin
    case_number = data[:caseNum]
    sos_file = RedhatAccess::SosReports::Generator.create_report case_number
    strata = RedhatAccess::Strata::Client.new(data[:authToken])
    strata.api.attachment_broker.add(case_number,
                                     false,
                                     sos_file,
                                     "Attachment for case #{case_number}")
    render :nothing => true,
      :status => 201
  rescue => e
    logger.error e.backtrace
    #logger.error "Failed to import facts for Host::Discovered: #{e}"
    render :text => "Error attaching sos file " + e.message,
      :layout => false ,
      :status => 500
  end
end

#indexObject



9
10
11
12
# File 'app/controllers/redhat_access/api/attachments_controller.rb', line 9

def index
  render :text => "SOS Report?checked=true",
    :layout => false
end