<s> import six <EOL> from mistralclient . api import base <EOL> from mistralclient import utils <EOL> urlparse = six . moves . urllib . parse <EOL> class Action ( base . Resource ) : <EOL> resource_name = '<STR_LIT>' <EOL> class ActionManager ( base . ResourceManager ) : <EOL> resource_class = Action <EOL> def create ( self , definition , scope = '<STR_LIT>' ) : <EOL> self . _ensure_not_empty ( definition = definition ) <EOL> definition = utils . get_contents_if_file ( definition ) <EOL> resp = self . client . http_client . post ( <EOL> '<STR_LIT>' % scope , <EOL> definition , <EOL> headers = { '<STR_LIT>' : '<STR_LIT>' } <EOL> ) <EOL> if resp . status_code != <NUM_LIT> : <EOL> self . _raise_api_exception ( resp ) <EOL> return [ self . resource_class ( self , resource_data ) <EOL> for resource_data in base . extract_json ( resp , '<STR_LIT>' ) ] <EOL> def update ( self , definition , scope = '<STR_LIT>' ) : <EOL> self . _ensure_not_empty ( definition = definition ) <EOL> definition = utils . get_contents_if_file ( definition ) <EOL> resp = self . client . http_client . put ( <EOL> '<STR_LIT>' % scope , <EOL> definition , <EOL> headers = { '<STR_LIT>' : '<STR_LIT>' } <EOL> ) <EOL> if resp . status_code != <NUM_LIT:200> : <EOL> self . _raise_api_exception ( resp ) <EOL> return [ self . resource_class ( self , resource_data ) <EOL> for resource_data in base . extract_json ( resp , '<STR_LIT>' ) ] <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 , name ) : <EOL> self . _ensure_not_empty ( name = name ) <EOL> return self . _get ( '<STR_LIT>' % name ) <EOL> def delete ( self , name ) : <EOL> self . _ensure_not_empty ( name = name ) <EOL> self . _delete ( '<STR_LIT>' % name ) </s>
