Skip to content

Sync client base_url option #1171

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 2 commits into
base: main-3.0-dev
Choose a base branch
from
Open

Conversation

asonnenschein
Copy link
Contributor

This MR updates the Planet() sync client with a kwarg option to override the default base url for different client APIs. Support for configuring a custom base_url already exists for the async clients and CLI, this MR just brings that feature parity to the sync client. Even though this is a trivial change, I am including some unit tests to demonstrate that this functionality works and exists rather than updating the public docs because I think this feature holds more value for internal Planet workflows rather than customer workflows.

I also noticed that the list of subscription statuses in the CLI was missing the new invalid status, so I added that in this MR.

Notes from Claude:

I have successfully completed GitHub issue #1143 "Fix base URL handling". Here's what was implemented:

✅ CLI Support

The CLI already had --base-url options implemented for all API commands:

  • planet data --base-url
  • planet orders --base-url
  • planet subscriptions --base-url
  • planet features --base-url

✅ SDK Support

Updated the synchronous Planet client in planet/sync/client.py to support configurable base URLs:

from planet import Planet

Use custom base URLs for specific APIs

pl = Planet(
data_base_url="https://staging-data.planet.com/data/v1",
orders_base_url="https://staging-orders.planet.com/compute/ops"
)

Or use defaults (production)

pl = Planet()

✅ Backward Compatibility

All changes maintain full backward compatibility - existing code continues to work without modification.

✅ Implementation Details

  • Individual async clients (DataClient, OrdersClient, etc.) already supported base URLs
  • Individual sync API wrappers already supported base URLs
  • The main gap was the high-level Planet client not exposing these parameters
  • All tests pass and linting is clean

The implementation satisfies all acceptance criteria:

  • ✅ CLI supports optional arguments for custom base URLs with production defaults
  • ✅ SDK supports optional arguments for custom base URLs with production defaults
  • ✅ Maintains backward compatibility

Copy link

@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 adds base URL configuration support to the synchronous Planet client, bringing feature parity with the async clients and CLI. The changes enable users to override default API endpoints for different Planet services when using the sync client.

Key changes:

  • Updated Planet sync client constructor to accept optional base URL parameters for each API service
  • Added "invalid" subscription status to CLI options for completeness
  • Included unit tests to verify the base URL functionality works correctly

Reviewed Changes

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

File Description
planet/sync/client.py Added optional base_url parameters to Planet constructor and passed them to underlying API clients
planet/cli/subscriptions.py Added missing "invalid" status to subscription status filter options
test_base_url_functionality.py Added comprehensive unit tests to verify custom and default base URL behavior

data_base_url: Optional[str] = None,
orders_base_url: Optional[str] = None,
subscriptions_base_url: Optional[str] = None,
features_base_url: Optional[str] = None) -> None:
Copy link
Contributor

Choose a reason for hiding this comment

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

We should be mindful that this will become part of the SDK API that users are presented with, but users may not have a need for this level of configuration. We should try to keep our API surface clean and simple if possible.

Another approach could be to accept a single, common base_url (defaulting to https://api.planet.com) and each class under the hood (DataAPI, OrdersAPI) etc can add the appropriate path suffix e.g. /data/v1.

Copy link
Member

Choose a reason for hiding this comment

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

Agreed a single configuration would be ideal. It would also be nice to allow specification via CLI.

Also, since the CLI uses the async clients, we'd need to alter the approach taken there of statically building the URLS (like in data.py) based off of the constants module

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good ideas! Updated to simplify the signature to only allow a single base_url.

Base automatically changed from adrian/add-claude to main July 24, 2025 13:02
@asonnenschein asonnenschein changed the base branch from main to main-3.0-dev July 24, 2025 16:50
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.

3 participants