#NEWLINE# def url_for( self , attr = None , filter_value = None , service_type = None , endpoint_type = 'publicURL' , service_name = None , volume_service_name = None ) : #NEWLINE# #INDENT# 'Fetches the public URL from the given service for\n        a particular endpoint attribute. If none given, returns\n        the first. See tests for sample service catalog.' #NEWLINE# matching_endpoints = [ ] #NEWLINE# if ( 'serviceCatalog' not in self . catalog [ 'access' ] ) : #NEWLINE# #INDENT# return None #NEWLINE# #UNINDENT# catalog = self . catalog [ 'access' ] [ 'serviceCatalog' ] #NEWLINE# for service in catalog : #NEWLINE# #INDENT# if ( service . get ( 'type' ) != service_type ) : #NEWLINE# #INDENT# continue #NEWLINE# #UNINDENT# endpoints = service [ 'endpoints' ] #NEWLINE# for endpoint in endpoints : #NEWLINE# #INDENT# if ( ( not filter_value ) or ( endpoint . get ( attr ) == filter_value ) ) : #NEWLINE# #INDENT# endpoint [ 'serviceName' ] = service . get ( 'name' ) #NEWLINE# matching_endpoints . append ( endpoint ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# if ( not matching_endpoints ) : #NEWLINE# #INDENT# raise exc . EndpointNotFound ( ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( len ( matching_endpoints ) > 1 ) : #NEWLINE# #INDENT# raise exc . AmbiguousEndpoints ( endpoints = matching_endpoints ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# return matching_endpoints [ 0 ] [ endpoint_type ]