Get the endpoint uri according to message header entry with fallback default uri.
516075
public String resolveEndpointUri(Message message, String defaultName) {
        Map<String, Object> headers = message.getHeaders();

        String destinationName;
        if (headers.containsKey(DESTINATION_HEADER_NAME)) {
            destinationName = headers.get(DESTINATION_HEADER_NAME).toString();
        } else if (StringUtils.hasText(defaultName)) {
            destinationName = defaultName;
        } else {
            destinationName = defaultDestinationName;
        }

        if (destinationName == null) {
            throw new CitrusRuntimeException("Unable to resolve dynamic destination name! Neither header entry '" +
                    DESTINATION_HEADER_NAME + "' nor default destination name is set");
        }

        return destinationName;
    }
526543
def endpoint(ctx, config, verbose):
    """"""
    if ctx.invoked_subcommand is None:
        # TODO default_endpoint = config.get('core', {}).get('default')
        for endpoint, values in config.get('endpoints', {}).items():
            # TODO is_default = default_endpoint == endpoint
            if not verbose:
                click.echo(endpoint)
            else:
                click.echo(
                    '{endpoint}\t{url}'.format(
                        endpoint=endpoint, url=values.get('url', '')
                    )
                )
1216850
public Set<String> endpointUris() {
        try {
            // we must use reflection for now until Camel supports the getEndpoints() method
            // https://issues.apache.org/jira/browse/CAMEL-3644
            // ...
            // the above is no longer valid since Camel 2.7.0
            List<CamelEndpointFactoryBean> endpoints = contextElement.getEndpoints();
            List<String> uris = new LinkedList<String>();
            if (endpoints != null) {
                for (CamelEndpointFactoryBean cefb : endpoints) {
                    uris.add(cefb.getUri());
                }
            }

            // lets detect any drools endpoints...
            List<Node> sessions = nodesByNamespace(doc, droolsNamespace.getURI(), "ksession");
            if (sessions != null) {
                for (Node session : sessions) {
                    if (session instanceof Element) {
                        Element e = (Element) session;
                        String node = e.getAttributeValue("node");
                        String sid = e.getAttributeValue("id");
                        if (node != null && node.length() > 0 && sid != null && sid.length() > 0) {
                            String du = "drools:" + node + "/" + sid;
                            boolean exists = false;
                            for (String uri : uris) {
                                if (uri.startsWith(du)) {
                                    exists = true;
                                }
                            }
                            if (!exists) {
                                uris.add(du);
                            }
                        }
                    }
                }
            }
            return new TreeSet<String>(uris);
        } catch (Exception e) {
            LOG.error(e.getMessage(), e);
            return new HashSet<String>();
        }
    }
551304
def get_url endpoint, method
      api = @wp_api ? 'wp-json' : 'wc-api'
      url = @url
      url = "#{url}/" unless url.end_with? "/"
      url = "#{url}#{api}/#{@version}/#{endpoint}"

      @is_ssl ? url : oauth_url(url, method)
    end
209057
public String[] getEndpointInfo(InetAddress endpoint)
    {
        String[] rawEndpointInfo = getRawEndpointInfo(endpoint);
        if (rawEndpointInfo == null)
            throw new RuntimeException("Unknown host " + endpoint + " with no default configured");
        return rawEndpointInfo;
    }
1312292
def as_url(self):
        '''
        
        '''
        if '' in self._scope:
            return self._finalize().as_url

        if not self._is_endpoint:
            raise UrlBuildingError('Not an endpoint {}'.format(repr(self)))

        if self._ready:
            path, host = self._path, self._host
        else:
            return self().as_url

        # XXX there is a little mess with `domain` and `host` terms
        if ':' in host:
            domain, port = host.split(':')
        else:
            domain = host
            port = None

        if self._bound_env:
            request = self._bound_env.request
            scheme_port = {'http': '80',
                           'https': '443'}.get(request.scheme, '80')

            # Domain to compare with the result of build.
            # If both values are equal, domain part can be hidden from result.
            # Take it from route_state, not from env.request, because
            # route_state contains domain values with aliased replaced by their
            # primary value
            primary_domain = self._bound_env._route_state.primary_domain
            host_split = request.host.split(':')
            request_domain = host_split[0]
            request_port = host_split[1] if len(host_split) > 1 else scheme_port
            port = port or request_port

            return URL(path, host=domain or request_domain,
                       port=port if port != scheme_port else None,
                       scheme=request.scheme, fragment=self._fragment,
                       show_host=host and (domain != primary_domain \
                                           or port != request_port))
        return URL(path, host=domain, port=port,
                   fragment=self._fragment, show_host=True)
539016
private static String getHost(final String endpoint) {
        String host = URI.create(endpoint).getHost();
        if (host == null) {
            host = URI.create("http://" + endpoint).getHost();
        }
        return host;
    }
21818
def get_endpoint_name(self, headers):
        
        # Headers are case-insensitive. Probably a better way to do this.
        match = headers.get('x-amz-target') or headers.get('X-Amz-Target')
        if match:
            return match.split(".")[1]
841470
def _get_valid_endpoint(resp, name, entry_type):
        
        catalog = resp.get('token', {}).get('catalog', [])
        for entry in catalog:
            if (
                entry.get('name')
                and entry.get('type')
                and entry.get('name') == name
                and entry.get('type') == entry_type
            ):
                # Collect any endpoints on the public or internal interface
                valid_endpoints = {}
                for ep in entry.get('endpoints'):
                    interface = ep.get('interface', '')
                    if interface in ['public', 'internal']:
                        valid_endpoints[interface] = ep.get('url')

                if valid_endpoints:
                    # Favor public endpoints over internal
                    return valid_endpoints.get('public', valid_endpoints.get('internal'))

        return None
573451
public EndpointRef getSourceEndpoint() {
        return new EndpointRef(TagUtil.getUriPath(topSpan.getTags()), topSpan.getOperationName(), false);
    }
660418
private synchronized String getMatchingURI(String incomingURI) {
        String[] incomingURIParts = incomingURI.split("/");

        ArrayList<String[]> tockenizedEndpoints = new ArrayList<String[]>();
        for (String endpointURI : serverEndpointConfigMap.keySet()) {
            // Since the endpoint paths are either relative URIs or URI templates level 1, the paths do not match if they 
            // do not have the same number of segments, using ’/’ as the separator.
            if (incomingURIParts.length == endpointURI.split("/").length) {
                tockenizedEndpoints.add(endpointURI.split("/"));
            }
        }

        /**
         * For each segment of the incoming uri, compare the corresponding segment of every endpoint uri. If matched (exact match or variable {} match)
         * add that endpoint to the list of matchedURI. Move to next segment of the incoming uri and do the same match. At the end of this loop
         * we have list of possible matched endpoints for the incoming URI
         * For e.g if the incoming uri = a/b/d and endpoints are /{var}/b/d, /a/x/y, {var}/b/{var}, /a/{var}/{var}, /{var}/{var}/{var} then
         * possible matchedURIs are /{var}/b/d, {var}/b/{var}, /a/{var}/{var}, /{var}/{var}/{var}
         */
        for (int i = 1; i < incomingURIParts.length; i++) { // start with i=1 skipping the first part because first part of split("/") for /../../.. is always an empty string 
            ArrayList<String[]> matchedURIs = new ArrayList<String[]>();
            // for a each segment in incomingURI, check the corresponding segment of every endpoint.
            for (int j = 0; j < tockenizedEndpoints.size(); j++) {
                String[] tockens = tockenizedEndpoints.get(j);
                if (incomingURIParts[i].equals(tockens[i])) {
                    matchedURIs.add(tockenizedEndpoints.get(j));
                }
                if (tockens[i].startsWith("{") && (tockens[i].endsWith("}"))) {
                    matchedURIs.add(tockenizedEndpoints.get(j));
                }
            }
            tockenizedEndpoints.clear();
            tockenizedEndpoints.addAll(matchedURIs);
        }

        //sort matched endpoints in order of preference from left to right for exact match at each segment giving a higher precedence 
        if (tockenizedEndpoints.size() > 1) {
            Collections.sort(tockenizedEndpoints, COMPARATOR);
        }

        String[] tockenizedEndpoint = null;
        if (!tockenizedEndpoints.isEmpty()) {
            tockenizedEndpoint = tockenizedEndpoints.get(0); //best match is always the top element in the sorted list
        }

        if (tockenizedEndpoint != null) {
            return unTockenizeEp(tockenizedEndpoint);
        } else {
            return null;
        }
    }
1186011
def get_endpoint(brain_or_object, default=DEFAULT_ENDPOINT):
    
    portal_type = get_portal_type(brain_or_object)
    resource = portal_type_to_resource(portal_type)

    # Try to get the right namespaced endpoint
    endpoints = router.DefaultRouter.view_functions.keys()
    if resource in endpoints:
        return resource  # exact match
    endpoint_candidates = filter(lambda e: e.endswith(resource), endpoints)
    if len(endpoint_candidates) == 1:
        # only return the namespaced endpoint, if we have an exact match
        return endpoint_candidates[0]

    return default
1298922
def get_endpoint_server_root(self):
        
        parsed = urlparse(self._endpoint)
        root = parsed.scheme + "://" + parsed.hostname

        if parsed.port is not None:
            root += ":" + unicode(parsed.port)

        return root
337694
def endpoint(request):
    """"""
    # pylint: disable=too-many-return-statements,too-many-branches

    # In order to 'hide' the endpoint, all non-POST requests should return
    # the site's default HTTP404
    if request.method != 'POST':
        raise Http404

    # If necessary, check that the topic is correct
    if hasattr(settings, 'BOUNCY_TOPIC_ARN'):
        # Confirm that the proper topic header was sent
        if 'HTTP_X_AMZ_SNS_TOPIC_ARN' not in request.META:
            return HttpResponseBadRequest('No TopicArn Header')

        # Check to see if the topic is in the settings
        # Because you can have bounces and complaints coming from multiple
        # topics, BOUNCY_TOPIC_ARN is a list
        if (not request.META['HTTP_X_AMZ_SNS_TOPIC_ARN']
                in settings.BOUNCY_TOPIC_ARN):
            return HttpResponseBadRequest('Bad Topic')

    # Load the JSON POST Body
    if isinstance(request.body, str):
        # requests return str in python 2.7
        request_body = request.body
    else:
        # and return bytes in python 3.4
        request_body = request.body.decode()
    try:
        data = json.loads(request_body)
    except ValueError:
        logger.warning('Notification Not Valid JSON: {}'.format(request_body))
        return HttpResponseBadRequest('Not Valid JSON')

    # Ensure that the JSON we're provided contains all the keys we expect
    # Comparison code from http://stackoverflow.com/questions/1285911/
    if not set(VITAL_NOTIFICATION_FIELDS) <= set(data):
        logger.warning('Request Missing Necessary Keys')
        return HttpResponseBadRequest('Request Missing Necessary Keys')

    # Ensure that the type of notification is one we'll accept
    if not data['Type'] in ALLOWED_TYPES:
        logger.info('Notification Type Not Known %s', data['Type'])
        return HttpResponseBadRequest('Unknown Notification Type')

    # Confirm that the signing certificate is hosted on a correct domain
    # AWS by default uses sns.{region}.amazonaws.com
    # On the off chance you need this to be a different domain, allow the
    # regex to be overridden in settings
    domain = urlparse(data['SigningCertURL']).netloc
    pattern = getattr(
        settings, 'BOUNCY_CERT_DOMAIN_REGEX', r"sns.[a-z0-9\-]+.amazonaws.com$"
    )
    if not re.search(pattern, domain):
        logger.warning(
            'Improper Certificate Location %s', data['SigningCertURL'])
        return HttpResponseBadRequest('Improper Certificate Location')

    # Verify that the notification is signed by Amazon
    if (getattr(settings, 'BOUNCY_VERIFY_CERTIFICATE', True)
            and not verify_notification(data)):
        logger.error('Verification Failure %s', )
        return HttpResponseBadRequest('Improper Signature')

    # Send a signal to say a valid notification has been received
    signals.notification.send(
        sender='bouncy_endpoint', notification=data, request=request)

    # Handle subscription-based messages.
    if data['Type'] == 'SubscriptionConfirmation':
        # Allow the disabling of the auto-subscription feature
        if not getattr(settings, 'BOUNCY_AUTO_SUBSCRIBE', True):
            raise Http404
        return approve_subscription(data)
    elif data['Type'] == 'UnsubscribeConfirmation':
        # We won't handle unsubscribe requests here. Return a 200 status code
        # so Amazon won't redeliver the request. If you want to remove this
        # endpoint, remove it either via the API or the AWS Console
        logger.info('UnsubscribeConfirmation Not Handled')
        return HttpResponse('UnsubscribeConfirmation Not Handled')

    try:
        message = json.loads(data['Message'])
    except ValueError:
        # This message is not JSON. But we need to return a 200 status code
        # so that Amazon doesn't attempt to deliver the message again
        logger.info('Non-Valid JSON Message Received')
        return HttpResponse('Message is not valid JSON')

    return process_message(message, data)
122830
private static EndPointInfo defineEndPoint(EndPointMgr epm, String name, String[] config) {
        String host = null;
        String port = null;
        for (int i = 0; i < config.length; i++) {
            String key = ChannelUtils.extractKey(config[i]);
            if ("host".equalsIgnoreCase(key)) {
                host = ChannelUtils.extractValue(config[i]);
            } else if ("port".equalsIgnoreCase(key)) {
                port = ChannelUtils.extractValue(config[i]);
            }
        }
        return epm.defineEndPoint(name, host, Integer.parseInt(port));
    }
847250
def get_url_endpoint(self):
        
        endpoint = self.url
        if self.type not in ('Hypermap:WorldMap',):
            endpoint = 'registry/%s/layer/%s/map/wmts/1.0.0/WMTSCapabilities.xml' % (
                self.catalog.slug,
                self.id
            )
        return endpoint
939402
public HttpMessage uri(final String requestUri) {
        setHeader(DynamicEndpointUriResolver.ENDPOINT_URI_HEADER_NAME, requestUri);
        setHeader(HttpMessageHeaders.HTTP_REQUEST_URI, requestUri);
        return this;
    }