Skip to content

feat!: add location ops, replace BasinScope with LocationInfo#61

Merged
sgbalogh merged 6 commits into
mainfrom
location
May 23, 2026
Merged

feat!: add location ops, replace BasinScope with LocationInfo#61
sgbalogh merged 6 commits into
mainfrom
location

Conversation

@sgbalogh
Copy link
Copy Markdown
Member

No description provided.

@sgbalogh sgbalogh marked this pull request as ready for review May 23, 2026 20:06
@sgbalogh sgbalogh requested a review from a team as a code owner May 23, 2026 20:06
@greptile-apps
Copy link
Copy Markdown

greptile-apps Bot commented May 23, 2026

Greptile Summary

This is a breaking refactor that replaces the static BasinScope enum (which hard-coded aws:us-east-1) with a dynamic LocationInfo dataclass and three new account-level RPCs for discovering and managing locations. BasinInfo.scope becomes BasinInfo.location: str | None, and create_basin/ensure_basin gain an optional location parameter.

  • LocationInfo (name: str, is_private: bool) replaces BasinScope, enabling the SDK to surface both public and private placements returned by the server rather than enumerating them at compile time.
  • list_locations / get_default_location / set_default_location are added to S2, each backed by the new /v1/locations endpoints; the location RPCs are excluded from CI (matching the access_tokens pattern) and covered by opt-in integration tests.
  • Three new Operation enum values (LIST_LOCATIONS, GET_DEFAULT_LOCATION, SET_DEFAULT_LOCATION) extend access-token scoping to match the new endpoints.

Confidence Score: 5/5

The refactor cleanly removes the hard-coded BasinScope enum and replaces it with a server-driven LocationInfo type; no existing logic is silently broken.

All changed paths are straightforward: new mapper/validator functions, additive keyword arguments to existing methods, and three new async methods that follow the established SDK pattern. The author's decisions are consistent with the API spec referenced throughout the PR. Integration tests cover the new surface area; unit tests cover the new validator.

No files require special attention.

Important Files Changed

Filename Overview
src/s2_sdk/_ops.py Adds optional location param to create_basin and ensure_basin, and introduces three new async methods (list_locations, get_default_location, set_default_location) with proper validation and mapper calls.
src/s2_sdk/_types.py Removes BasinScope enum, adds LocationInfo dataclass with name/is_private fields, updates BasinInfo.scope to location: str
src/s2_sdk/_mappers.py Adds location_info_from_json mapper and updates basin_info_from_json to use data.get('location') string instead of BasinScope enum coercion.
src/s2_sdk/_validators.py Adds validate_location enforcing a 1-64 character length bound, consistent with what the API spec documents for LocationName.
tests/test_account_ops.py Adds three integration tests for location RPCs (marked locations) that are intentionally excluded from CI; includes proper cleanup in finally blocks.
src/s2_sdk/init.py Removes BasinScope from imports and all, adds LocationInfo as the expected public-API surface for the breaking change.
tests/test_validators.py Adds unit tests for validate_location covering the happy path, empty string, and over-length inputs.
.github/workflows/ci.yml Excludes new locations-marked tests from CI integration run, consistent with how access_tokens tests are handled.

Sequence Diagram

sequenceDiagram
    participant User
    participant S2
    participant AccountClient as Account API

    User->>S2: list_locations()
    S2->>AccountClient: GET /v1/locations
    AccountClient-->>S2: [LocationInfo, ...]
    S2-->>User: list[LocationInfo]

    User->>S2: get_default_location()
    S2->>AccountClient: GET /v1/locations/default
    AccountClient-->>S2: LocationInfo
    S2-->>User: LocationInfo

    User->>S2: set_default_location(name)
    S2->>S2: validate_location(name)
    S2->>AccountClient: PUT /v1/locations/default body: name
    AccountClient-->>S2: LocationInfo
    S2-->>User: LocationInfo

    User->>S2: "create_basin(name, location=name)"
    S2->>S2: validate_basin(name)
    S2->>S2: validate_location(location)
    S2->>AccountClient: POST /v1/basins with basin, config, location
    AccountClient-->>S2: BasinInfo
    S2-->>User: BasinInfo
Loading

Reviews (2): Last reviewed commit: "skip location tests for s2-lite as not i..." | Re-trigger Greptile

Comment thread src/s2_sdk/_validators.py
Comment thread src/s2_sdk/_ops.py
Comment thread src/s2_sdk/_types.py
@sgbalogh
Copy link
Copy Markdown
Member Author

@greptile re-review please, see my replies to comments

@quettabit
Copy link
Copy Markdown
Member

i think "feat!: add location ops, replace BasinScope with LocationInfo" would be more appropriate?

Copy link
Copy Markdown
Member

@quettabit quettabit left a comment

Choose a reason for hiding this comment

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

LGTM! (just a comment abt PR title)

@sgbalogh sgbalogh changed the title refactor!: remove BasinScope and replace with LocationName, add related *location* rpcs feat!: add location ops, replace BasinScope with LocationInfo May 23, 2026
@sgbalogh sgbalogh merged commit d1157ad into main May 23, 2026
11 checks passed
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