<s> from openstack . object_store . v1 import account as _account <EOL> from openstack . object_store . v1 import container as _container <EOL> from openstack . object_store . v1 import obj as _obj <EOL> from openstack import proxy <EOL> class Proxy ( proxy . BaseProxy ) : <EOL> def get_account_metadata ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . _head ( _account . Account ) <EOL> def set_account_metadata ( self , ** metadata ) : <EOL> """<STR_LIT>""" <EOL> account = self . _get_resource ( _account . Account , None ) <EOL> account . set_metadata ( self . session , metadata ) <EOL> def delete_account_metadata ( self , keys ) : <EOL> """<STR_LIT>""" <EOL> account = self . _get_resource ( _account . Account , None ) <EOL> account . delete_metadata ( self . session , keys ) <EOL> def containers ( self , ** query ) : <EOL> """<STR_LIT>""" <EOL> return _container . Container . list ( self . session , ** query ) <EOL> def create_container ( self , ** attrs ) : <EOL> """<STR_LIT>""" <EOL> return self . _create ( _container . Container , ** attrs ) <EOL> def delete_container ( self , container , ignore_missing = True ) : <EOL> """<STR_LIT>""" <EOL> self . _delete ( _container . Container , container , <EOL> ignore_missing = ignore_missing ) <EOL> def get_container_metadata ( self , container ) : <EOL> """<STR_LIT>""" <EOL> return self . _head ( _container . Container , container ) <EOL> def set_container_metadata ( self , container , ** metadata ) : <EOL> """<STR_LIT>""" <EOL> res = self . _get_resource ( _container . Container , container ) <EOL> res . set_metadata ( self . session , metadata ) <EOL> def delete_container_metadata ( self , container , keys ) : <EOL> """<STR_LIT>""" <EOL> res = self . _get_resource ( _container . Container , container ) <EOL> res . delete_metadata ( self . session , keys ) <EOL> def objects ( self , container , ** query ) : <EOL> """<STR_LIT>""" <EOL> container = _container . Container . from_id ( container ) <EOL> objs = _obj . Object . list ( self . session , <EOL> path_args = { "<STR_LIT>" : container . name } , <EOL> ** query ) <EOL> for obj in objs : <EOL> obj . container = container . name <EOL> yield obj <EOL> def _get_container_name ( self , obj , container ) : <EOL> if isinstance ( obj , _obj . Object ) : <EOL> if obj . container is not None : <EOL> return obj . container <EOL> if container is not None : <EOL> container = _container . Container . from_id ( container ) <EOL> return container . name <EOL> raise ValueError ( "<STR_LIT>" ) <EOL> def get_object ( self , obj , container = None ) : <EOL> """<STR_LIT>""" <EOL> container_name = self . _get_container_name ( obj , container ) <EOL> return self . _get ( _obj . Object , obj , <EOL> path_args = { "<STR_LIT>" : container_name } ) <EOL> def download_object ( self , obj , container = None , path = None ) : <EOL> """<STR_LIT>""" <EOL> with open ( path , "<STR_LIT:w>" ) as out : <EOL> out . write ( self . get_object ( obj , container ) ) <EOL> def upload_object ( self , ** attrs ) : <EOL> """<STR_LIT>""" <EOL> container = attrs . pop ( "<STR_LIT>" , None ) <EOL> container_name = self . _get_container_name ( None , container ) <EOL> return self . _create ( _obj . Object , <EOL> path_args = { "<STR_LIT>" : container_name } , ** attrs ) <EOL> def copy_object ( self ) : <EOL> """<STR_LIT>""" <EOL> raise NotImplementedError <EOL> def delete_object ( self , obj , ignore_missing = True , container = None ) : <EOL> """<STR_LIT>""" <EOL> container_name = self . _get_container_name ( obj , container ) <EOL> self . _delete ( _obj . Object , obj , ignore_missing = ignore_missing , <EOL> path_args = { "<STR_LIT>" : container_name } ) <EOL> def get_object_metadata ( self , obj , container = None ) : <EOL> """<STR_LIT>""" <EOL> container_name = self . _get_container_name ( obj , container ) <EOL> return self . _head ( _obj . Object , obj , <EOL> path_args = { "<STR_LIT>" : container_name } ) <EOL> def set_object_metadata ( self , obj , container = None , ** metadata ) : <EOL> """<STR_LIT>""" <EOL> container_name = self . _get_container_name ( obj , container ) <EOL> res = self . _get_resource ( _obj . Object , obj , <EOL> path_args = { "<STR_LIT>" : container_name } ) <EOL> res . set_metadata ( self . session , metadata ) <EOL> def delete_object_metadata ( self , obj , container = None , keys = None ) : <EOL> """<STR_LIT>""" <EOL> container_name = self . _get_container_name ( obj , container ) <EOL> res = self . _get_resource ( _obj . Object , obj , <EOL> path_args = { "<STR_LIT>" : container_name } ) <EOL> res . delete_metadata ( self . session , keys ) </s>
