#NEWLINE# def run_command( token , proxy , image_id , params , record ) : #NEWLINE# #INDENT# '\n\trun command and process result\n\t' #NEWLINE# method = 'POST' #NEWLINE# url = ( ( IMAGES + str ( image_id ) ) + '/actions' ) #NEWLINE# result = DigitalOcean . do_request ( method , url , token = token , proxy = proxy , params = params ) #NEWLINE# if result [ 'has_error' ] : #NEWLINE# #INDENT# click . echo ( ) #NEWLINE# click . echo ( ( 'Error: %s' % result [ 'error_message' ] ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# headers = [ 'Fields' , 'Values' ] #NEWLINE# table = [ [ 'Id' , result [ 'action' ] [ 'id' ] ] , [ 'Status' , result [ 'action' ] [ 'status' ] ] , [ 'Type' , result [ 'action' ] [ 'type' ] ] , [ 'Started at' , result [ 'action' ] [ 'started_at' ] ] , [ 'Completed at' , result [ 'action' ] [ 'completed_at' ] ] , [ 'Resource Id' , result [ 'action' ] [ 'resource_id' ] ] , [ 'Resource Type' , result [ 'action' ] [ 'resource_type' ] ] , [ 'Region' , result [ 'action' ] [ 'region' ] ] ] #NEWLINE# data = { #NEWLINE# #INDENT# 'headers' : headers , #NEWLINE# 'table_data' : table , #NEWLINE# #UNINDENT# } #NEWLINE# cmd = ( 'Command: docli image-actions -a %d -i %d' % ( image_id , result [ 'action' ] [ 'id' ] ) ) #NEWLINE# print_table ( tablefmt , data , record ) #NEWLINE# click . echo ( ) #NEWLINE# click . echo ( 'To get status update of above action execute following command.' ) #NEWLINE# click . echo ( cmd )