#NEWLINE# def keygen( self , extra_qs = None ) : #NEWLINE# #INDENT# self . __clear_response ( ) #NEWLINE# if ( ( self . api_username is None ) or ( self . api_password is None ) ) : #NEWLINE# #INDENT# raise PanXapiError ( ( 'api_username and api_password ' + 'arguments required' ) ) #NEWLINE# #UNINDENT# query = { #NEWLINE# #INDENT# 'type' : 'keygen' , #NEWLINE# 'user' : self . api_username , #NEWLINE# 'password' : self . api_password , #NEWLINE# #UNINDENT# } #NEWLINE# if ( self . serial is not None ) : #NEWLINE# #INDENT# query [ 'target' ] = self . serial #NEWLINE# #UNINDENT# if ( extra_qs is not None ) : #NEWLINE# #INDENT# query = self . __merge_extra_qs ( query , extra_qs ) #NEWLINE# #UNINDENT# response = self . __api_request ( query ) #NEWLINE# if ( not response ) : #NEWLINE# #INDENT# raise PanXapiError ( self . status_detail ) #NEWLINE# #UNINDENT# if ( not self . __set_response ( response ) ) : #NEWLINE# #INDENT# raise PanXapiError ( element . status_detail ) #NEWLINE# #UNINDENT# if ( self . element_result is None ) : #NEWLINE# #INDENT# raise PanXapiError ( 'keygen(): result element not found' ) #NEWLINE# #UNINDENT# element = self . element_result . find ( 'key' ) #NEWLINE# if ( element is None ) : #NEWLINE# #INDENT# raise PanXapiError ( 'keygen(): key element not found' ) #NEWLINE# #UNINDENT# self . api_key = element . text #NEWLINE# return self . api_key