diff --git a/.speakeasy/gen.lock b/.speakeasy/gen.lock index c4577b4..ace120f 100755 --- a/.speakeasy/gen.lock +++ b/.speakeasy/gen.lock @@ -1,19 +1,20 @@ lockVersion: 2.0.0 id: 4fc4737a-135f-4840-8e6d-42a2b2a2884b management: - docChecksum: 7621b6bd3bfaca0bcd2b0dc8150e0325 + docChecksum: 9ef18a373ab97ecd377d1039e3d02538 docVersion: 1.0.0 - speakeasyVersion: 1.286.3 - generationVersion: 2.329.0 - releaseVersion: 0.2.0 - configChecksum: f7dcb627a24c2bc24f40a5b483adfe68 + speakeasyVersion: 1.296.1 + generationVersion: 2.338.1 + releaseVersion: 0.3.0 + configChecksum: 2498dd6a83123f53e18f3a1cf63243d3 repoURL: https://github.com/unkeyed/unkey-go.git installationURL: https://github.com/unkeyed/unkey-go features: go: additionalDependencies: 0.1.0 constsAndDefaults: 0.1.4 - core: 3.4.8 + core: 3.4.10 + deprecations: 2.81.1 globalSecurity: 2.82.9 globalSecurityCallbacks: 0.1.0 globalSecurityFlattening: 0.1.0 @@ -21,7 +22,7 @@ features: ignores: 2.81.1 intellisenseMarkdownSupport: 0.1.0 nullables: 0.1.0 - responseFormat: 0.1.1 + responseFormat: 0.1.2 sdkHooks: 0.1.0 generatedFiles: - liveness.go @@ -53,13 +54,20 @@ generatedFiles: - /models/operations/getkey.go - /models/operations/deletekey.go - /models/operations/createkey.go + - /models/operations/verifykey.go - /models/operations/updatekey.go - /models/operations/updateremaining.go - /models/operations/getverifications.go - /models/operations/getapi.go - /models/operations/listkeys.go + - /models/operations/deletekeys.go - /models/operations/limit.go - /models/operations/v1migrationscreatekeys.go + - /models/components/httpmetadata.go + - /models/components/key.go + - /models/components/v1keysverifykeyresponse.go + - /models/components/v1keysverifykeyrequest.go + - /models/components/security.go - /models/sdkerrors/errbadrequest.go - /models/sdkerrors/errunauthorized.go - /models/sdkerrors/errforbidden.go @@ -67,45 +75,57 @@ generatedFiles: - /models/sdkerrors/errconflict.go - /models/sdkerrors/errtoomanyrequests.go - /models/sdkerrors/errinternalservererror.go - - /models/components/key.go - - /models/components/v1keysverifykeyresponse.go - - /models/components/v1keysverifykeyrequest.go - - /models/components/security.go - docs/models/operations/createapirequestbody.md - docs/models/operations/createapiresponsebody.md + - docs/models/operations/createapiresponse.md - docs/models/operations/deleteapirequestbody.md - docs/models/operations/deleteapiresponsebody.md + - docs/models/operations/deleteapiresponse.md - docs/models/operations/services.md - docs/models/operations/v1livenessresponsebody.md + - docs/models/operations/v1livenessresponse.md - docs/models/operations/getkeyrequest.md + - docs/models/operations/getkeyresponse.md - docs/models/operations/deletekeyrequestbody.md - docs/models/operations/deletekeyresponsebody.md + - docs/models/operations/deletekeyresponse.md - docs/models/operations/interval.md - docs/models/operations/refill.md - docs/models/operations/type.md - docs/models/operations/ratelimit.md - docs/models/operations/createkeyrequestbody.md - docs/models/operations/createkeyresponsebody.md + - docs/models/operations/createkeyresponse.md + - docs/models/operations/verifykeyresponse.md - docs/models/operations/updatekeytype.md - docs/models/operations/updatekeyratelimit.md - docs/models/operations/updatekeyinterval.md - docs/models/operations/updatekeyrefill.md - docs/models/operations/updatekeyrequestbody.md - docs/models/operations/updatekeyresponsebody.md + - docs/models/operations/updatekeyresponse.md - docs/models/operations/op.md - docs/models/operations/updateremainingrequestbody.md - docs/models/operations/updateremainingresponsebody.md + - docs/models/operations/updateremainingresponse.md - docs/models/operations/granularity.md - docs/models/operations/getverificationsrequest.md - docs/models/operations/verifications.md - docs/models/operations/getverificationsresponsebody.md + - docs/models/operations/getverificationsresponse.md - docs/models/operations/getapirequest.md - docs/models/operations/getapiresponsebody.md + - docs/models/operations/getapiresponse.md - docs/models/operations/listkeysrequest.md - docs/models/operations/listkeysresponsebody.md + - docs/models/operations/listkeysresponse.md + - docs/models/operations/deletekeysrequestbody.md + - docs/models/operations/deletekeysresponsebody.md + - docs/models/operations/deletekeysresponse.md - docs/models/operations/resources.md - docs/models/operations/limitrequestbody.md - docs/models/operations/limitresponsebody.md + - docs/models/operations/limitresponse.md - docs/models/operations/variant.md - docs/models/operations/hash.md - docs/models/operations/v1migrationscreatekeysinterval.md @@ -114,6 +134,21 @@ generatedFiles: - docs/models/operations/v1migrationscreatekeysratelimit.md - docs/models/operations/requestbody.md - docs/models/operations/v1migrationscreatekeysresponsebody.md + - docs/models/operations/v1migrationscreatekeysresponse.md + - docs/models/components/httpmetadata.md + - docs/models/components/interval.md + - docs/models/components/refill.md + - docs/models/components/type.md + - docs/models/components/ratelimit.md + - docs/models/components/key.md + - docs/models/components/v1keysverifykeyresponseratelimit.md + - docs/models/components/code.md + - docs/models/components/v1keysverifykeyresponse.md + - docs/models/components/permissions.md + - docs/models/components/authorization.md + - docs/models/components/v1keysverifykeyrequestratelimit.md + - docs/models/components/v1keysverifykeyrequest.md + - docs/models/components/security.md - docs/models/sdkerrors/code.md - docs/models/sdkerrors/error.md - docs/models/sdkerrors/errbadrequest.md @@ -135,19 +170,6 @@ generatedFiles: - docs/models/sdkerrors/errinternalservererrorcode.md - docs/models/sdkerrors/errinternalservererrorerror.md - docs/models/sdkerrors/errinternalservererror.md - - docs/models/components/interval.md - - docs/models/components/refill.md - - docs/models/components/type.md - - docs/models/components/ratelimit.md - - docs/models/components/key.md - - docs/models/components/v1keysverifykeyresponseratelimit.md - - docs/models/components/code.md - - docs/models/components/v1keysverifykeyresponse.md - - docs/models/components/permissions.md - - docs/models/components/authorization.md - - docs/models/components/v1keysverifykeyrequestratelimit.md - - docs/models/components/v1keysverifykeyrequest.md - - docs/models/components/security.md - docs/sdks/unkey/README.md - docs/sdks/liveness/README.md - docs/sdks/keys/README.md diff --git a/.speakeasy/gen.yaml b/.speakeasy/gen.yaml index 965091c..126da07 100755 --- a/.speakeasy/gen.yaml +++ b/.speakeasy/gen.yaml @@ -12,8 +12,9 @@ generation: auth: oAuth2ClientCredentialsEnabled: true go: - version: 0.2.0 + version: 0.3.0 additionalDependencies: {} + allowUnknownFieldsInWeakUnions: false clientServerStatusCodesAsErrors: true flattenGlobalSecurity: true imports: diff --git a/.speakeasy/workflow.lock b/.speakeasy/workflow.lock index 267cdfc..5eb1938 100644 --- a/.speakeasy/workflow.lock +++ b/.speakeasy/workflow.lock @@ -1,9 +1,9 @@ -speakeasyVersion: 1.286.3 +speakeasyVersion: 1.296.1 sources: openapi.json: sourceNamespace: openapi-json - sourceRevisionDigest: sha256:ea1217f15e8f55b82aace2a90dc970e731407804e4a60879d0d69bcfd7538aaa - sourceBlobDigest: sha256:e692b07a5ebd9d35e5c5ca35d98f0715dabd7647ad584b71114af07504e2b539 + sourceRevisionDigest: sha256:05b10ec1f0babf41de0f75b23d22fb8832b0be7a230046afcda6632b38133871 + sourceBlobDigest: sha256:f8f5d1be63f97653cc910a7d31f5c89f65df52988c9fd4d1a303d7a5ecfaf4c1 tags: - latest - main @@ -11,8 +11,8 @@ targets: go: source: openapi.json sourceNamespace: openapi-json - sourceRevisionDigest: sha256:ea1217f15e8f55b82aace2a90dc970e731407804e4a60879d0d69bcfd7538aaa - sourceBlobDigest: sha256:e692b07a5ebd9d35e5c5ca35d98f0715dabd7647ad584b71114af07504e2b539 + sourceRevisionDigest: sha256:05b10ec1f0babf41de0f75b23d22fb8832b0be7a230046afcda6632b38133871 + sourceBlobDigest: sha256:f8f5d1be63f97653cc910a7d31f5c89f65df52988c9fd4d1a303d7a5ecfaf4c1 outLocation: /github/workspace/repo workflow: workflowVersion: 1.0.0 @@ -27,5 +27,3 @@ workflow: go: target: go source: openapi.json - codeSamples: - output: codeSamples.yaml diff --git a/README.md b/README.md index 7f3ed71..dd3a3f2 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,6 @@ package main import ( "context" unkeygo "github.com/unkeyed/unkey-go" - "github.com/unkeyed/unkey-go/models/components" "github.com/unkeyed/unkey-go/models/operations" "log" ) @@ -28,17 +27,15 @@ func main() { s := unkeygo.New( unkeygo.WithSecurity(""), ) - request := operations.CreateAPIRequestBody{ Name: "my-api", } - ctx := context.Background() res, err := s.CreateAPI(ctx, request) if err != nil { log.Fatal(err) } - if res != nil { + if res.Object != nil { // handle response } } @@ -72,6 +69,7 @@ func main() { * [GetAPI](docs/sdks/apis/README.md#getapi) * [ListKeys](docs/sdks/apis/README.md#listkeys) +* [DeleteKeys](docs/sdks/apis/README.md#deletekeys) ### [Ratelimits](docs/sdks/ratelimits/README.md) @@ -107,7 +105,6 @@ import ( "context" "errors" unkeygo "github.com/unkeyed/unkey-go" - "github.com/unkeyed/unkey-go/models/components" "github.com/unkeyed/unkey-go/models/operations" "github.com/unkeyed/unkey-go/models/sdkerrors" "log" @@ -117,11 +114,9 @@ func main() { s := unkeygo.New( unkeygo.WithSecurity(""), ) - request := operations.CreateAPIRequestBody{ Name: "my-api", } - ctx := context.Background() res, err := s.CreateAPI(ctx, request) if err != nil { @@ -198,7 +193,6 @@ package main import ( "context" unkeygo "github.com/unkeyed/unkey-go" - "github.com/unkeyed/unkey-go/models/components" "github.com/unkeyed/unkey-go/models/operations" "log" ) @@ -208,17 +202,15 @@ func main() { unkeygo.WithServerIndex(0), unkeygo.WithSecurity(""), ) - request := operations.CreateAPIRequestBody{ Name: "my-api", } - ctx := context.Background() res, err := s.CreateAPI(ctx, request) if err != nil { log.Fatal(err) } - if res != nil { + if res.Object != nil { // handle response } } @@ -235,7 +227,6 @@ package main import ( "context" unkeygo "github.com/unkeyed/unkey-go" - "github.com/unkeyed/unkey-go/models/components" "github.com/unkeyed/unkey-go/models/operations" "log" ) @@ -245,17 +236,15 @@ func main() { unkeygo.WithServerURL("https://api.unkey.dev"), unkeygo.WithSecurity(""), ) - request := operations.CreateAPIRequestBody{ Name: "my-api", } - ctx := context.Background() res, err := s.CreateAPI(ctx, request) if err != nil { log.Fatal(err) } - if res != nil { + if res.Object != nil { // handle response } } @@ -318,17 +307,15 @@ func main() { s := unkeygo.New( unkeygo.WithSecurity(""), ) - request := operations.CreateAPIRequestBody{ Name: "my-api", } - ctx := context.Background() res, err := s.CreateAPI(ctx, request) if err != nil { log.Fatal(err) } - if res != nil { + if res.Object != nil { // handle response } } diff --git a/RELEASES.md b/RELEASES.md index 1163963..14da83a 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -38,4 +38,14 @@ Based on: ### Generated - [go v0.2.0] . ### Releases -- [Go v0.2.0] https://github.com/unkeyed/unkey-go/releases/tag/v0.2.0 - . \ No newline at end of file +- [Go v0.2.0] https://github.com/unkeyed/unkey-go/releases/tag/v0.2.0 - . + +## 2024-05-27 15:42:36 +### Changes +Based on: +- OpenAPI Doc +- Speakeasy CLI 1.296.1 (2.338.1) https://github.com/speakeasy-api/speakeasy +### Generated +- [go v0.3.0] . +### Releases +- [Go v0.3.0] https://github.com/unkeyed/unkey-go/releases/tag/v0.3.0 - . \ No newline at end of file diff --git a/USAGE.md b/USAGE.md index 05040c2..cce2c5d 100644 --- a/USAGE.md +++ b/USAGE.md @@ -5,7 +5,6 @@ package main import ( "context" unkeygo "github.com/unkeyed/unkey-go" - "github.com/unkeyed/unkey-go/models/components" "github.com/unkeyed/unkey-go/models/operations" "log" ) @@ -14,17 +13,15 @@ func main() { s := unkeygo.New( unkeygo.WithSecurity(""), ) - request := operations.CreateAPIRequestBody{ Name: "my-api", } - ctx := context.Background() res, err := s.CreateAPI(ctx, request) if err != nil { log.Fatal(err) } - if res != nil { + if res.Object != nil { // handle response } } diff --git a/apis.go b/apis.go index 3daa8ec..e0ccb4e 100644 --- a/apis.go +++ b/apis.go @@ -8,6 +8,7 @@ import ( "fmt" "github.com/unkeyed/unkey-go/internal/hooks" "github.com/unkeyed/unkey-go/internal/utils" + "github.com/unkeyed/unkey-go/models/components" "github.com/unkeyed/unkey-go/models/operations" "github.com/unkeyed/unkey-go/models/sdkerrors" "io" @@ -25,7 +26,7 @@ func newApis(sdkConfig sdkConfiguration) *Apis { } } -func (s *Apis) GetAPI(ctx context.Context, request operations.GetAPIRequest) (*operations.GetAPIResponseBody, error) { +func (s *Apis) GetAPI(ctx context.Context, request operations.GetAPIRequest) (*operations.GetAPIResponse, error) { hookCtx := hooks.HookContext{ Context: ctx, OperationID: "getApi", @@ -83,6 +84,13 @@ func (s *Apis) GetAPI(ctx context.Context, request operations.GetAPIRequest) (*o } } + res := &operations.GetAPIResponse{ + HTTPMeta: components.HTTPMetadata{ + Request: req, + Response: httpRes, + }, + } + rawBody, err := io.ReadAll(httpRes.Body) if err != nil { return nil, fmt.Errorf("error reading response body: %w", err) @@ -99,7 +107,7 @@ func (s *Apis) GetAPI(ctx context.Context, request operations.GetAPIRequest) (*o return nil, err } - return &out, nil + res.Object = &out default: return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } @@ -194,9 +202,12 @@ func (s *Apis) GetAPI(ctx context.Context, request operations.GetAPIRequest) (*o default: return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) } + + return res, nil + } -func (s *Apis) ListKeys(ctx context.Context, request operations.ListKeysRequest) (*operations.ListKeysResponseBody, error) { +func (s *Apis) ListKeys(ctx context.Context, request operations.ListKeysRequest) (*operations.ListKeysResponse, error) { hookCtx := hooks.HookContext{ Context: ctx, OperationID: "listKeys", @@ -254,6 +265,13 @@ func (s *Apis) ListKeys(ctx context.Context, request operations.ListKeysRequest) } } + res := &operations.ListKeysResponse{ + HTTPMeta: components.HTTPMetadata{ + Request: req, + Response: httpRes, + }, + } + rawBody, err := io.ReadAll(httpRes.Body) if err != nil { return nil, fmt.Errorf("error reading response body: %w", err) @@ -270,7 +288,7 @@ func (s *Apis) ListKeys(ctx context.Context, request operations.ListKeysRequest) return nil, err } - return &out, nil + res.Object = &out default: return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } @@ -365,4 +383,190 @@ func (s *Apis) ListKeys(ctx context.Context, request operations.ListKeysRequest) default: return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) } + + return res, nil + +} + +func (s *Apis) DeleteKeys(ctx context.Context, request operations.DeleteKeysRequestBody) (*operations.DeleteKeysResponse, error) { + hookCtx := hooks.HookContext{ + Context: ctx, + OperationID: "deleteKeys", + OAuth2Scopes: []string{}, + SecuritySource: s.sdkConfiguration.Security, + } + + baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + opURL, err := url.JoinPath(baseURL, "/v1/apis.deleteKeys") + if err != nil { + return nil, fmt.Errorf("error generating URL: %w", err) + } + + bodyReader, reqContentType, err := utils.SerializeRequestBody(ctx, request, false, false, "Request", "json", `request:"mediaType=application/json"`) + if err != nil { + return nil, err + } + + req, err := http.NewRequestWithContext(ctx, "POST", opURL, bodyReader) + if err != nil { + return nil, fmt.Errorf("error creating request: %w", err) + } + req.Header.Set("Accept", "application/json") + req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent) + req.Header.Set("Content-Type", reqContentType) + + if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { + return nil, err + } + + req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, err + } + + httpRes, err := s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + return nil, err + } else if utils.MatchStatusCodes([]string{"400", "401", "403", "404", "409", "429", "4XX", "500", "5XX"}, httpRes.StatusCode) { + _httpRes, err := s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) + if err != nil { + return nil, err + } else if _httpRes != nil { + httpRes = _httpRes + } + } else { + httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + + res := &operations.DeleteKeysResponse{ + HTTPMeta: components.HTTPMetadata{ + Request: req, + Response: httpRes, + }, + } + + rawBody, err := io.ReadAll(httpRes.Body) + if err != nil { + return nil, fmt.Errorf("error reading response body: %w", err) + } + httpRes.Body.Close() + httpRes.Body = io.NopCloser(bytes.NewBuffer(rawBody)) + + switch { + case httpRes.StatusCode == 200: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + var out operations.DeleteKeysResponseBody + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + res.Object = &out + default: + return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + case httpRes.StatusCode == 400: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + var out sdkerrors.ErrBadRequest + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + return nil, &out + default: + return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + case httpRes.StatusCode == 401: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + var out sdkerrors.ErrUnauthorized + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + return nil, &out + default: + return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + case httpRes.StatusCode == 403: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + var out sdkerrors.ErrForbidden + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + return nil, &out + default: + return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + case httpRes.StatusCode == 404: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + var out sdkerrors.ErrNotFound + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + return nil, &out + default: + return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + case httpRes.StatusCode == 409: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + var out sdkerrors.ErrConflict + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + return nil, &out + default: + return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + case httpRes.StatusCode == 429: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + var out sdkerrors.ErrTooManyRequests + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + return nil, &out + default: + return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + case httpRes.StatusCode >= 400 && httpRes.StatusCode < 500: + fallthrough + case httpRes.StatusCode >= 500 && httpRes.StatusCode < 600: + return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) + case httpRes.StatusCode == 500: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + var out sdkerrors.ErrInternalServerError + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + return nil, &out + default: + return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + default: + return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) + } + + return res, nil + } diff --git a/docs/models/components/httpmetadata.md b/docs/models/components/httpmetadata.md new file mode 100644 index 0000000..df1fdd5 --- /dev/null +++ b/docs/models/components/httpmetadata.md @@ -0,0 +1,9 @@ +# HTTPMetadata + + +## Fields + +| Field | Type | Required | Description | +| ------------------------------------------------------- | ------------------------------------------------------- | ------------------------------------------------------- | ------------------------------------------------------- | +| `Response` | [*http.Response](https://pkg.go.dev/net/http#Response) | :heavy_check_mark: | Raw HTTP response; suitable for custom response parsing | +| `Request` | [*http.Request](https://pkg.go.dev/net/http#Request) | :heavy_check_mark: | Raw HTTP request; suitable for debugging | \ No newline at end of file diff --git a/docs/models/components/key.md b/docs/models/components/key.md index 40a4c93..8d6b2a4 100644 --- a/docs/models/components/key.md +++ b/docs/models/components/key.md @@ -12,12 +12,14 @@ | `Name` | **string* | :heavy_minus_sign: | The name of the key, give keys a name to easily identify their purpose | Customer X | | `OwnerID` | **string* | :heavy_minus_sign: | The id of the tenant associated with this key. Use whatever reference you have in your system to identify the tenant. When verifying the key, we will send this field back to you, so you know who is accessing your API. | user_123 | | `Meta` | map[string]*any* | :heavy_minus_sign: | Any additional metadata you want to store with the key | {
"roles": [
"admin",
"user"
],
"stripeCustomerId": "cus_1234"
} | -| `CreatedAt` | **float64* | :heavy_minus_sign: | The unix timestamp in milliseconds when the key was created | 0 | +| `CreatedAt` | *float64* | :heavy_check_mark: | The unix timestamp in milliseconds when the key was created | 0 | +| `UpdatedAt` | **float64* | :heavy_minus_sign: | The unix timestamp in milliseconds when the key was last updated | 0 | | `DeletedAt` | **float64* | :heavy_minus_sign: | The unix timestamp in milliseconds when the key was deleted. We don't delete the key outright, you can restore it later. | 0 | | `Expires` | **float64* | :heavy_minus_sign: | The unix timestamp in milliseconds when the key will expire. If this field is null or undefined, the key is not expiring. | 0 | | `Remaining` | **float64* | :heavy_minus_sign: | The number of requests that can be made with this key before it becomes invalid. If this field is null or undefined, the key has no request limit. | 1000 | | `Refill` | [*components.Refill](../../models/components/refill.md) | :heavy_minus_sign: | Unkey allows you to refill remaining verifications on a key on a regular interval. | {
"interval": "daily",
"amount": 10
} | -| `Ratelimit` | [*components.Ratelimit](../../models/components/ratelimit.md) | :heavy_minus_sign: | Unkey comes with per-key ratelimiting out of the box. | {
"type": "fast",
"limit": 10,
"refillRate": 1,
"refillInterval": 60
} | +| `Ratelimit` | [*components.Ratelimit](../../models/components/ratelimit.md) | :heavy_minus_sign: | Unkey comes with per-key ratelimiting out of the box. | {
"async": true,
"limit": 10,
"duration": 60
} | | `Roles` | []*string* | :heavy_minus_sign: | All roles this key belongs to | [
"admin",
"finance"
] | | `Permissions` | []*string* | :heavy_minus_sign: | All permissions this key has | [
"domain.dns.create_record",
"finance.read_receipt"
] | -| `Enabled` | **bool* | :heavy_minus_sign: | Sets if key is enabled or disabled. Disabled keys are not valid. | true | \ No newline at end of file +| `Enabled` | **bool* | :heavy_minus_sign: | Sets if key is enabled or disabled. Disabled keys are not valid. | true | +| `Plaintext` | **string* | :heavy_minus_sign: | The key in plaintext | | \ No newline at end of file diff --git a/docs/models/components/ratelimit.md b/docs/models/components/ratelimit.md index 5a50167..68305f6 100644 --- a/docs/models/components/ratelimit.md +++ b/docs/models/components/ratelimit.md @@ -7,7 +7,9 @@ Unkey comes with per-key ratelimiting out of the box. | Field | Type | Required | Description | | -------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------- | +| `Async` | *bool* | :heavy_check_mark: | N/A | | `Type` | [*components.Type](../../models/components/type.md) | :heavy_minus_sign: | Fast ratelimiting doesn't add latency, while consistent ratelimiting is more accurate.

[Learn more](https://unkey.dev/docs/features/ratelimiting) | | `Limit` | *int64* | :heavy_check_mark: | The total amount of burstable requests. | -| `RefillRate` | *int64* | :heavy_check_mark: | How many tokens to refill during each refillInterval. | -| `RefillInterval` | *int64* | :heavy_check_mark: | Determines the speed at which tokens are refilled, in milliseconds. | \ No newline at end of file +| `RefillRate` | **int64* | :heavy_minus_sign: | How many tokens to refill during each refillInterval. | +| `RefillInterval` | **int64* | :heavy_minus_sign: | Determines the speed at which tokens are refilled, in milliseconds. | +| `Duration` | *int64* | :heavy_check_mark: | The duration of the ratelimit window, in milliseconds. | \ No newline at end of file diff --git a/docs/models/operations/createapiresponse.md b/docs/models/operations/createapiresponse.md new file mode 100644 index 0000000..b58cd60 --- /dev/null +++ b/docs/models/operations/createapiresponse.md @@ -0,0 +1,9 @@ +# CreateAPIResponse + + +## Fields + +| Field | Type | Required | Description | +| ------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------- | +| `HTTPMeta` | [components.HTTPMetadata](../../models/components/httpmetadata.md) | :heavy_check_mark: | N/A | +| `Object` | [*operations.CreateAPIResponseBody](../../models/operations/createapiresponsebody.md) | :heavy_minus_sign: | The configuration for an api | \ No newline at end of file diff --git a/docs/models/operations/createkeyrequestbody.md b/docs/models/operations/createkeyrequestbody.md index 6274519..814c74b 100644 --- a/docs/models/operations/createkeyrequestbody.md +++ b/docs/models/operations/createkeyrequestbody.md @@ -3,18 +3,18 @@ ## Fields -| Field | Type | Required | Description | Example | -| --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `APIID` | *string* | :heavy_check_mark: | Choose an `API` where this key should be created. | api_123 | -| `Prefix` | **string* | :heavy_minus_sign: | To make it easier for your users to understand which product an api key belongs to, you can add prefix them.

For example Stripe famously prefixes their customer ids with cus_ or their api keys with sk_live_.

The underscore is automatically added if you are defining a prefix, for example: "prefix": "abc" will result in a key like abc_xxxxxxxxx
| | -| `Name` | **string* | :heavy_minus_sign: | The name for your Key. This is not customer facing. | my key | -| `ByteLength` | **int64* | :heavy_minus_sign: | The byte length used to generate your key determines its entropy as well as its length. Higher is better, but keys become longer and more annoying to handle. The default is 16 bytes, or 2^^128 possible combinations. | | -| `OwnerID` | **string* | :heavy_minus_sign: | Your user’s Id. This will provide a link between Unkey and your customer record.
When validating a key, we will return this back to you, so you can clearly identify your user from their api key. | team_123 | -| `Meta` | map[string]*any* | :heavy_minus_sign: | This is a place for dynamic meta data, anything that feels useful for you should go here | {
"billingTier": "PRO",
"trialEnds": "2023-06-16T17:16:37.161Z"
} | -| `Roles` | []*string* | :heavy_minus_sign: | A list of roles that this key should have. If the role does not exist, an error is thrown | [
"admin",
"finance"
] | -| `Expires` | **int64* | :heavy_minus_sign: | You can auto expire keys by providing a unix timestamp in milliseconds. Once Keys expire they will automatically be disabled and are no longer valid unless you enable them again. | 1623869797161 | -| `Remaining` | **int64* | :heavy_minus_sign: | You can limit the number of requests a key can make. Once a key reaches 0 remaining requests, it will automatically be disabled and is no longer valid unless you update it.

[Learn more](https://unkey.dev/docs/features/remaining) | 1000 | -| `Refill` | [*operations.Refill](../../models/operations/refill.md) | :heavy_minus_sign: | Unkey enables you to refill verifications for each key at regular intervals. | {
"interval": "daily",
"amount": 100
} | -| `Ratelimit` | [*operations.Ratelimit](../../models/operations/ratelimit.md) | :heavy_minus_sign: | Unkey comes with per-key ratelimiting out of the box. | {
"type": "fast",
"limit": 10,
"refillRate": 1,
"refillInterval": 60
} | -| `Enabled` | **bool* | :heavy_minus_sign: | Sets if key is enabled or disabled. Disabled keys are not valid. | false | -| `Environment` | **string* | :heavy_minus_sign: | Environments allow you to divide your keyspace.

Some applications like Stripe, Clerk, WorkOS and others have a concept of "live" and "test" keys to
give the developer a way to develop their own application without the risk of modifying real world
resources.

When you set an environment, we will return it back to you when validating the key, so you can
handle it correctly.
| | \ No newline at end of file +| Field | Type | Required | Description | Example | +| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | +| `APIID` | *string* | :heavy_check_mark: | Choose an `API` where this key should be created. | api_123 | +| `Prefix` | **string* | :heavy_minus_sign: | To make it easier for your users to understand which product an api key belongs to, you can add prefix them.

For example Stripe famously prefixes their customer ids with cus_ or their api keys with sk_live_.

The underscore is automatically added if you are defining a prefix, for example: "prefix": "abc" will result in a key like abc_xxxxxxxxx
| | +| `Name` | **string* | :heavy_minus_sign: | The name for your Key. This is not customer facing. | my key | +| `ByteLength` | **int64* | :heavy_minus_sign: | The byte length used to generate your key determines its entropy as well as its length. Higher is better, but keys become longer and more annoying to handle. The default is 16 bytes, or 2^^128 possible combinations. | | +| `OwnerID` | **string* | :heavy_minus_sign: | Your user’s Id. This will provide a link between Unkey and your customer record.
When validating a key, we will return this back to you, so you can clearly identify your user from their api key. | team_123 | +| `Meta` | map[string]*any* | :heavy_minus_sign: | This is a place for dynamic meta data, anything that feels useful for you should go here | {
"billingTier": "PRO",
"trialEnds": "2023-06-16T17:16:37.161Z"
} | +| `Roles` | []*string* | :heavy_minus_sign: | A list of roles that this key should have. If the role does not exist, an error is thrown | [
"admin",
"finance"
] | +| `Expires` | **int64* | :heavy_minus_sign: | You can auto expire keys by providing a unix timestamp in milliseconds. Once Keys expire they will automatically be disabled and are no longer valid unless you enable them again. | 1623869797161 | +| `Remaining` | **int64* | :heavy_minus_sign: | You can limit the number of requests a key can make. Once a key reaches 0 remaining requests, it will automatically be disabled and is no longer valid unless you update it.

[Learn more](https://unkey.dev/docs/features/remaining) | 1000 | +| `Refill` | [*operations.Refill](../../models/operations/refill.md) | :heavy_minus_sign: | Unkey enables you to refill verifications for each key at regular intervals. | {
"interval": "daily",
"amount": 100
} | +| `Ratelimit` | [*operations.Ratelimit](../../models/operations/ratelimit.md) | :heavy_minus_sign: | Unkey comes with per-key fixed-window ratelimiting out of the box. | {
"type": "fast",
"limit": 10,
"duration": 60000
} | +| `Enabled` | **bool* | :heavy_minus_sign: | Sets if key is enabled or disabled. Disabled keys are not valid. | false | +| `Environment` | **string* | :heavy_minus_sign: | Environments allow you to divide your keyspace.

Some applications like Stripe, Clerk, WorkOS and others have a concept of "live" and "test" keys to
give the developer a way to develop their own application without the risk of modifying real world
resources.

When you set an environment, we will return it back to you when validating the key, so you can
handle it correctly.
| | \ No newline at end of file diff --git a/docs/models/operations/createkeyresponse.md b/docs/models/operations/createkeyresponse.md new file mode 100644 index 0000000..3e4da02 --- /dev/null +++ b/docs/models/operations/createkeyresponse.md @@ -0,0 +1,9 @@ +# CreateKeyResponse + + +## Fields + +| Field | Type | Required | Description | +| ------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------- | +| `HTTPMeta` | [components.HTTPMetadata](../../models/components/httpmetadata.md) | :heavy_check_mark: | N/A | +| `Object` | [*operations.CreateKeyResponseBody](../../models/operations/createkeyresponsebody.md) | :heavy_minus_sign: | The configuration for an api | \ No newline at end of file diff --git a/docs/models/operations/deleteapiresponse.md b/docs/models/operations/deleteapiresponse.md new file mode 100644 index 0000000..e9c7925 --- /dev/null +++ b/docs/models/operations/deleteapiresponse.md @@ -0,0 +1,9 @@ +# DeleteAPIResponse + + +## Fields + +| Field | Type | Required | Description | +| ---------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------- | +| `HTTPMeta` | [components.HTTPMetadata](../../models/components/httpmetadata.md) | :heavy_check_mark: | N/A | +| `Object` | [*operations.DeleteAPIResponseBody](../../models/operations/deleteapiresponsebody.md) | :heavy_minus_sign: | The api was successfully deleted, it may take up to 30s for this to take effect in all regions | \ No newline at end of file diff --git a/docs/models/operations/deletekeyresponse.md b/docs/models/operations/deletekeyresponse.md new file mode 100644 index 0000000..395e7fd --- /dev/null +++ b/docs/models/operations/deletekeyresponse.md @@ -0,0 +1,9 @@ +# DeleteKeyResponse + + +## Fields + +| Field | Type | Required | Description | +| ---------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------- | +| `HTTPMeta` | [components.HTTPMetadata](../../models/components/httpmetadata.md) | :heavy_check_mark: | N/A | +| `Object` | [*operations.DeleteKeyResponseBody](../../models/operations/deletekeyresponsebody.md) | :heavy_minus_sign: | The key was successfully revoked, it may take up to 30s for this to take effect in all regions | \ No newline at end of file diff --git a/docs/models/operations/deletekeysrequestbody.md b/docs/models/operations/deletekeysrequestbody.md new file mode 100644 index 0000000..86e359a --- /dev/null +++ b/docs/models/operations/deletekeysrequestbody.md @@ -0,0 +1,9 @@ +# DeleteKeysRequestBody + + +## Fields + +| Field | Type | Required | Description | Example | +| ------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------ | +| `APIID` | *string* | :heavy_check_mark: | The id of the api, that the keys belong to. | api_1234 | +| `Permanent` | **bool* | :heavy_minus_sign: | If true, the keys will be permanently deleted. If false, the keys will be soft-deleted and can be restored later. | | \ No newline at end of file diff --git a/docs/models/operations/deletekeysresponse.md b/docs/models/operations/deletekeysresponse.md new file mode 100644 index 0000000..8419df0 --- /dev/null +++ b/docs/models/operations/deletekeysresponse.md @@ -0,0 +1,9 @@ +# DeleteKeysResponse + + +## Fields + +| Field | Type | Required | Description | +| --------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------- | +| `HTTPMeta` | [components.HTTPMetadata](../../models/components/httpmetadata.md) | :heavy_check_mark: | N/A | +| `Object` | [*operations.DeleteKeysResponseBody](../../models/operations/deletekeysresponsebody.md) | :heavy_minus_sign: | The keys have been deleted | \ No newline at end of file diff --git a/docs/models/operations/deletekeysresponsebody.md b/docs/models/operations/deletekeysresponsebody.md new file mode 100644 index 0000000..6e04d25 --- /dev/null +++ b/docs/models/operations/deletekeysresponsebody.md @@ -0,0 +1,10 @@ +# DeleteKeysResponseBody + +The keys have been deleted + + +## Fields + +| Field | Type | Required | Description | +| ------------------------------------ | ------------------------------------ | ------------------------------------ | ------------------------------------ | +| `DeletedKeys` | *float64* | :heavy_check_mark: | The number of keys that were deleted | \ No newline at end of file diff --git a/docs/models/operations/getapiresponse.md b/docs/models/operations/getapiresponse.md new file mode 100644 index 0000000..dc5ba70 --- /dev/null +++ b/docs/models/operations/getapiresponse.md @@ -0,0 +1,9 @@ +# GetAPIResponse + + +## Fields + +| Field | Type | Required | Description | +| ------------------------------------------------------------------------------- | ------------------------------------------------------------------------------- | ------------------------------------------------------------------------------- | ------------------------------------------------------------------------------- | +| `HTTPMeta` | [components.HTTPMetadata](../../models/components/httpmetadata.md) | :heavy_check_mark: | N/A | +| `Object` | [*operations.GetAPIResponseBody](../../models/operations/getapiresponsebody.md) | :heavy_minus_sign: | The configuration for an api | \ No newline at end of file diff --git a/docs/models/operations/getkeyrequest.md b/docs/models/operations/getkeyrequest.md index 07227c6..9e75c84 100644 --- a/docs/models/operations/getkeyrequest.md +++ b/docs/models/operations/getkeyrequest.md @@ -5,4 +5,5 @@ | Field | Type | Required | Description | Example | | ------------------ | ------------------ | ------------------ | ------------------ | ------------------ | -| `KeyID` | *string* | :heavy_check_mark: | N/A | key_1234 | \ No newline at end of file +| `KeyID` | *string* | :heavy_check_mark: | N/A | key_1234 | +| `Decrypt` | **bool* | :heavy_minus_sign: | N/A | | \ No newline at end of file diff --git a/docs/models/operations/getkeyresponse.md b/docs/models/operations/getkeyresponse.md new file mode 100644 index 0000000..2d71bd3 --- /dev/null +++ b/docs/models/operations/getkeyresponse.md @@ -0,0 +1,9 @@ +# GetKeyResponse + + +## Fields + +| Field | Type | Required | Description | +| ------------------------------------------------------------------ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | +| `HTTPMeta` | [components.HTTPMetadata](../../models/components/httpmetadata.md) | :heavy_check_mark: | N/A | +| `Key` | [*components.Key](../../models/components/key.md) | :heavy_minus_sign: | The configuration for a single key | \ No newline at end of file diff --git a/docs/models/operations/getverificationsresponse.md b/docs/models/operations/getverificationsresponse.md new file mode 100644 index 0000000..a6871b1 --- /dev/null +++ b/docs/models/operations/getverificationsresponse.md @@ -0,0 +1,9 @@ +# GetVerificationsResponse + + +## Fields + +| Field | Type | Required | Description | +| --------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------- | +| `HTTPMeta` | [components.HTTPMetadata](../../models/components/httpmetadata.md) | :heavy_check_mark: | N/A | +| `Object` | [*operations.GetVerificationsResponseBody](../../models/operations/getverificationsresponsebody.md) | :heavy_minus_sign: | Usage numbers over time | \ No newline at end of file diff --git a/docs/models/operations/hash.md b/docs/models/operations/hash.md index 2dd3176..60be1ec 100644 --- a/docs/models/operations/hash.md +++ b/docs/models/operations/hash.md @@ -1,5 +1,7 @@ # Hash +Provide either `hash` or `plaintext` + ## Fields diff --git a/docs/models/operations/limitresponse.md b/docs/models/operations/limitresponse.md new file mode 100644 index 0000000..8647ca9 --- /dev/null +++ b/docs/models/operations/limitresponse.md @@ -0,0 +1,9 @@ +# LimitResponse + + +## Fields + +| Field | Type | Required | Description | +| ----------------------------------------------------------------------------- | ----------------------------------------------------------------------------- | ----------------------------------------------------------------------------- | ----------------------------------------------------------------------------- | +| `HTTPMeta` | [components.HTTPMetadata](../../models/components/httpmetadata.md) | :heavy_check_mark: | N/A | +| `Object` | [*operations.LimitResponseBody](../../models/operations/limitresponsebody.md) | :heavy_minus_sign: | N/A | \ No newline at end of file diff --git a/docs/models/operations/listkeysrequest.md b/docs/models/operations/listkeysrequest.md index 7fd1b64..9046952 100644 --- a/docs/models/operations/listkeysrequest.md +++ b/docs/models/operations/listkeysrequest.md @@ -8,4 +8,5 @@ | `APIID` | *string* | :heavy_check_mark: | N/A | api_1234 | | `Limit` | **int64* | :heavy_minus_sign: | N/A | 100 | | `Cursor` | **string* | :heavy_minus_sign: | N/A | | -| `OwnerID` | **string* | :heavy_minus_sign: | N/A | | \ No newline at end of file +| `OwnerID` | **string* | :heavy_minus_sign: | N/A | | +| `Decrypt` | **bool* | :heavy_minus_sign: | N/A | | \ No newline at end of file diff --git a/docs/models/operations/listkeysresponse.md b/docs/models/operations/listkeysresponse.md new file mode 100644 index 0000000..57465ef --- /dev/null +++ b/docs/models/operations/listkeysresponse.md @@ -0,0 +1,9 @@ +# ListKeysResponse + + +## Fields + +| Field | Type | Required | Description | +| ----------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------- | +| `HTTPMeta` | [components.HTTPMetadata](../../models/components/httpmetadata.md) | :heavy_check_mark: | N/A | +| `Object` | [*operations.ListKeysResponseBody](../../models/operations/listkeysresponsebody.md) | :heavy_minus_sign: | The configuration for an api | \ No newline at end of file diff --git a/docs/models/operations/ratelimit.md b/docs/models/operations/ratelimit.md index 7caa3bf..87c5b11 100644 --- a/docs/models/operations/ratelimit.md +++ b/docs/models/operations/ratelimit.md @@ -1,13 +1,15 @@ # Ratelimit -Unkey comes with per-key ratelimiting out of the box. +Unkey comes with per-key fixed-window ratelimiting out of the box. ## Fields -| Field | Type | Required | Description | -| -------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------- | -| `Type` | [*operations.Type](../../models/operations/type.md) | :heavy_minus_sign: | Fast ratelimiting doesn't add latency, while consistent ratelimiting is more accurate.

[Learn more](https://unkey.dev/docs/features/ratelimiting) | -| `Limit` | *int64* | :heavy_check_mark: | The total amount of burstable requests. | -| `RefillRate` | *int64* | :heavy_check_mark: | How many tokens to refill during each refillInterval. | -| `RefillInterval` | *int64* | :heavy_check_mark: | Determines the speed at which tokens are refilled, in milliseconds. | \ No newline at end of file +| Field | Type | Required | Description | Example | +| ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `Async` | **bool* | :heavy_minus_sign: | Async will return a response immediately, lowering latency at the cost of accuracy.

[Learn more](https://unkey.dev/docs/features/ratelimiting) | | +| ~~`Type`~~ | [*operations.Type](../../models/operations/type.md) | :heavy_minus_sign: | : warning: ** DEPRECATED **: This will be removed in a future release, please migrate away from it as soon as possible.

Deprecated, used `async`. Fast ratelimiting doesn't add latency, while consistent ratelimiting is more accurate.

[Learn more](https://unkey.dev/docs/features/ratelimiting) | | +| `Limit` | *int64* | :heavy_check_mark: | The total amount of requests in a given interval. | | +| `Duration` | *int64* | :heavy_check_mark: | The window duration in milliseconds | 60000 | +| ~~`RefillRate`~~ | **int64* | :heavy_minus_sign: | : warning: ** DEPRECATED **: This will be removed in a future release, please migrate away from it as soon as possible.

How many tokens to refill during each refillInterval. | | +| ~~`RefillInterval`~~ | **int64* | :heavy_minus_sign: | : warning: ** DEPRECATED **: This will be removed in a future release, please migrate away from it as soon as possible.

The refill timeframe, in milliseconds. | | \ No newline at end of file diff --git a/docs/models/operations/requestbody.md b/docs/models/operations/requestbody.md index a89525e..1b0a47c 100644 --- a/docs/models/operations/requestbody.md +++ b/docs/models/operations/requestbody.md @@ -3,19 +3,20 @@ ## Fields -| Field | Type | Required | Description | Example | -| --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `APIID` | *string* | :heavy_check_mark: | Choose an `API` where this key should be created. | api_123 | -| `Prefix` | **string* | :heavy_minus_sign: | To make it easier for your users to understand which product an api key belongs to, you can add prefix them.

For example Stripe famously prefixes their customer ids with cus_ or their api keys with sk_live_.

The underscore is automatically added if you are defining a prefix, for example: "prefix": "abc" will result in a key like abc_xxxxxxxxx
| | -| `Name` | **string* | :heavy_minus_sign: | The name for your Key. This is not customer facing. | my key | -| `Hash` | [operations.Hash](../../models/operations/hash.md) | :heavy_check_mark: | N/A | | -| `Start` | **string* | :heavy_minus_sign: | The first 4 characters of the key. If a prefix is used, it should be the prefix plus 4 characters. | unkey_32kq | -| `OwnerID` | **string* | :heavy_minus_sign: | Your user’s Id. This will provide a link between Unkey and your customer record.
When validating a key, we will return this back to you, so you can clearly identify your user from their api key. | team_123 | -| `Meta` | map[string]*any* | :heavy_minus_sign: | This is a place for dynamic meta data, anything that feels useful for you should go here | {
"billingTier": "PRO",
"trialEnds": "2023-06-16T17:16:37.161Z"
} | -| `Roles` | []*string* | :heavy_minus_sign: | A list of roles that this key should have. If the role does not exist, an error is thrown | [
"admin",
"finance"
] | -| `Expires` | **int64* | :heavy_minus_sign: | You can auto expire keys by providing a unix timestamp in milliseconds. Once Keys expire they will automatically be disabled and are no longer valid unless you enable them again. | 1623869797161 | -| `Remaining` | **int64* | :heavy_minus_sign: | You can limit the number of requests a key can make. Once a key reaches 0 remaining requests, it will automatically be disabled and is no longer valid unless you update it.

[Learn more](https://unkey.dev/docs/features/remaining) | 1000 | -| `Refill` | [*operations.V1MigrationsCreateKeysRefill](../../models/operations/v1migrationscreatekeysrefill.md) | :heavy_minus_sign: | Unkey enables you to refill verifications for each key at regular intervals. | {
"interval": "daily",
"amount": 100
} | -| `Ratelimit` | [*operations.V1MigrationsCreateKeysRatelimit](../../models/operations/v1migrationscreatekeysratelimit.md) | :heavy_minus_sign: | Unkey comes with per-key ratelimiting out of the box. | {
"type": "fast",
"limit": 10,
"refillRate": 1,
"refillInterval": 60
} | -| `Enabled` | **bool* | :heavy_minus_sign: | Sets if key is enabled or disabled. Disabled keys are not valid. | false | -| `Environment` | **string* | :heavy_minus_sign: | Environments allow you to divide your keyspace.

Some applications like Stripe, Clerk, WorkOS and others have a concept of "live" and "test" keys to
give the developer a way to develop their own application without the risk of modifying real world
resources.

When you set an environment, we will return it back to you when validating the key, so you can
handle it correctly.
| | \ No newline at end of file +| Field | Type | Required | Description | Example | +| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | +| `APIID` | *string* | :heavy_check_mark: | Choose an `API` where this key should be created. | api_123 | +| `Prefix` | **string* | :heavy_minus_sign: | To make it easier for your users to understand which product an api key belongs to, you can add prefix them.

For example Stripe famously prefixes their customer ids with cus_ or their api keys with sk_live_.

The underscore is automatically added if you are defining a prefix, for example: "prefix": "abc" will result in a key like abc_xxxxxxxxx
| | +| `Name` | **string* | :heavy_minus_sign: | The name for your Key. This is not customer facing. | my key | +| `Plaintext` | **string* | :heavy_minus_sign: | The raw key in plaintext. If provided, unkey encrypts this value and stores it securely. Provide either `hash` or `plaintext` | | +| `Hash` | [*operations.Hash](../../models/operations/hash.md) | :heavy_minus_sign: | Provide either `hash` or `plaintext` | | +| `Start` | **string* | :heavy_minus_sign: | The first 4 characters of the key. If a prefix is used, it should be the prefix plus 4 characters. | unkey_32kq | +| `OwnerID` | **string* | :heavy_minus_sign: | Your user’s Id. This will provide a link between Unkey and your customer record.
When validating a key, we will return this back to you, so you can clearly identify your user from their api key. | team_123 | +| `Meta` | map[string]*any* | :heavy_minus_sign: | This is a place for dynamic meta data, anything that feels useful for you should go here | {
"billingTier": "PRO",
"trialEnds": "2023-06-16T17:16:37.161Z"
} | +| `Roles` | []*string* | :heavy_minus_sign: | A list of roles that this key should have. If the role does not exist, an error is thrown | [
"admin",
"finance"
] | +| `Expires` | **int64* | :heavy_minus_sign: | You can auto expire keys by providing a unix timestamp in milliseconds. Once Keys expire they will automatically be disabled and are no longer valid unless you enable them again. | 1623869797161 | +| `Remaining` | **int64* | :heavy_minus_sign: | You can limit the number of requests a key can make. Once a key reaches 0 remaining requests, it will automatically be disabled and is no longer valid unless you update it.

[Learn more](https://unkey.dev/docs/features/remaining) | 1000 | +| `Refill` | [*operations.V1MigrationsCreateKeysRefill](../../models/operations/v1migrationscreatekeysrefill.md) | :heavy_minus_sign: | Unkey enables you to refill verifications for each key at regular intervals. | {
"interval": "daily",
"amount": 100
} | +| `Ratelimit` | [*operations.V1MigrationsCreateKeysRatelimit](../../models/operations/v1migrationscreatekeysratelimit.md) | :heavy_minus_sign: | Unkey comes with per-key ratelimiting out of the box. | {
"type": "fast",
"limit": 10,
"refillRate": 1,
"refillInterval": 60
} | +| `Enabled` | **bool* | :heavy_minus_sign: | Sets if key is enabled or disabled. Disabled keys are not valid. | false | +| `Environment` | **string* | :heavy_minus_sign: | Environments allow you to divide your keyspace.

Some applications like Stripe, Clerk, WorkOS and others have a concept of "live" and "test" keys to
give the developer a way to develop their own application without the risk of modifying real world
resources.

When you set an environment, we will return it back to you when validating the key, so you can
handle it correctly.
| | \ No newline at end of file diff --git a/docs/models/operations/type.md b/docs/models/operations/type.md index e06fa5d..4afd5bf 100644 --- a/docs/models/operations/type.md +++ b/docs/models/operations/type.md @@ -1,10 +1,12 @@ -# Type +# ~~Type~~ -Fast ratelimiting doesn't add latency, while consistent ratelimiting is more accurate. +Deprecated, used `async`. Fast ratelimiting doesn't add latency, while consistent ratelimiting is more accurate. Learn more +> :warning: **DEPRECATED**: This will be removed in a future release, please migrate away from it as soon as possible. + ## Values diff --git a/docs/models/operations/updatekeyratelimit.md b/docs/models/operations/updatekeyratelimit.md index 049e1ed..07b001e 100644 --- a/docs/models/operations/updatekeyratelimit.md +++ b/docs/models/operations/updatekeyratelimit.md @@ -5,9 +5,11 @@ Unkey comes with per-key ratelimiting out of the box. Set `null` to disable. ## Fields -| Field | Type | Required | Description | -| -------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------- | -| `Type` | [operations.UpdateKeyType](../../models/operations/updatekeytype.md) | :heavy_check_mark: | Fast ratelimiting doesn't add latency, while consistent ratelimiting is more accurate.

[Learn more](https://unkey.dev/docs/features/ratelimiting) | -| `Limit` | *int64* | :heavy_check_mark: | The total amount of burstable requests. | -| `RefillRate` | *int64* | :heavy_check_mark: | How many tokens to refill during each refillInterval. | -| `RefillInterval` | *int64* | :heavy_check_mark: | Determines the speed at which tokens are refilled, in milliseconds. | \ No newline at end of file +| Field | Type | Required | Description | +| --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| ~~`Type`~~ | [*operations.UpdateKeyType](../../models/operations/updatekeytype.md) | :heavy_minus_sign: | : warning: ** DEPRECATED **: This will be removed in a future release, please migrate away from it as soon as possible.

Fast ratelimiting doesn't add latency, while consistent ratelimiting is more accurate.

[Learn more](https://unkey.dev/docs/features/ratelimiting) | +| `Async` | **bool* | :heavy_minus_sign: | Asnyc ratelimiting doesn't add latency, while sync ratelimiting is more accurate.

[Learn more](https://unkey.dev/docs/features/ratelimiting) | +| `Limit` | *int64* | :heavy_check_mark: | The total amount of burstable requests. | +| ~~`RefillRate`~~ | **int64* | :heavy_minus_sign: | : warning: ** DEPRECATED **: This will be removed in a future release, please migrate away from it as soon as possible.

How many tokens to refill during each refillInterval. | +| `RefillInterval` | *int64* | :heavy_check_mark: | Determines the speed at which tokens are refilled, in milliseconds. | +| `Duration` | **int64* | :heavy_minus_sign: | The duration of each ratelimit window, in milliseconds. | \ No newline at end of file diff --git a/docs/models/operations/updatekeyresponse.md b/docs/models/operations/updatekeyresponse.md new file mode 100644 index 0000000..307e0ac --- /dev/null +++ b/docs/models/operations/updatekeyresponse.md @@ -0,0 +1,9 @@ +# UpdateKeyResponse + + +## Fields + +| Field | Type | Required | Description | +| ---------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------- | +| `HTTPMeta` | [components.HTTPMetadata](../../models/components/httpmetadata.md) | :heavy_check_mark: | N/A | +| `Object` | [*operations.UpdateKeyResponseBody](../../models/operations/updatekeyresponsebody.md) | :heavy_minus_sign: | The key was successfully updated, it may take up to 30s for this to take effect in all regions | \ No newline at end of file diff --git a/docs/models/operations/updatekeytype.md b/docs/models/operations/updatekeytype.md index 4e2bfa4..1eb7f6b 100644 --- a/docs/models/operations/updatekeytype.md +++ b/docs/models/operations/updatekeytype.md @@ -1,10 +1,12 @@ -# UpdateKeyType +# ~~UpdateKeyType~~ Fast ratelimiting doesn't add latency, while consistent ratelimiting is more accurate. Learn more +> :warning: **DEPRECATED**: This will be removed in a future release, please migrate away from it as soon as possible. + ## Values diff --git a/docs/models/operations/updateremainingresponse.md b/docs/models/operations/updateremainingresponse.md new file mode 100644 index 0000000..ba7de12 --- /dev/null +++ b/docs/models/operations/updateremainingresponse.md @@ -0,0 +1,9 @@ +# UpdateRemainingResponse + + +## Fields + +| Field | Type | Required | Description | +| ------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------- | +| `HTTPMeta` | [components.HTTPMetadata](../../models/components/httpmetadata.md) | :heavy_check_mark: | N/A | +| `Object` | [*operations.UpdateRemainingResponseBody](../../models/operations/updateremainingresponsebody.md) | :heavy_minus_sign: | The configuration for an api | \ No newline at end of file diff --git a/docs/models/operations/v1livenessresponse.md b/docs/models/operations/v1livenessresponse.md new file mode 100644 index 0000000..eafbf32 --- /dev/null +++ b/docs/models/operations/v1livenessresponse.md @@ -0,0 +1,9 @@ +# V1LivenessResponse + + +## Fields + +| Field | Type | Required | Description | +| --------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------- | +| `HTTPMeta` | [components.HTTPMetadata](../../models/components/httpmetadata.md) | :heavy_check_mark: | N/A | +| `Object` | [*operations.V1LivenessResponseBody](../../models/operations/v1livenessresponsebody.md) | :heavy_minus_sign: | The configured services and their status | \ No newline at end of file diff --git a/docs/models/operations/v1migrationscreatekeysratelimit.md b/docs/models/operations/v1migrationscreatekeysratelimit.md index cd5a254..1affb78 100644 --- a/docs/models/operations/v1migrationscreatekeysratelimit.md +++ b/docs/models/operations/v1migrationscreatekeysratelimit.md @@ -5,9 +5,10 @@ Unkey comes with per-key ratelimiting out of the box. ## Fields -| Field | Type | Required | Description | -| -------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------- | -| `Type` | [*operations.V1MigrationsCreateKeysType](../../models/operations/v1migrationscreatekeystype.md) | :heavy_minus_sign: | Fast ratelimiting doesn't add latency, while consistent ratelimiting is more accurate.

[Learn more](https://unkey.dev/docs/features/ratelimiting) | -| `Limit` | *int64* | :heavy_check_mark: | The total amount of burstable requests. | -| `RefillRate` | *int64* | :heavy_check_mark: | How many tokens to refill during each refillInterval. | -| `RefillInterval` | *int64* | :heavy_check_mark: | Determines the speed at which tokens are refilled, in milliseconds. | \ No newline at end of file +| Field | Type | Required | Description | +| --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `Async` | **bool* | :heavy_minus_sign: | Async will return a response immediately, lowering latency at the cost of accuracy.

[Learn more](https://unkey.dev/docs/features/ratelimiting) | +| ~~`Type`~~ | [*operations.V1MigrationsCreateKeysType](../../models/operations/v1migrationscreatekeystype.md) | :heavy_minus_sign: | : warning: ** DEPRECATED **: This will be removed in a future release, please migrate away from it as soon as possible.

Fast ratelimiting doesn't add latency, while consistent ratelimiting is more accurate.

[Learn more](https://unkey.dev/docs/features/ratelimiting) | +| `Limit` | *int64* | :heavy_check_mark: | The total amount of burstable requests. | +| ~~`RefillRate`~~ | *int64* | :heavy_check_mark: | : warning: ** DEPRECATED **: This will be removed in a future release, please migrate away from it as soon as possible.

How many tokens to refill during each refillInterval. | +| ~~`RefillInterval`~~ | *int64* | :heavy_check_mark: | : warning: ** DEPRECATED **: This will be removed in a future release, please migrate away from it as soon as possible.

Determines the speed at which tokens are refilled, in milliseconds. | \ No newline at end of file diff --git a/docs/models/operations/v1migrationscreatekeysresponse.md b/docs/models/operations/v1migrationscreatekeysresponse.md new file mode 100644 index 0000000..ee60190 --- /dev/null +++ b/docs/models/operations/v1migrationscreatekeysresponse.md @@ -0,0 +1,9 @@ +# V1MigrationsCreateKeysResponse + + +## Fields + +| Field | Type | Required | Description | +| --------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------- | +| `HTTPMeta` | [components.HTTPMetadata](../../models/components/httpmetadata.md) | :heavy_check_mark: | N/A | +| `Object` | [*operations.V1MigrationsCreateKeysResponseBody](../../models/operations/v1migrationscreatekeysresponsebody.md) | :heavy_minus_sign: | The key ids of all created keys | \ No newline at end of file diff --git a/docs/models/operations/v1migrationscreatekeystype.md b/docs/models/operations/v1migrationscreatekeystype.md index fbc7b8d..3f445da 100644 --- a/docs/models/operations/v1migrationscreatekeystype.md +++ b/docs/models/operations/v1migrationscreatekeystype.md @@ -1,10 +1,12 @@ -# V1MigrationsCreateKeysType +# ~~V1MigrationsCreateKeysType~~ Fast ratelimiting doesn't add latency, while consistent ratelimiting is more accurate. Learn more +> :warning: **DEPRECATED**: This will be removed in a future release, please migrate away from it as soon as possible. + ## Values diff --git a/docs/models/operations/verifykeyresponse.md b/docs/models/operations/verifykeyresponse.md new file mode 100644 index 0000000..158642c --- /dev/null +++ b/docs/models/operations/verifykeyresponse.md @@ -0,0 +1,9 @@ +# VerifyKeyResponse + + +## Fields + +| Field | Type | Required | Description | +| ----------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- | +| `HTTPMeta` | [components.HTTPMetadata](../../models/components/httpmetadata.md) | :heavy_check_mark: | N/A | +| `V1KeysVerifyKeyResponse` | [*components.V1KeysVerifyKeyResponse](../../models/components/v1keysverifykeyresponse.md) | :heavy_minus_sign: | The verification result | \ No newline at end of file diff --git a/docs/sdks/apis/README.md b/docs/sdks/apis/README.md index 8294df9..7174581 100644 --- a/docs/sdks/apis/README.md +++ b/docs/sdks/apis/README.md @@ -5,6 +5,7 @@ * [GetAPI](#getapi) * [ListKeys](#listkeys) +* [DeleteKeys](#deletekeys) ## GetAPI @@ -14,7 +15,6 @@ package main import( - "github.com/unkeyed/unkey-go/models/components" unkeygo "github.com/unkeyed/unkey-go" "github.com/unkeyed/unkey-go/models/operations" "context" @@ -25,17 +25,15 @@ func main() { s := unkeygo.New( unkeygo.WithSecurity(""), ) - request := operations.GetAPIRequest{ APIID: "api_1234", } - ctx := context.Background() res, err := s.Apis.GetAPI(ctx, request) if err != nil { log.Fatal(err) } - if res != nil { + if res.Object != nil { // handle response } } @@ -51,7 +49,7 @@ func main() { ### Response -**[*operations.GetAPIResponseBody](../../models/operations/getapiresponsebody.md), error** +**[*operations.GetAPIResponse](../../models/operations/getapiresponse.md), error** | Error Object | Status Code | Content Type | | -------------------------------- | -------------------------------- | -------------------------------- | | sdkerrors.ErrBadRequest | 400 | application/json | @@ -71,7 +69,6 @@ func main() { package main import( - "github.com/unkeyed/unkey-go/models/components" unkeygo "github.com/unkeyed/unkey-go" "github.com/unkeyed/unkey-go/models/operations" "context" @@ -82,18 +79,16 @@ func main() { s := unkeygo.New( unkeygo.WithSecurity(""), ) - request := operations.ListKeysRequest{ APIID: "api_1234", Limit: unkeygo.Int64(100), } - ctx := context.Background() res, err := s.Apis.ListKeys(ctx, request) if err != nil { log.Fatal(err) } - if res != nil { + if res.Object != nil { // handle response } } @@ -109,7 +104,61 @@ func main() { ### Response -**[*operations.ListKeysResponseBody](../../models/operations/listkeysresponsebody.md), error** +**[*operations.ListKeysResponse](../../models/operations/listkeysresponse.md), error** +| Error Object | Status Code | Content Type | +| -------------------------------- | -------------------------------- | -------------------------------- | +| sdkerrors.ErrBadRequest | 400 | application/json | +| sdkerrors.ErrUnauthorized | 401 | application/json | +| sdkerrors.ErrForbidden | 403 | application/json | +| sdkerrors.ErrNotFound | 404 | application/json | +| sdkerrors.ErrConflict | 409 | application/json | +| sdkerrors.ErrTooManyRequests | 429 | application/json | +| sdkerrors.ErrInternalServerError | 500 | application/json | +| sdkerrors.SDKError | 4xx-5xx | */* | + +## DeleteKeys + +### Example Usage + +```go +package main + +import( + unkeygo "github.com/unkeyed/unkey-go" + "github.com/unkeyed/unkey-go/models/operations" + "context" + "log" +) + +func main() { + s := unkeygo.New( + unkeygo.WithSecurity(""), + ) + request := operations.DeleteKeysRequestBody{ + APIID: "api_1234", + } + ctx := context.Background() + res, err := s.Apis.DeleteKeys(ctx, request) + if err != nil { + log.Fatal(err) + } + if res.Object != nil { + // handle response + } +} +``` + +### Parameters + +| Parameter | Type | Required | Description | +| ------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------ | +| `ctx` | [context.Context](https://pkg.go.dev/context#Context) | :heavy_check_mark: | The context to use for the request. | +| `request` | [operations.DeleteKeysRequestBody](../../models/operations/deletekeysrequestbody.md) | :heavy_check_mark: | The request object to use for the request. | + + +### Response + +**[*operations.DeleteKeysResponse](../../models/operations/deletekeysresponse.md), error** | Error Object | Status Code | Content Type | | -------------------------------- | -------------------------------- | -------------------------------- | | sdkerrors.ErrBadRequest | 400 | application/json | diff --git a/docs/sdks/keys/README.md b/docs/sdks/keys/README.md index dd75fb9..06ac4dc 100644 --- a/docs/sdks/keys/README.md +++ b/docs/sdks/keys/README.md @@ -19,7 +19,6 @@ package main import( - "github.com/unkeyed/unkey-go/models/components" unkeygo "github.com/unkeyed/unkey-go" "github.com/unkeyed/unkey-go/models/operations" "context" @@ -30,17 +29,15 @@ func main() { s := unkeygo.New( unkeygo.WithSecurity(""), ) - request := operations.GetKeyRequest{ KeyID: "key_1234", } - ctx := context.Background() res, err := s.Keys.GetKey(ctx, request) if err != nil { log.Fatal(err) } - if res != nil { + if res.Key != nil { // handle response } } @@ -56,7 +53,7 @@ func main() { ### Response -**[*components.Key](../../models/components/key.md), error** +**[*operations.GetKeyResponse](../../models/operations/getkeyresponse.md), error** | Error Object | Status Code | Content Type | | -------------------------------- | -------------------------------- | -------------------------------- | | sdkerrors.ErrBadRequest | 400 | application/json | @@ -76,7 +73,6 @@ func main() { package main import( - "github.com/unkeyed/unkey-go/models/components" unkeygo "github.com/unkeyed/unkey-go" "github.com/unkeyed/unkey-go/models/operations" "context" @@ -87,17 +83,15 @@ func main() { s := unkeygo.New( unkeygo.WithSecurity(""), ) - request := operations.DeleteKeyRequestBody{ KeyID: "key_1234", } - ctx := context.Background() res, err := s.Keys.DeleteKey(ctx, request) if err != nil { log.Fatal(err) } - if res != nil { + if res.Object != nil { // handle response } } @@ -113,7 +107,7 @@ func main() { ### Response -**[*operations.DeleteKeyResponseBody](../../models/operations/deletekeyresponsebody.md), error** +**[*operations.DeleteKeyResponse](../../models/operations/deletekeyresponse.md), error** | Error Object | Status Code | Content Type | | -------------------------------- | -------------------------------- | -------------------------------- | | sdkerrors.ErrBadRequest | 400 | application/json | @@ -133,7 +127,6 @@ func main() { package main import( - "github.com/unkeyed/unkey-go/models/components" unkeygo "github.com/unkeyed/unkey-go" "github.com/unkeyed/unkey-go/models/operations" "context" @@ -144,7 +137,6 @@ func main() { s := unkeygo.New( unkeygo.WithSecurity(""), ) - request := operations.CreateKeyRequestBody{ APIID: "api_123", Name: unkeygo.String("my key"), @@ -164,20 +156,17 @@ func main() { Amount: 100, }, Ratelimit: &operations.Ratelimit{ - Type: operations.TypeFast.ToPointer(), Limit: 10, - RefillRate: 1, - RefillInterval: 60, + Duration: 60000, }, Enabled: unkeygo.Bool(false), } - ctx := context.Background() res, err := s.Keys.CreateKey(ctx, request) if err != nil { log.Fatal(err) } - if res != nil { + if res.Object != nil { // handle response } } @@ -193,7 +182,7 @@ func main() { ### Response -**[*operations.CreateKeyResponseBody](../../models/operations/createkeyresponsebody.md), error** +**[*operations.CreateKeyResponse](../../models/operations/createkeyresponse.md), error** | Error Object | Status Code | Content Type | | -------------------------------- | -------------------------------- | -------------------------------- | | sdkerrors.ErrBadRequest | 400 | application/json | @@ -213,8 +202,8 @@ func main() { package main import( - "github.com/unkeyed/unkey-go/models/components" unkeygo "github.com/unkeyed/unkey-go" + "github.com/unkeyed/unkey-go/models/components" "context" "log" ) @@ -223,7 +212,6 @@ func main() { s := unkeygo.New( unkeygo.WithSecurity(""), ) - request := components.V1KeysVerifyKeyRequest{ APIID: unkeygo.String("api_1234"), Key: "sk_1234", @@ -231,13 +219,12 @@ func main() { Permissions: &components.Permissions{}, }, } - ctx := context.Background() res, err := s.Keys.VerifyKey(ctx, request) if err != nil { log.Fatal(err) } - if res != nil { + if res.V1KeysVerifyKeyResponse != nil { // handle response } } @@ -253,7 +240,7 @@ func main() { ### Response -**[*components.V1KeysVerifyKeyResponse](../../models/components/v1keysverifykeyresponse.md), error** +**[*operations.VerifyKeyResponse](../../models/operations/verifykeyresponse.md), error** | Error Object | Status Code | Content Type | | -------------------------------- | -------------------------------- | -------------------------------- | | sdkerrors.ErrBadRequest | 400 | application/json | @@ -273,7 +260,6 @@ func main() { package main import( - "github.com/unkeyed/unkey-go/models/components" unkeygo "github.com/unkeyed/unkey-go" "github.com/unkeyed/unkey-go/models/operations" "context" @@ -284,7 +270,6 @@ func main() { s := unkeygo.New( unkeygo.WithSecurity(""), ) - request := operations.UpdateKeyRequestBody{ KeyID: "key_123", Name: unkeygo.String("Customer X"), @@ -298,9 +283,8 @@ func main() { }, Expires: unkeygo.Float64(0), Ratelimit: &operations.UpdateKeyRatelimit{ - Type: operations.UpdateKeyTypeFast, Limit: 10, - RefillRate: 1, + RefillRate: unkeygo.Int64(1), RefillInterval: 60, }, Remaining: unkeygo.Float64(1000), @@ -310,13 +294,12 @@ func main() { }, Enabled: unkeygo.Bool(true), } - ctx := context.Background() res, err := s.Keys.UpdateKey(ctx, request) if err != nil { log.Fatal(err) } - if res != nil { + if res.Object != nil { // handle response } } @@ -332,7 +315,7 @@ func main() { ### Response -**[*operations.UpdateKeyResponseBody](../../models/operations/updatekeyresponsebody.md), error** +**[*operations.UpdateKeyResponse](../../models/operations/updatekeyresponse.md), error** | Error Object | Status Code | Content Type | | -------------------------------- | -------------------------------- | -------------------------------- | | sdkerrors.ErrBadRequest | 400 | application/json | @@ -352,7 +335,6 @@ func main() { package main import( - "github.com/unkeyed/unkey-go/models/components" unkeygo "github.com/unkeyed/unkey-go" "github.com/unkeyed/unkey-go/models/operations" "context" @@ -363,19 +345,17 @@ func main() { s := unkeygo.New( unkeygo.WithSecurity(""), ) - request := operations.UpdateRemainingRequestBody{ KeyID: "key_123", Op: operations.OpSet, Value: unkeygo.Int64(1), } - ctx := context.Background() res, err := s.Keys.UpdateRemaining(ctx, request) if err != nil { log.Fatal(err) } - if res != nil { + if res.Object != nil { // handle response } } @@ -391,7 +371,7 @@ func main() { ### Response -**[*operations.UpdateRemainingResponseBody](../../models/operations/updateremainingresponsebody.md), error** +**[*operations.UpdateRemainingResponse](../../models/operations/updateremainingresponse.md), error** | Error Object | Status Code | Content Type | | -------------------------------- | -------------------------------- | -------------------------------- | | sdkerrors.ErrBadRequest | 400 | application/json | @@ -411,7 +391,6 @@ func main() { package main import( - "github.com/unkeyed/unkey-go/models/components" unkeygo "github.com/unkeyed/unkey-go" "github.com/unkeyed/unkey-go/models/operations" "context" @@ -422,7 +401,6 @@ func main() { s := unkeygo.New( unkeygo.WithSecurity(""), ) - request := operations.GetVerificationsRequest{ KeyID: unkeygo.String("key_1234"), OwnerID: unkeygo.String("chronark"), @@ -430,13 +408,12 @@ func main() { End: unkeygo.Int64(1620000000000), Granularity: operations.GranularityDay.ToPointer(), } - ctx := context.Background() res, err := s.Keys.GetVerifications(ctx, request) if err != nil { log.Fatal(err) } - if res != nil { + if res.Object != nil { // handle response } } @@ -452,7 +429,7 @@ func main() { ### Response -**[*operations.GetVerificationsResponseBody](../../models/operations/getverificationsresponsebody.md), error** +**[*operations.GetVerificationsResponse](../../models/operations/getverificationsresponse.md), error** | Error Object | Status Code | Content Type | | -------------------------------- | -------------------------------- | -------------------------------- | | sdkerrors.ErrBadRequest | 400 | application/json | diff --git a/docs/sdks/liveness/README.md b/docs/sdks/liveness/README.md index 1af45b5..0a239a2 100644 --- a/docs/sdks/liveness/README.md +++ b/docs/sdks/liveness/README.md @@ -13,7 +13,6 @@ package main import( - "github.com/unkeyed/unkey-go/models/components" unkeygo "github.com/unkeyed/unkey-go" "context" "log" @@ -24,14 +23,12 @@ func main() { unkeygo.WithSecurity(""), ) - - ctx := context.Background() res, err := s.Liveness.V1Liveness(ctx) if err != nil { log.Fatal(err) } - if res != nil { + if res.Object != nil { // handle response } } @@ -46,7 +43,7 @@ func main() { ### Response -**[*operations.V1LivenessResponseBody](../../models/operations/v1livenessresponsebody.md), error** +**[*operations.V1LivenessResponse](../../models/operations/v1livenessresponse.md), error** | Error Object | Status Code | Content Type | | -------------------------------- | -------------------------------- | -------------------------------- | | sdkerrors.ErrBadRequest | 400 | application/json | diff --git a/docs/sdks/migrations/README.md b/docs/sdks/migrations/README.md index c0846dd..67e3f33 100644 --- a/docs/sdks/migrations/README.md +++ b/docs/sdks/migrations/README.md @@ -13,7 +13,6 @@ package main import( - "github.com/unkeyed/unkey-go/models/components" unkeygo "github.com/unkeyed/unkey-go" "github.com/unkeyed/unkey-go/models/operations" "context" @@ -24,15 +23,10 @@ func main() { s := unkeygo.New( unkeygo.WithSecurity(""), ) - request := []operations.RequestBody{ operations.RequestBody{ APIID: "api_123", Name: unkeygo.String("my key"), - Hash: operations.Hash{ - Value: "", - Variant: operations.VariantSha256Base64, - }, Start: unkeygo.String("unkey_32kq"), OwnerID: unkeygo.String("team_123"), Meta: map[string]any{ @@ -50,7 +44,6 @@ func main() { Amount: 100, }, Ratelimit: &operations.V1MigrationsCreateKeysRatelimit{ - Type: operations.V1MigrationsCreateKeysTypeFast.ToPointer(), Limit: 10, RefillRate: 1, RefillInterval: 60, @@ -58,13 +51,12 @@ func main() { Enabled: unkeygo.Bool(false), }, } - ctx := context.Background() res, err := s.Migrations.V1MigrationsCreateKeys(ctx, request) if err != nil { log.Fatal(err) } - if res != nil { + if res.Object != nil { // handle response } } @@ -80,7 +72,7 @@ func main() { ### Response -**[*operations.V1MigrationsCreateKeysResponseBody](../../models/operations/v1migrationscreatekeysresponsebody.md), error** +**[*operations.V1MigrationsCreateKeysResponse](../../models/operations/v1migrationscreatekeysresponse.md), error** | Error Object | Status Code | Content Type | | -------------------------------- | -------------------------------- | -------------------------------- | | sdkerrors.ErrBadRequest | 400 | application/json | diff --git a/docs/sdks/ratelimits/README.md b/docs/sdks/ratelimits/README.md index 17987db..fddc68f 100644 --- a/docs/sdks/ratelimits/README.md +++ b/docs/sdks/ratelimits/README.md @@ -13,7 +13,6 @@ package main import( - "github.com/unkeyed/unkey-go/models/components" unkeygo "github.com/unkeyed/unkey-go" "github.com/unkeyed/unkey-go/models/operations" "context" @@ -24,7 +23,6 @@ func main() { s := unkeygo.New( unkeygo.WithSecurity(""), ) - request := operations.LimitRequestBody{ Namespace: unkeygo.String("email.outbound"), Identifier: "user_123", @@ -39,13 +37,12 @@ func main() { }, }, } - ctx := context.Background() res, err := s.Ratelimits.Limit(ctx, request) if err != nil { log.Fatal(err) } - if res != nil { + if res.Object != nil { // handle response } } @@ -61,7 +58,7 @@ func main() { ### Response -**[*operations.LimitResponseBody](../../models/operations/limitresponsebody.md), error** +**[*operations.LimitResponse](../../models/operations/limitresponse.md), error** | Error Object | Status Code | Content Type | | -------------------------------- | -------------------------------- | -------------------------------- | | sdkerrors.ErrBadRequest | 400 | application/json | diff --git a/docs/sdks/unkey/README.md b/docs/sdks/unkey/README.md index 0750afb..0ad6e8d 100644 --- a/docs/sdks/unkey/README.md +++ b/docs/sdks/unkey/README.md @@ -16,7 +16,6 @@ package main import( - "github.com/unkeyed/unkey-go/models/components" unkeygo "github.com/unkeyed/unkey-go" "github.com/unkeyed/unkey-go/models/operations" "context" @@ -27,17 +26,15 @@ func main() { s := unkeygo.New( unkeygo.WithSecurity(""), ) - request := operations.CreateAPIRequestBody{ Name: "my-api", } - ctx := context.Background() res, err := s.CreateAPI(ctx, request) if err != nil { log.Fatal(err) } - if res != nil { + if res.Object != nil { // handle response } } @@ -53,7 +50,7 @@ func main() { ### Response -**[*operations.CreateAPIResponseBody](../../models/operations/createapiresponsebody.md), error** +**[*operations.CreateAPIResponse](../../models/operations/createapiresponse.md), error** | Error Object | Status Code | Content Type | | -------------------------------- | -------------------------------- | -------------------------------- | | sdkerrors.ErrBadRequest | 400 | application/json | @@ -73,7 +70,6 @@ func main() { package main import( - "github.com/unkeyed/unkey-go/models/components" unkeygo "github.com/unkeyed/unkey-go" "github.com/unkeyed/unkey-go/models/operations" "context" @@ -84,17 +80,15 @@ func main() { s := unkeygo.New( unkeygo.WithSecurity(""), ) - request := operations.DeleteAPIRequestBody{ APIID: "api_1234", } - ctx := context.Background() res, err := s.DeleteAPI(ctx, request) if err != nil { log.Fatal(err) } - if res != nil { + if res.Object != nil { // handle response } } @@ -110,7 +104,7 @@ func main() { ### Response -**[*operations.DeleteAPIResponseBody](../../models/operations/deleteapiresponsebody.md), error** +**[*operations.DeleteAPIResponse](../../models/operations/deleteapiresponse.md), error** | Error Object | Status Code | Content Type | | -------------------------------- | -------------------------------- | -------------------------------- | | sdkerrors.ErrBadRequest | 400 | application/json | diff --git a/internal/utils/headers.go b/internal/utils/headers.go index 0249876..107d210 100644 --- a/internal/utils/headers.go +++ b/internal/utils/headers.go @@ -18,8 +18,7 @@ func PopulateHeaders(_ context.Context, req *http.Request, headers interface{}, } func populateHeaders(headers interface{}, globals interface{}, reqHeaders http.Header, skipFields []string) []string { - headerParamsStructType := reflect.TypeOf(headers) - headerParamsValType := reflect.ValueOf(headers) + headerParamsStructType, headerParamsValType := dereferencePointers(reflect.TypeOf(headers), reflect.ValueOf(headers)) globalsAlreadyPopulated := []string{} diff --git a/internal/utils/pathparams.go b/internal/utils/pathparams.go index 78f6f11..d9831de 100644 --- a/internal/utils/pathparams.go +++ b/internal/utils/pathparams.go @@ -38,8 +38,7 @@ func GenerateURL(_ context.Context, serverURL, path string, pathParams interface } func populateParsedParameters(pathParams interface{}, globals interface{}, parsedParameters map[string]string, skipFields []string) ([]string, error) { - pathParamsStructType := reflect.TypeOf(pathParams) - pathParamsValType := reflect.ValueOf(pathParams) + pathParamsStructType, pathParamsValType := dereferencePointers(reflect.TypeOf(pathParams), reflect.ValueOf(pathParams)) globalsAlreadyPopulated := []string{} diff --git a/internal/utils/queryparams.go b/internal/utils/queryparams.go index 8d1bf47..e2c5b9d 100644 --- a/internal/utils/queryparams.go +++ b/internal/utils/queryparams.go @@ -32,8 +32,7 @@ func PopulateQueryParams(_ context.Context, req *http.Request, queryParams inter } func populateQueryParams(queryParams interface{}, globals interface{}, values url.Values, skipFields []string) ([]string, error) { - queryParamsStructType := reflect.TypeOf(queryParams) - queryParamsValType := reflect.ValueOf(queryParams) + queryParamsStructType, queryParamsValType := dereferencePointers(reflect.TypeOf(queryParams), reflect.ValueOf(queryParams)) globalsAlreadyPopulated := []string{} diff --git a/internal/utils/security.go b/internal/utils/security.go index 8023225..f7abb69 100644 --- a/internal/utils/security.go +++ b/internal/utils/security.go @@ -196,6 +196,10 @@ func handleBasicAuthScheme(headers map[string]string, scheme interface{}) { fieldType := schemeStructType.Field(i) valType := schemeValType.Field(i) + if fieldType.Type.Kind() == reflect.Ptr { + valType = valType.Elem() + } + secTag := parseSecurityTag(fieldType) if secTag == nil || secTag.Name == "" { continue diff --git a/internal/utils/utils.go b/internal/utils/utils.go index a35dc9b..eab3682 100644 --- a/internal/utils/utils.go +++ b/internal/utils/utils.go @@ -3,6 +3,7 @@ package utils import ( + "context" "fmt" "io" "math/big" @@ -87,6 +88,12 @@ func MatchStatusCodes(expectedCodes []string, statusCode int) bool { return false } +func AsSecuritySource(security interface{}) func(context.Context) (interface{}, error) { + return func(context.Context) (interface{}, error) { + return security, nil + } +} + func parseStructTag(tagKey string, field reflect.StructField) map[string]string { tag := field.Tag.Get(tagKey) if tag == "" { diff --git a/keys.go b/keys.go index d3bee0b..1d9cb75 100644 --- a/keys.go +++ b/keys.go @@ -26,7 +26,7 @@ func newKeys(sdkConfig sdkConfiguration) *Keys { } } -func (s *Keys) GetKey(ctx context.Context, request operations.GetKeyRequest) (*components.Key, error) { +func (s *Keys) GetKey(ctx context.Context, request operations.GetKeyRequest) (*operations.GetKeyResponse, error) { hookCtx := hooks.HookContext{ Context: ctx, OperationID: "getKey", @@ -84,6 +84,13 @@ func (s *Keys) GetKey(ctx context.Context, request operations.GetKeyRequest) (*c } } + res := &operations.GetKeyResponse{ + HTTPMeta: components.HTTPMetadata{ + Request: req, + Response: httpRes, + }, + } + rawBody, err := io.ReadAll(httpRes.Body) if err != nil { return nil, fmt.Errorf("error reading response body: %w", err) @@ -100,7 +107,7 @@ func (s *Keys) GetKey(ctx context.Context, request operations.GetKeyRequest) (*c return nil, err } - return &out, nil + res.Key = &out default: return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } @@ -195,9 +202,12 @@ func (s *Keys) GetKey(ctx context.Context, request operations.GetKeyRequest) (*c default: return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) } + + return res, nil + } -func (s *Keys) DeleteKey(ctx context.Context, request operations.DeleteKeyRequestBody) (*operations.DeleteKeyResponseBody, error) { +func (s *Keys) DeleteKey(ctx context.Context, request operations.DeleteKeyRequestBody) (*operations.DeleteKeyResponse, error) { hookCtx := hooks.HookContext{ Context: ctx, OperationID: "deleteKey", @@ -257,6 +267,13 @@ func (s *Keys) DeleteKey(ctx context.Context, request operations.DeleteKeyReques } } + res := &operations.DeleteKeyResponse{ + HTTPMeta: components.HTTPMetadata{ + Request: req, + Response: httpRes, + }, + } + rawBody, err := io.ReadAll(httpRes.Body) if err != nil { return nil, fmt.Errorf("error reading response body: %w", err) @@ -273,7 +290,7 @@ func (s *Keys) DeleteKey(ctx context.Context, request operations.DeleteKeyReques return nil, err } - return &out, nil + res.Object = &out default: return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } @@ -368,9 +385,12 @@ func (s *Keys) DeleteKey(ctx context.Context, request operations.DeleteKeyReques default: return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) } + + return res, nil + } -func (s *Keys) CreateKey(ctx context.Context, request operations.CreateKeyRequestBody) (*operations.CreateKeyResponseBody, error) { +func (s *Keys) CreateKey(ctx context.Context, request operations.CreateKeyRequestBody) (*operations.CreateKeyResponse, error) { hookCtx := hooks.HookContext{ Context: ctx, OperationID: "createKey", @@ -430,6 +450,13 @@ func (s *Keys) CreateKey(ctx context.Context, request operations.CreateKeyReques } } + res := &operations.CreateKeyResponse{ + HTTPMeta: components.HTTPMetadata{ + Request: req, + Response: httpRes, + }, + } + rawBody, err := io.ReadAll(httpRes.Body) if err != nil { return nil, fmt.Errorf("error reading response body: %w", err) @@ -446,7 +473,7 @@ func (s *Keys) CreateKey(ctx context.Context, request operations.CreateKeyReques return nil, err } - return &out, nil + res.Object = &out default: return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } @@ -541,9 +568,12 @@ func (s *Keys) CreateKey(ctx context.Context, request operations.CreateKeyReques default: return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) } + + return res, nil + } -func (s *Keys) VerifyKey(ctx context.Context, request components.V1KeysVerifyKeyRequest) (*components.V1KeysVerifyKeyResponse, error) { +func (s *Keys) VerifyKey(ctx context.Context, request components.V1KeysVerifyKeyRequest) (*operations.VerifyKeyResponse, error) { hookCtx := hooks.HookContext{ Context: ctx, OperationID: "verifyKey", @@ -603,6 +633,13 @@ func (s *Keys) VerifyKey(ctx context.Context, request components.V1KeysVerifyKey } } + res := &operations.VerifyKeyResponse{ + HTTPMeta: components.HTTPMetadata{ + Request: req, + Response: httpRes, + }, + } + rawBody, err := io.ReadAll(httpRes.Body) if err != nil { return nil, fmt.Errorf("error reading response body: %w", err) @@ -619,7 +656,7 @@ func (s *Keys) VerifyKey(ctx context.Context, request components.V1KeysVerifyKey return nil, err } - return &out, nil + res.V1KeysVerifyKeyResponse = &out default: return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } @@ -714,9 +751,12 @@ func (s *Keys) VerifyKey(ctx context.Context, request components.V1KeysVerifyKey default: return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) } + + return res, nil + } -func (s *Keys) UpdateKey(ctx context.Context, request operations.UpdateKeyRequestBody) (*operations.UpdateKeyResponseBody, error) { +func (s *Keys) UpdateKey(ctx context.Context, request operations.UpdateKeyRequestBody) (*operations.UpdateKeyResponse, error) { hookCtx := hooks.HookContext{ Context: ctx, OperationID: "updateKey", @@ -776,6 +816,13 @@ func (s *Keys) UpdateKey(ctx context.Context, request operations.UpdateKeyReques } } + res := &operations.UpdateKeyResponse{ + HTTPMeta: components.HTTPMetadata{ + Request: req, + Response: httpRes, + }, + } + rawBody, err := io.ReadAll(httpRes.Body) if err != nil { return nil, fmt.Errorf("error reading response body: %w", err) @@ -792,7 +839,7 @@ func (s *Keys) UpdateKey(ctx context.Context, request operations.UpdateKeyReques return nil, err } - return &out, nil + res.Object = &out default: return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } @@ -887,9 +934,12 @@ func (s *Keys) UpdateKey(ctx context.Context, request operations.UpdateKeyReques default: return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) } + + return res, nil + } -func (s *Keys) UpdateRemaining(ctx context.Context, request operations.UpdateRemainingRequestBody) (*operations.UpdateRemainingResponseBody, error) { +func (s *Keys) UpdateRemaining(ctx context.Context, request operations.UpdateRemainingRequestBody) (*operations.UpdateRemainingResponse, error) { hookCtx := hooks.HookContext{ Context: ctx, OperationID: "updateRemaining", @@ -949,6 +999,13 @@ func (s *Keys) UpdateRemaining(ctx context.Context, request operations.UpdateRem } } + res := &operations.UpdateRemainingResponse{ + HTTPMeta: components.HTTPMetadata{ + Request: req, + Response: httpRes, + }, + } + rawBody, err := io.ReadAll(httpRes.Body) if err != nil { return nil, fmt.Errorf("error reading response body: %w", err) @@ -965,7 +1022,7 @@ func (s *Keys) UpdateRemaining(ctx context.Context, request operations.UpdateRem return nil, err } - return &out, nil + res.Object = &out default: return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } @@ -1060,9 +1117,12 @@ func (s *Keys) UpdateRemaining(ctx context.Context, request operations.UpdateRem default: return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) } + + return res, nil + } -func (s *Keys) GetVerifications(ctx context.Context, request operations.GetVerificationsRequest) (*operations.GetVerificationsResponseBody, error) { +func (s *Keys) GetVerifications(ctx context.Context, request operations.GetVerificationsRequest) (*operations.GetVerificationsResponse, error) { hookCtx := hooks.HookContext{ Context: ctx, OperationID: "getVerifications", @@ -1120,6 +1180,13 @@ func (s *Keys) GetVerifications(ctx context.Context, request operations.GetVerif } } + res := &operations.GetVerificationsResponse{ + HTTPMeta: components.HTTPMetadata{ + Request: req, + Response: httpRes, + }, + } + rawBody, err := io.ReadAll(httpRes.Body) if err != nil { return nil, fmt.Errorf("error reading response body: %w", err) @@ -1136,7 +1203,7 @@ func (s *Keys) GetVerifications(ctx context.Context, request operations.GetVerif return nil, err } - return &out, nil + res.Object = &out default: return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } @@ -1231,4 +1298,7 @@ func (s *Keys) GetVerifications(ctx context.Context, request operations.GetVerif default: return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) } + + return res, nil + } diff --git a/liveness.go b/liveness.go index 3849830..8f79703 100644 --- a/liveness.go +++ b/liveness.go @@ -8,6 +8,7 @@ import ( "fmt" "github.com/unkeyed/unkey-go/internal/hooks" "github.com/unkeyed/unkey-go/internal/utils" + "github.com/unkeyed/unkey-go/models/components" "github.com/unkeyed/unkey-go/models/operations" "github.com/unkeyed/unkey-go/models/sdkerrors" "io" @@ -25,7 +26,7 @@ func newLiveness(sdkConfig sdkConfiguration) *Liveness { } } -func (s *Liveness) V1Liveness(ctx context.Context) (*operations.V1LivenessResponseBody, error) { +func (s *Liveness) V1Liveness(ctx context.Context) (*operations.V1LivenessResponse, error) { hookCtx := hooks.HookContext{ Context: ctx, OperationID: "v1.liveness", @@ -79,6 +80,13 @@ func (s *Liveness) V1Liveness(ctx context.Context) (*operations.V1LivenessRespon } } + res := &operations.V1LivenessResponse{ + HTTPMeta: components.HTTPMetadata{ + Request: req, + Response: httpRes, + }, + } + rawBody, err := io.ReadAll(httpRes.Body) if err != nil { return nil, fmt.Errorf("error reading response body: %w", err) @@ -95,7 +103,7 @@ func (s *Liveness) V1Liveness(ctx context.Context) (*operations.V1LivenessRespon return nil, err } - return &out, nil + res.Object = &out default: return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } @@ -190,4 +198,7 @@ func (s *Liveness) V1Liveness(ctx context.Context) (*operations.V1LivenessRespon default: return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) } + + return res, nil + } diff --git a/migrations.go b/migrations.go index 1a0709e..cc4c01b 100644 --- a/migrations.go +++ b/migrations.go @@ -8,6 +8,7 @@ import ( "fmt" "github.com/unkeyed/unkey-go/internal/hooks" "github.com/unkeyed/unkey-go/internal/utils" + "github.com/unkeyed/unkey-go/models/components" "github.com/unkeyed/unkey-go/models/operations" "github.com/unkeyed/unkey-go/models/sdkerrors" "io" @@ -25,7 +26,7 @@ func newMigrations(sdkConfig sdkConfiguration) *Migrations { } } -func (s *Migrations) V1MigrationsCreateKeys(ctx context.Context, request []operations.RequestBody) (*operations.V1MigrationsCreateKeysResponseBody, error) { +func (s *Migrations) V1MigrationsCreateKeys(ctx context.Context, request []operations.RequestBody) (*operations.V1MigrationsCreateKeysResponse, error) { hookCtx := hooks.HookContext{ Context: ctx, OperationID: "v1.migrations.createKeys", @@ -85,6 +86,13 @@ func (s *Migrations) V1MigrationsCreateKeys(ctx context.Context, request []opera } } + res := &operations.V1MigrationsCreateKeysResponse{ + HTTPMeta: components.HTTPMetadata{ + Request: req, + Response: httpRes, + }, + } + rawBody, err := io.ReadAll(httpRes.Body) if err != nil { return nil, fmt.Errorf("error reading response body: %w", err) @@ -101,7 +109,7 @@ func (s *Migrations) V1MigrationsCreateKeys(ctx context.Context, request []opera return nil, err } - return &out, nil + res.Object = &out default: return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } @@ -196,4 +204,7 @@ func (s *Migrations) V1MigrationsCreateKeys(ctx context.Context, request []opera default: return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) } + + return res, nil + } diff --git a/models/components/httpmetadata.go b/models/components/httpmetadata.go new file mode 100644 index 0000000..f6ec394 --- /dev/null +++ b/models/components/httpmetadata.go @@ -0,0 +1,28 @@ +// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + +package components + +import ( + "net/http" +) + +type HTTPMetadata struct { + // Raw HTTP response; suitable for custom response parsing + Response *http.Response `json:"-"` + // Raw HTTP request; suitable for debugging + Request *http.Request `json:"-"` +} + +func (o *HTTPMetadata) GetResponse() *http.Response { + if o == nil { + return nil + } + return o.Response +} + +func (o *HTTPMetadata) GetRequest() *http.Request { + if o == nil { + return nil + } + return o.Request +} diff --git a/models/components/key.go b/models/components/key.go index d0f8b73..dc9644a 100644 --- a/models/components/key.go +++ b/models/components/key.go @@ -5,7 +5,6 @@ package components import ( "encoding/json" "fmt" - "github.com/unkeyed/unkey-go/internal/utils" ) // Interval - Determines the rate at which verifications will be refilled. @@ -19,7 +18,6 @@ const ( func (e Interval) ToPointer() *Interval { return &e } - func (e *Interval) UnmarshalJSON(data []byte) error { var v string if err := json.Unmarshal(data, &v); err != nil { @@ -80,7 +78,6 @@ const ( func (e Type) ToPointer() *Type { return &e } - func (e *Type) UnmarshalJSON(data []byte) error { var v string if err := json.Unmarshal(data, &v); err != nil { @@ -99,25 +96,24 @@ func (e *Type) UnmarshalJSON(data []byte) error { // Ratelimit - Unkey comes with per-key ratelimiting out of the box. type Ratelimit struct { + Async bool `json:"async"` // Fast ratelimiting doesn't add latency, while consistent ratelimiting is more accurate. - Type *Type `default:"fast" json:"type"` + Type *Type `json:"type,omitempty"` // The total amount of burstable requests. Limit int64 `json:"limit"` // How many tokens to refill during each refillInterval. - RefillRate int64 `json:"refillRate"` + RefillRate *int64 `json:"refillRate,omitempty"` // Determines the speed at which tokens are refilled, in milliseconds. - RefillInterval int64 `json:"refillInterval"` -} - -func (r Ratelimit) MarshalJSON() ([]byte, error) { - return utils.MarshalJSON(r, "", false) + RefillInterval *int64 `json:"refillInterval,omitempty"` + // The duration of the ratelimit window, in milliseconds. + Duration int64 `json:"duration"` } -func (r *Ratelimit) UnmarshalJSON(data []byte) error { - if err := utils.UnmarshalJSON(data, &r, "", false, false); err != nil { - return err +func (o *Ratelimit) GetAsync() bool { + if o == nil { + return false } - return nil + return o.Async } func (o *Ratelimit) GetType() *Type { @@ -134,20 +130,27 @@ func (o *Ratelimit) GetLimit() int64 { return o.Limit } -func (o *Ratelimit) GetRefillRate() int64 { +func (o *Ratelimit) GetRefillRate() *int64 { if o == nil { - return 0 + return nil } return o.RefillRate } -func (o *Ratelimit) GetRefillInterval() int64 { +func (o *Ratelimit) GetRefillInterval() *int64 { if o == nil { - return 0 + return nil } return o.RefillInterval } +func (o *Ratelimit) GetDuration() int64 { + if o == nil { + return 0 + } + return o.Duration +} + type Key struct { // The id of the key ID string `json:"id"` @@ -164,7 +167,9 @@ type Key struct { // Any additional metadata you want to store with the key Meta map[string]any `json:"meta,omitempty"` // The unix timestamp in milliseconds when the key was created - CreatedAt *float64 `json:"createdAt,omitempty"` + CreatedAt float64 `json:"createdAt"` + // The unix timestamp in milliseconds when the key was last updated + UpdatedAt *float64 `json:"updatedAt,omitempty"` // The unix timestamp in milliseconds when the key was deleted. We don't delete the key outright, you can restore it later. DeletedAt *float64 `json:"deletedAt,omitempty"` // The unix timestamp in milliseconds when the key will expire. If this field is null or undefined, the key is not expiring. @@ -181,6 +186,8 @@ type Key struct { Permissions []string `json:"permissions,omitempty"` // Sets if key is enabled or disabled. Disabled keys are not valid. Enabled *bool `json:"enabled,omitempty"` + // The key in plaintext + Plaintext *string `json:"plaintext,omitempty"` } func (o *Key) GetID() string { @@ -232,13 +239,20 @@ func (o *Key) GetMeta() map[string]any { return o.Meta } -func (o *Key) GetCreatedAt() *float64 { +func (o *Key) GetCreatedAt() float64 { if o == nil { - return nil + return 0.0 } return o.CreatedAt } +func (o *Key) GetUpdatedAt() *float64 { + if o == nil { + return nil + } + return o.UpdatedAt +} + func (o *Key) GetDeletedAt() *float64 { if o == nil { return nil @@ -294,3 +308,10 @@ func (o *Key) GetEnabled() *bool { } return o.Enabled } + +func (o *Key) GetPlaintext() *string { + if o == nil { + return nil + } + return o.Plaintext +} diff --git a/models/components/v1keysverifykeyresponse.go b/models/components/v1keysverifykeyresponse.go index 4636e72..69b3236 100644 --- a/models/components/v1keysverifykeyresponse.go +++ b/models/components/v1keysverifykeyresponse.go @@ -64,7 +64,6 @@ const ( func (e Code) ToPointer() *Code { return &e } - func (e *Code) UnmarshalJSON(data []byte) error { var v string if err := json.Unmarshal(data, &v); err != nil { diff --git a/models/operations/createapi.go b/models/operations/createapi.go index 90a3d68..fb7cb90 100644 --- a/models/operations/createapi.go +++ b/models/operations/createapi.go @@ -2,6 +2,10 @@ package operations +import ( + "github.com/unkeyed/unkey-go/models/components" +) + type CreateAPIRequestBody struct { // The name for your API. This is not customer facing. Name string `json:"name"` @@ -26,3 +30,23 @@ func (o *CreateAPIResponseBody) GetAPIID() string { } return o.APIID } + +type CreateAPIResponse struct { + HTTPMeta components.HTTPMetadata `json:"-"` + // The configuration for an api + Object *CreateAPIResponseBody +} + +func (o *CreateAPIResponse) GetHTTPMeta() components.HTTPMetadata { + if o == nil { + return components.HTTPMetadata{} + } + return o.HTTPMeta +} + +func (o *CreateAPIResponse) GetObject() *CreateAPIResponseBody { + if o == nil { + return nil + } + return o.Object +} diff --git a/models/operations/createkey.go b/models/operations/createkey.go index 90ba122..ed0b7d6 100644 --- a/models/operations/createkey.go +++ b/models/operations/createkey.go @@ -6,6 +6,7 @@ import ( "encoding/json" "fmt" "github.com/unkeyed/unkey-go/internal/utils" + "github.com/unkeyed/unkey-go/models/components" ) // Interval - Unkey will automatically refill verifications at the set interval. @@ -19,7 +20,6 @@ const ( func (e Interval) ToPointer() *Interval { return &e } - func (e *Interval) UnmarshalJSON(data []byte) error { var v string if err := json.Unmarshal(data, &v); err != nil { @@ -58,9 +58,11 @@ func (o *Refill) GetAmount() int64 { return o.Amount } -// Type - Fast ratelimiting doesn't add latency, while consistent ratelimiting is more accurate. +// Type - Deprecated, used `async`. Fast ratelimiting doesn't add latency, while consistent ratelimiting is more accurate. // // https://unkey.dev/docs/features/ratelimiting - Learn more +// +// Deprecated type: This will be removed in a future release, please migrate away from it as soon as possible. type Type string const ( @@ -71,7 +73,6 @@ const ( func (e Type) ToPointer() *Type { return &e } - func (e *Type) UnmarshalJSON(data []byte) error { var v string if err := json.Unmarshal(data, &v); err != nil { @@ -88,16 +89,26 @@ func (e *Type) UnmarshalJSON(data []byte) error { } } -// Ratelimit - Unkey comes with per-key ratelimiting out of the box. +// Ratelimit - Unkey comes with per-key fixed-window ratelimiting out of the box. type Ratelimit struct { - // Fast ratelimiting doesn't add latency, while consistent ratelimiting is more accurate. + // Async will return a response immediately, lowering latency at the cost of accuracy. + Async *bool `default:"false" json:"async"` + // Deprecated, used `async`. Fast ratelimiting doesn't add latency, while consistent ratelimiting is more accurate. + // + // Deprecated field: This will be removed in a future release, please migrate away from it as soon as possible. Type *Type `default:"fast" json:"type"` - // The total amount of burstable requests. + // The total amount of requests in a given interval. Limit int64 `json:"limit"` + // The window duration in milliseconds + Duration int64 `json:"duration"` // How many tokens to refill during each refillInterval. - RefillRate int64 `json:"refillRate"` - // Determines the speed at which tokens are refilled, in milliseconds. - RefillInterval int64 `json:"refillInterval"` + // + // Deprecated field: This will be removed in a future release, please migrate away from it as soon as possible. + RefillRate *int64 `json:"refillRate,omitempty"` + // The refill timeframe, in milliseconds. + // + // Deprecated field: This will be removed in a future release, please migrate away from it as soon as possible. + RefillInterval *int64 `json:"refillInterval,omitempty"` } func (r Ratelimit) MarshalJSON() ([]byte, error) { @@ -111,6 +122,13 @@ func (r *Ratelimit) UnmarshalJSON(data []byte) error { return nil } +func (o *Ratelimit) GetAsync() *bool { + if o == nil { + return nil + } + return o.Async +} + func (o *Ratelimit) GetType() *Type { if o == nil { return nil @@ -125,16 +143,23 @@ func (o *Ratelimit) GetLimit() int64 { return o.Limit } -func (o *Ratelimit) GetRefillRate() int64 { +func (o *Ratelimit) GetDuration() int64 { if o == nil { return 0 } + return o.Duration +} + +func (o *Ratelimit) GetRefillRate() *int64 { + if o == nil { + return nil + } return o.RefillRate } -func (o *Ratelimit) GetRefillInterval() int64 { +func (o *Ratelimit) GetRefillInterval() *int64 { if o == nil { - return 0 + return nil } return o.RefillInterval } @@ -166,7 +191,7 @@ type CreateKeyRequestBody struct { Remaining *int64 `json:"remaining,omitempty"` // Unkey enables you to refill verifications for each key at regular intervals. Refill *Refill `json:"refill,omitempty"` - // Unkey comes with per-key ratelimiting out of the box. + // Unkey comes with per-key fixed-window ratelimiting out of the box. Ratelimit *Ratelimit `json:"ratelimit,omitempty"` // Sets if key is enabled or disabled. Disabled keys are not valid. Enabled *bool `default:"true" json:"enabled"` @@ -305,3 +330,23 @@ func (o *CreateKeyResponseBody) GetKey() string { } return o.Key } + +type CreateKeyResponse struct { + HTTPMeta components.HTTPMetadata `json:"-"` + // The configuration for an api + Object *CreateKeyResponseBody +} + +func (o *CreateKeyResponse) GetHTTPMeta() components.HTTPMetadata { + if o == nil { + return components.HTTPMetadata{} + } + return o.HTTPMeta +} + +func (o *CreateKeyResponse) GetObject() *CreateKeyResponseBody { + if o == nil { + return nil + } + return o.Object +} diff --git a/models/operations/deleteapi.go b/models/operations/deleteapi.go index 70fce4f..b2f2d75 100644 --- a/models/operations/deleteapi.go +++ b/models/operations/deleteapi.go @@ -2,6 +2,10 @@ package operations +import ( + "github.com/unkeyed/unkey-go/models/components" +) + type DeleteAPIRequestBody struct { // The id of the api to delete APIID string `json:"apiId"` @@ -17,3 +21,23 @@ func (o *DeleteAPIRequestBody) GetAPIID() string { // DeleteAPIResponseBody - The api was successfully deleted, it may take up to 30s for this to take effect in all regions type DeleteAPIResponseBody struct { } + +type DeleteAPIResponse struct { + HTTPMeta components.HTTPMetadata `json:"-"` + // The api was successfully deleted, it may take up to 30s for this to take effect in all regions + Object *DeleteAPIResponseBody +} + +func (o *DeleteAPIResponse) GetHTTPMeta() components.HTTPMetadata { + if o == nil { + return components.HTTPMetadata{} + } + return o.HTTPMeta +} + +func (o *DeleteAPIResponse) GetObject() *DeleteAPIResponseBody { + if o == nil { + return nil + } + return o.Object +} diff --git a/models/operations/deletekey.go b/models/operations/deletekey.go index 3185276..f500fa0 100644 --- a/models/operations/deletekey.go +++ b/models/operations/deletekey.go @@ -2,6 +2,10 @@ package operations +import ( + "github.com/unkeyed/unkey-go/models/components" +) + type DeleteKeyRequestBody struct { // The id of the key to revoke KeyID string `json:"keyId"` @@ -17,3 +21,23 @@ func (o *DeleteKeyRequestBody) GetKeyID() string { // DeleteKeyResponseBody - The key was successfully revoked, it may take up to 30s for this to take effect in all regions type DeleteKeyResponseBody struct { } + +type DeleteKeyResponse struct { + HTTPMeta components.HTTPMetadata `json:"-"` + // The key was successfully revoked, it may take up to 30s for this to take effect in all regions + Object *DeleteKeyResponseBody +} + +func (o *DeleteKeyResponse) GetHTTPMeta() components.HTTPMetadata { + if o == nil { + return components.HTTPMetadata{} + } + return o.HTTPMeta +} + +func (o *DeleteKeyResponse) GetObject() *DeleteKeyResponseBody { + if o == nil { + return nil + } + return o.Object +} diff --git a/models/operations/deletekeys.go b/models/operations/deletekeys.go new file mode 100644 index 0000000..1dc3542 --- /dev/null +++ b/models/operations/deletekeys.go @@ -0,0 +1,73 @@ +// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + +package operations + +import ( + "github.com/unkeyed/unkey-go/internal/utils" + "github.com/unkeyed/unkey-go/models/components" +) + +type DeleteKeysRequestBody struct { + // The id of the api, that the keys belong to. + APIID string `json:"apiId"` + // If true, the keys will be permanently deleted. If false, the keys will be soft-deleted and can be restored later. + Permanent *bool `default:"false" json:"permanent"` +} + +func (d DeleteKeysRequestBody) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(d, "", false) +} + +func (d *DeleteKeysRequestBody) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &d, "", false, false); err != nil { + return err + } + return nil +} + +func (o *DeleteKeysRequestBody) GetAPIID() string { + if o == nil { + return "" + } + return o.APIID +} + +func (o *DeleteKeysRequestBody) GetPermanent() *bool { + if o == nil { + return nil + } + return o.Permanent +} + +// DeleteKeysResponseBody - The keys have been deleted +type DeleteKeysResponseBody struct { + // The number of keys that were deleted + DeletedKeys float64 `json:"deletedKeys"` +} + +func (o *DeleteKeysResponseBody) GetDeletedKeys() float64 { + if o == nil { + return 0.0 + } + return o.DeletedKeys +} + +type DeleteKeysResponse struct { + HTTPMeta components.HTTPMetadata `json:"-"` + // The keys have been deleted + Object *DeleteKeysResponseBody +} + +func (o *DeleteKeysResponse) GetHTTPMeta() components.HTTPMetadata { + if o == nil { + return components.HTTPMetadata{} + } + return o.HTTPMeta +} + +func (o *DeleteKeysResponse) GetObject() *DeleteKeysResponseBody { + if o == nil { + return nil + } + return o.Object +} diff --git a/models/operations/getapi.go b/models/operations/getapi.go index a7f9819..7978738 100644 --- a/models/operations/getapi.go +++ b/models/operations/getapi.go @@ -2,6 +2,10 @@ package operations +import ( + "github.com/unkeyed/unkey-go/models/components" +) + type GetAPIRequest struct { APIID string `queryParam:"style=form,explode=true,name=apiId"` } @@ -43,3 +47,23 @@ func (o *GetAPIResponseBody) GetName() *string { } return o.Name } + +type GetAPIResponse struct { + HTTPMeta components.HTTPMetadata `json:"-"` + // The configuration for an api + Object *GetAPIResponseBody +} + +func (o *GetAPIResponse) GetHTTPMeta() components.HTTPMetadata { + if o == nil { + return components.HTTPMetadata{} + } + return o.HTTPMeta +} + +func (o *GetAPIResponse) GetObject() *GetAPIResponseBody { + if o == nil { + return nil + } + return o.Object +} diff --git a/models/operations/getkey.go b/models/operations/getkey.go index 4f2a031..a21bca6 100644 --- a/models/operations/getkey.go +++ b/models/operations/getkey.go @@ -2,8 +2,13 @@ package operations +import ( + "github.com/unkeyed/unkey-go/models/components" +) + type GetKeyRequest struct { - KeyID string `queryParam:"style=form,explode=true,name=keyId"` + KeyID string `queryParam:"style=form,explode=true,name=keyId"` + Decrypt *bool `queryParam:"style=form,explode=true,name=decrypt"` } func (o *GetKeyRequest) GetKeyID() string { @@ -12,3 +17,30 @@ func (o *GetKeyRequest) GetKeyID() string { } return o.KeyID } + +func (o *GetKeyRequest) GetDecrypt() *bool { + if o == nil { + return nil + } + return o.Decrypt +} + +type GetKeyResponse struct { + HTTPMeta components.HTTPMetadata `json:"-"` + // The configuration for a single key + Key *components.Key +} + +func (o *GetKeyResponse) GetHTTPMeta() components.HTTPMetadata { + if o == nil { + return components.HTTPMetadata{} + } + return o.HTTPMeta +} + +func (o *GetKeyResponse) GetKey() *components.Key { + if o == nil { + return nil + } + return o.Key +} diff --git a/models/operations/getverifications.go b/models/operations/getverifications.go index ba5a918..f71d40b 100644 --- a/models/operations/getverifications.go +++ b/models/operations/getverifications.go @@ -6,6 +6,7 @@ import ( "encoding/json" "fmt" "github.com/unkeyed/unkey-go/internal/utils" + "github.com/unkeyed/unkey-go/models/components" ) // Granularity - The granularity of the usage data to fetch, currently only `day` is supported @@ -18,7 +19,6 @@ const ( func (e Granularity) ToPointer() *Granularity { return &e } - func (e *Granularity) UnmarshalJSON(data []byte) error { var v string if err := json.Unmarshal(data, &v); err != nil { @@ -138,3 +138,23 @@ func (o *GetVerificationsResponseBody) GetVerifications() []Verifications { } return o.Verifications } + +type GetVerificationsResponse struct { + HTTPMeta components.HTTPMetadata `json:"-"` + // Usage numbers over time + Object *GetVerificationsResponseBody +} + +func (o *GetVerificationsResponse) GetHTTPMeta() components.HTTPMetadata { + if o == nil { + return components.HTTPMetadata{} + } + return o.HTTPMeta +} + +func (o *GetVerificationsResponse) GetObject() *GetVerificationsResponseBody { + if o == nil { + return nil + } + return o.Object +} diff --git a/models/operations/limit.go b/models/operations/limit.go index 69a78e8..c75c543 100644 --- a/models/operations/limit.go +++ b/models/operations/limit.go @@ -4,6 +4,7 @@ package operations import ( "github.com/unkeyed/unkey-go/internal/utils" + "github.com/unkeyed/unkey-go/models/components" ) type Resources struct { @@ -169,3 +170,22 @@ func (o *LimitResponseBody) GetReset() float64 { } return o.Reset } + +type LimitResponse struct { + HTTPMeta components.HTTPMetadata `json:"-"` + Object *LimitResponseBody +} + +func (o *LimitResponse) GetHTTPMeta() components.HTTPMetadata { + if o == nil { + return components.HTTPMetadata{} + } + return o.HTTPMeta +} + +func (o *LimitResponse) GetObject() *LimitResponseBody { + if o == nil { + return nil + } + return o.Object +} diff --git a/models/operations/listkeys.go b/models/operations/listkeys.go index 24a0d6b..fba3379 100644 --- a/models/operations/listkeys.go +++ b/models/operations/listkeys.go @@ -12,6 +12,7 @@ type ListKeysRequest struct { Limit *int64 `default:"100" queryParam:"style=form,explode=true,name=limit"` Cursor *string `queryParam:"style=form,explode=true,name=cursor"` OwnerID *string `queryParam:"style=form,explode=true,name=ownerId"` + Decrypt *bool `queryParam:"style=form,explode=true,name=decrypt"` } func (l ListKeysRequest) MarshalJSON() ([]byte, error) { @@ -53,6 +54,13 @@ func (o *ListKeysRequest) GetOwnerID() *string { return o.OwnerID } +func (o *ListKeysRequest) GetDecrypt() *bool { + if o == nil { + return nil + } + return o.Decrypt +} + // ListKeysResponseBody - The configuration for an api type ListKeysResponseBody struct { Keys []components.Key `json:"keys"` @@ -82,3 +90,23 @@ func (o *ListKeysResponseBody) GetTotal() int64 { } return o.Total } + +type ListKeysResponse struct { + HTTPMeta components.HTTPMetadata `json:"-"` + // The configuration for an api + Object *ListKeysResponseBody +} + +func (o *ListKeysResponse) GetHTTPMeta() components.HTTPMetadata { + if o == nil { + return components.HTTPMetadata{} + } + return o.HTTPMeta +} + +func (o *ListKeysResponse) GetObject() *ListKeysResponseBody { + if o == nil { + return nil + } + return o.Object +} diff --git a/models/operations/updatekey.go b/models/operations/updatekey.go index ea51280..3998528 100644 --- a/models/operations/updatekey.go +++ b/models/operations/updatekey.go @@ -5,11 +5,15 @@ package operations import ( "encoding/json" "fmt" + "github.com/unkeyed/unkey-go/internal/utils" + "github.com/unkeyed/unkey-go/models/components" ) // UpdateKeyType - Fast ratelimiting doesn't add latency, while consistent ratelimiting is more accurate. // // https://unkey.dev/docs/features/ratelimiting - Learn more +// +// Deprecated type: This will be removed in a future release, please migrate away from it as soon as possible. type UpdateKeyType string const ( @@ -20,7 +24,6 @@ const ( func (e UpdateKeyType) ToPointer() *UpdateKeyType { return &e } - func (e *UpdateKeyType) UnmarshalJSON(data []byte) error { var v string if err := json.Unmarshal(data, &v); err != nil { @@ -40,22 +43,48 @@ func (e *UpdateKeyType) UnmarshalJSON(data []byte) error { // UpdateKeyRatelimit - Unkey comes with per-key ratelimiting out of the box. Set `null` to disable. type UpdateKeyRatelimit struct { // Fast ratelimiting doesn't add latency, while consistent ratelimiting is more accurate. - Type UpdateKeyType `json:"type"` + // + // Deprecated field: This will be removed in a future release, please migrate away from it as soon as possible. + Type *UpdateKeyType `json:"type,omitempty"` + // Asnyc ratelimiting doesn't add latency, while sync ratelimiting is more accurate. + Async *bool `default:"false" json:"async"` // The total amount of burstable requests. Limit int64 `json:"limit"` // How many tokens to refill during each refillInterval. - RefillRate int64 `json:"refillRate"` + // + // Deprecated field: This will be removed in a future release, please migrate away from it as soon as possible. + RefillRate *int64 `json:"refillRate,omitempty"` // Determines the speed at which tokens are refilled, in milliseconds. RefillInterval int64 `json:"refillInterval"` + // The duration of each ratelimit window, in milliseconds. + Duration *int64 `json:"duration,omitempty"` } -func (o *UpdateKeyRatelimit) GetType() UpdateKeyType { +func (u UpdateKeyRatelimit) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(u, "", false) +} + +func (u *UpdateKeyRatelimit) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &u, "", false, false); err != nil { + return err + } + return nil +} + +func (o *UpdateKeyRatelimit) GetType() *UpdateKeyType { if o == nil { - return UpdateKeyType("") + return nil } return o.Type } +func (o *UpdateKeyRatelimit) GetAsync() *bool { + if o == nil { + return nil + } + return o.Async +} + func (o *UpdateKeyRatelimit) GetLimit() int64 { if o == nil { return 0 @@ -63,9 +92,9 @@ func (o *UpdateKeyRatelimit) GetLimit() int64 { return o.Limit } -func (o *UpdateKeyRatelimit) GetRefillRate() int64 { +func (o *UpdateKeyRatelimit) GetRefillRate() *int64 { if o == nil { - return 0 + return nil } return o.RefillRate } @@ -77,6 +106,13 @@ func (o *UpdateKeyRatelimit) GetRefillInterval() int64 { return o.RefillInterval } +func (o *UpdateKeyRatelimit) GetDuration() *int64 { + if o == nil { + return nil + } + return o.Duration +} + // UpdateKeyInterval - Unkey will automatically refill verifications at the set interval. If null is used the refill functionality will be removed from the key. type UpdateKeyInterval string @@ -88,7 +124,6 @@ const ( func (e UpdateKeyInterval) ToPointer() *UpdateKeyInterval { return &e } - func (e *UpdateKeyInterval) UnmarshalJSON(data []byte) error { var v string if err := json.Unmarshal(data, &v); err != nil { @@ -214,3 +249,23 @@ func (o *UpdateKeyRequestBody) GetEnabled() *bool { // UpdateKeyResponseBody - The key was successfully updated, it may take up to 30s for this to take effect in all regions type UpdateKeyResponseBody struct { } + +type UpdateKeyResponse struct { + HTTPMeta components.HTTPMetadata `json:"-"` + // The key was successfully updated, it may take up to 30s for this to take effect in all regions + Object *UpdateKeyResponseBody +} + +func (o *UpdateKeyResponse) GetHTTPMeta() components.HTTPMetadata { + if o == nil { + return components.HTTPMetadata{} + } + return o.HTTPMeta +} + +func (o *UpdateKeyResponse) GetObject() *UpdateKeyResponseBody { + if o == nil { + return nil + } + return o.Object +} diff --git a/models/operations/updateremaining.go b/models/operations/updateremaining.go index 773aa6d..f43c92e 100644 --- a/models/operations/updateremaining.go +++ b/models/operations/updateremaining.go @@ -5,6 +5,7 @@ package operations import ( "encoding/json" "fmt" + "github.com/unkeyed/unkey-go/models/components" ) // Op - The operation you want to perform on the remaining count @@ -19,7 +20,6 @@ const ( func (e Op) ToPointer() *Op { return &e } - func (e *Op) UnmarshalJSON(data []byte) error { var v string if err := json.Unmarshal(data, &v); err != nil { @@ -80,3 +80,23 @@ func (o *UpdateRemainingResponseBody) GetRemaining() *int64 { } return o.Remaining } + +type UpdateRemainingResponse struct { + HTTPMeta components.HTTPMetadata `json:"-"` + // The configuration for an api + Object *UpdateRemainingResponseBody +} + +func (o *UpdateRemainingResponse) GetHTTPMeta() components.HTTPMetadata { + if o == nil { + return components.HTTPMetadata{} + } + return o.HTTPMeta +} + +func (o *UpdateRemainingResponse) GetObject() *UpdateRemainingResponseBody { + if o == nil { + return nil + } + return o.Object +} diff --git a/models/operations/v1liveness.go b/models/operations/v1liveness.go index 40f0e4c..8e1e0d1 100644 --- a/models/operations/v1liveness.go +++ b/models/operations/v1liveness.go @@ -2,6 +2,10 @@ package operations +import ( + "github.com/unkeyed/unkey-go/models/components" +) + type Services struct { // The name of the connected metrics service Metrics string `json:"metrics"` @@ -70,3 +74,23 @@ func (o *V1LivenessResponseBody) GetServices() Services { } return o.Services } + +type V1LivenessResponse struct { + HTTPMeta components.HTTPMetadata `json:"-"` + // The configured services and their status + Object *V1LivenessResponseBody +} + +func (o *V1LivenessResponse) GetHTTPMeta() components.HTTPMetadata { + if o == nil { + return components.HTTPMetadata{} + } + return o.HTTPMeta +} + +func (o *V1LivenessResponse) GetObject() *V1LivenessResponseBody { + if o == nil { + return nil + } + return o.Object +} diff --git a/models/operations/v1migrationscreatekeys.go b/models/operations/v1migrationscreatekeys.go index 4eafdec..039a767 100644 --- a/models/operations/v1migrationscreatekeys.go +++ b/models/operations/v1migrationscreatekeys.go @@ -6,6 +6,7 @@ import ( "encoding/json" "fmt" "github.com/unkeyed/unkey-go/internal/utils" + "github.com/unkeyed/unkey-go/models/components" ) // Variant - The algorithm for hashing and encoding, currently only sha256 and base64 are supported @@ -18,7 +19,6 @@ const ( func (e Variant) ToPointer() *Variant { return &e } - func (e *Variant) UnmarshalJSON(data []byte) error { var v string if err := json.Unmarshal(data, &v); err != nil { @@ -33,6 +33,7 @@ func (e *Variant) UnmarshalJSON(data []byte) error { } } +// Hash - Provide either `hash` or `plaintext` type Hash struct { // The hashed and encoded key Value string `json:"value"` @@ -65,7 +66,6 @@ const ( func (e V1MigrationsCreateKeysInterval) ToPointer() *V1MigrationsCreateKeysInterval { return &e } - func (e *V1MigrationsCreateKeysInterval) UnmarshalJSON(data []byte) error { var v string if err := json.Unmarshal(data, &v); err != nil { @@ -107,6 +107,8 @@ func (o *V1MigrationsCreateKeysRefill) GetAmount() int64 { // V1MigrationsCreateKeysType - Fast ratelimiting doesn't add latency, while consistent ratelimiting is more accurate. // // https://unkey.dev/docs/features/ratelimiting - Learn more +// +// Deprecated type: This will be removed in a future release, please migrate away from it as soon as possible. type V1MigrationsCreateKeysType string const ( @@ -117,7 +119,6 @@ const ( func (e V1MigrationsCreateKeysType) ToPointer() *V1MigrationsCreateKeysType { return &e } - func (e *V1MigrationsCreateKeysType) UnmarshalJSON(data []byte) error { var v string if err := json.Unmarshal(data, &v); err != nil { @@ -136,13 +137,21 @@ func (e *V1MigrationsCreateKeysType) UnmarshalJSON(data []byte) error { // V1MigrationsCreateKeysRatelimit - Unkey comes with per-key ratelimiting out of the box. type V1MigrationsCreateKeysRatelimit struct { + // Async will return a response immediately, lowering latency at the cost of accuracy. + Async *bool `default:"false" json:"async"` // Fast ratelimiting doesn't add latency, while consistent ratelimiting is more accurate. + // + // Deprecated field: This will be removed in a future release, please migrate away from it as soon as possible. Type *V1MigrationsCreateKeysType `default:"fast" json:"type"` // The total amount of burstable requests. Limit int64 `json:"limit"` // How many tokens to refill during each refillInterval. + // + // Deprecated field: This will be removed in a future release, please migrate away from it as soon as possible. RefillRate int64 `json:"refillRate"` // Determines the speed at which tokens are refilled, in milliseconds. + // + // Deprecated field: This will be removed in a future release, please migrate away from it as soon as possible. RefillInterval int64 `json:"refillInterval"` } @@ -157,6 +166,13 @@ func (v *V1MigrationsCreateKeysRatelimit) UnmarshalJSON(data []byte) error { return nil } +func (o *V1MigrationsCreateKeysRatelimit) GetAsync() *bool { + if o == nil { + return nil + } + return o.Async +} + func (o *V1MigrationsCreateKeysRatelimit) GetType() *V1MigrationsCreateKeysType { if o == nil { return nil @@ -197,9 +213,12 @@ type RequestBody struct { Prefix *string `json:"prefix,omitempty"` // The name for your Key. This is not customer facing. Name *string `json:"name,omitempty"` - Hash Hash `json:"hash"` + // The raw key in plaintext. If provided, unkey encrypts this value and stores it securely. Provide either `hash` or `plaintext` + Plaintext *string `json:"plaintext,omitempty"` + // Provide either `hash` or `plaintext` + Hash *Hash `json:"hash,omitempty"` // The first 4 characters of the key. If a prefix is used, it should be the prefix plus 4 characters. - Start *string `default:"" json:"start"` + Start *string `json:"start,omitempty"` // Your user’s Id. This will provide a link between Unkey and your customer record. // When validating a key, we will return this back to you, so you can clearly identify your user from their api key. OwnerID *string `json:"ownerId,omitempty"` @@ -261,9 +280,16 @@ func (o *RequestBody) GetName() *string { return o.Name } -func (o *RequestBody) GetHash() Hash { +func (o *RequestBody) GetPlaintext() *string { if o == nil { - return Hash{} + return nil + } + return o.Plaintext +} + +func (o *RequestBody) GetHash() *Hash { + if o == nil { + return nil } return o.Hash } @@ -350,3 +376,23 @@ func (o *V1MigrationsCreateKeysResponseBody) GetKeyIds() []string { } return o.KeyIds } + +type V1MigrationsCreateKeysResponse struct { + HTTPMeta components.HTTPMetadata `json:"-"` + // The key ids of all created keys + Object *V1MigrationsCreateKeysResponseBody +} + +func (o *V1MigrationsCreateKeysResponse) GetHTTPMeta() components.HTTPMetadata { + if o == nil { + return components.HTTPMetadata{} + } + return o.HTTPMeta +} + +func (o *V1MigrationsCreateKeysResponse) GetObject() *V1MigrationsCreateKeysResponseBody { + if o == nil { + return nil + } + return o.Object +} diff --git a/models/operations/verifykey.go b/models/operations/verifykey.go new file mode 100644 index 0000000..b4a41b9 --- /dev/null +++ b/models/operations/verifykey.go @@ -0,0 +1,27 @@ +// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + +package operations + +import ( + "github.com/unkeyed/unkey-go/models/components" +) + +type VerifyKeyResponse struct { + HTTPMeta components.HTTPMetadata `json:"-"` + // The verification result + V1KeysVerifyKeyResponse *components.V1KeysVerifyKeyResponse +} + +func (o *VerifyKeyResponse) GetHTTPMeta() components.HTTPMetadata { + if o == nil { + return components.HTTPMetadata{} + } + return o.HTTPMeta +} + +func (o *VerifyKeyResponse) GetV1KeysVerifyKeyResponse() *components.V1KeysVerifyKeyResponse { + if o == nil { + return nil + } + return o.V1KeysVerifyKeyResponse +} diff --git a/models/sdkerrors/errbadrequest.go b/models/sdkerrors/errbadrequest.go index 15911fd..18e07ab 100644 --- a/models/sdkerrors/errbadrequest.go +++ b/models/sdkerrors/errbadrequest.go @@ -17,7 +17,6 @@ const ( func (e Code) ToPointer() *Code { return &e } - func (e *Code) UnmarshalJSON(data []byte) error { var v string if err := json.Unmarshal(data, &v); err != nil { diff --git a/models/sdkerrors/errconflict.go b/models/sdkerrors/errconflict.go index d9c38a0..a098cc0 100644 --- a/models/sdkerrors/errconflict.go +++ b/models/sdkerrors/errconflict.go @@ -17,7 +17,6 @@ const ( func (e ErrConflictCode) ToPointer() *ErrConflictCode { return &e } - func (e *ErrConflictCode) UnmarshalJSON(data []byte) error { var v string if err := json.Unmarshal(data, &v); err != nil { diff --git a/models/sdkerrors/errforbidden.go b/models/sdkerrors/errforbidden.go index 7e6d662..1e49ba4 100644 --- a/models/sdkerrors/errforbidden.go +++ b/models/sdkerrors/errforbidden.go @@ -17,7 +17,6 @@ const ( func (e ErrForbiddenCode) ToPointer() *ErrForbiddenCode { return &e } - func (e *ErrForbiddenCode) UnmarshalJSON(data []byte) error { var v string if err := json.Unmarshal(data, &v); err != nil { diff --git a/models/sdkerrors/errinternalservererror.go b/models/sdkerrors/errinternalservererror.go index 98c1062..99a72e0 100644 --- a/models/sdkerrors/errinternalservererror.go +++ b/models/sdkerrors/errinternalservererror.go @@ -17,7 +17,6 @@ const ( func (e ErrInternalServerErrorCode) ToPointer() *ErrInternalServerErrorCode { return &e } - func (e *ErrInternalServerErrorCode) UnmarshalJSON(data []byte) error { var v string if err := json.Unmarshal(data, &v); err != nil { diff --git a/models/sdkerrors/errnotfound.go b/models/sdkerrors/errnotfound.go index c654128..ab5c4e0 100644 --- a/models/sdkerrors/errnotfound.go +++ b/models/sdkerrors/errnotfound.go @@ -17,7 +17,6 @@ const ( func (e ErrNotFoundCode) ToPointer() *ErrNotFoundCode { return &e } - func (e *ErrNotFoundCode) UnmarshalJSON(data []byte) error { var v string if err := json.Unmarshal(data, &v); err != nil { diff --git a/models/sdkerrors/errtoomanyrequests.go b/models/sdkerrors/errtoomanyrequests.go index 12aede8..6d93a89 100644 --- a/models/sdkerrors/errtoomanyrequests.go +++ b/models/sdkerrors/errtoomanyrequests.go @@ -17,7 +17,6 @@ const ( func (e ErrTooManyRequestsCode) ToPointer() *ErrTooManyRequestsCode { return &e } - func (e *ErrTooManyRequestsCode) UnmarshalJSON(data []byte) error { var v string if err := json.Unmarshal(data, &v); err != nil { diff --git a/models/sdkerrors/errunauthorized.go b/models/sdkerrors/errunauthorized.go index cb76100..3dee86a 100644 --- a/models/sdkerrors/errunauthorized.go +++ b/models/sdkerrors/errunauthorized.go @@ -17,7 +17,6 @@ const ( func (e ErrUnauthorizedCode) ToPointer() *ErrUnauthorizedCode { return &e } - func (e *ErrUnauthorizedCode) UnmarshalJSON(data []byte) error { var v string if err := json.Unmarshal(data, &v); err != nil { diff --git a/ratelimits.go b/ratelimits.go index 71cd4d3..1713713 100644 --- a/ratelimits.go +++ b/ratelimits.go @@ -8,6 +8,7 @@ import ( "fmt" "github.com/unkeyed/unkey-go/internal/hooks" "github.com/unkeyed/unkey-go/internal/utils" + "github.com/unkeyed/unkey-go/models/components" "github.com/unkeyed/unkey-go/models/operations" "github.com/unkeyed/unkey-go/models/sdkerrors" "io" @@ -25,7 +26,7 @@ func newRatelimits(sdkConfig sdkConfiguration) *Ratelimits { } } -func (s *Ratelimits) Limit(ctx context.Context, request operations.LimitRequestBody) (*operations.LimitResponseBody, error) { +func (s *Ratelimits) Limit(ctx context.Context, request operations.LimitRequestBody) (*operations.LimitResponse, error) { hookCtx := hooks.HookContext{ Context: ctx, OperationID: "limit", @@ -85,6 +86,13 @@ func (s *Ratelimits) Limit(ctx context.Context, request operations.LimitRequestB } } + res := &operations.LimitResponse{ + HTTPMeta: components.HTTPMetadata{ + Request: req, + Response: httpRes, + }, + } + rawBody, err := io.ReadAll(httpRes.Body) if err != nil { return nil, fmt.Errorf("error reading response body: %w", err) @@ -101,7 +109,7 @@ func (s *Ratelimits) Limit(ctx context.Context, request operations.LimitRequestB return nil, err } - return &out, nil + res.Object = &out default: return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } @@ -196,4 +204,7 @@ func (s *Ratelimits) Limit(ctx context.Context, request operations.LimitRequestB default: return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) } + + return res, nil + } diff --git a/unkey.go b/unkey.go index c664086..b3fd4e1 100644 --- a/unkey.go +++ b/unkey.go @@ -116,17 +116,11 @@ func WithClient(client HTTPClient) SDKOption { } } -func withSecurity(security interface{}) func(context.Context) (interface{}, error) { - return func(context.Context) (interface{}, error) { - return security, nil - } -} - // WithSecurity configures the SDK to use the provided security details func WithSecurity(bearerAuth string) SDKOption { return func(sdk *Unkey) { security := components.Security{BearerAuth: &bearerAuth} - sdk.sdkConfiguration.Security = withSecurity(&security) + sdk.sdkConfiguration.Security = utils.AsSecuritySource(&security) } } @@ -151,9 +145,9 @@ func New(opts ...SDKOption) *Unkey { sdkConfiguration: sdkConfiguration{ Language: "go", OpenAPIDocVersion: "1.0.0", - SDKVersion: "0.2.0", - GenVersion: "2.329.0", - UserAgent: "speakeasy-sdk/go 0.2.0 2.329.0 1.0.0 github.com/unkeyed/unkey-go", + SDKVersion: "0.3.0", + GenVersion: "2.338.1", + UserAgent: "speakeasy-sdk/go 0.3.0 2.338.1 1.0.0 github.com/unkeyed/unkey-go", Hooks: hooks.New(), }, } @@ -186,7 +180,7 @@ func New(opts ...SDKOption) *Unkey { return sdk } -func (s *Unkey) CreateAPI(ctx context.Context, request operations.CreateAPIRequestBody) (*operations.CreateAPIResponseBody, error) { +func (s *Unkey) CreateAPI(ctx context.Context, request operations.CreateAPIRequestBody) (*operations.CreateAPIResponse, error) { hookCtx := hooks.HookContext{ Context: ctx, OperationID: "createApi", @@ -246,6 +240,13 @@ func (s *Unkey) CreateAPI(ctx context.Context, request operations.CreateAPIReque } } + res := &operations.CreateAPIResponse{ + HTTPMeta: components.HTTPMetadata{ + Request: req, + Response: httpRes, + }, + } + rawBody, err := io.ReadAll(httpRes.Body) if err != nil { return nil, fmt.Errorf("error reading response body: %w", err) @@ -262,7 +263,7 @@ func (s *Unkey) CreateAPI(ctx context.Context, request operations.CreateAPIReque return nil, err } - return &out, nil + res.Object = &out default: return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } @@ -357,9 +358,12 @@ func (s *Unkey) CreateAPI(ctx context.Context, request operations.CreateAPIReque default: return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) } + + return res, nil + } -func (s *Unkey) DeleteAPI(ctx context.Context, request operations.DeleteAPIRequestBody) (*operations.DeleteAPIResponseBody, error) { +func (s *Unkey) DeleteAPI(ctx context.Context, request operations.DeleteAPIRequestBody) (*operations.DeleteAPIResponse, error) { hookCtx := hooks.HookContext{ Context: ctx, OperationID: "deleteApi", @@ -419,6 +423,13 @@ func (s *Unkey) DeleteAPI(ctx context.Context, request operations.DeleteAPIReque } } + res := &operations.DeleteAPIResponse{ + HTTPMeta: components.HTTPMetadata{ + Request: req, + Response: httpRes, + }, + } + rawBody, err := io.ReadAll(httpRes.Body) if err != nil { return nil, fmt.Errorf("error reading response body: %w", err) @@ -435,7 +446,7 @@ func (s *Unkey) DeleteAPI(ctx context.Context, request operations.DeleteAPIReque return nil, err } - return &out, nil + res.Object = &out default: return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } @@ -530,4 +541,7 @@ func (s *Unkey) DeleteAPI(ctx context.Context, request operations.DeleteAPIReque default: return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) } + + return res, nil + }