<s> from gbpservice . network . neutronv2 import client <EOL> class API ( object ) : <EOL> """<STR_LIT>""" <EOL> def _create_resource ( self , context , resource , attrs ) : <EOL> action = '<STR_LIT>' + resource <EOL> neutron = client . get_client ( context ) <EOL> obj_creator = getattr ( neutron , action ) <EOL> return obj_creator ( attrs ) [ resource ] <EOL> def _show_resource ( self , context , resource , resource_id ) : <EOL> action = '<STR_LIT>' + resource <EOL> neutron = client . get_client ( context ) <EOL> obj_method = getattr ( neutron , action ) <EOL> return obj_method ( resource_id ) [ resource ] <EOL> def _list_resources ( self , context , resource , filters = None ) : <EOL> filters = filters or { } <EOL> resources = resource + '<STR_LIT:s>' <EOL> action = '<STR_LIT>' + resources <EOL> neutron = client . get_client ( context ) <EOL> obj_lister = getattr ( neutron , action ) <EOL> return obj_lister ( ** filters ) [ resources ] <EOL> def _update_resource ( self , context , resource , resource_id , attrs ) : <EOL> action = '<STR_LIT>' + resource <EOL> neutron = client . get_client ( context ) <EOL> obj_updater = getattr ( neutron , action ) <EOL> return obj_updater ( resource_id , attrs ) [ resource ] <EOL> def _delete_resource ( self , context , resource , resource_id ) : <EOL> action = '<STR_LIT>' + resource <EOL> neutron = client . get_client ( context ) <EOL> obj_deleter = getattr ( neutron , action ) <EOL> obj_deleter ( resource_id ) <EOL> def create_network ( self , context , network ) : <EOL> return self . _create_resource ( context , '<STR_LIT>' , network ) <EOL> def show_network ( self , context , net_id ) : <EOL> return self . _show_resource ( context , '<STR_LIT>' , net_id ) <EOL> def list_networks ( self , context , filters = None ) : <EOL> filters = filters or { } <EOL> return self . _list_resources ( context , '<STR_LIT>' , filters ) <EOL> def update_network ( self , context , net_id , network ) : <EOL> return self . _update_resource ( context , '<STR_LIT>' , net_id , network ) <EOL> def delete_network ( self , context , net_id ) : <EOL> self . _delete_resource ( context , '<STR_LIT>' , net_id ) <EOL> def create_subnet ( self , context , subnet ) : <EOL> return self . _create_resource ( context , '<STR_LIT>' , subnet ) <EOL> def show_subnet ( self , context , subnet_id ) : <EOL> return self . _show_resource ( context , '<STR_LIT>' , subnet_id ) <EOL> def list_subnets ( self , context , filters = None ) : <EOL> filters = filters or { } <EOL> return self . _list_resources ( context , '<STR_LIT>' , filters ) <EOL> def update_subnet ( self , context , subnet_id , subnet ) : <EOL> return self . _update_resource ( context , '<STR_LIT>' , subnet_id , subnet ) <EOL> def delete_subnet ( self , context , subnet_id ) : <EOL> self . _delete_resource ( context , '<STR_LIT>' , subnet_id ) <EOL> def create_port ( self , context , port ) : <EOL> return self . _create_resource ( context , '<STR_LIT:port>' , port ) <EOL> def show_port ( self , context , port_id ) : <EOL> return self . _show_resource ( context , '<STR_LIT:port>' , port_id ) <EOL> def list_ports ( self , context , filters = None ) : <EOL> filters = filters or { } <EOL> return self . _list_resources ( context , '<STR_LIT:port>' , filters ) <EOL> def update_port ( self , context , port_id , port ) : <EOL> return self . _update_resource ( context , '<STR_LIT:port>' , port_id , port ) <EOL> def delete_port ( self , context , port_id ) : <EOL> self . _delete_resource ( context , '<STR_LIT:port>' , port_id ) <EOL> def create_security_group ( self , context , sg ) : <EOL> return self . _create_resource ( context , '<STR_LIT>' , sg ) <EOL> def show_security_group ( self , context , sg_id ) : <EOL> return self . _show_resource ( context , '<STR_LIT>' , sg_id ) <EOL> def list_security_groups ( self , context , filters = None ) : <EOL> filters = filters or { } <EOL> return self . _list_resources ( context , '<STR_LIT>' , filters ) <EOL> def update_security_group ( self , context , sg_id , sg ) : <EOL> return self . _update_resource ( context , '<STR_LIT>' , sg_id , sg ) <EOL> def delete_security_group ( self , context , sg_id ) : <EOL> self . _delete_resource ( context , '<STR_LIT>' , sg_id ) <EOL> def create_security_group_rule ( self , context , rule ) : <EOL> return self . _create_resource ( context , '<STR_LIT>' , rule ) <EOL> def show_security_group_rule ( self , context , rule_id ) : <EOL> return self . _show_resource ( context , '<STR_LIT>' , rule_id ) <EOL> def list_security_group_rules ( self , context , filters = None ) : <EOL> filters = filters or { } <EOL> return self . _list_resources ( context , '<STR_LIT>' , filters ) <EOL> def delete_security_group_rule ( self , context , rule_id ) : <EOL> self . _delete_resource ( context , '<STR_LIT>' , rule_id ) <EOL> def create_router ( self , context , router ) : <EOL> return self . _create_resource ( context , '<STR_LIT>' , router ) <EOL> def show_router ( self , context , router_id ) : <EOL> return self . _show_resource ( context , '<STR_LIT>' , router_id ) <EOL> def list_routers ( self , context , filters = None ) : <EOL> filters = filters or { } <EOL> return self . _list_resources ( context , '<STR_LIT>' , filters ) <EOL> def update_router ( self , context , router_id , router ) : <EOL> return self . _update_resource ( context , '<STR_LIT>' , router_id , router ) <EOL> def delete_router ( self , context , router_id ) : <EOL> self . _delete_resource ( context , '<STR_LIT>' , router_id ) <EOL> def add_router_interface ( self , context , router_id , interface ) : <EOL> return client . get_client ( context ) . add_interface_router ( router_id , <EOL> interface ) <EOL> def remove_router_interface ( self , context , router_id , interface ) : <EOL> return client . get_client ( context ) . remove_interface_router ( router_id , <EOL> interface ) </s>
