Skip to content

Commit fea3159

Browse files
committed
Added API call to fetch usage data
1 parent f0f159e commit fea3159

File tree

8 files changed

+1909
-150
lines changed

8 files changed

+1909
-150
lines changed

components/usage-api/go/v1/usage.pb.go

Lines changed: 611 additions & 150 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

components/usage-api/go/v1/usage_grpc.pb.go

Lines changed: 38 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

components/usage-api/typescript/src/usage/v1/usage_grpc_pb.d.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import * as google_protobuf_timestamp_pb from "google-protobuf/google/protobuf/t
1616

1717
interface IUsageServiceService extends grpc.ServiceDefinition<grpc.UntypedServiceImplementation> {
1818
listBilledUsage: IUsageServiceService_IListBilledUsage;
19+
findUsage: IUsageServiceService_IFindUsage;
1920
reconcileUsage: IUsageServiceService_IReconcileUsage;
2021
getCostCenter: IUsageServiceService_IGetCostCenter;
2122
reconcileUsageWithLedger: IUsageServiceService_IReconcileUsageWithLedger;
@@ -30,6 +31,15 @@ interface IUsageServiceService_IListBilledUsage extends grpc.MethodDefinition<us
3031
responseSerialize: grpc.serialize<usage_v1_usage_pb.ListBilledUsageResponse>;
3132
responseDeserialize: grpc.deserialize<usage_v1_usage_pb.ListBilledUsageResponse>;
3233
}
34+
interface IUsageServiceService_IFindUsage extends grpc.MethodDefinition<usage_v1_usage_pb.FindUsageRequest, usage_v1_usage_pb.FindUsageResponse> {
35+
path: "/usage.v1.UsageService/FindUsage";
36+
requestStream: false;
37+
responseStream: false;
38+
requestSerialize: grpc.serialize<usage_v1_usage_pb.FindUsageRequest>;
39+
requestDeserialize: grpc.deserialize<usage_v1_usage_pb.FindUsageRequest>;
40+
responseSerialize: grpc.serialize<usage_v1_usage_pb.FindUsageResponse>;
41+
responseDeserialize: grpc.deserialize<usage_v1_usage_pb.FindUsageResponse>;
42+
}
3343
interface IUsageServiceService_IReconcileUsage extends grpc.MethodDefinition<usage_v1_usage_pb.ReconcileUsageRequest, usage_v1_usage_pb.ReconcileUsageResponse> {
3444
path: "/usage.v1.UsageService/ReconcileUsage";
3545
requestStream: false;
@@ -62,6 +72,7 @@ export const UsageServiceService: IUsageServiceService;
6272

6373
export interface IUsageServiceServer extends grpc.UntypedServiceImplementation {
6474
listBilledUsage: grpc.handleUnaryCall<usage_v1_usage_pb.ListBilledUsageRequest, usage_v1_usage_pb.ListBilledUsageResponse>;
75+
findUsage: grpc.handleUnaryCall<usage_v1_usage_pb.FindUsageRequest, usage_v1_usage_pb.FindUsageResponse>;
6576
reconcileUsage: grpc.handleUnaryCall<usage_v1_usage_pb.ReconcileUsageRequest, usage_v1_usage_pb.ReconcileUsageResponse>;
6677
getCostCenter: grpc.handleUnaryCall<usage_v1_usage_pb.GetCostCenterRequest, usage_v1_usage_pb.GetCostCenterResponse>;
6778
reconcileUsageWithLedger: grpc.handleUnaryCall<usage_v1_usage_pb.ReconcileUsageWithLedgerRequest, usage_v1_usage_pb.ReconcileUsageWithLedgerResponse>;
@@ -71,6 +82,9 @@ export interface IUsageServiceClient {
7182
listBilledUsage(request: usage_v1_usage_pb.ListBilledUsageRequest, callback: (error: grpc.ServiceError | null, response: usage_v1_usage_pb.ListBilledUsageResponse) => void): grpc.ClientUnaryCall;
7283
listBilledUsage(request: usage_v1_usage_pb.ListBilledUsageRequest, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: usage_v1_usage_pb.ListBilledUsageResponse) => void): grpc.ClientUnaryCall;
7384
listBilledUsage(request: usage_v1_usage_pb.ListBilledUsageRequest, metadata: grpc.Metadata, options: Partial<grpc.CallOptions>, callback: (error: grpc.ServiceError | null, response: usage_v1_usage_pb.ListBilledUsageResponse) => void): grpc.ClientUnaryCall;
85+
findUsage(request: usage_v1_usage_pb.FindUsageRequest, callback: (error: grpc.ServiceError | null, response: usage_v1_usage_pb.FindUsageResponse) => void): grpc.ClientUnaryCall;
86+
findUsage(request: usage_v1_usage_pb.FindUsageRequest, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: usage_v1_usage_pb.FindUsageResponse) => void): grpc.ClientUnaryCall;
87+
findUsage(request: usage_v1_usage_pb.FindUsageRequest, metadata: grpc.Metadata, options: Partial<grpc.CallOptions>, callback: (error: grpc.ServiceError | null, response: usage_v1_usage_pb.FindUsageResponse) => void): grpc.ClientUnaryCall;
7488
reconcileUsage(request: usage_v1_usage_pb.ReconcileUsageRequest, callback: (error: grpc.ServiceError | null, response: usage_v1_usage_pb.ReconcileUsageResponse) => void): grpc.ClientUnaryCall;
7589
reconcileUsage(request: usage_v1_usage_pb.ReconcileUsageRequest, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: usage_v1_usage_pb.ReconcileUsageResponse) => void): grpc.ClientUnaryCall;
7690
reconcileUsage(request: usage_v1_usage_pb.ReconcileUsageRequest, metadata: grpc.Metadata, options: Partial<grpc.CallOptions>, callback: (error: grpc.ServiceError | null, response: usage_v1_usage_pb.ReconcileUsageResponse) => void): grpc.ClientUnaryCall;
@@ -87,6 +101,9 @@ export class UsageServiceClient extends grpc.Client implements IUsageServiceClie
87101
public listBilledUsage(request: usage_v1_usage_pb.ListBilledUsageRequest, callback: (error: grpc.ServiceError | null, response: usage_v1_usage_pb.ListBilledUsageResponse) => void): grpc.ClientUnaryCall;
88102
public listBilledUsage(request: usage_v1_usage_pb.ListBilledUsageRequest, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: usage_v1_usage_pb.ListBilledUsageResponse) => void): grpc.ClientUnaryCall;
89103
public listBilledUsage(request: usage_v1_usage_pb.ListBilledUsageRequest, metadata: grpc.Metadata, options: Partial<grpc.CallOptions>, callback: (error: grpc.ServiceError | null, response: usage_v1_usage_pb.ListBilledUsageResponse) => void): grpc.ClientUnaryCall;
104+
public findUsage(request: usage_v1_usage_pb.FindUsageRequest, callback: (error: grpc.ServiceError | null, response: usage_v1_usage_pb.FindUsageResponse) => void): grpc.ClientUnaryCall;
105+
public findUsage(request: usage_v1_usage_pb.FindUsageRequest, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: usage_v1_usage_pb.FindUsageResponse) => void): grpc.ClientUnaryCall;
106+
public findUsage(request: usage_v1_usage_pb.FindUsageRequest, metadata: grpc.Metadata, options: Partial<grpc.CallOptions>, callback: (error: grpc.ServiceError | null, response: usage_v1_usage_pb.FindUsageResponse) => void): grpc.ClientUnaryCall;
90107
public reconcileUsage(request: usage_v1_usage_pb.ReconcileUsageRequest, callback: (error: grpc.ServiceError | null, response: usage_v1_usage_pb.ReconcileUsageResponse) => void): grpc.ClientUnaryCall;
91108
public reconcileUsage(request: usage_v1_usage_pb.ReconcileUsageRequest, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: usage_v1_usage_pb.ReconcileUsageResponse) => void): grpc.ClientUnaryCall;
92109
public reconcileUsage(request: usage_v1_usage_pb.ReconcileUsageRequest, metadata: grpc.Metadata, options: Partial<grpc.CallOptions>, callback: (error: grpc.ServiceError | null, response: usage_v1_usage_pb.ReconcileUsageResponse) => void): grpc.ClientUnaryCall;

components/usage-api/typescript/src/usage/v1/usage_grpc_pb.js

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,28 @@ var grpc = require('@grpc/grpc-js');
1111
var usage_v1_usage_pb = require('../../usage/v1/usage_pb.js');
1212
var google_protobuf_timestamp_pb = require('google-protobuf/google/protobuf/timestamp_pb.js');
1313

14+
function serialize_usage_v1_FindUsageRequest(arg) {
15+
if (!(arg instanceof usage_v1_usage_pb.FindUsageRequest)) {
16+
throw new Error('Expected argument of type usage.v1.FindUsageRequest');
17+
}
18+
return Buffer.from(arg.serializeBinary());
19+
}
20+
21+
function deserialize_usage_v1_FindUsageRequest(buffer_arg) {
22+
return usage_v1_usage_pb.FindUsageRequest.deserializeBinary(new Uint8Array(buffer_arg));
23+
}
24+
25+
function serialize_usage_v1_FindUsageResponse(arg) {
26+
if (!(arg instanceof usage_v1_usage_pb.FindUsageResponse)) {
27+
throw new Error('Expected argument of type usage.v1.FindUsageResponse');
28+
}
29+
return Buffer.from(arg.serializeBinary());
30+
}
31+
32+
function deserialize_usage_v1_FindUsageResponse(buffer_arg) {
33+
return usage_v1_usage_pb.FindUsageResponse.deserializeBinary(new Uint8Array(buffer_arg));
34+
}
35+
1436
function serialize_usage_v1_GetCostCenterRequest(arg) {
1537
if (!(arg instanceof usage_v1_usage_pb.GetCostCenterRequest)) {
1638
throw new Error('Expected argument of type usage.v1.GetCostCenterRequest');
@@ -113,6 +135,18 @@ listBilledUsage: {
113135
responseSerialize: serialize_usage_v1_ListBilledUsageResponse,
114136
responseDeserialize: deserialize_usage_v1_ListBilledUsageResponse,
115137
},
138+
// ListBilledUsage retrieves all usage for the specified attributionId
139+
findUsage: {
140+
path: '/usage.v1.UsageService/FindUsage',
141+
requestStream: false,
142+
responseStream: false,
143+
requestType: usage_v1_usage_pb.FindUsageRequest,
144+
responseType: usage_v1_usage_pb.FindUsageResponse,
145+
requestSerialize: serialize_usage_v1_FindUsageRequest,
146+
requestDeserialize: deserialize_usage_v1_FindUsageRequest,
147+
responseSerialize: serialize_usage_v1_FindUsageResponse,
148+
responseDeserialize: deserialize_usage_v1_FindUsageResponse,
149+
},
116150
// ReconcileUsage collects usage for the specified time period, and stores the usage records in the database, returning the records.
117151
reconcileUsage: {
118152
path: '/usage.v1.UsageService/ReconcileUsage',

components/usage-api/typescript/src/usage/v1/usage_pb.d.ts

Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,137 @@ export namespace PaginatedResponse {
189189
}
190190
}
191191

192+
export class FindUsageRequest extends jspb.Message {
193+
getAttributionId(): string;
194+
setAttributionId(value: string): FindUsageRequest;
195+
196+
hasFrom(): boolean;
197+
clearFrom(): void;
198+
getFrom(): google_protobuf_timestamp_pb.Timestamp | undefined;
199+
setFrom(value?: google_protobuf_timestamp_pb.Timestamp): FindUsageRequest;
200+
201+
hasTo(): boolean;
202+
clearTo(): void;
203+
getTo(): google_protobuf_timestamp_pb.Timestamp | undefined;
204+
setTo(value?: google_protobuf_timestamp_pb.Timestamp): FindUsageRequest;
205+
getOrder(): FindUsageRequest.Ordering;
206+
setOrder(value: FindUsageRequest.Ordering): FindUsageRequest;
207+
208+
hasPagination(): boolean;
209+
clearPagination(): void;
210+
getPagination(): PaginatedRequest | undefined;
211+
setPagination(value?: PaginatedRequest): FindUsageRequest;
212+
213+
serializeBinary(): Uint8Array;
214+
toObject(includeInstance?: boolean): FindUsageRequest.AsObject;
215+
static toObject(includeInstance: boolean, msg: FindUsageRequest): FindUsageRequest.AsObject;
216+
static extensions: {[key: number]: jspb.ExtensionFieldInfo<jspb.Message>};
217+
static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo<jspb.Message>};
218+
static serializeBinaryToWriter(message: FindUsageRequest, writer: jspb.BinaryWriter): void;
219+
static deserializeBinary(bytes: Uint8Array): FindUsageRequest;
220+
static deserializeBinaryFromReader(message: FindUsageRequest, reader: jspb.BinaryReader): FindUsageRequest;
221+
}
222+
223+
export namespace FindUsageRequest {
224+
export type AsObject = {
225+
attributionId: string,
226+
from?: google_protobuf_timestamp_pb.Timestamp.AsObject,
227+
to?: google_protobuf_timestamp_pb.Timestamp.AsObject,
228+
order: FindUsageRequest.Ordering,
229+
pagination?: PaginatedRequest.AsObject,
230+
}
231+
232+
export enum Ordering {
233+
ORDERING_DESCENDING = 0,
234+
ORDERING_ASCENDING = 1,
235+
}
236+
237+
}
238+
239+
export class FindUsageResponse extends jspb.Message {
240+
clearSessionsList(): void;
241+
getSessionsList(): Array<BilledSession>;
242+
setSessionsList(value: Array<BilledSession>): FindUsageResponse;
243+
addSessions(value?: BilledSession, index?: number): BilledSession;
244+
getTotalCreditsUsed(): number;
245+
setTotalCreditsUsed(value: number): FindUsageResponse;
246+
247+
hasPagination(): boolean;
248+
clearPagination(): void;
249+
getPagination(): PaginatedResponse | undefined;
250+
setPagination(value?: PaginatedResponse): FindUsageResponse;
251+
252+
serializeBinary(): Uint8Array;
253+
toObject(includeInstance?: boolean): FindUsageResponse.AsObject;
254+
static toObject(includeInstance: boolean, msg: FindUsageResponse): FindUsageResponse.AsObject;
255+
static extensions: {[key: number]: jspb.ExtensionFieldInfo<jspb.Message>};
256+
static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo<jspb.Message>};
257+
static serializeBinaryToWriter(message: FindUsageResponse, writer: jspb.BinaryWriter): void;
258+
static deserializeBinary(bytes: Uint8Array): FindUsageResponse;
259+
static deserializeBinaryFromReader(message: FindUsageResponse, reader: jspb.BinaryReader): FindUsageResponse;
260+
}
261+
262+
export namespace FindUsageResponse {
263+
export type AsObject = {
264+
sessionsList: Array<BilledSession.AsObject>,
265+
totalCreditsUsed: number,
266+
pagination?: PaginatedResponse.AsObject,
267+
}
268+
}
269+
270+
export class Usage extends jspb.Message {
271+
getId(): string;
272+
setId(value: string): Usage;
273+
getAttributionId(): string;
274+
setAttributionId(value: string): Usage;
275+
getDescription(): string;
276+
setDescription(value: string): Usage;
277+
getCredits(): number;
278+
setCredits(value: number): Usage;
279+
280+
hasEffectiveTime(): boolean;
281+
clearEffectiveTime(): void;
282+
getEffectiveTime(): google_protobuf_timestamp_pb.Timestamp | undefined;
283+
setEffectiveTime(value?: google_protobuf_timestamp_pb.Timestamp): Usage;
284+
getKind(): Usage.Kind;
285+
setKind(value: Usage.Kind): Usage;
286+
getWorkspaceInstanceId(): string;
287+
setWorkspaceInstanceId(value: string): Usage;
288+
getDraft(): boolean;
289+
setDraft(value: boolean): Usage;
290+
getMetadata(): string;
291+
setMetadata(value: string): Usage;
292+
293+
serializeBinary(): Uint8Array;
294+
toObject(includeInstance?: boolean): Usage.AsObject;
295+
static toObject(includeInstance: boolean, msg: Usage): Usage.AsObject;
296+
static extensions: {[key: number]: jspb.ExtensionFieldInfo<jspb.Message>};
297+
static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo<jspb.Message>};
298+
static serializeBinaryToWriter(message: Usage, writer: jspb.BinaryWriter): void;
299+
static deserializeBinary(bytes: Uint8Array): Usage;
300+
static deserializeBinaryFromReader(message: Usage, reader: jspb.BinaryReader): Usage;
301+
}
302+
303+
export namespace Usage {
304+
export type AsObject = {
305+
id: string,
306+
attributionId: string,
307+
description: string,
308+
credits: number,
309+
effectiveTime?: google_protobuf_timestamp_pb.Timestamp.AsObject,
310+
kind: Usage.Kind,
311+
workspaceInstanceId: string,
312+
draft: boolean,
313+
metadata: string,
314+
}
315+
316+
export enum Kind {
317+
KIND_WORKSPACE_INSTANCE = 0,
318+
KIND_INVOICE = 1,
319+
}
320+
321+
}
322+
192323
export class BilledSession extends jspb.Message {
193324
getAttributionId(): string;
194325
setAttributionId(value: string): BilledSession;

0 commit comments

Comments
 (0)