{"id":37068076,"url":"https://github.com/anomaly/gallagher","last_synced_at":"2026-01-14T08:00:02.570Z","repository":{"id":148798421,"uuid":"596821116","full_name":"anomaly/gallagher","owner":"anomaly","description":"The missing toolkit for extending Gallagher Command Centre, featuring a CLI, SQL interface, TUI and a Python idiomatic SDK","archived":false,"fork":false,"pushed_at":"2026-01-14T00:43:11.000Z","size":11388,"stargazers_count":14,"open_issues_count":39,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2026-01-14T04:36:38.820Z","etag":null,"topics":["cli","foss","gallagher","python","sdk","security","sql","tui"],"latest_commit_sha":null,"homepage":"https://anomaly.github.io/gallagher/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/anomaly.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":"CITATION.cff","codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null},"funding":{"github":["anomaly"]}},"created_at":"2023-02-03T01:49:34.000Z","updated_at":"2026-01-03T10:34:27.000Z","dependencies_parsed_at":"2023-12-27T01:35:39.892Z","dependency_job_id":"f2904cf9-cabd-431f-9ed8-213ff16e7eaa","html_url":"https://github.com/anomaly/gallagher","commit_stats":null,"previous_names":[],"tags_count":15,"template":false,"template_full_name":null,"purl":"pkg:github/anomaly/gallagher","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anomaly%2Fgallagher","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anomaly%2Fgallagher/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anomaly%2Fgallagher/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anomaly%2Fgallagher/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/anomaly","download_url":"https://codeload.github.com/anomaly/gallagher/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anomaly%2Fgallagher/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28413527,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-14T05:26:33.345Z","status":"ssl_error","status_checked_at":"2026-01-14T05:21:57.251Z","response_time":107,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["cli","foss","gallagher","python","sdk","security","sql","tui"],"created_at":"2026-01-14T08:00:01.723Z","updated_at":"2026-01-14T08:00:02.561Z","avatar_url":"https://github.com/anomaly.png","language":"Python","readme":"# Gallagher Python Toolkit\n\n\u003e The missing developer toolkit for Gallagher Command Centre\n\n[![PyPI version](https://badge.fury.io/py/gallagher.svg)](https://badge.fury.io/py/gallagher)\n[![Python Version](https://img.shields.io/pypi/pyversions/gallagher)](https://pypi.org/project/gallagher/)\n[![Build Status](https://github.com/anomaly/gallagher/actions/workflows/run-tests.yml/badge.svg?branch=master)](https://github.com/anomaly/gallagher/actions?query=branch%3Amaster)\n\n\u003cdiv align=\"center\"\u003e\n\u003cimg src=\"https://raw.githubusercontent.com/anomaly/gallagher/master/assets/logo-gpt.png\" alt=\"Gallagher Python Toolkit Logo\" height=128 width=128/\u003e\n\u003c/div\u003e\n\nGallagher Security manufacture a variety of perimeter [security products](https://security.gallagher.com). At the hear of these is the [Command Centre](https://products.security.gallagher.com/security/au/en_AU/products/software/command-centre/p/C201311) software. Command Centre is deployed locally (in simplistic terms, the complexity varies for every use case). Version `8.6` introduced a REST API which allows you to interact with the system via HTTP requests locally or via Gallagher's [Cloud API Gateway](https://gallaghersecurity.github.io/docs/Command%20Centre%20Cloud%20Api%20Gateway%20TIP.pdf) which eliminates the need for maintaining proxies and VPNs.\n\nOur Python Toolkit focuses on enhancing the developer experience (DX) around the REST API. In principle we provide the following:\n\n- **Python SDK** an idiomatic client (including `asyncio` support) to extend the CC functionality.\n- **Command Line Interface** (CLI) to build powerful pipeline-based workflows.\n- **Terminal User Interface** (TUI) for easy interactions with the Command Centre.\n- **SQL interface** query the REST API as if it were a database or interact with via an ORM.\n\n\u003e [!NOTE]\\\n\u003e This project is **NOT** affiliated with Gallagher Security. All trademarks are the property of their respective owners.\n\nWhile Gallagher maintain a set of [Swagger definitions](https://github.com/gallaghersecurity/cc-rest-docs) for their API, they are primarily intended to generate the documentation [published on Github](https://gallaghersecurity.github.io/cc-rest-docs/ref/index.html). They use a tool called [Spectacle](https://github.com/sourcey/spectacle). Gallagher explicitly state that the Swagger definitions are not intended to be used to generate code. Due to this the API client is hand built and not auto-generated.\n\n\u003e [!IMPORTANT]\\\n\u003e Due to custom annotations the YAML files will not parse with any standard parser.\n\nEverything this project provides hinges upon our Python SDK, designed to enhance the developer experience. It's design is highly opinionated from our experience in building APIs, we ensure conformance with Gallagher software design interfaces.\n\n\u003e [!TIP]\\\n\u003e If you've worked with [stripe-python](https://github.com/stripe/stripe-python) the syntax may feel familiar.\n\nIf you are using one of our user facing tools, it's not important for you to understand how the SDK works, however since it underpins everything, here's a rather sample example:\n\n```python\n# Import core python libs\nimport os\nimport asyncio\n\n# Import the client and models\nfrom gallagher import cc\nfrom gallagher.dto.summary import CardholderSummary\nfrom gallagher.cc.cardholders import Cardholder\n\n# Optionally provide a client certificate and key\ncert_path = os.path.join(os.getcwd(), \"client.pem\")\nkey_path = os.path.join(os.getcwd(), \"client.key\")\n\n# Set the API key from the environment\napi_key = os.environ.get(\"GACC_API_KEY\")\ncc.api_key = api_key\n\n# Async support gives us back a coroutine\nch_coro = Cardholder.list()\n\n# Run the coroutine to get the cardholder\ncardholders = asyncio.run(ch_coro)\ncardholder = cardholders.results[0]\n\n# This is now a pydantic object\ntype(cardholder) == CardholderSummary\n\n# Print out some details from the object\ncardholder.href\ncardholder.first_name\n```\n\n\u003e [!IMPORTANT]\\\n\u003e Gallagher infrastructure deals with perimeter security. We take this extremely seriously and providing a complete test suite to provide that our software meets all standards. These tests constantly run against our _demo_ command centre hosted on the cloud.\n\nThe rest of the README touches upon each of the tools we provide. If you like what you see so far we recommend you [head over to our documentation](https://anomaly.github.io/gallagher).\n\n## Using the CLI and TUI\n\nOur CLI is designed to automate custom workflows via scripts. Inspired by the greatest Unix tools out there, it does one thing and it does it well, leaving you to integrate it into a pipeline. The utility is able to speaking machine readable formats like JSON, YAML and CSV as well as producing formatted output.\n\nHere's an example of fetching the details of a `cardholder`:\n\n```\n(gallagher-py3.11) ➜  gallagher git:(alpha-3) gala ch get 8272\n person\n                  id 8272\n          first_name Jerry\n           last_name Zurcher\n          short_name None\n         description None\n          authorised yes\n\n  disable_cipher_pad no\n            division 2\n hrefs\n                edit edit\n```\n\n## Interacting via SQL\n\n[Shillelagh](https://shillelagh.readthedocs.io/en/latest/) is a Python library that allows you to interact with REST APIs as if they were SQL databases, including the ability to provide a SQLAlchemy `dialect` allowing you to treat endpoints as a virtual table.\n\nAssuming you had the SQL extensions installed, a simplistic example of querying Cardholders from the command would look like this:\n\n```sql\n🍀\u003e SELECT * FROM \"https://commandcentre-api-au.security.gallagher.cloud/api/cardholders\" WHERE id=8427;\n```\n\nwhich would return a result set of:\n\n```\nfirst_name    last_name    authorised    id\n------------  -----------  ------------ ----\nCammy         Albares      True         8427\n(1 row in 0.23s)\n\n```\n\n## Command Centre API Notes\n\nThe Gallagher API the principles of [HATEOAS](https://en.wikipedia.org/wiki/HATEOAS) which ensures that the API is self-descriptive and future proof.\n\nA `href` attribute provides a the destination of referenced objects in the responses. These are full qualified and will be prefixed with the server origin i.e if you are using the Cloud Gateway then all your URLs will be prefixed with the appropriate gateway's address.\n\nThese appear in various forms, starting from as simple as the `href` itself:\n\n```json\n\"cardholders\": {\n    \"href\": \"https://localhost:8904/api/access_groups/352/cardholders\"\n}\n```\n\nthrough to self recursive references (where the data is nested) with additional attributes:\n\n```json\n\"parent\": {\n    \"href\": \"https://localhost:8904/api/access_groups/100\",\n    \"name\": \"All R\u0026D\"\n}\n```\n\n\u003e [!CAUTION]\\\n\u003e Following the design patterns outlined by HATEOAS, you must never hardcode any URLs. You should hit the base API URL which returns the `hrefs` of all other resources.\n\u003e If you are using the Python SDK, then you don't have to worry about this, the client will handle this for you.\n\n## Python SDK Design\n\nThis API client primarily depends on the following libraries:\n\n- [httpx](https://www.python-httpx.org), fo transporting and parsing HTTP requests\n- [pydantic](https://pydantic.dev), for validating responses and constructing request bodies\n\nWe use [Taskfile](https://taskfile.dev) to automate running tasks.\n\nThe project provides a comprehensive set of tests which can be run with `task test`. These tests do create objects in the Command Centre, we advice you to obtain a test license.\n\n\u003e [!IMPORTANT]\n\u003e It's **not recommended** to run tests against a production system.\n\n### Data Transfer Objects\n\nThere are three types of schema definitions, each one of them suffixed with their intent:\n\n- **Ref** are `References` to other objects, they using contain a `href` and possibly additional meta data such as a `name` or `id`\n- **Summary** is what is returned by the Gallagher API in operations such as [searches](https://gallaghersecurity.github.io/cc-rest-docs/ref/cardholders.html), these are generally a subset of the full object\n- **Detail** are the full object found at a particular `href`, they compound on the `Summary` schema and add additional attributes\n- **Response** is a collection of `Summary` objects with other paths like `next` and `previous` for pagination and `updates` for polling results\n- **Payload** is used to send a request to the API\n\nIn summary the properties of each are as follows:\n\n- `Refs` are the minimal pathway to an object\n- `Summary` builds on a `Ref` and provides a subset of the attributes\n- `Detail` builds on a `Summary` and provides the full set of attributes\n- `Response` encapsulates a collection of `Summary` objects, they typically have `next` and `previous` paths for pagination\n- `Payload` are verbose and match the schema definition on the documentation\n\nEach `resource` endpoint subclasses the `APIEndpoint` which marks a resource as `fetchable`, `queryable`, `creatable`, `updatable` and `deletable`. This is determined by the configuration defined using an `EndpointConfig` class.\n\n\u003e [!TIP]\n\u003e The above is meant to be a summary, please see [our documentation](https://anomaly.github.io/gallagher) for more details.\n\n### Schema Design Patterns\n\nOur `schemas` provide a set of `Mixins` that are used to construct the Models. These are repeatable patterns that need not be repeated. The typical patter would be to subclass from the `Mixins` e.g:\n\n```python\nfrom .utils import AppBaseModel, IdentityMixin, HrefMixin\n\nclass AccessGroupRef(\n    AppBaseModel,\n    HrefMixin\n):\n    name: str\n```\n\nwhere the `HrefMixin` (see also `OptionalHrefMixin` for use where the `href` is not always present) provides the `href` attribute:\n\n```python\nclass HrefMixin(BaseModel):\n    href: str\n```\n\nThese `Mixin` classes can also be used to declare attributes that seek to use the same pattern:\n\n```python\nclass DivisionDetail(\n    AppBaseModel,\n    IdentityMixin,\n):\n    name: str\n    description: Optional[str] = None\n    server_display_name: Optional[str] = None\n    parent: OptionalHrefMixin = None\n```\n\n### Schemas\n\nOur `schemas` provide a set of `Mixins` that are used to construct the Models. These are repeatable patterns that need not be repeated. The typical patter would be to subclass from the `Mixins` e.g:\n\n```python\nfrom .utils import AppBaseModel, IdentityMixin, HrefMixin\n\nclass AccessGroupRef(\n    AppBaseModel,\n    HrefMixin\n):\n    name: str\n```\n\nwhere the `HrefMixin` provides the `href` attribute:\n\n```python\nclass HrefMixin(BaseModel):\n    href: str\n```\n\nThese `Mixin` classes can also be used to declare attributes that seek to use the same pattern:\n\n```python\nclass DivisionDetail(\n    AppBaseModel,\n    IdentityMixin,\n):\n    name: str\n    description: Optional[str]\n    server_display_name: str\n    parent: Optional[HrefMixin]\n```\n\nwhere `parent` is simply an `href` without any other attributes. In the cases where these attributes have more than just an `href` we defined `Reference` classes:\n\n```python\nclass AccessGroupRef(\n    AppBaseModel,\n    HrefMixin\n):\n    name: str\n```\n\nand use them to populate the attributes:\n\n```python\nclass VisitorTypeDetail(\n    AppBaseModel,\n    IdentityMixin\n):\n    access_group : AccessGroupRef\n    host_access_groups: list[AccessGroupSummary]\n    visitor_access_groups: list[AccessGroupSummary]\n```\n\nIn this example the `AppGroupRef` has a `name` attribute which is not present in the `HrefMixin` class.\n\n\u003e Please see the schema section for naming conventions for `schema` classes\n\nwhere `parent` is simply an `href` without any other attributes. In the cases where these attributes have more than just an `href` we defined `Reference` classes:\n\n```python\nclass AccessGroupRef(\n    AppBaseModel,\n    HrefMixin\n):\n    name: str\n```\n\nand use them to populate the attributes:\n\n```python\nclass VisitorTypeDetail(\n    AppBaseModel,\n    IdentityMixin\n):\n    access_group : AccessGroupRef\n    host_access_groups: list[AccessGroupSummary]\n    visitor_access_groups: list[AccessGroupSummary]\n```\n\nIn this example the `AppGroupRef` has a `name` attribute which is not present in the `HrefMixin` class.\n\n\u003e Please see the schema section for naming conventions for `schema` classes\n\n## Resources\n\nThe following are resources that were discoverd during the design and development of these tools. Not all of them are in use by the toolkit, they were discovered as the library evolved.\n\n### Python Libraries\n\n\u003e [!TIP]\n\u003e Following are Python libraries that I have found during the development of the Gallagher tools. They are not necessarily in use at the moment but a reference in case we need the functionality.\n\n- [plotext](https://github.com/piccolomo/plotext?tab=readme-ov-file) - plots directly on your terminal (something I found when I was exploring apps like [dolphie](https://github.com/charles-001/dolphie))\n- [rich-pixels](https://github.com/darrenburns/rich-pixels) - a [Rich-compatible](https://github.com/Textualize/rich) library for writing pixel images and other colourful grids to the terminal by @darrenburns\n- [PyFilesystem](https://github.com/pyfilesystem/pyfilesystem2) - a Python file system abstraction layer\n\n### Articles\n\n- [A year of building for the terminal](https://textual.textualize.io/blog/2022/12/20/a-year-of-building-for-the-terminal/) by [@darrenburns](https://github.com/darrenburns)\n\n## License\n\nDistributed under the MIT License except Artwork and Branding assets.\n\n## Credits\n\n- [Matthew Skiles](https://matthewskiles.com) for the beautiful logo for the project.\n- [Orion Edwards](https://github.com/borland) for all his support on getting @devraj started with the Gallagher API.\n- [Mick Lambert](https://www.linkedin.com/in/michael-lambert-au/), [Tim Harris](https://www.linkedin.com/in/timharris01/), [Andrew Donkin](https://github.com/andrewdonkin), [Mike Margrain](https://www.linkedin.com/in/mike-margrain-b914381a/), [Nathan Matera](https://www.linkedin.com/in/nathan-matera-0a30b6240/) from the Gallagher team for all their support.\n","funding_links":["https://github.com/sponsors/anomaly"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fanomaly%2Fgallagher","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fanomaly%2Fgallagher","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fanomaly%2Fgallagher/lists"}