✨ add list_cubes method to client#6
Conversation
| cube["name"] | ||
| for cube in response.json().get("cubes", []) | ||
| if isinstance(cube, dict) and isinstance(cube.get("name"), str) |
There was a problem hiding this comment.
can you structure the response as pydantic model? it's the pattern we use for other requests
| measures: list["CubeJSMetaMeasure"] = Field(default_factory=list) | ||
| dimensions: list["CubeJSMetaDimension"] = Field(default_factory=list) | ||
| segments: list["CubeJSMetaSegment"] = Field(default_factory=list) |
There was a problem hiding this comment.
if you use from __future__ import annotations you don't need to use this string reference here, it could be just list[CubeJSMetaMeasure]
| class CubeJSMetaMeasure(BaseModel): | ||
| """CubeJS measure metadata.""" | ||
|
|
||
| name: str | ||
| title: str | ||
| type: str | ||
| short_title: str | None = Field(default=None, alias="shortTitle") | ||
| alias_name: str | None = Field(default=None, alias="aliasName") | ||
| agg_type: str | None = Field(default=None, alias="aggType") | ||
| drill_members: list[str] = Field(default_factory=list, alias="drillMembers") | ||
|
|
||
| class Config: # noqa: D106 | ||
| populate_by_name = True | ||
|
|
||
|
|
||
| class CubeJSMetaDimension(BaseModel): | ||
| """CubeJS dimension metadata.""" | ||
|
|
||
| name: str | ||
| title: str | ||
| type: str | ||
| short_title: str | None = Field(default=None, alias="shortTitle") | ||
| alias_name: str | None = Field(default=None, alias="aliasName") | ||
| suggest_filter_values: bool | None = Field( | ||
| default=None, alias="suggestFilterValues" | ||
| ) | ||
|
|
||
| class Config: # noqa: D106 | ||
| populate_by_name = True | ||
|
|
||
|
|
||
| class CubeJSMetaSegment(BaseModel): | ||
| """CubeJS segment metadata.""" | ||
|
|
||
| name: str | ||
| title: str | ||
| short_title: str | None = Field(default=None, alias="shortTitle") | ||
|
|
||
| class Config: # noqa: D106 | ||
| populate_by_name = True | ||
|
|
||
|
|
||
| class CubeJSMetaResponse(BaseModel): | ||
| """CubeJS metadata response. | ||
|
|
||
| Args: | ||
| cubes: cubejs metadata entries for cubes and views. | ||
|
|
||
| """ | ||
|
|
||
| cubes: list[CubeJSMetaCube] = Field(default_factory=list) |
rafaelleinio
left a comment
There was a problem hiding this comment.
I'll merge and release, thanks for the contribution old friend 🤓
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit a324296. Configure here.
haha it's been a pleasure |

Note
Low Risk
Low risk, additive change that introduces a new metadata call and data models without altering existing query execution logic.
Overview
Adds a new async
list_cubes()client method that calls CubeJSGET /cubejs-api/v1/metawith the same retry/error-handling behavior asget_measures, returning a typedCubeJSMetaResponse.Introduces Pydantic metadata models (
CubeJSMetaCube,CubeJSMetaMeasure,CubeJSMetaDimension,CubeJSMetaSegment) with alias support for CubeJS field names, exports them fromcubejs.__init__, and adds unit tests covering successful parsing/serialization and 400-error handling. Also updatesuv.lock(dependency metadata churn).Reviewed by Cursor Bugbot for commit a324296. Bugbot is set up for automated code reviews on this repo. Configure here.
Implements meta endpoint as a list cubes method