{"id":13651693,"url":"https://github.com/gmr/consulate","last_synced_at":"2025-04-04T19:11:32.696Z","repository":{"id":16572686,"uuid":"19326700","full_name":"gmr/consulate","owner":"gmr","description":"Python client for the Consul HTTP API","archived":false,"fork":false,"pushed_at":"2024-07-04T16:13:47.000Z","size":334,"stargazers_count":342,"open_issues_count":21,"forks_count":100,"subscribers_count":21,"default_branch":"master","last_synced_at":"2024-10-14T17:13:04.913Z","etag":null,"topics":["hacktoberfest"],"latest_commit_sha":null,"homepage":"http://consulate.readthedocs.org","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/gmr.png","metadata":{"files":{"readme":"README.rst","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2014-04-30T20:44:49.000Z","updated_at":"2024-08-29T09:50:07.000Z","dependencies_parsed_at":"2024-10-25T18:43:13.579Z","dependency_job_id":"e3d38082-8a28-4b83-9899-0381e6b5a97b","html_url":"https://github.com/gmr/consulate","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gmr%2Fconsulate","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gmr%2Fconsulate/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gmr%2Fconsulate/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gmr%2Fconsulate/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gmr","download_url":"https://codeload.github.com/gmr/consulate/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247234922,"owners_count":20905854,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["hacktoberfest"],"created_at":"2024-08-02T02:00:51.601Z","updated_at":"2025-04-04T19:11:32.659Z","avatar_url":"https://github.com/gmr.png","language":"Python","funding_links":[],"categories":["Projects"],"sub_categories":["Programming Language Clients"],"readme":"Consulate: A Consul Client Library\n==================================\n\nConsulate is a Python client library and set of application for the Consul\nservice discovery and configuration system.\n\n|Version| |Status| |Coverage|\n\nInstallation\n------------\n\nConsulate is available via via `pypi \u003chttps://pypi.org/project/consulate/\u003e`_\nand can be installed with easy_install or pip:\n\n.. code:: bash\n\n    pip install consulate\n\nIf you require communicating with Consul via a Unix socket, there is an extra\ndependency that is installed via:\n\n.. code:: bash\n\n    pip install consulate[unixsocket]\n\nCommand Line Utilities\n----------------------\nConsulate comes with two command line utilities that make working with Consul\neasier from a management perspective. The ``consulate`` application provides\na cli wrapper for common tasks performed.\n\nconsulate\n^^^^^^^^^\nThe consulate application provides a CLI interface for registering a service,\nbacking up and restoring the contents of the KV database, and actions for getting,\nsetting, and deleting keys from the KV database.\n\n.. code:: bash\n\n    usage: consulate [-h] [--api-scheme API_SCHEME] [--api-host API_HOST]\n                     [--api-port API_PORT] [--datacenter DC] [--token TOKEN]\n                     {register,deregister,kv,run_once} ...\n\n    CLI utilities for Consul\n\n    optional arguments:\n      -h, --help            show this help message and exit\n      --api-scheme API_SCHEME\n                            The scheme to use for connecting to Consul with\n      --api-host API_HOST   The consul host to connect on\n      --api-port API_PORT   The consul API port to connect to\n      --datacenter DC       The datacenter to specify for the connection\n      --token TOKEN         ACL token\n\n    Commands:\n      {register,deregister,kv,run_once,services}\n        register            Register a service for this node\n        deregister          Deregister a service for this node\n        kv                  Key/Value Database Utilities\n        run_once            Lock command\n        services            List services for this node\n\n    If the CONSUL_RPC_ADDR environment variable is set, it will be parsed and used\n    for default values when connecting.\n\nService Registration Help:\n\n.. code:: bash\n\n    usage: consulate register [-h] [-a ADDRESS] [-p PORT] [-s SERVICE_ID]\n                              [-t TAGS]\n                              name {check,httpcheck,no-check,ttl} ...\n\n    positional arguments:\n      name                  The service name\n\n    optional arguments:\n      -h, --help            show this help message and exit\n      -a ADDRESS, --address ADDRESS\n                            Specify an address\n      -p PORT, --port PORT  Specify a port\n      -s SERVICE_ID, --service-id SERVICE_ID\n                            Specify a service ID\n      -t TAGS, --tags TAGS  Specify a comma delimited list of tags\n\n    Service Check Options:\n      {check,httpcheck,no-check,ttl}\n        check               Define an external script-based check\n        httpcheck           Define an HTTP-based check\n        no-check            Do not enable service monitoring\n        ttl                 Define a duration based TTL check\n\nKV Database Utilities Help:\n\n.. code:: bash\n\n    usage: consulate kv [-h] {backup,restore,ls,mkdir,get,set,rm} ...\n\n    optional arguments:\n      -h, --help            show this help message and exit\n\n    Key/Value Database Utilities:\n      {backup,restore,ls,mkdir,get,set,rm}\n        backup              Backup to stdout or a JSON file\n        restore             Restore from stdin or a JSON file\n        ls                  List all of the keys\n        mkdir               Create a folder\n        get                 Get a key from the database\n        set                 Set a key in the database\n        rm                  Remove a key from the database\n\nLocking Operations Help:\n\n.. code:: bash\n\n    usage: consulate [-h] run_once [-i INTERVAL] prefix command\n\n    positional arguments:\n      prefix                the name of the lock which will be held in Consul.\n      command               the command to run\n\n    optional arguments:\n      -h, --help            show this help message and exit\n      -i, --interval        hold the lock for INTERVAL seconds\n\nService listing Help:\n\n.. code:: bash\n\n    usage: consulate services [-h] [-i INDENT]\n\n    optional arguments:\n      -h, --help            show this help message and exit\n      -i INDENT, --indent INDENT\n                            The indent level for output\n\nAPI Usage Examples\n------------------\nThe following examples highlight the usage of Consulate and does not document\nthe scope of the full Consulate API.\n\n*Using Consulate with the Consul kv database:*\n\n.. code:: python\n\n    consul = consulate.Consul()\n\n    # Set the key named release_flag to True\n    consul.kv['release_flag'] = True\n\n    # Get the value for the release_flag, if not set, raises AttributeError\n    try:\n        should_release_feature = consul.kv['release_flag']\n    except AttributeError:\n        should_release_feature = False\n\n    # Delete the release_flag key\n    del consul.kv['release_flag']\n\n    # Find all keys that start with \"fl\"\n    consul.kv.find('fl')\n\n    # Find all keys that start with \"feature_flag\" terminated by \"/\" separator\n    consul.kv.find('feature_flag', separator='/')\n\n    # Check to see if a key called \"foo\" is set\n    if \"foo\" in consul.kv:\n        print 'Already Set'\n\n    # Return all of the items in the key/value store\n    consul.kv.items()\n\n*Working with the Consulate.agent API:*\n\n.. code:: python\n\n    consul = consulate.Consul()\n\n    # Get all of the service checks for the local agent\n    checks = consul.agent.checks()\n\n    # Get all of the services registered with the local agent\n    services = consul.agent.services()\n\n    # Add a service to the local agent\n    consul.agent.service.register('redis',\n                                   port=6379,\n                                   tags=['master'],\n                                   ttl='10s')\n\n\n*Fetching health information from Consul:*\n\n.. code:: python\n\n    consul = consulate.Consul()\n\n    # Get the health of a individual node\n    health = consul.health.node('my-node')\n\n    # Get all checks that are critical\n    checks = consul.health.state('critical')\n\nFor more examples, check out the Consulate documentation.\n\n.. |Version| image:: https://img.shields.io/pypi/v/consulate.svg?\n   :target: https://pypi.python.org/pypi/consulate\n\n.. |Status| image:: https://img.shields.io/travis/gmr/consulate.svg?\n   :target: https://travis-ci.org/gmr/consulate\n\n.. |Coverage| image:: https://img.shields.io/codecov/c/github/gmr/consulate.svg?\n   :target: https://codecov.io/github/gmr/consulate?branch=master\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgmr%2Fconsulate","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgmr%2Fconsulate","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgmr%2Fconsulate/lists"}