Skip to content
Closed
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
68 changes: 46 additions & 22 deletions go/apps/api/openapi/gen.go

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

162 changes: 140 additions & 22 deletions go/apps/api/openapi/openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -208,42 +208,40 @@
"type": "object"
},
"V2RatelimitGetOverrideResponseBody": {
"$ref": "#/components/schemas/RatelimitOverride"
},
"V2RatelimitListOverridesRequestBody": {
"description": "List all overrides for a namespace",
"additionalProperties": false,
"properties": {
"namespaceId": {
"description": "The id of the namespace.",
"type": "string",
"minLength": 1,
"maxLength": 255
},
"overrideId": {
"description": "The id of the override.",
"description": "The id of the namespace. Either namespaceId or namespaceName must be provided",
"type": "string",
"minLength": 1,
"maxLength": 255
},
"duration": {
"description": "The duration in milliseconds for the rate limit window.",
"format": "int64",
"type": "integer",
"minimum": 1000
},
"identifier": {
"description": "Identifier of your user, this can be their userId, an email, an ip or anything else. Wildcards ( * ) can be used to match multiple identifiers, More info can be found at https://www.unkey.com/docs/ratelimiting/overrides#wildcard-rules",
"namespaceName": {
"description": "The name of the namespace. Either namespaceId or namespaceName must be provided",
"type": "string",
"minLength": 1,
"maxLength": 255
},
"limit": {
"description": "The maximum number of requests allowed.",
"format": "int64",
"type": "integer",
"minimum": 0
}
},
"required": ["namespaceId", "overrideId", "duration", "identifier", "limit"],
"type": "object"
},
"V2RatelimitListOverridesResponseBody": {
"type": "object",
"additionalProperties": false,
"properties": {
"overrides": {
"type": "array",
"items": {
"$ref": "#/components/schemas/RatelimitOverride"
}
}
},
"required": ["overrides"]
},
"V2RatelimitLimitRequestBody": {
"additionalProperties": false,
"properties": {
Expand Down Expand Up @@ -341,6 +339,43 @@
"V2RatelimitDeleteOverrideResponseBody": {
"additionalProperties": false,
"type": "object"
},
"RatelimitOverride": {
"type": "object",
"additionalProperties": false,
"properties": {
"namespaceId": {
"description": "The id of the namespace.",
"type": "string",
"minLength": 1,
"maxLength": 255
},
"overrideId": {
"description": "The id of the override.",
"type": "string",
"minLength": 1,
"maxLength": 255
},
"duration": {
"description": "The duration in milliseconds for the rate limit window.",
"format": "int64",
"type": "integer",
"minimum": 1000
},
"identifier": {
"description": "Identifier of your user, this can be their userId, an email, an ip or anything else. Wildcards ( * ) can be used to match multiple identifiers, More info can be found at https://www.unkey.com/docs/ratelimiting/overrides#wildcard-rules",
"type": "string",
"minLength": 1,
"maxLength": 255
},
"limit": {
"description": "The maximum number of requests allowed.",
"format": "int64",
"type": "integer",
"minimum": 0
}
},
"required": ["namespaceId", "overrideId", "duration", "identifier", "limit"]
}
}
},
Expand Down Expand Up @@ -595,6 +630,89 @@
}
}
},
"/v2/ratelimit.listOverrides": {
"post": {
"tags": ["ratelimit"],
"operationId": "ratelimit.listOverrides",
"security": [
{
"rootKey": []
}
],
"requestBody": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/V2RatelimitListOverridesRequestBody"
}
}
},
"required": true
},
"responses": {
"200": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/V2RatelimitListOverridesResponseBody"
}
}
},
"description": "OK"
},
"400": {
"description": "Bad request",
"content": {
"application/problem+json": {
"schema": {
"$ref": "#/components/schemas/BadRequestError"
}
}
}
},
"401": {
"description": "Unauthorized",
"content": {
"application/problem+json": {
"schema": {
"$ref": "#/components/schemas/UnauthorizedError"
}
}
}
},
"403": {
"description": "Forbidden",
"content": {
"application/problem+json": {
"schema": {
"$ref": "#/components/schemas/ForbiddenError"
}
}
}
},
"404": {
"description": "Not Found",
"content": {
"application/problem+json": {
"schema": {
"$ref": "#/components/schemas/NotFoundError"
}
}
}
},
"500": {
"content": {
"application/problem+json": {
"schema": {
"$ref": "#/components/schemas/InternalServerError"
}
}
},
"description": "Error"
}
}
}
},
"/v2/ratelimit.deleteOverride": {
"post": {
"tags": ["ratelimit"],
Expand Down
13 changes: 11 additions & 2 deletions go/apps/api/routes/register.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
v2RatelimitDeleteOverride "github.com/unkeyed/unkey/go/apps/api/routes/v2_ratelimit_delete_override"
v2RatelimitGetOverride "github.com/unkeyed/unkey/go/apps/api/routes/v2_ratelimit_get_override"
v2RatelimitLimit "github.com/unkeyed/unkey/go/apps/api/routes/v2_ratelimit_limit"
v2RatelimitListOverrides "github.com/unkeyed/unkey/go/apps/api/routes/v2_ratelimit_list_overrides"
v2RatelimitSetOverride "github.com/unkeyed/unkey/go/apps/api/routes/v2_ratelimit_set_override"
zen "github.com/unkeyed/unkey/go/pkg/zen"
)
Expand Down Expand Up @@ -40,7 +41,6 @@ func Register(srv *zen.Server, svc *Services) {
// ---------------------------------------------------------------------------
// v2/ratelimit

// v2/ratelimit.limit
srv.RegisterRoute(
defaultMiddlewares,
v2RatelimitLimit.New(v2RatelimitLimit.Services{
Expand All @@ -54,7 +54,6 @@ func Register(srv *zen.Server, svc *Services) {
RatelimitOverrideMatchesCache: svc.Caches.RatelimitOverridesMatch,
}),
)
// v2/ratelimit.setOverride
srv.RegisterRoute(
defaultMiddlewares,
v2RatelimitSetOverride.New(v2RatelimitSetOverride.Services{
Expand All @@ -75,6 +74,16 @@ func Register(srv *zen.Server, svc *Services) {
}),
)

srv.RegisterRoute(
defaultMiddlewares,
v2RatelimitListOverrides.New(v2RatelimitListOverrides.Services{
Logger: svc.Logger,
DB: svc.Database,
Keys: svc.Keys,
Permissions: svc.Permissions,
}),
)

srv.RegisterRoute(
defaultMiddlewares,
v2RatelimitDeleteOverride.New(v2RatelimitDeleteOverride.Services{
Expand Down
Loading
Loading