Skip to content

[usage] Remove BillingService.SetBilledSession proto #13013

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 16, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
372 changes: 81 additions & 291 deletions components/usage-api/go/v1/billing.pb.go

Large diffs are not rendered by default.

38 changes: 0 additions & 38 deletions components/usage-api/go/v1/billing_grpc.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

214 changes: 0 additions & 214 deletions components/usage-api/typescript/src/usage/v1/billing.pb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,63 +8,9 @@
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 {
}

Expand Down Expand Up @@ -97,19 +43,6 @@ export interface CancelSubscriptionRequest {
export interface CancelSubscriptionResponse {
}

/**
* 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 {};
}
Expand Down Expand Up @@ -494,112 +427,6 @@ export const CancelSubscriptionResponse = {
},
};

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>): 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>): SetBilledSessionResponse {
const message = createBaseSetBilledSessionResponse();
return message;
},
};

export type BillingServiceDefinition = typeof BillingServiceDefinition;
export const BillingServiceDefinition = {
name: "BillingService",
Expand Down Expand Up @@ -650,15 +477,6 @@ export const BillingServiceDefinition = {
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;

Expand Down Expand Up @@ -692,11 +510,6 @@ export interface BillingServiceServiceImplementation<CallContextExt = {}> {
request: CancelSubscriptionRequest,
context: CallContext & CallContextExt,
): Promise<DeepPartial<CancelSubscriptionResponse>>;
/** SetBilledSession marks an instance as billed with a billing system */
setBilledSession(
request: SetBilledSessionRequest,
context: CallContext & CallContextExt,
): Promise<DeepPartial<SetBilledSessionResponse>>;
}

export interface BillingServiceClient<CallOptionsExt = {}> {
Expand Down Expand Up @@ -729,11 +542,6 @@ export interface BillingServiceClient<CallOptionsExt = {}> {
request: DeepPartial<CancelSubscriptionRequest>,
options?: CallOptions & CallOptionsExt,
): Promise<CancelSubscriptionResponse>;
/** SetBilledSession marks an instance as billed with a billing system */
setBilledSession(
request: DeepPartial<SetBilledSessionRequest>,
options?: CallOptions & CallOptionsExt,
): Promise<SetBilledSessionResponse>;
}

export interface DataLoaderOptions {
Expand Down Expand Up @@ -771,28 +579,6 @@ export type DeepPartial<T> = T extends Builtin ? T
: T extends {} ? { [K in keyof T]?: DeepPartial<T[K]> }
: Partial<T>;

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");
Expand Down
22 changes: 0 additions & 22 deletions components/usage-api/usage/v1/billing.proto
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ package usage.v1;

option go_package = "github.com/gitpod-io/gitpod/usage-api/v1";

import "google/protobuf/timestamp.proto";

service BillingService {
// ReconcileInvoices retrieves current credit balance and reflects it in billing system.
// Internal RPC, not intended for general consumption.
Expand All @@ -21,9 +19,6 @@ service BillingService {
// CancelSubscription cancels a stripe subscription in our system
// Called by a stripe webhook
rpc CancelSubscription(CancelSubscriptionRequest) returns (CancelSubscriptionResponse) {};

// SetBilledSession marks an instance as billed with a billing system
rpc SetBilledSession(SetBilledSessionRequest) returns (SetBilledSessionResponse) {};
}

message ReconcileInvoicesRequest {}
Expand Down Expand Up @@ -57,20 +52,3 @@ message CancelSubscriptionRequest {

message CancelSubscriptionResponse {
}

enum System {
SYSTEM_UNKNOWN = 0;
SYSTEM_CHARGEBEE = 1;
SYSTEM_STRIPE = 2;
}

// If there are two billable sessions for this instance ID,
// the second one's "from" will be the first one's "to"
message SetBilledSessionRequest {
string instance_id = 1;
google.protobuf.Timestamp from = 2;
System system = 3;
}

message SetBilledSessionResponse {
}
Loading