Sha256: 1bd273ebb113f75fecb69e10ff3a107d374e0a778ebf61a1e89ff371d9ed3f85

Contents?: true

Size: 1.3 KB

Versions: 51

Compression:

Stored size: 1.3 KB

Contents

require_dependency "redhat_access/application_controller"
require_dependency "redhat_access/strata/client"
require_dependency "redhat_access/sos_reports/generator"

module RedhatAccess
  module Api
    class AttachmentsController < RedhatAccess::Api::ApiController
      wrap_parameters :attach_payload, format: :json
      def index
        render :text => "SOS Report?checked=true",
          :layout => false
      end

      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

      def api_version
        'v1'
      end
    end
  end
end

Version data entries

51 entries across 51 versions & 1 rubygems

Version Path
redhat_access-2.0.10 app/controllers/redhat_access/api/attachments_controller.rb
redhat_access-2.0.9 app/controllers/redhat_access/api/attachments_controller.rb
redhat_access-2.0.8 app/controllers/redhat_access/api/attachments_controller.rb
redhat_access-2.0.7 app/controllers/redhat_access/api/attachments_controller.rb
redhat_access-2.0.6 app/controllers/redhat_access/api/attachments_controller.rb
redhat_access-2.0.5 app/controllers/redhat_access/api/attachments_controller.rb
redhat_access-2.0.4 app/controllers/redhat_access/api/attachments_controller.rb
redhat_access-2.0.3 app/controllers/redhat_access/api/attachments_controller.rb
redhat_access-2.0.2 app/controllers/redhat_access/api/attachments_controller.rb
redhat_access-2.0.1 app/controllers/redhat_access/api/attachments_controller.rb
redhat_access-2.0.0 app/controllers/redhat_access/api/attachments_controller.rb