Path: blob/main/components/gitpod-protocol/src/usage.ts
2498 views
/**1* Copyright (c) 2022 Gitpod GmbH. All rights reserved.2* Licensed under the GNU Affero General Public License (AGPL).3* See License.AGPL.txt in the project root for license information.4*/56import { WorkspaceType } from "./protocol";78// types below are manually kept in sycn with components/usage-api/typescript/src/usage/v1/usage_pb.d.ts9export interface ListUsageRequest {10attributionId: string;11userId?: string;12from?: number;13to?: number;14order: Ordering;15pagination?: PaginationRequest;16}1718export enum Ordering {19ORDERING_DESCENDING = 0,20ORDERING_ASCENDING = 1,21}2223export interface PaginationRequest {24perPage: number;25page: number;26}2728export interface ListUsageResponse {29usageEntriesList: Usage[];30pagination?: PaginationResponse;31creditsUsed: number;32ledgerIntervalMinutes?: number;33}3435export interface PaginationResponse {36perPage: number;37totalPages: number;38total: number;39page: number;40}4142export type UsageKind = "workspaceinstance" | "invoice";43export interface Usage {44id: string;45attributionId: string;46description: string;47credits: number;48effectiveTime?: number;49kind: UsageKind;50workspaceInstanceId: string;51draft: boolean;52metadata: WorkspaceInstanceUsageData | InvoiceUsageData;53}5455// the equivalent golang shape is maintained in `/workspace/gitpod/`components/usage/pkg/db/usage.go`56export interface WorkspaceInstanceUsageData {57workspaceId: string;58workspaceType: WorkspaceType;59workspaceClass: string;60contextURL: string;61creationTime?: string;62startTime: string;63endTime?: string;64stoppedTime?: string;65userId: string;66userName: string;67userAvatarURL: string;68}6970export interface InvoiceUsageData {71invoiceId: string;72startDate: string;73endDate: string;74}7576export interface CostCenterJSON {77attributionId: string;78spendingLimit: number;79billingStrategy: CostCenter_BillingStrategy;80nextBillingTime?: string;81billingCycleStart?: string;82}8384export enum CostCenter_BillingStrategy {85BILLING_STRATEGY_STRIPE = "BILLING_STRATEGY_STRIPE",86BILLING_STRATEGY_OTHER = "BILLING_STRATEGY_OTHER",87UNRECOGNIZED = "UNRECOGNIZED",88}899091