Skip to content

Commit 4e6b440

Browse files
author
Tim Roes
committed
feat: add organization balance API (#13964)
1 parent eb28d9b commit 4e6b440

File tree

3 files changed

+117
-1
lines changed

3 files changed

+117
-1
lines changed

airbyte-api/problems-api/src/main/openapi/api-problems.yaml

+32
Original file line numberDiff line numberDiff line change
@@ -549,6 +549,38 @@ components:
549549
default: An unexpected error occurred when creating your GitHub contribution.
550550
data:
551551
$ref: "#/components/schemas/GithubContributionProblemData"
552+
BillingSubscriptionRequiredProblemResponse:
553+
x-implements: io.airbyte.api.problems.ProblemResponse
554+
type: object
555+
allOf:
556+
- $ref: "#/components/schemas/BaseProblemFields"
557+
- type: object
558+
properties:
559+
status:
560+
type: integer
561+
default: 404
562+
type:
563+
type: string
564+
default: error:billing/subscription/subscription-required
565+
title:
566+
type: string
567+
default: A subscription is required for this operation to succeed.
568+
BillingTooManyNonPrepaidSubscriptionsProblemResponse:
569+
x-implements: io.airbyte.api.problems.ProblemResponse
570+
type: object
571+
allOf:
572+
- $ref: "#/components/schemas/BaseProblemFields"
573+
- type: object
574+
properties:
575+
status:
576+
type: integer
577+
default: 400
578+
type:
579+
type: string
580+
default: error:billing/subscription/too-many-incompatible-subscriptions
581+
title:
582+
type: string
583+
default: Found more than one subscription with some not being prepaid.
552584
ProblemCronData:
553585
type: object
554586
properties:

airbyte-api/server-api/src/main/openapi/config.yaml

+75-1
Original file line numberDiff line numberDiff line change
@@ -4609,6 +4609,25 @@ paths:
46094609
application/json:
46104610
schema:
46114611
$ref: "#/components/schemas/PaymentInformationRead"
4612+
/v1/billing/organization_balance:
4613+
post:
4614+
summary: Get the current balance of an organization
4615+
tags:
4616+
- billing
4617+
- cloud-only
4618+
operationId: getOrganizationBalance
4619+
requestBody:
4620+
content:
4621+
application/json:
4622+
schema:
4623+
$ref: "#/components/schemas/OrganizationIdRequestBody"
4624+
responses:
4625+
"200":
4626+
description: Successfully got organization's balance
4627+
content:
4628+
application/json:
4629+
schema:
4630+
$ref: "#/components/schemas/OrganizationBalanceRead"
46124631
/v1/organizations/get:
46134632
post:
46144633
summary: Get an organization info
@@ -10431,6 +10450,56 @@ components:
1043110450
$ref: "#/components/schemas/AddressRead"
1043210451
defaultPaymentMethod:
1043310452
$ref: "#/components/schemas/PaymentMethodRead"
10453+
OrganizationBalanceRead:
10454+
type: object
10455+
required:
10456+
- upcomingInvoice
10457+
- planType
10458+
properties:
10459+
planType:
10460+
description: Whether the customer is on a prepaid or in_arrears type plan. This is only used during the migration and will be removed after the migration again.
10461+
type: string
10462+
enum:
10463+
- in_arrears
10464+
- prepaid
10465+
deprecated: true
10466+
upcomingInvoice:
10467+
type: object
10468+
required:
10469+
- currency
10470+
- amount
10471+
- dueDate
10472+
properties:
10473+
currency:
10474+
type: string
10475+
amount:
10476+
type: string
10477+
description: The amount of the next upcoming invoice formatted as a decimal number wrapped inside a string.
10478+
dueDate:
10479+
$ref: "#/components/schemas/LocalDate"
10480+
credits:
10481+
type: object
10482+
required:
10483+
- balance
10484+
- blocks
10485+
properties:
10486+
balance:
10487+
type: number
10488+
format: double
10489+
blocks:
10490+
type: array
10491+
items:
10492+
$ref: "#/components/schemas/CreditBlockRead"
10493+
CreditBlockRead:
10494+
type: object
10495+
required:
10496+
- amount
10497+
properties:
10498+
amount:
10499+
type: number
10500+
format: double
10501+
expiryDate:
10502+
$ref: "#/components/schemas/ISO8601DateTime"
1043410503

1043510504
# ORGANIZATIONS
1043610505
OrganizationId:
@@ -14250,10 +14319,15 @@ components:
1425014319
- destination
1425114320
x-sdk-component: true
1425214321

14322+
LocalDate:
14323+
type: string
14324+
format: date
14325+
x-field-extra-annotation: '@com.fasterxml.jackson.annotation.JsonFormat(pattern="yyyy-MM-dd")'
14326+
1425314327
ISO8601DateTime:
1425414328
type: string
1425514329
format: date-time
14256-
x-field-extra-annotation: '@com.fasterxml.jackson.annotation.JsonFormat(pattern="yyyy-MM-dd''T''HH:mm:ss.SSS''Z''")'
14330+
x-field-extra-annotation: '@com.fasterxml.jackson.annotation.JsonFormat(pattern="yyyy-MM-dd''T''HH:mm:ss.SSSZ")'
1425714331

1425814332
DiagnosticReportRequestBody:
1425914333
type: object

airbyte-server/src/main/kotlin/io/airbyte/server/apis/controllers/BillingController.kt

+10
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import io.airbyte.api.generated.BillingApi
44
import io.airbyte.api.model.generated.CustomerPortalRead
55
import io.airbyte.api.model.generated.CustomerPortalRequestBody
66
import io.airbyte.api.model.generated.ListInvoicesRead
7+
import io.airbyte.api.model.generated.OrganizationBalanceRead
78
import io.airbyte.api.model.generated.OrganizationIdRequestBody
89
import io.airbyte.api.model.generated.PaymentInformationRead
910
import io.airbyte.api.problems.throwable.generated.ApiNotImplementedInOssProblem
@@ -43,4 +44,13 @@ open class BillingController : BillingApi {
4344
): PaymentInformationRead {
4445
throw ApiNotImplementedInOssProblem()
4546
}
47+
48+
@RequiresIntent(Intent.ManageOrganizationBilling)
49+
@Post("/organization_balance")
50+
@ExecuteOn(AirbyteTaskExecutors.IO)
51+
override fun getOrganizationBalance(
52+
@Body organizationIdRequestBody: OrganizationIdRequestBody,
53+
): OrganizationBalanceRead {
54+
throw ApiNotImplementedInOssProblem()
55+
}
4656
}

0 commit comments

Comments
 (0)