<s> import json <EOL> from oslo_utils import uuidutils <EOL> import six <EOL> from mistralclient . api import base <EOL> urlparse = six . moves . urllib . parse <EOL> class Execution ( base . Resource ) : <EOL> resource_name = '<STR_LIT>' <EOL> class ExecutionManager ( base . ResourceManager ) : <EOL> resource_class = Execution <EOL> def create ( self , workflow_identifier , workflow_input = None , description = '<STR_LIT>' , <EOL> ** params ) : <EOL> self . _ensure_not_empty ( workflow_identifier = workflow_identifier ) <EOL> data = { <EOL> '<STR_LIT:description>' : description <EOL> } <EOL> if uuidutils . is_uuid_like ( workflow_identifier ) : <EOL> data . update ( { '<STR_LIT>' : workflow_identifier } ) <EOL> else : <EOL> data . update ( { '<STR_LIT>' : workflow_identifier } ) <EOL> if workflow_input : <EOL> if isinstance ( workflow_input , six . string_types ) : <EOL> data . update ( { '<STR_LIT:input>' : workflow_input } ) <EOL> else : <EOL> data . update ( { '<STR_LIT:input>' : json . dumps ( workflow_input ) } ) <EOL> if params : <EOL> data . update ( { '<STR_LIT>' : json . dumps ( params ) } ) <EOL> return self . _create ( '<STR_LIT>' , data ) <EOL> def update ( self , id , state , description = None , env = None ) : <EOL> data = { } <EOL> if state : <EOL> data [ '<STR_LIT:state>' ] = state <EOL> if description : <EOL> data [ '<STR_LIT:description>' ] = description <EOL> if env : <EOL> data [ '<STR_LIT>' ] = { '<STR_LIT>' : env } <EOL> return self . _update ( '<STR_LIT>' % id , data ) <EOL> def list ( self , marker = '<STR_LIT>' , limit = None , sort_keys = '<STR_LIT>' , sort_dirs = '<STR_LIT>' ) : <EOL> qparams = { } <EOL> if marker : <EOL> qparams [ '<STR_LIT>' ] = marker <EOL> if limit : <EOL> qparams [ '<STR_LIT>' ] = limit <EOL> if sort_keys : <EOL> qparams [ '<STR_LIT>' ] = sort_keys <EOL> if sort_dirs : <EOL> qparams [ '<STR_LIT>' ] = sort_dirs <EOL> query_string = ( "<STR_LIT>" % urlparse . urlencode ( list ( qparams . items ( ) ) ) <EOL> if qparams else "<STR_LIT>" ) <EOL> return self . _list ( <EOL> '<STR_LIT>' % query_string , <EOL> response_key = '<STR_LIT>' , <EOL> ) <EOL> def get ( self , id ) : <EOL> self . _ensure_not_empty ( id = id ) <EOL> return self . _get ( '<STR_LIT>' % id ) <EOL> def delete ( self , id ) : <EOL> self . _ensure_not_empty ( id = id ) <EOL> self . _delete ( '<STR_LIT>' % id ) </s>
