diff --git a/.speakeasy/gen.lock b/.speakeasy/gen.lock index 7d932e1..c4577b4 100755 --- a/.speakeasy/gen.lock +++ b/.speakeasy/gen.lock @@ -1,24 +1,24 @@ lockVersion: 2.0.0 id: 4fc4737a-135f-4840-8e6d-42a2b2a2884b management: - docChecksum: a715ffbc95c5418289d86dc35921e0e8 + docChecksum: 7621b6bd3bfaca0bcd2b0dc8150e0325 docVersion: 1.0.0 - speakeasyVersion: 1.286.0 - generationVersion: 2.326.3 - releaseVersion: 0.1.9 - configChecksum: 804fe5269ba412bff73d4706ac012430 + speakeasyVersion: 1.286.3 + generationVersion: 2.329.0 + releaseVersion: 0.2.0 + configChecksum: f7dcb627a24c2bc24f40a5b483adfe68 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.7 - deprecations: 2.81.1 + core: 3.4.8 globalSecurity: 2.82.9 globalSecurityCallbacks: 0.1.0 globalSecurityFlattening: 0.1.0 globalServerURLs: 2.82.2 + ignores: 2.81.1 intellisenseMarkdownSupport: 0.1.0 nullables: 0.1.0 responseFormat: 0.1.1 @@ -49,9 +49,6 @@ generatedFiles: - internal/utils/utils.go - /models/operations/createapi.go - /models/operations/deleteapi.go - - /models/operations/deprecatedcreatekey.go - - /models/operations/deprecatedverifykey.go - - /models/operations/deprecatedlistkeys.go - /models/operations/v1liveness.go - /models/operations/getkey.go - /models/operations/deletekey.go @@ -78,16 +75,6 @@ generatedFiles: - docs/models/operations/createapiresponsebody.md - docs/models/operations/deleteapirequestbody.md - docs/models/operations/deleteapiresponsebody.md - - docs/models/operations/deprecatedcreatekeytype.md - - docs/models/operations/deprecatedcreatekeyratelimit.md - - docs/models/operations/deprecatedcreatekeyrequestbody.md - - docs/models/operations/deprecatedcreatekeyresponsebody.md - - docs/models/operations/deprecatedverifykeyrequestbody.md - - docs/models/operations/deprecatedverifykeyratelimit.md - - docs/models/operations/code.md - - docs/models/operations/deprecatedverifykeyresponsebody.md - - docs/models/operations/deprecatedlistkeysrequest.md - - docs/models/operations/deprecatedlistkeysresponsebody.md - docs/models/operations/services.md - docs/models/operations/v1livenessresponsebody.md - docs/models/operations/getkeyrequest.md diff --git a/.speakeasy/gen.yaml b/.speakeasy/gen.yaml index c727ade..d6eac9c 100755 --- a/.speakeasy/gen.yaml +++ b/.speakeasy/gen.yaml @@ -12,7 +12,7 @@ generation: auth: oAuth2ClientCredentialsEnabled: true go: - version: 0.1.9 + version: 0.2.0 additionalDependencies: {} clientServerStatusCodesAsErrors: true flattenGlobalSecurity: true diff --git a/.speakeasy/workflow.lock b/.speakeasy/workflow.lock index 820f1f6..267cdfc 100644 --- a/.speakeasy/workflow.lock +++ b/.speakeasy/workflow.lock @@ -1,9 +1,9 @@ -speakeasyVersion: 1.286.0 +speakeasyVersion: 1.286.3 sources: openapi.json: sourceNamespace: openapi-json - sourceRevisionDigest: sha256:ac05bb0f5c3a362720650d5dacb4c16503a78f8b0aaebd6d9525fb27869028b2 - sourceBlobDigest: sha256:f0cdc501f15708ac39aefbdeb32553e5ce6a19b4dc32f7e3976c1b91b53eb6ba + sourceRevisionDigest: sha256:ea1217f15e8f55b82aace2a90dc970e731407804e4a60879d0d69bcfd7538aaa + sourceBlobDigest: sha256:e692b07a5ebd9d35e5c5ca35d98f0715dabd7647ad584b71114af07504e2b539 tags: - latest - main @@ -11,8 +11,8 @@ targets: go: source: openapi.json sourceNamespace: openapi-json - sourceRevisionDigest: sha256:ac05bb0f5c3a362720650d5dacb4c16503a78f8b0aaebd6d9525fb27869028b2 - sourceBlobDigest: sha256:f0cdc501f15708ac39aefbdeb32553e5ce6a19b4dc32f7e3976c1b91b53eb6ba + sourceRevisionDigest: sha256:ea1217f15e8f55b82aace2a90dc970e731407804e4a60879d0d69bcfd7538aaa + sourceBlobDigest: sha256:e692b07a5ebd9d35e5c5ca35d98f0715dabd7647ad584b71114af07504e2b539 outLocation: /github/workspace/repo workflow: workflowVersion: 1.0.0 diff --git a/README.md b/README.md index 6af46bd..86199ee 100644 --- a/README.md +++ b/README.md @@ -18,15 +18,15 @@ package main import ( "context" - "github.com/unkeyed/unkey" - "github.com/unkeyed/unkey/models/components" - "github.com/unkeyed/unkey/models/operations" + unkeygo "github.com/unkeyed/unkey-go" + "github.com/unkeyed/unkey-go/models/components" + "github.com/unkeyed/unkey-go/models/operations" "log" ) func main() { - s := unkey.New( - unkey.WithSecurity(""), + s := unkeygo.New( + unkeygo.WithSecurity(""), ) request := operations.CreateAPIRequestBody{ @@ -53,9 +53,6 @@ func main() { * [CreateAPI](docs/sdks/unkey/README.md#createapi) * [DeleteAPI](docs/sdks/unkey/README.md#deleteapi) -* [DeprecatedCreateKey](docs/sdks/unkey/README.md#deprecatedcreatekey) -* [~~DeprecatedVerifyKey~~](docs/sdks/unkey/README.md#deprecatedverifykey) - :warning: **Deprecated** -* [DeprecatedListKeys](docs/sdks/unkey/README.md#deprecatedlistkeys) ### [Liveness](docs/sdks/liveness/README.md) @@ -109,16 +106,16 @@ package main import ( "context" "errors" - "github.com/unkeyed/unkey" - "github.com/unkeyed/unkey/models/components" - "github.com/unkeyed/unkey/models/operations" - "github.com/unkeyed/unkey/models/sdkerrors" + 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" ) func main() { - s := unkey.New( - unkey.WithSecurity(""), + s := unkeygo.New( + unkeygo.WithSecurity(""), ) request := operations.CreateAPIRequestBody{ @@ -200,16 +197,16 @@ package main import ( "context" - "github.com/unkeyed/unkey" - "github.com/unkeyed/unkey/models/components" - "github.com/unkeyed/unkey/models/operations" + unkeygo "github.com/unkeyed/unkey-go" + "github.com/unkeyed/unkey-go/models/components" + "github.com/unkeyed/unkey-go/models/operations" "log" ) func main() { - s := unkey.New( - unkey.WithServerIndex(0), - unkey.WithSecurity(""), + s := unkeygo.New( + unkeygo.WithServerIndex(0), + unkeygo.WithSecurity(""), ) request := operations.CreateAPIRequestBody{ @@ -237,16 +234,16 @@ package main import ( "context" - "github.com/unkeyed/unkey" - "github.com/unkeyed/unkey/models/components" - "github.com/unkeyed/unkey/models/operations" + unkeygo "github.com/unkeyed/unkey-go" + "github.com/unkeyed/unkey-go/models/components" + "github.com/unkeyed/unkey-go/models/operations" "log" ) func main() { - s := unkey.New( - unkey.WithServerURL("https://api.unkey.dev"), - unkey.WithSecurity(""), + s := unkeygo.New( + unkeygo.WithServerURL("https://api.unkey.dev"), + unkeygo.WithSecurity(""), ) request := operations.CreateAPIRequestBody{ @@ -312,14 +309,14 @@ package main import ( "context" - "github.com/unkeyed/unkey" - "github.com/unkeyed/unkey/models/operations" + unkeygo "github.com/unkeyed/unkey-go" + "github.com/unkeyed/unkey-go/models/operations" "log" ) func main() { - s := unkey.New( - unkey.WithSecurity(""), + s := unkeygo.New( + unkeygo.WithSecurity(""), ) request := operations.CreateAPIRequestBody{ diff --git a/RELEASES.md b/RELEASES.md index 1a297f0..1163963 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -28,4 +28,14 @@ Based on: ### Generated - [go v0.1.9] . ### Releases -- [Go v0.1.9] https://github.com/unkeyed/unkey-go/releases/tag/v0.1.9 - . \ No newline at end of file +- [Go v0.1.9] https://github.com/unkeyed/unkey-go/releases/tag/v0.1.9 - . + +## 2024-05-14 00:23:57 +### Changes +Based on: +- OpenAPI Doc +- Speakeasy CLI 1.286.3 (2.329.0) https://github.com/speakeasy-api/speakeasy +### 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 diff --git a/USAGE.md b/USAGE.md index fca2a59..05040c2 100644 --- a/USAGE.md +++ b/USAGE.md @@ -4,15 +4,15 @@ package main import ( "context" - "github.com/unkeyed/unkey" - "github.com/unkeyed/unkey/models/components" - "github.com/unkeyed/unkey/models/operations" + unkeygo "github.com/unkeyed/unkey-go" + "github.com/unkeyed/unkey-go/models/components" + "github.com/unkeyed/unkey-go/models/operations" "log" ) func main() { - s := unkey.New( - unkey.WithSecurity(""), + s := unkeygo.New( + unkeygo.WithSecurity(""), ) request := operations.CreateAPIRequestBody{ diff --git a/apis.go b/apis.go index 93daf7f..3daa8ec 100644 --- a/apis.go +++ b/apis.go @@ -1,15 +1,15 @@ // Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. -package unkey +package unkeygo import ( "bytes" "context" "fmt" - "github.com/unkeyed/unkey/internal/hooks" - "github.com/unkeyed/unkey/internal/utils" - "github.com/unkeyed/unkey/models/operations" - "github.com/unkeyed/unkey/models/sdkerrors" + "github.com/unkeyed/unkey-go/internal/hooks" + "github.com/unkeyed/unkey-go/internal/utils" + "github.com/unkeyed/unkey-go/models/operations" + "github.com/unkeyed/unkey-go/models/sdkerrors" "io" "net/http" "net/url" diff --git a/codeSamples.yaml b/codeSamples.yaml index 493bce9..4b9a832 100644 --- a/codeSamples.yaml +++ b/codeSamples.yaml @@ -3,105 +3,87 @@ info: title: CodeSamples overlay for go target version: 0.0.0 actions: - - target: $["paths"]["/v1/apis.listKeys"]["get"] + - target: $["paths"]["/v1/keys.verifyKey"]["post"] update: "x-codeSamples": - "lang": "go" - "label": "listKeys" - "source": "package main\n\nimport(\n\t\"github.com/unkeyed/unkey/models/components\"\n\t\"github.com/unkeyed/unkey\"\n\t\"github.com/unkeyed/unkey/models/operations\"\n\t\"context\"\n\t\"log\"\n)\n\nfunc main() {\n s := unkey.New(\n unkey.WithSecurity(\"\"),\n )\n\n request := operations.ListKeysRequest{\n APIID: \"api_1234\",\n Limit: unkey.Int64(100),\n }\n \n ctx := context.Background()\n res, err := s.ListKeys(ctx, request)\n if err != nil {\n log.Fatal(err)\n }\n if res != nil {\n // handle response\n }\n}" - - target: $["paths"]["/v1/keys"]["post"] + "label": "verifyKey" + "source": "package main\n\nimport(\n\t\"github.com/unkeyed/unkey-go/models/components\"\n\tunkeygo \"github.com/unkeyed/unkey-go\"\n\t\"context\"\n\t\"log\"\n)\n\nfunc main() {\n s := unkeygo.New(\n unkeygo.WithSecurity(\"\"),\n )\n\n request := components.V1KeysVerifyKeyRequest{\n APIID: unkeygo.String(\"api_1234\"),\n Key: \"sk_1234\",\n Authorization: &components.Authorization{\n Permissions: &components.Permissions{},\n },\n }\n \n ctx := context.Background()\n res, err := s.VerifyKey(ctx, request)\n if err != nil {\n log.Fatal(err)\n }\n if res != nil {\n // handle response\n }\n}" + - target: $["paths"]["/v1/keys.deleteKey"]["post"] update: "x-codeSamples": - "lang": "go" - "label": "createKey" - "source": "package main\n\nimport(\n\t\"github.com/unkeyed/unkey/models/components\"\n\t\"github.com/unkeyed/unkey\"\n\t\"github.com/unkeyed/unkey/models/operations\"\n\t\"context\"\n\t\"log\"\n)\n\nfunc main() {\n s := unkey.New(\n unkey.WithSecurity(\"\"),\n )\n\n request := operations.DeprecatedCreateKeyRequestBody{\n APIID: \"api_123\",\n Name: unkey.String(\"my key\"),\n OwnerID: unkey.String(\"team_123\"),\n Meta: map[string]interface{}{\n \"billingTier\": \"PRO\",\n \"trialEnds\": \"2023-06-16T17:16:37.161Z\",\n },\n Expires: unkey.Int64(1623869797161),\n Remaining: unkey.Int64(1000),\n Ratelimit: &operations.DeprecatedCreateKeyRatelimit{\n Type: operations.DeprecatedCreateKeyTypeFast.ToPointer(),\n Limit: 10,\n RefillRate: 1,\n RefillInterval: 60,\n },\n }\n \n ctx := context.Background()\n res, err := s.DeprecatedCreateKey(ctx, request)\n if err != nil {\n log.Fatal(err)\n }\n if res != nil {\n // handle response\n }\n}" - - target: $["paths"]["/v1/keys.verifyKey"]["post"] + "label": "deleteKey" + "source": "package main\n\nimport(\n\t\"github.com/unkeyed/unkey-go/models/components\"\n\tunkeygo \"github.com/unkeyed/unkey-go\"\n\t\"github.com/unkeyed/unkey-go/models/operations\"\n\t\"context\"\n\t\"log\"\n)\n\nfunc main() {\n s := unkeygo.New(\n unkeygo.WithSecurity(\"\"),\n )\n\n request := operations.DeleteKeyRequestBody{\n KeyID: \"key_1234\",\n }\n \n ctx := context.Background()\n res, err := s.DeleteKey(ctx, request)\n if err != nil {\n log.Fatal(err)\n }\n if res != nil {\n // handle response\n }\n}" + - target: $["paths"]["/v1/keys.updateRemaining"]["post"] update: "x-codeSamples": - "lang": "go" - "label": "verifyKey" - "source": "package main\n\nimport(\n\t\"github.com/unkeyed/unkey/models/components\"\n\t\"github.com/unkeyed/unkey\"\n\t\"context\"\n\t\"log\"\n)\n\nfunc main() {\n s := unkey.New(\n unkey.WithSecurity(\"\"),\n )\n\n request := components.V1KeysVerifyKeyRequest{\n APIID: unkey.String(\"api_1234\"),\n Key: \"sk_1234\",\n Authorization: &components.Authorization{\n Permissions: &components.Permissions{},\n },\n }\n \n ctx := context.Background()\n res, err := s.VerifyKey(ctx, request)\n if err != nil {\n log.Fatal(err)\n }\n if res != nil {\n // handle response\n }\n}" + "label": "updateRemaining" + "source": "package main\n\nimport(\n\t\"github.com/unkeyed/unkey-go/models/components\"\n\tunkeygo \"github.com/unkeyed/unkey-go\"\n\t\"github.com/unkeyed/unkey-go/models/operations\"\n\t\"context\"\n\t\"log\"\n)\n\nfunc main() {\n s := unkeygo.New(\n unkeygo.WithSecurity(\"\"),\n )\n\n request := operations.UpdateRemainingRequestBody{\n KeyID: \"key_123\",\n Op: operations.OpSet,\n Value: unkeygo.Int64(1),\n }\n \n ctx := context.Background()\n res, err := s.UpdateRemaining(ctx, request)\n if err != nil {\n log.Fatal(err)\n }\n if res != nil {\n // handle response\n }\n}" - target: $["paths"]["/v1/apis.getApi"]["get"] update: "x-codeSamples": - "lang": "go" "label": "getApi" - "source": "package main\n\nimport(\n\t\"github.com/unkeyed/unkey/models/components\"\n\t\"github.com/unkeyed/unkey\"\n\t\"github.com/unkeyed/unkey/models/operations\"\n\t\"context\"\n\t\"log\"\n)\n\nfunc main() {\n s := unkey.New(\n unkey.WithSecurity(\"\"),\n )\n\n request := operations.GetAPIRequest{\n APIID: \"api_1234\",\n }\n \n ctx := context.Background()\n res, err := s.GetAPI(ctx, request)\n if err != nil {\n log.Fatal(err)\n }\n if res != nil {\n // handle response\n }\n}" - - target: $["paths"]["/v1/keys.getVerifications"]["get"] - update: - "x-codeSamples": - - "lang": "go" - "label": "getVerifications" - "source": "package main\n\nimport(\n\t\"github.com/unkeyed/unkey/models/components\"\n\t\"github.com/unkeyed/unkey\"\n\t\"github.com/unkeyed/unkey/models/operations\"\n\t\"context\"\n\t\"log\"\n)\n\nfunc main() {\n s := unkey.New(\n unkey.WithSecurity(\"\"),\n )\n\n request := operations.GetVerificationsRequest{\n KeyID: unkey.String(\"key_1234\"),\n OwnerID: unkey.String(\"chronark\"),\n Start: unkey.Int64(1620000000000),\n End: unkey.Int64(1620000000000),\n Granularity: operations.GranularityDay.ToPointer(),\n }\n \n ctx := context.Background()\n res, err := s.GetVerifications(ctx, request)\n if err != nil {\n log.Fatal(err)\n }\n if res != nil {\n // handle response\n }\n}" + "source": "package main\n\nimport(\n\t\"github.com/unkeyed/unkey-go/models/components\"\n\tunkeygo \"github.com/unkeyed/unkey-go\"\n\t\"github.com/unkeyed/unkey-go/models/operations\"\n\t\"context\"\n\t\"log\"\n)\n\nfunc main() {\n s := unkeygo.New(\n unkeygo.WithSecurity(\"\"),\n )\n\n request := operations.GetAPIRequest{\n APIID: \"api_1234\",\n }\n \n ctx := context.Background()\n res, err := s.GetAPI(ctx, request)\n if err != nil {\n log.Fatal(err)\n }\n if res != nil {\n // handle response\n }\n}" - target: $["paths"]["/v1/ratelimits.limit"]["post"] update: "x-codeSamples": - "lang": "go" "label": "limit" - "source": "package main\n\nimport(\n\t\"github.com/unkeyed/unkey/models/components\"\n\t\"github.com/unkeyed/unkey\"\n\t\"github.com/unkeyed/unkey/models/operations\"\n\t\"context\"\n\t\"log\"\n)\n\nfunc main() {\n s := unkey.New(\n unkey.WithSecurity(\"\"),\n )\n\n request := operations.LimitRequestBody{\n Namespace: unkey.String(\"email.outbound\"),\n Identifier: \"user_123\",\n Limit: 10,\n Duration: 60000,\n Cost: unkey.Int64(2),\n Resources: []operations.Resources{\n operations.Resources{\n Type: \"project\",\n ID: \"p_123\",\n Name: unkey.String(\"dub\"),\n },\n },\n }\n \n ctx := context.Background()\n res, err := s.Limit(ctx, request)\n if err != nil {\n log.Fatal(err)\n }\n if res != nil {\n // handle response\n }\n}" + "source": "package main\n\nimport(\n\t\"github.com/unkeyed/unkey-go/models/components\"\n\tunkeygo \"github.com/unkeyed/unkey-go\"\n\t\"github.com/unkeyed/unkey-go/models/operations\"\n\t\"context\"\n\t\"log\"\n)\n\nfunc main() {\n s := unkeygo.New(\n unkeygo.WithSecurity(\"\"),\n )\n\n request := operations.LimitRequestBody{\n Namespace: unkeygo.String(\"email.outbound\"),\n Identifier: \"user_123\",\n Limit: 10,\n Duration: 60000,\n Cost: unkeygo.Int64(2),\n Resources: []operations.Resources{\n operations.Resources{\n Type: \"project\",\n ID: \"p_123\",\n Name: unkeygo.String(\"dub\"),\n },\n },\n }\n \n ctx := context.Background()\n res, err := s.Limit(ctx, request)\n if err != nil {\n log.Fatal(err)\n }\n if res != nil {\n // handle response\n }\n}" - target: $["paths"]["/v1/apis.createApi"]["post"] update: "x-codeSamples": - "lang": "go" "label": "createApi" - "source": "package main\n\nimport(\n\t\"github.com/unkeyed/unkey/models/components\"\n\t\"github.com/unkeyed/unkey\"\n\t\"github.com/unkeyed/unkey/models/operations\"\n\t\"context\"\n\t\"log\"\n)\n\nfunc main() {\n s := unkey.New(\n unkey.WithSecurity(\"\"),\n )\n\n request := operations.CreateAPIRequestBody{\n Name: \"my-api\",\n }\n \n ctx := context.Background()\n res, err := s.CreateAPI(ctx, request)\n if err != nil {\n log.Fatal(err)\n }\n if res != nil {\n // handle response\n }\n}" - - target: $["paths"]["/v1/keys.createKey"]["post"] - update: - "x-codeSamples": - - "lang": "go" - "label": "createKey" - "source": "package main\n\nimport(\n\t\"github.com/unkeyed/unkey/models/components\"\n\t\"github.com/unkeyed/unkey\"\n\t\"github.com/unkeyed/unkey/models/operations\"\n\t\"context\"\n\t\"log\"\n)\n\nfunc main() {\n s := unkey.New(\n unkey.WithSecurity(\"\"),\n )\n\n request := operations.CreateKeyRequestBody{\n APIID: \"api_123\",\n Name: unkey.String(\"my key\"),\n OwnerID: unkey.String(\"team_123\"),\n Meta: map[string]interface{}{\n \"billingTier\": \"PRO\",\n \"trialEnds\": \"2023-06-16T17:16:37.161Z\",\n },\n Roles: []string{\n \"admin\",\n \"finance\",\n },\n Expires: unkey.Int64(1623869797161),\n Remaining: unkey.Int64(1000),\n Refill: &operations.Refill{\n Interval: operations.IntervalDaily,\n Amount: 100,\n },\n Ratelimit: &operations.Ratelimit{\n Type: operations.TypeFast.ToPointer(),\n Limit: 10,\n RefillRate: 1,\n RefillInterval: 60,\n },\n Enabled: unkey.Bool(false),\n }\n \n ctx := context.Background()\n res, err := s.CreateKey(ctx, request)\n if err != nil {\n log.Fatal(err)\n }\n if res != nil {\n // handle response\n }\n}" - - target: $["paths"]["/v1/keys.updateRemaining"]["post"] + "source": "package main\n\nimport(\n\t\"github.com/unkeyed/unkey-go/models/components\"\n\tunkeygo \"github.com/unkeyed/unkey-go\"\n\t\"github.com/unkeyed/unkey-go/models/operations\"\n\t\"context\"\n\t\"log\"\n)\n\nfunc main() {\n s := unkeygo.New(\n unkeygo.WithSecurity(\"\"),\n )\n\n request := operations.CreateAPIRequestBody{\n Name: \"my-api\",\n }\n \n ctx := context.Background()\n res, err := s.CreateAPI(ctx, request)\n if err != nil {\n log.Fatal(err)\n }\n if res != nil {\n // handle response\n }\n}" + - target: $["paths"]["/v1/liveness"]["get"] update: "x-codeSamples": - "lang": "go" - "label": "updateRemaining" - "source": "package main\n\nimport(\n\t\"github.com/unkeyed/unkey/models/components\"\n\t\"github.com/unkeyed/unkey\"\n\t\"github.com/unkeyed/unkey/models/operations\"\n\t\"context\"\n\t\"log\"\n)\n\nfunc main() {\n s := unkey.New(\n unkey.WithSecurity(\"\"),\n )\n\n request := operations.UpdateRemainingRequestBody{\n KeyID: \"key_123\",\n Op: operations.OpSet,\n Value: unkey.Int64(1),\n }\n \n ctx := context.Background()\n res, err := s.UpdateRemaining(ctx, request)\n if err != nil {\n log.Fatal(err)\n }\n if res != nil {\n // handle response\n }\n}" + "label": "liveness" + "source": "package main\n\nimport(\n\t\"github.com/unkeyed/unkey-go/models/components\"\n\tunkeygo \"github.com/unkeyed/unkey-go\"\n\t\"context\"\n\t\"log\"\n)\n\nfunc main() {\n s := unkeygo.New(\n unkeygo.WithSecurity(\"\"),\n )\n\n\n \n ctx := context.Background()\n res, err := s.V1Liveness(ctx)\n if err != nil {\n log.Fatal(err)\n }\n if res != nil {\n // handle response\n }\n}" - target: $["paths"]["/v1/keys.getKey"]["get"] update: "x-codeSamples": - "lang": "go" "label": "getKey" - "source": "package main\n\nimport(\n\t\"github.com/unkeyed/unkey/models/components\"\n\t\"github.com/unkeyed/unkey\"\n\t\"github.com/unkeyed/unkey/models/operations\"\n\t\"context\"\n\t\"log\"\n)\n\nfunc main() {\n s := unkey.New(\n unkey.WithSecurity(\"\"),\n )\n\n request := operations.GetKeyRequest{\n KeyID: \"key_1234\",\n }\n \n ctx := context.Background()\n res, err := s.GetKey(ctx, request)\n if err != nil {\n log.Fatal(err)\n }\n if res != nil {\n // handle response\n }\n}" - - target: $["paths"]["/v1/keys.deleteKey"]["post"] - update: - "x-codeSamples": - - "lang": "go" - "label": "deleteKey" - "source": "package main\n\nimport(\n\t\"github.com/unkeyed/unkey/models/components\"\n\t\"github.com/unkeyed/unkey\"\n\t\"github.com/unkeyed/unkey/models/operations\"\n\t\"context\"\n\t\"log\"\n)\n\nfunc main() {\n s := unkey.New(\n unkey.WithSecurity(\"\"),\n )\n\n request := operations.DeleteKeyRequestBody{\n KeyID: \"key_1234\",\n }\n \n ctx := context.Background()\n res, err := s.DeleteKey(ctx, request)\n if err != nil {\n log.Fatal(err)\n }\n if res != nil {\n // handle response\n }\n}" - - target: $["paths"]["/v1/migrations.createKeys"]["post"] + "source": "package main\n\nimport(\n\t\"github.com/unkeyed/unkey-go/models/components\"\n\tunkeygo \"github.com/unkeyed/unkey-go\"\n\t\"github.com/unkeyed/unkey-go/models/operations\"\n\t\"context\"\n\t\"log\"\n)\n\nfunc main() {\n s := unkeygo.New(\n unkeygo.WithSecurity(\"\"),\n )\n\n request := operations.GetKeyRequest{\n KeyID: \"key_1234\",\n }\n \n ctx := context.Background()\n res, err := s.GetKey(ctx, request)\n if err != nil {\n log.Fatal(err)\n }\n if res != nil {\n // handle response\n }\n}" + - target: $["paths"]["/v1/keys.createKey"]["post"] update: "x-codeSamples": - "lang": "go" - "label": "createKeys" - "source": "package main\n\nimport(\n\t\"github.com/unkeyed/unkey/models/components\"\n\t\"github.com/unkeyed/unkey\"\n\t\"github.com/unkeyed/unkey/models/operations\"\n\t\"context\"\n\t\"log\"\n)\n\nfunc main() {\n s := unkey.New(\n unkey.WithSecurity(\"\"),\n )\n\n request := []operations.RequestBody{\n operations.RequestBody{\n APIID: \"api_123\",\n Name: unkey.String(\"my key\"),\n Hash: operations.Hash{\n Value: \"\",\n Variant: operations.VariantSha256Base64,\n },\n Start: unkey.String(\"unkey_32kq\"),\n OwnerID: unkey.String(\"team_123\"),\n Meta: map[string]interface{}{\n \"billingTier\": \"PRO\",\n \"trialEnds\": \"2023-06-16T17:16:37.161Z\",\n },\n Roles: []string{\n \"admin\",\n \"finance\",\n },\n Expires: unkey.Int64(1623869797161),\n Remaining: unkey.Int64(1000),\n Refill: &operations.V1MigrationsCreateKeysRefill{\n Interval: operations.V1MigrationsCreateKeysIntervalDaily,\n Amount: 100,\n },\n Ratelimit: &operations.V1MigrationsCreateKeysRatelimit{\n Type: operations.V1MigrationsCreateKeysTypeFast.ToPointer(),\n Limit: 10,\n RefillRate: 1,\n RefillInterval: 60,\n },\n Enabled: unkey.Bool(false),\n },\n }\n \n ctx := context.Background()\n res, err := s.V1MigrationsCreateKeys(ctx, request)\n if err != nil {\n log.Fatal(err)\n }\n if res != nil {\n // handle response\n }\n}" - - target: $["paths"]["/v1/liveness"]["get"] + "label": "createKey" + "source": "package main\n\nimport(\n\t\"github.com/unkeyed/unkey-go/models/components\"\n\tunkeygo \"github.com/unkeyed/unkey-go\"\n\t\"github.com/unkeyed/unkey-go/models/operations\"\n\t\"context\"\n\t\"log\"\n)\n\nfunc main() {\n s := unkeygo.New(\n unkeygo.WithSecurity(\"\"),\n )\n\n request := operations.CreateKeyRequestBody{\n APIID: \"api_123\",\n Name: unkeygo.String(\"my key\"),\n OwnerID: unkeygo.String(\"team_123\"),\n Meta: map[string]any{\n \"billingTier\": \"PRO\",\n \"trialEnds\": \"2023-06-16T17:16:37.161Z\",\n },\n Roles: []string{\n \"admin\",\n \"finance\",\n },\n Expires: unkeygo.Int64(1623869797161),\n Remaining: unkeygo.Int64(1000),\n Refill: &operations.Refill{\n Interval: operations.IntervalDaily,\n Amount: 100,\n },\n Ratelimit: &operations.Ratelimit{\n Type: operations.TypeFast.ToPointer(),\n Limit: 10,\n RefillRate: 1,\n RefillInterval: 60,\n },\n Enabled: unkeygo.Bool(false),\n }\n \n ctx := context.Background()\n res, err := s.CreateKey(ctx, request)\n if err != nil {\n log.Fatal(err)\n }\n if res != nil {\n // handle response\n }\n}" + - target: $["paths"]["/v1/keys.updateKey"]["post"] update: "x-codeSamples": - "lang": "go" - "label": "liveness" - "source": "package main\n\nimport(\n\t\"github.com/unkeyed/unkey/models/components\"\n\t\"github.com/unkeyed/unkey\"\n\t\"context\"\n\t\"log\"\n)\n\nfunc main() {\n s := unkey.New(\n unkey.WithSecurity(\"\"),\n )\n\n\n \n ctx := context.Background()\n res, err := s.V1Liveness(ctx)\n if err != nil {\n log.Fatal(err)\n }\n if res != nil {\n // handle response\n }\n}" - - target: $["paths"]["/v1/keys.updateKey"]["post"] + "label": "updateKey" + "source": "package main\n\nimport(\n\t\"github.com/unkeyed/unkey-go/models/components\"\n\tunkeygo \"github.com/unkeyed/unkey-go\"\n\t\"github.com/unkeyed/unkey-go/models/operations\"\n\t\"context\"\n\t\"log\"\n)\n\nfunc main() {\n s := unkeygo.New(\n unkeygo.WithSecurity(\"\"),\n )\n\n request := operations.UpdateKeyRequestBody{\n KeyID: \"key_123\",\n Name: unkeygo.String(\"Customer X\"),\n OwnerID: unkeygo.String(\"user_123\"),\n Meta: map[string]any{\n \"roles\": []any{\n \"admin\",\n \"user\",\n },\n \"stripeCustomerId\": \"cus_1234\",\n },\n Expires: unkeygo.Float64(0),\n Ratelimit: &operations.UpdateKeyRatelimit{\n Type: operations.UpdateKeyTypeFast,\n Limit: 10,\n RefillRate: 1,\n RefillInterval: 60,\n },\n Remaining: unkeygo.Float64(1000),\n Refill: &operations.UpdateKeyRefill{\n Interval: operations.UpdateKeyIntervalDaily,\n Amount: 100,\n },\n Enabled: unkeygo.Bool(true),\n }\n \n ctx := context.Background()\n res, err := s.UpdateKey(ctx, request)\n if err != nil {\n log.Fatal(err)\n }\n if res != nil {\n // handle response\n }\n}" + - target: $["paths"]["/v1/keys.getVerifications"]["get"] update: "x-codeSamples": - "lang": "go" - "label": "updateKey" - "source": "package main\n\nimport(\n\t\"github.com/unkeyed/unkey/models/components\"\n\t\"github.com/unkeyed/unkey\"\n\t\"github.com/unkeyed/unkey/models/operations\"\n\t\"context\"\n\t\"log\"\n)\n\nfunc main() {\n s := unkey.New(\n unkey.WithSecurity(\"\"),\n )\n\n request := operations.UpdateKeyRequestBody{\n KeyID: \"key_123\",\n Name: unkey.String(\"Customer X\"),\n OwnerID: unkey.String(\"user_123\"),\n Meta: map[string]interface{}{\n \"roles\": \"\",\n \"stripeCustomerId\": \"cus_1234\",\n },\n Expires: unkey.Float64(0),\n Ratelimit: &operations.UpdateKeyRatelimit{\n Type: operations.UpdateKeyTypeFast,\n Limit: 10,\n RefillRate: 1,\n RefillInterval: 60,\n },\n Remaining: unkey.Float64(1000),\n Refill: &operations.UpdateKeyRefill{\n Interval: operations.UpdateKeyIntervalDaily,\n Amount: 100,\n },\n Enabled: unkey.Bool(true),\n }\n \n ctx := context.Background()\n res, err := s.UpdateKey(ctx, request)\n if err != nil {\n log.Fatal(err)\n }\n if res != nil {\n // handle response\n }\n}" + "label": "getVerifications" + "source": "package main\n\nimport(\n\t\"github.com/unkeyed/unkey-go/models/components\"\n\tunkeygo \"github.com/unkeyed/unkey-go\"\n\t\"github.com/unkeyed/unkey-go/models/operations\"\n\t\"context\"\n\t\"log\"\n)\n\nfunc main() {\n s := unkeygo.New(\n unkeygo.WithSecurity(\"\"),\n )\n\n request := operations.GetVerificationsRequest{\n KeyID: unkeygo.String(\"key_1234\"),\n OwnerID: unkeygo.String(\"chronark\"),\n Start: unkeygo.Int64(1620000000000),\n End: unkeygo.Int64(1620000000000),\n Granularity: operations.GranularityDay.ToPointer(),\n }\n \n ctx := context.Background()\n res, err := s.GetVerifications(ctx, request)\n if err != nil {\n log.Fatal(err)\n }\n if res != nil {\n // handle response\n }\n}" - target: $["paths"]["/v1/apis.deleteApi"]["post"] update: "x-codeSamples": - "lang": "go" "label": "deleteApi" - "source": "package main\n\nimport(\n\t\"github.com/unkeyed/unkey/models/components\"\n\t\"github.com/unkeyed/unkey\"\n\t\"github.com/unkeyed/unkey/models/operations\"\n\t\"context\"\n\t\"log\"\n)\n\nfunc main() {\n s := unkey.New(\n unkey.WithSecurity(\"\"),\n )\n\n request := operations.DeleteAPIRequestBody{\n APIID: \"api_1234\",\n }\n \n ctx := context.Background()\n res, err := s.DeleteAPI(ctx, request)\n if err != nil {\n log.Fatal(err)\n }\n if res != nil {\n // handle response\n }\n}" - - target: $["paths"]["/v1/keys/verify"]["post"] + "source": "package main\n\nimport(\n\t\"github.com/unkeyed/unkey-go/models/components\"\n\tunkeygo \"github.com/unkeyed/unkey-go\"\n\t\"github.com/unkeyed/unkey-go/models/operations\"\n\t\"context\"\n\t\"log\"\n)\n\nfunc main() {\n s := unkeygo.New(\n unkeygo.WithSecurity(\"\"),\n )\n\n request := operations.DeleteAPIRequestBody{\n APIID: \"api_1234\",\n }\n \n ctx := context.Background()\n res, err := s.DeleteAPI(ctx, request)\n if err != nil {\n log.Fatal(err)\n }\n if res != nil {\n // handle response\n }\n}" + - target: $["paths"]["/v1/migrations.createKeys"]["post"] update: "x-codeSamples": - "lang": "go" - "label": "verifyKey" - "source": "package main\n\nimport(\n\t\"github.com/unkeyed/unkey/models/components\"\n\t\"github.com/unkeyed/unkey\"\n\t\"github.com/unkeyed/unkey/models/operations\"\n\t\"context\"\n\t\"log\"\n)\n\nfunc main() {\n s := unkey.New(\n unkey.WithSecurity(\"\"),\n )\n\n request := operations.DeprecatedVerifyKeyRequestBody{\n APIID: unkey.String(\"api_1234\"),\n Key: \"sk_1234\",\n }\n \n ctx := context.Background()\n res, err := s.DeprecatedVerifyKey(ctx, request)\n if err != nil {\n log.Fatal(err)\n }\n if res != nil {\n // handle response\n }\n}" - - target: $["paths"]["/v1/apis/{apiId}/keys"]["get"] + "label": "createKeys" + "source": "package main\n\nimport(\n\t\"github.com/unkeyed/unkey-go/models/components\"\n\tunkeygo \"github.com/unkeyed/unkey-go\"\n\t\"github.com/unkeyed/unkey-go/models/operations\"\n\t\"context\"\n\t\"log\"\n)\n\nfunc main() {\n s := unkeygo.New(\n unkeygo.WithSecurity(\"\"),\n )\n\n request := []operations.RequestBody{\n operations.RequestBody{\n APIID: \"api_123\",\n Name: unkeygo.String(\"my key\"),\n Hash: operations.Hash{\n Value: \"\",\n Variant: operations.VariantSha256Base64,\n },\n Start: unkeygo.String(\"unkey_32kq\"),\n OwnerID: unkeygo.String(\"team_123\"),\n Meta: map[string]any{\n \"billingTier\": \"PRO\",\n \"trialEnds\": \"2023-06-16T17:16:37.161Z\",\n },\n Roles: []string{\n \"admin\",\n \"finance\",\n },\n Expires: unkeygo.Int64(1623869797161),\n Remaining: unkeygo.Int64(1000),\n Refill: &operations.V1MigrationsCreateKeysRefill{\n Interval: operations.V1MigrationsCreateKeysIntervalDaily,\n Amount: 100,\n },\n Ratelimit: &operations.V1MigrationsCreateKeysRatelimit{\n Type: operations.V1MigrationsCreateKeysTypeFast.ToPointer(),\n Limit: 10,\n RefillRate: 1,\n RefillInterval: 60,\n },\n Enabled: unkeygo.Bool(false),\n },\n }\n \n ctx := context.Background()\n res, err := s.V1MigrationsCreateKeys(ctx, request)\n if err != nil {\n log.Fatal(err)\n }\n if res != nil {\n // handle response\n }\n}" + - target: $["paths"]["/v1/apis.listKeys"]["get"] update: "x-codeSamples": - "lang": "go" "label": "listKeys" - "source": "package main\n\nimport(\n\t\"github.com/unkeyed/unkey/models/components\"\n\t\"github.com/unkeyed/unkey\"\n\t\"github.com/unkeyed/unkey/models/operations\"\n\t\"context\"\n\t\"log\"\n)\n\nfunc main() {\n s := unkey.New(\n unkey.WithSecurity(\"\"),\n )\n\n request := operations.DeprecatedListKeysRequest{\n APIID: \"api_1234\",\n Limit: unkey.Int64(100),\n }\n \n ctx := context.Background()\n res, err := s.DeprecatedListKeys(ctx, request)\n if err != nil {\n log.Fatal(err)\n }\n if res != nil {\n // handle response\n }\n}" + "source": "package main\n\nimport(\n\t\"github.com/unkeyed/unkey-go/models/components\"\n\tunkeygo \"github.com/unkeyed/unkey-go\"\n\t\"github.com/unkeyed/unkey-go/models/operations\"\n\t\"context\"\n\t\"log\"\n)\n\nfunc main() {\n s := unkeygo.New(\n unkeygo.WithSecurity(\"\"),\n )\n\n request := operations.ListKeysRequest{\n APIID: \"api_1234\",\n Limit: unkeygo.Int64(100),\n }\n \n ctx := context.Background()\n res, err := s.ListKeys(ctx, request)\n if err != nil {\n log.Fatal(err)\n }\n if res != nil {\n // handle response\n }\n}" diff --git a/docs/models/components/key.md b/docs/models/components/key.md index d45fd5a..40a4c93 100644 --- a/docs/models/components/key.md +++ b/docs/models/components/key.md @@ -11,7 +11,7 @@ | `APIID` | **string* | :heavy_minus_sign: | The id of the api that this key is for | api_1234 | | `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]*interface{}* | :heavy_minus_sign: | Any additional metadata you want to store with the key | {
"roles": [
"admin",
"user"
],
"stripeCustomerId": "cus_1234"
} | +| `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 | | `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 | diff --git a/docs/models/components/v1keysverifykeyresponse.md b/docs/models/components/v1keysverifykeyresponse.md index 61fd136..b80f0b0 100644 --- a/docs/models/components/v1keysverifykeyresponse.md +++ b/docs/models/components/v1keysverifykeyresponse.md @@ -9,7 +9,7 @@ | `Valid` | *bool* | :heavy_check_mark: | Whether the key is valid or not.
A key could be invalid for a number of reasons, for example if it has expired, has no more verifications left or if it has been deleted. | true | | `Name` | **string* | :heavy_minus_sign: | The name of the key, give keys a name to easily identifiy 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]*interface{}* | :heavy_minus_sign: | Any additional metadata you want to store with the key | {
"roles": [
"admin",
"user"
],
"stripeCustomerId": "cus_1234"
} | +| `Meta` | map[string]*any* | :heavy_minus_sign: | Any additional metadata you want to store with the key | {
"roles": [
"admin",
"user"
],
"stripeCustomerId": "cus_1234"
} | | `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. | 123 | | `Ratelimit` | [*components.V1KeysVerifyKeyResponseRatelimit](../../models/components/v1keysverifykeyresponseratelimit.md) | :heavy_minus_sign: | The ratelimit configuration for this key. If this field is null or undefined, the key has no ratelimit. | {
"limit": 10,
"remaining": 9,
"reset": 3600000
} | | `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 | diff --git a/docs/models/operations/code.md b/docs/models/operations/code.md deleted file mode 100644 index f096e21..0000000 --- a/docs/models/operations/code.md +++ /dev/null @@ -1,23 +0,0 @@ -# Code - -If the key is invalid this field will be set to the reason why it is invalid. -Possible values are: -- NOT_FOUND: the key does not exist or has expired -- FORBIDDEN: the key is not allowed to access the api -- USAGE_EXCEEDED: the key has exceeded its request limit -- RATE_LIMITED: the key has been ratelimited, -- INSUFFICIENT_PERMISSIONS: you do not have the required permissions to perform this action - - - -## Values - -| Name | Value | -| ----------------------------- | ----------------------------- | -| `CodeNotFound` | NOT_FOUND | -| `CodeForbidden` | FORBIDDEN | -| `CodeUsageExceeded` | USAGE_EXCEEDED | -| `CodeRateLimited` | RATE_LIMITED | -| `CodeUnauthorized` | UNAUTHORIZED | -| `CodeDisabled` | DISABLED | -| `CodeInsufficientPermissions` | INSUFFICIENT_PERMISSIONS | \ No newline at end of file diff --git a/docs/models/operations/createkeyrequestbody.md b/docs/models/operations/createkeyrequestbody.md index de42b13..6274519 100644 --- a/docs/models/operations/createkeyrequestbody.md +++ b/docs/models/operations/createkeyrequestbody.md @@ -10,7 +10,7 @@ | `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]*interface{}* | :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"
} | +| `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 | diff --git a/docs/models/operations/deprecatedcreatekeyratelimit.md b/docs/models/operations/deprecatedcreatekeyratelimit.md deleted file mode 100644 index d09aab3..0000000 --- a/docs/models/operations/deprecatedcreatekeyratelimit.md +++ /dev/null @@ -1,13 +0,0 @@ -# DeprecatedCreateKeyRatelimit - -Unkey comes with per-key ratelimiting out of the box. - - -## Fields - -| Field | Type | Required | Description | -| -------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------- | -| `Type` | [*operations.DeprecatedCreateKeyType](../../models/operations/deprecatedcreatekeytype.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 diff --git a/docs/models/operations/deprecatedcreatekeyrequestbody.md b/docs/models/operations/deprecatedcreatekeyrequestbody.md deleted file mode 100644 index 3bc3c30..0000000 --- a/docs/models/operations/deprecatedcreatekeyrequestbody.md +++ /dev/null @@ -1,16 +0,0 @@ -# DeprecatedCreateKeyRequestBody - - -## 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]*interface{}* | :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"
} | -| `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 | -| `Ratelimit` | [*operations.DeprecatedCreateKeyRatelimit](../../models/operations/deprecatedcreatekeyratelimit.md) | :heavy_minus_sign: | Unkey comes with per-key ratelimiting out of the box. | {
"type": "fast",
"limit": 10,
"refillRate": 1,
"refillInterval": 60
} | \ No newline at end of file diff --git a/docs/models/operations/deprecatedcreatekeyresponsebody.md b/docs/models/operations/deprecatedcreatekeyresponsebody.md deleted file mode 100644 index bf1ffd0..0000000 --- a/docs/models/operations/deprecatedcreatekeyresponsebody.md +++ /dev/null @@ -1,11 +0,0 @@ -# DeprecatedCreateKeyResponseBody - -The configuration for an api - - -## Fields - -| Field | Type | Required | Description | Example | -| ----------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------- | -| `KeyID` | *string* | :heavy_check_mark: | The id of the key. This is not a secret and can be stored as a reference if you wish. You need the keyId to update or delete a key later. | key_123 | -| `Key` | *string* | :heavy_check_mark: | The newly created api key, do not store this on your own system but pass it along to your user. | prefix_xxxxxxxxx | \ No newline at end of file diff --git a/docs/models/operations/deprecatedcreatekeytype.md b/docs/models/operations/deprecatedcreatekeytype.md deleted file mode 100644 index 284c6ae..0000000 --- a/docs/models/operations/deprecatedcreatekeytype.md +++ /dev/null @@ -1,14 +0,0 @@ -# DeprecatedCreateKeyType - -Fast ratelimiting doesn't add latency, while consistent ratelimiting is more accurate. - -Learn more - - - -## Values - -| Name | Value | -| ----------------------------------- | ----------------------------------- | -| `DeprecatedCreateKeyTypeFast` | fast | -| `DeprecatedCreateKeyTypeConsistent` | consistent | \ No newline at end of file diff --git a/docs/models/operations/deprecatedlistkeysrequest.md b/docs/models/operations/deprecatedlistkeysrequest.md deleted file mode 100644 index 41f95ec..0000000 --- a/docs/models/operations/deprecatedlistkeysrequest.md +++ /dev/null @@ -1,11 +0,0 @@ -# DeprecatedListKeysRequest - - -## Fields - -| Field | Type | Required | Description | Example | -| ------------------ | ------------------ | ------------------ | ------------------ | ------------------ | -| `APIID` | *string* | :heavy_check_mark: | N/A | api_1234 | -| `Limit` | **int64* | :heavy_minus_sign: | N/A | 100 | -| `Offset` | **float64* | :heavy_minus_sign: | N/A | | -| `OwnerID` | **string* | :heavy_minus_sign: | N/A | | \ No newline at end of file diff --git a/docs/models/operations/deprecatedlistkeysresponsebody.md b/docs/models/operations/deprecatedlistkeysresponsebody.md deleted file mode 100644 index 7784e1b..0000000 --- a/docs/models/operations/deprecatedlistkeysresponsebody.md +++ /dev/null @@ -1,11 +0,0 @@ -# DeprecatedListKeysResponseBody - -Keys belonging to the api - - -## Fields - -| Field | Type | Required | Description | -| -------------------------------------------------- | -------------------------------------------------- | -------------------------------------------------- | -------------------------------------------------- | -| `Keys` | [][components.Key](../../models/components/key.md) | :heavy_check_mark: | N/A | -| `Total` | *int64* | :heavy_check_mark: | The total number of keys for this api | \ No newline at end of file diff --git a/docs/models/operations/deprecatedverifykeyratelimit.md b/docs/models/operations/deprecatedverifykeyratelimit.md deleted file mode 100644 index d915bbb..0000000 --- a/docs/models/operations/deprecatedverifykeyratelimit.md +++ /dev/null @@ -1,12 +0,0 @@ -# DeprecatedVerifyKeyRatelimit - -The ratelimit configuration for this key. If this field is null or undefined, the key has no ratelimit. - - -## Fields - -| Field | Type | Required | Description | Example | -| ------------------------------------------------------------ | ------------------------------------------------------------ | ------------------------------------------------------------ | ------------------------------------------------------------ | ------------------------------------------------------------ | -| `Limit` | *float64* | :heavy_check_mark: | Maximum number of requests that can be made inside a window | 10 | -| `Remaining` | *float64* | :heavy_check_mark: | Remaining requests after this verification | 9 | -| `Reset` | *float64* | :heavy_check_mark: | Unix timestamp in milliseconds when the ratelimit will reset | 3600000 | \ No newline at end of file diff --git a/docs/models/operations/deprecatedverifykeyrequestbody.md b/docs/models/operations/deprecatedverifykeyrequestbody.md deleted file mode 100644 index 0223a81..0000000 --- a/docs/models/operations/deprecatedverifykeyrequestbody.md +++ /dev/null @@ -1,9 +0,0 @@ -# DeprecatedVerifyKeyRequestBody - - -## Fields - -| Field | Type | Required | Description | Example | -| ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `APIID` | **string* | :heavy_minus_sign: | The id of the api where the key belongs to. This is optional for now but will be required soon.
The key will be verified against the api's configuration. If the key does not belong to the api, the verification will fail. | api_1234 | -| `Key` | *string* | :heavy_check_mark: | The key to verify | sk_1234 | \ No newline at end of file diff --git a/docs/models/operations/deprecatedverifykeyresponsebody.md b/docs/models/operations/deprecatedverifykeyresponsebody.md deleted file mode 100644 index a7248fe..0000000 --- a/docs/models/operations/deprecatedverifykeyresponsebody.md +++ /dev/null @@ -1,20 +0,0 @@ -# DeprecatedVerifyKeyResponseBody - -The verification result - - -## Fields - -| Field | Type | Required | Description | Example | -| --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `KeyID` | **string* | :heavy_minus_sign: | The id of the key | key_1234 | -| `Valid` | *bool* | :heavy_check_mark: | Whether the key is valid or not.
A key could be invalid for a number of reasons, for example if it has expired, has no more verifications left or if it has been deleted. | true | -| `Name` | **string* | :heavy_minus_sign: | The name of the key, give keys a name to easily identifiy 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]*interface{}* | :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 | -| `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. | 123 | -| `Ratelimit` | [*operations.DeprecatedVerifyKeyRatelimit](../../models/operations/deprecatedverifykeyratelimit.md) | :heavy_minus_sign: | The ratelimit configuration for this key. If this field is null or undefined, the key has no ratelimit. | {
"limit": 10,
"remaining": 9,
"reset": 3600000
} | -| `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 | -| `Code` | [*operations.Code](../../models/operations/code.md) | :heavy_minus_sign: | If the key is invalid this field will be set to the reason why it is invalid.
Possible values are:
- NOT_FOUND: the key does not exist or has expired
- FORBIDDEN: the key is not allowed to access the api
- USAGE_EXCEEDED: the key has exceeded its request limit
- RATE_LIMITED: the key has been ratelimited,
- INSUFFICIENT_PERMISSIONS: you do not have the required permissions to perform this action
| NOT_FOUND | \ No newline at end of file diff --git a/docs/models/operations/limitrequestbody.md b/docs/models/operations/limitrequestbody.md index bf85bdf..d0cc724 100644 --- a/docs/models/operations/limitrequestbody.md +++ b/docs/models/operations/limitrequestbody.md @@ -11,5 +11,5 @@ | `Duration` | *int64* | :heavy_check_mark: | The window duration in milliseconds | 60000 | | `Cost` | **int64* | :heavy_minus_sign: | Expensive requests may use up more tokens. You can specify a cost to the request here and we'll deduct this many tokens in the current window. If there are not enough tokens left, the request is denied. | 2 | | `Async` | **bool* | :heavy_minus_sign: | Async will return a response immediately, lowering latency at the cost of accuracy. | | -| `Meta` | map[string]*interface{}* | :heavy_minus_sign: | Attach any metadata to this request | | +| `Meta` | map[string]*any* | :heavy_minus_sign: | Attach any metadata to this request | | | `Resources` | [][operations.Resources](../../models/operations/resources.md) | :heavy_minus_sign: | Resources that are about to be accessed by the user | [
{
"type": "project",
"id": "p_123",
"name": "dub"
}
] | \ No newline at end of file diff --git a/docs/models/operations/requestbody.md b/docs/models/operations/requestbody.md index 006e79e..a89525e 100644 --- a/docs/models/operations/requestbody.md +++ b/docs/models/operations/requestbody.md @@ -11,7 +11,7 @@ | `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]*interface{}* | :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"
} | +| `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 | diff --git a/docs/models/operations/resources.md b/docs/models/operations/resources.md index 58a9bb2..d9cf880 100644 --- a/docs/models/operations/resources.md +++ b/docs/models/operations/resources.md @@ -8,4 +8,4 @@ | `Type` | *string* | :heavy_check_mark: | The type of resource | organization | | `ID` | *string* | :heavy_check_mark: | The unique identifier for the resource | org_123 | | `Name` | **string* | :heavy_minus_sign: | A human readable name for this resource | unkey | -| `Meta` | map[string]*interface{}* | :heavy_minus_sign: | Attach any metadata to this resources | | \ No newline at end of file +| `Meta` | map[string]*any* | :heavy_minus_sign: | Attach any metadata to this resources | | \ No newline at end of file diff --git a/docs/models/operations/updatekeyrequestbody.md b/docs/models/operations/updatekeyrequestbody.md index 2939470..6eb18e4 100644 --- a/docs/models/operations/updatekeyrequestbody.md +++ b/docs/models/operations/updatekeyrequestbody.md @@ -8,7 +8,7 @@ | `KeyID` | *string* | :heavy_check_mark: | The id of the key you want to modify | key_123 | | `Name` | **string* | :heavy_minus_sign: | The name of the key | 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]*interface{}* | :heavy_minus_sign: | Any additional metadata you want to store with the key | {
"roles": [
"admin",
"user"
],
"stripeCustomerId": "cus_1234"
} | +| `Meta` | map[string]*any* | :heavy_minus_sign: | Any additional metadata you want to store with the key | {
"roles": [
"admin",
"user"
],
"stripeCustomerId": "cus_1234"
} | | `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 | | `Ratelimit` | [*operations.UpdateKeyRatelimit](../../models/operations/updatekeyratelimit.md) | :heavy_minus_sign: | Unkey comes with per-key ratelimiting out of the box. Set `null` to disable. | {
"type": "fast",
"limit": 10,
"refillRate": 1,
"refillInterval": 60
} | | `Remaining` | **float64* | :heavy_minus_sign: | The number of requests that can be made with this key before it becomes invalid. Set `null` to disable. | 1000 | diff --git a/docs/sdks/apis/README.md b/docs/sdks/apis/README.md index e54ce08..8294df9 100644 --- a/docs/sdks/apis/README.md +++ b/docs/sdks/apis/README.md @@ -14,16 +14,16 @@ package main import( - "github.com/unkeyed/unkey/models/components" - "github.com/unkeyed/unkey" - "github.com/unkeyed/unkey/models/operations" + "github.com/unkeyed/unkey-go/models/components" + unkeygo "github.com/unkeyed/unkey-go" + "github.com/unkeyed/unkey-go/models/operations" "context" "log" ) func main() { - s := unkey.New( - unkey.WithSecurity(""), + s := unkeygo.New( + unkeygo.WithSecurity(""), ) request := operations.GetAPIRequest{ @@ -71,21 +71,21 @@ func main() { package main import( - "github.com/unkeyed/unkey/models/components" - "github.com/unkeyed/unkey" - "github.com/unkeyed/unkey/models/operations" + "github.com/unkeyed/unkey-go/models/components" + unkeygo "github.com/unkeyed/unkey-go" + "github.com/unkeyed/unkey-go/models/operations" "context" "log" ) func main() { - s := unkey.New( - unkey.WithSecurity(""), + s := unkeygo.New( + unkeygo.WithSecurity(""), ) request := operations.ListKeysRequest{ APIID: "api_1234", - Limit: unkey.Int64(100), + Limit: unkeygo.Int64(100), } ctx := context.Background() diff --git a/docs/sdks/keys/README.md b/docs/sdks/keys/README.md index e2b8946..dd75fb9 100644 --- a/docs/sdks/keys/README.md +++ b/docs/sdks/keys/README.md @@ -19,16 +19,16 @@ package main import( - "github.com/unkeyed/unkey/models/components" - "github.com/unkeyed/unkey" - "github.com/unkeyed/unkey/models/operations" + "github.com/unkeyed/unkey-go/models/components" + unkeygo "github.com/unkeyed/unkey-go" + "github.com/unkeyed/unkey-go/models/operations" "context" "log" ) func main() { - s := unkey.New( - unkey.WithSecurity(""), + s := unkeygo.New( + unkeygo.WithSecurity(""), ) request := operations.GetKeyRequest{ @@ -76,16 +76,16 @@ func main() { package main import( - "github.com/unkeyed/unkey/models/components" - "github.com/unkeyed/unkey" - "github.com/unkeyed/unkey/models/operations" + "github.com/unkeyed/unkey-go/models/components" + unkeygo "github.com/unkeyed/unkey-go" + "github.com/unkeyed/unkey-go/models/operations" "context" "log" ) func main() { - s := unkey.New( - unkey.WithSecurity(""), + s := unkeygo.New( + unkeygo.WithSecurity(""), ) request := operations.DeleteKeyRequestBody{ @@ -133,23 +133,23 @@ func main() { package main import( - "github.com/unkeyed/unkey/models/components" - "github.com/unkeyed/unkey" - "github.com/unkeyed/unkey/models/operations" + "github.com/unkeyed/unkey-go/models/components" + unkeygo "github.com/unkeyed/unkey-go" + "github.com/unkeyed/unkey-go/models/operations" "context" "log" ) func main() { - s := unkey.New( - unkey.WithSecurity(""), + s := unkeygo.New( + unkeygo.WithSecurity(""), ) request := operations.CreateKeyRequestBody{ APIID: "api_123", - Name: unkey.String("my key"), - OwnerID: unkey.String("team_123"), - Meta: map[string]interface{}{ + Name: unkeygo.String("my key"), + OwnerID: unkeygo.String("team_123"), + Meta: map[string]any{ "billingTier": "PRO", "trialEnds": "2023-06-16T17:16:37.161Z", }, @@ -157,8 +157,8 @@ func main() { "admin", "finance", }, - Expires: unkey.Int64(1623869797161), - Remaining: unkey.Int64(1000), + Expires: unkeygo.Int64(1623869797161), + Remaining: unkeygo.Int64(1000), Refill: &operations.Refill{ Interval: operations.IntervalDaily, Amount: 100, @@ -169,7 +169,7 @@ func main() { RefillRate: 1, RefillInterval: 60, }, - Enabled: unkey.Bool(false), + Enabled: unkeygo.Bool(false), } ctx := context.Background() @@ -213,19 +213,19 @@ func main() { package main import( - "github.com/unkeyed/unkey/models/components" - "github.com/unkeyed/unkey" + "github.com/unkeyed/unkey-go/models/components" + unkeygo "github.com/unkeyed/unkey-go" "context" "log" ) func main() { - s := unkey.New( - unkey.WithSecurity(""), + s := unkeygo.New( + unkeygo.WithSecurity(""), ) request := components.V1KeysVerifyKeyRequest{ - APIID: unkey.String("api_1234"), + APIID: unkeygo.String("api_1234"), Key: "sk_1234", Authorization: &components.Authorization{ Permissions: &components.Permissions{}, @@ -273,39 +273,42 @@ func main() { package main import( - "github.com/unkeyed/unkey/models/components" - "github.com/unkeyed/unkey" - "github.com/unkeyed/unkey/models/operations" + "github.com/unkeyed/unkey-go/models/components" + unkeygo "github.com/unkeyed/unkey-go" + "github.com/unkeyed/unkey-go/models/operations" "context" "log" ) func main() { - s := unkey.New( - unkey.WithSecurity(""), + s := unkeygo.New( + unkeygo.WithSecurity(""), ) request := operations.UpdateKeyRequestBody{ KeyID: "key_123", - Name: unkey.String("Customer X"), - OwnerID: unkey.String("user_123"), - Meta: map[string]interface{}{ - "roles": "", + Name: unkeygo.String("Customer X"), + OwnerID: unkeygo.String("user_123"), + Meta: map[string]any{ + "roles": []any{ + "admin", + "user", + }, "stripeCustomerId": "cus_1234", }, - Expires: unkey.Float64(0), + Expires: unkeygo.Float64(0), Ratelimit: &operations.UpdateKeyRatelimit{ Type: operations.UpdateKeyTypeFast, Limit: 10, RefillRate: 1, RefillInterval: 60, }, - Remaining: unkey.Float64(1000), + Remaining: unkeygo.Float64(1000), Refill: &operations.UpdateKeyRefill{ Interval: operations.UpdateKeyIntervalDaily, Amount: 100, }, - Enabled: unkey.Bool(true), + Enabled: unkeygo.Bool(true), } ctx := context.Background() @@ -349,22 +352,22 @@ func main() { package main import( - "github.com/unkeyed/unkey/models/components" - "github.com/unkeyed/unkey" - "github.com/unkeyed/unkey/models/operations" + "github.com/unkeyed/unkey-go/models/components" + unkeygo "github.com/unkeyed/unkey-go" + "github.com/unkeyed/unkey-go/models/operations" "context" "log" ) func main() { - s := unkey.New( - unkey.WithSecurity(""), + s := unkeygo.New( + unkeygo.WithSecurity(""), ) request := operations.UpdateRemainingRequestBody{ KeyID: "key_123", Op: operations.OpSet, - Value: unkey.Int64(1), + Value: unkeygo.Int64(1), } ctx := context.Background() @@ -408,23 +411,23 @@ func main() { package main import( - "github.com/unkeyed/unkey/models/components" - "github.com/unkeyed/unkey" - "github.com/unkeyed/unkey/models/operations" + "github.com/unkeyed/unkey-go/models/components" + unkeygo "github.com/unkeyed/unkey-go" + "github.com/unkeyed/unkey-go/models/operations" "context" "log" ) func main() { - s := unkey.New( - unkey.WithSecurity(""), + s := unkeygo.New( + unkeygo.WithSecurity(""), ) request := operations.GetVerificationsRequest{ - KeyID: unkey.String("key_1234"), - OwnerID: unkey.String("chronark"), - Start: unkey.Int64(1620000000000), - End: unkey.Int64(1620000000000), + KeyID: unkeygo.String("key_1234"), + OwnerID: unkeygo.String("chronark"), + Start: unkeygo.Int64(1620000000000), + End: unkeygo.Int64(1620000000000), Granularity: operations.GranularityDay.ToPointer(), } diff --git a/docs/sdks/liveness/README.md b/docs/sdks/liveness/README.md index 0f3903a..1af45b5 100644 --- a/docs/sdks/liveness/README.md +++ b/docs/sdks/liveness/README.md @@ -13,15 +13,15 @@ package main import( - "github.com/unkeyed/unkey/models/components" - "github.com/unkeyed/unkey" + "github.com/unkeyed/unkey-go/models/components" + unkeygo "github.com/unkeyed/unkey-go" "context" "log" ) func main() { - s := unkey.New( - unkey.WithSecurity(""), + s := unkeygo.New( + unkeygo.WithSecurity(""), ) diff --git a/docs/sdks/migrations/README.md b/docs/sdks/migrations/README.md index d5caa29..c0846dd 100644 --- a/docs/sdks/migrations/README.md +++ b/docs/sdks/migrations/README.md @@ -13,29 +13,29 @@ package main import( - "github.com/unkeyed/unkey/models/components" - "github.com/unkeyed/unkey" - "github.com/unkeyed/unkey/models/operations" + "github.com/unkeyed/unkey-go/models/components" + unkeygo "github.com/unkeyed/unkey-go" + "github.com/unkeyed/unkey-go/models/operations" "context" "log" ) func main() { - s := unkey.New( - unkey.WithSecurity(""), + s := unkeygo.New( + unkeygo.WithSecurity(""), ) request := []operations.RequestBody{ operations.RequestBody{ APIID: "api_123", - Name: unkey.String("my key"), + Name: unkeygo.String("my key"), Hash: operations.Hash{ Value: "", Variant: operations.VariantSha256Base64, }, - Start: unkey.String("unkey_32kq"), - OwnerID: unkey.String("team_123"), - Meta: map[string]interface{}{ + Start: unkeygo.String("unkey_32kq"), + OwnerID: unkeygo.String("team_123"), + Meta: map[string]any{ "billingTier": "PRO", "trialEnds": "2023-06-16T17:16:37.161Z", }, @@ -43,8 +43,8 @@ func main() { "admin", "finance", }, - Expires: unkey.Int64(1623869797161), - Remaining: unkey.Int64(1000), + Expires: unkeygo.Int64(1623869797161), + Remaining: unkeygo.Int64(1000), Refill: &operations.V1MigrationsCreateKeysRefill{ Interval: operations.V1MigrationsCreateKeysIntervalDaily, Amount: 100, @@ -55,7 +55,7 @@ func main() { RefillRate: 1, RefillInterval: 60, }, - Enabled: unkey.Bool(false), + Enabled: unkeygo.Bool(false), }, } diff --git a/docs/sdks/ratelimits/README.md b/docs/sdks/ratelimits/README.md index c491c72..17987db 100644 --- a/docs/sdks/ratelimits/README.md +++ b/docs/sdks/ratelimits/README.md @@ -13,29 +13,29 @@ package main import( - "github.com/unkeyed/unkey/models/components" - "github.com/unkeyed/unkey" - "github.com/unkeyed/unkey/models/operations" + "github.com/unkeyed/unkey-go/models/components" + unkeygo "github.com/unkeyed/unkey-go" + "github.com/unkeyed/unkey-go/models/operations" "context" "log" ) func main() { - s := unkey.New( - unkey.WithSecurity(""), + s := unkeygo.New( + unkeygo.WithSecurity(""), ) request := operations.LimitRequestBody{ - Namespace: unkey.String("email.outbound"), + Namespace: unkeygo.String("email.outbound"), Identifier: "user_123", Limit: 10, Duration: 60000, - Cost: unkey.Int64(2), + Cost: unkeygo.Int64(2), Resources: []operations.Resources{ operations.Resources{ Type: "project", ID: "p_123", - Name: unkey.String("dub"), + Name: unkeygo.String("dub"), }, }, } diff --git a/docs/sdks/unkey/README.md b/docs/sdks/unkey/README.md index 0210cec..0750afb 100644 --- a/docs/sdks/unkey/README.md +++ b/docs/sdks/unkey/README.md @@ -7,9 +7,6 @@ * [CreateAPI](#createapi) * [DeleteAPI](#deleteapi) -* [DeprecatedCreateKey](#deprecatedcreatekey) -* [~~DeprecatedVerifyKey~~](#deprecatedverifykey) - :warning: **Deprecated** -* [DeprecatedListKeys](#deprecatedlistkeys) ## CreateAPI @@ -19,16 +16,16 @@ package main import( - "github.com/unkeyed/unkey/models/components" - "github.com/unkeyed/unkey" - "github.com/unkeyed/unkey/models/operations" + "github.com/unkeyed/unkey-go/models/components" + unkeygo "github.com/unkeyed/unkey-go" + "github.com/unkeyed/unkey-go/models/operations" "context" "log" ) func main() { - s := unkey.New( - unkey.WithSecurity(""), + s := unkeygo.New( + unkeygo.WithSecurity(""), ) request := operations.CreateAPIRequestBody{ @@ -76,16 +73,16 @@ func main() { package main import( - "github.com/unkeyed/unkey/models/components" - "github.com/unkeyed/unkey" - "github.com/unkeyed/unkey/models/operations" + "github.com/unkeyed/unkey-go/models/components" + unkeygo "github.com/unkeyed/unkey-go" + "github.com/unkeyed/unkey-go/models/operations" "context" "log" ) func main() { - s := unkey.New( - unkey.WithSecurity(""), + s := unkeygo.New( + unkeygo.WithSecurity(""), ) request := operations.DeleteAPIRequestBody{ @@ -124,192 +121,3 @@ func main() { | sdkerrors.ErrTooManyRequests | 429 | application/json | | sdkerrors.ErrInternalServerError | 500 | application/json | | sdkerrors.SDKError | 4xx-5xx | */* | - -## DeprecatedCreateKey - -### Example Usage - -```go -package main - -import( - "github.com/unkeyed/unkey/models/components" - "github.com/unkeyed/unkey" - "github.com/unkeyed/unkey/models/operations" - "context" - "log" -) - -func main() { - s := unkey.New( - unkey.WithSecurity(""), - ) - - request := operations.DeprecatedCreateKeyRequestBody{ - APIID: "api_123", - Name: unkey.String("my key"), - OwnerID: unkey.String("team_123"), - Meta: map[string]interface{}{ - "billingTier": "PRO", - "trialEnds": "2023-06-16T17:16:37.161Z", - }, - Expires: unkey.Int64(1623869797161), - Remaining: unkey.Int64(1000), - Ratelimit: &operations.DeprecatedCreateKeyRatelimit{ - Type: operations.DeprecatedCreateKeyTypeFast.ToPointer(), - Limit: 10, - RefillRate: 1, - RefillInterval: 60, - }, - } - - ctx := context.Background() - res, err := s.DeprecatedCreateKey(ctx, request) - if err != nil { - log.Fatal(err) - } - if res != 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.DeprecatedCreateKeyRequestBody](../../models/operations/deprecatedcreatekeyrequestbody.md) | :heavy_check_mark: | The request object to use for the request. | - - -### Response - -**[*operations.DeprecatedCreateKeyResponseBody](../../models/operations/deprecatedcreatekeyresponsebody.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 | */* | - -## ~~DeprecatedVerifyKey~~ - -> :warning: **DEPRECATED**: This will be removed in a future release, please migrate away from it as soon as possible. - -### Example Usage - -```go -package main - -import( - "github.com/unkeyed/unkey/models/components" - "github.com/unkeyed/unkey" - "github.com/unkeyed/unkey/models/operations" - "context" - "log" -) - -func main() { - s := unkey.New( - unkey.WithSecurity(""), - ) - - request := operations.DeprecatedVerifyKeyRequestBody{ - APIID: unkey.String("api_1234"), - Key: "sk_1234", - } - - ctx := context.Background() - res, err := s.DeprecatedVerifyKey(ctx, request) - if err != nil { - log.Fatal(err) - } - if res != 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.DeprecatedVerifyKeyRequestBody](../../models/operations/deprecatedverifykeyrequestbody.md) | :heavy_check_mark: | The request object to use for the request. | - - -### Response - -**[*operations.DeprecatedVerifyKeyResponseBody](../../models/operations/deprecatedverifykeyresponsebody.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 | */* | - -## DeprecatedListKeys - -### Example Usage - -```go -package main - -import( - "github.com/unkeyed/unkey/models/components" - "github.com/unkeyed/unkey" - "github.com/unkeyed/unkey/models/operations" - "context" - "log" -) - -func main() { - s := unkey.New( - unkey.WithSecurity(""), - ) - - request := operations.DeprecatedListKeysRequest{ - APIID: "api_1234", - Limit: unkey.Int64(100), - } - - ctx := context.Background() - res, err := s.DeprecatedListKeys(ctx, request) - if err != nil { - log.Fatal(err) - } - if res != 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.DeprecatedListKeysRequest](../../models/operations/deprecatedlistkeysrequest.md) | :heavy_check_mark: | The request object to use for the request. | - - -### Response - -**[*operations.DeprecatedListKeysResponseBody](../../models/operations/deprecatedlistkeysresponsebody.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 | */* | diff --git a/go.mod b/go.mod index 423a560..ee5e9bf 100644 --- a/go.mod +++ b/go.mod @@ -1,4 +1,4 @@ -module github.com/unkeyed/unkey +module github.com/unkeyed/unkey-go go 1.20 diff --git a/internal/utils/form.go b/internal/utils/form.go index 646346f..da69a53 100644 --- a/internal/utils/form.go +++ b/internal/utils/form.go @@ -12,7 +12,7 @@ import ( "github.com/ericlagergren/decimal" - "github.com/unkeyed/unkey/types" + "github.com/unkeyed/unkey-go/types" ) func populateForm(paramName string, explode bool, objType reflect.Type, objValue reflect.Value, delimiter string, getFieldName func(reflect.StructField) string) url.Values { diff --git a/internal/utils/json.go b/internal/utils/json.go index 3724aa0..9aac25a 100644 --- a/internal/utils/json.go +++ b/internal/utils/json.go @@ -13,7 +13,7 @@ import ( "time" "unsafe" - "github.com/unkeyed/unkey/types" + "github.com/unkeyed/unkey-go/types" "github.com/ericlagergren/decimal" ) diff --git a/internal/utils/pathparams.go b/internal/utils/pathparams.go index 563f054..78f6f11 100644 --- a/internal/utils/pathparams.go +++ b/internal/utils/pathparams.go @@ -13,7 +13,7 @@ import ( "github.com/ericlagergren/decimal" - "github.com/unkeyed/unkey/types" + "github.com/unkeyed/unkey-go/types" ) func GenerateURL(_ context.Context, serverURL, path string, pathParams interface{}, globals interface{}) (string, error) { diff --git a/keys.go b/keys.go index 9cf092c..d3bee0b 100644 --- a/keys.go +++ b/keys.go @@ -1,16 +1,16 @@ // Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. -package unkey +package unkeygo import ( "bytes" "context" "fmt" - "github.com/unkeyed/unkey/internal/hooks" - "github.com/unkeyed/unkey/internal/utils" - "github.com/unkeyed/unkey/models/components" - "github.com/unkeyed/unkey/models/operations" - "github.com/unkeyed/unkey/models/sdkerrors" + "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" "net/http" "net/url" diff --git a/liveness.go b/liveness.go index c703194..3849830 100644 --- a/liveness.go +++ b/liveness.go @@ -1,15 +1,15 @@ // Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. -package unkey +package unkeygo import ( "bytes" "context" "fmt" - "github.com/unkeyed/unkey/internal/hooks" - "github.com/unkeyed/unkey/internal/utils" - "github.com/unkeyed/unkey/models/operations" - "github.com/unkeyed/unkey/models/sdkerrors" + "github.com/unkeyed/unkey-go/internal/hooks" + "github.com/unkeyed/unkey-go/internal/utils" + "github.com/unkeyed/unkey-go/models/operations" + "github.com/unkeyed/unkey-go/models/sdkerrors" "io" "net/http" "net/url" diff --git a/migrations.go b/migrations.go index b03d4e9..1a0709e 100644 --- a/migrations.go +++ b/migrations.go @@ -1,15 +1,15 @@ // Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. -package unkey +package unkeygo import ( "bytes" "context" "fmt" - "github.com/unkeyed/unkey/internal/hooks" - "github.com/unkeyed/unkey/internal/utils" - "github.com/unkeyed/unkey/models/operations" - "github.com/unkeyed/unkey/models/sdkerrors" + "github.com/unkeyed/unkey-go/internal/hooks" + "github.com/unkeyed/unkey-go/internal/utils" + "github.com/unkeyed/unkey-go/models/operations" + "github.com/unkeyed/unkey-go/models/sdkerrors" "io" "net/http" "net/url" diff --git a/models/components/key.go b/models/components/key.go index 403270a..d0f8b73 100644 --- a/models/components/key.go +++ b/models/components/key.go @@ -5,7 +5,7 @@ package components import ( "encoding/json" "fmt" - "github.com/unkeyed/unkey/internal/utils" + "github.com/unkeyed/unkey-go/internal/utils" ) // Interval - Determines the rate at which verifications will be refilled. @@ -162,7 +162,7 @@ type Key struct { // 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. OwnerID *string `json:"ownerId,omitempty"` // Any additional metadata you want to store with the key - Meta map[string]interface{} `json:"meta,omitempty"` + Meta map[string]any `json:"meta,omitempty"` // The unix timestamp in milliseconds when the key was created CreatedAt *float64 `json:"createdAt,omitempty"` // The unix timestamp in milliseconds when the key was deleted. We don't delete the key outright, you can restore it later. @@ -225,7 +225,7 @@ func (o *Key) GetOwnerID() *string { return o.OwnerID } -func (o *Key) GetMeta() map[string]interface{} { +func (o *Key) GetMeta() map[string]any { if o == nil { return nil } diff --git a/models/components/v1keysverifykeyrequest.go b/models/components/v1keysverifykeyrequest.go index e4b6b5a..dcbf9de 100644 --- a/models/components/v1keysverifykeyrequest.go +++ b/models/components/v1keysverifykeyrequest.go @@ -3,7 +3,7 @@ package components import ( - "github.com/unkeyed/unkey/internal/utils" + "github.com/unkeyed/unkey-go/internal/utils" ) // Permissions - A query for which permissions you require diff --git a/models/components/v1keysverifykeyresponse.go b/models/components/v1keysverifykeyresponse.go index 7aba39a..4636e72 100644 --- a/models/components/v1keysverifykeyresponse.go +++ b/models/components/v1keysverifykeyresponse.go @@ -104,7 +104,7 @@ type V1KeysVerifyKeyResponse struct { // 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. OwnerID *string `json:"ownerId,omitempty"` // Any additional metadata you want to store with the key - Meta map[string]interface{} `json:"meta,omitempty"` + Meta map[string]any `json:"meta,omitempty"` // The unix timestamp in milliseconds when the key will expire. If this field is null or undefined, the key is not expiring. Expires *float64 `json:"expires,omitempty"` // The ratelimit configuration for this key. If this field is null or undefined, the key has no ratelimit. @@ -159,7 +159,7 @@ func (o *V1KeysVerifyKeyResponse) GetOwnerID() *string { return o.OwnerID } -func (o *V1KeysVerifyKeyResponse) GetMeta() map[string]interface{} { +func (o *V1KeysVerifyKeyResponse) GetMeta() map[string]any { if o == nil { return nil } diff --git a/models/operations/createkey.go b/models/operations/createkey.go index e6ad4a7..90ba122 100644 --- a/models/operations/createkey.go +++ b/models/operations/createkey.go @@ -5,7 +5,7 @@ package operations import ( "encoding/json" "fmt" - "github.com/unkeyed/unkey/internal/utils" + "github.com/unkeyed/unkey-go/internal/utils" ) // Interval - Unkey will automatically refill verifications at the set interval. @@ -157,7 +157,7 @@ type CreateKeyRequestBody struct { // 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"` // This is a place for dynamic meta data, anything that feels useful for you should go here - Meta map[string]interface{} `json:"meta,omitempty"` + Meta map[string]any `json:"meta,omitempty"` // A list of roles that this key should have. If the role does not exist, an error is thrown Roles []string `json:"roles,omitempty"` // 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. @@ -228,7 +228,7 @@ func (o *CreateKeyRequestBody) GetOwnerID() *string { return o.OwnerID } -func (o *CreateKeyRequestBody) GetMeta() map[string]interface{} { +func (o *CreateKeyRequestBody) GetMeta() map[string]any { if o == nil { return nil } diff --git a/models/operations/deprecatedcreatekey.go b/models/operations/deprecatedcreatekey.go deleted file mode 100644 index 4ffeb9f..0000000 --- a/models/operations/deprecatedcreatekey.go +++ /dev/null @@ -1,213 +0,0 @@ -// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. - -package operations - -import ( - "encoding/json" - "fmt" - "github.com/unkeyed/unkey/internal/utils" -) - -// DeprecatedCreateKeyType - Fast ratelimiting doesn't add latency, while consistent ratelimiting is more accurate. -// -// https://unkey.dev/docs/features/ratelimiting - Learn more -type DeprecatedCreateKeyType string - -const ( - DeprecatedCreateKeyTypeFast DeprecatedCreateKeyType = "fast" - DeprecatedCreateKeyTypeConsistent DeprecatedCreateKeyType = "consistent" -) - -func (e DeprecatedCreateKeyType) ToPointer() *DeprecatedCreateKeyType { - return &e -} - -func (e *DeprecatedCreateKeyType) UnmarshalJSON(data []byte) error { - var v string - if err := json.Unmarshal(data, &v); err != nil { - return err - } - switch v { - case "fast": - fallthrough - case "consistent": - *e = DeprecatedCreateKeyType(v) - return nil - default: - return fmt.Errorf("invalid value for DeprecatedCreateKeyType: %v", v) - } -} - -// DeprecatedCreateKeyRatelimit - Unkey comes with per-key ratelimiting out of the box. -type DeprecatedCreateKeyRatelimit struct { - // Fast ratelimiting doesn't add latency, while consistent ratelimiting is more accurate. - Type *DeprecatedCreateKeyType `default:"fast" json:"type"` - // The total amount of burstable requests. - Limit int64 `json:"limit"` - // 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"` -} - -func (d DeprecatedCreateKeyRatelimit) MarshalJSON() ([]byte, error) { - return utils.MarshalJSON(d, "", false) -} - -func (d *DeprecatedCreateKeyRatelimit) UnmarshalJSON(data []byte) error { - if err := utils.UnmarshalJSON(data, &d, "", false, false); err != nil { - return err - } - return nil -} - -func (o *DeprecatedCreateKeyRatelimit) GetType() *DeprecatedCreateKeyType { - if o == nil { - return nil - } - return o.Type -} - -func (o *DeprecatedCreateKeyRatelimit) GetLimit() int64 { - if o == nil { - return 0 - } - return o.Limit -} - -func (o *DeprecatedCreateKeyRatelimit) GetRefillRate() int64 { - if o == nil { - return 0 - } - return o.RefillRate -} - -func (o *DeprecatedCreateKeyRatelimit) GetRefillInterval() int64 { - if o == nil { - return 0 - } - return o.RefillInterval -} - -type DeprecatedCreateKeyRequestBody struct { - // Choose an `API` where this key should be created. - APIID string `json:"apiId"` - // 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 - // - Prefix *string `json:"prefix,omitempty"` - // The name for your Key. This is not customer facing. - Name *string `json:"name,omitempty"` - // 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. - ByteLength *int64 `default:"16" json:"byteLength"` - // 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"` - // This is a place for dynamic meta data, anything that feels useful for you should go here - Meta map[string]interface{} `json:"meta,omitempty"` - // 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. - Expires *int64 `json:"expires,omitempty"` - // 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. - Remaining *int64 `json:"remaining,omitempty"` - // Unkey comes with per-key ratelimiting out of the box. - Ratelimit *DeprecatedCreateKeyRatelimit `json:"ratelimit,omitempty"` -} - -func (d DeprecatedCreateKeyRequestBody) MarshalJSON() ([]byte, error) { - return utils.MarshalJSON(d, "", false) -} - -func (d *DeprecatedCreateKeyRequestBody) UnmarshalJSON(data []byte) error { - if err := utils.UnmarshalJSON(data, &d, "", false, false); err != nil { - return err - } - return nil -} - -func (o *DeprecatedCreateKeyRequestBody) GetAPIID() string { - if o == nil { - return "" - } - return o.APIID -} - -func (o *DeprecatedCreateKeyRequestBody) GetPrefix() *string { - if o == nil { - return nil - } - return o.Prefix -} - -func (o *DeprecatedCreateKeyRequestBody) GetName() *string { - if o == nil { - return nil - } - return o.Name -} - -func (o *DeprecatedCreateKeyRequestBody) GetByteLength() *int64 { - if o == nil { - return nil - } - return o.ByteLength -} - -func (o *DeprecatedCreateKeyRequestBody) GetOwnerID() *string { - if o == nil { - return nil - } - return o.OwnerID -} - -func (o *DeprecatedCreateKeyRequestBody) GetMeta() map[string]interface{} { - if o == nil { - return nil - } - return o.Meta -} - -func (o *DeprecatedCreateKeyRequestBody) GetExpires() *int64 { - if o == nil { - return nil - } - return o.Expires -} - -func (o *DeprecatedCreateKeyRequestBody) GetRemaining() *int64 { - if o == nil { - return nil - } - return o.Remaining -} - -func (o *DeprecatedCreateKeyRequestBody) GetRatelimit() *DeprecatedCreateKeyRatelimit { - if o == nil { - return nil - } - return o.Ratelimit -} - -// DeprecatedCreateKeyResponseBody - The configuration for an api -type DeprecatedCreateKeyResponseBody struct { - // The id of the key. This is not a secret and can be stored as a reference if you wish. You need the keyId to update or delete a key later. - KeyID string `json:"keyId"` - // The newly created api key, do not store this on your own system but pass it along to your user. - Key string `json:"key"` -} - -func (o *DeprecatedCreateKeyResponseBody) GetKeyID() string { - if o == nil { - return "" - } - return o.KeyID -} - -func (o *DeprecatedCreateKeyResponseBody) GetKey() string { - if o == nil { - return "" - } - return o.Key -} diff --git a/models/operations/deprecatedlistkeys.go b/models/operations/deprecatedlistkeys.go deleted file mode 100644 index 6d33582..0000000 --- a/models/operations/deprecatedlistkeys.go +++ /dev/null @@ -1,75 +0,0 @@ -// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. - -package operations - -import ( - "github.com/unkeyed/unkey/internal/utils" - "github.com/unkeyed/unkey/models/components" -) - -type DeprecatedListKeysRequest struct { - APIID string `pathParam:"style=simple,explode=false,name=apiId"` - Limit *int64 `default:"100" queryParam:"style=form,explode=true,name=limit"` - Offset *float64 `queryParam:"style=form,explode=true,name=offset"` - OwnerID *string `queryParam:"style=form,explode=true,name=ownerId"` -} - -func (d DeprecatedListKeysRequest) MarshalJSON() ([]byte, error) { - return utils.MarshalJSON(d, "", false) -} - -func (d *DeprecatedListKeysRequest) UnmarshalJSON(data []byte) error { - if err := utils.UnmarshalJSON(data, &d, "", false, false); err != nil { - return err - } - return nil -} - -func (o *DeprecatedListKeysRequest) GetAPIID() string { - if o == nil { - return "" - } - return o.APIID -} - -func (o *DeprecatedListKeysRequest) GetLimit() *int64 { - if o == nil { - return nil - } - return o.Limit -} - -func (o *DeprecatedListKeysRequest) GetOffset() *float64 { - if o == nil { - return nil - } - return o.Offset -} - -func (o *DeprecatedListKeysRequest) GetOwnerID() *string { - if o == nil { - return nil - } - return o.OwnerID -} - -// DeprecatedListKeysResponseBody - Keys belonging to the api -type DeprecatedListKeysResponseBody struct { - Keys []components.Key `json:"keys"` - // The total number of keys for this api - Total int64 `json:"total"` -} - -func (o *DeprecatedListKeysResponseBody) GetKeys() []components.Key { - if o == nil { - return []components.Key{} - } - return o.Keys -} - -func (o *DeprecatedListKeysResponseBody) GetTotal() int64 { - if o == nil { - return 0 - } - return o.Total -} diff --git a/models/operations/deprecatedverifykey.go b/models/operations/deprecatedverifykey.go deleted file mode 100644 index caa61d1..0000000 --- a/models/operations/deprecatedverifykey.go +++ /dev/null @@ -1,221 +0,0 @@ -// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. - -package operations - -import ( - "encoding/json" - "fmt" -) - -type DeprecatedVerifyKeyRequestBody struct { - // The id of the api where the key belongs to. This is optional for now but will be required soon. - // The key will be verified against the api's configuration. If the key does not belong to the api, the verification will fail. - APIID *string `json:"apiId,omitempty"` - // The key to verify - Key string `json:"key"` -} - -func (o *DeprecatedVerifyKeyRequestBody) GetAPIID() *string { - if o == nil { - return nil - } - return o.APIID -} - -func (o *DeprecatedVerifyKeyRequestBody) GetKey() string { - if o == nil { - return "" - } - return o.Key -} - -// DeprecatedVerifyKeyRatelimit - The ratelimit configuration for this key. If this field is null or undefined, the key has no ratelimit. -type DeprecatedVerifyKeyRatelimit struct { - // Maximum number of requests that can be made inside a window - Limit float64 `json:"limit"` - // Remaining requests after this verification - Remaining float64 `json:"remaining"` - // Unix timestamp in milliseconds when the ratelimit will reset - Reset float64 `json:"reset"` -} - -func (o *DeprecatedVerifyKeyRatelimit) GetLimit() float64 { - if o == nil { - return 0.0 - } - return o.Limit -} - -func (o *DeprecatedVerifyKeyRatelimit) GetRemaining() float64 { - if o == nil { - return 0.0 - } - return o.Remaining -} - -func (o *DeprecatedVerifyKeyRatelimit) GetReset() float64 { - if o == nil { - return 0.0 - } - return o.Reset -} - -// Code - If the key is invalid this field will be set to the reason why it is invalid. -// Possible values are: -// - NOT_FOUND: the key does not exist or has expired -// - FORBIDDEN: the key is not allowed to access the api -// - USAGE_EXCEEDED: the key has exceeded its request limit -// - RATE_LIMITED: the key has been ratelimited, -// - INSUFFICIENT_PERMISSIONS: you do not have the required permissions to perform this action -type Code string - -const ( - CodeNotFound Code = "NOT_FOUND" - CodeForbidden Code = "FORBIDDEN" - CodeUsageExceeded Code = "USAGE_EXCEEDED" - CodeRateLimited Code = "RATE_LIMITED" - CodeUnauthorized Code = "UNAUTHORIZED" - CodeDisabled Code = "DISABLED" - CodeInsufficientPermissions Code = "INSUFFICIENT_PERMISSIONS" -) - -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 { - return err - } - switch v { - case "NOT_FOUND": - fallthrough - case "FORBIDDEN": - fallthrough - case "USAGE_EXCEEDED": - fallthrough - case "RATE_LIMITED": - fallthrough - case "UNAUTHORIZED": - fallthrough - case "DISABLED": - fallthrough - case "INSUFFICIENT_PERMISSIONS": - *e = Code(v) - return nil - default: - return fmt.Errorf("invalid value for Code: %v", v) - } -} - -// DeprecatedVerifyKeyResponseBody - The verification result -type DeprecatedVerifyKeyResponseBody struct { - // The id of the key - KeyID *string `json:"keyId,omitempty"` - // Whether the key is valid or not. - // A key could be invalid for a number of reasons, for example if it has expired, has no more verifications left or if it has been deleted. - Valid bool `json:"valid"` - // The name of the key, give keys a name to easily identifiy their purpose - Name *string `json:"name,omitempty"` - // 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. - OwnerID *string `json:"ownerId,omitempty"` - // Any additional metadata you want to store with the key - Meta map[string]interface{} `json:"meta,omitempty"` - // The unix timestamp in milliseconds when the key was created - CreatedAt *float64 `json:"createdAt,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. - Expires *float64 `json:"expires,omitempty"` - // The ratelimit configuration for this key. If this field is null or undefined, the key has no ratelimit. - Ratelimit *DeprecatedVerifyKeyRatelimit `json:"ratelimit,omitempty"` - // 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. - Remaining *float64 `json:"remaining,omitempty"` - // If the key is invalid this field will be set to the reason why it is invalid. - // Possible values are: - // - NOT_FOUND: the key does not exist or has expired - // - FORBIDDEN: the key is not allowed to access the api - // - USAGE_EXCEEDED: the key has exceeded its request limit - // - RATE_LIMITED: the key has been ratelimited, - // - INSUFFICIENT_PERMISSIONS: you do not have the required permissions to perform this action - // - Code *Code `json:"code,omitempty"` -} - -func (o *DeprecatedVerifyKeyResponseBody) GetKeyID() *string { - if o == nil { - return nil - } - return o.KeyID -} - -func (o *DeprecatedVerifyKeyResponseBody) GetValid() bool { - if o == nil { - return false - } - return o.Valid -} - -func (o *DeprecatedVerifyKeyResponseBody) GetName() *string { - if o == nil { - return nil - } - return o.Name -} - -func (o *DeprecatedVerifyKeyResponseBody) GetOwnerID() *string { - if o == nil { - return nil - } - return o.OwnerID -} - -func (o *DeprecatedVerifyKeyResponseBody) GetMeta() map[string]interface{} { - if o == nil { - return nil - } - return o.Meta -} - -func (o *DeprecatedVerifyKeyResponseBody) GetCreatedAt() *float64 { - if o == nil { - return nil - } - return o.CreatedAt -} - -func (o *DeprecatedVerifyKeyResponseBody) GetDeletedAt() *float64 { - if o == nil { - return nil - } - return o.DeletedAt -} - -func (o *DeprecatedVerifyKeyResponseBody) GetExpires() *float64 { - if o == nil { - return nil - } - return o.Expires -} - -func (o *DeprecatedVerifyKeyResponseBody) GetRatelimit() *DeprecatedVerifyKeyRatelimit { - if o == nil { - return nil - } - return o.Ratelimit -} - -func (o *DeprecatedVerifyKeyResponseBody) GetRemaining() *float64 { - if o == nil { - return nil - } - return o.Remaining -} - -func (o *DeprecatedVerifyKeyResponseBody) GetCode() *Code { - if o == nil { - return nil - } - return o.Code -} diff --git a/models/operations/getverifications.go b/models/operations/getverifications.go index 1fd093d..ba5a918 100644 --- a/models/operations/getverifications.go +++ b/models/operations/getverifications.go @@ -5,7 +5,7 @@ package operations import ( "encoding/json" "fmt" - "github.com/unkeyed/unkey/internal/utils" + "github.com/unkeyed/unkey-go/internal/utils" ) // Granularity - The granularity of the usage data to fetch, currently only `day` is supported diff --git a/models/operations/limit.go b/models/operations/limit.go index 32c8674..69a78e8 100644 --- a/models/operations/limit.go +++ b/models/operations/limit.go @@ -3,7 +3,7 @@ package operations import ( - "github.com/unkeyed/unkey/internal/utils" + "github.com/unkeyed/unkey-go/internal/utils" ) type Resources struct { @@ -14,7 +14,7 @@ type Resources struct { // A human readable name for this resource Name *string `json:"name,omitempty"` // Attach any metadata to this resources - Meta map[string]interface{} `json:"meta,omitempty"` + Meta map[string]any `json:"meta,omitempty"` } func (o *Resources) GetType() string { @@ -38,7 +38,7 @@ func (o *Resources) GetName() *string { return o.Name } -func (o *Resources) GetMeta() map[string]interface{} { +func (o *Resources) GetMeta() map[string]any { if o == nil { return nil } @@ -59,7 +59,7 @@ type LimitRequestBody struct { // Async will return a response immediately, lowering latency at the cost of accuracy. Async *bool `default:"false" json:"async"` // Attach any metadata to this request - Meta map[string]interface{} `json:"meta,omitempty"` + Meta map[string]any `json:"meta,omitempty"` // Resources that are about to be accessed by the user Resources []Resources `json:"resources,omitempty"` } @@ -117,7 +117,7 @@ func (o *LimitRequestBody) GetAsync() *bool { return o.Async } -func (o *LimitRequestBody) GetMeta() map[string]interface{} { +func (o *LimitRequestBody) GetMeta() map[string]any { if o == nil { return nil } diff --git a/models/operations/listkeys.go b/models/operations/listkeys.go index b2184d6..24a0d6b 100644 --- a/models/operations/listkeys.go +++ b/models/operations/listkeys.go @@ -3,8 +3,8 @@ package operations import ( - "github.com/unkeyed/unkey/internal/utils" - "github.com/unkeyed/unkey/models/components" + "github.com/unkeyed/unkey-go/internal/utils" + "github.com/unkeyed/unkey-go/models/components" ) type ListKeysRequest struct { diff --git a/models/operations/updatekey.go b/models/operations/updatekey.go index 39ea661..ea51280 100644 --- a/models/operations/updatekey.go +++ b/models/operations/updatekey.go @@ -135,7 +135,7 @@ type UpdateKeyRequestBody struct { // 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. OwnerID *string `json:"ownerId,omitempty"` // Any additional metadata you want to store with the key - Meta map[string]interface{} `json:"meta,omitempty"` + Meta map[string]any `json:"meta,omitempty"` // The unix timestamp in milliseconds when the key will expire. If this field is null or undefined, the key is not expiring. Expires *float64 `json:"expires,omitempty"` // Unkey comes with per-key ratelimiting out of the box. Set `null` to disable. @@ -169,7 +169,7 @@ func (o *UpdateKeyRequestBody) GetOwnerID() *string { return o.OwnerID } -func (o *UpdateKeyRequestBody) GetMeta() map[string]interface{} { +func (o *UpdateKeyRequestBody) GetMeta() map[string]any { if o == nil { return nil } diff --git a/models/operations/v1migrationscreatekeys.go b/models/operations/v1migrationscreatekeys.go index efd6378..4eafdec 100644 --- a/models/operations/v1migrationscreatekeys.go +++ b/models/operations/v1migrationscreatekeys.go @@ -5,7 +5,7 @@ package operations import ( "encoding/json" "fmt" - "github.com/unkeyed/unkey/internal/utils" + "github.com/unkeyed/unkey-go/internal/utils" ) // Variant - The algorithm for hashing and encoding, currently only sha256 and base64 are supported @@ -204,7 +204,7 @@ type RequestBody struct { // 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"` // This is a place for dynamic meta data, anything that feels useful for you should go here - Meta map[string]interface{} `json:"meta,omitempty"` + Meta map[string]any `json:"meta,omitempty"` // A list of roles that this key should have. If the role does not exist, an error is thrown Roles []string `json:"roles,omitempty"` // 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. @@ -282,7 +282,7 @@ func (o *RequestBody) GetOwnerID() *string { return o.OwnerID } -func (o *RequestBody) GetMeta() map[string]interface{} { +func (o *RequestBody) GetMeta() map[string]any { if o == nil { return nil } diff --git a/ratelimits.go b/ratelimits.go index d393f08..71cd4d3 100644 --- a/ratelimits.go +++ b/ratelimits.go @@ -1,15 +1,15 @@ // Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. -package unkey +package unkeygo import ( "bytes" "context" "fmt" - "github.com/unkeyed/unkey/internal/hooks" - "github.com/unkeyed/unkey/internal/utils" - "github.com/unkeyed/unkey/models/operations" - "github.com/unkeyed/unkey/models/sdkerrors" + "github.com/unkeyed/unkey-go/internal/hooks" + "github.com/unkeyed/unkey-go/internal/utils" + "github.com/unkeyed/unkey-go/models/operations" + "github.com/unkeyed/unkey-go/models/sdkerrors" "io" "net/http" "net/url" diff --git a/unkey.go b/unkey.go index 5b2458b..c664086 100644 --- a/unkey.go +++ b/unkey.go @@ -1,16 +1,16 @@ // Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. -package unkey +package unkeygo import ( "bytes" "context" "fmt" - "github.com/unkeyed/unkey/internal/hooks" - "github.com/unkeyed/unkey/internal/utils" - "github.com/unkeyed/unkey/models/components" - "github.com/unkeyed/unkey/models/operations" - "github.com/unkeyed/unkey/models/sdkerrors" + "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" "net/http" "net/url" @@ -151,9 +151,9 @@ func New(opts ...SDKOption) *Unkey { sdkConfiguration: sdkConfiguration{ Language: "go", OpenAPIDocVersion: "1.0.0", - SDKVersion: "0.1.9", - GenVersion: "2.326.3", - UserAgent: "speakeasy-sdk/go 0.1.9 2.326.3 1.0.0 github.com/unkeyed/unkey", + 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", Hooks: hooks.New(), }, } @@ -531,523 +531,3 @@ func (s *Unkey) DeleteAPI(ctx context.Context, request operations.DeleteAPIReque return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) } } - -func (s *Unkey) DeprecatedCreateKey(ctx context.Context, request operations.DeprecatedCreateKeyRequestBody) (*operations.DeprecatedCreateKeyResponseBody, error) { - hookCtx := hooks.HookContext{ - Context: ctx, - OperationID: "deprecated.createKey", - OAuth2Scopes: []string{}, - SecuritySource: s.sdkConfiguration.Security, - } - - baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) - opURL, err := url.JoinPath(baseURL, "/v1/keys") - 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 - } - } - - 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.DeprecatedCreateKeyResponseBody - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - return &out, nil - 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) - } -} - -// DeprecatedVerifyKey -// -// Deprecated method: This will be removed in a future release, please migrate away from it as soon as possible. -func (s *Unkey) DeprecatedVerifyKey(ctx context.Context, request operations.DeprecatedVerifyKeyRequestBody) (*operations.DeprecatedVerifyKeyResponseBody, error) { - hookCtx := hooks.HookContext{ - Context: ctx, - OperationID: "deprecated.verifyKey", - OAuth2Scopes: []string{}, - SecuritySource: s.sdkConfiguration.Security, - } - - baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) - opURL, err := url.JoinPath(baseURL, "/v1/keys/verify") - 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 - } - } - - 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.DeprecatedVerifyKeyResponseBody - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - return &out, nil - 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) - } -} - -func (s *Unkey) DeprecatedListKeys(ctx context.Context, request operations.DeprecatedListKeysRequest) (*operations.DeprecatedListKeysResponseBody, error) { - hookCtx := hooks.HookContext{ - Context: ctx, - OperationID: "deprecated.listKeys", - OAuth2Scopes: []string{}, - SecuritySource: s.sdkConfiguration.Security, - } - - baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) - opURL, err := utils.GenerateURL(ctx, baseURL, "/v1/apis/{apiId}/keys", request, nil) - if err != nil { - return nil, fmt.Errorf("error generating URL: %w", err) - } - - req, err := http.NewRequestWithContext(ctx, "GET", opURL, nil) - 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) - - if err := utils.PopulateQueryParams(ctx, req, request, nil); err != nil { - return nil, fmt.Errorf("error populating query params: %w", err) - } - - 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 - } - } - - 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.DeprecatedListKeysResponseBody - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - return &out, nil - 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) - } -}