File: status.py

package info (click to toggle)
python-consul 1.6.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 484 kB
  • sloc: python: 2,858; makefile: 197
file content (25 lines) | stat: -rw-r--r-- 674 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
from consul.callback import CB


class Status:
    """
    The Status endpoints are used to get information about the status
     of the Consul cluster.
    """

    def __init__(self, agent) -> None:
        self.agent = agent

    def leader(self):
        """
        This endpoint is used to get the Raft leader for the datacenter
        in which the agent is running.
        """
        return self.agent.http.get(CB.json(), "/v1/status/leader")

    def peers(self):
        """
        This endpoint retrieves the Raft peers for the datacenter in which
        the the agent is running.
        """
        return self.agent.http.get(CB.json(), "/v1/status/peers")