Fetch json based on the element name
    First gets the href based on a search by name, then makes a
    second query to obtain the element json

    :method: GET
    :param str name: element name
    :return: :py:class:`smc.api.web.SMCResult`
972395
def fetch_json_by_name(name):
    
    result = fetch_meta_by_name(name)
    if result.href:
        result = fetch_json_by_href(result.href)
    return result
711555
def download_as_json(name):
    
    location = list(IPList.objects.filter(name))
    if location:
        iplist = location[0]
        return iplist.download(as_type='json')
135685
def fetch_json(self, method, url, data=None, expected_status_code=None):
        
        return self.fetch(method, url, data, expected_status_code).json()
982093
def fetch_object(self, obj_name, include_meta=False, chunk_size=None):
        
        return self.fetch(obj=obj_name, include_meta=include_meta,
                chunk_size=chunk_size)
880839
def deserialise(self, element_json: str) -> Element:
        

        return self.deserialise_dict(json.loads(element_json))
562111
def _get_key_values(self, name):
        
        results = {}

        for key, value in self.qs.items():
            try:
                if not key.startswith(name):
                    continue

                key_start = key.index('[') + 1
                key_end = key.index(']')
                item_key = key[key_start:key_end]

                if ',' in value:
                    item_value = value.split(',')
                else:
                    item_value = value
                results.update({item_key: item_value})
            except Exception:
                raise BadRequest("Parse error", source={'parameter': key})

        return results
1115988
def get_data_by_key(self, name):
        
        data = graceful_chain_get(self.json, "data")

        if data is None or name not in data:
            return {}

        if self.is_yaml(name):
            return yaml.load(data[name]) or {}
        return json.loads(data[name])
997464
def hget(self, name, key):
        
        with self.pipe as pipe:
            f = Future()
            res = pipe.hget(self.redis_key(name),
                            self.memberparse.encode(key))

            def cb():
                f.set(self._value_decode(key, res.result))

            pipe.on_execute(cb)
            return f
704468
def _get_json(self, model, space=None, rel_path=None, extra_params=None, get_all=None):
        
        # Only API.spaces and API.event should not provide
        # the `space argument
        if space is None and model not in (Space, Event):
            raise Exception(
                'In general, `API._get_json` should always '
                'be called with a `space` argument.'
            )

        if not extra_params:
            extra_params = {}

        # Handle pagination for requests carrying large amounts of data
        extra_params['page'] = extra_params.get('page', 1)

        # Generate the url to hit
        url = '{0}/{1}/{2}.json?{3}'.format(
            settings.API_ROOT_PATH,
            settings.API_VERSION,
            rel_path or model.rel_path,
            urllib.urlencode(extra_params),
        )

        # If the cache is being used and the url has been hit already
        if self.cache_responses and url in self.cache:
            response = self.cache[url]
        else:
            # Fetch the data
            headers = {
                'X-Api-Key': self.key,
                'X-Api-Secret': self.secret,
            }
            response = self.session.get(url=url, headers=headers)
            # If the cache is being used, update it
            if self.cache_responses:
                self.cache[url] = response

        if response.status_code == 200:  # OK
            results = []
            json_response = response.json()
            for obj in json_response:
                instance = model(data=obj)
                instance.api = self
                if space:
                    instance.space = space
                results.append(instance)
            # If it looks like there are more pages to fetch,
            # try and fetch the next one
            per_page = extra_params.get('per_page', None)
            if (
                get_all
                and per_page
                and len(json_response)
                and per_page == len(json_response)
            ):
                extra_params['page'] += 1
                results = results + self._get_json(model, space, rel_path, extra_params, get_all=get_all)
            return results
        elif response.status_code == 204:  # No Content
            return []
        else:  # Most likely a 404 Not Found
            raise Exception(
                'Code {0} returned from `{1}`. Response text: "{2}".'.format(
                    response.status_code,
                    url,
                    response.text
                )
            )
639864
def get_by_name(self, name):
        
        try:
            spec = self._dom.get('templates', {})[name]
        except KeyError:
            raise LagoMissingTemplateError(name, self._path)

        return Template(
            name=name,
            versions={
                ver_name: TemplateVersion(
                    name='%s:%s:%s' % (self.name, name, ver_name),
                    source=self._providers[ver_spec['source']],
                    handle=ver_spec['handle'],
                    timestamp=ver_spec['timestamp'],
                )
                for ver_name, ver_spec in spec['versions'].items()
            },
        )
352469
def abi_get_element_by_name(abi, name):
    
    if (abi and "abi" in abi):
        for a in abi["abi"]:
            if ("name" in a and a["name"] == name):
                return a
    return None
252651
def get(self, name):
        
        # do import here to keep soft dependency
        import requests

        # append base url to requested name
        url = urljoin(self.base_url, name)
        # fetch the data from the remote url
        response = requests.get(url)
        # return the bytes of the response
        return response.content
1261573
def cls_get_by_name(cls, name):
    
    try:
        val = getattr(cls, name)
    except AttributeError:
        for attr in (a for a in dir(cls) if not a.startswith('_')):
            try:
                val = getattr(cls, attr)
            except AttributeError:
                # Is known to happen.
                continue
            valname = getattr(val, 'name', None)
            if valname == name:
                return val
        else:
            raise ValueError('No {} with that name: {}'.format(
                cls.__name__,
                name,
            ))
    else:
        return val
1164496
def get_page_object_by_name(context, name):
    
    selected_object = None

    try:
        for obj_type in context['page']['content']:
            for obj in context['page']['content'][obj_type]:
                if obj.name == name:
                    selected_object = obj
                    break
        if selected_object is None:
            for obj_type in context['page']['content']:
                for obj in context['page']['ext_content'][obj_type]:
                    if obj.name == name:
                        selected_object = obj
                        break
    except TypeError:
        pass
    return selected_object
1100398
def get(self, name):
        
        parameter = next((p for p in self.parameters if p.name == name), None)
        if parameter is None:
            raise LookupError("Cannot find parameter '" + name + "'.")
        return parameter
1172814
def getJson(cls, url, method='GET', headers={}, data=None, socket=None, timeout=120):
        
        if not 'Content-Type' in headers:
            headers['Content-Type'] = ['application/json']

        body = yield cls().getBody(url, method, headers, data, socket, timeout)

        defer.returnValue(json.loads(body))
340715
def get(self, url):
        
        r = requests.get(self._format_url(url), headers=self.headers, timeout=TIMEOUT)
        self._check_response(r, 200)

        return r.json()