Skip to content

POC Quota API SDK/CLI - #1217

Open
asonnenschein wants to merge 5 commits into
mainfrom
adrians/add-quota-api
Open

POC Quota API SDK/CLI#1217
asonnenschein wants to merge 5 commits into
mainfrom
adrians/add-quota-api

Conversation

@asonnenschein

Copy link
Copy Markdown
Contributor

Description

Adds support for the Planet Quota Reservations API to the SDK. Includes an async client, sync client, and CLI built on the
async client, following the same patterns used by the existing Planet APIs that are supported in the SDK.

Changes

  • Add QuotaClient (planet/clients/quota.py) covering all Quota Reservations API endpoints: list_reservations, get_reservation, create_reservation,
    bulk_create_reservations, estimate_reservation, list_jobs, get_job, plus list_products (with optional supports_reservation filter) for looking up the
    product_id required by reservation requests.
  • Add a _QuotaPaged subclass of models.Paged to handle the API's {meta: {next: ...}, results: [...]} pagination shape.
  • Add QuotaAPI (planet/sync/quota.py) synchronous wrapper, exposed on Planet as pl.quota.
  • Add planet quota CLI group (planet/cli/quota.py) with products, reservations, and jobs subcommands. List commands support --limit, --page-size, --sort,
    --fields, and repeated --filter KEY=VALUE. Mutation commands accept repeated --aoi-ref or --aoi-refs <json> (string, file, or stdin) for large AOI lists.
  • Register QuotaClient in planet.clients._client_directory so sess.client('quota') resolves it, and export QuotaClient from the top-level planet package.

@asonnenschein

Copy link
Copy Markdown
Contributor Author

@asonnenschein to do - add tests.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds first-pass SDK + CLI support for Planet’s Quota Reservations API, including an async client, sync wrapper on Planet, and a new planet quota CLI command group, plus integration tests for both API and CLI behavior.

Changes:

  • Introduces QuotaClient (async) with pagination support for the Quota API response shape.
  • Adds QuotaAPI (sync) and exposes it as Planet().quota.
  • Adds planet quota CLI group (products/reservations/jobs) and integration tests covering expected request/response behavior.

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
tests/integration/test_quota_cli.py New integration coverage for planet quota CLI subcommands and request parameter handling.
tests/integration/test_quota_api.py New integration coverage for async + sync Quota API clients, pagination, and product filtering.
planet/sync/quota.py New synchronous wrapper (QuotaAPI) around the async QuotaClient.
planet/sync/client.py Exposes QuotaAPI as Planet().quota.
planet/clients/quota.py New async QuotaClient + _QuotaPaged pagination adapter for {meta, results} responses.
planet/clients/init.py Registers and exports QuotaClient for sess.client('quota') resolution.
planet/cli/types.py Adds mypy override ignores for CommaSeparatedString/Float.convert signatures.
planet/cli/quota.py New planet quota CLI group implementation using the async client.
planet/cli/cli.py Registers the new quota CLI command group.
planet/init.py Exports QuotaClient from the top-level planet package.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread planet/clients/quota.py Outdated
Comment thread planet/cli/quota.py

@tbarsballe tbarsballe left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall, this looks good. I've run some test commands locally, and everything works how I'd expect (though I didn't actually try reserving anything).

There's a little bit of an issue with verbose structure + vague or redundant comments throughout the MR, that is common with AI code but it's not too bad there. I've called out a couple places where it's noticeably inconsistent.

Following on from the discussion points during last weeks office hours: I ran quota reservations list on a customer account, and can confirm non-null organization_ids are returned in the results - it looks like the weirdness you were seeing when testing is a quirk of org 1.

Comment thread planet/clients/quota.py Outdated
Comment thread planet/clients/quota.py
Comment thread planet/sync/quota.py Outdated
Comment thread tests/integration/test_quota_api.py Outdated
Comment thread tests/integration/test_quota_api.py Outdated
Comment thread planet/cli/quota.py Outdated
asonnenschein and others added 5 commits August 20, 2026 13:10
  (client, sync wrapper, CLI) to match SubscriptionsClient
- drop section-divider banner comments from cli/quota.py and
  both quota test files
- convert inline test comment to a docstring in
  test_list_reservations_respects_limit
- align docstring cross-reference links to subscription_request.py
  style ([full.path.Class.method][])

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
…d docs

- remove unused `T = TypeVar("T")` and its import from clients/quota.py
- validate that `--aoi-refs` parses to a JSON array of strings before
  extending the ref list. Previously a JSON object was silently expanded
  into its keys and submitted as AOI refs; regression tests added for
  both the non-list and non-string-entry cases.
- revert planet/cli/types.py to main's version: #1219 fixed the same
  mypy override error properly by rebasing the CommaSeparated* types on
  click.ParamType, making this branch's `# type: ignore[override]`
  workaround redundant
- default `--page-size` to 500 on `quota jobs list`, matching
  `quota reservations list` and the 500 default already used by
  QuotaClient.list_jobs / QuotaAPI.list_jobs. The CLI was passing None
  and overriding it.
- add `planet.QuotaClient` to docs/python/sdk-reference.md
- add docs/cli/cli-quota.md tutorial and register it in the mkdocs nav

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@asonnenschein
asonnenschein force-pushed the adrians/add-quota-api branch from 9584f44 to 4014043 Compare August 20, 2026 18:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants