<s> from magnumclient . common import base <EOL> from magnumclient . common import utils <EOL> from magnumclient import exceptions <EOL> CREATION_ATTRIBUTES = [ '<STR_LIT:name>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' ] <EOL> class BayModel ( base . Resource ) : <EOL> def __repr__ ( self ) : <EOL> return "<STR_LIT>" % self . _info <EOL> class BayModelManager ( base . Manager ) : <EOL> resource_class = BayModel <EOL> @ staticmethod <EOL> def _path ( id = None ) : <EOL> return '<STR_LIT>' % id if id else '<STR_LIT>' <EOL> def list ( self , limit = None , marker = None , sort_key = None , <EOL> sort_dir = None , detail = False ) : <EOL> """<STR_LIT>""" <EOL> if limit is not None : <EOL> limit = int ( limit ) <EOL> filters = utils . common_filters ( marker , limit , sort_key , sort_dir ) <EOL> path = '<STR_LIT>' <EOL> if detail : <EOL> path += '<STR_LIT>' <EOL> if filters : <EOL> path += '<STR_LIT:?>' + '<STR_LIT:&>' . join ( filters ) <EOL> if limit is None : <EOL> return self . _list ( self . _path ( path ) , "<STR_LIT>" ) <EOL> else : <EOL> return self . _list_pagination ( self . _path ( path ) , "<STR_LIT>" , <EOL> limit = limit ) <EOL> def get ( self , id ) : <EOL> try : <EOL> return self . _list ( self . _path ( id ) ) [ <NUM_LIT:0> ] <EOL> except IndexError : <EOL> return None <EOL> def create ( self , ** kwargs ) : <EOL> new = { } <EOL> for ( key , value ) in kwargs . items ( ) : <EOL> if key in CREATION_ATTRIBUTES : <EOL> new [ key ] = value <EOL> else : <EOL> raise exceptions . InvalidAttribute ( <EOL> "<STR_LIT>" % "<STR_LIT:U+002C>" . join ( CREATION_ATTRIBUTES ) ) <EOL> return self . _create ( self . _path ( ) , new ) <EOL> def delete ( self , id ) : <EOL> return self . _delete ( self . _path ( id ) ) <EOL> def update ( self , id , patch ) : <EOL> return self . _update ( self . _path ( id ) , patch ) </s>
