Read the high availability status and current leader instance of Vault.

        Supported methods:
            GET: /sys/leader. Produces: 200 application/json

        :return: The JSON response of the request.
        :rtype: dict
505537
def read_leader_status(self):
        
        api_path = '/v1/sys/leader'
        response = self._adapter.get(
            url=api_path,
        )
        return response.json()
770544
def read(path):
    """"""
    url = '{}/{}/{}'.format(settings.VAULT_BASE_URL.rstrip('/'),
                            settings.VAULT_BASE_SECRET_PATH.strip('/'),
                            path.lstrip('/'))

    headers = {'X-Vault-Token': settings.VAULT_ACCESS_TOKEN}
    resp = requests.get(url, headers=headers)
    if resp.ok:
        return resp.json()['data']
    else:
        log.error('Failed VAULT GET request: %s %s', resp.status_code, resp.text)
        raise Exception('Failed Vault GET request: {} {}'.format(resp.status_code, resp.text))
189923
def _get_response_json(self, res):
        

        try:
            error = res.json()
        except ValueError:
            error = {
                "message": "The API did not respond with JSON, but: {0}".format(res.text[:1000]),
                "error_code": "{0}".format(res.status_code)
            }
        return error
350481
def read_init_status(self):
        
        api_path = '/v1/sys/init'
        response = self._adapter.get(
            url=api_path,
        )
        return response.json()
854130
public EtcdLeaderStatsResponse getLeaderStats() {
    try {
      return new EtcdLeaderStatsRequest(this.client, retryHandler).send().get();
    } catch (IOException | EtcdException | EtcdAuthenticationException | TimeoutException e) {
      return null;
    }
  }
143403
def get_stats_summary_dict(self):
        
        uptime = time.time() - self._established_time \
            if self._established_time != 0 else -1
        return {
            stats.UPDATE_MSG_IN: self.get_count(PeerCounterNames.RECV_UPDATES),
            stats.UPDATE_MSG_OUT: self.get_count(
                PeerCounterNames.SENT_UPDATES
            ),
            stats.TOTAL_MSG_IN: self.total_msg_recv,
            stats.TOTAL_MSG_OUT: self.total_msg_sent,
            stats.FMS_EST_TRANS: self.get_count(
                PeerCounterNames.FSM_ESTB_TRANSITIONS
            ),
            stats.UPTIME: uptime
        }
89969
def _retrieve(self):
        
        url = "%s://%s:%d/manager/status" % (self._proto, self._host, self._port)
        params = {}
        params['XML'] = 'true'
        response = util.get_url(url, self._user, self._password, params)
        tree = ElementTree.XML(response)
        return tree
967649
def ToJson(self):
        
        json = super(AccountState, self).ToJson()
        addr = Crypto.ToAddress(self.ScriptHash)

        json['address'] = addr
        json['script_hash'] = str(self.ScriptHash)
        json['frozen'] = self.IsFrozen
        json['votes'] = [v.hex() for v in self.Votes]

        balances = []
        for key, value in self.Balances.items():
            balances.append({'asset': key.To0xString(), 'value': value.ToString()})

        json['balances'] = balances
        return json
540514
def ToJson(self):
        
        return {
            'assetId': self.AssetId.To0xString(),
            'assetType': self.AssetType,
            'name': self.GetName(),
            'amount': self.Amount.value,
            'available': self.Available.value,
            'precision': self.Precision,
            'fee': self.Fee.value,
            'address': self.FeeAddress.ToString(),
            'owner': self.Owner.ToString(),
            'admin': Crypto.ToAddress(self.Admin),
            'issuer': Crypto.ToAddress(self.Issuer),
            'expiration': self.Expiration,
            'is_frozen': self.IsFrozen
        }
991514
def get_current_status(self):
        """"""
        url = get_url("/remote/status.json")
        params = {"oauth": self._oauth_token, "csrf": self._csrf_token}
        r = self._request(url=url, params=params)
        return r.json()
862608
def ToJson(self):
        
        jsn = super(MinerTransaction, self).ToJson()
        jsn['nonce'] = self.Nonce
        return jsn
978752
def get_vault_connection():
    '''
    
    '''
    def _use_local_config():
        log.debug('Using Vault connection details from local config')
        try:
            if __opts__['vault']['auth']['method'] == 'approle':
                verify = __opts__['vault'].get('verify', None)
                if _selftoken_expired():
                    log.debug('Vault token expired. Recreating one')
                    # Requesting a short ttl token
                    url = '{0}/v1/auth/approle/login'.format(__opts__['vault']['url'])
                    payload = {'role_id': __opts__['vault']['auth']['role_id']}
                    if 'secret_id' in __opts__['vault']['auth']:
                        payload['secret_id'] = __opts__['vault']['auth']['secret_id']
                    response = requests.post(url, json=payload, verify=verify)
                    if response.status_code != 200:
                        errmsg = 'An error occured while getting a token from approle'
                        raise salt.exceptions.CommandExecutionError(errmsg)
                    __opts__['vault']['auth']['token'] = response.json()['auth']['client_token']
            if __opts__['vault']['auth']['method'] == 'wrapped_token':
                verify = __opts__['vault'].get('verify', None)
                if _wrapped_token_valid():
                    url = '{0}/v1/sys/wrapping/unwrap'.format(__opts__['vault']['url'])
                    headers = {'X-Vault-Token': __opts__['vault']['auth']['token']}
                    response = requests.post(url, headers=headers, verify=verify)
                    if response.status_code != 200:
                        errmsg = 'An error occured while unwrapping vault token'
                        raise salt.exceptions.CommandExecutionError(errmsg)
                    __opts__['vault']['auth']['token'] = response.json()['auth']['client_token']
            return {
                'url': __opts__['vault']['url'],
                'token': __opts__['vault']['auth']['token'],
                'verify': __opts__['vault'].get('verify', None)
            }
        except KeyError as err:
            errmsg = 'Minion has "vault" config section, but could not find key "{0}" within'.format(err.message)
            raise salt.exceptions.CommandExecutionError(errmsg)

    if 'vault' in __opts__ and __opts__.get('__role', 'minion') == 'master':
        if 'id' in __grains__:
            log.debug('Contacting master for Vault connection details')
            return _get_token_and_url_from_master()
        else:
            return _use_local_config()
    elif any((__opts__['local'], __opts__['file_client'] == 'local', __opts__['master_type'] == 'disable')):
        return _use_local_config()
    else:
        log.debug('Contacting master for Vault connection details')
        return _get_token_and_url_from_master()
1352556
def mpstatus_to_json(status):
    ''''''
    msg_keys = list(status.msgs.keys())
    data = '{'
    for key in msg_keys[:-1]:
        data += mavlink_to_json(status.msgs[key]) + ','
    data += mavlink_to_json(status.msgs[msg_keys[-1]])
    data += '}'
    return data
488911
def fetch(self, vault_client):
        """"""
        result = self.read(vault_client)
        if result:
            if isinstance(result, dict) and 'data' in result:
                self.existing = result['data']
            else:
                self.existing = result
        else:
            self.existing = None
1303649
def check_status(self, ignore=(), status=None):
        
        self.SHARD_CHECKS = [
            {'check_msg': 'Bad Core Count Check', 'f': self._check_shard_count},
            {'check_msg': 'Bad Shard Cluster Status', 'f': self._check_shard_status}
        ]
        if status is None:
            status = self.clusterstatus()
        out = {}
        for collection in status:
            out[collection] = {}
            out[collection]['coll_status'] = True  # Means it's fine
            out[collection]['coll_messages'] = []
            for shard in status[collection]:
                self.logger.debug("Checking {}/{}".format(collection, shard))
                s_dict = status[collection][shard]
                for check in self.SHARD_CHECKS:
                    if check['check_msg'] in ignore:
                        continue
                    res = check['f'](s_dict)
                    if not res:
                        out[collection]['coll_status'] = False
                        if check['check_msg'] not in out[collection]['coll_messages']:
                            out[collection]['coll_messages'].append(check['check_msg'])
                        self.logger.debug(s_dict)
        return out
1359303
def json(self):
        
        data = super(CalTRACKHourlyModel, self).json()
        data.update(
            {
                "occupancy_lookup": self.occupancy_lookup.to_json(orient="split"),
                "temperature_bins": self.temperature_bins.to_json(orient="split"),
            }
        )
        return data
362609
def get_status(self, json_status=None):
        
        if json_status:
            self.json_status = json_status

        if self.json_status not in AjaxResponseStatus.choices:
            raise ValueError(
                "Invalid status selected: '{}'".format(self.json_status))

        return self.json_status