Repository navigation
feat(api): add plan add-ons to cloud API - #2661
Conversation
📝 WalkthroughWalkthroughThe changes introduce new API endpoints and associated schemas to manage plan add-ons. The OpenAPI specification now defines endpoints for listing, creating, updating, retrieving, and deleting add-on assignments for a plan. Detailed response codes are provided for each operation. In addition, a new interface is added in the cloud specification to support these endpoints by extending an existing interface in the product catalog namespace. Changes
Tip ⚡💬 Agentic Chat (Pro Plan, General Availability)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (6)
api/openapi.cloud.yaml (6)
6806-6879: GET /api/v1/plans/{planId}/addons Endpoint – Verify Parameter and Response Definitions
The GET method for listing add-ons is very comprehensive, with a detailed list of potential response codes and anx-internalflag. However, note that theplanIdparameter uses a union regex pattern (^[a-z0-9]+(?:_[a-z0-9]+)*$|^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$). Please verify that this union pattern is intentional and that it aligns with the internal identifier rules used elsewhere in the API.
6880-6961: POST /api/v1/plans/{planId}/addons Endpoint – Check Regex Consistency
The POST method for creating an add-on assignment is structured well and clearly defines the request body using thePlanAddonCreateschema. One point to note is that theplanIdparameter here uses a single regex pattern (^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$) rather than the union pattern used in the GET method above. Please confirm whether this difference is by design or if the patterns should be made consistent across endpoints.
7046-7124: GET /api/v1/plans/{planId}/addons/{planAddonId} Endpoint – Verify Regex Usage
The GET operation for retrieving a specific add-on assignment is complete with detailed response codes. However, the parameters here revert to using the union regex pattern for bothplanIdandplanAddonId, which differs from the POST, PUT, and DELETE endpoints. Please verify that the use of different regex patterns across operations is intentional and aligns with internal data formats.
7125-7200: DELETE /api/v1/plans/{planId}/addons/{planAddonId} Endpoint – Clarify Description
The DELETE endpoint is defined correctly with appropriate parameters and response codes. The description includes the phrase, "Once a plan is deleted it cannot be undeleted." Since this endpoint is for deleting an add-on assignment—not deleting the entire plan—the description might be misinterpreted. Consider revising it to clarify that it refers to the deletion of the add-on assignment.
17669-17745: PlanAddon Schema – Validate and Enrich Documentation
ThePlanAddonschema is clearly defined, including required fields likecreatedAt,updatedAt,addon, andfromPlanPhase. The nestedaddonobject is well structured with its own properties and constraints. It would be useful to include additional example values (beyond the ones already provided) and confirm that the regex pattern foridconsistently enforces the intended format.
17746-17853: PlanAddonCreate and PlanAddonReplaceUpdate Schemas – Consistency in Create/Update Models
The schemas forPlanAddonCreateandPlanAddonReplaceUpdatemirror each other nicely, ensuring that consumers understand which fields are required when creating or updating an add-on assignment. Ensure that all read-only fields (such askey,version, andinstanceType) are properly handled by the API so that clients do not attempt to override them. Additionally, consider adding minimum or maximum constraints for numeric fields likemaxQuantityif applicable for your business logic.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
api/openapi.cloud.yaml(2 hunks)api/spec/src/cloud/main.tsp(1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (9)
- GitHub Check: Test
- GitHub Check: Quickstart
- GitHub Check: Lint
- GitHub Check: E2E
- GitHub Check: Developer environment
- GitHub Check: CI
- GitHub Check: Commit hooks
- GitHub Check: Build
- GitHub Check: Analyze (go)
🔇 Additional comments (4)
api/spec/src/cloud/main.tsp (1)
220-223: Well-structured API interface addition for plan add-ons.The new
PlanAddonsinterface follows the established architectural pattern in the codebase, extending the baseOpenMeter.ProductCatalog.PlanAddonsinterface while providing a RESTful route structure that allows for operating on add-ons within the context of a specific plan. This aligns perfectly with the PR objective to "add plan add-ons to cloud API".api/openapi.cloud.yaml (3)
6962-7045: PUT /api/v1/plans/{planId}/addons/{planAddonId} Endpoint – Parameter Definitions and Consistency
The PUT operation for updating an add-on assignment is well defined with the required path parameters and detailed response codes. It uses a stricter regex pattern (similar to the POST method) for bothplanIdandplanAddonId. It would be beneficial to review the intended formats to ensure consistency across all endpoints handling these identifiers.
7201-7203: Archive Plan Endpoint – Confirm Inclusion and Documentation
A new endpoint (/api/v1/plans/{planId}/archive) with a POST method (operationId: archivePlan) is introduced at the end of this hunk. Although the primary focus of the PR is on plan add-ons, please confirm that adding the archive endpoint here is intentional and that complete specifications (parameters, responses, etc.) will be documented as needed.
17854-17856: PlanCreate Schema – Verify Unintended Changes
The diff snippet shows that thePlanCreateschema appears right after the add-on schemas. Please check that any modifications toPlanCreateare intentional and do not inadvertently affect existing functionality. If no changes are desired here, ensure that this part of the diff is verified before merging.
Overview
Add
PlanAddonAPI to Cloud API sepc.Summary by CodeRabbit