| import "@typespec/http"; |
| import "@typespec/openapi"; |
| import "@typespec/openapi3"; |
| import "../shared/index.tsp"; |
| import "../common/error.tsp"; |
| import "../common/pagination.tsp"; |
| import "../common/parameters.tsp"; |
| import "./subscription.tsp"; |
| import "./subscriptionaddon.tsp"; |
|
|
| using TypeSpec.Http; |
| using TypeSpec.OpenAPI; |
|
|
| namespace Subscriptions; |
|
|
| |
| |
| |
| @friendlyName("BillingSubscriptionCancel") |
| model SubscriptionCancel { |
| |
| |
| |
| timing?: SubscriptionEditTiming = SubscriptionEditTimingEnum.Immediate; |
| } |
|
|
| |
| |
| |
| @friendlyName("BillingSubscriptionChange") |
| model SubscriptionChange { |
| ...OmitProperties<SubscriptionCreate, "customer_id" | "customer_key">; |
|
|
| |
| |
| |
| |
| |
| timing: SubscriptionEditTiming; |
| } |
|
|
| |
| |
| |
| @friendlyName("BillingSubscriptionChangeResponse") |
| model SubscriptionChangeResponse { |
| |
| |
| |
| current: Subscription; |
|
|
| |
| |
| |
| next: Subscription; |
| } |
|
|
| |
| |
| |
| #suppress "@openmeter/api-spec-aip/repeated-prefix-grouping" "plan_id and plan_key should not be grouped" |
| @friendlyName("ListSubscriptionsParamsFilter") |
| model ListSubscriptionsParamsFilter { |
| #suppress "@openmeter/api-spec-aip/doc-decorator" "shared model" |
| id?: Common.ULIDFieldFilter; |
| #suppress "@openmeter/api-spec-aip/doc-decorator" "shared model" |
| customer_id?: Common.ULIDFieldFilter; |
| #suppress "@openmeter/api-spec-aip/doc-decorator" "shared model" |
| status?: Common.StringFieldFilterExact; |
| #suppress "@openmeter/api-spec-aip/doc-decorator" "shared model" |
| plan_id?: Common.ULIDFieldFilter; |
| #suppress "@openmeter/api-spec-aip/doc-decorator" "shared model" |
| plan_key?: Common.StringFieldFilterExact; |
| } |
|
|
| interface SubscriptionsOperations { |
| @post |
| @operationId("create-subscription") |
| @summary("Create subscription") |
| create(@body subscription: SubscriptionCreate): |
| | Shared.CreateResponse<Subscription> |
| | Common.NotFound |
| | Common.Conflict |
| | Common.ErrorResponses; |
|
|
| @get |
| @operationId("list-subscriptions") |
| @summary("List subscriptions") |
| list( |
| ...Common.PagePaginationQuery, |
|
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| @query(#{ name: "sort" }) |
| sort?: Common.SortQuery, |
|
|
| |
| |
| |
| @query(#{ style: "deepObject", explode: true }) |
| filter?: ListSubscriptionsParamsFilter, |
| ): |
| | Shared.PagePaginatedResponse<Subscription> |
| | Common.NotFound |
| | Common.ErrorResponses; |
|
|
| @get |
| @operationId("get-subscription") |
| @summary("Get subscription") |
| get(@path subscriptionId: Shared.ULID): |
| | Shared.GetResponse<Subscription> |
| | Common.NotFound |
| | Common.ErrorResponses; |
|
|
| |
| |
| |
| |
| @post |
| @operationId("cancel-subscription") |
| @summary("Cancel subscription") |
| @route("/{subscriptionId}/cancel") |
| cancel(@path subscriptionId: Shared.ULID, @body body: SubscriptionCancel): |
| | Shared.UpdateResponse<Subscription> |
| | Common.NotFound |
| | Common.Conflict |
| | Common.ErrorResponses; |
|
|
| |
| |
| |
| @post |
| @operationId("unschedule-cancelation") |
| @summary("Unschedule subscription cancelation") |
| @route("/{subscriptionId}/unschedule-cancelation") |
| unscheduleCancelation(@path subscriptionId: Shared.ULID): |
| | Shared.UpdateResponse<Subscription> |
| | Common.NotFound |
| | Common.Conflict |
| | Common.ErrorResponses; |
|
|
| |
| |
| |
| |
| @post |
| @operationId("change-subscription") |
| @summary("Change subscription") |
| @route("/{subscriptionId}/change") |
| change( |
| @path subscriptionId: Shared.ULID, |
|
|
| @body |
| body: SubscriptionChange, |
| ): |
| | SubscriptionChangeResponse |
| | Common.NotFound |
| | Common.Conflict |
| | Common.ErrorResponses; |
| } |
|
|
| interface SubscriptionAddonOperations { |
| |
| |
| |
| @post |
| @operationId("create-subscription-addon") |
| @summary("Create a new subscription add-on") |
| @extension(Shared.UnstableExtension, true) |
| @extension(Shared.InternalExtension, true) |
| create( |
| @path subscriptionId: Shared.ULID, |
| @body request: Shared.CreateRequest<SubscriptionAddon>, |
| ): |
| | Shared.CreateResponse<SubscriptionAddon> |
| | Common.ErrorResponses |
| | Common.NotFound |
| | Common.Conflict; |
|
|
| |
| |
| |
| @get |
| @operationId("list-subscription-addons") |
| @summary("List subscription addons") |
| @extension(Shared.UnstableExtension, true) |
| list( |
| @path subscriptionId: Shared.ULID, |
| ...Common.PagePaginationQuery, |
|
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| @query(#{ name: "sort" }) |
| sort?: Common.SortQuery, |
| ): |
| | Shared.PagePaginatedResponse<SubscriptionAddon> |
| | Common.NotFound |
| | Common.ErrorResponses; |
|
|
| |
| |
| |
| @get |
| @route("/{subscriptionAddonId}") |
| @operationId("get-subscription-addon") |
| @summary("Get add-on association for subscription") |
| @extension(Shared.UnstableExtension, true) |
| getAddon( |
| @path subscriptionId: Shared.ULID, |
| @path subscriptionAddonId: Shared.ULID, |
| ): |
| | Shared.GetResponse<SubscriptionAddon> |
| | Common.ErrorResponses |
| | Common.NotFound; |
| } |
|
|