#NEWLINE# def httpErrors( self , status_code , endpoint , result ) : #NEWLINE# #INDENT# if ( status_code == 403 ) : #NEWLINE# #INDENT# error_msg = ( 'ERROR: Call to %s failed with a 403 result\n' % endpoint ) #NEWLINE# error_msg += 'ERROR: This indicates a problem with authorization.\n' #NEWLINE# error_msg += 'ERROR: Please ensure that the credentials you created for this script\n' #NEWLINE# error_msg += 'ERROR: have the necessary permissions in the Luna portal.\n' #NEWLINE# error_msg += ( 'ERROR: Problem details: %s\n' % result [ 'detail' ] ) #NEWLINE# exit ( error_msg ) #NEWLINE# #UNINDENT# if ( status_code in [ 400 , 401 ] ) : #NEWLINE# #INDENT# error_msg = ( 'ERROR: Call to %s failed with a %s result\n' % ( endpoint , status_code ) ) #NEWLINE# error_msg += 'ERROR: This indicates a problem with authentication or headers.\n' #NEWLINE# error_msg += 'ERROR: Please ensure that the .edgerc file is formatted correctly.\n' #NEWLINE# error_msg += 'ERROR: If you still have issues, please use gen_edgerc.py to generate the credentials\n' #NEWLINE# error_msg += ( 'ERROR: Problem details: %s\n' % result ) #NEWLINE# exit ( error_msg ) #NEWLINE# #UNINDENT# if ( status_code in [ 404 ] ) : #NEWLINE# #INDENT# error_msg = ( 'ERROR: Call to %s failed with a %s result\n' % ( endpoint , status_code ) ) #NEWLINE# error_msg += 'ERROR: This means that the page does not exist as requested.\n' #NEWLINE# error_msg += "ERROR: Please ensure that the URL you're calling is correctly formatted\n" #NEWLINE# error_msg += 'ERROR: or look at other examples to make sure yours matches.\n' #NEWLINE# error_msg += ( 'ERROR: Problem details: %s\n' % result [ 'detail' ] ) #NEWLINE# exit ( error_msg ) #NEWLINE# #UNINDENT# error_string = None #NEWLINE# if ( 'errorString' in result ) : #NEWLINE# #INDENT# if error_string [ 'errorString' ] : #NEWLINE# #INDENT# error_string = result [ 'errorString' ] #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# for key in result : #NEWLINE# #INDENT# if ( type ( key ) is not str ) : #NEWLINE# #INDENT# continue #NEWLINE# #UNINDENT# if ( type ( result [ key ] [ 'errorString' ] ) is str ) : #NEWLINE# #INDENT# error_string = result [ key ] [ 'errorString' ] #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# if error_string : #NEWLINE# #INDENT# error_msg = 'ERROR: Call caused a server fault.\n' #NEWLINE# error_msg += 'ERROR: Please check the problem details for more information:\n' #NEWLINE# error_msg += ( 'ERROR: Problem details: %s\n' % error_string ) #NEWLINE# exit ( error_msg )