diff --git a/components/server/ee/src/billing/billing-service.ts b/components/server/ee/src/billing/billing-service.ts index 19a37c5edbf418..de98f317c83c2a 100644 --- a/components/server/ee/src/billing/billing-service.ts +++ b/components/server/ee/src/billing/billing-service.ts @@ -7,11 +7,8 @@ import { User } from "@gitpod/gitpod-protocol"; import { AttributionId } from "@gitpod/gitpod-protocol/lib/attribution"; import { log } from "@gitpod/gitpod-protocol/lib/util/logging"; -import { GetUpcomingInvoiceResponse } from "@gitpod/usage-api/lib/usage/v1/billing_pb"; -import { - CachingUsageServiceClientProvider, - CachingBillingServiceClientProvider, -} from "@gitpod/usage-api/lib/usage/v1/sugar"; +import { BillingServiceClient, BillingServiceDefinition } from "@gitpod/usage-api/lib/usage/v1/billing.pb"; +import { UsageServiceClient, UsageServiceDefinition } from "@gitpod/usage-api/lib/usage/v1/usage.pb"; import { inject, injectable } from "inversify"; import { UserService } from "../../../src/user/user-service"; @@ -24,14 +21,18 @@ export interface UsageLimitReachedResult { @injectable() export class BillingService { @inject(UserService) protected readonly userService: UserService; - @inject(CachingUsageServiceClientProvider) - protected readonly usageServiceClientProvider: CachingUsageServiceClientProvider; - @inject(CachingBillingServiceClientProvider) - protected readonly billingServiceClientProvider: CachingBillingServiceClientProvider; + @inject(UsageServiceDefinition.name) + protected readonly usageService: UsageServiceClient; + @inject(BillingServiceDefinition.name) + protected readonly billingService: BillingServiceClient; async checkUsageLimitReached(user: User): Promise { const attributionId = await this.userService.getWorkspaceUsageAttributionId(user); - const costCenter = await this.usageServiceClientProvider.getDefault().getCostCenter(attributionId); + const costCenter = ( + await this.usageService.getCostCenter({ + attributionId: AttributionId.render(attributionId), + }) + ).costCenter; if (!costCenter) { const err = new Error("No CostCenter found"); log.error({ userId: user.id }, err.message, err, { attributionId }); @@ -42,9 +43,9 @@ export class BillingService { }; } - const upcomingInvoice = await this.getUpcomingInvoice(attributionId); - const currentInvoiceCredits = upcomingInvoice.getCredits(); - if (currentInvoiceCredits >= costCenter.spendingLimit) { + const upcomingInvoice = await this.billingService.getUpcomingInvoice(attributionId); + const currentInvoiceCredits = upcomingInvoice.credits | 0; + if (currentInvoiceCredits >= (costCenter.spendingLimit || 0)) { log.info({ userId: user.id }, "Usage limit reached", { attributionId, currentInvoiceCredits, @@ -72,9 +73,4 @@ export class BillingService { attributionId, }; } - - async getUpcomingInvoice(attributionId: AttributionId): Promise { - const response = await this.billingServiceClientProvider.getDefault().getUpcomingInvoice(attributionId); - return response; - } } diff --git a/components/server/ee/src/workspace/gitpod-server-impl.ts b/components/server/ee/src/workspace/gitpod-server-impl.ts index 578a49a365b793..57899f72e83dfb 100644 --- a/components/server/ee/src/workspace/gitpod-server-impl.ts +++ b/components/server/ee/src/workspace/gitpod-server-impl.ts @@ -72,7 +72,12 @@ import { EligibilityService } from "../user/eligibility-service"; import { AccountStatementProvider } from "../user/account-statement-provider"; import { GithubUpgradeURL, PlanCoupon } from "@gitpod/gitpod-protocol/lib/payment-protocol"; import { ListUsageRequest, ListUsageResponse } from "@gitpod/gitpod-protocol/lib/usage"; -import * as usage_grpc from "@gitpod/usage-api/lib/usage/v1/usage_pb"; +import { + CostCenter_BillingStrategy, + ListUsageRequest_Ordering, + UsageServiceClient, + Usage_Kind, +} from "@gitpod/usage-api/lib/usage/v1/usage.pb"; import { AssigneeIdentityIdentifier, TeamSubscription, @@ -107,14 +112,13 @@ import { BitbucketAppSupport } from "../bitbucket/bitbucket-app-support"; import { URL } from "url"; import { UserCounter } from "../user/user-counter"; import { AttributionId } from "@gitpod/gitpod-protocol/lib/attribution"; -import { CachingUsageServiceClientProvider } from "@gitpod/usage-api/lib/usage/v1/sugar"; -import { Timestamp } from "google-protobuf/google/protobuf/timestamp_pb"; import { EntitlementService, MayStartWorkspaceResult } from "../../../src/billing/entitlement-service"; import { BillingMode } from "@gitpod/gitpod-protocol/lib/billing-mode"; import { BillingModes } from "../billing/billing-mode"; import { getExperimentsClientForBackend } from "@gitpod/gitpod-protocol/lib/experiments/configcat-server"; import { BillingService } from "../billing/billing-service"; import Stripe from "stripe"; +import { UsageServiceDefinition } from "@gitpod/usage-api/lib/usage/v1/usage.pb"; @injectable() export class GitpodServerEEImpl extends GitpodServerImpl { @@ -154,8 +158,8 @@ export class GitpodServerEEImpl extends GitpodServerImpl { @inject(UserService) protected readonly userService: UserService; - @inject(CachingUsageServiceClientProvider) - protected readonly usageServiceClientProvider: CachingUsageServiceClientProvider; + @inject(UsageServiceDefinition.name) + protected readonly usageService: UsageServiceClient; @inject(EntitlementService) protected readonly entitlementService: EntitlementService; @@ -2149,10 +2153,14 @@ export class GitpodServerEEImpl extends GitpodServerImpl { await this.stripeService.setDefaultPaymentMethodForCustomer(customer, setupIntentId); await this.stripeService.createSubscriptionForCustomer(customer); - await this.usageServiceClientProvider.getDefault().setCostCenter({ - id: attrId, - spendingLimit: this.defaultSpendingLimit, - billingStrategy: "stripe", + + // Creating a cost center for this team + await this.usageService.setCostCenter({ + costCenter: { + attributionId: attributionId, + spendingLimit: this.defaultSpendingLimit, + billingStrategy: CostCenter_BillingStrategy.BILLING_STRATEGY_STRIPE, + }, }); } catch (error) { log.error(`Failed to subscribe '${attributionId}' to Stripe`, error); @@ -2218,9 +2226,11 @@ export class GitpodServerEEImpl extends GitpodServerImpl { const attributionId: AttributionId = { kind: "team", teamId }; await this.guardCostCenterAccess(ctx, user.id, attributionId, "get"); - const costCenter = await this.usageServiceClientProvider.getDefault().getCostCenter(attributionId); - if (costCenter) { - return costCenter.spendingLimit; + const costCenter = await this.usageService.getCostCenter({ + attributionId: AttributionId.render(attributionId), + }); + if (costCenter?.costCenter) { + return costCenter.costCenter.spendingLimit; } return undefined; } @@ -2232,14 +2242,17 @@ export class GitpodServerEEImpl extends GitpodServerImpl { if (typeof usageLimit !== "number" || usageLimit < 0) { throw new ResponseError(ErrorCodes.BAD_REQUEST, "Unexpected `usageLimit` value."); } - const attributionId: AttributionId = { kind: "team", teamId }; - await this.guardCostCenterAccess(ctx, user.id, attributionId, "update"); - - const costCenter = await this.usageServiceClientProvider.getDefault().getCostCenter(attributionId); - await this.usageServiceClientProvider.getDefault().setCostCenter({ - id: attributionId, - spendingLimit: usageLimit, - billingStrategy: costCenter?.billingStrategy || "other", + const attrId: AttributionId = { kind: "team", teamId }; + await this.guardCostCenterAccess(ctx, user.id, attrId, "update"); + const attributionId = AttributionId.render(attrId); + const costCenter = await this.usageService.getCostCenter({ attributionId }); + await this.usageService.setCostCenter({ + costCenter: { + attributionId, + spendingLimit: usageLimit, + billingStrategy: + costCenter?.costCenter?.billingStrategy || CostCenter_BillingStrategy.BILLING_STRATEGY_OTHER, + }, }); } @@ -2271,50 +2284,40 @@ export class GitpodServerEEImpl extends GitpodServerImpl { const user = this.checkAndBlockUser("listUsage"); await this.guardCostCenterAccess(ctx, user.id, attributionId, "get"); - const timestampFrom = from ? Timestamp.fromDate(new Date(from)) : undefined; - const timestampTo = to ? Timestamp.fromDate(new Date(to)) : undefined; - - const usageClient = this.usageServiceClientProvider.getDefault(); - const request = new usage_grpc.ListUsageRequest(); - request.setAttributionId(AttributionId.render(attributionId)); - request.setFrom(timestampFrom); - if (to) { - request.setTo(timestampTo); - } - request.setOrder(req.order); - if (req.pagination) { - const paginatedRequest = new usage_grpc.PaginatedRequest(); - paginatedRequest.setPage(req.pagination.page); - paginatedRequest.setPerPage(req.pagination.perPage); - request.setPagination(paginatedRequest); - } - const response = await usageClient.listUsage(ctx, request); - const pagination = response.getPagination(); + const response = await this.usageService.listUsage({ + attributionId: AttributionId.render(attributionId), + from: from ? new Date(from) : undefined, + to: to ? new Date(to) : undefined, + order: ListUsageRequest_Ordering.ORDERING_DESCENDING, + pagination: { + page: req.pagination?.page, + perPage: req.pagination?.perPage, + }, + }); return { - usageEntriesList: response.getUsageEntriesList().map((u) => { + usageEntriesList: response.usageEntries.map((u) => { return { - id: u.getId(), - attributionId: u.getAttributionId(), - effectiveTime: u.getEffectiveTime()!.toDate().getTime(), - credits: u.getCredits(), - description: u.getDescription(), - draft: u.getDraft(), - workspaceInstanceId: u.getWorkspaceInstanceId(), - kind: - u.getKind() === usage_grpc.Usage.Kind.KIND_WORKSPACE_INSTANCE ? "workspaceinstance" : "invoice", - metadata: JSON.parse(u.getMetadata()), + id: u.id, + attributionId: u.attributionId, + effectiveTime: u.effectiveTime && u.effectiveTime.getTime(), + credits: u.credits, + description: u.description, + draft: u.draft, + workspaceInstanceId: u.workspaceInstanceId, + kind: u.kind === Usage_Kind.KIND_WORKSPACE_INSTANCE ? "workspaceinstance" : "invoice", + metadata: JSON.parse(u.metadata), }; }), - pagination: pagination + pagination: response.pagination ? { - page: pagination.getPage(), - perPage: pagination.getPerPage(), - total: pagination.getTotal(), - totalPages: pagination.getTotalPages(), + page: response.pagination.page, + perPage: response.pagination.perPage, + total: response.pagination.total, + totalPages: response.pagination.totalPages, } : undefined, - creditBalanceAtEnd: response.getCreditBalanceAtEnd(), - creditBalanceAtStart: response.getCreditBalanceAtStart(), + creditBalanceAtEnd: response.creditBalanceAtEnd, + creditBalanceAtStart: response.creditBalanceAtStart, }; } diff --git a/components/server/src/container-module.ts b/components/server/src/container-module.ts index adb9260e1798e8..581a527b9b97cf 100644 --- a/components/server/src/container-module.ts +++ b/components/server/src/container-module.ts @@ -100,15 +100,9 @@ import { InstallationAdminTelemetryDataProvider } from "./installation-admin/tel import { IDEService } from "./ide-service"; import { LicenseEvaluator } from "@gitpod/licensor/lib"; import { WorkspaceClusterImagebuilderClientProvider } from "./workspace/workspace-cluster-imagebuilder-client-provider"; -import { - CachingUsageServiceClientProvider, - CachingBillingServiceClientProvider, - UsageServiceClientCallMetrics, - UsageServiceClientConfig, - UsageServiceClientProvider, - BillingServiceClientCallMetrics, - BillingServiceClientConfig, -} from "@gitpod/usage-api/lib/usage/v1/sugar"; +import { UsageServiceClient, UsageServiceDefinition } from "@gitpod/usage-api/lib/usage/v1/usage.pb"; +import { BillingServiceClient, BillingServiceDefinition } from "@gitpod/usage-api/lib/usage/v1/billing.pb"; +import { createChannel, createClient } from "nice-grpc"; import { CommunityEntitlementService, EntitlementService } from "./billing/entitlement-service"; import { ConfigCatClientFactory, @@ -264,19 +258,14 @@ export const productionContainerModule = new ContainerModule((bind, unbind, isBo bind(NewsletterSubscriptionController).toSelf().inSingletonScope(); - bind(UsageServiceClientConfig).toDynamicValue((ctx) => { + bind(UsageServiceDefinition.name).toDynamicValue((ctx) => { const config = ctx.container.get(Config); - return { address: config.usageServiceAddr }; + return createClient(UsageServiceDefinition, createChannel(config.usageServiceAddr)); }); - bind(CachingUsageServiceClientProvider).toSelf().inSingletonScope(); - bind(UsageServiceClientProvider).toService(CachingImageBuilderClientProvider); - bind(UsageServiceClientCallMetrics).toService(IClientCallMetrics); - bind(CachingBillingServiceClientProvider).toSelf().inSingletonScope(); - bind(BillingServiceClientCallMetrics).toService(IClientCallMetrics); - bind(BillingServiceClientConfig).toDynamicValue((ctx) => { + bind(BillingServiceDefinition.name).toDynamicValue((ctx) => { const config = ctx.container.get(Config); - return { address: config.usageServiceAddr }; + return createClient(BillingServiceDefinition, createChannel(config.usageServiceAddr)); }); bind(EntitlementService).to(CommunityEntitlementService).inSingletonScope(); diff --git a/components/server/src/workspace/workspace-starter.ts b/components/server/src/workspace/workspace-starter.ts index b4716842a93f10..817dd08e405909 100644 --- a/components/server/src/workspace/workspace-starter.ts +++ b/components/server/src/workspace/workspace-starter.ts @@ -125,10 +125,8 @@ import { WorkspaceClasses, WorkspaceClassesConfig } from "./workspace-classes"; import { EntitlementService } from "../billing/entitlement-service"; import { BillingModes } from "../../ee/src/billing/billing-mode"; import { AttributionId } from "@gitpod/gitpod-protocol/lib/attribution"; -import { CachingBillingServiceClientProvider } from "@gitpod/usage-api/lib/usage/v1/sugar"; -import { Timestamp } from "google-protobuf/google/protobuf/timestamp_pb"; +import { BillingServiceClient, BillingServiceDefinition, System } from "@gitpod/usage-api/lib/usage/v1/billing.pb"; import { BillingMode } from "@gitpod/gitpod-protocol/lib/billing-mode"; -import { System } from "@gitpod/usage-api/lib/usage/v1/billing_pb"; import { LogContext } from "@gitpod/gitpod-protocol/lib/util/logging"; export interface StartWorkspaceOptions { @@ -283,8 +281,8 @@ export class WorkspaceStarter { @inject(TeamDB) protected readonly teamDB: TeamDB; @inject(EntitlementService) protected readonly entitlementService: EntitlementService; @inject(BillingModes) protected readonly billingModes: BillingModes; - @inject(CachingBillingServiceClientProvider) - protected readonly billingServiceClientProvider: CachingBillingServiceClientProvider; + @inject(BillingServiceDefinition.name) + protected readonly billingService: BillingServiceClient; public async startWorkspace( ctx: TraceContext, @@ -554,13 +552,15 @@ export class WorkspaceStarter { if (instance.usageAttributionId) { const creationTime = new Date(instance.creationTime); - const timestamped = Timestamp.fromDate(creationTime); const parsedAttributionId = AttributionId.parse(instance.usageAttributionId); if (parsedAttributionId) { const billingMode = await this.billingModes.getBillingMode(parsedAttributionId, creationTime); if (billingMode && billingMode.mode === "chargebee") { - const billingClient = this.billingServiceClientProvider.getDefault(); - await billingClient.setBilledSession(instance.id, timestamped, System.SYSTEM_CHARGEBEE); + await this.billingService.setBilledSession({ + instanceId: instance.id, + from: creationTime, + system: System.SYSTEM_CHARGEBEE, + }); } } } diff --git a/components/usage-api/generate.sh b/components/usage-api/generate.sh index 0450d52d604990..2b86555b34facd 100755 --- a/components/usage-api/generate.sh +++ b/components/usage-api/generate.sh @@ -22,6 +22,6 @@ go_protoc "$COMPONENTS_DIR" "usage/v1" mkdir -p go/v1 mv go/usage/v1/*.pb.go go/v1 rm -rf go/usage -typescript_protoc "$COMPONENTS_DIR" "usage/v1" +typescript_ts_protoc "$COMPONENTS_DIR" "usage/v1" update_license diff --git a/components/usage-api/typescript/package.json b/components/usage-api/typescript/package.json index 3bc640036b0789..e2cd4adfbdf23c 100644 --- a/components/usage-api/typescript/package.json +++ b/components/usage-api/typescript/package.json @@ -6,24 +6,19 @@ "lib" ], "scripts": { - "build": "mkdir -p lib; tsc && cp -fR src/* lib", - "watch": "leeway exec --package .:lib --transitive-dependencies --filter-type yarn --components --parallel -- tsc -w --preserveWatchOutput", - "test": "mocha --opts mocha.opts './**/*.spec.ts' --exclude './node_modules/**'", - "test:brk": "yarn test --inspect-brk" + "build": "mkdir -p lib; tsc", + "watch": "leeway exec --package .:lib --transitive-dependencies --filter-type yarn --components --parallel -- tsc -w --preserveWatchOutput" + }, + "overrides": { + "long": "4.0.0" }, "dependencies": { - "@gitpod/gitpod-protocol": "0.1.5", - "@grpc/grpc-js": "^1.3.7", - "google-protobuf": "^3.19.1", - "opentracing": "^0.14.4" + "long": "4.0.0", + "nice-grpc": "^2.0.0", + "ts-proto": "^1.125.0" }, "devDependencies": { - "@testdeck/mocha": "0.1.2", - "@types/chai": "^4.1.2", - "@types/google-protobuf": "^3.15.5", - "@types/node": "^16.11.0", "grpc-tools": "^1.11.2", - "grpc_tools_node_protoc_ts": "^5.3.2", "typescript": "~4.4.2", "typescript-formatter": "^7.2.2" } diff --git a/components/usage-api/typescript/src/google/protobuf/timestamp.pb.ts b/components/usage-api/typescript/src/google/protobuf/timestamp.pb.ts new file mode 100644 index 00000000000000..f21fdebdfa772e --- /dev/null +++ b/components/usage-api/typescript/src/google/protobuf/timestamp.pb.ts @@ -0,0 +1,229 @@ +/** + * Copyright (c) 2022 Gitpod GmbH. All rights reserved. + * Licensed under the GNU Affero General Public License (AGPL). + * See License-AGPL.txt in the project root for license information. + */ + +/* eslint-disable */ +import * as Long from "long"; +import * as _m0 from "protobufjs/minimal"; + +export const protobufPackage = "google.protobuf"; + +/** + * A Timestamp represents a point in time independent of any time zone or local + * calendar, encoded as a count of seconds and fractions of seconds at + * nanosecond resolution. The count is relative to an epoch at UTC midnight on + * January 1, 1970, in the proleptic Gregorian calendar which extends the + * Gregorian calendar backwards to year one. + * + * All minutes are 60 seconds long. Leap seconds are "smeared" so that no leap + * second table is needed for interpretation, using a [24-hour linear + * smear](https://developers.google.com/time/smear). + * + * The range is from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59.999999999Z. By + * restricting to that range, we ensure that we can convert to and from [RFC + * 3339](https://www.ietf.org/rfc/rfc3339.txt) date strings. + * + * # Examples + * + * Example 1: Compute Timestamp from POSIX `time()`. + * + * Timestamp timestamp; + * timestamp.set_seconds(time(NULL)); + * timestamp.set_nanos(0); + * + * Example 2: Compute Timestamp from POSIX `gettimeofday()`. + * + * struct timeval tv; + * gettimeofday(&tv, NULL); + * + * Timestamp timestamp; + * timestamp.set_seconds(tv.tv_sec); + * timestamp.set_nanos(tv.tv_usec * 1000); + * + * Example 3: Compute Timestamp from Win32 `GetSystemTimeAsFileTime()`. + * + * FILETIME ft; + * GetSystemTimeAsFileTime(&ft); + * UINT64 ticks = (((UINT64)ft.dwHighDateTime) << 32) | ft.dwLowDateTime; + * + * // A Windows tick is 100 nanoseconds. Windows epoch 1601-01-01T00:00:00Z + * // is 11644473600 seconds before Unix epoch 1970-01-01T00:00:00Z. + * Timestamp timestamp; + * timestamp.set_seconds((INT64) ((ticks / 10000000) - 11644473600LL)); + * timestamp.set_nanos((INT32) ((ticks % 10000000) * 100)); + * + * Example 4: Compute Timestamp from Java `System.currentTimeMillis()`. + * + * long millis = System.currentTimeMillis(); + * + * Timestamp timestamp = Timestamp.newBuilder().setSeconds(millis / 1000) + * .setNanos((int) ((millis % 1000) * 1000000)).build(); + * + * Example 5: Compute Timestamp from Java `Instant.now()`. + * + * Instant now = Instant.now(); + * + * Timestamp timestamp = + * Timestamp.newBuilder().setSeconds(now.getEpochSecond()) + * .setNanos(now.getNano()).build(); + * + * Example 6: Compute Timestamp from current time in Python. + * + * timestamp = Timestamp() + * timestamp.GetCurrentTime() + * + * # JSON Mapping + * + * In JSON format, the Timestamp type is encoded as a string in the + * [RFC 3339](https://www.ietf.org/rfc/rfc3339.txt) format. That is, the + * format is "{year}-{month}-{day}T{hour}:{min}:{sec}[.{frac_sec}]Z" + * where {year} is always expressed using four digits while {month}, {day}, + * {hour}, {min}, and {sec} are zero-padded to two digits each. The fractional + * seconds, which can go up to 9 digits (i.e. up to 1 nanosecond resolution), + * are optional. The "Z" suffix indicates the timezone ("UTC"); the timezone + * is required. A proto3 JSON serializer should always use UTC (as indicated by + * "Z") when printing the Timestamp type and a proto3 JSON parser should be + * able to accept both UTC and other timezones (as indicated by an offset). + * + * For example, "2017-01-15T01:30:15.01Z" encodes 15.01 seconds past + * 01:30 UTC on January 15, 2017. + * + * In JavaScript, one can convert a Date object to this format using the + * standard + * [toISOString()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString) + * method. In Python, a standard `datetime.datetime` object can be converted + * to this format using + * [`strftime`](https://docs.python.org/2/library/time.html#time.strftime) with + * the time format spec '%Y-%m-%dT%H:%M:%S.%fZ'. Likewise, in Java, one can use + * the Joda Time's [`ISODateTimeFormat.dateTime()`]( + * http://www.joda.org/joda-time/apidocs/org/joda/time/format/ISODateTimeFormat.html#dateTime%2D%2D + * ) to obtain a formatter capable of generating timestamps in this format. + */ +export interface Timestamp { + /** + * Represents seconds of UTC time since Unix epoch + * 1970-01-01T00:00:00Z. Must be from 0001-01-01T00:00:00Z to + * 9999-12-31T23:59:59Z inclusive. + */ + seconds: number; + /** + * Non-negative fractions of a second at nanosecond resolution. Negative + * second values with fractions must still have non-negative nanos values + * that count forward in time. Must be from 0 to 999,999,999 + * inclusive. + */ + nanos: number; +} + +function createBaseTimestamp(): Timestamp { + return { seconds: 0, nanos: 0 }; +} + +export const Timestamp = { + encode(message: Timestamp, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.seconds !== 0) { + writer.uint32(8).int64(message.seconds); + } + if (message.nanos !== 0) { + writer.uint32(16).int32(message.nanos); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): Timestamp { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseTimestamp(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.seconds = longToNumber(reader.int64() as Long); + break; + case 2: + message.nanos = reader.int32(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): Timestamp { + return { + seconds: isSet(object.seconds) ? Number(object.seconds) : 0, + nanos: isSet(object.nanos) ? Number(object.nanos) : 0, + }; + }, + + toJSON(message: Timestamp): unknown { + const obj: any = {}; + message.seconds !== undefined && (obj.seconds = Math.round(message.seconds)); + message.nanos !== undefined && (obj.nanos = Math.round(message.nanos)); + return obj; + }, + + fromPartial(object: DeepPartial): Timestamp { + const message = createBaseTimestamp(); + message.seconds = object.seconds ?? 0; + message.nanos = object.nanos ?? 0; + return message; + }, +}; + +export interface DataLoaderOptions { + cache?: boolean; +} + +export interface DataLoaders { + rpcDataLoaderOptions?: DataLoaderOptions; + getDataLoader(identifier: string, constructorFn: () => T): T; +} + +declare var self: any | undefined; +declare var window: any | undefined; +declare var global: any | undefined; +var globalThis: any = (() => { + if (typeof globalThis !== "undefined") { + return globalThis; + } + if (typeof self !== "undefined") { + return self; + } + if (typeof window !== "undefined") { + return window; + } + if (typeof global !== "undefined") { + return global; + } + throw "Unable to locate global object"; +})(); + +type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; + +export type DeepPartial = T extends Builtin ? T + : T extends Array ? Array> : T extends ReadonlyArray ? ReadonlyArray> + : T extends {} ? { [K in keyof T]?: DeepPartial } + : Partial; + +function longToNumber(long: Long): number { + if (long.gt(Number.MAX_SAFE_INTEGER)) { + throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); + } + return long.toNumber(); +} + +// If you get a compile-error about 'Constructor and ... have no overlap', +// add '--ts_proto_opt=esModuleInterop=true' as a flag when calling 'protoc'. +if (_m0.util.Long !== Long) { + _m0.util.Long = Long as any; + _m0.configure(); +} + +function isSet(value: any): boolean { + return value !== null && value !== undefined; +} diff --git a/components/usage-api/typescript/src/usage/v1/billing.pb.ts b/components/usage-api/typescript/src/usage/v1/billing.pb.ts new file mode 100644 index 00000000000000..5cbcf640ee8da5 --- /dev/null +++ b/components/usage-api/typescript/src/usage/v1/billing.pb.ts @@ -0,0 +1,691 @@ +/** + * Copyright (c) 2022 Gitpod GmbH. All rights reserved. + * Licensed under the GNU Affero General Public License (AGPL). + * See License-AGPL.txt in the project root for license information. + */ + +/* eslint-disable */ +import * as Long from "long"; +import { CallContext, CallOptions } from "nice-grpc-common"; +import * as _m0 from "protobufjs/minimal"; +import { Timestamp } from "../../google/protobuf/timestamp.pb"; + +export const protobufPackage = "usage.v1"; + +export enum System { + SYSTEM_UNKNOWN = "SYSTEM_UNKNOWN", + SYSTEM_CHARGEBEE = "SYSTEM_CHARGEBEE", + SYSTEM_STRIPE = "SYSTEM_STRIPE", + UNRECOGNIZED = "UNRECOGNIZED", +} + +export function systemFromJSON(object: any): System { + switch (object) { + case 0: + case "SYSTEM_UNKNOWN": + return System.SYSTEM_UNKNOWN; + case 1: + case "SYSTEM_CHARGEBEE": + return System.SYSTEM_CHARGEBEE; + case 2: + case "SYSTEM_STRIPE": + return System.SYSTEM_STRIPE; + case -1: + case "UNRECOGNIZED": + default: + return System.UNRECOGNIZED; + } +} + +export function systemToJSON(object: System): string { + switch (object) { + case System.SYSTEM_UNKNOWN: + return "SYSTEM_UNKNOWN"; + case System.SYSTEM_CHARGEBEE: + return "SYSTEM_CHARGEBEE"; + case System.SYSTEM_STRIPE: + return "SYSTEM_STRIPE"; + case System.UNRECOGNIZED: + default: + return "UNRECOGNIZED"; + } +} + +export function systemToNumber(object: System): number { + switch (object) { + case System.SYSTEM_UNKNOWN: + return 0; + case System.SYSTEM_CHARGEBEE: + return 1; + case System.SYSTEM_STRIPE: + return 2; + case System.UNRECOGNIZED: + default: + return -1; + } +} + +export interface ReconcileInvoicesRequest { +} + +export interface ReconcileInvoicesResponse { +} + +export interface GetUpcomingInvoiceRequest { + teamId: string | undefined; + userId: string | undefined; +} + +export interface GetUpcomingInvoiceResponse { + invoiceId: string; + currency: string; + amount: number; + credits: number; +} + +export interface FinalizeInvoiceRequest { + invoiceId: string; +} + +export interface FinalizeInvoiceResponse { +} + +/** + * If there are two billable sessions for this instance ID, + * the second one's "from" will be the first one's "to" + */ +export interface SetBilledSessionRequest { + instanceId: string; + from: Date | undefined; + system: System; +} + +export interface SetBilledSessionResponse { +} + +function createBaseReconcileInvoicesRequest(): ReconcileInvoicesRequest { + return {}; +} + +export const ReconcileInvoicesRequest = { + encode(_: ReconcileInvoicesRequest, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): ReconcileInvoicesRequest { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseReconcileInvoicesRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(_: any): ReconcileInvoicesRequest { + return {}; + }, + + toJSON(_: ReconcileInvoicesRequest): unknown { + const obj: any = {}; + return obj; + }, + + fromPartial(_: DeepPartial): ReconcileInvoicesRequest { + const message = createBaseReconcileInvoicesRequest(); + return message; + }, +}; + +function createBaseReconcileInvoicesResponse(): ReconcileInvoicesResponse { + return {}; +} + +export const ReconcileInvoicesResponse = { + encode(_: ReconcileInvoicesResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): ReconcileInvoicesResponse { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseReconcileInvoicesResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(_: any): ReconcileInvoicesResponse { + return {}; + }, + + toJSON(_: ReconcileInvoicesResponse): unknown { + const obj: any = {}; + return obj; + }, + + fromPartial(_: DeepPartial): ReconcileInvoicesResponse { + const message = createBaseReconcileInvoicesResponse(); + return message; + }, +}; + +function createBaseGetUpcomingInvoiceRequest(): GetUpcomingInvoiceRequest { + return { teamId: undefined, userId: undefined }; +} + +export const GetUpcomingInvoiceRequest = { + encode(message: GetUpcomingInvoiceRequest, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.teamId !== undefined) { + writer.uint32(10).string(message.teamId); + } + if (message.userId !== undefined) { + writer.uint32(18).string(message.userId); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): GetUpcomingInvoiceRequest { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseGetUpcomingInvoiceRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.teamId = reader.string(); + break; + case 2: + message.userId = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): GetUpcomingInvoiceRequest { + return { + teamId: isSet(object.teamId) ? String(object.teamId) : undefined, + userId: isSet(object.userId) ? String(object.userId) : undefined, + }; + }, + + toJSON(message: GetUpcomingInvoiceRequest): unknown { + const obj: any = {}; + message.teamId !== undefined && (obj.teamId = message.teamId); + message.userId !== undefined && (obj.userId = message.userId); + return obj; + }, + + fromPartial(object: DeepPartial): GetUpcomingInvoiceRequest { + const message = createBaseGetUpcomingInvoiceRequest(); + message.teamId = object.teamId ?? undefined; + message.userId = object.userId ?? undefined; + return message; + }, +}; + +function createBaseGetUpcomingInvoiceResponse(): GetUpcomingInvoiceResponse { + return { invoiceId: "", currency: "", amount: 0, credits: 0 }; +} + +export const GetUpcomingInvoiceResponse = { + encode(message: GetUpcomingInvoiceResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.invoiceId !== "") { + writer.uint32(10).string(message.invoiceId); + } + if (message.currency !== "") { + writer.uint32(18).string(message.currency); + } + if (message.amount !== 0) { + writer.uint32(25).double(message.amount); + } + if (message.credits !== 0) { + writer.uint32(32).int64(message.credits); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): GetUpcomingInvoiceResponse { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseGetUpcomingInvoiceResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.invoiceId = reader.string(); + break; + case 2: + message.currency = reader.string(); + break; + case 3: + message.amount = reader.double(); + break; + case 4: + message.credits = longToNumber(reader.int64() as Long); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): GetUpcomingInvoiceResponse { + return { + invoiceId: isSet(object.invoiceId) ? String(object.invoiceId) : "", + currency: isSet(object.currency) ? String(object.currency) : "", + amount: isSet(object.amount) ? Number(object.amount) : 0, + credits: isSet(object.credits) ? Number(object.credits) : 0, + }; + }, + + toJSON(message: GetUpcomingInvoiceResponse): unknown { + const obj: any = {}; + message.invoiceId !== undefined && (obj.invoiceId = message.invoiceId); + message.currency !== undefined && (obj.currency = message.currency); + message.amount !== undefined && (obj.amount = message.amount); + message.credits !== undefined && (obj.credits = Math.round(message.credits)); + return obj; + }, + + fromPartial(object: DeepPartial): GetUpcomingInvoiceResponse { + const message = createBaseGetUpcomingInvoiceResponse(); + message.invoiceId = object.invoiceId ?? ""; + message.currency = object.currency ?? ""; + message.amount = object.amount ?? 0; + message.credits = object.credits ?? 0; + return message; + }, +}; + +function createBaseFinalizeInvoiceRequest(): FinalizeInvoiceRequest { + return { invoiceId: "" }; +} + +export const FinalizeInvoiceRequest = { + encode(message: FinalizeInvoiceRequest, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.invoiceId !== "") { + writer.uint32(10).string(message.invoiceId); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): FinalizeInvoiceRequest { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseFinalizeInvoiceRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.invoiceId = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): FinalizeInvoiceRequest { + return { invoiceId: isSet(object.invoiceId) ? String(object.invoiceId) : "" }; + }, + + toJSON(message: FinalizeInvoiceRequest): unknown { + const obj: any = {}; + message.invoiceId !== undefined && (obj.invoiceId = message.invoiceId); + return obj; + }, + + fromPartial(object: DeepPartial): FinalizeInvoiceRequest { + const message = createBaseFinalizeInvoiceRequest(); + message.invoiceId = object.invoiceId ?? ""; + return message; + }, +}; + +function createBaseFinalizeInvoiceResponse(): FinalizeInvoiceResponse { + return {}; +} + +export const FinalizeInvoiceResponse = { + encode(_: FinalizeInvoiceResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): FinalizeInvoiceResponse { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseFinalizeInvoiceResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(_: any): FinalizeInvoiceResponse { + return {}; + }, + + toJSON(_: FinalizeInvoiceResponse): unknown { + const obj: any = {}; + return obj; + }, + + fromPartial(_: DeepPartial): FinalizeInvoiceResponse { + const message = createBaseFinalizeInvoiceResponse(); + return message; + }, +}; + +function createBaseSetBilledSessionRequest(): SetBilledSessionRequest { + return { instanceId: "", from: undefined, system: System.SYSTEM_UNKNOWN }; +} + +export const SetBilledSessionRequest = { + encode(message: SetBilledSessionRequest, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.instanceId !== "") { + writer.uint32(10).string(message.instanceId); + } + if (message.from !== undefined) { + Timestamp.encode(toTimestamp(message.from), writer.uint32(18).fork()).ldelim(); + } + if (message.system !== System.SYSTEM_UNKNOWN) { + writer.uint32(24).int32(systemToNumber(message.system)); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): SetBilledSessionRequest { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseSetBilledSessionRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.instanceId = reader.string(); + break; + case 2: + message.from = fromTimestamp(Timestamp.decode(reader, reader.uint32())); + break; + case 3: + message.system = systemFromJSON(reader.int32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): SetBilledSessionRequest { + return { + instanceId: isSet(object.instanceId) ? String(object.instanceId) : "", + from: isSet(object.from) ? fromJsonTimestamp(object.from) : undefined, + system: isSet(object.system) ? systemFromJSON(object.system) : System.SYSTEM_UNKNOWN, + }; + }, + + toJSON(message: SetBilledSessionRequest): unknown { + const obj: any = {}; + message.instanceId !== undefined && (obj.instanceId = message.instanceId); + message.from !== undefined && (obj.from = message.from.toISOString()); + message.system !== undefined && (obj.system = systemToJSON(message.system)); + return obj; + }, + + fromPartial(object: DeepPartial): SetBilledSessionRequest { + const message = createBaseSetBilledSessionRequest(); + message.instanceId = object.instanceId ?? ""; + message.from = object.from ?? undefined; + message.system = object.system ?? System.SYSTEM_UNKNOWN; + return message; + }, +}; + +function createBaseSetBilledSessionResponse(): SetBilledSessionResponse { + return {}; +} + +export const SetBilledSessionResponse = { + encode(_: SetBilledSessionResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): SetBilledSessionResponse { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseSetBilledSessionResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(_: any): SetBilledSessionResponse { + return {}; + }, + + toJSON(_: SetBilledSessionResponse): unknown { + const obj: any = {}; + return obj; + }, + + fromPartial(_: DeepPartial): SetBilledSessionResponse { + const message = createBaseSetBilledSessionResponse(); + return message; + }, +}; + +export type BillingServiceDefinition = typeof BillingServiceDefinition; +export const BillingServiceDefinition = { + name: "BillingService", + fullName: "usage.v1.BillingService", + methods: { + /** + * ReconcileInvoices retrieves current credit balance and reflects it in billing system. + * Internal RPC, not intended for general consumption. + */ + reconcileInvoices: { + name: "ReconcileInvoices", + requestType: ReconcileInvoicesRequest, + requestStream: false, + responseType: ReconcileInvoicesResponse, + responseStream: false, + options: {}, + }, + /** GetUpcomingInvoice retrieves the latest invoice for a given query. */ + getUpcomingInvoice: { + name: "GetUpcomingInvoice", + requestType: GetUpcomingInvoiceRequest, + requestStream: false, + responseType: GetUpcomingInvoiceResponse, + responseStream: false, + options: {}, + }, + /** + * FinalizeInvoice marks all sessions occurring in the given Stripe invoice as + * having been invoiced. + */ + finalizeInvoice: { + name: "FinalizeInvoice", + requestType: FinalizeInvoiceRequest, + requestStream: false, + responseType: FinalizeInvoiceResponse, + responseStream: false, + options: {}, + }, + /** SetBilledSession marks an instance as billed with a billing system */ + setBilledSession: { + name: "SetBilledSession", + requestType: SetBilledSessionRequest, + requestStream: false, + responseType: SetBilledSessionResponse, + responseStream: false, + options: {}, + }, + }, +} as const; + +export interface BillingServiceServiceImplementation { + /** + * ReconcileInvoices retrieves current credit balance and reflects it in billing system. + * Internal RPC, not intended for general consumption. + */ + reconcileInvoices( + request: ReconcileInvoicesRequest, + context: CallContext & CallContextExt, + ): Promise>; + /** GetUpcomingInvoice retrieves the latest invoice for a given query. */ + getUpcomingInvoice( + request: GetUpcomingInvoiceRequest, + context: CallContext & CallContextExt, + ): Promise>; + /** + * FinalizeInvoice marks all sessions occurring in the given Stripe invoice as + * having been invoiced. + */ + finalizeInvoice( + request: FinalizeInvoiceRequest, + context: CallContext & CallContextExt, + ): Promise>; + /** SetBilledSession marks an instance as billed with a billing system */ + setBilledSession( + request: SetBilledSessionRequest, + context: CallContext & CallContextExt, + ): Promise>; +} + +export interface BillingServiceClient { + /** + * ReconcileInvoices retrieves current credit balance and reflects it in billing system. + * Internal RPC, not intended for general consumption. + */ + reconcileInvoices( + request: DeepPartial, + options?: CallOptions & CallOptionsExt, + ): Promise; + /** GetUpcomingInvoice retrieves the latest invoice for a given query. */ + getUpcomingInvoice( + request: DeepPartial, + options?: CallOptions & CallOptionsExt, + ): Promise; + /** + * FinalizeInvoice marks all sessions occurring in the given Stripe invoice as + * having been invoiced. + */ + finalizeInvoice( + request: DeepPartial, + options?: CallOptions & CallOptionsExt, + ): Promise; + /** SetBilledSession marks an instance as billed with a billing system */ + setBilledSession( + request: DeepPartial, + options?: CallOptions & CallOptionsExt, + ): Promise; +} + +export interface DataLoaderOptions { + cache?: boolean; +} + +export interface DataLoaders { + rpcDataLoaderOptions?: DataLoaderOptions; + getDataLoader(identifier: string, constructorFn: () => T): T; +} + +declare var self: any | undefined; +declare var window: any | undefined; +declare var global: any | undefined; +var globalThis: any = (() => { + if (typeof globalThis !== "undefined") { + return globalThis; + } + if (typeof self !== "undefined") { + return self; + } + if (typeof window !== "undefined") { + return window; + } + if (typeof global !== "undefined") { + return global; + } + throw "Unable to locate global object"; +})(); + +type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; + +export type DeepPartial = T extends Builtin ? T + : T extends Array ? Array> : T extends ReadonlyArray ? ReadonlyArray> + : T extends {} ? { [K in keyof T]?: DeepPartial } + : Partial; + +function toTimestamp(date: Date): Timestamp { + const seconds = date.getTime() / 1_000; + const nanos = (date.getTime() % 1_000) * 1_000_000; + return { seconds, nanos }; +} + +function fromTimestamp(t: Timestamp): Date { + let millis = t.seconds * 1_000; + millis += t.nanos / 1_000_000; + return new Date(millis); +} + +function fromJsonTimestamp(o: any): Date { + if (o instanceof Date) { + return o; + } else if (typeof o === "string") { + return new Date(o); + } else { + return fromTimestamp(Timestamp.fromJSON(o)); + } +} + +function longToNumber(long: Long): number { + if (long.gt(Number.MAX_SAFE_INTEGER)) { + throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); + } + return long.toNumber(); +} + +// If you get a compile-error about 'Constructor and ... have no overlap', +// add '--ts_proto_opt=esModuleInterop=true' as a flag when calling 'protoc'. +if (_m0.util.Long !== Long) { + _m0.util.Long = Long as any; + _m0.configure(); +} + +function isSet(value: any): boolean { + return value !== null && value !== undefined; +} diff --git a/components/usage-api/typescript/src/usage/v1/billing_grpc_pb.d.ts b/components/usage-api/typescript/src/usage/v1/billing_grpc_pb.d.ts deleted file mode 100644 index 5085583c73120c..00000000000000 --- a/components/usage-api/typescript/src/usage/v1/billing_grpc_pb.d.ts +++ /dev/null @@ -1,99 +0,0 @@ -/** - * Copyright (c) 2022 Gitpod GmbH. All rights reserved. - * Licensed under the GNU Affero General Public License (AGPL). - * See License-AGPL.txt in the project root for license information. - */ - -// package: usage.v1 -// file: usage/v1/billing.proto - -/* tslint:disable */ -/* eslint-disable */ - -import * as grpc from "@grpc/grpc-js"; -import * as usage_v1_billing_pb from "../../usage/v1/billing_pb"; -import * as google_protobuf_timestamp_pb from "google-protobuf/google/protobuf/timestamp_pb"; - -interface IBillingServiceService extends grpc.ServiceDefinition { - reconcileInvoices: IBillingServiceService_IReconcileInvoices; - getUpcomingInvoice: IBillingServiceService_IGetUpcomingInvoice; - finalizeInvoice: IBillingServiceService_IFinalizeInvoice; - setBilledSession: IBillingServiceService_ISetBilledSession; -} - -interface IBillingServiceService_IReconcileInvoices extends grpc.MethodDefinition { - path: "/usage.v1.BillingService/ReconcileInvoices"; - requestStream: false; - responseStream: false; - requestSerialize: grpc.serialize; - requestDeserialize: grpc.deserialize; - responseSerialize: grpc.serialize; - responseDeserialize: grpc.deserialize; -} -interface IBillingServiceService_IGetUpcomingInvoice extends grpc.MethodDefinition { - path: "/usage.v1.BillingService/GetUpcomingInvoice"; - requestStream: false; - responseStream: false; - requestSerialize: grpc.serialize; - requestDeserialize: grpc.deserialize; - responseSerialize: grpc.serialize; - responseDeserialize: grpc.deserialize; -} -interface IBillingServiceService_IFinalizeInvoice extends grpc.MethodDefinition { - path: "/usage.v1.BillingService/FinalizeInvoice"; - requestStream: false; - responseStream: false; - requestSerialize: grpc.serialize; - requestDeserialize: grpc.deserialize; - responseSerialize: grpc.serialize; - responseDeserialize: grpc.deserialize; -} -interface IBillingServiceService_ISetBilledSession extends grpc.MethodDefinition { - path: "/usage.v1.BillingService/SetBilledSession"; - requestStream: false; - responseStream: false; - requestSerialize: grpc.serialize; - requestDeserialize: grpc.deserialize; - responseSerialize: grpc.serialize; - responseDeserialize: grpc.deserialize; -} - -export const BillingServiceService: IBillingServiceService; - -export interface IBillingServiceServer extends grpc.UntypedServiceImplementation { - reconcileInvoices: grpc.handleUnaryCall; - getUpcomingInvoice: grpc.handleUnaryCall; - finalizeInvoice: grpc.handleUnaryCall; - setBilledSession: grpc.handleUnaryCall; -} - -export interface IBillingServiceClient { - reconcileInvoices(request: usage_v1_billing_pb.ReconcileInvoicesRequest, callback: (error: grpc.ServiceError | null, response: usage_v1_billing_pb.ReconcileInvoicesResponse) => void): grpc.ClientUnaryCall; - reconcileInvoices(request: usage_v1_billing_pb.ReconcileInvoicesRequest, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: usage_v1_billing_pb.ReconcileInvoicesResponse) => void): grpc.ClientUnaryCall; - reconcileInvoices(request: usage_v1_billing_pb.ReconcileInvoicesRequest, metadata: grpc.Metadata, options: Partial, callback: (error: grpc.ServiceError | null, response: usage_v1_billing_pb.ReconcileInvoicesResponse) => void): grpc.ClientUnaryCall; - getUpcomingInvoice(request: usage_v1_billing_pb.GetUpcomingInvoiceRequest, callback: (error: grpc.ServiceError | null, response: usage_v1_billing_pb.GetUpcomingInvoiceResponse) => void): grpc.ClientUnaryCall; - getUpcomingInvoice(request: usage_v1_billing_pb.GetUpcomingInvoiceRequest, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: usage_v1_billing_pb.GetUpcomingInvoiceResponse) => void): grpc.ClientUnaryCall; - getUpcomingInvoice(request: usage_v1_billing_pb.GetUpcomingInvoiceRequest, metadata: grpc.Metadata, options: Partial, callback: (error: grpc.ServiceError | null, response: usage_v1_billing_pb.GetUpcomingInvoiceResponse) => void): grpc.ClientUnaryCall; - finalizeInvoice(request: usage_v1_billing_pb.FinalizeInvoiceRequest, callback: (error: grpc.ServiceError | null, response: usage_v1_billing_pb.FinalizeInvoiceResponse) => void): grpc.ClientUnaryCall; - finalizeInvoice(request: usage_v1_billing_pb.FinalizeInvoiceRequest, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: usage_v1_billing_pb.FinalizeInvoiceResponse) => void): grpc.ClientUnaryCall; - finalizeInvoice(request: usage_v1_billing_pb.FinalizeInvoiceRequest, metadata: grpc.Metadata, options: Partial, callback: (error: grpc.ServiceError | null, response: usage_v1_billing_pb.FinalizeInvoiceResponse) => void): grpc.ClientUnaryCall; - setBilledSession(request: usage_v1_billing_pb.SetBilledSessionRequest, callback: (error: grpc.ServiceError | null, response: usage_v1_billing_pb.SetBilledSessionResponse) => void): grpc.ClientUnaryCall; - setBilledSession(request: usage_v1_billing_pb.SetBilledSessionRequest, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: usage_v1_billing_pb.SetBilledSessionResponse) => void): grpc.ClientUnaryCall; - setBilledSession(request: usage_v1_billing_pb.SetBilledSessionRequest, metadata: grpc.Metadata, options: Partial, callback: (error: grpc.ServiceError | null, response: usage_v1_billing_pb.SetBilledSessionResponse) => void): grpc.ClientUnaryCall; -} - -export class BillingServiceClient extends grpc.Client implements IBillingServiceClient { - constructor(address: string, credentials: grpc.ChannelCredentials, options?: Partial); - public reconcileInvoices(request: usage_v1_billing_pb.ReconcileInvoicesRequest, callback: (error: grpc.ServiceError | null, response: usage_v1_billing_pb.ReconcileInvoicesResponse) => void): grpc.ClientUnaryCall; - public reconcileInvoices(request: usage_v1_billing_pb.ReconcileInvoicesRequest, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: usage_v1_billing_pb.ReconcileInvoicesResponse) => void): grpc.ClientUnaryCall; - public reconcileInvoices(request: usage_v1_billing_pb.ReconcileInvoicesRequest, metadata: grpc.Metadata, options: Partial, callback: (error: grpc.ServiceError | null, response: usage_v1_billing_pb.ReconcileInvoicesResponse) => void): grpc.ClientUnaryCall; - public getUpcomingInvoice(request: usage_v1_billing_pb.GetUpcomingInvoiceRequest, callback: (error: grpc.ServiceError | null, response: usage_v1_billing_pb.GetUpcomingInvoiceResponse) => void): grpc.ClientUnaryCall; - public getUpcomingInvoice(request: usage_v1_billing_pb.GetUpcomingInvoiceRequest, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: usage_v1_billing_pb.GetUpcomingInvoiceResponse) => void): grpc.ClientUnaryCall; - public getUpcomingInvoice(request: usage_v1_billing_pb.GetUpcomingInvoiceRequest, metadata: grpc.Metadata, options: Partial, callback: (error: grpc.ServiceError | null, response: usage_v1_billing_pb.GetUpcomingInvoiceResponse) => void): grpc.ClientUnaryCall; - public finalizeInvoice(request: usage_v1_billing_pb.FinalizeInvoiceRequest, callback: (error: grpc.ServiceError | null, response: usage_v1_billing_pb.FinalizeInvoiceResponse) => void): grpc.ClientUnaryCall; - public finalizeInvoice(request: usage_v1_billing_pb.FinalizeInvoiceRequest, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: usage_v1_billing_pb.FinalizeInvoiceResponse) => void): grpc.ClientUnaryCall; - public finalizeInvoice(request: usage_v1_billing_pb.FinalizeInvoiceRequest, metadata: grpc.Metadata, options: Partial, callback: (error: grpc.ServiceError | null, response: usage_v1_billing_pb.FinalizeInvoiceResponse) => void): grpc.ClientUnaryCall; - public setBilledSession(request: usage_v1_billing_pb.SetBilledSessionRequest, callback: (error: grpc.ServiceError | null, response: usage_v1_billing_pb.SetBilledSessionResponse) => void): grpc.ClientUnaryCall; - public setBilledSession(request: usage_v1_billing_pb.SetBilledSessionRequest, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: usage_v1_billing_pb.SetBilledSessionResponse) => void): grpc.ClientUnaryCall; - public setBilledSession(request: usage_v1_billing_pb.SetBilledSessionRequest, metadata: grpc.Metadata, options: Partial, callback: (error: grpc.ServiceError | null, response: usage_v1_billing_pb.SetBilledSessionResponse) => void): grpc.ClientUnaryCall; -} diff --git a/components/usage-api/typescript/src/usage/v1/billing_grpc_pb.js b/components/usage-api/typescript/src/usage/v1/billing_grpc_pb.js deleted file mode 100644 index 3e4ea610156d2f..00000000000000 --- a/components/usage-api/typescript/src/usage/v1/billing_grpc_pb.js +++ /dev/null @@ -1,156 +0,0 @@ -/** - * Copyright (c) 2022 Gitpod GmbH. All rights reserved. - * Licensed under the GNU Affero General Public License (AGPL). - * See License-AGPL.txt in the project root for license information. - */ - -// GENERATED CODE -- DO NOT EDIT! - -'use strict'; -var grpc = require('@grpc/grpc-js'); -var usage_v1_billing_pb = require('../../usage/v1/billing_pb.js'); -var google_protobuf_timestamp_pb = require('google-protobuf/google/protobuf/timestamp_pb.js'); - -function serialize_usage_v1_FinalizeInvoiceRequest(arg) { - if (!(arg instanceof usage_v1_billing_pb.FinalizeInvoiceRequest)) { - throw new Error('Expected argument of type usage.v1.FinalizeInvoiceRequest'); - } - return Buffer.from(arg.serializeBinary()); -} - -function deserialize_usage_v1_FinalizeInvoiceRequest(buffer_arg) { - return usage_v1_billing_pb.FinalizeInvoiceRequest.deserializeBinary(new Uint8Array(buffer_arg)); -} - -function serialize_usage_v1_FinalizeInvoiceResponse(arg) { - if (!(arg instanceof usage_v1_billing_pb.FinalizeInvoiceResponse)) { - throw new Error('Expected argument of type usage.v1.FinalizeInvoiceResponse'); - } - return Buffer.from(arg.serializeBinary()); -} - -function deserialize_usage_v1_FinalizeInvoiceResponse(buffer_arg) { - return usage_v1_billing_pb.FinalizeInvoiceResponse.deserializeBinary(new Uint8Array(buffer_arg)); -} - -function serialize_usage_v1_GetUpcomingInvoiceRequest(arg) { - if (!(arg instanceof usage_v1_billing_pb.GetUpcomingInvoiceRequest)) { - throw new Error('Expected argument of type usage.v1.GetUpcomingInvoiceRequest'); - } - return Buffer.from(arg.serializeBinary()); -} - -function deserialize_usage_v1_GetUpcomingInvoiceRequest(buffer_arg) { - return usage_v1_billing_pb.GetUpcomingInvoiceRequest.deserializeBinary(new Uint8Array(buffer_arg)); -} - -function serialize_usage_v1_GetUpcomingInvoiceResponse(arg) { - if (!(arg instanceof usage_v1_billing_pb.GetUpcomingInvoiceResponse)) { - throw new Error('Expected argument of type usage.v1.GetUpcomingInvoiceResponse'); - } - return Buffer.from(arg.serializeBinary()); -} - -function deserialize_usage_v1_GetUpcomingInvoiceResponse(buffer_arg) { - return usage_v1_billing_pb.GetUpcomingInvoiceResponse.deserializeBinary(new Uint8Array(buffer_arg)); -} - -function serialize_usage_v1_ReconcileInvoicesRequest(arg) { - if (!(arg instanceof usage_v1_billing_pb.ReconcileInvoicesRequest)) { - throw new Error('Expected argument of type usage.v1.ReconcileInvoicesRequest'); - } - return Buffer.from(arg.serializeBinary()); -} - -function deserialize_usage_v1_ReconcileInvoicesRequest(buffer_arg) { - return usage_v1_billing_pb.ReconcileInvoicesRequest.deserializeBinary(new Uint8Array(buffer_arg)); -} - -function serialize_usage_v1_ReconcileInvoicesResponse(arg) { - if (!(arg instanceof usage_v1_billing_pb.ReconcileInvoicesResponse)) { - throw new Error('Expected argument of type usage.v1.ReconcileInvoicesResponse'); - } - return Buffer.from(arg.serializeBinary()); -} - -function deserialize_usage_v1_ReconcileInvoicesResponse(buffer_arg) { - return usage_v1_billing_pb.ReconcileInvoicesResponse.deserializeBinary(new Uint8Array(buffer_arg)); -} - -function serialize_usage_v1_SetBilledSessionRequest(arg) { - if (!(arg instanceof usage_v1_billing_pb.SetBilledSessionRequest)) { - throw new Error('Expected argument of type usage.v1.SetBilledSessionRequest'); - } - return Buffer.from(arg.serializeBinary()); -} - -function deserialize_usage_v1_SetBilledSessionRequest(buffer_arg) { - return usage_v1_billing_pb.SetBilledSessionRequest.deserializeBinary(new Uint8Array(buffer_arg)); -} - -function serialize_usage_v1_SetBilledSessionResponse(arg) { - if (!(arg instanceof usage_v1_billing_pb.SetBilledSessionResponse)) { - throw new Error('Expected argument of type usage.v1.SetBilledSessionResponse'); - } - return Buffer.from(arg.serializeBinary()); -} - -function deserialize_usage_v1_SetBilledSessionResponse(buffer_arg) { - return usage_v1_billing_pb.SetBilledSessionResponse.deserializeBinary(new Uint8Array(buffer_arg)); -} - - -var BillingServiceService = exports.BillingServiceService = { - // ReconcileInvoices retrieves current credit balance and reflects it in billing system. -// Internal RPC, not intended for general consumption. -reconcileInvoices: { - path: '/usage.v1.BillingService/ReconcileInvoices', - requestStream: false, - responseStream: false, - requestType: usage_v1_billing_pb.ReconcileInvoicesRequest, - responseType: usage_v1_billing_pb.ReconcileInvoicesResponse, - requestSerialize: serialize_usage_v1_ReconcileInvoicesRequest, - requestDeserialize: deserialize_usage_v1_ReconcileInvoicesRequest, - responseSerialize: serialize_usage_v1_ReconcileInvoicesResponse, - responseDeserialize: deserialize_usage_v1_ReconcileInvoicesResponse, - }, - // GetUpcomingInvoice retrieves the latest invoice for a given query. -getUpcomingInvoice: { - path: '/usage.v1.BillingService/GetUpcomingInvoice', - requestStream: false, - responseStream: false, - requestType: usage_v1_billing_pb.GetUpcomingInvoiceRequest, - responseType: usage_v1_billing_pb.GetUpcomingInvoiceResponse, - requestSerialize: serialize_usage_v1_GetUpcomingInvoiceRequest, - requestDeserialize: deserialize_usage_v1_GetUpcomingInvoiceRequest, - responseSerialize: serialize_usage_v1_GetUpcomingInvoiceResponse, - responseDeserialize: deserialize_usage_v1_GetUpcomingInvoiceResponse, - }, - // FinalizeInvoice marks all sessions occurring in the given Stripe invoice as -// having been invoiced. -finalizeInvoice: { - path: '/usage.v1.BillingService/FinalizeInvoice', - requestStream: false, - responseStream: false, - requestType: usage_v1_billing_pb.FinalizeInvoiceRequest, - responseType: usage_v1_billing_pb.FinalizeInvoiceResponse, - requestSerialize: serialize_usage_v1_FinalizeInvoiceRequest, - requestDeserialize: deserialize_usage_v1_FinalizeInvoiceRequest, - responseSerialize: serialize_usage_v1_FinalizeInvoiceResponse, - responseDeserialize: deserialize_usage_v1_FinalizeInvoiceResponse, - }, - // SetBilledSession marks an instance as billed with a billing system -setBilledSession: { - path: '/usage.v1.BillingService/SetBilledSession', - requestStream: false, - responseStream: false, - requestType: usage_v1_billing_pb.SetBilledSessionRequest, - responseType: usage_v1_billing_pb.SetBilledSessionResponse, - requestSerialize: serialize_usage_v1_SetBilledSessionRequest, - requestDeserialize: deserialize_usage_v1_SetBilledSessionRequest, - responseSerialize: serialize_usage_v1_SetBilledSessionResponse, - responseDeserialize: deserialize_usage_v1_SetBilledSessionResponse, - }, -}; - -exports.BillingServiceClient = grpc.makeGenericClientConstructor(BillingServiceService); diff --git a/components/usage-api/typescript/src/usage/v1/billing_pb.d.ts b/components/usage-api/typescript/src/usage/v1/billing_pb.d.ts deleted file mode 100644 index ee6fc86e259c35..00000000000000 --- a/components/usage-api/typescript/src/usage/v1/billing_pb.d.ts +++ /dev/null @@ -1,204 +0,0 @@ -/** - * Copyright (c) 2022 Gitpod GmbH. All rights reserved. - * Licensed under the GNU Affero General Public License (AGPL). - * See License-AGPL.txt in the project root for license information. - */ - -// package: usage.v1 -// file: usage/v1/billing.proto - -/* tslint:disable */ -/* eslint-disable */ - -import * as jspb from "google-protobuf"; -import * as google_protobuf_timestamp_pb from "google-protobuf/google/protobuf/timestamp_pb"; - -export class ReconcileInvoicesRequest extends jspb.Message { - - serializeBinary(): Uint8Array; - toObject(includeInstance?: boolean): ReconcileInvoicesRequest.AsObject; - static toObject(includeInstance: boolean, msg: ReconcileInvoicesRequest): ReconcileInvoicesRequest.AsObject; - static extensions: {[key: number]: jspb.ExtensionFieldInfo}; - static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; - static serializeBinaryToWriter(message: ReconcileInvoicesRequest, writer: jspb.BinaryWriter): void; - static deserializeBinary(bytes: Uint8Array): ReconcileInvoicesRequest; - static deserializeBinaryFromReader(message: ReconcileInvoicesRequest, reader: jspb.BinaryReader): ReconcileInvoicesRequest; -} - -export namespace ReconcileInvoicesRequest { - export type AsObject = { - } -} - -export class ReconcileInvoicesResponse extends jspb.Message { - - serializeBinary(): Uint8Array; - toObject(includeInstance?: boolean): ReconcileInvoicesResponse.AsObject; - static toObject(includeInstance: boolean, msg: ReconcileInvoicesResponse): ReconcileInvoicesResponse.AsObject; - static extensions: {[key: number]: jspb.ExtensionFieldInfo}; - static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; - static serializeBinaryToWriter(message: ReconcileInvoicesResponse, writer: jspb.BinaryWriter): void; - static deserializeBinary(bytes: Uint8Array): ReconcileInvoicesResponse; - static deserializeBinaryFromReader(message: ReconcileInvoicesResponse, reader: jspb.BinaryReader): ReconcileInvoicesResponse; -} - -export namespace ReconcileInvoicesResponse { - export type AsObject = { - } -} - -export class GetUpcomingInvoiceRequest extends jspb.Message { - - hasTeamId(): boolean; - clearTeamId(): void; - getTeamId(): string; - setTeamId(value: string): GetUpcomingInvoiceRequest; - - hasUserId(): boolean; - clearUserId(): void; - getUserId(): string; - setUserId(value: string): GetUpcomingInvoiceRequest; - - getIdentifierCase(): GetUpcomingInvoiceRequest.IdentifierCase; - - serializeBinary(): Uint8Array; - toObject(includeInstance?: boolean): GetUpcomingInvoiceRequest.AsObject; - static toObject(includeInstance: boolean, msg: GetUpcomingInvoiceRequest): GetUpcomingInvoiceRequest.AsObject; - static extensions: {[key: number]: jspb.ExtensionFieldInfo}; - static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; - static serializeBinaryToWriter(message: GetUpcomingInvoiceRequest, writer: jspb.BinaryWriter): void; - static deserializeBinary(bytes: Uint8Array): GetUpcomingInvoiceRequest; - static deserializeBinaryFromReader(message: GetUpcomingInvoiceRequest, reader: jspb.BinaryReader): GetUpcomingInvoiceRequest; -} - -export namespace GetUpcomingInvoiceRequest { - export type AsObject = { - teamId: string, - userId: string, - } - - export enum IdentifierCase { - IDENTIFIER_NOT_SET = 0, - TEAM_ID = 1, - USER_ID = 2, - } - -} - -export class GetUpcomingInvoiceResponse extends jspb.Message { - getInvoiceId(): string; - setInvoiceId(value: string): GetUpcomingInvoiceResponse; - getCurrency(): string; - setCurrency(value: string): GetUpcomingInvoiceResponse; - getAmount(): number; - setAmount(value: number): GetUpcomingInvoiceResponse; - getCredits(): number; - setCredits(value: number): GetUpcomingInvoiceResponse; - - serializeBinary(): Uint8Array; - toObject(includeInstance?: boolean): GetUpcomingInvoiceResponse.AsObject; - static toObject(includeInstance: boolean, msg: GetUpcomingInvoiceResponse): GetUpcomingInvoiceResponse.AsObject; - static extensions: {[key: number]: jspb.ExtensionFieldInfo}; - static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; - static serializeBinaryToWriter(message: GetUpcomingInvoiceResponse, writer: jspb.BinaryWriter): void; - static deserializeBinary(bytes: Uint8Array): GetUpcomingInvoiceResponse; - static deserializeBinaryFromReader(message: GetUpcomingInvoiceResponse, reader: jspb.BinaryReader): GetUpcomingInvoiceResponse; -} - -export namespace GetUpcomingInvoiceResponse { - export type AsObject = { - invoiceId: string, - currency: string, - amount: number, - credits: number, - } -} - -export class FinalizeInvoiceRequest extends jspb.Message { - getInvoiceId(): string; - setInvoiceId(value: string): FinalizeInvoiceRequest; - - serializeBinary(): Uint8Array; - toObject(includeInstance?: boolean): FinalizeInvoiceRequest.AsObject; - static toObject(includeInstance: boolean, msg: FinalizeInvoiceRequest): FinalizeInvoiceRequest.AsObject; - static extensions: {[key: number]: jspb.ExtensionFieldInfo}; - static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; - static serializeBinaryToWriter(message: FinalizeInvoiceRequest, writer: jspb.BinaryWriter): void; - static deserializeBinary(bytes: Uint8Array): FinalizeInvoiceRequest; - static deserializeBinaryFromReader(message: FinalizeInvoiceRequest, reader: jspb.BinaryReader): FinalizeInvoiceRequest; -} - -export namespace FinalizeInvoiceRequest { - export type AsObject = { - invoiceId: string, - } -} - -export class FinalizeInvoiceResponse extends jspb.Message { - - serializeBinary(): Uint8Array; - toObject(includeInstance?: boolean): FinalizeInvoiceResponse.AsObject; - static toObject(includeInstance: boolean, msg: FinalizeInvoiceResponse): FinalizeInvoiceResponse.AsObject; - static extensions: {[key: number]: jspb.ExtensionFieldInfo}; - static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; - static serializeBinaryToWriter(message: FinalizeInvoiceResponse, writer: jspb.BinaryWriter): void; - static deserializeBinary(bytes: Uint8Array): FinalizeInvoiceResponse; - static deserializeBinaryFromReader(message: FinalizeInvoiceResponse, reader: jspb.BinaryReader): FinalizeInvoiceResponse; -} - -export namespace FinalizeInvoiceResponse { - export type AsObject = { - } -} - -export class SetBilledSessionRequest extends jspb.Message { - getInstanceId(): string; - setInstanceId(value: string): SetBilledSessionRequest; - - hasFrom(): boolean; - clearFrom(): void; - getFrom(): google_protobuf_timestamp_pb.Timestamp | undefined; - setFrom(value?: google_protobuf_timestamp_pb.Timestamp): SetBilledSessionRequest; - getSystem(): System; - setSystem(value: System): SetBilledSessionRequest; - - serializeBinary(): Uint8Array; - toObject(includeInstance?: boolean): SetBilledSessionRequest.AsObject; - static toObject(includeInstance: boolean, msg: SetBilledSessionRequest): SetBilledSessionRequest.AsObject; - static extensions: {[key: number]: jspb.ExtensionFieldInfo}; - static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; - static serializeBinaryToWriter(message: SetBilledSessionRequest, writer: jspb.BinaryWriter): void; - static deserializeBinary(bytes: Uint8Array): SetBilledSessionRequest; - static deserializeBinaryFromReader(message: SetBilledSessionRequest, reader: jspb.BinaryReader): SetBilledSessionRequest; -} - -export namespace SetBilledSessionRequest { - export type AsObject = { - instanceId: string, - from?: google_protobuf_timestamp_pb.Timestamp.AsObject, - system: System, - } -} - -export class SetBilledSessionResponse extends jspb.Message { - - serializeBinary(): Uint8Array; - toObject(includeInstance?: boolean): SetBilledSessionResponse.AsObject; - static toObject(includeInstance: boolean, msg: SetBilledSessionResponse): SetBilledSessionResponse.AsObject; - static extensions: {[key: number]: jspb.ExtensionFieldInfo}; - static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; - static serializeBinaryToWriter(message: SetBilledSessionResponse, writer: jspb.BinaryWriter): void; - static deserializeBinary(bytes: Uint8Array): SetBilledSessionResponse; - static deserializeBinaryFromReader(message: SetBilledSessionResponse, reader: jspb.BinaryReader): SetBilledSessionResponse; -} - -export namespace SetBilledSessionResponse { - export type AsObject = { - } -} - -export enum System { - SYSTEM_UNKNOWN = 0, - SYSTEM_CHARGEBEE = 1, - SYSTEM_STRIPE = 2, -} diff --git a/components/usage-api/typescript/src/usage/v1/billing_pb.js b/components/usage-api/typescript/src/usage/v1/billing_pb.js deleted file mode 100644 index a220fc9be1e18f..00000000000000 --- a/components/usage-api/typescript/src/usage/v1/billing_pb.js +++ /dev/null @@ -1,1400 +0,0 @@ -/** - * Copyright (c) 2022 Gitpod GmbH. All rights reserved. - * Licensed under the GNU Affero General Public License (AGPL). - * See License-AGPL.txt in the project root for license information. - */ - -// source: usage/v1/billing.proto -/** - * @fileoverview - * @enhanceable - * @suppress {missingRequire} reports error on implicit type usages. - * @suppress {messageConventions} JS Compiler reports an error if a variable or - * field starts with 'MSG_' and isn't a translatable message. - * @public - */ -// GENERATED CODE -- DO NOT EDIT! -/* eslint-disable */ -// @ts-nocheck - -var jspb = require('google-protobuf'); -var goog = jspb; -var global = (function() { return this || window || global || self || Function('return this')(); }).call(null); - -var google_protobuf_timestamp_pb = require('google-protobuf/google/protobuf/timestamp_pb.js'); -goog.object.extend(proto, google_protobuf_timestamp_pb); -goog.exportSymbol('proto.usage.v1.FinalizeInvoiceRequest', null, global); -goog.exportSymbol('proto.usage.v1.FinalizeInvoiceResponse', null, global); -goog.exportSymbol('proto.usage.v1.GetUpcomingInvoiceRequest', null, global); -goog.exportSymbol('proto.usage.v1.GetUpcomingInvoiceRequest.IdentifierCase', null, global); -goog.exportSymbol('proto.usage.v1.GetUpcomingInvoiceResponse', null, global); -goog.exportSymbol('proto.usage.v1.ReconcileInvoicesRequest', null, global); -goog.exportSymbol('proto.usage.v1.ReconcileInvoicesResponse', null, global); -goog.exportSymbol('proto.usage.v1.SetBilledSessionRequest', null, global); -goog.exportSymbol('proto.usage.v1.SetBilledSessionResponse', null, global); -goog.exportSymbol('proto.usage.v1.System', null, global); -/** - * Generated by JsPbCodeGenerator. - * @param {Array=} opt_data Optional initial data array, typically from a - * server response, or constructed directly in Javascript. The array is used - * in place and becomes part of the constructed object. It is not cloned. - * If no data is provided, the constructed object will be empty, but still - * valid. - * @extends {jspb.Message} - * @constructor - */ -proto.usage.v1.ReconcileInvoicesRequest = function(opt_data) { - jspb.Message.initialize(this, opt_data, 0, -1, null, null); -}; -goog.inherits(proto.usage.v1.ReconcileInvoicesRequest, jspb.Message); -if (goog.DEBUG && !COMPILED) { - /** - * @public - * @override - */ - proto.usage.v1.ReconcileInvoicesRequest.displayName = 'proto.usage.v1.ReconcileInvoicesRequest'; -} -/** - * Generated by JsPbCodeGenerator. - * @param {Array=} opt_data Optional initial data array, typically from a - * server response, or constructed directly in Javascript. The array is used - * in place and becomes part of the constructed object. It is not cloned. - * If no data is provided, the constructed object will be empty, but still - * valid. - * @extends {jspb.Message} - * @constructor - */ -proto.usage.v1.ReconcileInvoicesResponse = function(opt_data) { - jspb.Message.initialize(this, opt_data, 0, -1, null, null); -}; -goog.inherits(proto.usage.v1.ReconcileInvoicesResponse, jspb.Message); -if (goog.DEBUG && !COMPILED) { - /** - * @public - * @override - */ - proto.usage.v1.ReconcileInvoicesResponse.displayName = 'proto.usage.v1.ReconcileInvoicesResponse'; -} -/** - * Generated by JsPbCodeGenerator. - * @param {Array=} opt_data Optional initial data array, typically from a - * server response, or constructed directly in Javascript. The array is used - * in place and becomes part of the constructed object. It is not cloned. - * If no data is provided, the constructed object will be empty, but still - * valid. - * @extends {jspb.Message} - * @constructor - */ -proto.usage.v1.GetUpcomingInvoiceRequest = function(opt_data) { - jspb.Message.initialize(this, opt_data, 0, -1, null, proto.usage.v1.GetUpcomingInvoiceRequest.oneofGroups_); -}; -goog.inherits(proto.usage.v1.GetUpcomingInvoiceRequest, jspb.Message); -if (goog.DEBUG && !COMPILED) { - /** - * @public - * @override - */ - proto.usage.v1.GetUpcomingInvoiceRequest.displayName = 'proto.usage.v1.GetUpcomingInvoiceRequest'; -} -/** - * Generated by JsPbCodeGenerator. - * @param {Array=} opt_data Optional initial data array, typically from a - * server response, or constructed directly in Javascript. The array is used - * in place and becomes part of the constructed object. It is not cloned. - * If no data is provided, the constructed object will be empty, but still - * valid. - * @extends {jspb.Message} - * @constructor - */ -proto.usage.v1.GetUpcomingInvoiceResponse = function(opt_data) { - jspb.Message.initialize(this, opt_data, 0, -1, null, null); -}; -goog.inherits(proto.usage.v1.GetUpcomingInvoiceResponse, jspb.Message); -if (goog.DEBUG && !COMPILED) { - /** - * @public - * @override - */ - proto.usage.v1.GetUpcomingInvoiceResponse.displayName = 'proto.usage.v1.GetUpcomingInvoiceResponse'; -} -/** - * Generated by JsPbCodeGenerator. - * @param {Array=} opt_data Optional initial data array, typically from a - * server response, or constructed directly in Javascript. The array is used - * in place and becomes part of the constructed object. It is not cloned. - * If no data is provided, the constructed object will be empty, but still - * valid. - * @extends {jspb.Message} - * @constructor - */ -proto.usage.v1.FinalizeInvoiceRequest = function(opt_data) { - jspb.Message.initialize(this, opt_data, 0, -1, null, null); -}; -goog.inherits(proto.usage.v1.FinalizeInvoiceRequest, jspb.Message); -if (goog.DEBUG && !COMPILED) { - /** - * @public - * @override - */ - proto.usage.v1.FinalizeInvoiceRequest.displayName = 'proto.usage.v1.FinalizeInvoiceRequest'; -} -/** - * Generated by JsPbCodeGenerator. - * @param {Array=} opt_data Optional initial data array, typically from a - * server response, or constructed directly in Javascript. The array is used - * in place and becomes part of the constructed object. It is not cloned. - * If no data is provided, the constructed object will be empty, but still - * valid. - * @extends {jspb.Message} - * @constructor - */ -proto.usage.v1.FinalizeInvoiceResponse = function(opt_data) { - jspb.Message.initialize(this, opt_data, 0, -1, null, null); -}; -goog.inherits(proto.usage.v1.FinalizeInvoiceResponse, jspb.Message); -if (goog.DEBUG && !COMPILED) { - /** - * @public - * @override - */ - proto.usage.v1.FinalizeInvoiceResponse.displayName = 'proto.usage.v1.FinalizeInvoiceResponse'; -} -/** - * Generated by JsPbCodeGenerator. - * @param {Array=} opt_data Optional initial data array, typically from a - * server response, or constructed directly in Javascript. The array is used - * in place and becomes part of the constructed object. It is not cloned. - * If no data is provided, the constructed object will be empty, but still - * valid. - * @extends {jspb.Message} - * @constructor - */ -proto.usage.v1.SetBilledSessionRequest = function(opt_data) { - jspb.Message.initialize(this, opt_data, 0, -1, null, null); -}; -goog.inherits(proto.usage.v1.SetBilledSessionRequest, jspb.Message); -if (goog.DEBUG && !COMPILED) { - /** - * @public - * @override - */ - proto.usage.v1.SetBilledSessionRequest.displayName = 'proto.usage.v1.SetBilledSessionRequest'; -} -/** - * Generated by JsPbCodeGenerator. - * @param {Array=} opt_data Optional initial data array, typically from a - * server response, or constructed directly in Javascript. The array is used - * in place and becomes part of the constructed object. It is not cloned. - * If no data is provided, the constructed object will be empty, but still - * valid. - * @extends {jspb.Message} - * @constructor - */ -proto.usage.v1.SetBilledSessionResponse = function(opt_data) { - jspb.Message.initialize(this, opt_data, 0, -1, null, null); -}; -goog.inherits(proto.usage.v1.SetBilledSessionResponse, jspb.Message); -if (goog.DEBUG && !COMPILED) { - /** - * @public - * @override - */ - proto.usage.v1.SetBilledSessionResponse.displayName = 'proto.usage.v1.SetBilledSessionResponse'; -} - - - -if (jspb.Message.GENERATE_TO_OBJECT) { -/** - * Creates an object representation of this proto. - * Field names that are reserved in JavaScript and will be renamed to pb_name. - * Optional fields that are not set will be set to undefined. - * To access a reserved field use, foo.pb_, eg, foo.pb_default. - * For the list of reserved names please see: - * net/proto2/compiler/js/internal/generator.cc#kKeyword. - * @param {boolean=} opt_includeInstance Deprecated. whether to include the - * JSPB instance for transitional soy proto support: - * http://goto/soy-param-migration - * @return {!Object} - */ -proto.usage.v1.ReconcileInvoicesRequest.prototype.toObject = function(opt_includeInstance) { - return proto.usage.v1.ReconcileInvoicesRequest.toObject(opt_includeInstance, this); -}; - - -/** - * Static version of the {@see toObject} method. - * @param {boolean|undefined} includeInstance Deprecated. Whether to include - * the JSPB instance for transitional soy proto support: - * http://goto/soy-param-migration - * @param {!proto.usage.v1.ReconcileInvoicesRequest} msg The msg instance to transform. - * @return {!Object} - * @suppress {unusedLocalVariables} f is only used for nested messages - */ -proto.usage.v1.ReconcileInvoicesRequest.toObject = function(includeInstance, msg) { - var f, obj = { - - }; - - if (includeInstance) { - obj.$jspbMessageInstance = msg; - } - return obj; -}; -} - - -/** - * Deserializes binary data (in protobuf wire format). - * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.usage.v1.ReconcileInvoicesRequest} - */ -proto.usage.v1.ReconcileInvoicesRequest.deserializeBinary = function(bytes) { - var reader = new jspb.BinaryReader(bytes); - var msg = new proto.usage.v1.ReconcileInvoicesRequest; - return proto.usage.v1.ReconcileInvoicesRequest.deserializeBinaryFromReader(msg, reader); -}; - - -/** - * Deserializes binary data (in protobuf wire format) from the - * given reader into the given message object. - * @param {!proto.usage.v1.ReconcileInvoicesRequest} msg The message object to deserialize into. - * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.usage.v1.ReconcileInvoicesRequest} - */ -proto.usage.v1.ReconcileInvoicesRequest.deserializeBinaryFromReader = function(msg, reader) { - while (reader.nextField()) { - if (reader.isEndGroup()) { - break; - } - var field = reader.getFieldNumber(); - switch (field) { - default: - reader.skipField(); - break; - } - } - return msg; -}; - - -/** - * Serializes the message to binary data (in protobuf wire format). - * @return {!Uint8Array} - */ -proto.usage.v1.ReconcileInvoicesRequest.prototype.serializeBinary = function() { - var writer = new jspb.BinaryWriter(); - proto.usage.v1.ReconcileInvoicesRequest.serializeBinaryToWriter(this, writer); - return writer.getResultBuffer(); -}; - - -/** - * Serializes the given message to binary data (in protobuf wire - * format), writing to the given BinaryWriter. - * @param {!proto.usage.v1.ReconcileInvoicesRequest} message - * @param {!jspb.BinaryWriter} writer - * @suppress {unusedLocalVariables} f is only used for nested messages - */ -proto.usage.v1.ReconcileInvoicesRequest.serializeBinaryToWriter = function(message, writer) { - var f = undefined; -}; - - - - - -if (jspb.Message.GENERATE_TO_OBJECT) { -/** - * Creates an object representation of this proto. - * Field names that are reserved in JavaScript and will be renamed to pb_name. - * Optional fields that are not set will be set to undefined. - * To access a reserved field use, foo.pb_, eg, foo.pb_default. - * For the list of reserved names please see: - * net/proto2/compiler/js/internal/generator.cc#kKeyword. - * @param {boolean=} opt_includeInstance Deprecated. whether to include the - * JSPB instance for transitional soy proto support: - * http://goto/soy-param-migration - * @return {!Object} - */ -proto.usage.v1.ReconcileInvoicesResponse.prototype.toObject = function(opt_includeInstance) { - return proto.usage.v1.ReconcileInvoicesResponse.toObject(opt_includeInstance, this); -}; - - -/** - * Static version of the {@see toObject} method. - * @param {boolean|undefined} includeInstance Deprecated. Whether to include - * the JSPB instance for transitional soy proto support: - * http://goto/soy-param-migration - * @param {!proto.usage.v1.ReconcileInvoicesResponse} msg The msg instance to transform. - * @return {!Object} - * @suppress {unusedLocalVariables} f is only used for nested messages - */ -proto.usage.v1.ReconcileInvoicesResponse.toObject = function(includeInstance, msg) { - var f, obj = { - - }; - - if (includeInstance) { - obj.$jspbMessageInstance = msg; - } - return obj; -}; -} - - -/** - * Deserializes binary data (in protobuf wire format). - * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.usage.v1.ReconcileInvoicesResponse} - */ -proto.usage.v1.ReconcileInvoicesResponse.deserializeBinary = function(bytes) { - var reader = new jspb.BinaryReader(bytes); - var msg = new proto.usage.v1.ReconcileInvoicesResponse; - return proto.usage.v1.ReconcileInvoicesResponse.deserializeBinaryFromReader(msg, reader); -}; - - -/** - * Deserializes binary data (in protobuf wire format) from the - * given reader into the given message object. - * @param {!proto.usage.v1.ReconcileInvoicesResponse} msg The message object to deserialize into. - * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.usage.v1.ReconcileInvoicesResponse} - */ -proto.usage.v1.ReconcileInvoicesResponse.deserializeBinaryFromReader = function(msg, reader) { - while (reader.nextField()) { - if (reader.isEndGroup()) { - break; - } - var field = reader.getFieldNumber(); - switch (field) { - default: - reader.skipField(); - break; - } - } - return msg; -}; - - -/** - * Serializes the message to binary data (in protobuf wire format). - * @return {!Uint8Array} - */ -proto.usage.v1.ReconcileInvoicesResponse.prototype.serializeBinary = function() { - var writer = new jspb.BinaryWriter(); - proto.usage.v1.ReconcileInvoicesResponse.serializeBinaryToWriter(this, writer); - return writer.getResultBuffer(); -}; - - -/** - * Serializes the given message to binary data (in protobuf wire - * format), writing to the given BinaryWriter. - * @param {!proto.usage.v1.ReconcileInvoicesResponse} message - * @param {!jspb.BinaryWriter} writer - * @suppress {unusedLocalVariables} f is only used for nested messages - */ -proto.usage.v1.ReconcileInvoicesResponse.serializeBinaryToWriter = function(message, writer) { - var f = undefined; -}; - - - -/** - * Oneof group definitions for this message. Each group defines the field - * numbers belonging to that group. When of these fields' value is set, all - * other fields in the group are cleared. During deserialization, if multiple - * fields are encountered for a group, only the last value seen will be kept. - * @private {!Array>} - * @const - */ -proto.usage.v1.GetUpcomingInvoiceRequest.oneofGroups_ = [[1,2]]; - -/** - * @enum {number} - */ -proto.usage.v1.GetUpcomingInvoiceRequest.IdentifierCase = { - IDENTIFIER_NOT_SET: 0, - TEAM_ID: 1, - USER_ID: 2 -}; - -/** - * @return {proto.usage.v1.GetUpcomingInvoiceRequest.IdentifierCase} - */ -proto.usage.v1.GetUpcomingInvoiceRequest.prototype.getIdentifierCase = function() { - return /** @type {proto.usage.v1.GetUpcomingInvoiceRequest.IdentifierCase} */(jspb.Message.computeOneofCase(this, proto.usage.v1.GetUpcomingInvoiceRequest.oneofGroups_[0])); -}; - - - -if (jspb.Message.GENERATE_TO_OBJECT) { -/** - * Creates an object representation of this proto. - * Field names that are reserved in JavaScript and will be renamed to pb_name. - * Optional fields that are not set will be set to undefined. - * To access a reserved field use, foo.pb_, eg, foo.pb_default. - * For the list of reserved names please see: - * net/proto2/compiler/js/internal/generator.cc#kKeyword. - * @param {boolean=} opt_includeInstance Deprecated. whether to include the - * JSPB instance for transitional soy proto support: - * http://goto/soy-param-migration - * @return {!Object} - */ -proto.usage.v1.GetUpcomingInvoiceRequest.prototype.toObject = function(opt_includeInstance) { - return proto.usage.v1.GetUpcomingInvoiceRequest.toObject(opt_includeInstance, this); -}; - - -/** - * Static version of the {@see toObject} method. - * @param {boolean|undefined} includeInstance Deprecated. Whether to include - * the JSPB instance for transitional soy proto support: - * http://goto/soy-param-migration - * @param {!proto.usage.v1.GetUpcomingInvoiceRequest} msg The msg instance to transform. - * @return {!Object} - * @suppress {unusedLocalVariables} f is only used for nested messages - */ -proto.usage.v1.GetUpcomingInvoiceRequest.toObject = function(includeInstance, msg) { - var f, obj = { - teamId: jspb.Message.getFieldWithDefault(msg, 1, ""), - userId: jspb.Message.getFieldWithDefault(msg, 2, "") - }; - - if (includeInstance) { - obj.$jspbMessageInstance = msg; - } - return obj; -}; -} - - -/** - * Deserializes binary data (in protobuf wire format). - * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.usage.v1.GetUpcomingInvoiceRequest} - */ -proto.usage.v1.GetUpcomingInvoiceRequest.deserializeBinary = function(bytes) { - var reader = new jspb.BinaryReader(bytes); - var msg = new proto.usage.v1.GetUpcomingInvoiceRequest; - return proto.usage.v1.GetUpcomingInvoiceRequest.deserializeBinaryFromReader(msg, reader); -}; - - -/** - * Deserializes binary data (in protobuf wire format) from the - * given reader into the given message object. - * @param {!proto.usage.v1.GetUpcomingInvoiceRequest} msg The message object to deserialize into. - * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.usage.v1.GetUpcomingInvoiceRequest} - */ -proto.usage.v1.GetUpcomingInvoiceRequest.deserializeBinaryFromReader = function(msg, reader) { - while (reader.nextField()) { - if (reader.isEndGroup()) { - break; - } - var field = reader.getFieldNumber(); - switch (field) { - case 1: - var value = /** @type {string} */ (reader.readString()); - msg.setTeamId(value); - break; - case 2: - var value = /** @type {string} */ (reader.readString()); - msg.setUserId(value); - break; - default: - reader.skipField(); - break; - } - } - return msg; -}; - - -/** - * Serializes the message to binary data (in protobuf wire format). - * @return {!Uint8Array} - */ -proto.usage.v1.GetUpcomingInvoiceRequest.prototype.serializeBinary = function() { - var writer = new jspb.BinaryWriter(); - proto.usage.v1.GetUpcomingInvoiceRequest.serializeBinaryToWriter(this, writer); - return writer.getResultBuffer(); -}; - - -/** - * Serializes the given message to binary data (in protobuf wire - * format), writing to the given BinaryWriter. - * @param {!proto.usage.v1.GetUpcomingInvoiceRequest} message - * @param {!jspb.BinaryWriter} writer - * @suppress {unusedLocalVariables} f is only used for nested messages - */ -proto.usage.v1.GetUpcomingInvoiceRequest.serializeBinaryToWriter = function(message, writer) { - var f = undefined; - f = /** @type {string} */ (jspb.Message.getField(message, 1)); - if (f != null) { - writer.writeString( - 1, - f - ); - } - f = /** @type {string} */ (jspb.Message.getField(message, 2)); - if (f != null) { - writer.writeString( - 2, - f - ); - } -}; - - -/** - * optional string team_id = 1; - * @return {string} - */ -proto.usage.v1.GetUpcomingInvoiceRequest.prototype.getTeamId = function() { - return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); -}; - - -/** - * @param {string} value - * @return {!proto.usage.v1.GetUpcomingInvoiceRequest} returns this - */ -proto.usage.v1.GetUpcomingInvoiceRequest.prototype.setTeamId = function(value) { - return jspb.Message.setOneofField(this, 1, proto.usage.v1.GetUpcomingInvoiceRequest.oneofGroups_[0], value); -}; - - -/** - * Clears the field making it undefined. - * @return {!proto.usage.v1.GetUpcomingInvoiceRequest} returns this - */ -proto.usage.v1.GetUpcomingInvoiceRequest.prototype.clearTeamId = function() { - return jspb.Message.setOneofField(this, 1, proto.usage.v1.GetUpcomingInvoiceRequest.oneofGroups_[0], undefined); -}; - - -/** - * Returns whether this field is set. - * @return {boolean} - */ -proto.usage.v1.GetUpcomingInvoiceRequest.prototype.hasTeamId = function() { - return jspb.Message.getField(this, 1) != null; -}; - - -/** - * optional string user_id = 2; - * @return {string} - */ -proto.usage.v1.GetUpcomingInvoiceRequest.prototype.getUserId = function() { - return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 2, "")); -}; - - -/** - * @param {string} value - * @return {!proto.usage.v1.GetUpcomingInvoiceRequest} returns this - */ -proto.usage.v1.GetUpcomingInvoiceRequest.prototype.setUserId = function(value) { - return jspb.Message.setOneofField(this, 2, proto.usage.v1.GetUpcomingInvoiceRequest.oneofGroups_[0], value); -}; - - -/** - * Clears the field making it undefined. - * @return {!proto.usage.v1.GetUpcomingInvoiceRequest} returns this - */ -proto.usage.v1.GetUpcomingInvoiceRequest.prototype.clearUserId = function() { - return jspb.Message.setOneofField(this, 2, proto.usage.v1.GetUpcomingInvoiceRequest.oneofGroups_[0], undefined); -}; - - -/** - * Returns whether this field is set. - * @return {boolean} - */ -proto.usage.v1.GetUpcomingInvoiceRequest.prototype.hasUserId = function() { - return jspb.Message.getField(this, 2) != null; -}; - - - - - -if (jspb.Message.GENERATE_TO_OBJECT) { -/** - * Creates an object representation of this proto. - * Field names that are reserved in JavaScript and will be renamed to pb_name. - * Optional fields that are not set will be set to undefined. - * To access a reserved field use, foo.pb_, eg, foo.pb_default. - * For the list of reserved names please see: - * net/proto2/compiler/js/internal/generator.cc#kKeyword. - * @param {boolean=} opt_includeInstance Deprecated. whether to include the - * JSPB instance for transitional soy proto support: - * http://goto/soy-param-migration - * @return {!Object} - */ -proto.usage.v1.GetUpcomingInvoiceResponse.prototype.toObject = function(opt_includeInstance) { - return proto.usage.v1.GetUpcomingInvoiceResponse.toObject(opt_includeInstance, this); -}; - - -/** - * Static version of the {@see toObject} method. - * @param {boolean|undefined} includeInstance Deprecated. Whether to include - * the JSPB instance for transitional soy proto support: - * http://goto/soy-param-migration - * @param {!proto.usage.v1.GetUpcomingInvoiceResponse} msg The msg instance to transform. - * @return {!Object} - * @suppress {unusedLocalVariables} f is only used for nested messages - */ -proto.usage.v1.GetUpcomingInvoiceResponse.toObject = function(includeInstance, msg) { - var f, obj = { - invoiceId: jspb.Message.getFieldWithDefault(msg, 1, ""), - currency: jspb.Message.getFieldWithDefault(msg, 2, ""), - amount: jspb.Message.getFloatingPointFieldWithDefault(msg, 3, 0.0), - credits: jspb.Message.getFieldWithDefault(msg, 4, 0) - }; - - if (includeInstance) { - obj.$jspbMessageInstance = msg; - } - return obj; -}; -} - - -/** - * Deserializes binary data (in protobuf wire format). - * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.usage.v1.GetUpcomingInvoiceResponse} - */ -proto.usage.v1.GetUpcomingInvoiceResponse.deserializeBinary = function(bytes) { - var reader = new jspb.BinaryReader(bytes); - var msg = new proto.usage.v1.GetUpcomingInvoiceResponse; - return proto.usage.v1.GetUpcomingInvoiceResponse.deserializeBinaryFromReader(msg, reader); -}; - - -/** - * Deserializes binary data (in protobuf wire format) from the - * given reader into the given message object. - * @param {!proto.usage.v1.GetUpcomingInvoiceResponse} msg The message object to deserialize into. - * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.usage.v1.GetUpcomingInvoiceResponse} - */ -proto.usage.v1.GetUpcomingInvoiceResponse.deserializeBinaryFromReader = function(msg, reader) { - while (reader.nextField()) { - if (reader.isEndGroup()) { - break; - } - var field = reader.getFieldNumber(); - switch (field) { - case 1: - var value = /** @type {string} */ (reader.readString()); - msg.setInvoiceId(value); - break; - case 2: - var value = /** @type {string} */ (reader.readString()); - msg.setCurrency(value); - break; - case 3: - var value = /** @type {number} */ (reader.readDouble()); - msg.setAmount(value); - break; - case 4: - var value = /** @type {number} */ (reader.readInt64()); - msg.setCredits(value); - break; - default: - reader.skipField(); - break; - } - } - return msg; -}; - - -/** - * Serializes the message to binary data (in protobuf wire format). - * @return {!Uint8Array} - */ -proto.usage.v1.GetUpcomingInvoiceResponse.prototype.serializeBinary = function() { - var writer = new jspb.BinaryWriter(); - proto.usage.v1.GetUpcomingInvoiceResponse.serializeBinaryToWriter(this, writer); - return writer.getResultBuffer(); -}; - - -/** - * Serializes the given message to binary data (in protobuf wire - * format), writing to the given BinaryWriter. - * @param {!proto.usage.v1.GetUpcomingInvoiceResponse} message - * @param {!jspb.BinaryWriter} writer - * @suppress {unusedLocalVariables} f is only used for nested messages - */ -proto.usage.v1.GetUpcomingInvoiceResponse.serializeBinaryToWriter = function(message, writer) { - var f = undefined; - f = message.getInvoiceId(); - if (f.length > 0) { - writer.writeString( - 1, - f - ); - } - f = message.getCurrency(); - if (f.length > 0) { - writer.writeString( - 2, - f - ); - } - f = message.getAmount(); - if (f !== 0.0) { - writer.writeDouble( - 3, - f - ); - } - f = message.getCredits(); - if (f !== 0) { - writer.writeInt64( - 4, - f - ); - } -}; - - -/** - * optional string invoice_id = 1; - * @return {string} - */ -proto.usage.v1.GetUpcomingInvoiceResponse.prototype.getInvoiceId = function() { - return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); -}; - - -/** - * @param {string} value - * @return {!proto.usage.v1.GetUpcomingInvoiceResponse} returns this - */ -proto.usage.v1.GetUpcomingInvoiceResponse.prototype.setInvoiceId = function(value) { - return jspb.Message.setProto3StringField(this, 1, value); -}; - - -/** - * optional string currency = 2; - * @return {string} - */ -proto.usage.v1.GetUpcomingInvoiceResponse.prototype.getCurrency = function() { - return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 2, "")); -}; - - -/** - * @param {string} value - * @return {!proto.usage.v1.GetUpcomingInvoiceResponse} returns this - */ -proto.usage.v1.GetUpcomingInvoiceResponse.prototype.setCurrency = function(value) { - return jspb.Message.setProto3StringField(this, 2, value); -}; - - -/** - * optional double amount = 3; - * @return {number} - */ -proto.usage.v1.GetUpcomingInvoiceResponse.prototype.getAmount = function() { - return /** @type {number} */ (jspb.Message.getFloatingPointFieldWithDefault(this, 3, 0.0)); -}; - - -/** - * @param {number} value - * @return {!proto.usage.v1.GetUpcomingInvoiceResponse} returns this - */ -proto.usage.v1.GetUpcomingInvoiceResponse.prototype.setAmount = function(value) { - return jspb.Message.setProto3FloatField(this, 3, value); -}; - - -/** - * optional int64 credits = 4; - * @return {number} - */ -proto.usage.v1.GetUpcomingInvoiceResponse.prototype.getCredits = function() { - return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 4, 0)); -}; - - -/** - * @param {number} value - * @return {!proto.usage.v1.GetUpcomingInvoiceResponse} returns this - */ -proto.usage.v1.GetUpcomingInvoiceResponse.prototype.setCredits = function(value) { - return jspb.Message.setProto3IntField(this, 4, value); -}; - - - - - -if (jspb.Message.GENERATE_TO_OBJECT) { -/** - * Creates an object representation of this proto. - * Field names that are reserved in JavaScript and will be renamed to pb_name. - * Optional fields that are not set will be set to undefined. - * To access a reserved field use, foo.pb_, eg, foo.pb_default. - * For the list of reserved names please see: - * net/proto2/compiler/js/internal/generator.cc#kKeyword. - * @param {boolean=} opt_includeInstance Deprecated. whether to include the - * JSPB instance for transitional soy proto support: - * http://goto/soy-param-migration - * @return {!Object} - */ -proto.usage.v1.FinalizeInvoiceRequest.prototype.toObject = function(opt_includeInstance) { - return proto.usage.v1.FinalizeInvoiceRequest.toObject(opt_includeInstance, this); -}; - - -/** - * Static version of the {@see toObject} method. - * @param {boolean|undefined} includeInstance Deprecated. Whether to include - * the JSPB instance for transitional soy proto support: - * http://goto/soy-param-migration - * @param {!proto.usage.v1.FinalizeInvoiceRequest} msg The msg instance to transform. - * @return {!Object} - * @suppress {unusedLocalVariables} f is only used for nested messages - */ -proto.usage.v1.FinalizeInvoiceRequest.toObject = function(includeInstance, msg) { - var f, obj = { - invoiceId: jspb.Message.getFieldWithDefault(msg, 1, "") - }; - - if (includeInstance) { - obj.$jspbMessageInstance = msg; - } - return obj; -}; -} - - -/** - * Deserializes binary data (in protobuf wire format). - * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.usage.v1.FinalizeInvoiceRequest} - */ -proto.usage.v1.FinalizeInvoiceRequest.deserializeBinary = function(bytes) { - var reader = new jspb.BinaryReader(bytes); - var msg = new proto.usage.v1.FinalizeInvoiceRequest; - return proto.usage.v1.FinalizeInvoiceRequest.deserializeBinaryFromReader(msg, reader); -}; - - -/** - * Deserializes binary data (in protobuf wire format) from the - * given reader into the given message object. - * @param {!proto.usage.v1.FinalizeInvoiceRequest} msg The message object to deserialize into. - * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.usage.v1.FinalizeInvoiceRequest} - */ -proto.usage.v1.FinalizeInvoiceRequest.deserializeBinaryFromReader = function(msg, reader) { - while (reader.nextField()) { - if (reader.isEndGroup()) { - break; - } - var field = reader.getFieldNumber(); - switch (field) { - case 1: - var value = /** @type {string} */ (reader.readString()); - msg.setInvoiceId(value); - break; - default: - reader.skipField(); - break; - } - } - return msg; -}; - - -/** - * Serializes the message to binary data (in protobuf wire format). - * @return {!Uint8Array} - */ -proto.usage.v1.FinalizeInvoiceRequest.prototype.serializeBinary = function() { - var writer = new jspb.BinaryWriter(); - proto.usage.v1.FinalizeInvoiceRequest.serializeBinaryToWriter(this, writer); - return writer.getResultBuffer(); -}; - - -/** - * Serializes the given message to binary data (in protobuf wire - * format), writing to the given BinaryWriter. - * @param {!proto.usage.v1.FinalizeInvoiceRequest} message - * @param {!jspb.BinaryWriter} writer - * @suppress {unusedLocalVariables} f is only used for nested messages - */ -proto.usage.v1.FinalizeInvoiceRequest.serializeBinaryToWriter = function(message, writer) { - var f = undefined; - f = message.getInvoiceId(); - if (f.length > 0) { - writer.writeString( - 1, - f - ); - } -}; - - -/** - * optional string invoice_id = 1; - * @return {string} - */ -proto.usage.v1.FinalizeInvoiceRequest.prototype.getInvoiceId = function() { - return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); -}; - - -/** - * @param {string} value - * @return {!proto.usage.v1.FinalizeInvoiceRequest} returns this - */ -proto.usage.v1.FinalizeInvoiceRequest.prototype.setInvoiceId = function(value) { - return jspb.Message.setProto3StringField(this, 1, value); -}; - - - - - -if (jspb.Message.GENERATE_TO_OBJECT) { -/** - * Creates an object representation of this proto. - * Field names that are reserved in JavaScript and will be renamed to pb_name. - * Optional fields that are not set will be set to undefined. - * To access a reserved field use, foo.pb_, eg, foo.pb_default. - * For the list of reserved names please see: - * net/proto2/compiler/js/internal/generator.cc#kKeyword. - * @param {boolean=} opt_includeInstance Deprecated. whether to include the - * JSPB instance for transitional soy proto support: - * http://goto/soy-param-migration - * @return {!Object} - */ -proto.usage.v1.FinalizeInvoiceResponse.prototype.toObject = function(opt_includeInstance) { - return proto.usage.v1.FinalizeInvoiceResponse.toObject(opt_includeInstance, this); -}; - - -/** - * Static version of the {@see toObject} method. - * @param {boolean|undefined} includeInstance Deprecated. Whether to include - * the JSPB instance for transitional soy proto support: - * http://goto/soy-param-migration - * @param {!proto.usage.v1.FinalizeInvoiceResponse} msg The msg instance to transform. - * @return {!Object} - * @suppress {unusedLocalVariables} f is only used for nested messages - */ -proto.usage.v1.FinalizeInvoiceResponse.toObject = function(includeInstance, msg) { - var f, obj = { - - }; - - if (includeInstance) { - obj.$jspbMessageInstance = msg; - } - return obj; -}; -} - - -/** - * Deserializes binary data (in protobuf wire format). - * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.usage.v1.FinalizeInvoiceResponse} - */ -proto.usage.v1.FinalizeInvoiceResponse.deserializeBinary = function(bytes) { - var reader = new jspb.BinaryReader(bytes); - var msg = new proto.usage.v1.FinalizeInvoiceResponse; - return proto.usage.v1.FinalizeInvoiceResponse.deserializeBinaryFromReader(msg, reader); -}; - - -/** - * Deserializes binary data (in protobuf wire format) from the - * given reader into the given message object. - * @param {!proto.usage.v1.FinalizeInvoiceResponse} msg The message object to deserialize into. - * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.usage.v1.FinalizeInvoiceResponse} - */ -proto.usage.v1.FinalizeInvoiceResponse.deserializeBinaryFromReader = function(msg, reader) { - while (reader.nextField()) { - if (reader.isEndGroup()) { - break; - } - var field = reader.getFieldNumber(); - switch (field) { - default: - reader.skipField(); - break; - } - } - return msg; -}; - - -/** - * Serializes the message to binary data (in protobuf wire format). - * @return {!Uint8Array} - */ -proto.usage.v1.FinalizeInvoiceResponse.prototype.serializeBinary = function() { - var writer = new jspb.BinaryWriter(); - proto.usage.v1.FinalizeInvoiceResponse.serializeBinaryToWriter(this, writer); - return writer.getResultBuffer(); -}; - - -/** - * Serializes the given message to binary data (in protobuf wire - * format), writing to the given BinaryWriter. - * @param {!proto.usage.v1.FinalizeInvoiceResponse} message - * @param {!jspb.BinaryWriter} writer - * @suppress {unusedLocalVariables} f is only used for nested messages - */ -proto.usage.v1.FinalizeInvoiceResponse.serializeBinaryToWriter = function(message, writer) { - var f = undefined; -}; - - - - - -if (jspb.Message.GENERATE_TO_OBJECT) { -/** - * Creates an object representation of this proto. - * Field names that are reserved in JavaScript and will be renamed to pb_name. - * Optional fields that are not set will be set to undefined. - * To access a reserved field use, foo.pb_, eg, foo.pb_default. - * For the list of reserved names please see: - * net/proto2/compiler/js/internal/generator.cc#kKeyword. - * @param {boolean=} opt_includeInstance Deprecated. whether to include the - * JSPB instance for transitional soy proto support: - * http://goto/soy-param-migration - * @return {!Object} - */ -proto.usage.v1.SetBilledSessionRequest.prototype.toObject = function(opt_includeInstance) { - return proto.usage.v1.SetBilledSessionRequest.toObject(opt_includeInstance, this); -}; - - -/** - * Static version of the {@see toObject} method. - * @param {boolean|undefined} includeInstance Deprecated. Whether to include - * the JSPB instance for transitional soy proto support: - * http://goto/soy-param-migration - * @param {!proto.usage.v1.SetBilledSessionRequest} msg The msg instance to transform. - * @return {!Object} - * @suppress {unusedLocalVariables} f is only used for nested messages - */ -proto.usage.v1.SetBilledSessionRequest.toObject = function(includeInstance, msg) { - var f, obj = { - instanceId: jspb.Message.getFieldWithDefault(msg, 1, ""), - from: (f = msg.getFrom()) && google_protobuf_timestamp_pb.Timestamp.toObject(includeInstance, f), - system: jspb.Message.getFieldWithDefault(msg, 3, 0) - }; - - if (includeInstance) { - obj.$jspbMessageInstance = msg; - } - return obj; -}; -} - - -/** - * Deserializes binary data (in protobuf wire format). - * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.usage.v1.SetBilledSessionRequest} - */ -proto.usage.v1.SetBilledSessionRequest.deserializeBinary = function(bytes) { - var reader = new jspb.BinaryReader(bytes); - var msg = new proto.usage.v1.SetBilledSessionRequest; - return proto.usage.v1.SetBilledSessionRequest.deserializeBinaryFromReader(msg, reader); -}; - - -/** - * Deserializes binary data (in protobuf wire format) from the - * given reader into the given message object. - * @param {!proto.usage.v1.SetBilledSessionRequest} msg The message object to deserialize into. - * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.usage.v1.SetBilledSessionRequest} - */ -proto.usage.v1.SetBilledSessionRequest.deserializeBinaryFromReader = function(msg, reader) { - while (reader.nextField()) { - if (reader.isEndGroup()) { - break; - } - var field = reader.getFieldNumber(); - switch (field) { - case 1: - var value = /** @type {string} */ (reader.readString()); - msg.setInstanceId(value); - break; - case 2: - var value = new google_protobuf_timestamp_pb.Timestamp; - reader.readMessage(value,google_protobuf_timestamp_pb.Timestamp.deserializeBinaryFromReader); - msg.setFrom(value); - break; - case 3: - var value = /** @type {!proto.usage.v1.System} */ (reader.readEnum()); - msg.setSystem(value); - break; - default: - reader.skipField(); - break; - } - } - return msg; -}; - - -/** - * Serializes the message to binary data (in protobuf wire format). - * @return {!Uint8Array} - */ -proto.usage.v1.SetBilledSessionRequest.prototype.serializeBinary = function() { - var writer = new jspb.BinaryWriter(); - proto.usage.v1.SetBilledSessionRequest.serializeBinaryToWriter(this, writer); - return writer.getResultBuffer(); -}; - - -/** - * Serializes the given message to binary data (in protobuf wire - * format), writing to the given BinaryWriter. - * @param {!proto.usage.v1.SetBilledSessionRequest} message - * @param {!jspb.BinaryWriter} writer - * @suppress {unusedLocalVariables} f is only used for nested messages - */ -proto.usage.v1.SetBilledSessionRequest.serializeBinaryToWriter = function(message, writer) { - var f = undefined; - f = message.getInstanceId(); - if (f.length > 0) { - writer.writeString( - 1, - f - ); - } - f = message.getFrom(); - if (f != null) { - writer.writeMessage( - 2, - f, - google_protobuf_timestamp_pb.Timestamp.serializeBinaryToWriter - ); - } - f = message.getSystem(); - if (f !== 0.0) { - writer.writeEnum( - 3, - f - ); - } -}; - - -/** - * optional string instance_id = 1; - * @return {string} - */ -proto.usage.v1.SetBilledSessionRequest.prototype.getInstanceId = function() { - return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); -}; - - -/** - * @param {string} value - * @return {!proto.usage.v1.SetBilledSessionRequest} returns this - */ -proto.usage.v1.SetBilledSessionRequest.prototype.setInstanceId = function(value) { - return jspb.Message.setProto3StringField(this, 1, value); -}; - - -/** - * optional google.protobuf.Timestamp from = 2; - * @return {?proto.google.protobuf.Timestamp} - */ -proto.usage.v1.SetBilledSessionRequest.prototype.getFrom = function() { - return /** @type{?proto.google.protobuf.Timestamp} */ ( - jspb.Message.getWrapperField(this, google_protobuf_timestamp_pb.Timestamp, 2)); -}; - - -/** - * @param {?proto.google.protobuf.Timestamp|undefined} value - * @return {!proto.usage.v1.SetBilledSessionRequest} returns this -*/ -proto.usage.v1.SetBilledSessionRequest.prototype.setFrom = function(value) { - return jspb.Message.setWrapperField(this, 2, value); -}; - - -/** - * Clears the message field making it undefined. - * @return {!proto.usage.v1.SetBilledSessionRequest} returns this - */ -proto.usage.v1.SetBilledSessionRequest.prototype.clearFrom = function() { - return this.setFrom(undefined); -}; - - -/** - * Returns whether this field is set. - * @return {boolean} - */ -proto.usage.v1.SetBilledSessionRequest.prototype.hasFrom = function() { - return jspb.Message.getField(this, 2) != null; -}; - - -/** - * optional System system = 3; - * @return {!proto.usage.v1.System} - */ -proto.usage.v1.SetBilledSessionRequest.prototype.getSystem = function() { - return /** @type {!proto.usage.v1.System} */ (jspb.Message.getFieldWithDefault(this, 3, 0)); -}; - - -/** - * @param {!proto.usage.v1.System} value - * @return {!proto.usage.v1.SetBilledSessionRequest} returns this - */ -proto.usage.v1.SetBilledSessionRequest.prototype.setSystem = function(value) { - return jspb.Message.setProto3EnumField(this, 3, value); -}; - - - - - -if (jspb.Message.GENERATE_TO_OBJECT) { -/** - * Creates an object representation of this proto. - * Field names that are reserved in JavaScript and will be renamed to pb_name. - * Optional fields that are not set will be set to undefined. - * To access a reserved field use, foo.pb_, eg, foo.pb_default. - * For the list of reserved names please see: - * net/proto2/compiler/js/internal/generator.cc#kKeyword. - * @param {boolean=} opt_includeInstance Deprecated. whether to include the - * JSPB instance for transitional soy proto support: - * http://goto/soy-param-migration - * @return {!Object} - */ -proto.usage.v1.SetBilledSessionResponse.prototype.toObject = function(opt_includeInstance) { - return proto.usage.v1.SetBilledSessionResponse.toObject(opt_includeInstance, this); -}; - - -/** - * Static version of the {@see toObject} method. - * @param {boolean|undefined} includeInstance Deprecated. Whether to include - * the JSPB instance for transitional soy proto support: - * http://goto/soy-param-migration - * @param {!proto.usage.v1.SetBilledSessionResponse} msg The msg instance to transform. - * @return {!Object} - * @suppress {unusedLocalVariables} f is only used for nested messages - */ -proto.usage.v1.SetBilledSessionResponse.toObject = function(includeInstance, msg) { - var f, obj = { - - }; - - if (includeInstance) { - obj.$jspbMessageInstance = msg; - } - return obj; -}; -} - - -/** - * Deserializes binary data (in protobuf wire format). - * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.usage.v1.SetBilledSessionResponse} - */ -proto.usage.v1.SetBilledSessionResponse.deserializeBinary = function(bytes) { - var reader = new jspb.BinaryReader(bytes); - var msg = new proto.usage.v1.SetBilledSessionResponse; - return proto.usage.v1.SetBilledSessionResponse.deserializeBinaryFromReader(msg, reader); -}; - - -/** - * Deserializes binary data (in protobuf wire format) from the - * given reader into the given message object. - * @param {!proto.usage.v1.SetBilledSessionResponse} msg The message object to deserialize into. - * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.usage.v1.SetBilledSessionResponse} - */ -proto.usage.v1.SetBilledSessionResponse.deserializeBinaryFromReader = function(msg, reader) { - while (reader.nextField()) { - if (reader.isEndGroup()) { - break; - } - var field = reader.getFieldNumber(); - switch (field) { - default: - reader.skipField(); - break; - } - } - return msg; -}; - - -/** - * Serializes the message to binary data (in protobuf wire format). - * @return {!Uint8Array} - */ -proto.usage.v1.SetBilledSessionResponse.prototype.serializeBinary = function() { - var writer = new jspb.BinaryWriter(); - proto.usage.v1.SetBilledSessionResponse.serializeBinaryToWriter(this, writer); - return writer.getResultBuffer(); -}; - - -/** - * Serializes the given message to binary data (in protobuf wire - * format), writing to the given BinaryWriter. - * @param {!proto.usage.v1.SetBilledSessionResponse} message - * @param {!jspb.BinaryWriter} writer - * @suppress {unusedLocalVariables} f is only used for nested messages - */ -proto.usage.v1.SetBilledSessionResponse.serializeBinaryToWriter = function(message, writer) { - var f = undefined; -}; - - -/** - * @enum {number} - */ -proto.usage.v1.System = { - SYSTEM_UNKNOWN: 0, - SYSTEM_CHARGEBEE: 1, - SYSTEM_STRIPE: 2 -}; - -goog.object.extend(exports, proto.usage.v1); diff --git a/components/usage-api/typescript/src/usage/v1/sugar.ts b/components/usage-api/typescript/src/usage/v1/sugar.ts deleted file mode 100644 index 4392a9740f2bed..00000000000000 --- a/components/usage-api/typescript/src/usage/v1/sugar.ts +++ /dev/null @@ -1,318 +0,0 @@ -/** - * Copyright (c) 2022 Gitpod GmbH. All rights reserved. - * Licensed under the GNU Affero General Public License (AGPL). - * See License-AGPL.txt in the project root for license information. - */ - -import { UsageServiceClient } from "./usage_grpc_pb"; -import { BillingServiceClient } from "./billing_grpc_pb"; -import { TraceContext } from "@gitpod/gitpod-protocol/lib/util/tracing"; -import * as opentracing from "opentracing"; -import { Metadata } from "@grpc/grpc-js"; -import { - CostCenter as ProtocolCostCenter, - GetCostCenterRequest, - GetCostCenterResponse, - ListUsageRequest, - ListUsageResponse, - SetCostCenterRequest, - SetCostCenterResponse, -} from "./usage_pb"; -import { - GetUpcomingInvoiceRequest, - GetUpcomingInvoiceResponse, - SetBilledSessionRequest, - SetBilledSessionResponse, - System, -} from "./billing_pb"; -import { injectable, inject, optional } from "inversify"; -import { createClientCallMetricsInterceptor, IClientCallMetrics } from "@gitpod/gitpod-protocol/lib/util/grpc"; -import * as grpc from "@grpc/grpc-js"; -import { Timestamp } from "google-protobuf/google/protobuf/timestamp_pb"; -import { AttributionId } from "@gitpod/gitpod-protocol/lib/attribution"; -import { CostCenter, BillingStrategy } from "@gitpod/gitpod-protocol"; - -export const UsageServiceClientProvider = Symbol("UsageServiceClientProvider"); -export const BillingServiceClientProvider = Symbol("BillingServiceClientProvider"); - -// UsageServiceClientProvider caches connections to UsageService -export interface UsageServiceClientProvider { - getDefault(): PromisifiedUsageServiceClient; -} -export interface BillingServiceClientProvider { - getDefault(): PromisifiedBillingServiceClient; -} - -function withTracing(ctx: TraceContext): Metadata { - const metadata = new Metadata(); - if (ctx.span) { - const carrier: { [key: string]: string } = {}; - opentracing.globalTracer().inject(ctx.span, opentracing.FORMAT_HTTP_HEADERS, carrier); - Object.keys(carrier) - .filter((p) => carrier.hasOwnProperty(p)) - .forEach((p) => metadata.set(p, carrier[p])); - } - return metadata; -} - -export const UsageServiceClientConfig = Symbol("UsageServiceClientConfig"); -export const BillingServiceClientConfig = Symbol("BillingServiceClientConfig"); - -export const UsageServiceClientCallMetrics = Symbol("UsageServiceClientCallMetrics"); -export const BillingServiceClientCallMetrics = Symbol("BillingServiceClientCallMetrics"); - -// UsageServiceClientConfig configures the access to the UsageService -export interface UsageServiceClientConfig { - address: string; -} - -export interface BillingServiceClientConfig { - address: string; -} - -@injectable() -export class CachingUsageServiceClientProvider implements UsageServiceClientProvider { - @inject(UsageServiceClientConfig) protected readonly clientConfig: UsageServiceClientConfig; - - @inject(UsageServiceClientCallMetrics) - @optional() - protected readonly clientCallMetrics: IClientCallMetrics; - - // gRPC connections can be used concurrently, even across services. - // Thus it makes sense to cache them rather than create a new connection for each request. - protected connectionCache: PromisifiedUsageServiceClient | undefined; - - getDefault() { - let interceptors: grpc.Interceptor[] = []; - if (this.clientCallMetrics) { - interceptors = [createClientCallMetricsInterceptor(this.clientCallMetrics)]; - } - - const createClient = () => { - return new PromisifiedUsageServiceClient( - new UsageServiceClient(this.clientConfig.address, grpc.credentials.createInsecure()), - interceptors, - ); - }; - let connection = this.connectionCache; - if (!connection) { - connection = createClient(); - } else if (!connection.isConnectionAlive()) { - connection.dispose(); - - connection = createClient(); - } - - this.connectionCache = connection; - return connection; - } -} - -@injectable() -export class CachingBillingServiceClientProvider implements BillingServiceClientProvider { - @inject(BillingServiceClientConfig) protected readonly billingClientConfig: BillingServiceClientConfig; - - @inject(BillingServiceClientCallMetrics) - @optional() - protected readonly billingClientCallMetrics: IClientCallMetrics; - - protected connectionCache: PromisifiedBillingServiceClient | undefined; - - getDefault() { - let interceptors: grpc.Interceptor[] = []; - if (this.billingClientCallMetrics) { - interceptors = [createClientCallMetricsInterceptor(this.billingClientCallMetrics)]; - } - - const createClient = () => { - return new PromisifiedBillingServiceClient( - new BillingServiceClient(this.billingClientConfig.address, grpc.credentials.createInsecure()), - interceptors, - ); - }; - let connection = this.connectionCache; - if (!connection) { - connection = createClient(); - } else if (!connection.isConnectionAlive()) { - connection.dispose(); - - connection = createClient(); - } - - this.connectionCache = connection; - return connection; - } -} - -export class PromisifiedUsageServiceClient { - constructor(public readonly client: UsageServiceClient, protected readonly interceptor: grpc.Interceptor[]) {} - - public isConnectionAlive() { - const cs = this.client.getChannel().getConnectivityState(false); - return ( - cs == grpc.connectivityState.CONNECTING || - cs == grpc.connectivityState.IDLE || - cs == grpc.connectivityState.READY - ); - } - - public async listUsage(_ctx: TraceContext, request: ListUsageRequest): Promise { - const ctx = TraceContext.childContext(`/usage-service/listUsage`, _ctx); - try { - const response = await new Promise((resolve, reject) => { - this.client.listUsage( - request, - withTracing(ctx), - (err: grpc.ServiceError | null, response: ListUsageResponse) => { - if (err) { - reject(err); - return; - } - resolve(response); - }, - ); - }); - return response; - } catch (err) { - TraceContext.setError(ctx, err); - throw err; - } finally { - ctx.span.finish(); - } - } - - public async getCostCenter(attributionID: AttributionId): Promise { - const request = new GetCostCenterRequest(); - request.setAttributionId(AttributionId.render(attributionID)); - - const response = await new Promise((resolve, reject) => { - this.client.getCostCenter(request, (err: grpc.ServiceError | null, response: GetCostCenterResponse) => { - if (err) { - reject(err); - return; - } - resolve(response); - }); - }); - if (!response.hasCostCenter()) { - return undefined; - } - - const attrId = AttributionId.parse(response.getCostCenter()!.getAttributionId()); - if (!attrId) { - return undefined; - } - - let billingStrategy: BillingStrategy = "other"; - if ( - response.getCostCenter()!.getBillingStrategy() === - ProtocolCostCenter.BillingStrategy.BILLING_STRATEGY_STRIPE - ) { - billingStrategy = "stripe"; - } - - return { - id: attrId, - spendingLimit: response.getCostCenter()!.getSpendingLimit(), - billingStrategy: billingStrategy, - }; - } - - public async setCostCenter(costCenter: CostCenter): Promise { - const request = new SetCostCenterRequest(); - const cc = new ProtocolCostCenter(); - cc.setAttributionId(AttributionId.render(costCenter.id)); - let billingStrategy = ProtocolCostCenter.BillingStrategy.BILLING_STRATEGY_OTHER; - if (costCenter.billingStrategy == "stripe") { - billingStrategy = ProtocolCostCenter.BillingStrategy.BILLING_STRATEGY_STRIPE; - } - cc.setBillingStrategy(billingStrategy); - cc.setSpendingLimit(costCenter.spendingLimit); - request.setCostCenter(cc); - - await new Promise((resolve, reject) => { - this.client.setCostCenter(request, (err: grpc.ServiceError | null, response: SetCostCenterResponse) => { - if (err) { - reject(err); - return; - } - resolve(response); - }); - }); - } - - public dispose() { - this.client.close(); - } - - protected getDefaultUnaryOptions(): Partial { - return { - interceptors: this.interceptor, - }; - } -} - -export class PromisifiedBillingServiceClient { - constructor(public readonly client: BillingServiceClient, protected readonly interceptor: grpc.Interceptor[]) {} - - public isConnectionAlive() { - const cs = this.client.getChannel().getConnectivityState(false); - return ( - cs == grpc.connectivityState.CONNECTING || - cs == grpc.connectivityState.IDLE || - cs == grpc.connectivityState.READY - ); - } - - public async setBilledSession(instanceId: string, instanceCreationTime: Timestamp, system: System) { - const req = new SetBilledSessionRequest(); - req.setInstanceId(instanceId); - req.setFrom(instanceCreationTime); - req.setSystem(system); - - const response = await new Promise((resolve, reject) => { - this.client.setBilledSession(req, (err: grpc.ServiceError | null, response: SetBilledSessionResponse) => { - if (err) { - reject(err); - return; - } - resolve(response); - }); - }); - return response; - } - - public dispose() { - this.client.close(); - } - - protected getDefaultUnaryOptions(): Partial { - return { - interceptors: this.interceptor, - }; - } - - public async getUpcomingInvoice(attributionId: AttributionId) { - const req = new GetUpcomingInvoiceRequest(); - if (attributionId.kind === "team") { - req.setTeamId(attributionId.teamId); - } - if (attributionId.kind === "user") { - req.setUserId(attributionId.userId); - } - - const response = await new Promise((resolve, reject) => { - this.client.getUpcomingInvoice( - req, - (err: grpc.ServiceError | null, response: GetUpcomingInvoiceResponse) => { - if (err) { - reject(err); - return; - } - resolve(response); - }, - ); - }); - return response; - } -} diff --git a/components/usage-api/typescript/src/usage/v1/usage.pb.ts b/components/usage-api/typescript/src/usage/v1/usage.pb.ts new file mode 100644 index 00000000000000..bda22b0d0643e8 --- /dev/null +++ b/components/usage-api/typescript/src/usage/v1/usage.pb.ts @@ -0,0 +1,1190 @@ +/** + * Copyright (c) 2022 Gitpod GmbH. All rights reserved. + * Licensed under the GNU Affero General Public License (AGPL). + * See License-AGPL.txt in the project root for license information. + */ + +/* eslint-disable */ +import * as Long from "long"; +import { CallContext, CallOptions } from "nice-grpc-common"; +import * as _m0 from "protobufjs/minimal"; +import { Timestamp } from "../../google/protobuf/timestamp.pb"; + +export const protobufPackage = "usage.v1"; + +export interface ReconcileUsageWithLedgerRequest { + /** from specifies the starting time range for this request. */ + from: + | Date + | undefined; + /** to specifies the end time range for this request. */ + to: Date | undefined; +} + +export interface ReconcileUsageWithLedgerResponse { +} + +export interface PaginatedRequest { + perPage: number; + page: number; +} + +export interface PaginatedResponse { + perPage: number; + totalPages: number; + total: number; + page: number; +} + +export interface ListUsageRequest { + attributionId: string; + /** + * from specifies the starting time range for this request. + * All instances which existed starting at from will be returned. + */ + from: + | Date + | undefined; + /** + * to specifies the end time range for this request. + * All instances which existed ending at to will be returned. + */ + to: Date | undefined; + order: ListUsageRequest_Ordering; + pagination: PaginatedRequest | undefined; +} + +export enum ListUsageRequest_Ordering { + ORDERING_DESCENDING = "ORDERING_DESCENDING", + ORDERING_ASCENDING = "ORDERING_ASCENDING", + UNRECOGNIZED = "UNRECOGNIZED", +} + +export function listUsageRequest_OrderingFromJSON(object: any): ListUsageRequest_Ordering { + switch (object) { + case 0: + case "ORDERING_DESCENDING": + return ListUsageRequest_Ordering.ORDERING_DESCENDING; + case 1: + case "ORDERING_ASCENDING": + return ListUsageRequest_Ordering.ORDERING_ASCENDING; + case -1: + case "UNRECOGNIZED": + default: + return ListUsageRequest_Ordering.UNRECOGNIZED; + } +} + +export function listUsageRequest_OrderingToJSON(object: ListUsageRequest_Ordering): string { + switch (object) { + case ListUsageRequest_Ordering.ORDERING_DESCENDING: + return "ORDERING_DESCENDING"; + case ListUsageRequest_Ordering.ORDERING_ASCENDING: + return "ORDERING_ASCENDING"; + case ListUsageRequest_Ordering.UNRECOGNIZED: + default: + return "UNRECOGNIZED"; + } +} + +export function listUsageRequest_OrderingToNumber(object: ListUsageRequest_Ordering): number { + switch (object) { + case ListUsageRequest_Ordering.ORDERING_DESCENDING: + return 0; + case ListUsageRequest_Ordering.ORDERING_ASCENDING: + return 1; + case ListUsageRequest_Ordering.UNRECOGNIZED: + default: + return -1; + } +} + +export interface ListUsageResponse { + usageEntries: Usage[]; + pagination: + | PaginatedResponse + | undefined; + /** the amount of credits the given account (attributionId) had at the beginning of the requested period */ + creditBalanceAtStart: number; + /** the amount of credits the given account (attributionId) had at the end of the requested period */ + creditBalanceAtEnd: number; +} + +export interface Usage { + id: string; + attributionId: string; + description: string; + credits: number; + effectiveTime: Date | undefined; + kind: Usage_Kind; + workspaceInstanceId: string; + draft: boolean; + metadata: string; +} + +export enum Usage_Kind { + KIND_WORKSPACE_INSTANCE = "KIND_WORKSPACE_INSTANCE", + KIND_INVOICE = "KIND_INVOICE", + UNRECOGNIZED = "UNRECOGNIZED", +} + +export function usage_KindFromJSON(object: any): Usage_Kind { + switch (object) { + case 0: + case "KIND_WORKSPACE_INSTANCE": + return Usage_Kind.KIND_WORKSPACE_INSTANCE; + case 1: + case "KIND_INVOICE": + return Usage_Kind.KIND_INVOICE; + case -1: + case "UNRECOGNIZED": + default: + return Usage_Kind.UNRECOGNIZED; + } +} + +export function usage_KindToJSON(object: Usage_Kind): string { + switch (object) { + case Usage_Kind.KIND_WORKSPACE_INSTANCE: + return "KIND_WORKSPACE_INSTANCE"; + case Usage_Kind.KIND_INVOICE: + return "KIND_INVOICE"; + case Usage_Kind.UNRECOGNIZED: + default: + return "UNRECOGNIZED"; + } +} + +export function usage_KindToNumber(object: Usage_Kind): number { + switch (object) { + case Usage_Kind.KIND_WORKSPACE_INSTANCE: + return 0; + case Usage_Kind.KIND_INVOICE: + return 1; + case Usage_Kind.UNRECOGNIZED: + default: + return -1; + } +} + +export interface SetCostCenterRequest { + costCenter: CostCenter | undefined; +} + +export interface SetCostCenterResponse { +} + +export interface GetCostCenterRequest { + attributionId: string; +} + +export interface GetCostCenterResponse { + costCenter: CostCenter | undefined; +} + +export interface CostCenter { + attributionId: string; + spendingLimit: number; + billingStrategy: CostCenter_BillingStrategy; +} + +export enum CostCenter_BillingStrategy { + BILLING_STRATEGY_STRIPE = "BILLING_STRATEGY_STRIPE", + BILLING_STRATEGY_OTHER = "BILLING_STRATEGY_OTHER", + UNRECOGNIZED = "UNRECOGNIZED", +} + +export function costCenter_BillingStrategyFromJSON(object: any): CostCenter_BillingStrategy { + switch (object) { + case 0: + case "BILLING_STRATEGY_STRIPE": + return CostCenter_BillingStrategy.BILLING_STRATEGY_STRIPE; + case 1: + case "BILLING_STRATEGY_OTHER": + return CostCenter_BillingStrategy.BILLING_STRATEGY_OTHER; + case -1: + case "UNRECOGNIZED": + default: + return CostCenter_BillingStrategy.UNRECOGNIZED; + } +} + +export function costCenter_BillingStrategyToJSON(object: CostCenter_BillingStrategy): string { + switch (object) { + case CostCenter_BillingStrategy.BILLING_STRATEGY_STRIPE: + return "BILLING_STRATEGY_STRIPE"; + case CostCenter_BillingStrategy.BILLING_STRATEGY_OTHER: + return "BILLING_STRATEGY_OTHER"; + case CostCenter_BillingStrategy.UNRECOGNIZED: + default: + return "UNRECOGNIZED"; + } +} + +export function costCenter_BillingStrategyToNumber(object: CostCenter_BillingStrategy): number { + switch (object) { + case CostCenter_BillingStrategy.BILLING_STRATEGY_STRIPE: + return 0; + case CostCenter_BillingStrategy.BILLING_STRATEGY_OTHER: + return 1; + case CostCenter_BillingStrategy.UNRECOGNIZED: + default: + return -1; + } +} + +function createBaseReconcileUsageWithLedgerRequest(): ReconcileUsageWithLedgerRequest { + return { from: undefined, to: undefined }; +} + +export const ReconcileUsageWithLedgerRequest = { + encode(message: ReconcileUsageWithLedgerRequest, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.from !== undefined) { + Timestamp.encode(toTimestamp(message.from), writer.uint32(10).fork()).ldelim(); + } + if (message.to !== undefined) { + Timestamp.encode(toTimestamp(message.to), writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): ReconcileUsageWithLedgerRequest { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseReconcileUsageWithLedgerRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.from = fromTimestamp(Timestamp.decode(reader, reader.uint32())); + break; + case 2: + message.to = fromTimestamp(Timestamp.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): ReconcileUsageWithLedgerRequest { + return { + from: isSet(object.from) ? fromJsonTimestamp(object.from) : undefined, + to: isSet(object.to) ? fromJsonTimestamp(object.to) : undefined, + }; + }, + + toJSON(message: ReconcileUsageWithLedgerRequest): unknown { + const obj: any = {}; + message.from !== undefined && (obj.from = message.from.toISOString()); + message.to !== undefined && (obj.to = message.to.toISOString()); + return obj; + }, + + fromPartial(object: DeepPartial): ReconcileUsageWithLedgerRequest { + const message = createBaseReconcileUsageWithLedgerRequest(); + message.from = object.from ?? undefined; + message.to = object.to ?? undefined; + return message; + }, +}; + +function createBaseReconcileUsageWithLedgerResponse(): ReconcileUsageWithLedgerResponse { + return {}; +} + +export const ReconcileUsageWithLedgerResponse = { + encode(_: ReconcileUsageWithLedgerResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): ReconcileUsageWithLedgerResponse { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseReconcileUsageWithLedgerResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(_: any): ReconcileUsageWithLedgerResponse { + return {}; + }, + + toJSON(_: ReconcileUsageWithLedgerResponse): unknown { + const obj: any = {}; + return obj; + }, + + fromPartial(_: DeepPartial): ReconcileUsageWithLedgerResponse { + const message = createBaseReconcileUsageWithLedgerResponse(); + return message; + }, +}; + +function createBasePaginatedRequest(): PaginatedRequest { + return { perPage: 0, page: 0 }; +} + +export const PaginatedRequest = { + encode(message: PaginatedRequest, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.perPage !== 0) { + writer.uint32(8).int64(message.perPage); + } + if (message.page !== 0) { + writer.uint32(16).int64(message.page); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): PaginatedRequest { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBasePaginatedRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.perPage = longToNumber(reader.int64() as Long); + break; + case 2: + message.page = longToNumber(reader.int64() as Long); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): PaginatedRequest { + return { + perPage: isSet(object.perPage) ? Number(object.perPage) : 0, + page: isSet(object.page) ? Number(object.page) : 0, + }; + }, + + toJSON(message: PaginatedRequest): unknown { + const obj: any = {}; + message.perPage !== undefined && (obj.perPage = Math.round(message.perPage)); + message.page !== undefined && (obj.page = Math.round(message.page)); + return obj; + }, + + fromPartial(object: DeepPartial): PaginatedRequest { + const message = createBasePaginatedRequest(); + message.perPage = object.perPage ?? 0; + message.page = object.page ?? 0; + return message; + }, +}; + +function createBasePaginatedResponse(): PaginatedResponse { + return { perPage: 0, totalPages: 0, total: 0, page: 0 }; +} + +export const PaginatedResponse = { + encode(message: PaginatedResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.perPage !== 0) { + writer.uint32(16).int64(message.perPage); + } + if (message.totalPages !== 0) { + writer.uint32(24).int64(message.totalPages); + } + if (message.total !== 0) { + writer.uint32(32).int64(message.total); + } + if (message.page !== 0) { + writer.uint32(40).int64(message.page); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): PaginatedResponse { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBasePaginatedResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 2: + message.perPage = longToNumber(reader.int64() as Long); + break; + case 3: + message.totalPages = longToNumber(reader.int64() as Long); + break; + case 4: + message.total = longToNumber(reader.int64() as Long); + break; + case 5: + message.page = longToNumber(reader.int64() as Long); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): PaginatedResponse { + return { + perPage: isSet(object.perPage) ? Number(object.perPage) : 0, + totalPages: isSet(object.totalPages) ? Number(object.totalPages) : 0, + total: isSet(object.total) ? Number(object.total) : 0, + page: isSet(object.page) ? Number(object.page) : 0, + }; + }, + + toJSON(message: PaginatedResponse): unknown { + const obj: any = {}; + message.perPage !== undefined && (obj.perPage = Math.round(message.perPage)); + message.totalPages !== undefined && (obj.totalPages = Math.round(message.totalPages)); + message.total !== undefined && (obj.total = Math.round(message.total)); + message.page !== undefined && (obj.page = Math.round(message.page)); + return obj; + }, + + fromPartial(object: DeepPartial): PaginatedResponse { + const message = createBasePaginatedResponse(); + message.perPage = object.perPage ?? 0; + message.totalPages = object.totalPages ?? 0; + message.total = object.total ?? 0; + message.page = object.page ?? 0; + return message; + }, +}; + +function createBaseListUsageRequest(): ListUsageRequest { + return { + attributionId: "", + from: undefined, + to: undefined, + order: ListUsageRequest_Ordering.ORDERING_DESCENDING, + pagination: undefined, + }; +} + +export const ListUsageRequest = { + encode(message: ListUsageRequest, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.attributionId !== "") { + writer.uint32(10).string(message.attributionId); + } + if (message.from !== undefined) { + Timestamp.encode(toTimestamp(message.from), writer.uint32(18).fork()).ldelim(); + } + if (message.to !== undefined) { + Timestamp.encode(toTimestamp(message.to), writer.uint32(26).fork()).ldelim(); + } + if (message.order !== ListUsageRequest_Ordering.ORDERING_DESCENDING) { + writer.uint32(32).int32(listUsageRequest_OrderingToNumber(message.order)); + } + if (message.pagination !== undefined) { + PaginatedRequest.encode(message.pagination, writer.uint32(42).fork()).ldelim(); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): ListUsageRequest { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseListUsageRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.attributionId = reader.string(); + break; + case 2: + message.from = fromTimestamp(Timestamp.decode(reader, reader.uint32())); + break; + case 3: + message.to = fromTimestamp(Timestamp.decode(reader, reader.uint32())); + break; + case 4: + message.order = listUsageRequest_OrderingFromJSON(reader.int32()); + break; + case 5: + message.pagination = PaginatedRequest.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): ListUsageRequest { + return { + attributionId: isSet(object.attributionId) ? String(object.attributionId) : "", + from: isSet(object.from) ? fromJsonTimestamp(object.from) : undefined, + to: isSet(object.to) ? fromJsonTimestamp(object.to) : undefined, + order: isSet(object.order) + ? listUsageRequest_OrderingFromJSON(object.order) + : ListUsageRequest_Ordering.ORDERING_DESCENDING, + pagination: isSet(object.pagination) ? PaginatedRequest.fromJSON(object.pagination) : undefined, + }; + }, + + toJSON(message: ListUsageRequest): unknown { + const obj: any = {}; + message.attributionId !== undefined && (obj.attributionId = message.attributionId); + message.from !== undefined && (obj.from = message.from.toISOString()); + message.to !== undefined && (obj.to = message.to.toISOString()); + message.order !== undefined && (obj.order = listUsageRequest_OrderingToJSON(message.order)); + message.pagination !== undefined && + (obj.pagination = message.pagination ? PaginatedRequest.toJSON(message.pagination) : undefined); + return obj; + }, + + fromPartial(object: DeepPartial): ListUsageRequest { + const message = createBaseListUsageRequest(); + message.attributionId = object.attributionId ?? ""; + message.from = object.from ?? undefined; + message.to = object.to ?? undefined; + message.order = object.order ?? ListUsageRequest_Ordering.ORDERING_DESCENDING; + message.pagination = (object.pagination !== undefined && object.pagination !== null) + ? PaginatedRequest.fromPartial(object.pagination) + : undefined; + return message; + }, +}; + +function createBaseListUsageResponse(): ListUsageResponse { + return { usageEntries: [], pagination: undefined, creditBalanceAtStart: 0, creditBalanceAtEnd: 0 }; +} + +export const ListUsageResponse = { + encode(message: ListUsageResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + for (const v of message.usageEntries) { + Usage.encode(v!, writer.uint32(10).fork()).ldelim(); + } + if (message.pagination !== undefined) { + PaginatedResponse.encode(message.pagination, writer.uint32(18).fork()).ldelim(); + } + if (message.creditBalanceAtStart !== 0) { + writer.uint32(25).double(message.creditBalanceAtStart); + } + if (message.creditBalanceAtEnd !== 0) { + writer.uint32(33).double(message.creditBalanceAtEnd); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): ListUsageResponse { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseListUsageResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.usageEntries.push(Usage.decode(reader, reader.uint32())); + break; + case 2: + message.pagination = PaginatedResponse.decode(reader, reader.uint32()); + break; + case 3: + message.creditBalanceAtStart = reader.double(); + break; + case 4: + message.creditBalanceAtEnd = reader.double(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): ListUsageResponse { + return { + usageEntries: Array.isArray(object?.usageEntries) ? object.usageEntries.map((e: any) => Usage.fromJSON(e)) : [], + pagination: isSet(object.pagination) ? PaginatedResponse.fromJSON(object.pagination) : undefined, + creditBalanceAtStart: isSet(object.creditBalanceAtStart) ? Number(object.creditBalanceAtStart) : 0, + creditBalanceAtEnd: isSet(object.creditBalanceAtEnd) ? Number(object.creditBalanceAtEnd) : 0, + }; + }, + + toJSON(message: ListUsageResponse): unknown { + const obj: any = {}; + if (message.usageEntries) { + obj.usageEntries = message.usageEntries.map((e) => e ? Usage.toJSON(e) : undefined); + } else { + obj.usageEntries = []; + } + message.pagination !== undefined && + (obj.pagination = message.pagination ? PaginatedResponse.toJSON(message.pagination) : undefined); + message.creditBalanceAtStart !== undefined && (obj.creditBalanceAtStart = message.creditBalanceAtStart); + message.creditBalanceAtEnd !== undefined && (obj.creditBalanceAtEnd = message.creditBalanceAtEnd); + return obj; + }, + + fromPartial(object: DeepPartial): ListUsageResponse { + const message = createBaseListUsageResponse(); + message.usageEntries = object.usageEntries?.map((e) => Usage.fromPartial(e)) || []; + message.pagination = (object.pagination !== undefined && object.pagination !== null) + ? PaginatedResponse.fromPartial(object.pagination) + : undefined; + message.creditBalanceAtStart = object.creditBalanceAtStart ?? 0; + message.creditBalanceAtEnd = object.creditBalanceAtEnd ?? 0; + return message; + }, +}; + +function createBaseUsage(): Usage { + return { + id: "", + attributionId: "", + description: "", + credits: 0, + effectiveTime: undefined, + kind: Usage_Kind.KIND_WORKSPACE_INSTANCE, + workspaceInstanceId: "", + draft: false, + metadata: "", + }; +} + +export const Usage = { + encode(message: Usage, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.id !== "") { + writer.uint32(10).string(message.id); + } + if (message.attributionId !== "") { + writer.uint32(18).string(message.attributionId); + } + if (message.description !== "") { + writer.uint32(26).string(message.description); + } + if (message.credits !== 0) { + writer.uint32(33).double(message.credits); + } + if (message.effectiveTime !== undefined) { + Timestamp.encode(toTimestamp(message.effectiveTime), writer.uint32(42).fork()).ldelim(); + } + if (message.kind !== Usage_Kind.KIND_WORKSPACE_INSTANCE) { + writer.uint32(48).int32(usage_KindToNumber(message.kind)); + } + if (message.workspaceInstanceId !== "") { + writer.uint32(58).string(message.workspaceInstanceId); + } + if (message.draft === true) { + writer.uint32(64).bool(message.draft); + } + if (message.metadata !== "") { + writer.uint32(74).string(message.metadata); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): Usage { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseUsage(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.id = reader.string(); + break; + case 2: + message.attributionId = reader.string(); + break; + case 3: + message.description = reader.string(); + break; + case 4: + message.credits = reader.double(); + break; + case 5: + message.effectiveTime = fromTimestamp(Timestamp.decode(reader, reader.uint32())); + break; + case 6: + message.kind = usage_KindFromJSON(reader.int32()); + break; + case 7: + message.workspaceInstanceId = reader.string(); + break; + case 8: + message.draft = reader.bool(); + break; + case 9: + message.metadata = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): Usage { + return { + id: isSet(object.id) ? String(object.id) : "", + attributionId: isSet(object.attributionId) ? String(object.attributionId) : "", + description: isSet(object.description) ? String(object.description) : "", + credits: isSet(object.credits) ? Number(object.credits) : 0, + effectiveTime: isSet(object.effectiveTime) ? fromJsonTimestamp(object.effectiveTime) : undefined, + kind: isSet(object.kind) ? usage_KindFromJSON(object.kind) : Usage_Kind.KIND_WORKSPACE_INSTANCE, + workspaceInstanceId: isSet(object.workspaceInstanceId) ? String(object.workspaceInstanceId) : "", + draft: isSet(object.draft) ? Boolean(object.draft) : false, + metadata: isSet(object.metadata) ? String(object.metadata) : "", + }; + }, + + toJSON(message: Usage): unknown { + const obj: any = {}; + message.id !== undefined && (obj.id = message.id); + message.attributionId !== undefined && (obj.attributionId = message.attributionId); + message.description !== undefined && (obj.description = message.description); + message.credits !== undefined && (obj.credits = message.credits); + message.effectiveTime !== undefined && (obj.effectiveTime = message.effectiveTime.toISOString()); + message.kind !== undefined && (obj.kind = usage_KindToJSON(message.kind)); + message.workspaceInstanceId !== undefined && (obj.workspaceInstanceId = message.workspaceInstanceId); + message.draft !== undefined && (obj.draft = message.draft); + message.metadata !== undefined && (obj.metadata = message.metadata); + return obj; + }, + + fromPartial(object: DeepPartial): Usage { + const message = createBaseUsage(); + message.id = object.id ?? ""; + message.attributionId = object.attributionId ?? ""; + message.description = object.description ?? ""; + message.credits = object.credits ?? 0; + message.effectiveTime = object.effectiveTime ?? undefined; + message.kind = object.kind ?? Usage_Kind.KIND_WORKSPACE_INSTANCE; + message.workspaceInstanceId = object.workspaceInstanceId ?? ""; + message.draft = object.draft ?? false; + message.metadata = object.metadata ?? ""; + return message; + }, +}; + +function createBaseSetCostCenterRequest(): SetCostCenterRequest { + return { costCenter: undefined }; +} + +export const SetCostCenterRequest = { + encode(message: SetCostCenterRequest, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.costCenter !== undefined) { + CostCenter.encode(message.costCenter, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): SetCostCenterRequest { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseSetCostCenterRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.costCenter = CostCenter.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): SetCostCenterRequest { + return { costCenter: isSet(object.costCenter) ? CostCenter.fromJSON(object.costCenter) : undefined }; + }, + + toJSON(message: SetCostCenterRequest): unknown { + const obj: any = {}; + message.costCenter !== undefined && + (obj.costCenter = message.costCenter ? CostCenter.toJSON(message.costCenter) : undefined); + return obj; + }, + + fromPartial(object: DeepPartial): SetCostCenterRequest { + const message = createBaseSetCostCenterRequest(); + message.costCenter = (object.costCenter !== undefined && object.costCenter !== null) + ? CostCenter.fromPartial(object.costCenter) + : undefined; + return message; + }, +}; + +function createBaseSetCostCenterResponse(): SetCostCenterResponse { + return {}; +} + +export const SetCostCenterResponse = { + encode(_: SetCostCenterResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): SetCostCenterResponse { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseSetCostCenterResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(_: any): SetCostCenterResponse { + return {}; + }, + + toJSON(_: SetCostCenterResponse): unknown { + const obj: any = {}; + return obj; + }, + + fromPartial(_: DeepPartial): SetCostCenterResponse { + const message = createBaseSetCostCenterResponse(); + return message; + }, +}; + +function createBaseGetCostCenterRequest(): GetCostCenterRequest { + return { attributionId: "" }; +} + +export const GetCostCenterRequest = { + encode(message: GetCostCenterRequest, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.attributionId !== "") { + writer.uint32(10).string(message.attributionId); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): GetCostCenterRequest { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseGetCostCenterRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.attributionId = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): GetCostCenterRequest { + return { attributionId: isSet(object.attributionId) ? String(object.attributionId) : "" }; + }, + + toJSON(message: GetCostCenterRequest): unknown { + const obj: any = {}; + message.attributionId !== undefined && (obj.attributionId = message.attributionId); + return obj; + }, + + fromPartial(object: DeepPartial): GetCostCenterRequest { + const message = createBaseGetCostCenterRequest(); + message.attributionId = object.attributionId ?? ""; + return message; + }, +}; + +function createBaseGetCostCenterResponse(): GetCostCenterResponse { + return { costCenter: undefined }; +} + +export const GetCostCenterResponse = { + encode(message: GetCostCenterResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.costCenter !== undefined) { + CostCenter.encode(message.costCenter, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): GetCostCenterResponse { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseGetCostCenterResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.costCenter = CostCenter.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): GetCostCenterResponse { + return { costCenter: isSet(object.costCenter) ? CostCenter.fromJSON(object.costCenter) : undefined }; + }, + + toJSON(message: GetCostCenterResponse): unknown { + const obj: any = {}; + message.costCenter !== undefined && + (obj.costCenter = message.costCenter ? CostCenter.toJSON(message.costCenter) : undefined); + return obj; + }, + + fromPartial(object: DeepPartial): GetCostCenterResponse { + const message = createBaseGetCostCenterResponse(); + message.costCenter = (object.costCenter !== undefined && object.costCenter !== null) + ? CostCenter.fromPartial(object.costCenter) + : undefined; + return message; + }, +}; + +function createBaseCostCenter(): CostCenter { + return { attributionId: "", spendingLimit: 0, billingStrategy: CostCenter_BillingStrategy.BILLING_STRATEGY_STRIPE }; +} + +export const CostCenter = { + encode(message: CostCenter, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.attributionId !== "") { + writer.uint32(10).string(message.attributionId); + } + if (message.spendingLimit !== 0) { + writer.uint32(16).int32(message.spendingLimit); + } + if (message.billingStrategy !== CostCenter_BillingStrategy.BILLING_STRATEGY_STRIPE) { + writer.uint32(24).int32(costCenter_BillingStrategyToNumber(message.billingStrategy)); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): CostCenter { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseCostCenter(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.attributionId = reader.string(); + break; + case 2: + message.spendingLimit = reader.int32(); + break; + case 3: + message.billingStrategy = costCenter_BillingStrategyFromJSON(reader.int32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): CostCenter { + return { + attributionId: isSet(object.attributionId) ? String(object.attributionId) : "", + spendingLimit: isSet(object.spendingLimit) ? Number(object.spendingLimit) : 0, + billingStrategy: isSet(object.billingStrategy) + ? costCenter_BillingStrategyFromJSON(object.billingStrategy) + : CostCenter_BillingStrategy.BILLING_STRATEGY_STRIPE, + }; + }, + + toJSON(message: CostCenter): unknown { + const obj: any = {}; + message.attributionId !== undefined && (obj.attributionId = message.attributionId); + message.spendingLimit !== undefined && (obj.spendingLimit = Math.round(message.spendingLimit)); + message.billingStrategy !== undefined && + (obj.billingStrategy = costCenter_BillingStrategyToJSON(message.billingStrategy)); + return obj; + }, + + fromPartial(object: DeepPartial): CostCenter { + const message = createBaseCostCenter(); + message.attributionId = object.attributionId ?? ""; + message.spendingLimit = object.spendingLimit ?? 0; + message.billingStrategy = object.billingStrategy ?? CostCenter_BillingStrategy.BILLING_STRATEGY_STRIPE; + return message; + }, +}; + +export type UsageServiceDefinition = typeof UsageServiceDefinition; +export const UsageServiceDefinition = { + name: "UsageService", + fullName: "usage.v1.UsageService", + methods: { + /** GetCostCenter retrieves the active cost center for the given attributionID */ + getCostCenter: { + name: "GetCostCenter", + requestType: GetCostCenterRequest, + requestStream: false, + responseType: GetCostCenterResponse, + responseStream: false, + options: {}, + }, + /** SetCostCenter stores the given cost center */ + setCostCenter: { + name: "SetCostCenter", + requestType: SetCostCenterRequest, + requestStream: false, + responseType: SetCostCenterResponse, + responseStream: false, + options: {}, + }, + /** Triggers reconciliation of usage with ledger implementation. */ + reconcileUsageWithLedger: { + name: "ReconcileUsageWithLedger", + requestType: ReconcileUsageWithLedgerRequest, + requestStream: false, + responseType: ReconcileUsageWithLedgerResponse, + responseStream: false, + options: {}, + }, + /** ListUsage retrieves all usage for the specified attributionId and theb given time range */ + listUsage: { + name: "ListUsage", + requestType: ListUsageRequest, + requestStream: false, + responseType: ListUsageResponse, + responseStream: false, + options: {}, + }, + }, +} as const; + +export interface UsageServiceServiceImplementation { + /** GetCostCenter retrieves the active cost center for the given attributionID */ + getCostCenter( + request: GetCostCenterRequest, + context: CallContext & CallContextExt, + ): Promise>; + /** SetCostCenter stores the given cost center */ + setCostCenter( + request: SetCostCenterRequest, + context: CallContext & CallContextExt, + ): Promise>; + /** Triggers reconciliation of usage with ledger implementation. */ + reconcileUsageWithLedger( + request: ReconcileUsageWithLedgerRequest, + context: CallContext & CallContextExt, + ): Promise>; + /** ListUsage retrieves all usage for the specified attributionId and theb given time range */ + listUsage(request: ListUsageRequest, context: CallContext & CallContextExt): Promise>; +} + +export interface UsageServiceClient { + /** GetCostCenter retrieves the active cost center for the given attributionID */ + getCostCenter( + request: DeepPartial, + options?: CallOptions & CallOptionsExt, + ): Promise; + /** SetCostCenter stores the given cost center */ + setCostCenter( + request: DeepPartial, + options?: CallOptions & CallOptionsExt, + ): Promise; + /** Triggers reconciliation of usage with ledger implementation. */ + reconcileUsageWithLedger( + request: DeepPartial, + options?: CallOptions & CallOptionsExt, + ): Promise; + /** ListUsage retrieves all usage for the specified attributionId and theb given time range */ + listUsage(request: DeepPartial, options?: CallOptions & CallOptionsExt): Promise; +} + +export interface DataLoaderOptions { + cache?: boolean; +} + +export interface DataLoaders { + rpcDataLoaderOptions?: DataLoaderOptions; + getDataLoader(identifier: string, constructorFn: () => T): T; +} + +declare var self: any | undefined; +declare var window: any | undefined; +declare var global: any | undefined; +var globalThis: any = (() => { + if (typeof globalThis !== "undefined") { + return globalThis; + } + if (typeof self !== "undefined") { + return self; + } + if (typeof window !== "undefined") { + return window; + } + if (typeof global !== "undefined") { + return global; + } + throw "Unable to locate global object"; +})(); + +type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; + +export type DeepPartial = T extends Builtin ? T + : T extends Array ? Array> : T extends ReadonlyArray ? ReadonlyArray> + : T extends {} ? { [K in keyof T]?: DeepPartial } + : Partial; + +function toTimestamp(date: Date): Timestamp { + const seconds = date.getTime() / 1_000; + const nanos = (date.getTime() % 1_000) * 1_000_000; + return { seconds, nanos }; +} + +function fromTimestamp(t: Timestamp): Date { + let millis = t.seconds * 1_000; + millis += t.nanos / 1_000_000; + return new Date(millis); +} + +function fromJsonTimestamp(o: any): Date { + if (o instanceof Date) { + return o; + } else if (typeof o === "string") { + return new Date(o); + } else { + return fromTimestamp(Timestamp.fromJSON(o)); + } +} + +function longToNumber(long: Long): number { + if (long.gt(Number.MAX_SAFE_INTEGER)) { + throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); + } + return long.toNumber(); +} + +// If you get a compile-error about 'Constructor and ... have no overlap', +// add '--ts_proto_opt=esModuleInterop=true' as a flag when calling 'protoc'. +if (_m0.util.Long !== Long) { + _m0.util.Long = Long as any; + _m0.configure(); +} + +function isSet(value: any): boolean { + return value !== null && value !== undefined; +} diff --git a/components/usage-api/typescript/src/usage/v1/usage_grpc_pb.d.ts b/components/usage-api/typescript/src/usage/v1/usage_grpc_pb.d.ts deleted file mode 100644 index 8bc2acd06f9fec..00000000000000 --- a/components/usage-api/typescript/src/usage/v1/usage_grpc_pb.d.ts +++ /dev/null @@ -1,99 +0,0 @@ -/** - * Copyright (c) 2022 Gitpod GmbH. All rights reserved. - * Licensed under the GNU Affero General Public License (AGPL). - * See License-AGPL.txt in the project root for license information. - */ - -// package: usage.v1 -// file: usage/v1/usage.proto - -/* tslint:disable */ -/* eslint-disable */ - -import * as grpc from "@grpc/grpc-js"; -import * as usage_v1_usage_pb from "../../usage/v1/usage_pb"; -import * as google_protobuf_timestamp_pb from "google-protobuf/google/protobuf/timestamp_pb"; - -interface IUsageServiceService extends grpc.ServiceDefinition { - getCostCenter: IUsageServiceService_IGetCostCenter; - setCostCenter: IUsageServiceService_ISetCostCenter; - reconcileUsageWithLedger: IUsageServiceService_IReconcileUsageWithLedger; - listUsage: IUsageServiceService_IListUsage; -} - -interface IUsageServiceService_IGetCostCenter extends grpc.MethodDefinition { - path: "/usage.v1.UsageService/GetCostCenter"; - requestStream: false; - responseStream: false; - requestSerialize: grpc.serialize; - requestDeserialize: grpc.deserialize; - responseSerialize: grpc.serialize; - responseDeserialize: grpc.deserialize; -} -interface IUsageServiceService_ISetCostCenter extends grpc.MethodDefinition { - path: "/usage.v1.UsageService/SetCostCenter"; - requestStream: false; - responseStream: false; - requestSerialize: grpc.serialize; - requestDeserialize: grpc.deserialize; - responseSerialize: grpc.serialize; - responseDeserialize: grpc.deserialize; -} -interface IUsageServiceService_IReconcileUsageWithLedger extends grpc.MethodDefinition { - path: "/usage.v1.UsageService/ReconcileUsageWithLedger"; - requestStream: false; - responseStream: false; - requestSerialize: grpc.serialize; - requestDeserialize: grpc.deserialize; - responseSerialize: grpc.serialize; - responseDeserialize: grpc.deserialize; -} -interface IUsageServiceService_IListUsage extends grpc.MethodDefinition { - path: "/usage.v1.UsageService/ListUsage"; - requestStream: false; - responseStream: false; - requestSerialize: grpc.serialize; - requestDeserialize: grpc.deserialize; - responseSerialize: grpc.serialize; - responseDeserialize: grpc.deserialize; -} - -export const UsageServiceService: IUsageServiceService; - -export interface IUsageServiceServer extends grpc.UntypedServiceImplementation { - getCostCenter: grpc.handleUnaryCall; - setCostCenter: grpc.handleUnaryCall; - reconcileUsageWithLedger: grpc.handleUnaryCall; - listUsage: grpc.handleUnaryCall; -} - -export interface IUsageServiceClient { - getCostCenter(request: usage_v1_usage_pb.GetCostCenterRequest, callback: (error: grpc.ServiceError | null, response: usage_v1_usage_pb.GetCostCenterResponse) => void): grpc.ClientUnaryCall; - getCostCenter(request: usage_v1_usage_pb.GetCostCenterRequest, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: usage_v1_usage_pb.GetCostCenterResponse) => void): grpc.ClientUnaryCall; - getCostCenter(request: usage_v1_usage_pb.GetCostCenterRequest, metadata: grpc.Metadata, options: Partial, callback: (error: grpc.ServiceError | null, response: usage_v1_usage_pb.GetCostCenterResponse) => void): grpc.ClientUnaryCall; - setCostCenter(request: usage_v1_usage_pb.SetCostCenterRequest, callback: (error: grpc.ServiceError | null, response: usage_v1_usage_pb.SetCostCenterResponse) => void): grpc.ClientUnaryCall; - setCostCenter(request: usage_v1_usage_pb.SetCostCenterRequest, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: usage_v1_usage_pb.SetCostCenterResponse) => void): grpc.ClientUnaryCall; - setCostCenter(request: usage_v1_usage_pb.SetCostCenterRequest, metadata: grpc.Metadata, options: Partial, callback: (error: grpc.ServiceError | null, response: usage_v1_usage_pb.SetCostCenterResponse) => void): grpc.ClientUnaryCall; - reconcileUsageWithLedger(request: usage_v1_usage_pb.ReconcileUsageWithLedgerRequest, callback: (error: grpc.ServiceError | null, response: usage_v1_usage_pb.ReconcileUsageWithLedgerResponse) => void): grpc.ClientUnaryCall; - reconcileUsageWithLedger(request: usage_v1_usage_pb.ReconcileUsageWithLedgerRequest, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: usage_v1_usage_pb.ReconcileUsageWithLedgerResponse) => void): grpc.ClientUnaryCall; - reconcileUsageWithLedger(request: usage_v1_usage_pb.ReconcileUsageWithLedgerRequest, metadata: grpc.Metadata, options: Partial, callback: (error: grpc.ServiceError | null, response: usage_v1_usage_pb.ReconcileUsageWithLedgerResponse) => void): grpc.ClientUnaryCall; - listUsage(request: usage_v1_usage_pb.ListUsageRequest, callback: (error: grpc.ServiceError | null, response: usage_v1_usage_pb.ListUsageResponse) => void): grpc.ClientUnaryCall; - listUsage(request: usage_v1_usage_pb.ListUsageRequest, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: usage_v1_usage_pb.ListUsageResponse) => void): grpc.ClientUnaryCall; - listUsage(request: usage_v1_usage_pb.ListUsageRequest, metadata: grpc.Metadata, options: Partial, callback: (error: grpc.ServiceError | null, response: usage_v1_usage_pb.ListUsageResponse) => void): grpc.ClientUnaryCall; -} - -export class UsageServiceClient extends grpc.Client implements IUsageServiceClient { - constructor(address: string, credentials: grpc.ChannelCredentials, options?: Partial); - public getCostCenter(request: usage_v1_usage_pb.GetCostCenterRequest, callback: (error: grpc.ServiceError | null, response: usage_v1_usage_pb.GetCostCenterResponse) => void): grpc.ClientUnaryCall; - public getCostCenter(request: usage_v1_usage_pb.GetCostCenterRequest, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: usage_v1_usage_pb.GetCostCenterResponse) => void): grpc.ClientUnaryCall; - public getCostCenter(request: usage_v1_usage_pb.GetCostCenterRequest, metadata: grpc.Metadata, options: Partial, callback: (error: grpc.ServiceError | null, response: usage_v1_usage_pb.GetCostCenterResponse) => void): grpc.ClientUnaryCall; - public setCostCenter(request: usage_v1_usage_pb.SetCostCenterRequest, callback: (error: grpc.ServiceError | null, response: usage_v1_usage_pb.SetCostCenterResponse) => void): grpc.ClientUnaryCall; - public setCostCenter(request: usage_v1_usage_pb.SetCostCenterRequest, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: usage_v1_usage_pb.SetCostCenterResponse) => void): grpc.ClientUnaryCall; - public setCostCenter(request: usage_v1_usage_pb.SetCostCenterRequest, metadata: grpc.Metadata, options: Partial, callback: (error: grpc.ServiceError | null, response: usage_v1_usage_pb.SetCostCenterResponse) => void): grpc.ClientUnaryCall; - public reconcileUsageWithLedger(request: usage_v1_usage_pb.ReconcileUsageWithLedgerRequest, callback: (error: grpc.ServiceError | null, response: usage_v1_usage_pb.ReconcileUsageWithLedgerResponse) => void): grpc.ClientUnaryCall; - public reconcileUsageWithLedger(request: usage_v1_usage_pb.ReconcileUsageWithLedgerRequest, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: usage_v1_usage_pb.ReconcileUsageWithLedgerResponse) => void): grpc.ClientUnaryCall; - public reconcileUsageWithLedger(request: usage_v1_usage_pb.ReconcileUsageWithLedgerRequest, metadata: grpc.Metadata, options: Partial, callback: (error: grpc.ServiceError | null, response: usage_v1_usage_pb.ReconcileUsageWithLedgerResponse) => void): grpc.ClientUnaryCall; - public listUsage(request: usage_v1_usage_pb.ListUsageRequest, callback: (error: grpc.ServiceError | null, response: usage_v1_usage_pb.ListUsageResponse) => void): grpc.ClientUnaryCall; - public listUsage(request: usage_v1_usage_pb.ListUsageRequest, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: usage_v1_usage_pb.ListUsageResponse) => void): grpc.ClientUnaryCall; - public listUsage(request: usage_v1_usage_pb.ListUsageRequest, metadata: grpc.Metadata, options: Partial, callback: (error: grpc.ServiceError | null, response: usage_v1_usage_pb.ListUsageResponse) => void): grpc.ClientUnaryCall; -} diff --git a/components/usage-api/typescript/src/usage/v1/usage_grpc_pb.js b/components/usage-api/typescript/src/usage/v1/usage_grpc_pb.js deleted file mode 100644 index ebd38f518d090d..00000000000000 --- a/components/usage-api/typescript/src/usage/v1/usage_grpc_pb.js +++ /dev/null @@ -1,154 +0,0 @@ -/** - * Copyright (c) 2022 Gitpod GmbH. All rights reserved. - * Licensed under the GNU Affero General Public License (AGPL). - * See License-AGPL.txt in the project root for license information. - */ - -// GENERATED CODE -- DO NOT EDIT! - -'use strict'; -var grpc = require('@grpc/grpc-js'); -var usage_v1_usage_pb = require('../../usage/v1/usage_pb.js'); -var google_protobuf_timestamp_pb = require('google-protobuf/google/protobuf/timestamp_pb.js'); - -function serialize_usage_v1_GetCostCenterRequest(arg) { - if (!(arg instanceof usage_v1_usage_pb.GetCostCenterRequest)) { - throw new Error('Expected argument of type usage.v1.GetCostCenterRequest'); - } - return Buffer.from(arg.serializeBinary()); -} - -function deserialize_usage_v1_GetCostCenterRequest(buffer_arg) { - return usage_v1_usage_pb.GetCostCenterRequest.deserializeBinary(new Uint8Array(buffer_arg)); -} - -function serialize_usage_v1_GetCostCenterResponse(arg) { - if (!(arg instanceof usage_v1_usage_pb.GetCostCenterResponse)) { - throw new Error('Expected argument of type usage.v1.GetCostCenterResponse'); - } - return Buffer.from(arg.serializeBinary()); -} - -function deserialize_usage_v1_GetCostCenterResponse(buffer_arg) { - return usage_v1_usage_pb.GetCostCenterResponse.deserializeBinary(new Uint8Array(buffer_arg)); -} - -function serialize_usage_v1_ListUsageRequest(arg) { - if (!(arg instanceof usage_v1_usage_pb.ListUsageRequest)) { - throw new Error('Expected argument of type usage.v1.ListUsageRequest'); - } - return Buffer.from(arg.serializeBinary()); -} - -function deserialize_usage_v1_ListUsageRequest(buffer_arg) { - return usage_v1_usage_pb.ListUsageRequest.deserializeBinary(new Uint8Array(buffer_arg)); -} - -function serialize_usage_v1_ListUsageResponse(arg) { - if (!(arg instanceof usage_v1_usage_pb.ListUsageResponse)) { - throw new Error('Expected argument of type usage.v1.ListUsageResponse'); - } - return Buffer.from(arg.serializeBinary()); -} - -function deserialize_usage_v1_ListUsageResponse(buffer_arg) { - return usage_v1_usage_pb.ListUsageResponse.deserializeBinary(new Uint8Array(buffer_arg)); -} - -function serialize_usage_v1_ReconcileUsageWithLedgerRequest(arg) { - if (!(arg instanceof usage_v1_usage_pb.ReconcileUsageWithLedgerRequest)) { - throw new Error('Expected argument of type usage.v1.ReconcileUsageWithLedgerRequest'); - } - return Buffer.from(arg.serializeBinary()); -} - -function deserialize_usage_v1_ReconcileUsageWithLedgerRequest(buffer_arg) { - return usage_v1_usage_pb.ReconcileUsageWithLedgerRequest.deserializeBinary(new Uint8Array(buffer_arg)); -} - -function serialize_usage_v1_ReconcileUsageWithLedgerResponse(arg) { - if (!(arg instanceof usage_v1_usage_pb.ReconcileUsageWithLedgerResponse)) { - throw new Error('Expected argument of type usage.v1.ReconcileUsageWithLedgerResponse'); - } - return Buffer.from(arg.serializeBinary()); -} - -function deserialize_usage_v1_ReconcileUsageWithLedgerResponse(buffer_arg) { - return usage_v1_usage_pb.ReconcileUsageWithLedgerResponse.deserializeBinary(new Uint8Array(buffer_arg)); -} - -function serialize_usage_v1_SetCostCenterRequest(arg) { - if (!(arg instanceof usage_v1_usage_pb.SetCostCenterRequest)) { - throw new Error('Expected argument of type usage.v1.SetCostCenterRequest'); - } - return Buffer.from(arg.serializeBinary()); -} - -function deserialize_usage_v1_SetCostCenterRequest(buffer_arg) { - return usage_v1_usage_pb.SetCostCenterRequest.deserializeBinary(new Uint8Array(buffer_arg)); -} - -function serialize_usage_v1_SetCostCenterResponse(arg) { - if (!(arg instanceof usage_v1_usage_pb.SetCostCenterResponse)) { - throw new Error('Expected argument of type usage.v1.SetCostCenterResponse'); - } - return Buffer.from(arg.serializeBinary()); -} - -function deserialize_usage_v1_SetCostCenterResponse(buffer_arg) { - return usage_v1_usage_pb.SetCostCenterResponse.deserializeBinary(new Uint8Array(buffer_arg)); -} - - -var UsageServiceService = exports.UsageServiceService = { - // GetCostCenter retrieves the active cost center for the given attributionID -getCostCenter: { - path: '/usage.v1.UsageService/GetCostCenter', - requestStream: false, - responseStream: false, - requestType: usage_v1_usage_pb.GetCostCenterRequest, - responseType: usage_v1_usage_pb.GetCostCenterResponse, - requestSerialize: serialize_usage_v1_GetCostCenterRequest, - requestDeserialize: deserialize_usage_v1_GetCostCenterRequest, - responseSerialize: serialize_usage_v1_GetCostCenterResponse, - responseDeserialize: deserialize_usage_v1_GetCostCenterResponse, - }, - // SetCostCenter stores the given cost center -setCostCenter: { - path: '/usage.v1.UsageService/SetCostCenter', - requestStream: false, - responseStream: false, - requestType: usage_v1_usage_pb.SetCostCenterRequest, - responseType: usage_v1_usage_pb.SetCostCenterResponse, - requestSerialize: serialize_usage_v1_SetCostCenterRequest, - requestDeserialize: deserialize_usage_v1_SetCostCenterRequest, - responseSerialize: serialize_usage_v1_SetCostCenterResponse, - responseDeserialize: deserialize_usage_v1_SetCostCenterResponse, - }, - // Triggers reconciliation of usage with ledger implementation. -reconcileUsageWithLedger: { - path: '/usage.v1.UsageService/ReconcileUsageWithLedger', - requestStream: false, - responseStream: false, - requestType: usage_v1_usage_pb.ReconcileUsageWithLedgerRequest, - responseType: usage_v1_usage_pb.ReconcileUsageWithLedgerResponse, - requestSerialize: serialize_usage_v1_ReconcileUsageWithLedgerRequest, - requestDeserialize: deserialize_usage_v1_ReconcileUsageWithLedgerRequest, - responseSerialize: serialize_usage_v1_ReconcileUsageWithLedgerResponse, - responseDeserialize: deserialize_usage_v1_ReconcileUsageWithLedgerResponse, - }, - // ListUsage retrieves all usage for the specified attributionId and theb given time range -listUsage: { - path: '/usage.v1.UsageService/ListUsage', - requestStream: false, - responseStream: false, - requestType: usage_v1_usage_pb.ListUsageRequest, - responseType: usage_v1_usage_pb.ListUsageResponse, - requestSerialize: serialize_usage_v1_ListUsageRequest, - requestDeserialize: deserialize_usage_v1_ListUsageRequest, - responseSerialize: serialize_usage_v1_ListUsageResponse, - responseDeserialize: deserialize_usage_v1_ListUsageResponse, - }, -}; - -exports.UsageServiceClient = grpc.makeGenericClientConstructor(UsageServiceService); diff --git a/components/usage-api/typescript/src/usage/v1/usage_pb.d.ts b/components/usage-api/typescript/src/usage/v1/usage_pb.d.ts deleted file mode 100644 index 8d4e4f87a1bc2b..00000000000000 --- a/components/usage-api/typescript/src/usage/v1/usage_pb.d.ts +++ /dev/null @@ -1,361 +0,0 @@ -/** - * Copyright (c) 2022 Gitpod GmbH. All rights reserved. - * Licensed under the GNU Affero General Public License (AGPL). - * See License-AGPL.txt in the project root for license information. - */ - -// package: usage.v1 -// file: usage/v1/usage.proto - -/* tslint:disable */ -/* eslint-disable */ - -import * as jspb from "google-protobuf"; -import * as google_protobuf_timestamp_pb from "google-protobuf/google/protobuf/timestamp_pb"; - -export class ReconcileUsageWithLedgerRequest extends jspb.Message { - - hasFrom(): boolean; - clearFrom(): void; - getFrom(): google_protobuf_timestamp_pb.Timestamp | undefined; - setFrom(value?: google_protobuf_timestamp_pb.Timestamp): ReconcileUsageWithLedgerRequest; - - hasTo(): boolean; - clearTo(): void; - getTo(): google_protobuf_timestamp_pb.Timestamp | undefined; - setTo(value?: google_protobuf_timestamp_pb.Timestamp): ReconcileUsageWithLedgerRequest; - - serializeBinary(): Uint8Array; - toObject(includeInstance?: boolean): ReconcileUsageWithLedgerRequest.AsObject; - static toObject(includeInstance: boolean, msg: ReconcileUsageWithLedgerRequest): ReconcileUsageWithLedgerRequest.AsObject; - static extensions: {[key: number]: jspb.ExtensionFieldInfo}; - static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; - static serializeBinaryToWriter(message: ReconcileUsageWithLedgerRequest, writer: jspb.BinaryWriter): void; - static deserializeBinary(bytes: Uint8Array): ReconcileUsageWithLedgerRequest; - static deserializeBinaryFromReader(message: ReconcileUsageWithLedgerRequest, reader: jspb.BinaryReader): ReconcileUsageWithLedgerRequest; -} - -export namespace ReconcileUsageWithLedgerRequest { - export type AsObject = { - from?: google_protobuf_timestamp_pb.Timestamp.AsObject, - to?: google_protobuf_timestamp_pb.Timestamp.AsObject, - } -} - -export class ReconcileUsageWithLedgerResponse extends jspb.Message { - - serializeBinary(): Uint8Array; - toObject(includeInstance?: boolean): ReconcileUsageWithLedgerResponse.AsObject; - static toObject(includeInstance: boolean, msg: ReconcileUsageWithLedgerResponse): ReconcileUsageWithLedgerResponse.AsObject; - static extensions: {[key: number]: jspb.ExtensionFieldInfo}; - static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; - static serializeBinaryToWriter(message: ReconcileUsageWithLedgerResponse, writer: jspb.BinaryWriter): void; - static deserializeBinary(bytes: Uint8Array): ReconcileUsageWithLedgerResponse; - static deserializeBinaryFromReader(message: ReconcileUsageWithLedgerResponse, reader: jspb.BinaryReader): ReconcileUsageWithLedgerResponse; -} - -export namespace ReconcileUsageWithLedgerResponse { - export type AsObject = { - } -} - -export class PaginatedRequest extends jspb.Message { - getPerPage(): number; - setPerPage(value: number): PaginatedRequest; - getPage(): number; - setPage(value: number): PaginatedRequest; - - serializeBinary(): Uint8Array; - toObject(includeInstance?: boolean): PaginatedRequest.AsObject; - static toObject(includeInstance: boolean, msg: PaginatedRequest): PaginatedRequest.AsObject; - static extensions: {[key: number]: jspb.ExtensionFieldInfo}; - static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; - static serializeBinaryToWriter(message: PaginatedRequest, writer: jspb.BinaryWriter): void; - static deserializeBinary(bytes: Uint8Array): PaginatedRequest; - static deserializeBinaryFromReader(message: PaginatedRequest, reader: jspb.BinaryReader): PaginatedRequest; -} - -export namespace PaginatedRequest { - export type AsObject = { - perPage: number, - page: number, - } -} - -export class PaginatedResponse extends jspb.Message { - getPerPage(): number; - setPerPage(value: number): PaginatedResponse; - getTotalPages(): number; - setTotalPages(value: number): PaginatedResponse; - getTotal(): number; - setTotal(value: number): PaginatedResponse; - getPage(): number; - setPage(value: number): PaginatedResponse; - - serializeBinary(): Uint8Array; - toObject(includeInstance?: boolean): PaginatedResponse.AsObject; - static toObject(includeInstance: boolean, msg: PaginatedResponse): PaginatedResponse.AsObject; - static extensions: {[key: number]: jspb.ExtensionFieldInfo}; - static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; - static serializeBinaryToWriter(message: PaginatedResponse, writer: jspb.BinaryWriter): void; - static deserializeBinary(bytes: Uint8Array): PaginatedResponse; - static deserializeBinaryFromReader(message: PaginatedResponse, reader: jspb.BinaryReader): PaginatedResponse; -} - -export namespace PaginatedResponse { - export type AsObject = { - perPage: number, - totalPages: number, - total: number, - page: number, - } -} - -export class ListUsageRequest extends jspb.Message { - getAttributionId(): string; - setAttributionId(value: string): ListUsageRequest; - - hasFrom(): boolean; - clearFrom(): void; - getFrom(): google_protobuf_timestamp_pb.Timestamp | undefined; - setFrom(value?: google_protobuf_timestamp_pb.Timestamp): ListUsageRequest; - - hasTo(): boolean; - clearTo(): void; - getTo(): google_protobuf_timestamp_pb.Timestamp | undefined; - setTo(value?: google_protobuf_timestamp_pb.Timestamp): ListUsageRequest; - getOrder(): ListUsageRequest.Ordering; - setOrder(value: ListUsageRequest.Ordering): ListUsageRequest; - - hasPagination(): boolean; - clearPagination(): void; - getPagination(): PaginatedRequest | undefined; - setPagination(value?: PaginatedRequest): ListUsageRequest; - - serializeBinary(): Uint8Array; - toObject(includeInstance?: boolean): ListUsageRequest.AsObject; - static toObject(includeInstance: boolean, msg: ListUsageRequest): ListUsageRequest.AsObject; - static extensions: {[key: number]: jspb.ExtensionFieldInfo}; - static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; - static serializeBinaryToWriter(message: ListUsageRequest, writer: jspb.BinaryWriter): void; - static deserializeBinary(bytes: Uint8Array): ListUsageRequest; - static deserializeBinaryFromReader(message: ListUsageRequest, reader: jspb.BinaryReader): ListUsageRequest; -} - -export namespace ListUsageRequest { - export type AsObject = { - attributionId: string, - from?: google_protobuf_timestamp_pb.Timestamp.AsObject, - to?: google_protobuf_timestamp_pb.Timestamp.AsObject, - order: ListUsageRequest.Ordering, - pagination?: PaginatedRequest.AsObject, - } - - export enum Ordering { - ORDERING_DESCENDING = 0, - ORDERING_ASCENDING = 1, - } - -} - -export class ListUsageResponse extends jspb.Message { - clearUsageEntriesList(): void; - getUsageEntriesList(): Array; - setUsageEntriesList(value: Array): ListUsageResponse; - addUsageEntries(value?: Usage, index?: number): Usage; - - hasPagination(): boolean; - clearPagination(): void; - getPagination(): PaginatedResponse | undefined; - setPagination(value?: PaginatedResponse): ListUsageResponse; - getCreditBalanceAtStart(): number; - setCreditBalanceAtStart(value: number): ListUsageResponse; - getCreditBalanceAtEnd(): number; - setCreditBalanceAtEnd(value: number): ListUsageResponse; - - serializeBinary(): Uint8Array; - toObject(includeInstance?: boolean): ListUsageResponse.AsObject; - static toObject(includeInstance: boolean, msg: ListUsageResponse): ListUsageResponse.AsObject; - static extensions: {[key: number]: jspb.ExtensionFieldInfo}; - static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; - static serializeBinaryToWriter(message: ListUsageResponse, writer: jspb.BinaryWriter): void; - static deserializeBinary(bytes: Uint8Array): ListUsageResponse; - static deserializeBinaryFromReader(message: ListUsageResponse, reader: jspb.BinaryReader): ListUsageResponse; -} - -export namespace ListUsageResponse { - export type AsObject = { - usageEntriesList: Array, - pagination?: PaginatedResponse.AsObject, - creditBalanceAtStart: number, - creditBalanceAtEnd: number, - } -} - -export class Usage extends jspb.Message { - getId(): string; - setId(value: string): Usage; - getAttributionId(): string; - setAttributionId(value: string): Usage; - getDescription(): string; - setDescription(value: string): Usage; - getCredits(): number; - setCredits(value: number): Usage; - - hasEffectiveTime(): boolean; - clearEffectiveTime(): void; - getEffectiveTime(): google_protobuf_timestamp_pb.Timestamp | undefined; - setEffectiveTime(value?: google_protobuf_timestamp_pb.Timestamp): Usage; - getKind(): Usage.Kind; - setKind(value: Usage.Kind): Usage; - getWorkspaceInstanceId(): string; - setWorkspaceInstanceId(value: string): Usage; - getDraft(): boolean; - setDraft(value: boolean): Usage; - getMetadata(): string; - setMetadata(value: string): Usage; - - serializeBinary(): Uint8Array; - toObject(includeInstance?: boolean): Usage.AsObject; - static toObject(includeInstance: boolean, msg: Usage): Usage.AsObject; - static extensions: {[key: number]: jspb.ExtensionFieldInfo}; - static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; - static serializeBinaryToWriter(message: Usage, writer: jspb.BinaryWriter): void; - static deserializeBinary(bytes: Uint8Array): Usage; - static deserializeBinaryFromReader(message: Usage, reader: jspb.BinaryReader): Usage; -} - -export namespace Usage { - export type AsObject = { - id: string, - attributionId: string, - description: string, - credits: number, - effectiveTime?: google_protobuf_timestamp_pb.Timestamp.AsObject, - kind: Usage.Kind, - workspaceInstanceId: string, - draft: boolean, - metadata: string, - } - - export enum Kind { - KIND_WORKSPACE_INSTANCE = 0, - KIND_INVOICE = 1, - } - -} - -export class SetCostCenterRequest extends jspb.Message { - - hasCostCenter(): boolean; - clearCostCenter(): void; - getCostCenter(): CostCenter | undefined; - setCostCenter(value?: CostCenter): SetCostCenterRequest; - - serializeBinary(): Uint8Array; - toObject(includeInstance?: boolean): SetCostCenterRequest.AsObject; - static toObject(includeInstance: boolean, msg: SetCostCenterRequest): SetCostCenterRequest.AsObject; - static extensions: {[key: number]: jspb.ExtensionFieldInfo}; - static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; - static serializeBinaryToWriter(message: SetCostCenterRequest, writer: jspb.BinaryWriter): void; - static deserializeBinary(bytes: Uint8Array): SetCostCenterRequest; - static deserializeBinaryFromReader(message: SetCostCenterRequest, reader: jspb.BinaryReader): SetCostCenterRequest; -} - -export namespace SetCostCenterRequest { - export type AsObject = { - costCenter?: CostCenter.AsObject, - } -} - -export class SetCostCenterResponse extends jspb.Message { - - serializeBinary(): Uint8Array; - toObject(includeInstance?: boolean): SetCostCenterResponse.AsObject; - static toObject(includeInstance: boolean, msg: SetCostCenterResponse): SetCostCenterResponse.AsObject; - static extensions: {[key: number]: jspb.ExtensionFieldInfo}; - static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; - static serializeBinaryToWriter(message: SetCostCenterResponse, writer: jspb.BinaryWriter): void; - static deserializeBinary(bytes: Uint8Array): SetCostCenterResponse; - static deserializeBinaryFromReader(message: SetCostCenterResponse, reader: jspb.BinaryReader): SetCostCenterResponse; -} - -export namespace SetCostCenterResponse { - export type AsObject = { - } -} - -export class GetCostCenterRequest extends jspb.Message { - getAttributionId(): string; - setAttributionId(value: string): GetCostCenterRequest; - - serializeBinary(): Uint8Array; - toObject(includeInstance?: boolean): GetCostCenterRequest.AsObject; - static toObject(includeInstance: boolean, msg: GetCostCenterRequest): GetCostCenterRequest.AsObject; - static extensions: {[key: number]: jspb.ExtensionFieldInfo}; - static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; - static serializeBinaryToWriter(message: GetCostCenterRequest, writer: jspb.BinaryWriter): void; - static deserializeBinary(bytes: Uint8Array): GetCostCenterRequest; - static deserializeBinaryFromReader(message: GetCostCenterRequest, reader: jspb.BinaryReader): GetCostCenterRequest; -} - -export namespace GetCostCenterRequest { - export type AsObject = { - attributionId: string, - } -} - -export class GetCostCenterResponse extends jspb.Message { - - hasCostCenter(): boolean; - clearCostCenter(): void; - getCostCenter(): CostCenter | undefined; - setCostCenter(value?: CostCenter): GetCostCenterResponse; - - serializeBinary(): Uint8Array; - toObject(includeInstance?: boolean): GetCostCenterResponse.AsObject; - static toObject(includeInstance: boolean, msg: GetCostCenterResponse): GetCostCenterResponse.AsObject; - static extensions: {[key: number]: jspb.ExtensionFieldInfo}; - static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; - static serializeBinaryToWriter(message: GetCostCenterResponse, writer: jspb.BinaryWriter): void; - static deserializeBinary(bytes: Uint8Array): GetCostCenterResponse; - static deserializeBinaryFromReader(message: GetCostCenterResponse, reader: jspb.BinaryReader): GetCostCenterResponse; -} - -export namespace GetCostCenterResponse { - export type AsObject = { - costCenter?: CostCenter.AsObject, - } -} - -export class CostCenter extends jspb.Message { - getAttributionId(): string; - setAttributionId(value: string): CostCenter; - getSpendingLimit(): number; - setSpendingLimit(value: number): CostCenter; - getBillingStrategy(): CostCenter.BillingStrategy; - setBillingStrategy(value: CostCenter.BillingStrategy): CostCenter; - - serializeBinary(): Uint8Array; - toObject(includeInstance?: boolean): CostCenter.AsObject; - static toObject(includeInstance: boolean, msg: CostCenter): CostCenter.AsObject; - static extensions: {[key: number]: jspb.ExtensionFieldInfo}; - static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; - static serializeBinaryToWriter(message: CostCenter, writer: jspb.BinaryWriter): void; - static deserializeBinary(bytes: Uint8Array): CostCenter; - static deserializeBinaryFromReader(message: CostCenter, reader: jspb.BinaryReader): CostCenter; -} - -export namespace CostCenter { - export type AsObject = { - attributionId: string, - spendingLimit: number, - billingStrategy: CostCenter.BillingStrategy, - } - - export enum BillingStrategy { - BILLING_STRATEGY_STRIPE = 0, - BILLING_STRATEGY_OTHER = 1, - } - -} diff --git a/components/usage-api/typescript/src/usage/v1/usage_pb.js b/components/usage-api/typescript/src/usage/v1/usage_pb.js deleted file mode 100644 index 18ed1a12a3b78b..00000000000000 --- a/components/usage-api/typescript/src/usage/v1/usage_pb.js +++ /dev/null @@ -1,2698 +0,0 @@ -/** - * Copyright (c) 2022 Gitpod GmbH. All rights reserved. - * Licensed under the GNU Affero General Public License (AGPL). - * See License-AGPL.txt in the project root for license information. - */ - -// source: usage/v1/usage.proto -/** - * @fileoverview - * @enhanceable - * @suppress {missingRequire} reports error on implicit type usages. - * @suppress {messageConventions} JS Compiler reports an error if a variable or - * field starts with 'MSG_' and isn't a translatable message. - * @public - */ -// GENERATED CODE -- DO NOT EDIT! -/* eslint-disable */ -// @ts-nocheck - -var jspb = require('google-protobuf'); -var goog = jspb; -var global = (function() { return this || window || global || self || Function('return this')(); }).call(null); - -var google_protobuf_timestamp_pb = require('google-protobuf/google/protobuf/timestamp_pb.js'); -goog.object.extend(proto, google_protobuf_timestamp_pb); -goog.exportSymbol('proto.usage.v1.CostCenter', null, global); -goog.exportSymbol('proto.usage.v1.CostCenter.BillingStrategy', null, global); -goog.exportSymbol('proto.usage.v1.GetCostCenterRequest', null, global); -goog.exportSymbol('proto.usage.v1.GetCostCenterResponse', null, global); -goog.exportSymbol('proto.usage.v1.ListUsageRequest', null, global); -goog.exportSymbol('proto.usage.v1.ListUsageRequest.Ordering', null, global); -goog.exportSymbol('proto.usage.v1.ListUsageResponse', null, global); -goog.exportSymbol('proto.usage.v1.PaginatedRequest', null, global); -goog.exportSymbol('proto.usage.v1.PaginatedResponse', null, global); -goog.exportSymbol('proto.usage.v1.ReconcileUsageWithLedgerRequest', null, global); -goog.exportSymbol('proto.usage.v1.ReconcileUsageWithLedgerResponse', null, global); -goog.exportSymbol('proto.usage.v1.SetCostCenterRequest', null, global); -goog.exportSymbol('proto.usage.v1.SetCostCenterResponse', null, global); -goog.exportSymbol('proto.usage.v1.Usage', null, global); -goog.exportSymbol('proto.usage.v1.Usage.Kind', null, global); -/** - * Generated by JsPbCodeGenerator. - * @param {Array=} opt_data Optional initial data array, typically from a - * server response, or constructed directly in Javascript. The array is used - * in place and becomes part of the constructed object. It is not cloned. - * If no data is provided, the constructed object will be empty, but still - * valid. - * @extends {jspb.Message} - * @constructor - */ -proto.usage.v1.ReconcileUsageWithLedgerRequest = function(opt_data) { - jspb.Message.initialize(this, opt_data, 0, -1, null, null); -}; -goog.inherits(proto.usage.v1.ReconcileUsageWithLedgerRequest, jspb.Message); -if (goog.DEBUG && !COMPILED) { - /** - * @public - * @override - */ - proto.usage.v1.ReconcileUsageWithLedgerRequest.displayName = 'proto.usage.v1.ReconcileUsageWithLedgerRequest'; -} -/** - * Generated by JsPbCodeGenerator. - * @param {Array=} opt_data Optional initial data array, typically from a - * server response, or constructed directly in Javascript. The array is used - * in place and becomes part of the constructed object. It is not cloned. - * If no data is provided, the constructed object will be empty, but still - * valid. - * @extends {jspb.Message} - * @constructor - */ -proto.usage.v1.ReconcileUsageWithLedgerResponse = function(opt_data) { - jspb.Message.initialize(this, opt_data, 0, -1, null, null); -}; -goog.inherits(proto.usage.v1.ReconcileUsageWithLedgerResponse, jspb.Message); -if (goog.DEBUG && !COMPILED) { - /** - * @public - * @override - */ - proto.usage.v1.ReconcileUsageWithLedgerResponse.displayName = 'proto.usage.v1.ReconcileUsageWithLedgerResponse'; -} -/** - * Generated by JsPbCodeGenerator. - * @param {Array=} opt_data Optional initial data array, typically from a - * server response, or constructed directly in Javascript. The array is used - * in place and becomes part of the constructed object. It is not cloned. - * If no data is provided, the constructed object will be empty, but still - * valid. - * @extends {jspb.Message} - * @constructor - */ -proto.usage.v1.PaginatedRequest = function(opt_data) { - jspb.Message.initialize(this, opt_data, 0, -1, null, null); -}; -goog.inherits(proto.usage.v1.PaginatedRequest, jspb.Message); -if (goog.DEBUG && !COMPILED) { - /** - * @public - * @override - */ - proto.usage.v1.PaginatedRequest.displayName = 'proto.usage.v1.PaginatedRequest'; -} -/** - * Generated by JsPbCodeGenerator. - * @param {Array=} opt_data Optional initial data array, typically from a - * server response, or constructed directly in Javascript. The array is used - * in place and becomes part of the constructed object. It is not cloned. - * If no data is provided, the constructed object will be empty, but still - * valid. - * @extends {jspb.Message} - * @constructor - */ -proto.usage.v1.PaginatedResponse = function(opt_data) { - jspb.Message.initialize(this, opt_data, 0, -1, null, null); -}; -goog.inherits(proto.usage.v1.PaginatedResponse, jspb.Message); -if (goog.DEBUG && !COMPILED) { - /** - * @public - * @override - */ - proto.usage.v1.PaginatedResponse.displayName = 'proto.usage.v1.PaginatedResponse'; -} -/** - * Generated by JsPbCodeGenerator. - * @param {Array=} opt_data Optional initial data array, typically from a - * server response, or constructed directly in Javascript. The array is used - * in place and becomes part of the constructed object. It is not cloned. - * If no data is provided, the constructed object will be empty, but still - * valid. - * @extends {jspb.Message} - * @constructor - */ -proto.usage.v1.ListUsageRequest = function(opt_data) { - jspb.Message.initialize(this, opt_data, 0, -1, null, null); -}; -goog.inherits(proto.usage.v1.ListUsageRequest, jspb.Message); -if (goog.DEBUG && !COMPILED) { - /** - * @public - * @override - */ - proto.usage.v1.ListUsageRequest.displayName = 'proto.usage.v1.ListUsageRequest'; -} -/** - * Generated by JsPbCodeGenerator. - * @param {Array=} opt_data Optional initial data array, typically from a - * server response, or constructed directly in Javascript. The array is used - * in place and becomes part of the constructed object. It is not cloned. - * If no data is provided, the constructed object will be empty, but still - * valid. - * @extends {jspb.Message} - * @constructor - */ -proto.usage.v1.ListUsageResponse = function(opt_data) { - jspb.Message.initialize(this, opt_data, 0, -1, proto.usage.v1.ListUsageResponse.repeatedFields_, null); -}; -goog.inherits(proto.usage.v1.ListUsageResponse, jspb.Message); -if (goog.DEBUG && !COMPILED) { - /** - * @public - * @override - */ - proto.usage.v1.ListUsageResponse.displayName = 'proto.usage.v1.ListUsageResponse'; -} -/** - * Generated by JsPbCodeGenerator. - * @param {Array=} opt_data Optional initial data array, typically from a - * server response, or constructed directly in Javascript. The array is used - * in place and becomes part of the constructed object. It is not cloned. - * If no data is provided, the constructed object will be empty, but still - * valid. - * @extends {jspb.Message} - * @constructor - */ -proto.usage.v1.Usage = function(opt_data) { - jspb.Message.initialize(this, opt_data, 0, -1, null, null); -}; -goog.inherits(proto.usage.v1.Usage, jspb.Message); -if (goog.DEBUG && !COMPILED) { - /** - * @public - * @override - */ - proto.usage.v1.Usage.displayName = 'proto.usage.v1.Usage'; -} -/** - * Generated by JsPbCodeGenerator. - * @param {Array=} opt_data Optional initial data array, typically from a - * server response, or constructed directly in Javascript. The array is used - * in place and becomes part of the constructed object. It is not cloned. - * If no data is provided, the constructed object will be empty, but still - * valid. - * @extends {jspb.Message} - * @constructor - */ -proto.usage.v1.SetCostCenterRequest = function(opt_data) { - jspb.Message.initialize(this, opt_data, 0, -1, null, null); -}; -goog.inherits(proto.usage.v1.SetCostCenterRequest, jspb.Message); -if (goog.DEBUG && !COMPILED) { - /** - * @public - * @override - */ - proto.usage.v1.SetCostCenterRequest.displayName = 'proto.usage.v1.SetCostCenterRequest'; -} -/** - * Generated by JsPbCodeGenerator. - * @param {Array=} opt_data Optional initial data array, typically from a - * server response, or constructed directly in Javascript. The array is used - * in place and becomes part of the constructed object. It is not cloned. - * If no data is provided, the constructed object will be empty, but still - * valid. - * @extends {jspb.Message} - * @constructor - */ -proto.usage.v1.SetCostCenterResponse = function(opt_data) { - jspb.Message.initialize(this, opt_data, 0, -1, null, null); -}; -goog.inherits(proto.usage.v1.SetCostCenterResponse, jspb.Message); -if (goog.DEBUG && !COMPILED) { - /** - * @public - * @override - */ - proto.usage.v1.SetCostCenterResponse.displayName = 'proto.usage.v1.SetCostCenterResponse'; -} -/** - * Generated by JsPbCodeGenerator. - * @param {Array=} opt_data Optional initial data array, typically from a - * server response, or constructed directly in Javascript. The array is used - * in place and becomes part of the constructed object. It is not cloned. - * If no data is provided, the constructed object will be empty, but still - * valid. - * @extends {jspb.Message} - * @constructor - */ -proto.usage.v1.GetCostCenterRequest = function(opt_data) { - jspb.Message.initialize(this, opt_data, 0, -1, null, null); -}; -goog.inherits(proto.usage.v1.GetCostCenterRequest, jspb.Message); -if (goog.DEBUG && !COMPILED) { - /** - * @public - * @override - */ - proto.usage.v1.GetCostCenterRequest.displayName = 'proto.usage.v1.GetCostCenterRequest'; -} -/** - * Generated by JsPbCodeGenerator. - * @param {Array=} opt_data Optional initial data array, typically from a - * server response, or constructed directly in Javascript. The array is used - * in place and becomes part of the constructed object. It is not cloned. - * If no data is provided, the constructed object will be empty, but still - * valid. - * @extends {jspb.Message} - * @constructor - */ -proto.usage.v1.GetCostCenterResponse = function(opt_data) { - jspb.Message.initialize(this, opt_data, 0, -1, null, null); -}; -goog.inherits(proto.usage.v1.GetCostCenterResponse, jspb.Message); -if (goog.DEBUG && !COMPILED) { - /** - * @public - * @override - */ - proto.usage.v1.GetCostCenterResponse.displayName = 'proto.usage.v1.GetCostCenterResponse'; -} -/** - * Generated by JsPbCodeGenerator. - * @param {Array=} opt_data Optional initial data array, typically from a - * server response, or constructed directly in Javascript. The array is used - * in place and becomes part of the constructed object. It is not cloned. - * If no data is provided, the constructed object will be empty, but still - * valid. - * @extends {jspb.Message} - * @constructor - */ -proto.usage.v1.CostCenter = function(opt_data) { - jspb.Message.initialize(this, opt_data, 0, -1, null, null); -}; -goog.inherits(proto.usage.v1.CostCenter, jspb.Message); -if (goog.DEBUG && !COMPILED) { - /** - * @public - * @override - */ - proto.usage.v1.CostCenter.displayName = 'proto.usage.v1.CostCenter'; -} - - - -if (jspb.Message.GENERATE_TO_OBJECT) { -/** - * Creates an object representation of this proto. - * Field names that are reserved in JavaScript and will be renamed to pb_name. - * Optional fields that are not set will be set to undefined. - * To access a reserved field use, foo.pb_, eg, foo.pb_default. - * For the list of reserved names please see: - * net/proto2/compiler/js/internal/generator.cc#kKeyword. - * @param {boolean=} opt_includeInstance Deprecated. whether to include the - * JSPB instance for transitional soy proto support: - * http://goto/soy-param-migration - * @return {!Object} - */ -proto.usage.v1.ReconcileUsageWithLedgerRequest.prototype.toObject = function(opt_includeInstance) { - return proto.usage.v1.ReconcileUsageWithLedgerRequest.toObject(opt_includeInstance, this); -}; - - -/** - * Static version of the {@see toObject} method. - * @param {boolean|undefined} includeInstance Deprecated. Whether to include - * the JSPB instance for transitional soy proto support: - * http://goto/soy-param-migration - * @param {!proto.usage.v1.ReconcileUsageWithLedgerRequest} msg The msg instance to transform. - * @return {!Object} - * @suppress {unusedLocalVariables} f is only used for nested messages - */ -proto.usage.v1.ReconcileUsageWithLedgerRequest.toObject = function(includeInstance, msg) { - var f, obj = { - from: (f = msg.getFrom()) && google_protobuf_timestamp_pb.Timestamp.toObject(includeInstance, f), - to: (f = msg.getTo()) && google_protobuf_timestamp_pb.Timestamp.toObject(includeInstance, f) - }; - - if (includeInstance) { - obj.$jspbMessageInstance = msg; - } - return obj; -}; -} - - -/** - * Deserializes binary data (in protobuf wire format). - * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.usage.v1.ReconcileUsageWithLedgerRequest} - */ -proto.usage.v1.ReconcileUsageWithLedgerRequest.deserializeBinary = function(bytes) { - var reader = new jspb.BinaryReader(bytes); - var msg = new proto.usage.v1.ReconcileUsageWithLedgerRequest; - return proto.usage.v1.ReconcileUsageWithLedgerRequest.deserializeBinaryFromReader(msg, reader); -}; - - -/** - * Deserializes binary data (in protobuf wire format) from the - * given reader into the given message object. - * @param {!proto.usage.v1.ReconcileUsageWithLedgerRequest} msg The message object to deserialize into. - * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.usage.v1.ReconcileUsageWithLedgerRequest} - */ -proto.usage.v1.ReconcileUsageWithLedgerRequest.deserializeBinaryFromReader = function(msg, reader) { - while (reader.nextField()) { - if (reader.isEndGroup()) { - break; - } - var field = reader.getFieldNumber(); - switch (field) { - case 1: - var value = new google_protobuf_timestamp_pb.Timestamp; - reader.readMessage(value,google_protobuf_timestamp_pb.Timestamp.deserializeBinaryFromReader); - msg.setFrom(value); - break; - case 2: - var value = new google_protobuf_timestamp_pb.Timestamp; - reader.readMessage(value,google_protobuf_timestamp_pb.Timestamp.deserializeBinaryFromReader); - msg.setTo(value); - break; - default: - reader.skipField(); - break; - } - } - return msg; -}; - - -/** - * Serializes the message to binary data (in protobuf wire format). - * @return {!Uint8Array} - */ -proto.usage.v1.ReconcileUsageWithLedgerRequest.prototype.serializeBinary = function() { - var writer = new jspb.BinaryWriter(); - proto.usage.v1.ReconcileUsageWithLedgerRequest.serializeBinaryToWriter(this, writer); - return writer.getResultBuffer(); -}; - - -/** - * Serializes the given message to binary data (in protobuf wire - * format), writing to the given BinaryWriter. - * @param {!proto.usage.v1.ReconcileUsageWithLedgerRequest} message - * @param {!jspb.BinaryWriter} writer - * @suppress {unusedLocalVariables} f is only used for nested messages - */ -proto.usage.v1.ReconcileUsageWithLedgerRequest.serializeBinaryToWriter = function(message, writer) { - var f = undefined; - f = message.getFrom(); - if (f != null) { - writer.writeMessage( - 1, - f, - google_protobuf_timestamp_pb.Timestamp.serializeBinaryToWriter - ); - } - f = message.getTo(); - if (f != null) { - writer.writeMessage( - 2, - f, - google_protobuf_timestamp_pb.Timestamp.serializeBinaryToWriter - ); - } -}; - - -/** - * optional google.protobuf.Timestamp from = 1; - * @return {?proto.google.protobuf.Timestamp} - */ -proto.usage.v1.ReconcileUsageWithLedgerRequest.prototype.getFrom = function() { - return /** @type{?proto.google.protobuf.Timestamp} */ ( - jspb.Message.getWrapperField(this, google_protobuf_timestamp_pb.Timestamp, 1)); -}; - - -/** - * @param {?proto.google.protobuf.Timestamp|undefined} value - * @return {!proto.usage.v1.ReconcileUsageWithLedgerRequest} returns this -*/ -proto.usage.v1.ReconcileUsageWithLedgerRequest.prototype.setFrom = function(value) { - return jspb.Message.setWrapperField(this, 1, value); -}; - - -/** - * Clears the message field making it undefined. - * @return {!proto.usage.v1.ReconcileUsageWithLedgerRequest} returns this - */ -proto.usage.v1.ReconcileUsageWithLedgerRequest.prototype.clearFrom = function() { - return this.setFrom(undefined); -}; - - -/** - * Returns whether this field is set. - * @return {boolean} - */ -proto.usage.v1.ReconcileUsageWithLedgerRequest.prototype.hasFrom = function() { - return jspb.Message.getField(this, 1) != null; -}; - - -/** - * optional google.protobuf.Timestamp to = 2; - * @return {?proto.google.protobuf.Timestamp} - */ -proto.usage.v1.ReconcileUsageWithLedgerRequest.prototype.getTo = function() { - return /** @type{?proto.google.protobuf.Timestamp} */ ( - jspb.Message.getWrapperField(this, google_protobuf_timestamp_pb.Timestamp, 2)); -}; - - -/** - * @param {?proto.google.protobuf.Timestamp|undefined} value - * @return {!proto.usage.v1.ReconcileUsageWithLedgerRequest} returns this -*/ -proto.usage.v1.ReconcileUsageWithLedgerRequest.prototype.setTo = function(value) { - return jspb.Message.setWrapperField(this, 2, value); -}; - - -/** - * Clears the message field making it undefined. - * @return {!proto.usage.v1.ReconcileUsageWithLedgerRequest} returns this - */ -proto.usage.v1.ReconcileUsageWithLedgerRequest.prototype.clearTo = function() { - return this.setTo(undefined); -}; - - -/** - * Returns whether this field is set. - * @return {boolean} - */ -proto.usage.v1.ReconcileUsageWithLedgerRequest.prototype.hasTo = function() { - return jspb.Message.getField(this, 2) != null; -}; - - - - - -if (jspb.Message.GENERATE_TO_OBJECT) { -/** - * Creates an object representation of this proto. - * Field names that are reserved in JavaScript and will be renamed to pb_name. - * Optional fields that are not set will be set to undefined. - * To access a reserved field use, foo.pb_, eg, foo.pb_default. - * For the list of reserved names please see: - * net/proto2/compiler/js/internal/generator.cc#kKeyword. - * @param {boolean=} opt_includeInstance Deprecated. whether to include the - * JSPB instance for transitional soy proto support: - * http://goto/soy-param-migration - * @return {!Object} - */ -proto.usage.v1.ReconcileUsageWithLedgerResponse.prototype.toObject = function(opt_includeInstance) { - return proto.usage.v1.ReconcileUsageWithLedgerResponse.toObject(opt_includeInstance, this); -}; - - -/** - * Static version of the {@see toObject} method. - * @param {boolean|undefined} includeInstance Deprecated. Whether to include - * the JSPB instance for transitional soy proto support: - * http://goto/soy-param-migration - * @param {!proto.usage.v1.ReconcileUsageWithLedgerResponse} msg The msg instance to transform. - * @return {!Object} - * @suppress {unusedLocalVariables} f is only used for nested messages - */ -proto.usage.v1.ReconcileUsageWithLedgerResponse.toObject = function(includeInstance, msg) { - var f, obj = { - - }; - - if (includeInstance) { - obj.$jspbMessageInstance = msg; - } - return obj; -}; -} - - -/** - * Deserializes binary data (in protobuf wire format). - * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.usage.v1.ReconcileUsageWithLedgerResponse} - */ -proto.usage.v1.ReconcileUsageWithLedgerResponse.deserializeBinary = function(bytes) { - var reader = new jspb.BinaryReader(bytes); - var msg = new proto.usage.v1.ReconcileUsageWithLedgerResponse; - return proto.usage.v1.ReconcileUsageWithLedgerResponse.deserializeBinaryFromReader(msg, reader); -}; - - -/** - * Deserializes binary data (in protobuf wire format) from the - * given reader into the given message object. - * @param {!proto.usage.v1.ReconcileUsageWithLedgerResponse} msg The message object to deserialize into. - * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.usage.v1.ReconcileUsageWithLedgerResponse} - */ -proto.usage.v1.ReconcileUsageWithLedgerResponse.deserializeBinaryFromReader = function(msg, reader) { - while (reader.nextField()) { - if (reader.isEndGroup()) { - break; - } - var field = reader.getFieldNumber(); - switch (field) { - default: - reader.skipField(); - break; - } - } - return msg; -}; - - -/** - * Serializes the message to binary data (in protobuf wire format). - * @return {!Uint8Array} - */ -proto.usage.v1.ReconcileUsageWithLedgerResponse.prototype.serializeBinary = function() { - var writer = new jspb.BinaryWriter(); - proto.usage.v1.ReconcileUsageWithLedgerResponse.serializeBinaryToWriter(this, writer); - return writer.getResultBuffer(); -}; - - -/** - * Serializes the given message to binary data (in protobuf wire - * format), writing to the given BinaryWriter. - * @param {!proto.usage.v1.ReconcileUsageWithLedgerResponse} message - * @param {!jspb.BinaryWriter} writer - * @suppress {unusedLocalVariables} f is only used for nested messages - */ -proto.usage.v1.ReconcileUsageWithLedgerResponse.serializeBinaryToWriter = function(message, writer) { - var f = undefined; -}; - - - - - -if (jspb.Message.GENERATE_TO_OBJECT) { -/** - * Creates an object representation of this proto. - * Field names that are reserved in JavaScript and will be renamed to pb_name. - * Optional fields that are not set will be set to undefined. - * To access a reserved field use, foo.pb_, eg, foo.pb_default. - * For the list of reserved names please see: - * net/proto2/compiler/js/internal/generator.cc#kKeyword. - * @param {boolean=} opt_includeInstance Deprecated. whether to include the - * JSPB instance for transitional soy proto support: - * http://goto/soy-param-migration - * @return {!Object} - */ -proto.usage.v1.PaginatedRequest.prototype.toObject = function(opt_includeInstance) { - return proto.usage.v1.PaginatedRequest.toObject(opt_includeInstance, this); -}; - - -/** - * Static version of the {@see toObject} method. - * @param {boolean|undefined} includeInstance Deprecated. Whether to include - * the JSPB instance for transitional soy proto support: - * http://goto/soy-param-migration - * @param {!proto.usage.v1.PaginatedRequest} msg The msg instance to transform. - * @return {!Object} - * @suppress {unusedLocalVariables} f is only used for nested messages - */ -proto.usage.v1.PaginatedRequest.toObject = function(includeInstance, msg) { - var f, obj = { - perPage: jspb.Message.getFieldWithDefault(msg, 1, 0), - page: jspb.Message.getFieldWithDefault(msg, 2, 0) - }; - - if (includeInstance) { - obj.$jspbMessageInstance = msg; - } - return obj; -}; -} - - -/** - * Deserializes binary data (in protobuf wire format). - * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.usage.v1.PaginatedRequest} - */ -proto.usage.v1.PaginatedRequest.deserializeBinary = function(bytes) { - var reader = new jspb.BinaryReader(bytes); - var msg = new proto.usage.v1.PaginatedRequest; - return proto.usage.v1.PaginatedRequest.deserializeBinaryFromReader(msg, reader); -}; - - -/** - * Deserializes binary data (in protobuf wire format) from the - * given reader into the given message object. - * @param {!proto.usage.v1.PaginatedRequest} msg The message object to deserialize into. - * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.usage.v1.PaginatedRequest} - */ -proto.usage.v1.PaginatedRequest.deserializeBinaryFromReader = function(msg, reader) { - while (reader.nextField()) { - if (reader.isEndGroup()) { - break; - } - var field = reader.getFieldNumber(); - switch (field) { - case 1: - var value = /** @type {number} */ (reader.readInt64()); - msg.setPerPage(value); - break; - case 2: - var value = /** @type {number} */ (reader.readInt64()); - msg.setPage(value); - break; - default: - reader.skipField(); - break; - } - } - return msg; -}; - - -/** - * Serializes the message to binary data (in protobuf wire format). - * @return {!Uint8Array} - */ -proto.usage.v1.PaginatedRequest.prototype.serializeBinary = function() { - var writer = new jspb.BinaryWriter(); - proto.usage.v1.PaginatedRequest.serializeBinaryToWriter(this, writer); - return writer.getResultBuffer(); -}; - - -/** - * Serializes the given message to binary data (in protobuf wire - * format), writing to the given BinaryWriter. - * @param {!proto.usage.v1.PaginatedRequest} message - * @param {!jspb.BinaryWriter} writer - * @suppress {unusedLocalVariables} f is only used for nested messages - */ -proto.usage.v1.PaginatedRequest.serializeBinaryToWriter = function(message, writer) { - var f = undefined; - f = message.getPerPage(); - if (f !== 0) { - writer.writeInt64( - 1, - f - ); - } - f = message.getPage(); - if (f !== 0) { - writer.writeInt64( - 2, - f - ); - } -}; - - -/** - * optional int64 per_page = 1; - * @return {number} - */ -proto.usage.v1.PaginatedRequest.prototype.getPerPage = function() { - return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 1, 0)); -}; - - -/** - * @param {number} value - * @return {!proto.usage.v1.PaginatedRequest} returns this - */ -proto.usage.v1.PaginatedRequest.prototype.setPerPage = function(value) { - return jspb.Message.setProto3IntField(this, 1, value); -}; - - -/** - * optional int64 page = 2; - * @return {number} - */ -proto.usage.v1.PaginatedRequest.prototype.getPage = function() { - return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 2, 0)); -}; - - -/** - * @param {number} value - * @return {!proto.usage.v1.PaginatedRequest} returns this - */ -proto.usage.v1.PaginatedRequest.prototype.setPage = function(value) { - return jspb.Message.setProto3IntField(this, 2, value); -}; - - - - - -if (jspb.Message.GENERATE_TO_OBJECT) { -/** - * Creates an object representation of this proto. - * Field names that are reserved in JavaScript and will be renamed to pb_name. - * Optional fields that are not set will be set to undefined. - * To access a reserved field use, foo.pb_, eg, foo.pb_default. - * For the list of reserved names please see: - * net/proto2/compiler/js/internal/generator.cc#kKeyword. - * @param {boolean=} opt_includeInstance Deprecated. whether to include the - * JSPB instance for transitional soy proto support: - * http://goto/soy-param-migration - * @return {!Object} - */ -proto.usage.v1.PaginatedResponse.prototype.toObject = function(opt_includeInstance) { - return proto.usage.v1.PaginatedResponse.toObject(opt_includeInstance, this); -}; - - -/** - * Static version of the {@see toObject} method. - * @param {boolean|undefined} includeInstance Deprecated. Whether to include - * the JSPB instance for transitional soy proto support: - * http://goto/soy-param-migration - * @param {!proto.usage.v1.PaginatedResponse} msg The msg instance to transform. - * @return {!Object} - * @suppress {unusedLocalVariables} f is only used for nested messages - */ -proto.usage.v1.PaginatedResponse.toObject = function(includeInstance, msg) { - var f, obj = { - perPage: jspb.Message.getFieldWithDefault(msg, 2, 0), - totalPages: jspb.Message.getFieldWithDefault(msg, 3, 0), - total: jspb.Message.getFieldWithDefault(msg, 4, 0), - page: jspb.Message.getFieldWithDefault(msg, 5, 0) - }; - - if (includeInstance) { - obj.$jspbMessageInstance = msg; - } - return obj; -}; -} - - -/** - * Deserializes binary data (in protobuf wire format). - * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.usage.v1.PaginatedResponse} - */ -proto.usage.v1.PaginatedResponse.deserializeBinary = function(bytes) { - var reader = new jspb.BinaryReader(bytes); - var msg = new proto.usage.v1.PaginatedResponse; - return proto.usage.v1.PaginatedResponse.deserializeBinaryFromReader(msg, reader); -}; - - -/** - * Deserializes binary data (in protobuf wire format) from the - * given reader into the given message object. - * @param {!proto.usage.v1.PaginatedResponse} msg The message object to deserialize into. - * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.usage.v1.PaginatedResponse} - */ -proto.usage.v1.PaginatedResponse.deserializeBinaryFromReader = function(msg, reader) { - while (reader.nextField()) { - if (reader.isEndGroup()) { - break; - } - var field = reader.getFieldNumber(); - switch (field) { - case 2: - var value = /** @type {number} */ (reader.readInt64()); - msg.setPerPage(value); - break; - case 3: - var value = /** @type {number} */ (reader.readInt64()); - msg.setTotalPages(value); - break; - case 4: - var value = /** @type {number} */ (reader.readInt64()); - msg.setTotal(value); - break; - case 5: - var value = /** @type {number} */ (reader.readInt64()); - msg.setPage(value); - break; - default: - reader.skipField(); - break; - } - } - return msg; -}; - - -/** - * Serializes the message to binary data (in protobuf wire format). - * @return {!Uint8Array} - */ -proto.usage.v1.PaginatedResponse.prototype.serializeBinary = function() { - var writer = new jspb.BinaryWriter(); - proto.usage.v1.PaginatedResponse.serializeBinaryToWriter(this, writer); - return writer.getResultBuffer(); -}; - - -/** - * Serializes the given message to binary data (in protobuf wire - * format), writing to the given BinaryWriter. - * @param {!proto.usage.v1.PaginatedResponse} message - * @param {!jspb.BinaryWriter} writer - * @suppress {unusedLocalVariables} f is only used for nested messages - */ -proto.usage.v1.PaginatedResponse.serializeBinaryToWriter = function(message, writer) { - var f = undefined; - f = message.getPerPage(); - if (f !== 0) { - writer.writeInt64( - 2, - f - ); - } - f = message.getTotalPages(); - if (f !== 0) { - writer.writeInt64( - 3, - f - ); - } - f = message.getTotal(); - if (f !== 0) { - writer.writeInt64( - 4, - f - ); - } - f = message.getPage(); - if (f !== 0) { - writer.writeInt64( - 5, - f - ); - } -}; - - -/** - * optional int64 per_page = 2; - * @return {number} - */ -proto.usage.v1.PaginatedResponse.prototype.getPerPage = function() { - return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 2, 0)); -}; - - -/** - * @param {number} value - * @return {!proto.usage.v1.PaginatedResponse} returns this - */ -proto.usage.v1.PaginatedResponse.prototype.setPerPage = function(value) { - return jspb.Message.setProto3IntField(this, 2, value); -}; - - -/** - * optional int64 total_pages = 3; - * @return {number} - */ -proto.usage.v1.PaginatedResponse.prototype.getTotalPages = function() { - return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 3, 0)); -}; - - -/** - * @param {number} value - * @return {!proto.usage.v1.PaginatedResponse} returns this - */ -proto.usage.v1.PaginatedResponse.prototype.setTotalPages = function(value) { - return jspb.Message.setProto3IntField(this, 3, value); -}; - - -/** - * optional int64 total = 4; - * @return {number} - */ -proto.usage.v1.PaginatedResponse.prototype.getTotal = function() { - return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 4, 0)); -}; - - -/** - * @param {number} value - * @return {!proto.usage.v1.PaginatedResponse} returns this - */ -proto.usage.v1.PaginatedResponse.prototype.setTotal = function(value) { - return jspb.Message.setProto3IntField(this, 4, value); -}; - - -/** - * optional int64 page = 5; - * @return {number} - */ -proto.usage.v1.PaginatedResponse.prototype.getPage = function() { - return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 5, 0)); -}; - - -/** - * @param {number} value - * @return {!proto.usage.v1.PaginatedResponse} returns this - */ -proto.usage.v1.PaginatedResponse.prototype.setPage = function(value) { - return jspb.Message.setProto3IntField(this, 5, value); -}; - - - - - -if (jspb.Message.GENERATE_TO_OBJECT) { -/** - * Creates an object representation of this proto. - * Field names that are reserved in JavaScript and will be renamed to pb_name. - * Optional fields that are not set will be set to undefined. - * To access a reserved field use, foo.pb_, eg, foo.pb_default. - * For the list of reserved names please see: - * net/proto2/compiler/js/internal/generator.cc#kKeyword. - * @param {boolean=} opt_includeInstance Deprecated. whether to include the - * JSPB instance for transitional soy proto support: - * http://goto/soy-param-migration - * @return {!Object} - */ -proto.usage.v1.ListUsageRequest.prototype.toObject = function(opt_includeInstance) { - return proto.usage.v1.ListUsageRequest.toObject(opt_includeInstance, this); -}; - - -/** - * Static version of the {@see toObject} method. - * @param {boolean|undefined} includeInstance Deprecated. Whether to include - * the JSPB instance for transitional soy proto support: - * http://goto/soy-param-migration - * @param {!proto.usage.v1.ListUsageRequest} msg The msg instance to transform. - * @return {!Object} - * @suppress {unusedLocalVariables} f is only used for nested messages - */ -proto.usage.v1.ListUsageRequest.toObject = function(includeInstance, msg) { - var f, obj = { - attributionId: jspb.Message.getFieldWithDefault(msg, 1, ""), - from: (f = msg.getFrom()) && google_protobuf_timestamp_pb.Timestamp.toObject(includeInstance, f), - to: (f = msg.getTo()) && google_protobuf_timestamp_pb.Timestamp.toObject(includeInstance, f), - order: jspb.Message.getFieldWithDefault(msg, 4, 0), - pagination: (f = msg.getPagination()) && proto.usage.v1.PaginatedRequest.toObject(includeInstance, f) - }; - - if (includeInstance) { - obj.$jspbMessageInstance = msg; - } - return obj; -}; -} - - -/** - * Deserializes binary data (in protobuf wire format). - * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.usage.v1.ListUsageRequest} - */ -proto.usage.v1.ListUsageRequest.deserializeBinary = function(bytes) { - var reader = new jspb.BinaryReader(bytes); - var msg = new proto.usage.v1.ListUsageRequest; - return proto.usage.v1.ListUsageRequest.deserializeBinaryFromReader(msg, reader); -}; - - -/** - * Deserializes binary data (in protobuf wire format) from the - * given reader into the given message object. - * @param {!proto.usage.v1.ListUsageRequest} msg The message object to deserialize into. - * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.usage.v1.ListUsageRequest} - */ -proto.usage.v1.ListUsageRequest.deserializeBinaryFromReader = function(msg, reader) { - while (reader.nextField()) { - if (reader.isEndGroup()) { - break; - } - var field = reader.getFieldNumber(); - switch (field) { - case 1: - var value = /** @type {string} */ (reader.readString()); - msg.setAttributionId(value); - break; - case 2: - var value = new google_protobuf_timestamp_pb.Timestamp; - reader.readMessage(value,google_protobuf_timestamp_pb.Timestamp.deserializeBinaryFromReader); - msg.setFrom(value); - break; - case 3: - var value = new google_protobuf_timestamp_pb.Timestamp; - reader.readMessage(value,google_protobuf_timestamp_pb.Timestamp.deserializeBinaryFromReader); - msg.setTo(value); - break; - case 4: - var value = /** @type {!proto.usage.v1.ListUsageRequest.Ordering} */ (reader.readEnum()); - msg.setOrder(value); - break; - case 5: - var value = new proto.usage.v1.PaginatedRequest; - reader.readMessage(value,proto.usage.v1.PaginatedRequest.deserializeBinaryFromReader); - msg.setPagination(value); - break; - default: - reader.skipField(); - break; - } - } - return msg; -}; - - -/** - * Serializes the message to binary data (in protobuf wire format). - * @return {!Uint8Array} - */ -proto.usage.v1.ListUsageRequest.prototype.serializeBinary = function() { - var writer = new jspb.BinaryWriter(); - proto.usage.v1.ListUsageRequest.serializeBinaryToWriter(this, writer); - return writer.getResultBuffer(); -}; - - -/** - * Serializes the given message to binary data (in protobuf wire - * format), writing to the given BinaryWriter. - * @param {!proto.usage.v1.ListUsageRequest} message - * @param {!jspb.BinaryWriter} writer - * @suppress {unusedLocalVariables} f is only used for nested messages - */ -proto.usage.v1.ListUsageRequest.serializeBinaryToWriter = function(message, writer) { - var f = undefined; - f = message.getAttributionId(); - if (f.length > 0) { - writer.writeString( - 1, - f - ); - } - f = message.getFrom(); - if (f != null) { - writer.writeMessage( - 2, - f, - google_protobuf_timestamp_pb.Timestamp.serializeBinaryToWriter - ); - } - f = message.getTo(); - if (f != null) { - writer.writeMessage( - 3, - f, - google_protobuf_timestamp_pb.Timestamp.serializeBinaryToWriter - ); - } - f = message.getOrder(); - if (f !== 0.0) { - writer.writeEnum( - 4, - f - ); - } - f = message.getPagination(); - if (f != null) { - writer.writeMessage( - 5, - f, - proto.usage.v1.PaginatedRequest.serializeBinaryToWriter - ); - } -}; - - -/** - * @enum {number} - */ -proto.usage.v1.ListUsageRequest.Ordering = { - ORDERING_DESCENDING: 0, - ORDERING_ASCENDING: 1 -}; - -/** - * optional string attribution_id = 1; - * @return {string} - */ -proto.usage.v1.ListUsageRequest.prototype.getAttributionId = function() { - return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); -}; - - -/** - * @param {string} value - * @return {!proto.usage.v1.ListUsageRequest} returns this - */ -proto.usage.v1.ListUsageRequest.prototype.setAttributionId = function(value) { - return jspb.Message.setProto3StringField(this, 1, value); -}; - - -/** - * optional google.protobuf.Timestamp from = 2; - * @return {?proto.google.protobuf.Timestamp} - */ -proto.usage.v1.ListUsageRequest.prototype.getFrom = function() { - return /** @type{?proto.google.protobuf.Timestamp} */ ( - jspb.Message.getWrapperField(this, google_protobuf_timestamp_pb.Timestamp, 2)); -}; - - -/** - * @param {?proto.google.protobuf.Timestamp|undefined} value - * @return {!proto.usage.v1.ListUsageRequest} returns this -*/ -proto.usage.v1.ListUsageRequest.prototype.setFrom = function(value) { - return jspb.Message.setWrapperField(this, 2, value); -}; - - -/** - * Clears the message field making it undefined. - * @return {!proto.usage.v1.ListUsageRequest} returns this - */ -proto.usage.v1.ListUsageRequest.prototype.clearFrom = function() { - return this.setFrom(undefined); -}; - - -/** - * Returns whether this field is set. - * @return {boolean} - */ -proto.usage.v1.ListUsageRequest.prototype.hasFrom = function() { - return jspb.Message.getField(this, 2) != null; -}; - - -/** - * optional google.protobuf.Timestamp to = 3; - * @return {?proto.google.protobuf.Timestamp} - */ -proto.usage.v1.ListUsageRequest.prototype.getTo = function() { - return /** @type{?proto.google.protobuf.Timestamp} */ ( - jspb.Message.getWrapperField(this, google_protobuf_timestamp_pb.Timestamp, 3)); -}; - - -/** - * @param {?proto.google.protobuf.Timestamp|undefined} value - * @return {!proto.usage.v1.ListUsageRequest} returns this -*/ -proto.usage.v1.ListUsageRequest.prototype.setTo = function(value) { - return jspb.Message.setWrapperField(this, 3, value); -}; - - -/** - * Clears the message field making it undefined. - * @return {!proto.usage.v1.ListUsageRequest} returns this - */ -proto.usage.v1.ListUsageRequest.prototype.clearTo = function() { - return this.setTo(undefined); -}; - - -/** - * Returns whether this field is set. - * @return {boolean} - */ -proto.usage.v1.ListUsageRequest.prototype.hasTo = function() { - return jspb.Message.getField(this, 3) != null; -}; - - -/** - * optional Ordering order = 4; - * @return {!proto.usage.v1.ListUsageRequest.Ordering} - */ -proto.usage.v1.ListUsageRequest.prototype.getOrder = function() { - return /** @type {!proto.usage.v1.ListUsageRequest.Ordering} */ (jspb.Message.getFieldWithDefault(this, 4, 0)); -}; - - -/** - * @param {!proto.usage.v1.ListUsageRequest.Ordering} value - * @return {!proto.usage.v1.ListUsageRequest} returns this - */ -proto.usage.v1.ListUsageRequest.prototype.setOrder = function(value) { - return jspb.Message.setProto3EnumField(this, 4, value); -}; - - -/** - * optional PaginatedRequest pagination = 5; - * @return {?proto.usage.v1.PaginatedRequest} - */ -proto.usage.v1.ListUsageRequest.prototype.getPagination = function() { - return /** @type{?proto.usage.v1.PaginatedRequest} */ ( - jspb.Message.getWrapperField(this, proto.usage.v1.PaginatedRequest, 5)); -}; - - -/** - * @param {?proto.usage.v1.PaginatedRequest|undefined} value - * @return {!proto.usage.v1.ListUsageRequest} returns this -*/ -proto.usage.v1.ListUsageRequest.prototype.setPagination = function(value) { - return jspb.Message.setWrapperField(this, 5, value); -}; - - -/** - * Clears the message field making it undefined. - * @return {!proto.usage.v1.ListUsageRequest} returns this - */ -proto.usage.v1.ListUsageRequest.prototype.clearPagination = function() { - return this.setPagination(undefined); -}; - - -/** - * Returns whether this field is set. - * @return {boolean} - */ -proto.usage.v1.ListUsageRequest.prototype.hasPagination = function() { - return jspb.Message.getField(this, 5) != null; -}; - - - -/** - * List of repeated fields within this message type. - * @private {!Array} - * @const - */ -proto.usage.v1.ListUsageResponse.repeatedFields_ = [1]; - - - -if (jspb.Message.GENERATE_TO_OBJECT) { -/** - * Creates an object representation of this proto. - * Field names that are reserved in JavaScript and will be renamed to pb_name. - * Optional fields that are not set will be set to undefined. - * To access a reserved field use, foo.pb_, eg, foo.pb_default. - * For the list of reserved names please see: - * net/proto2/compiler/js/internal/generator.cc#kKeyword. - * @param {boolean=} opt_includeInstance Deprecated. whether to include the - * JSPB instance for transitional soy proto support: - * http://goto/soy-param-migration - * @return {!Object} - */ -proto.usage.v1.ListUsageResponse.prototype.toObject = function(opt_includeInstance) { - return proto.usage.v1.ListUsageResponse.toObject(opt_includeInstance, this); -}; - - -/** - * Static version of the {@see toObject} method. - * @param {boolean|undefined} includeInstance Deprecated. Whether to include - * the JSPB instance for transitional soy proto support: - * http://goto/soy-param-migration - * @param {!proto.usage.v1.ListUsageResponse} msg The msg instance to transform. - * @return {!Object} - * @suppress {unusedLocalVariables} f is only used for nested messages - */ -proto.usage.v1.ListUsageResponse.toObject = function(includeInstance, msg) { - var f, obj = { - usageEntriesList: jspb.Message.toObjectList(msg.getUsageEntriesList(), - proto.usage.v1.Usage.toObject, includeInstance), - pagination: (f = msg.getPagination()) && proto.usage.v1.PaginatedResponse.toObject(includeInstance, f), - creditBalanceAtStart: jspb.Message.getFloatingPointFieldWithDefault(msg, 3, 0.0), - creditBalanceAtEnd: jspb.Message.getFloatingPointFieldWithDefault(msg, 4, 0.0) - }; - - if (includeInstance) { - obj.$jspbMessageInstance = msg; - } - return obj; -}; -} - - -/** - * Deserializes binary data (in protobuf wire format). - * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.usage.v1.ListUsageResponse} - */ -proto.usage.v1.ListUsageResponse.deserializeBinary = function(bytes) { - var reader = new jspb.BinaryReader(bytes); - var msg = new proto.usage.v1.ListUsageResponse; - return proto.usage.v1.ListUsageResponse.deserializeBinaryFromReader(msg, reader); -}; - - -/** - * Deserializes binary data (in protobuf wire format) from the - * given reader into the given message object. - * @param {!proto.usage.v1.ListUsageResponse} msg The message object to deserialize into. - * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.usage.v1.ListUsageResponse} - */ -proto.usage.v1.ListUsageResponse.deserializeBinaryFromReader = function(msg, reader) { - while (reader.nextField()) { - if (reader.isEndGroup()) { - break; - } - var field = reader.getFieldNumber(); - switch (field) { - case 1: - var value = new proto.usage.v1.Usage; - reader.readMessage(value,proto.usage.v1.Usage.deserializeBinaryFromReader); - msg.addUsageEntries(value); - break; - case 2: - var value = new proto.usage.v1.PaginatedResponse; - reader.readMessage(value,proto.usage.v1.PaginatedResponse.deserializeBinaryFromReader); - msg.setPagination(value); - break; - case 3: - var value = /** @type {number} */ (reader.readDouble()); - msg.setCreditBalanceAtStart(value); - break; - case 4: - var value = /** @type {number} */ (reader.readDouble()); - msg.setCreditBalanceAtEnd(value); - break; - default: - reader.skipField(); - break; - } - } - return msg; -}; - - -/** - * Serializes the message to binary data (in protobuf wire format). - * @return {!Uint8Array} - */ -proto.usage.v1.ListUsageResponse.prototype.serializeBinary = function() { - var writer = new jspb.BinaryWriter(); - proto.usage.v1.ListUsageResponse.serializeBinaryToWriter(this, writer); - return writer.getResultBuffer(); -}; - - -/** - * Serializes the given message to binary data (in protobuf wire - * format), writing to the given BinaryWriter. - * @param {!proto.usage.v1.ListUsageResponse} message - * @param {!jspb.BinaryWriter} writer - * @suppress {unusedLocalVariables} f is only used for nested messages - */ -proto.usage.v1.ListUsageResponse.serializeBinaryToWriter = function(message, writer) { - var f = undefined; - f = message.getUsageEntriesList(); - if (f.length > 0) { - writer.writeRepeatedMessage( - 1, - f, - proto.usage.v1.Usage.serializeBinaryToWriter - ); - } - f = message.getPagination(); - if (f != null) { - writer.writeMessage( - 2, - f, - proto.usage.v1.PaginatedResponse.serializeBinaryToWriter - ); - } - f = message.getCreditBalanceAtStart(); - if (f !== 0.0) { - writer.writeDouble( - 3, - f - ); - } - f = message.getCreditBalanceAtEnd(); - if (f !== 0.0) { - writer.writeDouble( - 4, - f - ); - } -}; - - -/** - * repeated Usage usage_entries = 1; - * @return {!Array} - */ -proto.usage.v1.ListUsageResponse.prototype.getUsageEntriesList = function() { - return /** @type{!Array} */ ( - jspb.Message.getRepeatedWrapperField(this, proto.usage.v1.Usage, 1)); -}; - - -/** - * @param {!Array} value - * @return {!proto.usage.v1.ListUsageResponse} returns this -*/ -proto.usage.v1.ListUsageResponse.prototype.setUsageEntriesList = function(value) { - return jspb.Message.setRepeatedWrapperField(this, 1, value); -}; - - -/** - * @param {!proto.usage.v1.Usage=} opt_value - * @param {number=} opt_index - * @return {!proto.usage.v1.Usage} - */ -proto.usage.v1.ListUsageResponse.prototype.addUsageEntries = function(opt_value, opt_index) { - return jspb.Message.addToRepeatedWrapperField(this, 1, opt_value, proto.usage.v1.Usage, opt_index); -}; - - -/** - * Clears the list making it empty but non-null. - * @return {!proto.usage.v1.ListUsageResponse} returns this - */ -proto.usage.v1.ListUsageResponse.prototype.clearUsageEntriesList = function() { - return this.setUsageEntriesList([]); -}; - - -/** - * optional PaginatedResponse pagination = 2; - * @return {?proto.usage.v1.PaginatedResponse} - */ -proto.usage.v1.ListUsageResponse.prototype.getPagination = function() { - return /** @type{?proto.usage.v1.PaginatedResponse} */ ( - jspb.Message.getWrapperField(this, proto.usage.v1.PaginatedResponse, 2)); -}; - - -/** - * @param {?proto.usage.v1.PaginatedResponse|undefined} value - * @return {!proto.usage.v1.ListUsageResponse} returns this -*/ -proto.usage.v1.ListUsageResponse.prototype.setPagination = function(value) { - return jspb.Message.setWrapperField(this, 2, value); -}; - - -/** - * Clears the message field making it undefined. - * @return {!proto.usage.v1.ListUsageResponse} returns this - */ -proto.usage.v1.ListUsageResponse.prototype.clearPagination = function() { - return this.setPagination(undefined); -}; - - -/** - * Returns whether this field is set. - * @return {boolean} - */ -proto.usage.v1.ListUsageResponse.prototype.hasPagination = function() { - return jspb.Message.getField(this, 2) != null; -}; - - -/** - * optional double credit_balance_at_start = 3; - * @return {number} - */ -proto.usage.v1.ListUsageResponse.prototype.getCreditBalanceAtStart = function() { - return /** @type {number} */ (jspb.Message.getFloatingPointFieldWithDefault(this, 3, 0.0)); -}; - - -/** - * @param {number} value - * @return {!proto.usage.v1.ListUsageResponse} returns this - */ -proto.usage.v1.ListUsageResponse.prototype.setCreditBalanceAtStart = function(value) { - return jspb.Message.setProto3FloatField(this, 3, value); -}; - - -/** - * optional double credit_balance_at_end = 4; - * @return {number} - */ -proto.usage.v1.ListUsageResponse.prototype.getCreditBalanceAtEnd = function() { - return /** @type {number} */ (jspb.Message.getFloatingPointFieldWithDefault(this, 4, 0.0)); -}; - - -/** - * @param {number} value - * @return {!proto.usage.v1.ListUsageResponse} returns this - */ -proto.usage.v1.ListUsageResponse.prototype.setCreditBalanceAtEnd = function(value) { - return jspb.Message.setProto3FloatField(this, 4, value); -}; - - - - - -if (jspb.Message.GENERATE_TO_OBJECT) { -/** - * Creates an object representation of this proto. - * Field names that are reserved in JavaScript and will be renamed to pb_name. - * Optional fields that are not set will be set to undefined. - * To access a reserved field use, foo.pb_, eg, foo.pb_default. - * For the list of reserved names please see: - * net/proto2/compiler/js/internal/generator.cc#kKeyword. - * @param {boolean=} opt_includeInstance Deprecated. whether to include the - * JSPB instance for transitional soy proto support: - * http://goto/soy-param-migration - * @return {!Object} - */ -proto.usage.v1.Usage.prototype.toObject = function(opt_includeInstance) { - return proto.usage.v1.Usage.toObject(opt_includeInstance, this); -}; - - -/** - * Static version of the {@see toObject} method. - * @param {boolean|undefined} includeInstance Deprecated. Whether to include - * the JSPB instance for transitional soy proto support: - * http://goto/soy-param-migration - * @param {!proto.usage.v1.Usage} msg The msg instance to transform. - * @return {!Object} - * @suppress {unusedLocalVariables} f is only used for nested messages - */ -proto.usage.v1.Usage.toObject = function(includeInstance, msg) { - var f, obj = { - id: jspb.Message.getFieldWithDefault(msg, 1, ""), - attributionId: jspb.Message.getFieldWithDefault(msg, 2, ""), - description: jspb.Message.getFieldWithDefault(msg, 3, ""), - credits: jspb.Message.getFloatingPointFieldWithDefault(msg, 4, 0.0), - effectiveTime: (f = msg.getEffectiveTime()) && google_protobuf_timestamp_pb.Timestamp.toObject(includeInstance, f), - kind: jspb.Message.getFieldWithDefault(msg, 6, 0), - workspaceInstanceId: jspb.Message.getFieldWithDefault(msg, 7, ""), - draft: jspb.Message.getBooleanFieldWithDefault(msg, 8, false), - metadata: jspb.Message.getFieldWithDefault(msg, 9, "") - }; - - if (includeInstance) { - obj.$jspbMessageInstance = msg; - } - return obj; -}; -} - - -/** - * Deserializes binary data (in protobuf wire format). - * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.usage.v1.Usage} - */ -proto.usage.v1.Usage.deserializeBinary = function(bytes) { - var reader = new jspb.BinaryReader(bytes); - var msg = new proto.usage.v1.Usage; - return proto.usage.v1.Usage.deserializeBinaryFromReader(msg, reader); -}; - - -/** - * Deserializes binary data (in protobuf wire format) from the - * given reader into the given message object. - * @param {!proto.usage.v1.Usage} msg The message object to deserialize into. - * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.usage.v1.Usage} - */ -proto.usage.v1.Usage.deserializeBinaryFromReader = function(msg, reader) { - while (reader.nextField()) { - if (reader.isEndGroup()) { - break; - } - var field = reader.getFieldNumber(); - switch (field) { - case 1: - var value = /** @type {string} */ (reader.readString()); - msg.setId(value); - break; - case 2: - var value = /** @type {string} */ (reader.readString()); - msg.setAttributionId(value); - break; - case 3: - var value = /** @type {string} */ (reader.readString()); - msg.setDescription(value); - break; - case 4: - var value = /** @type {number} */ (reader.readDouble()); - msg.setCredits(value); - break; - case 5: - var value = new google_protobuf_timestamp_pb.Timestamp; - reader.readMessage(value,google_protobuf_timestamp_pb.Timestamp.deserializeBinaryFromReader); - msg.setEffectiveTime(value); - break; - case 6: - var value = /** @type {!proto.usage.v1.Usage.Kind} */ (reader.readEnum()); - msg.setKind(value); - break; - case 7: - var value = /** @type {string} */ (reader.readString()); - msg.setWorkspaceInstanceId(value); - break; - case 8: - var value = /** @type {boolean} */ (reader.readBool()); - msg.setDraft(value); - break; - case 9: - var value = /** @type {string} */ (reader.readString()); - msg.setMetadata(value); - break; - default: - reader.skipField(); - break; - } - } - return msg; -}; - - -/** - * Serializes the message to binary data (in protobuf wire format). - * @return {!Uint8Array} - */ -proto.usage.v1.Usage.prototype.serializeBinary = function() { - var writer = new jspb.BinaryWriter(); - proto.usage.v1.Usage.serializeBinaryToWriter(this, writer); - return writer.getResultBuffer(); -}; - - -/** - * Serializes the given message to binary data (in protobuf wire - * format), writing to the given BinaryWriter. - * @param {!proto.usage.v1.Usage} message - * @param {!jspb.BinaryWriter} writer - * @suppress {unusedLocalVariables} f is only used for nested messages - */ -proto.usage.v1.Usage.serializeBinaryToWriter = function(message, writer) { - var f = undefined; - f = message.getId(); - if (f.length > 0) { - writer.writeString( - 1, - f - ); - } - f = message.getAttributionId(); - if (f.length > 0) { - writer.writeString( - 2, - f - ); - } - f = message.getDescription(); - if (f.length > 0) { - writer.writeString( - 3, - f - ); - } - f = message.getCredits(); - if (f !== 0.0) { - writer.writeDouble( - 4, - f - ); - } - f = message.getEffectiveTime(); - if (f != null) { - writer.writeMessage( - 5, - f, - google_protobuf_timestamp_pb.Timestamp.serializeBinaryToWriter - ); - } - f = message.getKind(); - if (f !== 0.0) { - writer.writeEnum( - 6, - f - ); - } - f = message.getWorkspaceInstanceId(); - if (f.length > 0) { - writer.writeString( - 7, - f - ); - } - f = message.getDraft(); - if (f) { - writer.writeBool( - 8, - f - ); - } - f = message.getMetadata(); - if (f.length > 0) { - writer.writeString( - 9, - f - ); - } -}; - - -/** - * @enum {number} - */ -proto.usage.v1.Usage.Kind = { - KIND_WORKSPACE_INSTANCE: 0, - KIND_INVOICE: 1 -}; - -/** - * optional string id = 1; - * @return {string} - */ -proto.usage.v1.Usage.prototype.getId = function() { - return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); -}; - - -/** - * @param {string} value - * @return {!proto.usage.v1.Usage} returns this - */ -proto.usage.v1.Usage.prototype.setId = function(value) { - return jspb.Message.setProto3StringField(this, 1, value); -}; - - -/** - * optional string attribution_id = 2; - * @return {string} - */ -proto.usage.v1.Usage.prototype.getAttributionId = function() { - return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 2, "")); -}; - - -/** - * @param {string} value - * @return {!proto.usage.v1.Usage} returns this - */ -proto.usage.v1.Usage.prototype.setAttributionId = function(value) { - return jspb.Message.setProto3StringField(this, 2, value); -}; - - -/** - * optional string description = 3; - * @return {string} - */ -proto.usage.v1.Usage.prototype.getDescription = function() { - return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 3, "")); -}; - - -/** - * @param {string} value - * @return {!proto.usage.v1.Usage} returns this - */ -proto.usage.v1.Usage.prototype.setDescription = function(value) { - return jspb.Message.setProto3StringField(this, 3, value); -}; - - -/** - * optional double credits = 4; - * @return {number} - */ -proto.usage.v1.Usage.prototype.getCredits = function() { - return /** @type {number} */ (jspb.Message.getFloatingPointFieldWithDefault(this, 4, 0.0)); -}; - - -/** - * @param {number} value - * @return {!proto.usage.v1.Usage} returns this - */ -proto.usage.v1.Usage.prototype.setCredits = function(value) { - return jspb.Message.setProto3FloatField(this, 4, value); -}; - - -/** - * optional google.protobuf.Timestamp effective_time = 5; - * @return {?proto.google.protobuf.Timestamp} - */ -proto.usage.v1.Usage.prototype.getEffectiveTime = function() { - return /** @type{?proto.google.protobuf.Timestamp} */ ( - jspb.Message.getWrapperField(this, google_protobuf_timestamp_pb.Timestamp, 5)); -}; - - -/** - * @param {?proto.google.protobuf.Timestamp|undefined} value - * @return {!proto.usage.v1.Usage} returns this -*/ -proto.usage.v1.Usage.prototype.setEffectiveTime = function(value) { - return jspb.Message.setWrapperField(this, 5, value); -}; - - -/** - * Clears the message field making it undefined. - * @return {!proto.usage.v1.Usage} returns this - */ -proto.usage.v1.Usage.prototype.clearEffectiveTime = function() { - return this.setEffectiveTime(undefined); -}; - - -/** - * Returns whether this field is set. - * @return {boolean} - */ -proto.usage.v1.Usage.prototype.hasEffectiveTime = function() { - return jspb.Message.getField(this, 5) != null; -}; - - -/** - * optional Kind kind = 6; - * @return {!proto.usage.v1.Usage.Kind} - */ -proto.usage.v1.Usage.prototype.getKind = function() { - return /** @type {!proto.usage.v1.Usage.Kind} */ (jspb.Message.getFieldWithDefault(this, 6, 0)); -}; - - -/** - * @param {!proto.usage.v1.Usage.Kind} value - * @return {!proto.usage.v1.Usage} returns this - */ -proto.usage.v1.Usage.prototype.setKind = function(value) { - return jspb.Message.setProto3EnumField(this, 6, value); -}; - - -/** - * optional string workspace_instance_id = 7; - * @return {string} - */ -proto.usage.v1.Usage.prototype.getWorkspaceInstanceId = function() { - return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 7, "")); -}; - - -/** - * @param {string} value - * @return {!proto.usage.v1.Usage} returns this - */ -proto.usage.v1.Usage.prototype.setWorkspaceInstanceId = function(value) { - return jspb.Message.setProto3StringField(this, 7, value); -}; - - -/** - * optional bool draft = 8; - * @return {boolean} - */ -proto.usage.v1.Usage.prototype.getDraft = function() { - return /** @type {boolean} */ (jspb.Message.getBooleanFieldWithDefault(this, 8, false)); -}; - - -/** - * @param {boolean} value - * @return {!proto.usage.v1.Usage} returns this - */ -proto.usage.v1.Usage.prototype.setDraft = function(value) { - return jspb.Message.setProto3BooleanField(this, 8, value); -}; - - -/** - * optional string metadata = 9; - * @return {string} - */ -proto.usage.v1.Usage.prototype.getMetadata = function() { - return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 9, "")); -}; - - -/** - * @param {string} value - * @return {!proto.usage.v1.Usage} returns this - */ -proto.usage.v1.Usage.prototype.setMetadata = function(value) { - return jspb.Message.setProto3StringField(this, 9, value); -}; - - - - - -if (jspb.Message.GENERATE_TO_OBJECT) { -/** - * Creates an object representation of this proto. - * Field names that are reserved in JavaScript and will be renamed to pb_name. - * Optional fields that are not set will be set to undefined. - * To access a reserved field use, foo.pb_, eg, foo.pb_default. - * For the list of reserved names please see: - * net/proto2/compiler/js/internal/generator.cc#kKeyword. - * @param {boolean=} opt_includeInstance Deprecated. whether to include the - * JSPB instance for transitional soy proto support: - * http://goto/soy-param-migration - * @return {!Object} - */ -proto.usage.v1.SetCostCenterRequest.prototype.toObject = function(opt_includeInstance) { - return proto.usage.v1.SetCostCenterRequest.toObject(opt_includeInstance, this); -}; - - -/** - * Static version of the {@see toObject} method. - * @param {boolean|undefined} includeInstance Deprecated. Whether to include - * the JSPB instance for transitional soy proto support: - * http://goto/soy-param-migration - * @param {!proto.usage.v1.SetCostCenterRequest} msg The msg instance to transform. - * @return {!Object} - * @suppress {unusedLocalVariables} f is only used for nested messages - */ -proto.usage.v1.SetCostCenterRequest.toObject = function(includeInstance, msg) { - var f, obj = { - costCenter: (f = msg.getCostCenter()) && proto.usage.v1.CostCenter.toObject(includeInstance, f) - }; - - if (includeInstance) { - obj.$jspbMessageInstance = msg; - } - return obj; -}; -} - - -/** - * Deserializes binary data (in protobuf wire format). - * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.usage.v1.SetCostCenterRequest} - */ -proto.usage.v1.SetCostCenterRequest.deserializeBinary = function(bytes) { - var reader = new jspb.BinaryReader(bytes); - var msg = new proto.usage.v1.SetCostCenterRequest; - return proto.usage.v1.SetCostCenterRequest.deserializeBinaryFromReader(msg, reader); -}; - - -/** - * Deserializes binary data (in protobuf wire format) from the - * given reader into the given message object. - * @param {!proto.usage.v1.SetCostCenterRequest} msg The message object to deserialize into. - * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.usage.v1.SetCostCenterRequest} - */ -proto.usage.v1.SetCostCenterRequest.deserializeBinaryFromReader = function(msg, reader) { - while (reader.nextField()) { - if (reader.isEndGroup()) { - break; - } - var field = reader.getFieldNumber(); - switch (field) { - case 1: - var value = new proto.usage.v1.CostCenter; - reader.readMessage(value,proto.usage.v1.CostCenter.deserializeBinaryFromReader); - msg.setCostCenter(value); - break; - default: - reader.skipField(); - break; - } - } - return msg; -}; - - -/** - * Serializes the message to binary data (in protobuf wire format). - * @return {!Uint8Array} - */ -proto.usage.v1.SetCostCenterRequest.prototype.serializeBinary = function() { - var writer = new jspb.BinaryWriter(); - proto.usage.v1.SetCostCenterRequest.serializeBinaryToWriter(this, writer); - return writer.getResultBuffer(); -}; - - -/** - * Serializes the given message to binary data (in protobuf wire - * format), writing to the given BinaryWriter. - * @param {!proto.usage.v1.SetCostCenterRequest} message - * @param {!jspb.BinaryWriter} writer - * @suppress {unusedLocalVariables} f is only used for nested messages - */ -proto.usage.v1.SetCostCenterRequest.serializeBinaryToWriter = function(message, writer) { - var f = undefined; - f = message.getCostCenter(); - if (f != null) { - writer.writeMessage( - 1, - f, - proto.usage.v1.CostCenter.serializeBinaryToWriter - ); - } -}; - - -/** - * optional CostCenter cost_center = 1; - * @return {?proto.usage.v1.CostCenter} - */ -proto.usage.v1.SetCostCenterRequest.prototype.getCostCenter = function() { - return /** @type{?proto.usage.v1.CostCenter} */ ( - jspb.Message.getWrapperField(this, proto.usage.v1.CostCenter, 1)); -}; - - -/** - * @param {?proto.usage.v1.CostCenter|undefined} value - * @return {!proto.usage.v1.SetCostCenterRequest} returns this -*/ -proto.usage.v1.SetCostCenterRequest.prototype.setCostCenter = function(value) { - return jspb.Message.setWrapperField(this, 1, value); -}; - - -/** - * Clears the message field making it undefined. - * @return {!proto.usage.v1.SetCostCenterRequest} returns this - */ -proto.usage.v1.SetCostCenterRequest.prototype.clearCostCenter = function() { - return this.setCostCenter(undefined); -}; - - -/** - * Returns whether this field is set. - * @return {boolean} - */ -proto.usage.v1.SetCostCenterRequest.prototype.hasCostCenter = function() { - return jspb.Message.getField(this, 1) != null; -}; - - - - - -if (jspb.Message.GENERATE_TO_OBJECT) { -/** - * Creates an object representation of this proto. - * Field names that are reserved in JavaScript and will be renamed to pb_name. - * Optional fields that are not set will be set to undefined. - * To access a reserved field use, foo.pb_, eg, foo.pb_default. - * For the list of reserved names please see: - * net/proto2/compiler/js/internal/generator.cc#kKeyword. - * @param {boolean=} opt_includeInstance Deprecated. whether to include the - * JSPB instance for transitional soy proto support: - * http://goto/soy-param-migration - * @return {!Object} - */ -proto.usage.v1.SetCostCenterResponse.prototype.toObject = function(opt_includeInstance) { - return proto.usage.v1.SetCostCenterResponse.toObject(opt_includeInstance, this); -}; - - -/** - * Static version of the {@see toObject} method. - * @param {boolean|undefined} includeInstance Deprecated. Whether to include - * the JSPB instance for transitional soy proto support: - * http://goto/soy-param-migration - * @param {!proto.usage.v1.SetCostCenterResponse} msg The msg instance to transform. - * @return {!Object} - * @suppress {unusedLocalVariables} f is only used for nested messages - */ -proto.usage.v1.SetCostCenterResponse.toObject = function(includeInstance, msg) { - var f, obj = { - - }; - - if (includeInstance) { - obj.$jspbMessageInstance = msg; - } - return obj; -}; -} - - -/** - * Deserializes binary data (in protobuf wire format). - * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.usage.v1.SetCostCenterResponse} - */ -proto.usage.v1.SetCostCenterResponse.deserializeBinary = function(bytes) { - var reader = new jspb.BinaryReader(bytes); - var msg = new proto.usage.v1.SetCostCenterResponse; - return proto.usage.v1.SetCostCenterResponse.deserializeBinaryFromReader(msg, reader); -}; - - -/** - * Deserializes binary data (in protobuf wire format) from the - * given reader into the given message object. - * @param {!proto.usage.v1.SetCostCenterResponse} msg The message object to deserialize into. - * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.usage.v1.SetCostCenterResponse} - */ -proto.usage.v1.SetCostCenterResponse.deserializeBinaryFromReader = function(msg, reader) { - while (reader.nextField()) { - if (reader.isEndGroup()) { - break; - } - var field = reader.getFieldNumber(); - switch (field) { - default: - reader.skipField(); - break; - } - } - return msg; -}; - - -/** - * Serializes the message to binary data (in protobuf wire format). - * @return {!Uint8Array} - */ -proto.usage.v1.SetCostCenterResponse.prototype.serializeBinary = function() { - var writer = new jspb.BinaryWriter(); - proto.usage.v1.SetCostCenterResponse.serializeBinaryToWriter(this, writer); - return writer.getResultBuffer(); -}; - - -/** - * Serializes the given message to binary data (in protobuf wire - * format), writing to the given BinaryWriter. - * @param {!proto.usage.v1.SetCostCenterResponse} message - * @param {!jspb.BinaryWriter} writer - * @suppress {unusedLocalVariables} f is only used for nested messages - */ -proto.usage.v1.SetCostCenterResponse.serializeBinaryToWriter = function(message, writer) { - var f = undefined; -}; - - - - - -if (jspb.Message.GENERATE_TO_OBJECT) { -/** - * Creates an object representation of this proto. - * Field names that are reserved in JavaScript and will be renamed to pb_name. - * Optional fields that are not set will be set to undefined. - * To access a reserved field use, foo.pb_, eg, foo.pb_default. - * For the list of reserved names please see: - * net/proto2/compiler/js/internal/generator.cc#kKeyword. - * @param {boolean=} opt_includeInstance Deprecated. whether to include the - * JSPB instance for transitional soy proto support: - * http://goto/soy-param-migration - * @return {!Object} - */ -proto.usage.v1.GetCostCenterRequest.prototype.toObject = function(opt_includeInstance) { - return proto.usage.v1.GetCostCenterRequest.toObject(opt_includeInstance, this); -}; - - -/** - * Static version of the {@see toObject} method. - * @param {boolean|undefined} includeInstance Deprecated. Whether to include - * the JSPB instance for transitional soy proto support: - * http://goto/soy-param-migration - * @param {!proto.usage.v1.GetCostCenterRequest} msg The msg instance to transform. - * @return {!Object} - * @suppress {unusedLocalVariables} f is only used for nested messages - */ -proto.usage.v1.GetCostCenterRequest.toObject = function(includeInstance, msg) { - var f, obj = { - attributionId: jspb.Message.getFieldWithDefault(msg, 1, "") - }; - - if (includeInstance) { - obj.$jspbMessageInstance = msg; - } - return obj; -}; -} - - -/** - * Deserializes binary data (in protobuf wire format). - * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.usage.v1.GetCostCenterRequest} - */ -proto.usage.v1.GetCostCenterRequest.deserializeBinary = function(bytes) { - var reader = new jspb.BinaryReader(bytes); - var msg = new proto.usage.v1.GetCostCenterRequest; - return proto.usage.v1.GetCostCenterRequest.deserializeBinaryFromReader(msg, reader); -}; - - -/** - * Deserializes binary data (in protobuf wire format) from the - * given reader into the given message object. - * @param {!proto.usage.v1.GetCostCenterRequest} msg The message object to deserialize into. - * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.usage.v1.GetCostCenterRequest} - */ -proto.usage.v1.GetCostCenterRequest.deserializeBinaryFromReader = function(msg, reader) { - while (reader.nextField()) { - if (reader.isEndGroup()) { - break; - } - var field = reader.getFieldNumber(); - switch (field) { - case 1: - var value = /** @type {string} */ (reader.readString()); - msg.setAttributionId(value); - break; - default: - reader.skipField(); - break; - } - } - return msg; -}; - - -/** - * Serializes the message to binary data (in protobuf wire format). - * @return {!Uint8Array} - */ -proto.usage.v1.GetCostCenterRequest.prototype.serializeBinary = function() { - var writer = new jspb.BinaryWriter(); - proto.usage.v1.GetCostCenterRequest.serializeBinaryToWriter(this, writer); - return writer.getResultBuffer(); -}; - - -/** - * Serializes the given message to binary data (in protobuf wire - * format), writing to the given BinaryWriter. - * @param {!proto.usage.v1.GetCostCenterRequest} message - * @param {!jspb.BinaryWriter} writer - * @suppress {unusedLocalVariables} f is only used for nested messages - */ -proto.usage.v1.GetCostCenterRequest.serializeBinaryToWriter = function(message, writer) { - var f = undefined; - f = message.getAttributionId(); - if (f.length > 0) { - writer.writeString( - 1, - f - ); - } -}; - - -/** - * optional string attribution_id = 1; - * @return {string} - */ -proto.usage.v1.GetCostCenterRequest.prototype.getAttributionId = function() { - return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); -}; - - -/** - * @param {string} value - * @return {!proto.usage.v1.GetCostCenterRequest} returns this - */ -proto.usage.v1.GetCostCenterRequest.prototype.setAttributionId = function(value) { - return jspb.Message.setProto3StringField(this, 1, value); -}; - - - - - -if (jspb.Message.GENERATE_TO_OBJECT) { -/** - * Creates an object representation of this proto. - * Field names that are reserved in JavaScript and will be renamed to pb_name. - * Optional fields that are not set will be set to undefined. - * To access a reserved field use, foo.pb_, eg, foo.pb_default. - * For the list of reserved names please see: - * net/proto2/compiler/js/internal/generator.cc#kKeyword. - * @param {boolean=} opt_includeInstance Deprecated. whether to include the - * JSPB instance for transitional soy proto support: - * http://goto/soy-param-migration - * @return {!Object} - */ -proto.usage.v1.GetCostCenterResponse.prototype.toObject = function(opt_includeInstance) { - return proto.usage.v1.GetCostCenterResponse.toObject(opt_includeInstance, this); -}; - - -/** - * Static version of the {@see toObject} method. - * @param {boolean|undefined} includeInstance Deprecated. Whether to include - * the JSPB instance for transitional soy proto support: - * http://goto/soy-param-migration - * @param {!proto.usage.v1.GetCostCenterResponse} msg The msg instance to transform. - * @return {!Object} - * @suppress {unusedLocalVariables} f is only used for nested messages - */ -proto.usage.v1.GetCostCenterResponse.toObject = function(includeInstance, msg) { - var f, obj = { - costCenter: (f = msg.getCostCenter()) && proto.usage.v1.CostCenter.toObject(includeInstance, f) - }; - - if (includeInstance) { - obj.$jspbMessageInstance = msg; - } - return obj; -}; -} - - -/** - * Deserializes binary data (in protobuf wire format). - * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.usage.v1.GetCostCenterResponse} - */ -proto.usage.v1.GetCostCenterResponse.deserializeBinary = function(bytes) { - var reader = new jspb.BinaryReader(bytes); - var msg = new proto.usage.v1.GetCostCenterResponse; - return proto.usage.v1.GetCostCenterResponse.deserializeBinaryFromReader(msg, reader); -}; - - -/** - * Deserializes binary data (in protobuf wire format) from the - * given reader into the given message object. - * @param {!proto.usage.v1.GetCostCenterResponse} msg The message object to deserialize into. - * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.usage.v1.GetCostCenterResponse} - */ -proto.usage.v1.GetCostCenterResponse.deserializeBinaryFromReader = function(msg, reader) { - while (reader.nextField()) { - if (reader.isEndGroup()) { - break; - } - var field = reader.getFieldNumber(); - switch (field) { - case 1: - var value = new proto.usage.v1.CostCenter; - reader.readMessage(value,proto.usage.v1.CostCenter.deserializeBinaryFromReader); - msg.setCostCenter(value); - break; - default: - reader.skipField(); - break; - } - } - return msg; -}; - - -/** - * Serializes the message to binary data (in protobuf wire format). - * @return {!Uint8Array} - */ -proto.usage.v1.GetCostCenterResponse.prototype.serializeBinary = function() { - var writer = new jspb.BinaryWriter(); - proto.usage.v1.GetCostCenterResponse.serializeBinaryToWriter(this, writer); - return writer.getResultBuffer(); -}; - - -/** - * Serializes the given message to binary data (in protobuf wire - * format), writing to the given BinaryWriter. - * @param {!proto.usage.v1.GetCostCenterResponse} message - * @param {!jspb.BinaryWriter} writer - * @suppress {unusedLocalVariables} f is only used for nested messages - */ -proto.usage.v1.GetCostCenterResponse.serializeBinaryToWriter = function(message, writer) { - var f = undefined; - f = message.getCostCenter(); - if (f != null) { - writer.writeMessage( - 1, - f, - proto.usage.v1.CostCenter.serializeBinaryToWriter - ); - } -}; - - -/** - * optional CostCenter cost_center = 1; - * @return {?proto.usage.v1.CostCenter} - */ -proto.usage.v1.GetCostCenterResponse.prototype.getCostCenter = function() { - return /** @type{?proto.usage.v1.CostCenter} */ ( - jspb.Message.getWrapperField(this, proto.usage.v1.CostCenter, 1)); -}; - - -/** - * @param {?proto.usage.v1.CostCenter|undefined} value - * @return {!proto.usage.v1.GetCostCenterResponse} returns this -*/ -proto.usage.v1.GetCostCenterResponse.prototype.setCostCenter = function(value) { - return jspb.Message.setWrapperField(this, 1, value); -}; - - -/** - * Clears the message field making it undefined. - * @return {!proto.usage.v1.GetCostCenterResponse} returns this - */ -proto.usage.v1.GetCostCenterResponse.prototype.clearCostCenter = function() { - return this.setCostCenter(undefined); -}; - - -/** - * Returns whether this field is set. - * @return {boolean} - */ -proto.usage.v1.GetCostCenterResponse.prototype.hasCostCenter = function() { - return jspb.Message.getField(this, 1) != null; -}; - - - - - -if (jspb.Message.GENERATE_TO_OBJECT) { -/** - * Creates an object representation of this proto. - * Field names that are reserved in JavaScript and will be renamed to pb_name. - * Optional fields that are not set will be set to undefined. - * To access a reserved field use, foo.pb_, eg, foo.pb_default. - * For the list of reserved names please see: - * net/proto2/compiler/js/internal/generator.cc#kKeyword. - * @param {boolean=} opt_includeInstance Deprecated. whether to include the - * JSPB instance for transitional soy proto support: - * http://goto/soy-param-migration - * @return {!Object} - */ -proto.usage.v1.CostCenter.prototype.toObject = function(opt_includeInstance) { - return proto.usage.v1.CostCenter.toObject(opt_includeInstance, this); -}; - - -/** - * Static version of the {@see toObject} method. - * @param {boolean|undefined} includeInstance Deprecated. Whether to include - * the JSPB instance for transitional soy proto support: - * http://goto/soy-param-migration - * @param {!proto.usage.v1.CostCenter} msg The msg instance to transform. - * @return {!Object} - * @suppress {unusedLocalVariables} f is only used for nested messages - */ -proto.usage.v1.CostCenter.toObject = function(includeInstance, msg) { - var f, obj = { - attributionId: jspb.Message.getFieldWithDefault(msg, 1, ""), - spendingLimit: jspb.Message.getFieldWithDefault(msg, 2, 0), - billingStrategy: jspb.Message.getFieldWithDefault(msg, 3, 0) - }; - - if (includeInstance) { - obj.$jspbMessageInstance = msg; - } - return obj; -}; -} - - -/** - * Deserializes binary data (in protobuf wire format). - * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.usage.v1.CostCenter} - */ -proto.usage.v1.CostCenter.deserializeBinary = function(bytes) { - var reader = new jspb.BinaryReader(bytes); - var msg = new proto.usage.v1.CostCenter; - return proto.usage.v1.CostCenter.deserializeBinaryFromReader(msg, reader); -}; - - -/** - * Deserializes binary data (in protobuf wire format) from the - * given reader into the given message object. - * @param {!proto.usage.v1.CostCenter} msg The message object to deserialize into. - * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.usage.v1.CostCenter} - */ -proto.usage.v1.CostCenter.deserializeBinaryFromReader = function(msg, reader) { - while (reader.nextField()) { - if (reader.isEndGroup()) { - break; - } - var field = reader.getFieldNumber(); - switch (field) { - case 1: - var value = /** @type {string} */ (reader.readString()); - msg.setAttributionId(value); - break; - case 2: - var value = /** @type {number} */ (reader.readInt32()); - msg.setSpendingLimit(value); - break; - case 3: - var value = /** @type {!proto.usage.v1.CostCenter.BillingStrategy} */ (reader.readEnum()); - msg.setBillingStrategy(value); - break; - default: - reader.skipField(); - break; - } - } - return msg; -}; - - -/** - * Serializes the message to binary data (in protobuf wire format). - * @return {!Uint8Array} - */ -proto.usage.v1.CostCenter.prototype.serializeBinary = function() { - var writer = new jspb.BinaryWriter(); - proto.usage.v1.CostCenter.serializeBinaryToWriter(this, writer); - return writer.getResultBuffer(); -}; - - -/** - * Serializes the given message to binary data (in protobuf wire - * format), writing to the given BinaryWriter. - * @param {!proto.usage.v1.CostCenter} message - * @param {!jspb.BinaryWriter} writer - * @suppress {unusedLocalVariables} f is only used for nested messages - */ -proto.usage.v1.CostCenter.serializeBinaryToWriter = function(message, writer) { - var f = undefined; - f = message.getAttributionId(); - if (f.length > 0) { - writer.writeString( - 1, - f - ); - } - f = message.getSpendingLimit(); - if (f !== 0) { - writer.writeInt32( - 2, - f - ); - } - f = message.getBillingStrategy(); - if (f !== 0.0) { - writer.writeEnum( - 3, - f - ); - } -}; - - -/** - * @enum {number} - */ -proto.usage.v1.CostCenter.BillingStrategy = { - BILLING_STRATEGY_STRIPE: 0, - BILLING_STRATEGY_OTHER: 1 -}; - -/** - * optional string attribution_id = 1; - * @return {string} - */ -proto.usage.v1.CostCenter.prototype.getAttributionId = function() { - return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); -}; - - -/** - * @param {string} value - * @return {!proto.usage.v1.CostCenter} returns this - */ -proto.usage.v1.CostCenter.prototype.setAttributionId = function(value) { - return jspb.Message.setProto3StringField(this, 1, value); -}; - - -/** - * optional int32 spending_limit = 2; - * @return {number} - */ -proto.usage.v1.CostCenter.prototype.getSpendingLimit = function() { - return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 2, 0)); -}; - - -/** - * @param {number} value - * @return {!proto.usage.v1.CostCenter} returns this - */ -proto.usage.v1.CostCenter.prototype.setSpendingLimit = function(value) { - return jspb.Message.setProto3IntField(this, 2, value); -}; - - -/** - * optional BillingStrategy billing_strategy = 3; - * @return {!proto.usage.v1.CostCenter.BillingStrategy} - */ -proto.usage.v1.CostCenter.prototype.getBillingStrategy = function() { - return /** @type {!proto.usage.v1.CostCenter.BillingStrategy} */ (jspb.Message.getFieldWithDefault(this, 3, 0)); -}; - - -/** - * @param {!proto.usage.v1.CostCenter.BillingStrategy} value - * @return {!proto.usage.v1.CostCenter} returns this - */ -proto.usage.v1.CostCenter.prototype.setBillingStrategy = function(value) { - return jspb.Message.setProto3EnumField(this, 3, value); -}; - - -goog.object.extend(exports, proto.usage.v1); diff --git a/scripts/protoc-generator.sh b/scripts/protoc-generator.sh index d30322d842522c..bf3dd9ebd36a0e 100755 --- a/scripts/protoc-generator.sh +++ b/scripts/protoc-generator.sh @@ -36,6 +36,37 @@ go_protoc() { "${PROTO_DIR}"/*.proto } +typescript_ts_protoc() { + local ROOT_DIR=$1 + local PROTO_DIR=${2:-.} + local MODULE_DIR + # Assigning external program output directly + # after the `local` keyword masks the return value (Could be an error). + # Should be done in a separate line. + MODULE_DIR=$(pwd) + TARGET_DIR="$MODULE_DIR"/typescript/src + + pushd typescript > /dev/null || exit + + yarn install + + rm -rf "$TARGET_DIR" + mkdir -p "$TARGET_DIR" + + echo "[protoc] Generating TypeScript files" + protoc --plugin="$MODULE_DIR"/typescript/node_modules/.bin/protoc-gen-ts_proto \ + --ts_proto_opt=context=true \ + --ts_proto_opt=lowerCaseServiceMethods=true \ + --ts_proto_opt=stringEnums=true \ + --ts_proto_out="$TARGET_DIR" \ + --ts_proto_opt=fileSuffix=.pb \ + --ts_proto_opt=outputServices=nice-grpc,outputServices=generic-definitions,useExactTypes=false \ + -I /usr/lib/protoc/include -I"$ROOT_DIR" -I.. -I"../$PROTO_DIR" \ + "../$PROTO_DIR"/*.proto + +popd > /dev/null || exit +} + typescript_protoc() { local ROOT_DIR=$1 local PROTO_DIR=${2:-.} diff --git a/yarn.lock b/yarn.lock index 7fb78b1fe2480c..ebdea467da07ee 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1448,6 +1448,14 @@ "@grpc/proto-loader" "^0.6.4" "@types/node" ">=12.12.47" +"@grpc/grpc-js@^1.6.1": + version "1.7.0" + resolved "https://registry.yarnpkg.com/@grpc/grpc-js/-/grpc-js-1.7.0.tgz#5a96bdbe51cce23faa38a4db6e43595a5c584849" + integrity sha512-wvKxal+40Xx11DXO2q5PfY3UiE25iwTb8SOz6A9IJII/V7d19x2ex0he+GJfVW0JZCaBjCPSjUB0yU9Ecm4WCw== + dependencies: + "@grpc/proto-loader" "^0.7.0" + "@types/node" ">=12.12.47" + "@grpc/proto-loader@^0.6.4": version "0.6.6" resolved "https://registry.npmjs.org/@grpc/proto-loader/-/proto-loader-0.6.6.tgz" @@ -1459,6 +1467,17 @@ protobufjs "^6.10.0" yargs "^16.1.1" +"@grpc/proto-loader@^0.7.0": + version "0.7.2" + resolved "https://registry.yarnpkg.com/@grpc/proto-loader/-/proto-loader-0.7.2.tgz#fa63178853afe1473c50cff89fe572f7c8b20154" + integrity sha512-jCdyLIT/tdQ1zhrbTQnJNK5nbDf0GoBpy5jVNywBzzMDF+Vs6uEaHnfz46dMtDxkvwrF2hzk5Z67goliceH0sA== + dependencies: + "@types/long" "^4.0.1" + lodash.camelcase "^4.3.0" + long "^4.0.0" + protobufjs "^7.0.0" + yargs "^16.2.0" + "@hapi/address@2.x.x": version "2.1.4" resolved "https://registry.npmjs.org/@hapi/address/-/address-2.1.4.tgz" @@ -3011,6 +3030,11 @@ dependencies: "@types/node" "*" +"@types/object-hash@^1.3.0": + version "1.3.4" + resolved "https://registry.yarnpkg.com/@types/object-hash/-/object-hash-1.3.4.tgz#079ba142be65833293673254831b5e3e847fe58b" + integrity sha512-xFdpkAkikBgqBdG9vIlsqffDV8GpvnPEzs0IUtr1v3BEB97ijsFQ4RXVbUZwjFThhB4MDSTUfvmxUD5PGx0wXA== + "@types/parse-json@^4.0.0": version "4.0.0" resolved "https://registry.npmjs.org/@types/parse-json/-/parse-json-4.0.0.tgz" @@ -3730,6 +3754,11 @@ abbrev@1: resolved "https://registry.npmjs.org/abbrev/-/abbrev-1.1.1.tgz" integrity sha512-nne9/IiQ/hzIhY6pdDnbBtz7DjPTKrY00P/zvPSm5pOFkl6xuGrGnXn/VtTNNfNtAfZ9/1RtehkszU9qcTii0Q== +abort-controller-x@^0.4.0: + version "0.4.0" + resolved "https://registry.yarnpkg.com/abort-controller-x/-/abort-controller-x-0.4.0.tgz#fde25da52548c7ff3d8b3b32dffc943452874d5f" + integrity sha512-cuNbw3c/SvEOkWkgxoWOOS3QzcTCC6YXCFH6oTZ/jvjZPBhkjaoUyCLwdAViRRhYmluJPD7vGaTLkHCp67xQVQ== + abort-controller@^3.0.0: version "3.0.0" resolved "https://registry.npmjs.org/abort-controller/-/abort-controller-3.0.0.tgz" @@ -6575,6 +6604,11 @@ data-urls@^2.0.0: whatwg-mimetype "^2.3.0" whatwg-url "^8.0.0" +dataloader@^1.4.0: + version "1.4.0" + resolved "https://registry.yarnpkg.com/dataloader/-/dataloader-1.4.0.tgz#bca11d867f5d3f1b9ed9f737bd15970c65dff5c8" + integrity sha512-68s5jYdlvasItOJnCuI2Q9s4q98g0pCyL3HrcKJu8KNugUl8ahgmZYg38ysLTgQjjXX3H8CJLkAvWrclWfcalw== + date-and-time@^2.0.0: version "2.0.1" resolved "https://registry.npmjs.org/date-and-time/-/date-and-time-2.0.1.tgz" @@ -7074,6 +7108,13 @@ dotenv@^8.2.0: resolved "https://registry.npmjs.org/dotenv/-/dotenv-8.6.0.tgz" integrity sha512-IrPdXQsk2BbzvCBGBOTmmSH5SodmqZNt4ERAZDmW4CT+tL8VtvinqywuANaFu4bOMWki16nqf0e4oC0QIaDr/g== +dprint-node@^1.0.7: + version "1.0.7" + resolved "https://registry.yarnpkg.com/dprint-node/-/dprint-node-1.0.7.tgz#f571eaf61affb3a696cff1bdde78a021875ba540" + integrity sha512-NTZOW9A7ipb0n7z7nC3wftvsbceircwVHSgzobJsEQa+7RnOMbhrfX5IflA6CtC4GA63DSAiHYXa4JKEy9F7cA== + dependencies: + detect-libc "^1.0.3" + duplexer3@^0.1.4: version "0.1.4" resolved "https://registry.npmjs.org/duplexer3/-/duplexer3-0.1.4.tgz" @@ -11452,15 +11493,20 @@ loglevel@^1.6.8: resolved "https://registry.npmjs.org/loglevel/-/loglevel-1.7.1.tgz" integrity sha512-Hesni4s5UkWkwCGJMQGAh71PaLUmKFM60dHvq0zi/vDhhrzuk+4GgNbTXJ12YYQJn6ZKBDNIjYcuQGKudvqrIw== +long@4.0.0, long@^4.0.0: + version "4.0.0" + resolved "https://registry.npmjs.org/long/-/long-4.0.0.tgz" + integrity sha512-XsP+KhQif4bjX1kbuSiySJFNAehNxgLb6hPRGJ9QsUr8ajHkuXGdrHmFUTUUXhDwVX2R5bY4JNZEwbUiMhV+MA== + long@^2.4.0: version "2.4.0" resolved "https://registry.npmjs.org/long/-/long-2.4.0.tgz" integrity sha1-n6GAux2VAM3CnEFWdmoZleH0Uk8= -long@^4.0.0: - version "4.0.0" - resolved "https://registry.npmjs.org/long/-/long-4.0.0.tgz" - integrity sha512-XsP+KhQif4bjX1kbuSiySJFNAehNxgLb6hPRGJ9QsUr8ajHkuXGdrHmFUTUUXhDwVX2R5bY4JNZEwbUiMhV+MA== +long@^5.0.0: + version "5.2.0" + resolved "https://registry.yarnpkg.com/long/-/long-5.2.0.tgz#2696dadf4b4da2ce3f6f6b89186085d94d52fd61" + integrity sha512-9RTUNjK60eJbx3uz+TEGF7fUr29ZDxR5QzXcyDpeSfeH28S9ycINflOgOlppit5U+4kNTe83KQnMEerw7GmE8w== longjohn@^0.2.12: version "0.2.12" @@ -12163,6 +12209,22 @@ next-tick@~1.0.0: resolved "https://registry.npmjs.org/next-tick/-/next-tick-1.0.0.tgz" integrity sha1-yobR/ogoFpsBICCOPchCS524NCw= +nice-grpc-common@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/nice-grpc-common/-/nice-grpc-common-2.0.0.tgz#36c9b9cdc38d3b4aa8ad7abf120fd4737eff70ea" + integrity sha512-8h/QraeDmScnbKLd5ImS+e7uUDxumvByBo6ILj1jLHjKlIa74WKHNSn54u7RmnJ5tFAYE70iTm8VWyvbTv82yg== + dependencies: + ts-error "^1.0.6" + +nice-grpc@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/nice-grpc/-/nice-grpc-2.0.0.tgz#0fa3f04e5f45905349cf44330ae26e54e77c6b1c" + integrity sha512-BEQgQi5Km9OV2SEv3CsHMrMifP6RiLE0DhjFaxef7UgIBV/6CVtnk/EFhH8gG5+C3xBK8w+2Lwind/W6GdczAQ== + dependencies: + "@grpc/grpc-js" "^1.6.1" + abort-controller-x "^0.4.0" + nice-grpc-common "^2.0.0" + nice-try@^1.0.4: version "1.0.5" resolved "https://registry.npmjs.org/nice-try/-/nice-try-1.0.5.tgz" @@ -12458,6 +12520,11 @@ object-copy@^0.1.0: define-property "^0.2.5" kind-of "^3.0.3" +object-hash@^1.3.1: + version "1.3.1" + resolved "https://registry.yarnpkg.com/object-hash/-/object-hash-1.3.1.tgz#fde452098a951cb145f039bb7d455449ddc126df" + integrity sha512-OSuu/pU4ENM9kmREg0BdNrUDIl1heYa4mBZacJc+vVWz4GtAwu7jO8s4AIt2aGRUTqxykpWzI3Oqnsm13tTMDA== + object-hash@^2.2.0: version "2.2.0" resolved "https://registry.npmjs.org/object-hash/-/object-hash-2.2.0.tgz" @@ -14447,6 +14514,43 @@ protobufjs@^6.10.0: "@types/node" ">=13.7.0" long "^4.0.0" +protobufjs@^6.11.3, protobufjs@^6.8.8: + version "6.11.3" + resolved "https://registry.yarnpkg.com/protobufjs/-/protobufjs-6.11.3.tgz#637a527205a35caa4f3e2a9a4a13ddffe0e7af74" + integrity sha512-xL96WDdCZYdU7Slin569tFX712BxsxslWwAfAhCYjQKGTq7dAU91Lomy6nLLhh/dyGhk/YH4TwTSRxTzhuHyZg== + dependencies: + "@protobufjs/aspromise" "^1.1.2" + "@protobufjs/base64" "^1.1.2" + "@protobufjs/codegen" "^2.0.4" + "@protobufjs/eventemitter" "^1.1.0" + "@protobufjs/fetch" "^1.1.0" + "@protobufjs/float" "^1.0.2" + "@protobufjs/inquire" "^1.1.0" + "@protobufjs/path" "^1.1.2" + "@protobufjs/pool" "^1.1.0" + "@protobufjs/utf8" "^1.1.0" + "@types/long" "^4.0.1" + "@types/node" ">=13.7.0" + long "^4.0.0" + +protobufjs@^7.0.0: + version "7.1.1" + resolved "https://registry.yarnpkg.com/protobufjs/-/protobufjs-7.1.1.tgz#0117befb4b0f5a49d028e93f2ca62c3c1f5e7c65" + integrity sha512-d0nMQqS/aT3lfV8bKi9Gbg73vPd2LcDdTDOu6RE/M+h9DY8g1EmDzk3ADPccthEWfTBjkR2oxNdx9Gs8YubT+g== + dependencies: + "@protobufjs/aspromise" "^1.1.2" + "@protobufjs/base64" "^1.1.2" + "@protobufjs/codegen" "^2.0.4" + "@protobufjs/eventemitter" "^1.1.0" + "@protobufjs/fetch" "^1.1.0" + "@protobufjs/float" "^1.0.2" + "@protobufjs/inquire" "^1.1.0" + "@protobufjs/path" "^1.1.2" + "@protobufjs/pool" "^1.1.0" + "@protobufjs/utf8" "^1.1.0" + "@types/node" ">=13.7.0" + long "^5.0.0" + proxy-addr@~2.0.5, proxy-addr@~2.0.7: version "2.0.7" resolved "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.7.tgz" @@ -17095,6 +17199,11 @@ tryer@^1.0.1: resolved "https://registry.npmjs.org/tryer/-/tryer-1.0.1.tgz" integrity sha512-c3zayb8/kWWpycWYg87P71E1S1ZL6b6IJxfb5fvsUgsf0S2MVGaDhDXXjDMpdCpfWXqptc+4mXwmiy1ypXqRAA== +ts-error@^1.0.6: + version "1.0.6" + resolved "https://registry.yarnpkg.com/ts-error/-/ts-error-1.0.6.tgz#277496f2a28de6c184cfce8dfd5cdd03a4e6b0fc" + integrity sha512-tLJxacIQUM82IR7JO1UUkKlYuUTmoY9HBJAmNWFzheSlDS5SPMcNIepejHJa4BpPQLAcbRhRf3GDJzyj6rbKvA== + ts-loader@^9.2.2: version "9.2.6" resolved "https://registry.npmjs.org/ts-loader/-/ts-loader-9.2.6.tgz" @@ -17154,6 +17263,33 @@ ts-pnp@1.2.0, ts-pnp@^1.1.6: resolved "https://registry.npmjs.org/ts-pnp/-/ts-pnp-1.2.0.tgz" integrity sha512-csd+vJOb/gkzvcCHgTGSChYpy5f1/XKNsmvBGO4JXS+z1v2HobugDz4s1IeFXM3wZB44uczs+eazB5Q/ccdhQw== +ts-poet@^6.1.0: + version "6.1.0" + resolved "https://registry.yarnpkg.com/ts-poet/-/ts-poet-6.1.0.tgz#c5c3d679dfce1fe39acb5f5415275c5d6a598cb7" + integrity sha512-PFwbNJjGrb44wzHUGQicG2/nhjR+3+k7zYLDTa8D61NVUitl7K/JgIc9/P+8oMNenntKzLc8tjLDOkPrxIhm6A== + dependencies: + dprint-node "^1.0.7" + +ts-proto-descriptors@1.7.1: + version "1.7.1" + resolved "https://registry.yarnpkg.com/ts-proto-descriptors/-/ts-proto-descriptors-1.7.1.tgz#685d00305b06adfa929fd5a016a419382cd64c50" + integrity sha512-oIKUh3K4Xts4v29USGLfUG+2mEk32MsqpgZAOUyUlkrcIdv34yE+k2oZ2Nzngm6cV/JgFdOxRCqeyvmWHuYAyw== + dependencies: + long "^4.0.0" + protobufjs "^6.8.8" + +ts-proto@^1.125.0: + version "1.125.0" + resolved "https://registry.yarnpkg.com/ts-proto/-/ts-proto-1.125.0.tgz#54c54e25ea2d4cd04dafa4bd7a20047380982d63" + integrity sha512-ADXnF+Psk3SaLzxtXrhvKUDrNNpg7LnL5rQuQL+u9PiOQ4C2ktWLvJM0VtL4zqQ9/OHROmXjebpR0KMZAkI93w== + dependencies: + "@types/object-hash" "^1.3.0" + dataloader "^1.4.0" + object-hash "^1.3.1" + protobufjs "^6.11.3" + ts-poet "^6.1.0" + ts-proto-descriptors "1.7.1" + ts-protoc-gen@^0.13.0: version "0.13.0" resolved "https://registry.npmjs.org/ts-protoc-gen/-/ts-protoc-gen-0.13.0.tgz"