Skip to main content

OpenCollective API helper (OpsDev.nz), staging-first with 1Password token resolution

Project description

oc_opsdevnz

Staging-first OpenCollective client and CLI for OpsDev.nz. Resolves tokens from 1Password via op-opsdevnz and defaults to the staging API unless you explicitly opt into prod.

Features

  • httpx GraphQL client with retries/backoff and redacted error messages.
  • Environment guardrails: staging by default, for_prod()/--prod required for production.
  • 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 modules/oc_opsdevnz[dev]

CLI (staging by default)

export OC_SECRET_REF="op://startmeup.nz/api-staging.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 --prod to target production (only when you mean it), or --api-url to override explicitly.

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 (real staging values):

- name: OpsDev.NZ
  slug: opsdev-nz
  description: OpsDev.NZ community and projects.
  tags: [opsdev, operations, engineering, nz]
  host_slug: startmeup-nz
  apply_to_host: true
  host_apply_message: Please host OpsDev.NZ on staging.

projects.yaml:

- name: GetJJobs.NZ
  slug: getjjobs-nz
  parent_slug: opsdev-nz
  description: Pilot job-matching project under OpsDev.NZ.
  tags: [jobs, pilot]

Python API

from oc_opsdevnz import OpenCollectiveClient

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

prod_client = OpenCollectiveClient.for_prod()  # explicit opt-in

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)

Development

cd modules/oc_opsdevnz
python -m venv .venv && source .venv/bin/activate
pip install -e .[dev]
pytest

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.1.2.tar.gz (15.9 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.1.2-py3-none-any.whl (14.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: oc_opsdevnz-0.1.2.tar.gz
  • Upload date:
  • Size: 15.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.0

File hashes

Hashes for oc_opsdevnz-0.1.2.tar.gz
Algorithm Hash digest
SHA256 2a952a408f0ab9fa469e87de26be076c82d4e0e7078f9518ba88768ba744f5ae
MD5 15bead1f92596310b32a7f8fa6082947
BLAKE2b-256 49d12a55ab1f223da7dd96d42b4f5b642878e990450c7e8d9bb182626278bd0a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: oc_opsdevnz-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 14.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.0

File hashes

Hashes for oc_opsdevnz-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 160bb933b86b3afb8b513804632693cfd8d488e213f97d5cda26cbfc9d94efc9
MD5 a99e9e96676cdbbd63f6c24ed43dd7c8
BLAKE2b-256 c6050324aa513e2c81cb5fab2eae9fac9877bdd64d69dfd230ef251bb76c22ed

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