@daocloud-proto/hydra 0.2.0-dev-1 → 0.2.0-dev-2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -7,6 +7,15 @@
7
7
  import * as HydraCommonCommon from "../../../common/common.pb"
8
8
  import * as fm from "../../../fetch.pb"
9
9
  import * as GoogleProtobufTimestamp from "../../../google/protobuf/timestamp.pb"
10
+
11
+ export enum TimePeriod {
12
+ TIME_PERIOD_UNSPECIFIED = "TIME_PERIOD_UNSPECIFIED",
13
+ TIME_PERIOD_HOUR = "TIME_PERIOD_HOUR",
14
+ TIME_PERIOD_DAY = "TIME_PERIOD_DAY",
15
+ TIME_PERIOD_WEEK = "TIME_PERIOD_WEEK",
16
+ TIME_PERIOD_MONTH = "TIME_PERIOD_MONTH",
17
+ }
18
+
10
19
  export type CreateAPIKeyRequest = {
11
20
  name?: string
12
21
  }
@@ -34,6 +43,31 @@ export type DeleteAPIKeyRequest = {
34
43
  id?: string
35
44
  }
36
45
 
46
+ export type APIKeyUsageStatisticsRequest = {
47
+ startTime?: GoogleProtobufTimestamp.Timestamp
48
+ endTime?: GoogleProtobufTimestamp.Timestamp
49
+ ids?: string[]
50
+ models?: string[]
51
+ period?: TimePeriod
52
+ }
53
+
54
+ export type APIKeyUsageStatisticsResponse = {
55
+ dataPoints?: DataPoint[]
56
+ totalUsage?: Usage
57
+ }
58
+
59
+ export type Usage = {
60
+ total?: string
61
+ input?: string
62
+ output?: string
63
+ }
64
+
65
+ export type DataPoint = {
66
+ timestamp?: GoogleProtobufTimestamp.Timestamp
67
+ usage?: Usage
68
+ model?: string
69
+ }
70
+
37
71
  export class APIKeyManagement {
38
72
  static CreateAPIKey(req: CreateAPIKeyRequest, initReq?: fm.InitReq): Promise<APIKey> {
39
73
  return fm.fetchReq<CreateAPIKeyRequest, APIKey>(`/apis/hydra.io/v1alpha1/apikeys`, {...initReq, method: "POST", body: JSON.stringify(req, fm.replacer)})
@@ -44,4 +78,7 @@ export class APIKeyManagement {
44
78
  static DeleteAPIKey(req: DeleteAPIKeyRequest, initReq?: fm.InitReq): Promise<APIKey> {
45
79
  return fm.fetchReq<DeleteAPIKeyRequest, APIKey>(`/apis/hydra.io/v1alpha1/apikeys/${req["id"]}`, {...initReq, method: "DELETE", body: JSON.stringify(req, fm.replacer)})
46
80
  }
81
+ static GetAPIKeyUsageStatistics(req: APIKeyUsageStatisticsRequest, initReq?: fm.InitReq): Promise<APIKeyUsageStatisticsResponse> {
82
+ return fm.fetchReq<APIKeyUsageStatisticsRequest, APIKeyUsageStatisticsResponse>(`/apis/hydra.io/v1alpha1/apikeys-stats?${fm.renderURLSearchParams(req, [])}`, {...initReq, method: "GET"})
83
+ }
47
84
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@daocloud-proto/hydra",
3
- "version": "v0.2.0-dev-1",
3
+ "version": "v0.2.0-dev-2",
4
4
  "description": "",
5
5
  "author": "",
6
6
  "license": "ISC"