Skip to main content

Typed Python SDK for the ForkTex Cloud platform — provision, deploy, and manage VPS-backed apps via a declarative manifest.

Project description

forktex-cloud

PyPI Python License

Standalone Python SDK for the ForkTex Cloud platform.

forktex-cloud is the typed httpx client + manifest plumbing that the forktex CLI uses to talk to the ForkTex Cloud control plane: project provisioning, server management, deployments, vault, manifest validation, and the docker-compose / Hetzner / Ansible bridge.

You can use it directly from any Python application — no forktex CLI required.

Install

pip install forktex-cloud

Requires Python ≥ 3.11.

Quick Start

Authenticated client

from forktex_cloud import Cloud, CloudContext

ctx = CloudContext(controller="https://cloud.forktex.com", account_key="ftx-...")
with Cloud.from_context(ctx) as client:
    projects = client.list_projects()
    servers  = client.list_servers()
    health   = client.health()

Direct auth

from forktex_cloud import Cloud

# JWT bearer (user login)
with Cloud("https://cloud.forktex.com", access_token="eyJ...") as client:
    me = client.me()

# Org-scoped API key (CI/CD)
with Cloud(
    "https://cloud.forktex.com",
    account_key="ftx-...",
    org_id="00000000-0000-0000-0000-000000000001",
) as client:
    events = client.list_events(project_id="...")
    status = client.server_status("server-uuid")

Local dev (point at your make local stack)

client = Cloud(
    base_url="http://localhost:8000",
    account_key="ftx-dev-key-2026",
    org_id="<your-org-uuid>",
)

Trigger a deploy pipeline

# Preview what an apply WOULD do (read-only, no mutation):
plan = client.plan(project_dir=Path("./my-project"), env="production")
print(plan.manifest_diff)            # added / removed / changed paths
for role in plan.ansible_plan:
    print(f"  {role.role}: {role.changed} changed, {role.failed} failed")
    for d in role.diffs:
        print(f"    {d.task}: {d.before_header}")  # file-level diff hints

# Full apply (provision + bootstrap + deploy + DNS + SSL)
job = client.apply(project_dir=Path("./my-project"))      # reads forktex.json
print(job.job_id, job.deployment_id, job.status)

# Code push to an existing server (no re-provision)
job = client.deploy(server_id="...", service="api")    # Ansible deploy tag

# Tear down
job = client.destroy(keep_dns=True)                       # preserves DNS record

Manifest loading + validation

from forktex_cloud import Manifest, ManifestError

# Validates eagerly against the canonical Pydantic schema at construction
try:
    m = Manifest.load("forktex.json", env="production")
except ManifestError as e:
    print(f"Invalid manifest: {e}")
    raise

# Typed access to the cloud block (discriminated union over all 4 kinds)
print(m.cloud.kind)                     # "ProjectDeployment" | "StaticSite" | ...
print(m.cloud.metadata.name)
for svc in m.services_for_env(env="production"):
    print(svc.id, svc.type, svc.image)

# Wire format round-trips cleanly (model_dump → parse_cloud_block)
as_dict = m.cloud.model_dump(by_alias=True, exclude_none=True)

Secrets vault (server-side, org-scoped)

client.vault_set("POSTGRES_PASSWORD", "hunter2")
secret = client.vault_get("POSTGRES_PASSWORD")           # -> VaultGetResponse
keys   = client.vault_list()                             # -> list[str]
client.vault_delete("POSTGRES_PASSWORD")

What's in the package

Module Purpose
forktex_cloud.client Typed sync httpx client (Cloud) + all OpenAPI-codegenned Pydantic models (ServerRead, ProjectRead, EventRead, VaultGetResponse, ...)
forktex_cloud.manifest Manifest loader, discriminated-union schema (v1), deep-merge for env overlays, ManifestError
forktex_cloud.config CloudContext — controller URL, JWT / account-key, current org + project keys
forktex_cloud.scaffold forktex cloud init template generator (ProjectDeployment / StaticSite / SingleContainer / NativeBuild)
forktex_cloud.bridge docker-compose generator (local mode), Loki config, log formatters used by forktex cloud apply --env local
forktex_cloud.secrets Fernet vault + ${vault:KEY} resolver for compile-time secret injection
forktex_cloud.paths Cross-platform .forktex/ + ~/.forktex/ filesystem spec (V1). See docs/forktex-directory-spec.md

All response models come from the OpenAPI codegen pipeline — one source of truth shared between the server and every consumer. No hand-written model drift.

Top-level re-exports

from forktex_cloud import (
    # Client
    Cloud, CloudAPIError,
    # Config
    CloudContext,
    # Manifest
    Manifest, ManifestError,
    # Response models (from OpenAPI codegen)
    ApiKeyCreated, ApiKeyRead,
    EnvironmentRead, EventRead,
    HealthRead, JobResponse, MeResponse,
    OrgRead, ProjectRead, ServerRead, UserRead,
    StatusResponse, TokenResponse, VaultGetResponse,
    WorkspaceRead,
)

Versioning

The SDK follows SemVer. The client's response models are generated from the server's OpenAPI spec at a fixed SPEC_VERSION + SPEC_HASH (inspectable at runtime via forktex_cloud.client.generated.SPEC_VERSION). When the server OpenAPI changes, the SDK is regenerated and released with a bumped version.

Repository

This SDK lives inside the forktex/cloud monorepo alongside the API server (api/) and React Native client (client/). The SDK package is independently versioned and published to PyPI.

License

MIT — see LICENSE.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

forktex_cloud-2.1.0.tar.gz (49.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

forktex_cloud-2.1.0-py3-none-any.whl (56.3 kB view details)

Uploaded Python 3

File details

Details for the file forktex_cloud-2.1.0.tar.gz.

File metadata

  • Download URL: forktex_cloud-2.1.0.tar.gz
  • Upload date:
  • Size: 49.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for forktex_cloud-2.1.0.tar.gz
Algorithm Hash digest
SHA256 34b69589bc456301d45bb8b00db87720e62c14bb41fb02d4675575f586f880bf
MD5 56a14f733b84da0a94ab69a7355ba0fb
BLAKE2b-256 b114ae328b43039cdf813b98d158b477577ccf74f46afbe66cb621746c5844ea

See more details on using hashes here.

File details

Details for the file forktex_cloud-2.1.0-py3-none-any.whl.

File metadata

  • Download URL: forktex_cloud-2.1.0-py3-none-any.whl
  • Upload date:
  • Size: 56.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for forktex_cloud-2.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8f923f77edc019e3b3862ec323ad663d5c7bb0176cdf3deb60899e78954a9d63
MD5 b1329daa896438257ef7d67dac18ad08
BLAKE2b-256 330ea2fa351d8308af33d0085207e145599b6b27ffbf66e650dfe34fe74e5cf1

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page