planet-client-python icon indicating copy to clipboard operation
planet-client-python copied to clipboard

Quota API

Open asonnenschein opened this issue 5 months ago • 0 comments

This PR provides a complete, production-ready Quota API client that seamlessly integrates with the existing Planet Python SDK architecture and follows all established patterns and conventions. Generated with help from Claude Code:

Ticket

https://github.com/planetlabs/planet-client-python/issues/1191

Key Features

  • Create quota reservations from JSON specifications
  • Estimate quota requirements and costs
  • List reservations with filtering (status, pagination)
  • Get specific reservation details
  • Cancel existing reservations
  • View current quota usage and limits

Details

  1. Async QuotaClient (planet/clients/quota.py)

    • Full async client following BaseClient pattern
    • Methods: create_reservation(), estimate_quota(), list_reservations(), get_reservation(), cancel_reservation(), get_quota_usage()
    • Proper URL construction and error handling
    • Paginated results with custom Reservations iterator
  2. Sync QuotaAPI (planet/sync/quota.py)

    • Synchronous wrapper following established patterns
    • All same methods as async client using _call_sync() and _aiter_to_iter()
  3. CLI Implementation (planet/cli/quota.py)

    • Complete CLI with subcommands: planet quota reservations {create,list,get,cancel}, planet quota estimate, planet quota usage
    • Support for JSON input files, filtering, compact output, and custom base URLs
    • Follows established CLI patterns with proper async context management
  4. Integration

    • Updated main Planet sync client to include quota API
    • Added QuotaClient to main module exports
    • Integrated with session management and client directory
  5. Comprehensive Testing

    • Unit tests (tests/unit/test_quota.py): Client initialization, URL construction, sync client integration
    • Integration tests (tests/integration/test_quota_api.py): HTTP mocking for async/sync clients with realistic request/response patterns
    • CLI integration tests (tests/integration/test_quota_cli.py): Complete CLI command testing with mocked HTTP responses
  6. Code Quality

    • All linting checks pass (flake8, yapf)
    • Type checking passes (mypy)
    • Follows existing code conventions and patterns
    • Comprehensive documentation with examples

asonnenschein avatar Aug 13 '25 21:08 asonnenschein