Skip to content

Quota API #1194

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Quota API #1194

wants to merge 1 commit into from

Conversation

asonnenschein
Copy link
Contributor

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

#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 asonnenschein requested a review from Copilot August 13, 2025 21:02
@asonnenschein asonnenschein self-assigned this Aug 13, 2025
@asonnenschein asonnenschein mentioned this pull request Aug 13, 2025
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR implements a complete, production-ready Quota API client for the Planet Python SDK that enables users to create, manage, and monitor quota reservations for Planet's data products.

  • Complete async QuotaClient with methods for creating reservations, estimating quota requirements, and managing existing reservations
  • Synchronous QuotaAPI wrapper following established SDK patterns with proper sync/async integration
  • Full CLI implementation with subcommands for all quota operations including JSON file input support

Reviewed Changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
planet/clients/quota.py Core async QuotaClient implementation with reservation management methods
planet/sync/quota.py Synchronous wrapper QuotaAPI following established patterns
planet/sync/client.py Integration of QuotaAPI into main Planet client
planet/clients/init.py Export QuotaClient in client registry
planet/init.py Export QuotaClient at package level
planet/cli/quota.py Complete CLI implementation with subcommands
planet/cli/cli.py Integration of quota CLI commands
tests/unit/test_quota.py Unit tests for client initialization and URL construction
tests/integration/test_quota_api.py Integration tests with HTTP mocking
tests/integration/test_quota_cli.py CLI integration tests
tests/unit/test_client.py Updated existing tests for quota integration

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

from planet.http import Session
from planet.models import Paged

BASE_URL = f'{PLANET_BASE_URL}/quota/v1'
Copy link
Preview

Copilot AI Aug 13, 2025

Choose a reason for hiding this comment

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

The BASE_URL variable is defined but never used within this file. Consider removing it since the default URL is already handled in the init method or use it consistently throughout the file.

Copilot uses AI. Check for mistakes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant