Skip to content

Conversation

@GAlexIHU
Copy link
Contributor

@GAlexIHU GAlexIHU commented Aug 11, 2025

Overview

Moves CustomerEntitlement APIs under V2 and fixes new EntitlementV2 types.

  • v2 package as spec/src/entitlements/v2: namespace OpenMeter.Entitlements.V2
  • type names (models, unions, etc...) are postfixed with V2 to avoid name-conflicts in generation (e.g. OpenAPI, typenames)
  • fixes type composition for union type and shared sub-types

This is meant to be the final look of the V2 CustomerEntitlement APIs

Summary by CodeRabbit

  • New Features

    • Introduced Entitlements API v2 with customer endpoints (create, list, get, delete, override), grants management, value lookup, history, and reset.
    • Added global grants listing with filtering and pagination.
    • Added v2 entitlement models with discriminated types (metered, static, boolean).
  • Breaking Changes

    • Removed v1 customer entitlements list and all write/grants operations; v1 value lookup remains available.
  • Documentation

    • Updated subjectKey notes to reflect subject deprecation and guidance toward customer APIs.
    • Clarified v2 endpoint paths and behavior.

@GAlexIHU GAlexIHU requested a review from a team as a code owner August 11, 2025 14:53
@GAlexIHU GAlexIHU added the release-note/ignore Ignore this change when generating release notes label Aug 11, 2025
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Aug 11, 2025

📝 Walkthrough

Walkthrough

Removes the v1 customer entitlements list and most management endpoints, adds a new OpenMeter.Entitlements.V2 API (models, customer endpoints, grants), exposes V2 via OpenMeterCloud.Entitlements.V2, updates router handlers/stubs for V2, and keeps the v1 entitlement value lookup.

Changes

Cohort / File(s) Summary
Entitlements V2 package
api/spec/src/entitlements/v2/main.tsp, api/spec/src/entitlements/v2/entitlements.tsp, api/spec/src/entitlements/v2/customer.tsp, api/spec/src/entitlements/v2/grants.tsp
Adds OpenMeter.Entitlements.V2 namespace; introduces EntitlementV2 discriminated union and V2 models (Metered/Boolean/Static + customer fields); adds customer-scoped V2 endpoints (create/list/get/delete/override, grants, value, history, reset) and /api/v2/grants listing.
Remove v1 customer entitlements & prune nested APIs
api/spec/src/entitlements/customer.tsp, api/spec/src/cloud/main.tsp
Deletes top-level v1 CustomerEntitlements list/CRUD surface; removes create/grants/history/reset operations from nested v1 CustomerEntitlement, leaving only v1 entitlement value lookup.
Cloud namespace mapping (V2 exposure)
api/spec/src/cloud/main.tsp
Adds OpenMeterCloud.Entitlements.V2 and maps CustomerEntitlements, CustomerEntitlement, and Grants to V2 types.
Entitlements model adjustments
api/spec/src/entitlements/entitlements.tsp
Updates EntitlementSharedFields.subjectKey docs and changes EntitlementBoolean signature to no longer extend EntitlementSharedFields.
Root spec import
api/spec/src/main.tsp
Imports ./entitlements/v2 into the main API spec.
Server router wiring (V2 stubs + v1 retention)
openmeter/server/router/entitlement.go, openmeter/server/router/credit.go
Adds/renames router handlers for V2 entitlement endpoints (most delegate to unimplemented.*V2 stubs), adds ListGrantsV2 stub for /api/v2/grants, and retains the v1 GET entitlement value handler.
Parser type mapping change
openmeter/entitlement/driver/parser.go
Changes boolean entitlement Type mapping to use api.EntitlementBooleanType instead of a raw string in ToBoolean and updates the EntitlementBoolean field type.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~40 minutes

Possibly related PRs

Tip

🔌 Remote MCP (Model Context Protocol) integration is now available!

Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats.

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/entitlement-api-v2

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.
    • 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.
  • 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 the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

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

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • 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.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 4

🔭 Outside diff range comments (1)
openmeter/server/router/entitlement.go (1)

177-181: V2 value endpoint also drops query params

Same issue as v1 variant: params aren’t forwarded to the driver.

 func (a *Router) GetCustomerEntitlementValueV2(w http.ResponseWriter, r *http.Request, customerIdOrKey string, featureKey string, params api.GetCustomerEntitlementValueV2Params) {
 	a.customerHandler.GetCustomerEntitlementValue().With(customerdriver.GetCustomerEntitlementValueParams{
 		CustomerIDOrKey: customerIdOrKey,
 		FeatureKey:      featureKey,
+		Params:          params,
 	}).ServeHTTP(w, r)
 }
🧹 Nitpick comments (11)
api/spec/src/entitlements/entitlements.tsp (3)

272-276: Clarify and formally deprecate subjectKey in v1 shapes

The note is good, but consider marking subjectKey as deprecated to surface the transition in generated clients and docs, and reference the v2 customer-scoped surface.

   /**
    * The identifier key unique to the subject.
    * NOTE: Subjects are being deprecated, please use the new customer APIs.
    */
   @example("customer-1")
+  #deprecated "Subjects are being deprecated. Use customer-scoped v2 endpoints (OpenMeterCloud.Entitlements.V2.*)."
   subjectKey: Key;

149-151: Typo in docs: “inpurs” → “inputs”

Minor documentation fix.

- * Create inpurs for metered entitlement
+ * Create inputs for metered entitlement

326-329: Typo in docs: “THe” → “The”

Minor documentation fix.

-   * THe usage period of the entitlement.
+   * The usage period of the entitlement.
api/spec/src/entitlements/v2/main.tsp (1)

21-21: Grammar nit: “should will” → “should”

Minor comment clarity fix.

-// NOTE: Public types, operationIDs and friendlyNames of versioned packages should will use the version suffix.
+// NOTE: Public types, operationIDs and friendlyNames of versioned packages should use the version suffix.
api/spec/src/cloud/main.tsp (1)

193-197: Consider deprecating the v1 single-customer entitlement endpoint

To guide migration, flag the v1 endpoint as deprecated in the Cloud surface and reference v2.

   @route("/api/v1/customers/{customerIdOrKey}/entitlements/{featureKey}")
   @tag("Entitlements")
   @tag("Customers")
+  #deprecated "Use /api/v2/customers/{customerIdOrKey}/entitlements/{entitlementIdOrFeatureKey} in OpenMeterCloud.Entitlements.V2."
   interface CustomerEntitlement
     extends OpenMeter.Entitlements.CustomerEntitlement {}
api/spec/src/entitlements/v2/grants.tsp (1)

16-19: Doc points to v1 subjects path; update to v2 customer path

The reference should point to the v2 customer-scoped grants endpoint (or keep it neutral) to avoid confusion.

-   * To fetch the grants of a specific entitlement please use the /api/v1/subjects/{subjectKeyOrID}/entitlements/{entitlementOrFeatureID}/grants endpoint.
+   * To fetch the grants of a specific entitlement, use the customer-scoped endpoint:
+   * /api/v2/customers/{customerIdOrKey}/entitlements/{entitlementIdOrFeatureKey}/grants
api/spec/src/entitlements/v2/entitlements.tsp (1)

33-40: Use Key type for customerKey for consistency

Elsewhere keys use the Key alias. Aligning customerKey improves consistency and any validations/formatting associated to Key.

   @example("customer-1")
-  customerKey?: string;
+  customerKey?: Key;
api/spec/src/entitlements/v2/customer.tsp (2)

84-84: Fix typos in docs

Several small typos; quick cleanup improves spec readability.

-   * Overriding an entitlement creates a new entitlement from the provided inputs and soft deletes the previous entitlement for the provided customer-feature pair. If the previous entitlement is already deleted or otherwise doesnt exist, the override will fail.
+   * Overriding an entitlement creates a new entitlement from the provided inputs and soft deletes the previous entitlement for the provided customer-feature pair. If the previous entitlement is already deleted or otherwise doesn't exist, the override will fail.
-   * Returns historical balance and usage data for the entitlement. The queried history can span accross multiple reset events.
+   * Returns historical balance and usage data for the entitlement. The queried history can span across multiple reset events.
-   * BurndownHistory returns a continous history of segments, where the segments are seperated by events that changed either the grant burndown priority or the usage period.
+   * BurndownHistory returns a continuous history of segments, where the segments are separated by events that changed either the grant burndown priority or the usage period.
-     * Windowsize
+     * Window size
-   * Reset marks the start of a new usage period for the entitlement and initiates grant rollover. At the start of a period usage is zerod out and grants are rolled over based on their rollover settings. It would typically be synced with the customers billing period to enforce usage based on their subscription.
+   * Reset marks the start of a new usage period for the entitlement and initiates grant rollover. At the start of a period usage is zeroed out and grants are rolled over based on their rollover settings. It would typically be synced with the customers billing period to enforce usage based on their subscription.

Also applies to: 170-170, 172-173, 197-197, 208-208


47-52: Confirm intent: mix of cursor and limit/offset pagination

Both QueryPagination and QueryLimitOffset are included. If both styles are intentionally supported concurrently, all good; otherwise, consider exposing only one to avoid ambiguous client usage.

openmeter/server/router/entitlement.go (2)

134-134: Update comments to reference /api/v2 paths for V2 methods

Docstrings still mention /api/v1; adjust to /api/v2 for accuracy.

-// (POST /api/v1/customers/{customerIdOrKey}/entitlements)
+// (POST /api/v2/customers/{customerIdOrKey}/entitlements)

-// (GET /api/v1/customers/{customerIdOrKey}/entitlements)
+// (GET /api/v2/customers/{customerIdOrKey}/entitlements)

-// (GET /api/v1/customers/{customerIdOrKey}/entitlements/{featureKey})
+// (GET /api/v2/customers/{customerIdOrKey}/entitlements/{featureKey})

-// (DELETE /api/v1/customers/{customerIdOrKey}/entitlements/{featureKey})
+// (DELETE /api/v2/customers/{customerIdOrKey}/entitlements/{featureKey})

-// (PUT /api/v1/customers/{customerIdOrKey}/entitlements/{featureKey}/override)
+// (PUT /api/v2/customers/{customerIdOrKey}/entitlements/{featureKey}/override)

-// (GET /api/v1/customers/{customerIdOrKey}/entitlements/{featureKey}/grants)
+// (GET /api/v2/customers/{customerIdOrKey}/entitlements/{featureKey}/grants)

-// (POST /api/v1/customers/{customerIdOrKey}/entitlements/{featureKey}/grants)
+// (POST /api/v2/customers/{customerIdOrKey}/entitlements/{featureKey}/grants)

-// (GET /api/v1/customers/{customerId}/entitlements/{featureKey}/value)
+// (GET /api/v2/customers/{customerId}/entitlements/{featureKey}/value)

-// (GET /api/v1/customers/{customerId}/entitlements/{featureKey}/history)
+// (GET /api/v2/customers/{customerId}/entitlements/{featureKey}/history)

-// (POST /api/v1/customers/{customerId}/entitlements/{featureKey}/reset)
+// (POST /api/v2/customers/{customerId}/entitlements/{featureKey}/reset)

Also applies to: 140-140, 146-146, 152-152, 158-158, 164-164, 170-170, 176-176, 185-185, 191-191


147-149: Param name clarity: consider entitlementIdOrFeatureKey

Specs accept either entitlement ID or feature key; naming the param featureKey may mislead. Consider renaming the parameter to entitlementIdOrFeatureKey for V2 methods to reflect semantics (no functional change).

Also applies to: 153-155, 159-161, 165-167, 171-173, 177-181, 186-188, 192-194

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 1197d9e and 3539159.

📒 Files selected for processing (10)
  • api/spec/src/cloud/main.tsp (1 hunks)
  • api/spec/src/entitlements/customer.tsp (0 hunks)
  • api/spec/src/entitlements/entitlements.tsp (1 hunks)
  • api/spec/src/entitlements/v2/customer.tsp (1 hunks)
  • api/spec/src/entitlements/v2/entitlements.tsp (1 hunks)
  • api/spec/src/entitlements/v2/grants.tsp (1 hunks)
  • api/spec/src/entitlements/v2/main.tsp (1 hunks)
  • api/spec/src/main.tsp (1 hunks)
  • openmeter/server/router/credit.go (1 hunks)
  • openmeter/server/router/entitlement.go (3 hunks)
💤 Files with no reviewable changes (1)
  • api/spec/src/entitlements/customer.tsp
🔇 Additional comments (3)
api/spec/src/main.tsp (1)

22-22: Wire-up for Entitlements V2 looks correct

Importing ./entitlements/v2 here is appropriate and aligns with the new v2 surface.

api/spec/src/cloud/main.tsp (2)

199-215: Good: Cloud surface exposes v2 customer entitlements and grants

V2 Cloud endpoints are correctly namespaced and routed.


212-215: Double-check visibility of v2 grants (internal vs public)

Spec marks v2 grants as x-internal. Confirm whether exposing /api/v2/grants on Cloud is intended for public use; if not, mirror the internal visibility or gate with auth accordingly.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

♻️ Duplicate comments (1)
openmeter/server/router/entitlement.go (1)

114-119: Query param 'time' is ignored in v1; forward it to the handler

The endpoint accepts api.GetCustomerEntitlementValueParams but does not forward the time filter to the driver, so the query parameter is silently dropped.

Apply this diff here to pass the time parameter:

 func (a *Router) GetCustomerEntitlementValue(w http.ResponseWriter, r *http.Request, customerIdOrKey string, featureKey string, params api.GetCustomerEntitlementValueParams) {
 	a.customerHandler.GetCustomerEntitlementValue().With(customerdriver.GetCustomerEntitlementValueParams{
 		CustomerIDOrKey: customerIdOrKey,
 		FeatureKey:      featureKey,
+		Time:            params.Time,
 	}).ServeHTTP(w, r)
 }

Note: customerdriver.GetCustomerEntitlementValueParams currently does not expose a field for Time. Extend it accordingly:

// openmeter/customer/httpdriver/customer.go
// add: import "time"
type (
    GetCustomerEntitlementValueParams = struct {
        CustomerIDOrKey string
        FeatureKey      string
        Time            *time.Time
    }
)

Run this script to locate and update the type and usages:

#!/bin/bash
# Locate the alias/struct for GetCustomerEntitlementValueParams and all usages.
rg -n -A2 -B2 $'GetCustomerEntitlementValueParams\\s*=\\s*struct' openmeter | sed -n '1,120p'
rg -n -A2 -B2 $'GetCustomerEntitlementValue\\(\\)' openmeter | sed -n '1,200p'
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 3539159 and 6792cb1.

📒 Files selected for processing (1)
  • openmeter/server/router/entitlement.go (1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
openmeter/server/router/entitlement.go (5)
openmeter/server/router/router.go (1)
  • Router (217-242)
api/api.gen.go (5)
  • GetCustomerEntitlementValueParams (7821-7823)
  • ListCustomerEntitlementsV2Params (8464-8492)
  • ListCustomerEntitlementGrantsV2Params (8495-8523)
  • GetCustomerEntitlementValueV2Params (8542-8544)
  • GetCustomerEntitlementHistoryV2Params (8526-8539)
api/client/go/client.gen.go (5)
  • GetCustomerEntitlementValueParams (7085-7087)
  • ListCustomerEntitlementsV2Params (7728-7756)
  • ListCustomerEntitlementGrantsV2Params (7759-7787)
  • GetCustomerEntitlementValueV2Params (7806-7808)
  • GetCustomerEntitlementHistoryV2Params (7790-7803)
openmeter/customer/httpdriver/customer.go (1)
  • GetCustomerEntitlementValueParams (333-336)
openmeter/customer/customer.go (1)
  • CustomerIDOrKey (111-114)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: Analyze (go)
  • GitHub Check: Analyze (javascript)
🔇 Additional comments (1)
openmeter/server/router/entitlement.go (1)

133-194: Verify the unimplemented stubs and add the import

I didn’t find any package unimplemented or definitions for the various *CustomerEntitlementV2 stubs in the repo. Please confirm that your generated OpenAPI/Swagger server stubs are present, locate their package path, and then add an import, for example:

 import (
   "net/http"

   "github.com/openmeterio/openmeter/api"
   customerdriver "github.com/openmeterio/openmeter/openmeter/customer/httpdriver"
   entitlementdriver "github.com/openmeterio/openmeter/openmeter/entitlement/driver"
+  unimplemented "<path/to/your/generated/unimplemented/package>"
 )

If you’re not sure where the stubs live, you can search for their definitions:

# Look for any file or directory named “unimplemented”
fd -HI unimplemented
# Or scan for the stub functions once you know where they should be
rg -n '^func\s+CreateCustomerEntitlementV2\(' -S

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

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 (1)
api/spec/src/entitlements/entitlements.tsp (1)

271-277: Mark subjectKey as deprecated to guide migration to V2 customer APIs

The note is helpful, but marking it as deprecated will propagate clearly to OpenAPI clients and docs, aligning with the PR goal of deprecating v1 subject endpoints.

Apply this diff to deprecate the field:

   /**
    * The identifier key unique to the subject.
-   * NOTE: Subjects are being deprecated, please use the new customer APIs.
+   * NOTE: Subjects are being deprecated, please use the new customer APIs.
    */
+  #deprecated "Subjects are deprecated in favor of the customer-scoped APIs under /api/v2. Use the V2 customer endpoints."
   @example("customer-1")
   subjectKey: Key;
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 6792cb1 and 2cb9ce0.

📒 Files selected for processing (3)
  • api/spec/src/entitlements/entitlements.tsp (2 hunks)
  • api/spec/src/entitlements/v2/entitlements.tsp (1 hunks)
  • openmeter/entitlement/driver/parser.go (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • api/spec/src/entitlements/v2/entitlements.tsp
🧰 Additional context used
🧬 Code Graph Analysis (1)
openmeter/entitlement/driver/parser.go (5)
api/api.gen.go (2)
  • EntitlementBooleanType (2654-2654)
  • EntitlementType (3200-3200)
api/client/go/client.gen.go (2)
  • EntitlementBooleanType (2394-2394)
  • EntitlementType (2723-2723)
api/client/javascript/src/client/schemas.ts (1)
  • EntitlementType (10864-10864)
openmeter/entitlement/entitlement.go (1)
  • EntitlementType (294-294)
openmeter/ent/db/entitlement/entitlement.go (1)
  • EntitlementType (171-171)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: Analyze (javascript)
  • GitHub Check: Analyze (go)
🔇 Additional comments (2)
openmeter/entitlement/driver/parser.go (1)

108-108: Boolean Type mapping now correctly uses the generated enum alias

Switching to api.EntitlementBooleanType(boolean.EntitlementType) aligns boolean with metered/static mappings and the generated API types. This improves type-safety without affecting wire format (still string).

api/spec/src/entitlements/entitlements.tsp (1)

361-368: Boolean entitlement model made consistent with metered/static

Refactoring EntitlementBoolean to a standalone model that sets type: EntitlementType.boolean and pulls in fields via OmitProperties matches the pattern used by metered/static. This also enables generators to emit a dedicated EntitlementBooleanType, which unblocks the parser change.

@GAlexIHU GAlexIHU force-pushed the feat/entitlement-api-v2 branch from 39d1e66 to a8d83da Compare August 13, 2025 14:37
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

♻️ Duplicate comments (7)
openmeter/server/router/credit.go (1)

32-34: Compile error: unresolved reference to unimplemented.ListGrantsV2; return 501 stub

This will not compile without an imported/defined unimplemented helper. Use an explicit 501 for now (or import the correct helper if it exists).

 func (a *Router) ListGrantsV2(w http.ResponseWriter, r *http.Request, params api.ListGrantsV2Params) {
-	unimplemented.ListGrantsV2(w, r, params)
+	// TODO: implement V2 grants listing (align with credit handler semantics)
+	http.Error(w, http.StatusText(http.StatusNotImplemented), http.StatusNotImplemented)
 }
openmeter/server/router/entitlement.go (6)

126-127: Fix V2 access route placeholder to {customerIdOrKey}.

Spec and function param use customerIdOrKey; comment still shows {customerId}.

-// (GET /api/v2/customers/{customerId}/access)
+// (GET /api/v2/customers/{customerIdOrKey}/access)

176-177: Fix V2 value route placeholder to {customerIdOrKey}.

Comment shows {customerId}; align with spec/param.

-// (GET /api/v2/customers/{customerId}/entitlements/{featureKey}/value)
+// (GET /api/v2/customers/{customerIdOrKey}/entitlements/{featureKey}/value)

185-186: Fix V2 history route placeholder to {customerIdOrKey}.

-// (GET /api/v2/customers/{customerId}/entitlements/{featureKey}/history)
+// (GET /api/v2/customers/{customerIdOrKey}/entitlements/{featureKey}/history)

191-192: Fix V2 reset route placeholder to {customerIdOrKey}.

-// (POST /api/v2/customers/{customerId}/entitlements/{featureKey}/reset)
+// (POST /api/v2/customers/{customerIdOrKey}/entitlements/{featureKey}/reset)

112-119: Forward query params to driver (v1 value endpoint).

The router drops incoming query params. Forward them to the driver so filters are respected.

 func (a *Router) GetCustomerEntitlementValue(w http.ResponseWriter, r *http.Request, customerIdOrKey string, featureKey string, params api.GetCustomerEntitlementValueParams) {
 	a.customerHandler.GetCustomerEntitlementValue().With(customerdriver.GetCustomerEntitlementValueParams{
 		CustomerIDOrKey: customerIdOrKey,
 		FeatureKey:      featureKey,
+		Params:          params,
 	}).ServeHTTP(w, r)
 }

176-182: Forward the time query param to the driver (V2 value endpoint).

The optional time filter is ignored. Pass it through so downstream handler can honor it.

 func (a *Router) GetCustomerEntitlementValueV2(w http.ResponseWriter, r *http.Request, customerIdOrKey string, featureKey string, params api.GetCustomerEntitlementValueV2Params) {
 	a.customerHandler.GetCustomerEntitlementValue().With(customerdriver.GetCustomerEntitlementValueParams{
 		CustomerIDOrKey: customerIdOrKey,
 		FeatureKey:      featureKey,
+		Time:            params.Time,
 	}).ServeHTTP(w, r)
 }
🧹 Nitpick comments (3)
openmeter/server/router/credit.go (1)

26-28: Nit: fix pluralization in comment (“APIs” not “APIS”)

Micro-typo in the section header.

-// V2 APIS
+// V2 APIs
api/spec/src/entitlements/v2/grants.tsp (2)

16-18: Doc references v1 subject endpoint; confirm intended until v2 subject-scoped grants exist

If v2 subject-scoped grants will be added soon, consider updating this note when available to avoid stale references.


41-49: Clarify precedence when both page and limit/offset are supplied

You include both pagination styles; the doc mentions page takes precedence. Consider adding a brief note in the endpoint description to explicitly state the precedence and any constraints (e.g., disallow mixing in validation).

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 39d1e66 and a8d83da.

📒 Files selected for processing (11)
  • api/spec/src/cloud/main.tsp (1 hunks)
  • api/spec/src/entitlements/customer.tsp (0 hunks)
  • api/spec/src/entitlements/entitlements.tsp (2 hunks)
  • api/spec/src/entitlements/v2/customer.tsp (1 hunks)
  • api/spec/src/entitlements/v2/entitlements.tsp (1 hunks)
  • api/spec/src/entitlements/v2/grants.tsp (1 hunks)
  • api/spec/src/entitlements/v2/main.tsp (1 hunks)
  • api/spec/src/main.tsp (1 hunks)
  • openmeter/entitlement/driver/parser.go (1 hunks)
  • openmeter/server/router/credit.go (1 hunks)
  • openmeter/server/router/entitlement.go (1 hunks)
💤 Files with no reviewable changes (1)
  • api/spec/src/entitlements/customer.tsp
🚧 Files skipped from review as they are similar to previous changes (7)
  • api/spec/src/entitlements/v2/main.tsp
  • api/spec/src/main.tsp
  • openmeter/entitlement/driver/parser.go
  • api/spec/src/entitlements/entitlements.tsp
  • api/spec/src/entitlements/v2/entitlements.tsp
  • api/spec/src/cloud/main.tsp
  • api/spec/src/entitlements/v2/customer.tsp
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (8)
  • GitHub Check: Artifacts / Container image
  • GitHub Check: Artifacts / Benthos Collector Container image
  • GitHub Check: Test
  • GitHub Check: Lint
  • GitHub Check: Migration Checks
  • GitHub Check: Build
  • GitHub Check: Code Generators
  • GitHub Check: Analyze (go)
🔇 Additional comments (3)
api/spec/src/entitlements/v2/grants.tsp (2)

12-50: Spec structure LGTM

Route, tagging, operationId, filters, and return type align with existing V2 patterns. No blocking issues from the spec shape.


1-50: Spec wiring and types are correctly set up
All verifications passed:

  • grants.tsp is imported in api/spec/src/entitlements/v2/main.tsp
  • operationId("listGrantsV2") is unique
  • Referenced types (Grant, GrantOrderBy, ULIDOrExternalKey, QueryPagination, QueryLimitOffset, QueryOrdering) exist in the spec

No further changes required.

openmeter/server/router/entitlement.go (1)

134-137: Confirm ‘unimplemented’ is defined in this package; no import needed

The symbol unimplemented is declared as a package-level var in openmeter/server/router/noop.go (line 9):

package router

import "github.com/openmeterio/openmeter/api"

// noop.go
var unimplemented api.ServerInterface = api.Unimplemented{}

Since entitlement.go is in the same router package, it can reference unimplemented.* without importing a separate package. No changes required.

@GAlexIHU GAlexIHU force-pushed the feat/entitlement-api-v2 branch from a8d83da to a73e1b9 Compare August 18, 2025 09:28
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

♻️ Duplicate comments (2)
openmeter/server/router/credit.go (1)

32-34: Fix compile error: remove unresolved unimplemented.ListGrantsV2 and return 501 stub

unimplemented isn’t imported/defined here, so this won’t compile. Stub the endpoint explicitly until implemented.

Apply:

 func (a *Router) ListGrantsV2(w http.ResponseWriter, r *http.Request, params api.ListGrantsV2Params) {
-	unimplemented.ListGrantsV2(w, r, params)
+	// TODO: implement V2 grants listing
+	http.Error(w, http.StatusText(http.StatusNotImplemented), http.StatusNotImplemented)
 }
openmeter/server/router/entitlement.go (1)

126-126: Align V2 route comments with placeholders {customerIdOrKey}

Comments still reference {customerId}; the V2 contract uses {customerIdOrKey}. Update for consistency with the spec/SDKs.

Apply:

-// (GET /api/v2/customers/{customerId}/access)
+// (GET /api/v2/customers/{customerIdOrKey}/access)
-// (GET /api/v2/customers/{customerId}/entitlements/{featureKey}/value)
+// (GET /api/v2/customers/{customerIdOrKey}/entitlements/{featureKey}/value)
-// (GET /api/v2/customers/{customerId}/entitlements/{featureKey}/history)
+// (GET /api/v2/customers/{customerIdOrKey}/entitlements/{featureKey}/history)
-// (POST /api/v2/customers/{customerId}/entitlements/{featureKey}/reset)
+// (POST /api/v2/customers/{customerIdOrKey}/entitlements/{featureKey}/reset)

Also applies to: 176-177, 185-186, 191-192

📜 Review details

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

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled
  • Linear integration is disabled

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between a8d83da and a73e1b9.

📒 Files selected for processing (11)
  • api/spec/src/cloud/main.tsp (1 hunks)
  • api/spec/src/entitlements/customer.tsp (0 hunks)
  • api/spec/src/entitlements/entitlements.tsp (2 hunks)
  • api/spec/src/entitlements/v2/customer.tsp (1 hunks)
  • api/spec/src/entitlements/v2/entitlements.tsp (1 hunks)
  • api/spec/src/entitlements/v2/grants.tsp (1 hunks)
  • api/spec/src/entitlements/v2/main.tsp (1 hunks)
  • api/spec/src/main.tsp (1 hunks)
  • openmeter/entitlement/driver/parser.go (1 hunks)
  • openmeter/server/router/credit.go (1 hunks)
  • openmeter/server/router/entitlement.go (1 hunks)
💤 Files with no reviewable changes (1)
  • api/spec/src/entitlements/customer.tsp
🚧 Files skipped from review as they are similar to previous changes (7)
  • openmeter/entitlement/driver/parser.go
  • api/spec/src/entitlements/v2/main.tsp
  • api/spec/src/main.tsp
  • api/spec/src/entitlements/v2/grants.tsp
  • api/spec/src/cloud/main.tsp
  • api/spec/src/entitlements/v2/customer.tsp
  • api/spec/src/entitlements/v2/entitlements.tsp
🧰 Additional context used
🧬 Code Graph Analysis (2)
openmeter/server/router/credit.go (3)
openmeter/server/router/router.go (1)
  • Router (217-242)
api/api.gen.go (1)
  • ListGrantsV2Params (8701-8740)
api/client/go/client.gen.go (1)
  • ListGrantsV2Params (8059-8098)
openmeter/server/router/entitlement.go (5)
openmeter/server/router/router.go (1)
  • Router (217-242)
api/api.gen.go (5)
  • GetCustomerEntitlementValueParams (7941-7943)
  • ListCustomerEntitlementsV2Params (8584-8612)
  • ListCustomerEntitlementGrantsV2Params (8615-8643)
  • GetCustomerEntitlementValueV2Params (8662-8664)
  • GetCustomerEntitlementHistoryV2Params (8646-8659)
api/client/go/client.gen.go (5)
  • GetCustomerEntitlementValueParams (7299-7301)
  • ListCustomerEntitlementsV2Params (7942-7970)
  • ListCustomerEntitlementGrantsV2Params (7973-8001)
  • GetCustomerEntitlementValueV2Params (8020-8022)
  • GetCustomerEntitlementHistoryV2Params (8004-8017)
openmeter/customer/httpdriver/customer.go (2)
  • GetCustomerEntitlementValueParams (333-336)
  • GetCustomerAccessParams (384-386)
openmeter/customer/customer.go (1)
  • CustomerIDOrKey (131-134)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (7)
  • GitHub Check: Artifacts / Container image
  • GitHub Check: Lint
  • GitHub Check: Migration Checks
  • GitHub Check: Code Generators
  • GitHub Check: Test
  • GitHub Check: Build
  • GitHub Check: Analyze (go)
🔇 Additional comments (1)
api/spec/src/entitlements/entitlements.tsp (1)

272-274: Spec changes look consistent with V2 direction

  • subjectKey doc tweak adds clear deprecation guidance toward customer APIs.
  • EntitlementBoolean remodeled to mirror the Static/Metered pattern (own type plus OmitProperties), which aligns with the discriminated union.

Also applies to: 361-368

@GAlexIHU GAlexIHU force-pushed the feat/entitlement-api-v2 branch from a73e1b9 to 87f9c4d Compare August 26, 2025 10:30
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

♻️ Duplicate comments (2)
openmeter/server/router/credit.go (1)

32-34: Fix compile error: unresolved reference to unimplemented.ListGrantsV2

This will not compile unless there’s an imported/defined unimplemented helper. If this is a placeholder, return 501 explicitly to keep the server building and make the route behavior clear.

 func (a *Router) ListGrantsV2(w http.ResponseWriter, r *http.Request, params api.ListGrantsV2Params) {
-	unimplemented.ListGrantsV2(w, r, params)
+	// TODO: implement V2 grants listing (align with credit handler semantics)
+	http.Error(w, http.StatusText(http.StatusNotImplemented), http.StatusNotImplemented)
 }
api/spec/src/entitlements/v2/customer.tsp (1)

94-96: Align override() param and body types with the rest of the surface

Other endpoints use ULIDOrKey for entitlementIdOrFeatureKey and fully-qualify the create input type. Keep override consistent to prevent generation mismatches.

   override(
     @path customerIdOrKey: ULIDOrExternalKey,
-    @path entitlementIdOrFeatureKey: ULIDOrExternalKey,
-    @body entitlement: EntitlementCreateInputs,
+    @path entitlementIdOrFeatureKey: ULIDOrKey,
+    @body entitlement: OpenMeter.Entitlements.EntitlementCreateInputs,
   ):
🧹 Nitpick comments (4)
openmeter/server/router/credit.go (2)

26-28: Nit: fix “APIS” header spelling

Use “APIs” (plural, mixed case) for readability.

-// V2 APIS
+// V2 APIs

30-34: Option: temporarily reuse the v1 handler to preserve behavior parity

If the v2 params are compatible (or can be mapped) you can delegate to the existing credit handler instead of returning 501. This avoids a behavioral regression while the dedicated v2 handler lands. If you want, I can propose a small adapter that translates api.ListGrantsV2Params to the v1 ListGrantsParams.

api/spec/src/entitlements/v2/customer.tsp (2)

156-167: Optional: clarify time query parameter semantics

Consider clarifying whether time is evaluated as “effective at” versus “as-of end-of-period” and whether it defaults to now. This reduces ambiguity for consumers and generators.

Example:

-    @query(#{ explode: true }) time?: DateTime,
+    // Point-in-time for value evaluation; defaults to now if omitted.
+    @query(#{ explode: true }) time?: DateTime,

199-205: Optional: consider an enum for time zones to improve validation

If you already have a common type (e.g., IANA TZ string), reference it; otherwise, consider documenting IANA format explicitly.

-    @query windowTimeZone?: string = "UTC",
+    // IANA time zone name (e.g., "UTC", "America/New_York")
+    @query windowTimeZone?: string = "UTC",
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled
  • Linear integration is disabled

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between a73e1b9 and 87f9c4d.

📒 Files selected for processing (11)
  • api/spec/src/cloud/main.tsp (1 hunks)
  • api/spec/src/entitlements/customer.tsp (0 hunks)
  • api/spec/src/entitlements/entitlements.tsp (2 hunks)
  • api/spec/src/entitlements/v2/customer.tsp (1 hunks)
  • api/spec/src/entitlements/v2/entitlements.tsp (1 hunks)
  • api/spec/src/entitlements/v2/grants.tsp (1 hunks)
  • api/spec/src/entitlements/v2/main.tsp (1 hunks)
  • api/spec/src/main.tsp (1 hunks)
  • openmeter/entitlement/driver/parser.go (1 hunks)
  • openmeter/server/router/credit.go (1 hunks)
  • openmeter/server/router/entitlement.go (1 hunks)
💤 Files with no reviewable changes (1)
  • api/spec/src/entitlements/customer.tsp
🚧 Files skipped from review as they are similar to previous changes (8)
  • api/spec/src/main.tsp
  • openmeter/entitlement/driver/parser.go
  • api/spec/src/entitlements/v2/main.tsp
  • api/spec/src/entitlements/v2/grants.tsp
  • api/spec/src/entitlements/entitlements.tsp
  • api/spec/src/cloud/main.tsp
  • openmeter/server/router/entitlement.go
  • api/spec/src/entitlements/v2/entitlements.tsp
🧰 Additional context used
🧬 Code graph analysis (1)
openmeter/server/router/credit.go (2)
openmeter/server/router/router.go (1)
  • Router (217-242)
api/api.gen.go (1)
  • ListGrantsV2Params (8716-8755)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (6)
  • GitHub Check: Lint
  • GitHub Check: Migration Checks
  • GitHub Check: Build
  • GitHub Check: Test
  • GitHub Check: Code Generators
  • GitHub Check: Analyze (go)

@GAlexIHU GAlexIHU changed the title refactor(api): move customerEntitlement APIs under V2 and fix type names refactor(api): finalize CustomerEntitlement APIs under V2 and fix types Aug 26, 2025
@GAlexIHU GAlexIHU force-pushed the feat/entitlement-api-v2 branch from 87f9c4d to 726af66 Compare August 26, 2025 14:51
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

♻️ Duplicate comments (7)
openmeter/server/router/entitlement.go (7)

126-127: Align V2 path comment with spec: {customerIdOrKey}

-// (GET /api/v2/customers/{customerId}/access)
+// (GET /api/v2/customers/{customerIdOrKey}/access)

176-177: Fix V2 path placeholder: {customerIdOrKey}

-// (GET /api/v2/customers/{customerId}/entitlements/{featureKey}/value)
+// (GET /api/v2/customers/{customerIdOrKey}/entitlements/{featureKey}/value)

185-186: Fix V2 path placeholder: {customerIdOrKey}

-// (GET /api/v2/customers/{customerId}/entitlements/{featureKey}/history)
+// (GET /api/v2/customers/{customerIdOrKey}/entitlements/{featureKey}/history)

191-192: Fix V2 path placeholder: {customerIdOrKey}

-// (POST /api/v2/customers/{customerId}/entitlements/{featureKey}/reset)
+// (POST /api/v2/customers/{customerIdOrKey}/entitlements/{featureKey}/reset)

115-119: Forward the optional time query parameter to the driver
This drops params.Time, so client time-based queries are ignored. Also update the driver param struct accordingly.

 func (a *Router) GetCustomerEntitlementValue(w http.ResponseWriter, r *http.Request, customerIdOrKey string, featureKey string, params api.GetCustomerEntitlementValueParams) {
 	a.customerHandler.GetCustomerEntitlementValue().With(customerdriver.GetCustomerEntitlementValueParams{
 		CustomerIDOrKey: customerIdOrKey,
 		FeatureKey:      featureKey,
+		Time:            params.Time,
 	}).ServeHTTP(w, r)
 }

Outside this file (driver), add support for the field:

--- a/openmeter/customer/httpdriver/customer.go
+++ b/openmeter/customer/httpdriver/customer.go
@@
-	GetCustomerEntitlementValueParams   = struct {
-		CustomerIDOrKey string
-		FeatureKey      string
-	}
+	GetCustomerEntitlementValueParams   = struct {
+		CustomerIDOrKey string
+		FeatureKey      string
+		Time            *time.Time
+	}

135-137: *Replace unresolved unimplemented.V2 calls with HTTP 501 stubs to keep build green
The unimplemented symbol isn’t imported/defined here, which will fail compilation. Return explicit 501s (consistent with other stubs) until implementations land.

 func (a *Router) CreateCustomerEntitlementV2(w http.ResponseWriter, r *http.Request, customerIdOrKey string) {
-	unimplemented.CreateCustomerEntitlementV2(w, r, customerIdOrKey)
+	// TODO: implement V2
+	http.Error(w, http.StatusText(http.StatusNotImplemented), http.StatusNotImplemented)
 }
 
 func (a *Router) ListCustomerEntitlementsV2(w http.ResponseWriter, r *http.Request, customerIdOrKey string, params api.ListCustomerEntitlementsV2Params) {
-	unimplemented.ListCustomerEntitlementsV2(w, r, customerIdOrKey, params)
+	// TODO: implement V2
+	http.Error(w, http.StatusText(http.StatusNotImplemented), http.StatusNotImplemented)
 }
 
 func (a *Router) GetCustomerEntitlementV2(w http.ResponseWriter, r *http.Request, customerIdOrKey string, featureKey string) {
-	unimplemented.GetCustomerEntitlementV2(w, r, customerIdOrKey, featureKey)
+	// TODO: implement V2
+	http.Error(w, http.StatusText(http.StatusNotImplemented), http.StatusNotImplemented)
 }
 
 func (a *Router) DeleteCustomerEntitlementV2(w http.ResponseWriter, r *http.Request, customerIdOrKey string, featureKey string) {
-	unimplemented.DeleteCustomerEntitlementV2(w, r, customerIdOrKey, featureKey)
+	// TODO: implement V2
+	http.Error(w, http.StatusText(http.StatusNotImplemented), http.StatusNotImplemented)
 }
 
 func (a *Router) OverrideCustomerEntitlementV2(w http.ResponseWriter, r *http.Request, customerIdOrKey string, featureKey string) {
-	unimplemented.OverrideCustomerEntitlementV2(w, r, customerIdOrKey, featureKey)
+	// TODO: implement V2
+	http.Error(w, http.StatusText(http.StatusNotImplemented), http.StatusNotImplemented)
 }
 
 func (a *Router) ListCustomerEntitlementGrantsV2(w http.ResponseWriter, r *http.Request, customerIdOrKey string, featureKey string, params api.ListCustomerEntitlementGrantsV2Params) {
-	unimplemented.ListCustomerEntitlementGrantsV2(w, r, customerIdOrKey, featureKey, params)
+	// TODO: implement V2
+	http.Error(w, http.StatusText(http.StatusNotImplemented), http.StatusNotImplemented)
 }
 
 func (a *Router) CreateCustomerEntitlementGrantV2(w http.ResponseWriter, r *http.Request, customerIdOrKey string, featureKey string) {
-	unimplemented.CreateCustomerEntitlementGrantV2(w, r, customerIdOrKey, featureKey)
+	// TODO: implement V2
+	http.Error(w, http.StatusText(http.StatusNotImplemented), http.StatusNotImplemented)
 }
 
 func (a *Router) GetCustomerEntitlementHistoryV2(w http.ResponseWriter, r *http.Request, customerIdOrKey string, featureKey string, params api.GetCustomerEntitlementHistoryV2Params) {
-	unimplemented.GetCustomerEntitlementHistoryV2(w, r, customerIdOrKey, featureKey, params)
+	// TODO: implement V2
+	http.Error(w, http.StatusText(http.StatusNotImplemented), http.StatusNotImplemented)
 }
 
 func (a *Router) ResetCustomerEntitlementUsageV2(w http.ResponseWriter, r *http.Request, customerIdOrKey string, featureKey string) {
-	unimplemented.ResetCustomerEntitlementUsageV2(w, r, customerIdOrKey, featureKey)
+	// TODO: implement V2
+	http.Error(w, http.StatusText(http.StatusNotImplemented), http.StatusNotImplemented)
 }

Also applies to: 141-143, 147-149, 153-155, 159-161, 165-167, 171-173, 187-189, 193-194


177-182: Also forward V2 time param to the driver
Same issue as v1—params.Time is dropped.

 func (a *Router) GetCustomerEntitlementValueV2(w http.ResponseWriter, r *http.Request, customerIdOrKey string, featureKey string, params api.GetCustomerEntitlementValueV2Params) {
 	a.customerHandler.GetCustomerEntitlementValue().With(customerdriver.GetCustomerEntitlementValueParams{
 		CustomerIDOrKey: customerIdOrKey,
 		FeatureKey:      featureKey,
+		Time:            params.Time,
 	}).ServeHTTP(w, r)
 }
🧹 Nitpick comments (3)
api/spec/src/entitlements/entitlements.tsp (2)

271-276: Mark subjectKey as deprecated to align with the migration away from subjects

You already communicate deprecation in the description. Make it machine-readable so SDKs/docs surface it consistently.

   /**
    * The identifier key unique to the subject.
    * NOTE: Subjects are being deprecated, please use the new customer APIs.
    */
   @example("customer-1")
-  subjectKey: Key;
+  #deprecated "Subjects are being deprecated. Use customer-scoped V2 APIs instead."
+  subjectKey: Key;

360-368: Boolean model still inherits usagePeriod/currentUsagePeriod via SharedFields

Unlike Metered (Lines 351–353), Boolean does not exclude currentUsagePeriod and usagePeriod from EntitlementSharedFields. If Boolean entitlements aren’t periodized, this leaks fields with unclear semantics. If they are periodized, consider adding read-only annotations similar to the metered calculated fields.

 model EntitlementBoolean {
   type: EntitlementType.boolean;
   ...OmitProperties<
     EntitlementBooleanCreateInputs,
     "type" | "metadata" | "usagePeriod" | "featureKey" | "featureId"
   >;
-  ...OmitProperties<EntitlementSharedFields, "type">;
+  ...OmitProperties<EntitlementSharedFields, "type" | "currentUsagePeriod" | "usagePeriod">;
 }

Follow-up: If Boolean entitlements do need visibility into period boundaries, introduce dedicated calculated fields with @visibility(Lifecycle.Read) as done for Metered, and document their semantics explicitly.

openmeter/server/router/entitlement.go (1)

112-114: Fix path placeholder: use {customerIdOrKey} to match the handler and spec
The function parameter is customerIdOrKey, but the comment shows {customerId}.

-// (GET /api/v1/customers/{customerId}/entitlements/{featureKey}/value)
+// (GET /api/v1/customers/{customerIdOrKey}/entitlements/{featureKey}/value)
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled
  • Linear integration is disabled

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 87f9c4d and 726af66.

📒 Files selected for processing (11)
  • api/spec/src/cloud/main.tsp (1 hunks)
  • api/spec/src/entitlements/customer.tsp (0 hunks)
  • api/spec/src/entitlements/entitlements.tsp (2 hunks)
  • api/spec/src/entitlements/v2/customer.tsp (1 hunks)
  • api/spec/src/entitlements/v2/entitlements.tsp (1 hunks)
  • api/spec/src/entitlements/v2/grants.tsp (1 hunks)
  • api/spec/src/entitlements/v2/main.tsp (1 hunks)
  • api/spec/src/main.tsp (1 hunks)
  • openmeter/entitlement/driver/parser.go (1 hunks)
  • openmeter/server/router/credit.go (1 hunks)
  • openmeter/server/router/entitlement.go (1 hunks)
💤 Files with no reviewable changes (1)
  • api/spec/src/entitlements/customer.tsp
🚧 Files skipped from review as they are similar to previous changes (8)
  • api/spec/src/main.tsp
  • openmeter/server/router/credit.go
  • api/spec/src/entitlements/v2/main.tsp
  • api/spec/src/cloud/main.tsp
  • api/spec/src/entitlements/v2/grants.tsp
  • openmeter/entitlement/driver/parser.go
  • api/spec/src/entitlements/v2/customer.tsp
  • api/spec/src/entitlements/v2/entitlements.tsp
🧰 Additional context used
🧬 Code graph analysis (1)
openmeter/server/router/entitlement.go (4)
openmeter/server/router/router.go (1)
  • Router (217-242)
api/api.gen.go (5)
  • GetCustomerEntitlementValueParams (7958-7960)
  • ListCustomerEntitlementsV2Params (8604-8632)
  • ListCustomerEntitlementGrantsV2Params (8635-8663)
  • GetCustomerEntitlementValueV2Params (8682-8684)
  • GetCustomerEntitlementHistoryV2Params (8666-8679)
openmeter/customer/httpdriver/customer.go (2)
  • GetCustomerEntitlementValueParams (333-336)
  • GetCustomerAccessParams (384-386)
openmeter/customer/customer.go (1)
  • CustomerIDOrKey (131-134)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (8)
  • GitHub Check: Artifacts / Benthos Collector Container image
  • GitHub Check: Artifacts / Container image
  • GitHub Check: Migration Checks
  • GitHub Check: Lint
  • GitHub Check: Code Generators
  • GitHub Check: Test
  • GitHub Check: Build
  • GitHub Check: Analyze (go)
🔇 Additional comments (1)
openmeter/server/router/entitlement.go (1)

112-119: Quick verification script for param forwarding and placeholder consistency
Run to confirm: (1) driver struct has Time, (2) router forwards Time for v1 and v2, (3) no leftover {customerId} placeholders in router comments.

Also applies to: 177-182

@GAlexIHU GAlexIHU merged commit 30c15d4 into main Aug 27, 2025
22 checks passed
@GAlexIHU GAlexIHU deleted the feat/entitlement-api-v2 branch August 27, 2025 12:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants