#NEWLINE# def _get_ptg_servicechain_mapping( self , session , provider_ptg_id = None , consumer_ptg_id = None , tenant_id = None , servicechain_instance_id = None , provider_ptg_ids = None ) : #NEWLINE# #INDENT# with session . begin ( subtransactions = True ) : #NEWLINE# #INDENT# query = session . query ( PtgServiceChainInstanceMapping ) #NEWLINE# if provider_ptg_id : #NEWLINE# #INDENT# query = query . filter_by ( provider_ptg_id = provider_ptg_id ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if provider_ptg_ids : #NEWLINE# #INDENT# query = query . filter ( PtgServiceChainInstanceMapping . provider_ptg_id . in_ ( list ( provider_ptg_ids ) ) ) #NEWLINE# #UNINDENT# #UNINDENT# if consumer_ptg_id : #NEWLINE# #INDENT# query = query . filter_by ( consumer_ptg_id = consumer_ptg_id ) #NEWLINE# #UNINDENT# if servicechain_instance_id : #NEWLINE# #INDENT# query = query . filter_by ( servicechain_instance_id = servicechain_instance_id ) #NEWLINE# #UNINDENT# if tenant_id : #NEWLINE# #INDENT# query = query . filter_by ( consumer_ptg_id = tenant_id ) #NEWLINE# #UNINDENT# all = query . all ( ) #NEWLINE# return [ utils . DictClass ( [ ( 'provider_ptg_id' , consumer_ptg_id . provider_ptg_id ) , ( 'consumer_ptg_id' , x . consumer_ptg_id ) , ( 'servicechain_instance_id' , x . servicechain_instance_id ) , ( 'tenant_id' , x . tenant_id ) ] ) for x in all ]