Skip to content

Commit 6ab8a47

Browse files
feat(api): add organization tax config (#4280)
1 parent 6471bb8 commit 6ab8a47

9 files changed

Lines changed: 870 additions & 582 deletions

File tree

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
import "./taxcodes.tsp";
2+
import "./operations.tsp";
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import "@typespec/http";
2+
import "@typespec/rest";
3+
import "@typespec/openapi";
4+
import "@typespec/openapi3";
5+
import "../common/error.tsp";
6+
import "../shared/index.tsp";
7+
import "./taxcodes.tsp";
8+
9+
using TypeSpec.Http;
10+
using TypeSpec.OpenAPI;
11+
12+
namespace Defaults;
13+
14+
interface OrganizationDefaultTaxCodesOperations {
15+
@get
16+
@operationId("get-organization-default-tax-codes")
17+
@summary("Get organization default tax codes")
18+
@extension(Shared.PrivateExtension, true)
19+
@extension(Shared.UnstableExtension, true)
20+
@extension(Shared.InternalExtension, true)
21+
get(
22+
): Shared.GetResponse<OrganizationDefaultTaxCodes> | Common.NotFound | Common.ErrorResponses;
23+
24+
@put
25+
@operationId("update-organization-default-tax-codes")
26+
@summary("Update organization default tax codes")
27+
@extension(Shared.PrivateExtension, true)
28+
@extension(Shared.UnstableExtension, true)
29+
@extension(Shared.InternalExtension, true)
30+
update(
31+
@body body: Shared.UpdateRequest<OrganizationDefaultTaxCodes>,
32+
): Shared.UpsertResponse<OrganizationDefaultTaxCodes> | Common.NotFound | Common.ErrorResponses;
33+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import "../shared/index.tsp";
2+
import "../tax/codes.tsp";
3+
4+
namespace Defaults;
5+
6+
/**
7+
* Organization-level default tax code references.
8+
*
9+
* Stores the default tax codes applied to specific billing contexts for this
10+
* organization. Provisioned automatically when the organization is created.
11+
*/
12+
@friendlyName("OrganizationDefaultTaxCodes")
13+
model OrganizationDefaultTaxCodes {
14+
/**
15+
* Default tax code for invoicing.
16+
*/
17+
@summary("Invoicing tax code")
18+
invoicing_tax_code: Shared.ResourceReference<Tax.TaxCode>;
19+
20+
/**
21+
* Default tax code for credit grants.
22+
*/
23+
@summary("Credit grant tax code")
24+
credit_grant_tax_code: Shared.ResourceReference<Tax.TaxCode>;
25+
26+
/**
27+
* Timestamp of creation.
28+
*/
29+
@visibility(Lifecycle.Read)
30+
created_at: Shared.DateTime;
31+
32+
/**
33+
* Timestamp of last update.
34+
*/
35+
@visibility(Lifecycle.Read)
36+
updated_at: Shared.DateTime;
37+
}

api/spec/packages/aip/src/konnect.tsp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import "./subscriptions/index.tsp";
1212
import "./apps/index.tsp";
1313
import "./billing/index.tsp";
1414
import "./tax/index.tsp";
15+
import "./defaults/index.tsp";
1516

1617
using TypeSpec.Http;
1718
using TypeSpec.OpenAPI;
@@ -52,6 +53,7 @@ using TypeSpec.OpenAPI;
5253
Shared.ProductCatalogTag,
5354
#{ description: Shared.ProductCatalogDescription }
5455
)
56+
@tagMetadata(Shared.DefaultsTag, #{ description: Shared.DefaultsDescription })
5557
@useAuth(systemAccountAccessToken | personalAccessToken | konnectAccessToken)
5658
namespace MeteringAndBilling;
5759

@@ -176,6 +178,11 @@ interface AddonsEndpoints extends ProductCatalog.AddonOperations {}
176178
@tag(Shared.ProductCatalogTag)
177179
interface PlanAddonEndpoints extends ProductCatalog.PlanAddonOperations {}
178180

181+
@route("/openmeter/defaults/tax-codes")
182+
@tag(Shared.DefaultsTag)
183+
interface OrganizationDefaultTaxCodesEndpoints
184+
extends Defaults.OrganizationDefaultTaxCodesOperations {}
185+
179186
/**
180187
* The system account access token is meant for automations and integrations that are not directly associated with a human identity.
181188
*/

api/spec/packages/aip/src/openmeter.tsp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import "./currencies/index.tsp";
1313
import "./features/index.tsp";
1414
import "./llmcost/index.tsp";
1515
import "./productcatalog/index.tsp";
16+
import "./defaults/index.tsp";
1617

1718
using TypeSpec.Http;
1819
using TypeSpec.OpenAPI;
@@ -58,6 +59,7 @@ using TypeSpec.OpenAPI;
5859
Shared.ProductCatalogTag,
5960
#{ description: Shared.ProductCatalogDescription }
6061
)
62+
@tagMetadata(Shared.DefaultsTag, #{ description: Shared.DefaultsDescription })
6163
namespace OpenMeter;
6264

6365
@route("/openmeter/events")
@@ -180,3 +182,8 @@ interface AddonsEndpoints extends ProductCatalog.AddonOperations {}
180182
@route("/openmeter/plans/{planId}/addons")
181183
@tag(Shared.ProductCatalogTag)
182184
interface PlanAddonEndpoints extends ProductCatalog.PlanAddonOperations {}
185+
186+
@route("/openmeter/defaults/tax-codes")
187+
@tag(Shared.DefaultsTag)
188+
interface OrganizationDefaultTaxCodesEndpoints
189+
extends Defaults.OrganizationDefaultTaxCodesOperations {}

api/spec/packages/aip/src/shared/consts.tsp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ const FeaturesDescription = "Features represent product capabilities backed by m
3535
const ProductCatalogTag = "OpenMeter Product Catalog";
3636
const ProductCatalogDescription = "Product catalog manages plans, add-ons, and their associations for subscription-based billing.";
3737

38+
const DefaultsTag = "OpenMeter Defaults";
39+
const DefaultsDescription = "Organization-level default configuration.";
40+
3841
const UnstableExtension = "x-unstable";
3942
const InternalExtension = "x-internal";
4043
const PrivateExtension = "x-private";

0 commit comments

Comments
 (0)