From ece8c1603f50cd7f24add6f7c053509f3502120f Mon Sep 17 00:00:00 2001 From: Mark Sagi-Kazar Date: Fri, 27 Sep 2024 14:09:34 +0200 Subject: [PATCH 1/7] fix: add missing customer interface to cloud tsp Signed-off-by: Mark Sagi-Kazar --- api/spec/src/cloud/main.tsp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/api/spec/src/cloud/main.tsp b/api/spec/src/cloud/main.tsp index df1797b8a..aa6cccd2a 100644 --- a/api/spec/src/cloud/main.tsp +++ b/api/spec/src/cloud/main.tsp @@ -142,3 +142,7 @@ namespace OpenMeterCloud.Entitlements { @tag("Entitlements (Experimental)") interface Subjects extends OpenMeter.Entitlements.Subjects {} } + +@route("/api/v1/customers") +@tag("Customers") +interface Customers extends OpenMeter.Customers {} From f094dbd5dd9f746d3ee9573255f2d41f36c3ac39 Mon Sep 17 00:00:00 2001 From: Mark Sagi-Kazar Date: Fri, 27 Sep 2024 14:17:41 +0200 Subject: [PATCH 2/7] fix: subject api spec Signed-off-by: Mark Sagi-Kazar --- api/spec/src/cloud/subjects.tsp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/api/spec/src/cloud/subjects.tsp b/api/spec/src/cloud/subjects.tsp index cc4a30a44..74989bc02 100644 --- a/api/spec/src/cloud/subjects.tsp +++ b/api/spec/src/cloud/subjects.tsp @@ -32,8 +32,15 @@ interface Subjects { * If the subject exists, it will be partially updated with the provided fields. */ @post - @operationId("listSubjects") + @operationId("upsertSubject") upsert(@body subject: Subject[]): Subject[] | OpenMeter.CommonErrors; + + /** + * Delete subject by ID or key. + */ + @delete + @operationId("deleteSubject") + delete(@path subjectIdOrKey: string): void | OpenMeter.CommonErrors; } /** From 7c01bb744369343fbb01b2f9a406dc81ad503045 Mon Sep 17 00:00:00 2001 From: Mark Sagi-Kazar Date: Fri, 27 Sep 2024 14:39:35 +0200 Subject: [PATCH 3/7] fix: make event filters optional Signed-off-by: Mark Sagi-Kazar --- api/spec/src/events.tsp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/api/spec/src/events.tsp b/api/spec/src/events.tsp index d335ab0de..89eabfeeb 100644 --- a/api/spec/src/events.tsp +++ b/api/spec/src/events.tsp @@ -27,7 +27,7 @@ interface Events { */ @query @example(utcDateTime.fromISO("2023-01-01T00:00:00Z")) - ingestedAtFrom: utcDateTime, + ingestedAtFrom?: utcDateTime, /** * End date-time in RFC 3339 format. @@ -36,7 +36,7 @@ interface Events { */ @query @example(utcDateTime.fromISO("2023-01-01T00:00:00Z")) - ingestedAtTo: utcDateTime, + ingestedAtTo?: utcDateTime, /** * If not provided lists all events. @@ -47,7 +47,7 @@ interface Events { */ @query @example(false) - hasError: boolean, + hasError?: boolean, /** * The event ID. @@ -56,7 +56,7 @@ interface Events { */ @query @example("my-event-id") - id: string, + id?: string, /** * The event subject. @@ -65,7 +65,7 @@ interface Events { */ @query @example("customer-1") - subject: string, + subject?: string, /** * Start date-time in RFC 3339 format. @@ -74,7 +74,7 @@ interface Events { */ @query @example(utcDateTime.fromISO("2023-01-01T00:00:00Z")) - from: utcDateTime, + from?: utcDateTime, /** * End date-time in RFC 3339 format. @@ -83,7 +83,7 @@ interface Events { */ @query @example(utcDateTime.fromISO("2023-01-01T00:00:00Z")) - to: utcDateTime, + to?: utcDateTime, /** * Number of events to return. @@ -92,7 +92,7 @@ interface Events { @minValue(1) @maxValue(100) @example(100) - limit: integer = 100, + limit?: integer = 100, ): IngestedEvent[] | CommonErrors; @post From e2789ad4c2b71946fd839928bf1d4ee847f6e13d Mon Sep 17 00:00:00 2001 From: Mark Sagi-Kazar Date: Fri, 27 Sep 2024 14:40:30 +0200 Subject: [PATCH 4/7] fix: remove subject from portal meter queries Signed-off-by: Mark Sagi-Kazar --- api/spec/src/portal.tsp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/api/spec/src/portal.tsp b/api/spec/src/portal.tsp index 652c8fd38..b106ef4ca 100644 --- a/api/spec/src/portal.tsp +++ b/api/spec/src/portal.tsp @@ -77,7 +77,7 @@ interface Meters { @route("/{meterSlug}/query") @operationId("queryPortalMeter") @sharedRoute - queryJson(@path meterSlug: Key, ...OpenMeter.MeterQuery, @header accept?: "application/json" = "application/json"): { + queryJson(@path meterSlug: Key, ...OmitProperties, @header accept?: "application/json" = "application/json"): { @header contentType: "application/json"; @body _: MeterQueryResult; } | NotFoundError | CommonErrors; @@ -89,7 +89,7 @@ interface Meters { @route("/{meterSlug}/query") @operationId("queryPortalMeter") @sharedRoute - queryCsv(@path meterSlug: Key, ...OpenMeter.MeterQuery, @header accept?: "text/csv"): { + queryCsv(@path meterSlug: Key, ...OmitProperties, @header accept?: "text/csv"): { @header contentType: "text/csv"; @body From 74b6ff87d65af4e46241455454cc425fc031be81 Mon Sep 17 00:00:00 2001 From: Mark Sagi-Kazar Date: Fri, 27 Sep 2024 14:40:46 +0200 Subject: [PATCH 5/7] fix: make windowSize required in entitlement history Signed-off-by: Mark Sagi-Kazar --- api/spec/src/entitlements/subjects.tsp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/spec/src/entitlements/subjects.tsp b/api/spec/src/entitlements/subjects.tsp index b0d3c9fb6..7f5991502 100644 --- a/api/spec/src/entitlements/subjects.tsp +++ b/api/spec/src/entitlements/subjects.tsp @@ -155,7 +155,7 @@ interface Subjects { /** * Windowsize */ - @query windowSize?: OpenMeter.WindowSize, + @query windowSize: OpenMeter.WindowSize, /** * The timezone used when calculating the windows. From 4c8c6b7ff3d1f88a7770bf13fcc5b93c29c4ccc1 Mon Sep 17 00:00:00 2001 From: Mark Sagi-Kazar Date: Fri, 27 Sep 2024 14:41:04 +0200 Subject: [PATCH 6/7] fix: add missing default values to notifications Signed-off-by: Mark Sagi-Kazar --- api/spec/src/notification/rule.tsp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/api/spec/src/notification/rule.tsp b/api/spec/src/notification/rule.tsp index cd11dcf72..90faa6449 100644 --- a/api/spec/src/notification/rule.tsp +++ b/api/spec/src/notification/rule.tsp @@ -223,7 +223,7 @@ interface Rules { */ @query @example(true) - includeDeleted?: boolean, + includeDeleted?: boolean = false, /** * Include disabled notification rules in response. @@ -232,7 +232,7 @@ interface Rules { */ @query @example(false) - includeDisabled?: boolean, + includeDisabled?: boolean = false, // TODO(chrisgacsal): figure out if there is a way to use union type for attribute like this // where the code generation results a less complicated/more idiomatic code. From 4aa21aa8e2c553d97baeda04f7428142f450edf3 Mon Sep 17 00:00:00 2001 From: Mark Sagi-Kazar Date: Sat, 28 Sep 2024 03:32:01 +0200 Subject: [PATCH 7/7] fix: lint Signed-off-by: Mark Sagi-Kazar --- api/spec/src/portal.tsp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/api/spec/src/portal.tsp b/api/spec/src/portal.tsp index b106ef4ca..9b0ea90f1 100644 --- a/api/spec/src/portal.tsp +++ b/api/spec/src/portal.tsp @@ -77,7 +77,11 @@ interface Meters { @route("/{meterSlug}/query") @operationId("queryPortalMeter") @sharedRoute - queryJson(@path meterSlug: Key, ...OmitProperties, @header accept?: "application/json" = "application/json"): { + queryJson( + @path meterSlug: Key, + ...OmitProperties, + @header accept?: "application/json" = "application/json", + ): { @header contentType: "application/json"; @body _: MeterQueryResult; } | NotFoundError | CommonErrors;