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.

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 modules/oc_opsdevnz[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)

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.2.3.tar.gz (16.2 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.3-py3-none-any.whl (14.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: oc_opsdevnz-0.2.3.tar.gz
  • Upload date:
  • Size: 16.2 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.2.3.tar.gz
Algorithm Hash digest
SHA256 979fe25cd0236bc61a45306eda6624c0812945ec03698dc2c23174f1a424bb03
MD5 b5ef3acddc8b96ec28c16728ffe16dad
BLAKE2b-256 95bc3170082fcc18880b9761db2a31b64eaf36dc896d8e2cc87c5be195a82e4d

See more details on using hashes here.

File details

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

File metadata

  • Download URL: oc_opsdevnz-0.2.3-py3-none-any.whl
  • Upload date:
  • Size: 14.6 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.2.3-py3-none-any.whl
Algorithm Hash digest
SHA256 d65789044ca17599deefc5b87166adf39fd2a9c06dcfcc6598487ed502ba8f16
MD5 dccb1609dfe21c80d7583263046ef604
BLAKE2b-256 24867c12c1b51b70b697a3753e78534b54c0fa8a719ce307a98668b130400c4e

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