Skip to content

chore: Update client to use versioned API#1512

Open
tpoliaw wants to merge 3 commits intomainfrom
client-api-version
Open

chore: Update client to use versioned API#1512
tpoliaw wants to merge 3 commits intomainfrom
client-api-version

Conversation

@tpoliaw
Copy link
Copy Markdown
Contributor

@tpoliaw tpoliaw commented Apr 24, 2026

No description provided.

@tpoliaw tpoliaw requested a review from a team as a code owner April 24, 2026 13:20
@tpoliaw tpoliaw requested a review from abbiemery April 24, 2026 13:21
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 24, 2026

Codecov Report

❌ Patch coverage is 44.44444% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 95.30%. Comparing base (53af457) to head (2994cde).
⚠️ Report is 4 commits behind head on main.

Files with missing lines Patch % Lines
src/blueapi/client/rest.py 44.44% 5 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1512   +/-   ##
=======================================
  Coverage   95.30%   95.30%           
=======================================
  Files          43       43           
  Lines        3198     3198           
=======================================
  Hits         3048     3048           
  Misses        150      150           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@tpoliaw
Copy link
Copy Markdown
Contributor Author

tpoliaw commented Apr 27, 2026

Should be rebased on #1523 to game the coverage check


def get_plans(self) -> PlanResponse:
return self._request_and_deserialize("/plans", PlanResponse)
return self._request_and_deserialize("/api/v1/plans", PlanResponse)
Copy link
Copy Markdown
Contributor

@ZohebShaikh ZohebShaikh Apr 28, 2026

Choose a reason for hiding this comment

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

    def _request_and_deserialize(
        self,
        suffix: str,
        target_type: type[T],
        data: Mapping[str, Any] | None = None,
        method="GET",
        get_exception: Callable[[requests.Response], Exception | None] = _exception,
        params: Mapping[str, Any] | None = None,
        prefix:str="/api/v1"
    ) -> T:
        url = self._config.url.unicode_string().removesuffix("/") + prefix + suffix

Something like this looks more maintainable ?

This endpoint will need the /api/v1 prefix as well for this to work

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

It would make this a smaller change but does bake in the assumption that v1 will always be the default. If we move to v2 being the main version in future we still need to make this change or accept that we will forever be passing prefix="/api/v2" in every call.

This endpoint will need the /api/v1 prefix as well for this to work

Why couldn't the client pass prefix="" when it was called?

Copy link
Copy Markdown
Contributor

@ZohebShaikh ZohebShaikh Apr 30, 2026

Choose a reason for hiding this comment

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

Why couldn't the client pass prefix="" when it was called?

We can but I think this should have also move to /api/v1 for consistency

It would make this a smaller change but does bake in the assumption that v1 will always be the default. If we move to v2 being the main version in future we still need to make this change or accept that we will forever be passing prefix="/api/v2" in every call.

for v2 if the above approach the call will look like prefix="api/v2" ,"/endpoint" instead of "/api/v2/endpoint" which is kind off annoying But can't we do something like this

def _request_and_deserialize(endpoint,prefix="api/v1"):
   ...
def _request_and_deserialize_v2(endpoint,prefix="api/v2",):
   _request_and_deserialize(endpoint,prefix)
   ...

and call _request_and_deserialize_v2 ?

Personally I like the approach I have mention of using a prefix but I'm not fussed about it

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