<s> from mistralclient . api import base <EOL> from mistralclient import utils <EOL> class Workbook ( base . Resource ) : <EOL> resource_name = '<STR_LIT>' <EOL> class WorkbookManager ( base . ResourceManager ) : <EOL> resource_class = Workbook <EOL> def create ( self , definition ) : <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>' , <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 , base . extract_json ( resp , None ) ) <EOL> def update ( self , definition ) : <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>' , <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 , base . extract_json ( resp , None ) ) <EOL> def list ( self ) : <EOL> return self . _list ( '<STR_LIT>' , response_key = '<STR_LIT>' ) <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 ) <EOL> def validate ( self , definition ) : <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>' , <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 base . extract_json ( resp , None ) </s>
