Skip to content

POC Quota API SDK/CLI#1217

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

POC Quota API SDK/CLI#1217
asonnenschein wants to merge 3 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
Comment on lines +17 to +29
from typing import Any, AsyncIterator, Dict, List, Optional, TypeVar

from planet.clients.base import _BaseClient
from planet.exceptions import APIError, ClientError
from planet.http import Session
from planet.models import Paged, Response
from ..constants import PLANET_BASE_URL

BASE_URL = f'{PLANET_BASE_URL}/account/v1'

LOGGER = logging.getLogger()

T = TypeVar("T")
Comment thread planet/cli/quota.py
Comment on lines +175 to +184
def _aoi_refs_from_options(aoi_ref: Tuple[str, ...],
aoi_refs_json: Optional[List[str]]) -> List[str]:
refs: List[str] = list(aoi_ref)
if aoi_refs_json:
refs.extend(aoi_refs_json)
if not refs:
raise click.BadParameter(
'At least one AOI ref must be supplied via --aoi-ref or '
'--aoi-refs.')
return refs
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.

2 participants