Code Craft AI RestClient - Twingate
The codecraftai-restclient-twingate package is a typed, aspect-driven client for the Twingate Admin API. Despite the restclient- prefix, the upstream API is GraphQL, not REST — Twingate publishes a single GraphQL endpoint at https://<your-network>.twingate.com/api/graphql/v1. The package consumes codecraftai-restclient-base for HTTP transport (POST, session management, auth header plumbing, aspects-driven retry/timeout) and layers GraphQL query and mutation construction on top.
The package is implemented as of Milestone M3b of the VPN/cloud-provisioning plan. See the specs/ folder for the Kiro-style requirements, design, and task documentation that drives that work.
Highlights
TwingateClient(RestClientBase) exposing api groups for resources, groups, connectors, remote_networks, and devices.
IVPNControlPlane Protocol conformance via an idempotent three-phase RBAC apply (apply_acl translates Tailscale-shaped flat-ACL JSON into Twingate’s resource × group × assignment surface).
Typed query and mutation builders under queries/ and mutations/, INPUT_OBJECT types under inputs/, and SchemaObject DTOs under model/.
Bearer auth from TwingateServiceAccountCredential; endpoint URL derived from the credential’s network slug.
Connector-name → connector-id resolution for mint_authkey so callers can pass tag-shaped inputs and have them work against Twingate’s id-keyed surface.
Replaces the M3-landed codecraftai-interop/vpn/twingate/twingatecontrolplane.py, which becomes a re-export shim for one release cycle after this package ships.
Schema Regeneration
The typed builders and DTOs are hand-authored from the documented Twingate GraphQL surface — see the “Codegen Decision” section of AGENTS.md. A maintainer with a live Twingate network can re-sync the checked-in schema snapshot:
python -m ccai.restclient.twingate._codegen.import_schema \
--network <slug> --token <api-token>
This rewrites source/packages/ccai/restclient/twingate/_spec/schema.json and _spec/schema.sha256. The emitter in _codegen/emitter.py can then validate or extend the hand-authored model/ / inputs/ modules. On a non-200 response or GraphQL errors the importer raises ConfigurationError and leaves the checked-in schema untouched.
Repository Structure
development/ - Runtime environment scripts.
repository-setup/ - Repository homing and setup scripts.
source/packages/ccai/restclient/twingate/ - Package source code (lands in M3b).
source/testroots/testbase/ccai/tests/restclient/twingate/ - TestBase test roots (lands in M3b).
specs/ - Requirements, design, and task documentation (Kiro-style).
userguide/ - Standards, conventions, and documentation.
Environment Setup
When working in a Codex container:
./development/setup-agent-container
For local development:
./repository-setup/rehome-repository
./development/setup-environment
Running Tests
Tests land in Milestone M3b. Once source code is in place:
source .venv/bin/activate
testbase testing run --root ./source/testroots/testbase --includes=testbase.ccai.tests
Standards and Conventions
Naming conventions: userguide/10-02-naming-conventions.rst
Code organization: userguide/10-01-code-organization.rst
Coding standards: userguide/10-00-coding-standards.rst
Additional Resources
User guide entry point: userguide/userguide.rst
Codegen decision rule: workspace PLAN-VPN-AND-CLOUD-PROVISIONING.md §9.2a
Metadata
Release files for codecraftai-restclient-twingate 1.2.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| codecraftai_restclient_twingate-1.2.1.tar.gz | 41.6 kB | With provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| codecraftai_restclient_twingate-1.2.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 117.8 kB
Release files / codecraftai_restclient_twingate-1.2.1.tar.gz
| Download URL | codecraftai_restclient_twingate-1.2.1.tar.gz |
|---|---|
| Size | 41.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
7e6fef844b2d584cb61f4b14aec4fff919da8f00839cf95d1ef30629c1d5f301
|
|
BLAKE2b-256 checksum How to use checksums |
51e90eab3dc6fc6805ba9c0aadc79d1dc95a5530e5e3f22b5501a40333864961
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 20, 2026.
Transparency logRelease files / codecraftai_restclient_twingate-1.2.1-py3-none-any.whl
| Download URL | codecraftai_restclient_twingate-1.2.1-py3-none-any.whl |
|---|---|
| Size | 76.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
0799680483d8cbe03878970ce0d6ca9e3aaf74f2f16f5c771ee5c1358b9360c6
|
|
BLAKE2b-256 checksum How to use checksums |
aa706ad9b397fcf1d9b3bea050e114587978c4f367814286a8fbe5abd00324a2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 20, 2026.
Transparency logSecurity for codecraftai-restclient-twingate 1.2.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
All 2 files in this release have been uploaded with provenance metadata.
Attestation for codecraftai_restclient_twingate-1.2.1.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 20, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.