<s> import json <EOL> import six <EOL> from mistralclient . api import base <EOL> from mistralclient import utils <EOL> class Environment ( base . Resource ) : <EOL> resource_name = '<STR_LIT>' <EOL> def _set_attributes ( self ) : <EOL> """<STR_LIT>""" <EOL> for k , v in self . _data . items ( ) : <EOL> if k == '<STR_LIT>' and isinstance ( v , six . string_types ) : <EOL> v = json . loads ( v ) <EOL> try : <EOL> setattr ( self , k , v ) <EOL> except AttributeError : <EOL> pass <EOL> class EnvironmentManager ( base . ResourceManager ) : <EOL> resource_class = Environment <EOL> def create ( self , ** kwargs ) : <EOL> if '<STR_LIT:file>' in kwargs : <EOL> file = kwargs [ '<STR_LIT:file>' ] <EOL> kwargs = utils . load_content ( utils . get_contents_if_file ( file ) ) <EOL> self . _ensure_not_empty ( name = kwargs . get ( '<STR_LIT:name>' , None ) , <EOL> variables = kwargs . get ( '<STR_LIT>' , None ) ) <EOL> if isinstance ( kwargs [ '<STR_LIT>' ] , dict ) : <EOL> kwargs [ '<STR_LIT>' ] = json . dumps ( kwargs [ '<STR_LIT>' ] ) <EOL> return self . _create ( '<STR_LIT>' , kwargs ) <EOL> def update ( self , ** kwargs ) : <EOL> if '<STR_LIT:file>' in kwargs : <EOL> file = kwargs [ '<STR_LIT:file>' ] <EOL> kwargs = utils . load_content ( utils . get_contents_if_file ( file ) ) <EOL> name = kwargs . get ( '<STR_LIT:name>' , None ) <EOL> self . _ensure_not_empty ( name = name ) <EOL> if kwargs . get ( '<STR_LIT>' ) and isinstance ( kwargs [ '<STR_LIT>' ] , dict ) : <EOL> kwargs [ '<STR_LIT>' ] = json . dumps ( kwargs [ '<STR_LIT>' ] ) <EOL> return self . _update ( '<STR_LIT>' , kwargs ) <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 ) </s>
