Skip to content

Commit 0c60393

Browse files
densumeshskeptrunedev
authored andcommitted
feature: add back user api key management
1 parent b2424ce commit 0c60393

File tree

7 files changed

+481
-2
lines changed

7 files changed

+481
-2
lines changed

clients/ts-sdk/openapi.json

Lines changed: 179 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6331,6 +6331,92 @@
63316331
]
63326332
}
63336333
},
6334+
"/api/user/api_key": {
6335+
"get": {
6336+
"tags": [
6337+
"User"
6338+
],
6339+
"summary": "Get User Api Keys",
6340+
"description": "Get the api keys which belong to the auth'ed user. The actual api key values are not returned, only the ids, names, and creation dates.",
6341+
"operationId": "get_user_api_keys",
6342+
"responses": {
6343+
"200": {
6344+
"description": "JSON body representing the api_key for the user",
6345+
"content": {
6346+
"application/json": {
6347+
"schema": {
6348+
"type": "array",
6349+
"items": {
6350+
"$ref": "#/components/schemas/ApiKeyRespBody"
6351+
}
6352+
}
6353+
}
6354+
}
6355+
},
6356+
"400": {
6357+
"description": "Service error relating to creating api_key for the user",
6358+
"content": {
6359+
"application/json": {
6360+
"schema": {
6361+
"$ref": "#/components/schemas/ErrorResponseBody"
6362+
}
6363+
}
6364+
}
6365+
}
6366+
},
6367+
"security": [
6368+
{
6369+
"ApiKey": [
6370+
"readonly"
6371+
]
6372+
}
6373+
]
6374+
}
6375+
},
6376+
"/api/user/api_key/{api_key_id}": {
6377+
"delete": {
6378+
"tags": [
6379+
"User"
6380+
],
6381+
"summary": "Delete User Api Key",
6382+
"description": "Delete an api key for the auth'ed user.",
6383+
"operationId": "delete_user_api_key",
6384+
"parameters": [
6385+
{
6386+
"name": "api_key_id",
6387+
"in": "path",
6388+
"description": "The id of the api key to delete",
6389+
"required": true,
6390+
"schema": {
6391+
"type": "string",
6392+
"format": "uuid"
6393+
}
6394+
}
6395+
],
6396+
"responses": {
6397+
"204": {
6398+
"description": "Confirmation that the api key was deleted"
6399+
},
6400+
"400": {
6401+
"description": "Service error relating to creating api_key for the user",
6402+
"content": {
6403+
"application/json": {
6404+
"schema": {
6405+
"$ref": "#/components/schemas/ErrorResponseBody"
6406+
}
6407+
}
6408+
}
6409+
}
6410+
},
6411+
"security": [
6412+
{
6413+
"ApiKey": [
6414+
"readonly"
6415+
]
6416+
}
6417+
]
6418+
}
6419+
},
63346420
"/metrics": {
63356421
"post": {
63366422
"tags": [
@@ -6498,6 +6584,13 @@
64986584
"type": "string",
64996585
"format": "uuid"
65006586
},
6587+
"organization_ids": {
6588+
"type": "array",
6589+
"items": {
6590+
"type": "string"
6591+
},
6592+
"nullable": true
6593+
},
65016594
"role": {
65026595
"type": "integer",
65036596
"format": "int32"
@@ -15922,6 +16015,92 @@
1592216015
}
1592316016
}
1592416017
},
16018+
"UserApiKey": {
16019+
"type": "object",
16020+
"required": [
16021+
"id",
16022+
"user_id",
16023+
"name",
16024+
"created_at",
16025+
"updated_at",
16026+
"role"
16027+
],
16028+
"properties": {
16029+
"api_key_hash": {
16030+
"type": "string",
16031+
"nullable": true
16032+
},
16033+
"blake3_hash": {
16034+
"type": "string",
16035+
"nullable": true
16036+
},
16037+
"created_at": {
16038+
"type": "string",
16039+
"format": "date-time"
16040+
},
16041+
"dataset_ids": {
16042+
"type": "array",
16043+
"items": {
16044+
"type": "string",
16045+
"nullable": true
16046+
},
16047+
"nullable": true
16048+
},
16049+
"expires_at": {
16050+
"type": "string",
16051+
"format": "date-time",
16052+
"nullable": true
16053+
},
16054+
"id": {
16055+
"type": "string",
16056+
"format": "uuid"
16057+
},
16058+
"name": {
16059+
"type": "string"
16060+
},
16061+
"organization_ids": {
16062+
"type": "array",
16063+
"items": {
16064+
"type": "string",
16065+
"nullable": true
16066+
},
16067+
"nullable": true
16068+
},
16069+
"params": {
16070+
"nullable": true
16071+
},
16072+
"role": {
16073+
"type": "integer",
16074+
"format": "int32"
16075+
},
16076+
"scopes": {
16077+
"type": "array",
16078+
"items": {
16079+
"type": "string",
16080+
"nullable": true
16081+
},
16082+
"nullable": true
16083+
},
16084+
"updated_at": {
16085+
"type": "string",
16086+
"format": "date-time"
16087+
},
16088+
"user_id": {
16089+
"type": "string",
16090+
"format": "uuid"
16091+
}
16092+
},
16093+
"example": {
16094+
"api_key_hash": "hash",
16095+
"blake3_hash": "hash",
16096+
"created_at": "2021-01-01 00:00:00.000",
16097+
"id": "e3e3e3e3-e3e3-e3e3-e3e3-e3e3e3e3e3e3",
16098+
"name": "Trieve",
16099+
"role": 1,
16100+
"updated_at": "2021-01-01 00:00:00.000",
16101+
"user_id": "e3e3e3e3-e3e3-e3e3-e3e3-e3e3e3e3e3"
16102+
}
16103+
},
1592516104
"UserOrganization": {
1592616105
"type": "object",
1592716106
"required": [

clients/ts-sdk/src/types.gen.ts

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ export type ApiKeyRespBody = {
5353
id: string;
5454
name: string;
5555
organization_id: string;
56+
organization_ids?: Array<(string)> | null;
5657
role: number;
5758
updated_at: string;
5859
};
@@ -3129,6 +3130,22 @@ export type UsageGraphPoint = {
31293130
time_stamp: string;
31303131
};
31313132

3133+
export type UserApiKey = {
3134+
api_key_hash?: (string) | null;
3135+
blake3_hash?: (string) | null;
3136+
created_at: string;
3137+
dataset_ids?: Array<((string) | null)> | null;
3138+
expires_at?: (string) | null;
3139+
id: string;
3140+
name: string;
3141+
organization_ids?: Array<((string) | null)> | null;
3142+
params?: unknown;
3143+
role: number;
3144+
scopes?: Array<((string) | null)> | null;
3145+
updated_at: string;
3146+
user_id: string;
3147+
};
3148+
31323149
export type UserOrganization = {
31333150
created_at: string;
31343151
id: string;
@@ -4482,6 +4499,17 @@ export type UpdateUserData = {
44824499

44834500
export type UpdateUserResponse = (void);
44844501

4502+
export type GetUserApiKeysResponse = (Array<ApiKeyRespBody>);
4503+
4504+
export type DeleteUserApiKeyData = {
4505+
/**
4506+
* The id of the api key to delete
4507+
*/
4508+
apiKeyId: string;
4509+
};
4510+
4511+
export type DeleteUserApiKeyResponse = (void);
4512+
44854513
export type GetMetricsResponse = (string);
44864514

44874515
export type $OpenApiTs = {
@@ -6037,6 +6065,35 @@ export type $OpenApiTs = {
60376065
};
60386066
};
60396067
};
6068+
'/api/user/api_key': {
6069+
get: {
6070+
res: {
6071+
/**
6072+
* JSON body representing the api_key for the user
6073+
*/
6074+
200: Array<ApiKeyRespBody>;
6075+
/**
6076+
* Service error relating to creating api_key for the user
6077+
*/
6078+
400: ErrorResponseBody;
6079+
};
6080+
};
6081+
};
6082+
'/api/user/api_key/{api_key_id}': {
6083+
delete: {
6084+
req: DeleteUserApiKeyData;
6085+
res: {
6086+
/**
6087+
* Confirmation that the api key was deleted
6088+
*/
6089+
204: void;
6090+
/**
6091+
* Service error relating to creating api_key for the user
6092+
*/
6093+
400: ErrorResponseBody;
6094+
};
6095+
};
6096+
};
60406097
'/metrics': {
60416098
post: {
60426099
res: {

0 commit comments

Comments
 (0)