Skip to content

feat(api): add plan add-ons to cloud API - #2661

Merged
chrisgacsal merged 1 commit into
mainfrom
feat/productcatalog
Apr 14, 2025
Merged

chrisgacsal merged 1 commit into
mainfrom
feat/productcatalog

Conversation

@chrisgacsal

@chrisgacsal chrisgacsal commented Apr 14, 2025 •

Copy link
Copy Markdown
Collaborator

Overview

Add PlanAddon API to Cloud API sepc.

Summary by CodeRabbit

  • New Features
    • Expanded the API with new endpoints for managing add-ons linked to specific plans, enabling operations such as listing, creating, updating, retrieving, and deleting add-on assignments.
    • Introduced an enhanced interface for add-on management within the product catalog.

@chrisgacsal chrisgacsal added area/api release-note/ignore Ignore this change when generating release notes labels Apr 14, 2025
@chrisgacsal chrisgacsal self-assigned this Apr 14, 2025
@chrisgacsal
chrisgacsal requested a review from a team as a code owner April 14, 2025 11:26
@coderabbitai

coderabbitai Bot commented Apr 14, 2025 •

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

The 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

File(s) Change Summary
api/openapi.cloud.yaml Added endpoints at /api/v1/plans/{planId}/addons (GET for listing and POST for creation) and /api/v1/plans/{planId}/addons/{planAddonId} (PUT for update, GET for retrieval, DELETE for removal) along with corresponding response codes; introduced schemas: PlanAddon, PlanAddonCreate, and PlanAddonReplaceUpdate.
api/spec/.../main.tsp Added the PlanAddons interface in the OpenMeterCloud.ProductCatalog namespace, extending OpenMeter.ProductCatalog.PlanAddons and associating it with the route /api/v1/plans/{planId}/addons.

Tip

⚡💬 Agentic Chat (Pro Plan, General Availability)
  • We're introducing multi-step agentic chat in review comments and issue comments, within and outside of PR's. This feature enhances review and issue discussions with the CodeRabbit agentic chat by enabling advanced interactions, including the ability to create pull requests directly from comments and add commits to existing pull requests.

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.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai plan to trigger planning for file edits and PR creation.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@chrisgacsal
chrisgacsal requested a review from tothandras April 14, 2025 11:27

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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 an x-internal flag. However, note that the planId parameter 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 the PlanAddonCreate schema. One point to note is that the planId parameter 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 both planId and planAddonId, 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
The PlanAddon schema is clearly defined, including required fields like createdAt, updatedAt, addon, and fromPlanPhase. The nested addon object 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 for id consistently enforces the intended format.


17746-17853: PlanAddonCreate and PlanAddonReplaceUpdate Schemas – Consistency in Create/Update Models
The schemas for PlanAddonCreate and PlanAddonReplaceUpdate mirror 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 as key, version, and instanceType) 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 like maxQuantity if applicable for your business logic.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c1e8d23 and e5ebb2f.

📒 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 PlanAddons interface follows the established architectural pattern in the codebase, extending the base OpenMeter.ProductCatalog.PlanAddons interface 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 both planId and planAddonId. 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 the PlanCreate schema appears right after the add-on schemas. Please check that any modifications to PlanCreate are 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/api release-note/ignore Ignore this change when generating release notes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants