Builds the url of the resource's index.

        :param resource: name of the resource or None
        :param kwargs: additional keyword arguments to build the url
        :return: url of the resource's index
349671
def get_index_url(self, resource=None, **kwargs):
        
        default_kwargs = self.default_kwargs_for_urls() \
            if resource == self.get_resource_name() else {}

        default_kwargs.update(kwargs)

        return self.get_full_url(
            self.app.reverse(
                '{}_index'.format(resource or self.get_resource_name()),
                **default_kwargs
            )
        )
1082709
def build(self, _name, *anons, **query):
        '''  '''
        builder = self.builder.get(_name)
        if not builder: raise RouteBuildError("No route with that name.", _name)
        try:
            for i, value in enumerate(anons): query['anon%d'%i] = value
            url = ''.join([f(query.pop(n)) if n else f for (n,f) in builder])
            return url if not query else url+'?'+urlencode(query)
        except KeyError:
            raise RouteBuildError('Missing URL argument: %r' % _e().args[0])
436414
def key_for_request(self, method, url, **kwargs):
        
        if method != 'get':
            return None

        return requests.Request(url=url, params=kwargs.get('params', {})).prepare().url
435882
def url_for(self, action='view', **kwargs):
        
        app = current_app._get_current_object() if current_app else None
        if app is not None and action in self.url_for_endpoints.get(app, {}):
            endpoint, paramattrs, _external = self.url_for_endpoints[app][action]
        else:
            try:
                endpoint, paramattrs, _external = self.url_for_endpoints[None][action]
            except KeyError:
                raise BuildError(action, kwargs, 'GET')
        params = {}
        for param, attr in list(paramattrs.items()):
            if isinstance(attr, tuple):
                # attr is a tuple containing:
                # 1. ('parent', 'name') --> self.parent.name
                # 2. ('**entity', 'name') --> kwargs['entity'].name
                if attr[0].startswith('**'):
                    item = kwargs.pop(attr[0][2:])
                    attr = attr[1:]
                else:
                    item = self
                for subattr in attr:
                    item = getattr(item, subattr)
                params[param] = item
            elif callable(attr):
                params[param] = attr(self)
            else:
                params[param] = getattr(self, attr)
        if _external is not None:
            params['_external'] = _external
        params.update(kwargs)  # Let kwargs override params

        # url_for from flask
        return url_for(endpoint, **params)
82854
def create(self, name, *args, **kwargs):
        
        resource_name = self._resource_name(name)
        log.info(
            "Creating {} '{}'...".format(self._model_name, resource_name))
        resource = self.collection.create(*args, name=resource_name, **kwargs)
        self._ids.add(resource.id)
        return resource
508310
def get_listing_api(self, resource):
        

        get_all_params = self.get_listing_parameters(resource)

        get_all_api = {
            'path': '/%s/' % resource.get_api_name(),
            'description': 'Operations on %s' % resource.model.__name__,
            'operations': [
                {
                    'httpMethod': 'GET',
                    'nickname': 'list%ss' % resource.model
                    .__name__,
                    'summary': 'Find %ss' % resource.model.__name__,
                    'parameters': get_all_params,
                }
            ]
        }

        return get_all_api
1002386
def get_url(self, name, view_name, kwargs, request):
        

        # Return None if the view name is not supplied
        if not view_name:
            return None

        # Return the hyperlink, or error if incorrectly configured.
        try:
            url = self.reverse(view_name, kwargs=kwargs, request=request)
        except NoReverseMatch:
            msg = (
                'Could not resolve URL for hyperlinked relationship using '
                'view name "%s". You may have failed to include the related '
                'model in your API, or incorrectly configured the '
                '`lookup_field` attribute on this field.'
            )
            raise ImproperlyConfigured(msg % view_name)

        if url is None:
            return None

        return Hyperlink(url, name)
691156
def _build_url(self, endpoint):
        
        try:
            path = self.endpoints[endpoint]
        except KeyError:
            msg = 'Unknown endpoint `{0}`'
            raise ValueError(msg.format(endpoint))
        absolute_url = urljoin(self.target, path)
        return absolute_url
223338
def _resource_prefix(self, resource=None):
        
        px = 'ELASTICSEARCH'
        if resource and config.DOMAIN[resource].get('elastic_prefix'):
            px = config.DOMAIN[resource].get('elastic_prefix')
        return px
1080595
def get_resource_url(resource):
    
    path = model_path(resource)
    parsed = list(urlparse.urlparse(path))
    parsed[1] = ""
    return urlparse.urlunparse(parsed)
752605
def _request(self, method, resource_uri, **kwargs):
        
        data = kwargs.get('data')
        response = method(self.API_BASE_URL + resource_uri,
                          json=data, headers=self.headers)
        response.raise_for_status()
        return response.json()
1286664
def _build_resource(self):
        """"""
        resource = {"name": self.name}

        if self.dns_name is not None:
            resource["dnsName"] = self.dns_name

        if self.description is not None:
            resource["description"] = self.description

        if self.name_server_set is not None:
            resource["nameServerSet"] = self.name_server_set

        return resource
373976
def url(self, version=None, **kwargs):
        """"""
        for url in self.urls(version):
            if [key for key in kwargs.keys() if not '{' + key + '}' in url]:
                continue

            return url.format(**kwargs)

        raise KeyError('URL that takes all provided parameters not found')
1296258
def url_for(self, resource, **values):
        """"""
        endpoint = resource.endpoint
        if self.blueprint:
            endpoint = '{0}.{1}'.format(self.blueprint.name, endpoint)
        return url_for(endpoint, **values)
344873
def set_related_method(self, resource, full_resource_url):
        
        method_name = self.get_method_name(resource, 'get')

        def get(self, **kwargs):
            return self._call_api_single_related_resource(
                resource, full_resource_url, method_name, **kwargs
            )

        def get_list(self, **kwargs):
            return self._call_api_many_related_resources(
                resource, full_resource_url, method_name, **kwargs
            )

        if isinstance(full_resource_url, list):
            setattr(
                self, method_name,
                types.MethodType(get_list, self)
            )
        else:
            setattr(
                self, method_name,
                types.MethodType(get, self)
            )
1304000
function(options){
      var url = options.apiUrl + (options.url ? options.url : '');

      if(options.params) {
        url += (url.indexOf('?') === -1 ? '?' : '&') + this.buildParams(options.params);
      }

      return url;
    }
328023
def url_to_resource(url, request=None):
    
    if request is None:
        request = get_current_request()
#    cnv = request.registry.getAdapter(request, IResourceUrlConverter)
    reg = get_current_registry()
    cnv = reg.getAdapter(request, IResourceUrlConverter)
    return cnv.url_to_resource(url)