-
Notifications
You must be signed in to change notification settings - Fork 17
feat: update Releases API #61
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
akhil-vamshi-konam
wants to merge
3
commits into
main
Choose a base branch
from
feat-update-releases
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
e17d1ba
chore: enhance Releases API with pagination support
akhil-vamshi-konam 7491e83
refactor: update work items and release tests to use paginated respon…
akhil-vamshi-konam 84ce79d
refactor: update ReleaseItemLabels and ReleaseWorkItems to use new re…
akhil-vamshi-konam File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,89 @@ | ||
| from __future__ import annotations | ||
|
|
||
| from collections.abc import Mapping | ||
| from typing import Any | ||
|
|
||
| from ...models.releases import ( | ||
| CreateReleaseComment, | ||
| PaginatedReleaseCommentResponse, | ||
| ReleaseComment, | ||
| UpdateReleaseComment, | ||
| ) | ||
| from ..base_resource import BaseResource | ||
|
|
||
|
|
||
| class ReleaseComments(BaseResource): | ||
| """API client for the comments on a release.""" | ||
|
|
||
| def __init__(self, config: Any) -> None: | ||
| super().__init__(config, "/workspaces/") | ||
|
|
||
| def list( | ||
| self, workspace_slug: str, release_id: str, params: Mapping[str, Any] | None = None | ||
| ) -> PaginatedReleaseCommentResponse: | ||
| """List the comments on a release (paginated). | ||
|
|
||
| Returns one page (20 by default). Pass `per_page`/`cursor` in params and | ||
| follow `next_cursor` to page through the rest. | ||
|
|
||
| Args: | ||
| workspace_slug: The workspace slug identifier | ||
| release_id: UUID of the release | ||
| params: Optional query parameters, e.g. `per_page`, `cursor` | ||
| """ | ||
| response = self._get(f"{workspace_slug}/releases/{release_id}/comments/", params=params) | ||
| return PaginatedReleaseCommentResponse.model_validate(response) | ||
|
|
||
| def retrieve(self, workspace_slug: str, release_id: str, comment_id: str) -> ReleaseComment: | ||
| """Retrieve a release comment by ID. | ||
|
|
||
| Args: | ||
| workspace_slug: The workspace slug identifier | ||
| release_id: UUID of the release | ||
| comment_id: UUID of the comment | ||
| """ | ||
| response = self._get(f"{workspace_slug}/releases/{release_id}/comments/{comment_id}/") | ||
| return ReleaseComment.model_validate(response) | ||
|
|
||
| def create( | ||
| self, workspace_slug: str, release_id: str, data: CreateReleaseComment | ||
| ) -> ReleaseComment: | ||
| """Create a comment on a release. | ||
|
|
||
| Args: | ||
| workspace_slug: The workspace slug identifier | ||
| release_id: UUID of the release | ||
| data: Comment data (body as `comment_html`) | ||
| """ | ||
| response = self._post( | ||
| f"{workspace_slug}/releases/{release_id}/comments/", | ||
| data.model_dump(exclude_none=True), | ||
| ) | ||
| return ReleaseComment.model_validate(response) | ||
|
|
||
| def update( | ||
| self, workspace_slug: str, release_id: str, comment_id: str, data: UpdateReleaseComment | ||
| ) -> ReleaseComment: | ||
| """Update a release comment by ID. | ||
|
|
||
| Args: | ||
| workspace_slug: The workspace slug identifier | ||
| release_id: UUID of the release | ||
| comment_id: UUID of the comment | ||
| data: Updated comment data | ||
| """ | ||
| response = self._patch( | ||
| f"{workspace_slug}/releases/{release_id}/comments/{comment_id}/", | ||
| data.model_dump(exclude_none=True), | ||
| ) | ||
| return ReleaseComment.model_validate(response) | ||
|
|
||
| def delete(self, workspace_slug: str, release_id: str, comment_id: str) -> None: | ||
| """Delete a release comment by ID. | ||
|
|
||
| Args: | ||
| workspace_slug: The workspace slug identifier | ||
| release_id: UUID of the release | ||
| comment_id: UUID of the comment | ||
| """ | ||
| return self._delete(f"{workspace_slug}/releases/{release_id}/comments/{comment_id}/") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,49 +1,64 @@ | ||
| from __future__ import annotations | ||
|
|
||
| from collections.abc import Mapping | ||
| from typing import Any | ||
|
|
||
| from ...models.releases import AddReleaseItemLabel, ReleaseLabel | ||
| from ...models.releases import ( | ||
| AddReleaseItemLabel, | ||
| PaginatedReleaseLabelResponse, | ||
| ReleaseLabel, | ||
| RemoveReleaseItemLabel, | ||
| ) | ||
| from ..base_resource import BaseResource | ||
|
|
||
|
|
||
| class ReleaseItemLabels(BaseResource): | ||
| """API client for managing labels on a specific release.""" | ||
| """API client for managing the labels attached to a specific release.""" | ||
|
|
||
| def __init__(self, config: Any) -> None: | ||
| super().__init__(config, "/workspaces/") | ||
|
|
||
| def list(self, workspace_slug: str, release_id: str) -> list[ReleaseLabel]: | ||
| """List labels assigned to a release. | ||
| def list( | ||
| self, workspace_slug: str, release_id: str, params: Mapping[str, Any] | None = None | ||
| ) -> PaginatedReleaseLabelResponse: | ||
| """List labels attached to a release (paginated). | ||
|
|
||
| Returns one page (20 by default). Pass `per_page`/`cursor` in params and | ||
| follow `next_cursor` to page through the rest. | ||
|
|
||
| Args: | ||
| workspace_slug: The workspace slug identifier | ||
| release_id: UUID of the release | ||
| params: Optional query parameters, e.g. `per_page`, `cursor` | ||
| """ | ||
| response = self._get(f"{workspace_slug}/releases/{release_id}/labels/") | ||
| return [ReleaseLabel.model_validate(item) for item in response] | ||
| response = self._get(f"{workspace_slug}/releases/{release_id}/labels/", params=params) | ||
| return PaginatedReleaseLabelResponse.model_validate(response) | ||
|
|
||
| def create( | ||
| self, workspace_slug: str, release_id: str, data: AddReleaseItemLabel | ||
| ) -> list[ReleaseLabel]: | ||
| """Add labels to a release. | ||
| """Attach labels to a release. | ||
|
|
||
| Args: | ||
| workspace_slug: The workspace slug identifier | ||
| release_id: UUID of the release | ||
| data: Label IDs to add | ||
| data: Label IDs to attach | ||
| """ | ||
| response = self._post( | ||
| f"{workspace_slug}/releases/{release_id}/labels/", | ||
| data.model_dump(exclude_none=True), | ||
| ) | ||
| return [ReleaseLabel.model_validate(item) for item in response] | ||
|
|
||
| def delete(self, workspace_slug: str, release_id: str, label_id: str) -> None: | ||
| """Remove a label from a release. | ||
| def delete(self, workspace_slug: str, release_id: str, data: RemoveReleaseItemLabel) -> None: | ||
| """Detach labels from a release (the labels themselves are not deleted). | ||
|
|
||
| Args: | ||
| workspace_slug: The workspace slug identifier | ||
| release_id: UUID of the release | ||
| label_id: UUID of the label to remove | ||
| data: Label IDs to detach | ||
| """ | ||
| return self._delete(f"{workspace_slug}/releases/{release_id}/labels/{label_id}/") | ||
| return self._delete( | ||
| f"{workspace_slug}/releases/{release_id}/labels/", | ||
| data.model_dump(exclude_none=True), | ||
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🗄️ Data Integrity & Integration | 🟠 Major | 🏗️ Heavy lift
Use typed Pydantic models for pagination parameters.
The new list methods expose raw
Mapping[str, Any]inputs, bypassing validation and the repository’s DTO contract.plane/api/releases/base.py#L35-L48: accept and serialize a release-list query model.plane/api/releases/tags.py#L21-L34: accept and serialize a tag-list query model.plane/api/releases/labels.py#L21-L34: accept and serialize a label-list query model.plane/api/releases/item_labels.py#L20-L34: accept and serialize an item-label query model.plane/api/releases/work_items.py#L19-L33: accept and serialize a work-item query model.plane/api/releases/comments.py#L21-L35: accept and serialize a comment query model.plane/api/releases/links.py#L21-L35: accept and serialize a link query model.As per coding guidelines, resource methods must accept Pydantic DTOs and serialize them with
model_dump(exclude_none=True).📍 Affects 7 files
plane/api/releases/base.py#L35-L48(this comment)plane/api/releases/tags.py#L21-L34plane/api/releases/labels.py#L21-L34plane/api/releases/item_labels.py#L20-L34plane/api/releases/work_items.py#L19-L33plane/api/releases/comments.py#L21-L35plane/api/releases/links.py#L21-L35🤖 Prompt for AI Agents
Source: Coding guidelines