#NEWLINE# @ jsexpose ( body_cls = TriggerTypeAPI , status_code = http_client . CREATED ) #NEWLINE# def post( self , triggertype ) : #NEWLINE# #INDENT# '\n            Create a new triggertype.\n\n            Handles requests:\n                POST /triggertypes/\n        ' #NEWLINE# try : #NEWLINE# #INDENT# triggertype_db = TriggerTypeAPI . to_model ( triggertype ) #NEWLINE# triggertype_db = TriggerType . add_or_update ( triggertype_db ) #NEWLINE# #UNINDENT# except ( ValidationError , ValueError ) as e : #NEWLINE# #INDENT# LOG . exception ( 'Validation failed for triggertype data=%s.' , triggertype ) #NEWLINE# abort ( http_client . BAD_REQUEST , str ( e ) ) #NEWLINE# return #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# extra = { #NEWLINE# #INDENT# 'triggertype_db' : triggertype_db , #NEWLINE# #UNINDENT# } #NEWLINE# LOG . audit ( ( 'TriggerType created. TriggerType.id=%s' % triggertype_db . id ) , extra = extra ) #NEWLINE# if ( not triggertype_db . parameters_schema ) : #NEWLINE# #INDENT# TriggerTypeController . _create_shadow_trigger ( triggertype_db ) #NEWLINE# #UNINDENT# #UNINDENT# triggertype_api = TriggerTypeAPI . from_model ( triggertype_db ) #NEWLINE# return triggertype_api