Skip to main content

OpenCollective API helper (OpsDev.nz), prod-default with 1Password token resolution

Project description

oc_opsdevnz

OpenCollective client and CLI for OpsDev.nz. Resolves tokens from 1Password via op-opsdevnz. Use --staging/--test to target the staging.opencollective.com API.

Why

StartMeUp.NZ manages collectives through a lifecycle: onboard, support, offboard. Each collective is a YAML file. One command applies it. No clicking through the OpenCollective web UI. GitOps for fiscal hosting: versioned, reviewed, repeatable.

Features

  • httpx GraphQL client with retries/backoff and redacted error messages.
  • Environment guardrails: prod by default; for_staging() or --staging/--test required for staging.
  • Token resolution via OC_SECRET_REF/OC_TOKEN using op-opsdevnz.
  • CLI helpers for whoami, host organization upserts, collective creation/apply-to-host flows, and project creation from YAML/JSON.

Install

pip install oc-opsdevnz op-opsdevnz
# or editable while hacking in this repo
pip install -e .[dev]

CLI

export OC_SECRET_REF="op://startmeup.nz/api.opencollective.com/credential"  # or set OC_TOKEN

# Fetch an account/collective by slug
oc-opsdevnz whoami opsdevnz

# Show installed version
oc-opsdevnz version

# Create/update host orgs from YAML
oc-opsdevnz hosts --file hosts.yaml

# Create/update collectives and optionally apply to a host
oc-opsdevnz collectives --file collectives.yaml

# Create/update projects under a parent collective
oc-opsdevnz projects --file projects.yaml

Use --file or --config to point at any filename you prefer; defaults above are just examples. Use --staging/--test to hit staging, or --api-url to override explicitly. --prod remains accepted for explicitness but is the default.

Example YAML shapes

hosts.yaml (real staging values):

- name: StartMeUp.NZ
  slug: startmeup-nz
  description: Fiscal sponsor for OpsDev.NZ and NZ startups (staging)
  website: https://startmeup.nz
  currency: nzd
  tags: [fiscal-host, newzealand, aotearoa]

collectives.yaml (example):

- name: Example Collective
  slug: example-collective
  description: Example collective for testing.
  tags: [example, staging]
  host_slug: startmeup-nz
  apply_to_host: true
  host_apply_message: Please host this example collective on staging.

projects.yaml (example):

- name: Example Project
  slug: example-project
  parent_slug: example-collective
  description: Pilot project under the example collective.
  tags: [example, project]

Python API

from oc_opsdevnz import OpenCollectiveClient

client = OpenCollectiveClient.for_staging()
data = client.graphql("query { account(slug:\"example-collective\") { id slug name } }")

prod_client = OpenCollectiveClient.for_prod()  # default choice for CLI

Helpers for YAML-driven workflows:

from oc_opsdevnz import load_items, upsert_collective, upsert_host, upsert_project
from pathlib import Path

client = OpenCollectiveClient.for_staging()
for host in load_items(Path("hosts.yaml")):
    upsert_host(client, host)
for project in load_items(Path("projects.yaml")):
    upsert_project(client, project)

Documentation

Module documentation lives in docs/ and is served with Zensical:

# Install Zensical (add to dev dependencies if missing)
uv add --dev zensical

# Serve docs locally (human — not for AI assistants)
uv run zensical serve

# Build docs to verify they render without errors
uv run zensical build

See zensical.toml for site configuration and navigation structure.

Development

uv sync --extra dev
uv run python -m pytest tests/ -v

To run linting:

uv run ruff check src tests

License

Apache-2.0 © OpsDev.nz

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

oc_opsdevnz-0.2.5.tar.gz (19.1 kB view details)

Uploaded Source

Built Distribution

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

oc_opsdevnz-0.2.5-py3-none-any.whl (15.9 kB view details)

Uploaded Python 3

File details

Details for the file oc_opsdevnz-0.2.5.tar.gz.

File metadata

  • Download URL: oc_opsdevnz-0.2.5.tar.gz
  • Upload date:
  • Size: 19.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for oc_opsdevnz-0.2.5.tar.gz
Algorithm Hash digest
SHA256 ddff707ab5baafe40216c1e7e02a23b81383dd920f103cec36ecc5fc9a9b6dc3
MD5 fa6e5fd0c6ed209cec07f9bc95251c91
BLAKE2b-256 2705259f8b5a5281eda6aa515c4db054c9359c0144c932ef4a9ab03821c89dd6

See more details on using hashes here.

Provenance

The following attestation bundles were made for oc_opsdevnz-0.2.5.tar.gz:

Publisher: publish.yml on startmeup-nz/oc-opsdevnz

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file oc_opsdevnz-0.2.5-py3-none-any.whl.

File metadata

  • Download URL: oc_opsdevnz-0.2.5-py3-none-any.whl
  • Upload date:
  • Size: 15.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for oc_opsdevnz-0.2.5-py3-none-any.whl
Algorithm Hash digest
SHA256 f158d38fd8e2e58b154d67c71f0eca588647bebdd0492579d7950e489fc58abb
MD5 d995b9995b4c559dd35de16bf30fb536
BLAKE2b-256 ce290de516b9a8e413b78dbc5a713afe7a0be0b44ae32b3574addff4f2167cd1

See more details on using hashes here.

Provenance

The following attestation bundles were made for oc_opsdevnz-0.2.5-py3-none-any.whl:

Publisher: publish.yml on startmeup-nz/oc-opsdevnz

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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