Skip to content

Commit 536b629

Browse files
committed
add spec
1 parent 6c23590 commit 536b629

File tree

5 files changed

+176
-28
lines changed

5 files changed

+176
-28
lines changed

svc/api/openapi/gen.go

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

svc/api/openapi/openapi-generated.yaml

Lines changed: 94 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -21,21 +21,26 @@ components:
2121
scheme: bearer
2222
type: http
2323
schemas:
24-
ChproxyMetricsRequestBody:
25-
type: array
26-
description: Array of API request metric events to be processed
27-
items:
28-
type: object
29-
additionalProperties: true
30-
ChproxyMetricsResponseBody:
24+
CacheInvalidateRequestBody:
3125
type: object
3226
required:
33-
- status
27+
- cacheName
28+
- keys
3429
properties:
35-
status:
30+
cacheName:
3631
type: string
37-
description: Processing status
38-
example: "OK"
32+
description: The name of the cache to invalidate entries from. Must match a registered cache resource name.
33+
example: "verification_key_by_hash"
34+
keys:
35+
type: array
36+
minItems: 1
37+
description: |-
38+
The cache keys to invalidate. For string-keyed caches (verification_key_by_hash,
39+
clickhouse_setting), pass the raw key values. For scoped-key caches (live_api_by_id,
40+
ratelimit_namespace, etc.), pass keys in "workspaceId:resourceId" format.
41+
items:
42+
type: string
43+
example: ["abc123"]
3944
BadRequestErrorResponse:
4045
type: object
4146
required:
@@ -47,6 +52,23 @@ components:
4752
error:
4853
$ref: "#/components/schemas/BadRequestErrorDetails"
4954
description: Error response for invalid requests that cannot be processed due to client-side errors. This typically occurs when request parameters are missing, malformed, or fail validation rules. The response includes detailed information about the specific errors in the request, including the location of each error and suggestions for fixing it. When receiving this error, check the 'errors' array in the response for specific validation issues that need to be addressed before retrying.
55+
UnauthorizedErrorResponse:
56+
type: object
57+
required:
58+
- meta
59+
- error
60+
properties:
61+
meta:
62+
$ref: "#/components/schemas/Meta"
63+
error:
64+
$ref: "#/components/schemas/BaseError"
65+
description: |-
66+
Error response when authentication has failed or credentials are missing. This occurs when:
67+
- No authentication token is provided in the request
68+
- The provided token is invalid, expired, or malformed
69+
- The token format doesn't match expected patterns
70+
71+
To resolve this error, ensure you're including a valid root key in the Authorization header.
5072
InternalServerErrorResponse:
5173
type: object
5274
required:
@@ -64,6 +86,21 @@ components:
6486
- The request ID in the response can help Unkey support investigate the issue
6587
- The error is likely temporary and retrying may succeed
6688
- If the error persists, contact Unkey support with the request ID
89+
ChproxyMetricsRequestBody:
90+
type: array
91+
description: Array of API request metric events to be processed
92+
items:
93+
type: object
94+
additionalProperties: true
95+
ChproxyMetricsResponseBody:
96+
type: object
97+
required:
98+
- status
99+
properties:
100+
status:
101+
type: string
102+
description: Processing status
103+
example: "OK"
67104
ChproxyRatelimitsRequestBody:
68105
type: array
69106
description: Array of ratelimit events to be processed
@@ -115,23 +152,6 @@ components:
115152
$ref: "#/components/schemas/Meta"
116153
data:
117154
$ref: "#/components/schemas/V2AnalyticsGetVerificationsResponseData"
118-
UnauthorizedErrorResponse:
119-
type: object
120-
required:
121-
- meta
122-
- error
123-
properties:
124-
meta:
125-
$ref: "#/components/schemas/Meta"
126-
error:
127-
$ref: "#/components/schemas/BaseError"
128-
description: |-
129-
Error response when authentication has failed or credentials are missing. This occurs when:
130-
- No authentication token is provided in the request
131-
- The provided token is invalid, expired, or malformed
132-
- The token format doesn't match expected patterns
133-
134-
To resolve this error, ensure you're including a valid root key in the Authorization header.
135155
ForbiddenErrorResponse:
136156
type: object
137157
required:
@@ -3751,6 +3771,52 @@ info:
37513771
version: 2.0.0
37523772
openapi: 3.1.0
37533773
paths:
3774+
/_internal/cache.invalidate:
3775+
post:
3776+
description: |-
3777+
Internal endpoint for invalidating cached entries across all API nodes.
3778+
Used by the dashboard to notify the API after mutations so stale cache
3779+
entries are evicted immediately rather than waiting for TTL expiry.
3780+
3781+
Invalidation is propagated to all cluster nodes via gossip when clustering
3782+
is enabled.
3783+
3784+
This endpoint requires a dedicated bearer token and should not be used by
3785+
external clients.
3786+
operationId: internalCacheInvalidate
3787+
requestBody:
3788+
content:
3789+
application/json:
3790+
schema:
3791+
$ref: '#/components/schemas/CacheInvalidateRequestBody'
3792+
required: true
3793+
responses:
3794+
"200":
3795+
description: Cache entries successfully invalidated
3796+
"400":
3797+
content:
3798+
application/json:
3799+
schema:
3800+
$ref: '#/components/schemas/BadRequestErrorResponse'
3801+
description: Invalid request body, missing cacheName or keys
3802+
"401":
3803+
content:
3804+
application/json:
3805+
schema:
3806+
$ref: '#/components/schemas/UnauthorizedErrorResponse'
3807+
description: Missing or invalid bearer token
3808+
"529":
3809+
content:
3810+
application/json:
3811+
schema:
3812+
$ref: '#/components/schemas/InternalServerErrorResponse'
3813+
description: Failed to invalidate cache entries
3814+
security: []
3815+
summary: Invalidate cache entries
3816+
tags:
3817+
- internal
3818+
x-excluded: true
3819+
x-speakeasy-ignore: true
37543820
/_internal/chproxy/metrics:
37553821
post:
37563822
description: |-

svc/api/openapi/openapi-split.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,10 @@ paths:
217217
/v2/permissions.deletePermission:
218218
$ref: "./spec/paths/v2/permissions/deletePermission/index.yaml"
219219

220+
# Cache Invalidation (Internal)
221+
/_internal/cache.invalidate:
222+
$ref: "./spec/paths/internal/cache_invalidate/index.yaml"
223+
220224
# ClickHouse Proxy Endpoints (Internal)
221225
/_internal/chproxy/verifications:
222226
$ref: "./spec/paths/chproxy/verifications/index.yaml"
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
type: object
2+
required:
3+
- cacheName
4+
- keys
5+
properties:
6+
cacheName:
7+
type: string
8+
description: The name of the cache to invalidate entries from. Must match a registered cache resource name.
9+
example: "verification_key_by_hash"
10+
keys:
11+
type: array
12+
minItems: 1
13+
description: |-
14+
The cache keys to invalidate. For string-keyed caches (verification_key_by_hash,
15+
clickhouse_setting), pass the raw key values. For scoped-key caches (live_api_by_id,
16+
ratelimit_namespace, etc.), pass keys in "workspaceId:resourceId" format.
17+
items:
18+
type: string
19+
example: ["abc123"]
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
post:
2+
x-speakeasy-ignore: true
3+
x-excluded: true
4+
tags:
5+
- internal
6+
security: []
7+
operationId: internalCacheInvalidate
8+
summary: Invalidate cache entries
9+
description: |-
10+
Internal endpoint for invalidating cached entries across all API nodes.
11+
Used by the dashboard to notify the API after mutations so stale cache
12+
entries are evicted immediately rather than waiting for TTL expiry.
13+
14+
Invalidation is propagated to all cluster nodes via gossip when clustering
15+
is enabled.
16+
17+
This endpoint requires a dedicated bearer token and should not be used by
18+
external clients.
19+
requestBody:
20+
required: true
21+
content:
22+
application/json:
23+
schema:
24+
"$ref": "./CacheInvalidateRequestBody.yaml"
25+
responses:
26+
"200":
27+
description: Cache entries successfully invalidated
28+
"400":
29+
content:
30+
application/json:
31+
schema:
32+
$ref: "../../../error/BadRequestErrorResponse.yaml"
33+
description: Invalid request body, missing cacheName or keys
34+
"401":
35+
content:
36+
application/json:
37+
schema:
38+
$ref: "../../../error/UnauthorizedErrorResponse.yaml"
39+
description: Missing or invalid bearer token
40+
"529":
41+
content:
42+
application/json:
43+
schema:
44+
$ref: "../../../error/InternalServerErrorResponse.yaml"
45+
description: Failed to invalidate cache entries

0 commit comments

Comments
 (0)