From 7ec69de5d76eb6184cb086c234d407a5be12e0c1 Mon Sep 17 00:00:00 2001 From: speakeasybot Date: Wed, 25 Sep 2024 00:30:31 +0000 Subject: [PATCH] ci: regenerated with OpenAPI Doc , Speakeasy CLI 1.402.12 --- .speakeasy/gen.lock | 1186 ++++++++++++--- .speakeasy/gen.yaml | 2 +- .speakeasy/workflow.lock | 11 +- README.md | 72 +- RELEASES.md | 12 +- apis.go | 515 ++++++- docs/models/operations/ratelimit.md | 16 +- docs/models/operations/type.md | 2 +- .../models/operations/updatekeyrequestbody.md | 27 +- docs/sdks/apis/README.md | 86 +- docs/sdks/identities/README.md | 101 +- docs/sdks/keys/README.md | 226 +-- docs/sdks/liveness/README.md | 8 +- docs/sdks/migrations/README.md | 35 +- docs/sdks/permissions/README.md | 117 +- docs/sdks/ratelimits/README.md | 24 +- docs/sdks/unkey/README.md | 6 +- identities.go | 584 ++++++- internal/utils/json.go | 25 +- internal/utils/requestbody.go | 27 +- internal/utils/security.go | 12 +- keys.go | 1343 ++++++++++++++++- liveness.go | 103 +- migrations.go | 206 ++- models/operations/createkey.go | 4 +- models/operations/updatekey.go | 16 +- permissions.go | 824 +++++++++- ratelimits.go | 103 +- types/pointers.go | 1 + unkey.go | 9 +- 30 files changed, 4905 insertions(+), 798 deletions(-) diff --git a/.speakeasy/gen.lock b/.speakeasy/gen.lock index 33b5406..a14bc3b 100755 --- a/.speakeasy/gen.lock +++ b/.speakeasy/gen.lock @@ -1,22 +1,22 @@ lockVersion: 2.0.0 id: 4fc4737a-135f-4840-8e6d-42a2b2a2884b management: - docChecksum: 621c3289c396eb08c056d389a37c2f2d + docChecksum: fedf8d1926c823e4a6b4787e9788634a docVersion: 1.0.0 - speakeasyVersion: 1.376.0 - generationVersion: 2.402.5 - releaseVersion: 0.9.0 - configChecksum: 0d5ecbbed7f980333206941ee50386c7 + speakeasyVersion: 1.402.12 + generationVersion: 2.422.15 + releaseVersion: 0.9.1 + configChecksum: d3a75ceda7f8ec35a8fa0d16f319ba62 repoURL: https://github.com/unkeyed/unkey-go.git installationURL: https://github.com/unkeyed/unkey-go features: go: additionalDependencies: 0.1.0 constsAndDefaults: 0.1.6 - core: 3.5.5 + core: 3.5.9 defaultEnabledRetries: 0.2.0 deprecations: 2.81.1 - envVarSecurityUsage: 0.3.0 + envVarSecurityUsage: 0.3.1 globalSecurity: 2.82.10 globalSecurityCallbacks: 0.1.0 globalSecurityFlattening: 0.1.0 @@ -30,274 +30,1000 @@ features: sdkHooks: 0.1.0 unions: 2.85.9 generatedFiles: - - liveness.go - - keys.go - - apis.go - - ratelimits.go - - migrations.go - - permissions.go - - identities.go - - unkey.go - - go.mod - - models/sdkerrors/sdkerror.go - - retry/config.go - - types/bigint.go - - types/date.go - - types/datetime.go - - types/decimal.go - - types/pointers.go - - internal/utils/contenttype.go - - internal/utils/form.go - - internal/utils/headers.go - - internal/utils/json.go - - internal/utils/pathparams.go - - internal/utils/queryparams.go - - internal/utils/requestbody.go - - internal/utils/retries.go - - internal/utils/security.go - - internal/utils/utils.go - - /models/operations/v1liveness.go - - /models/operations/getkey.go - - /models/operations/deletekey.go - - /models/operations/createkey.go - - /models/operations/verifykey.go - - /models/operations/updatekey.go - - /models/operations/updateremaining.go - - /models/operations/getverifications.go + - .gitattributes + - /models/components/httpmetadata.go + - /models/components/key.go + - /models/components/permissionquery.go + - /models/components/security.go + - /models/components/v1keysverifykeyrequest.go + - /models/components/v1keysverifykeyresponse.go - /models/operations/addpermissions.go - - /models/operations/removepermissions.go - - /models/operations/setpermissions.go - /models/operations/addroles.go - - /models/operations/removeroles.go - - /models/operations/setroles.go - - /models/operations/getapi.go - /models/operations/createapi.go - - /models/operations/listkeys.go + - /models/operations/createidentity.go + - /models/operations/createkey.go + - /models/operations/createpermission.go + - /models/operations/createrole.go - /models/operations/deleteapi.go + - /models/operations/deleteidentity.go + - /models/operations/deletekey.go - /models/operations/deletekeys.go - - /models/operations/limit.go - - /models/operations/v1migrationscreatekeys.go - - /models/operations/v1migrationsenqueuekeys.go - - /models/operations/createpermission.go - /models/operations/deletepermission.go - - /models/operations/getpermission.go - - /models/operations/listpermissions.go - - /models/operations/createrole.go - /models/operations/deleterole.go - - /models/operations/getrole.go - - /models/operations/listroles.go - - /models/operations/createidentity.go + - /models/operations/getapi.go - /models/operations/getidentity.go + - /models/operations/getkey.go + - /models/operations/getpermission.go + - /models/operations/getrole.go + - /models/operations/getverifications.go + - /models/operations/limit.go - /models/operations/listidentities.go + - /models/operations/listkeys.go + - /models/operations/listpermissions.go + - /models/operations/listroles.go + - /models/operations/removepermissions.go + - /models/operations/removeroles.go + - /models/operations/setpermissions.go + - /models/operations/setroles.go - /models/operations/updateidentity.go - - /models/operations/deleteidentity.go - - /models/components/httpmetadata.go - - /models/components/key.go - - /models/components/v1keysverifykeyresponse.go - - /models/components/v1keysverifykeyrequest.go - - /models/components/permissionquery.go - - /models/components/security.go + - /models/operations/updatekey.go + - /models/operations/updateremaining.go + - /models/operations/v1liveness.go + - /models/operations/v1migrationscreatekeys.go + - /models/operations/v1migrationsenqueuekeys.go + - /models/operations/verifykey.go - /models/sdkerrors/errbadrequest.go - - /models/sdkerrors/errunauthorized.go + - /models/sdkerrors/errconflict.go + - /models/sdkerrors/errdeleteprotected.go - /models/sdkerrors/errforbidden.go + - /models/sdkerrors/errinternalservererror.go - /models/sdkerrors/errnotfound.go - - /models/sdkerrors/errconflict.go - /models/sdkerrors/errtoomanyrequests.go - - /models/sdkerrors/errinternalservererror.go - - /models/sdkerrors/errdeleteprotected.go - - docs/models/operations/services.md - - docs/models/operations/v1livenessresponsebody.md - - docs/models/operations/v1livenessresponse.md - - docs/models/operations/getkeyrequest.md - - docs/models/operations/getkeyresponse.md - - docs/models/operations/deletekeyrequestbody.md - - docs/models/operations/deletekeyresponsebody.md - - docs/models/operations/deletekeyresponse.md - - docs/models/operations/interval.md - - docs/models/operations/refill.md - - docs/models/operations/type.md - - docs/models/operations/ratelimit.md - - docs/models/operations/createkeyrequestbody.md - - docs/models/operations/createkeyresponsebody.md - - docs/models/operations/createkeyresponse.md - - docs/models/operations/verifykeyresponse.md - - docs/models/operations/updatekeytype.md - - docs/models/operations/updatekeyratelimit.md - - docs/models/operations/updatekeyinterval.md - - docs/models/operations/updatekeyrefill.md - - docs/models/operations/roles.md - - docs/models/operations/permissions.md - - docs/models/operations/updatekeyrequestbody.md - - docs/models/operations/updatekeyresponsebody.md - - docs/models/operations/updatekeyresponse.md - - docs/models/operations/op.md - - docs/models/operations/updateremainingrequestbody.md - - docs/models/operations/updateremainingresponsebody.md - - docs/models/operations/updateremainingresponse.md - - docs/models/operations/granularity.md - - docs/models/operations/getverificationsrequest.md - - docs/models/operations/verifications.md - - docs/models/operations/getverificationsresponsebody.md - - docs/models/operations/getverificationsresponse.md + - /models/sdkerrors/errunauthorized.go + - CONTRIBUTING.md + - USAGE.md + - apis.go + - docs/models/components/and.md + - docs/models/components/authorization.md + - docs/models/components/code.md + - docs/models/components/httpmetadata.md + - docs/models/components/identity.md + - docs/models/components/interval.md + - docs/models/components/key.md + - docs/models/components/or.md + - docs/models/components/permissionquery.md + - docs/models/components/ratelimit.md + - docs/models/components/ratelimits.md + - docs/models/components/refill.md + - docs/models/components/security.md + - docs/models/components/type.md + - docs/models/components/v1keysverifykeyrequest.md + - docs/models/components/v1keysverifykeyrequestratelimit.md + - docs/models/components/v1keysverifykeyresponse.md + - docs/models/components/v1keysverifykeyresponseidentity.md + - docs/models/components/v1keysverifykeyresponseratelimit.md - docs/models/operations/addpermissionspermissions.md - docs/models/operations/addpermissionsrequestbody.md - - docs/models/operations/responsebody.md - docs/models/operations/addpermissionsresponse.md - - docs/models/operations/removepermissionspermissions.md - - docs/models/operations/removepermissionsrequestbody.md - - docs/models/operations/removepermissionsresponsebody.md - - docs/models/operations/removepermissionsresponse.md - - docs/models/operations/setpermissionspermissions.md - - docs/models/operations/setpermissionsrequestbody.md - - docs/models/operations/setpermissionsresponsebody.md - - docs/models/operations/setpermissionsresponse.md - - docs/models/operations/addrolesroles.md - docs/models/operations/addrolesrequestbody.md - - docs/models/operations/addrolesresponsebody.md - docs/models/operations/addrolesresponse.md - - docs/models/operations/removerolesroles.md - - docs/models/operations/removerolesrequestbody.md - - docs/models/operations/removerolesresponsebody.md - - docs/models/operations/removerolesresponse.md - - docs/models/operations/setrolesroles.md - - docs/models/operations/setrolesrequestbody.md - - docs/models/operations/setrolesresponsebody.md - - docs/models/operations/setrolesresponse.md - - docs/models/operations/getapirequest.md - - docs/models/operations/getapiresponsebody.md - - docs/models/operations/getapiresponse.md + - docs/models/operations/addrolesresponsebody.md + - docs/models/operations/addrolesroles.md - docs/models/operations/createapirequestbody.md - - docs/models/operations/createapiresponsebody.md - docs/models/operations/createapiresponse.md - - docs/models/operations/listkeysrequest.md - - docs/models/operations/listkeysresponsebody.md - - docs/models/operations/listkeysresponse.md + - docs/models/operations/createapiresponsebody.md + - docs/models/operations/createidentityrequestbody.md + - docs/models/operations/createidentityresponse.md + - docs/models/operations/createidentityresponsebody.md + - docs/models/operations/createkeyrequestbody.md + - docs/models/operations/createkeyresponse.md + - docs/models/operations/createkeyresponsebody.md + - docs/models/operations/createpermissionrequestbody.md + - docs/models/operations/createpermissionresponse.md + - docs/models/operations/createpermissionresponsebody.md + - docs/models/operations/createrolerequestbody.md + - docs/models/operations/createroleresponse.md + - docs/models/operations/createroleresponsebody.md - docs/models/operations/deleteapirequestbody.md - - docs/models/operations/deleteapiresponsebody.md - docs/models/operations/deleteapiresponse.md + - docs/models/operations/deleteapiresponsebody.md + - docs/models/operations/deleteidentityrequestbody.md + - docs/models/operations/deleteidentityresponse.md + - docs/models/operations/deleteidentityresponsebody.md + - docs/models/operations/deletekeyrequestbody.md + - docs/models/operations/deletekeyresponse.md + - docs/models/operations/deletekeyresponsebody.md - docs/models/operations/deletekeysrequestbody.md - - docs/models/operations/deletekeysresponsebody.md - docs/models/operations/deletekeysresponse.md - - docs/models/operations/resources.md - - docs/models/operations/limitrequestbody.md - - docs/models/operations/limitresponsebody.md - - docs/models/operations/limitresponse.md - - docs/models/operations/variant.md - - docs/models/operations/hash.md - - docs/models/operations/v1migrationscreatekeysinterval.md - - docs/models/operations/v1migrationscreatekeysrefill.md - - docs/models/operations/v1migrationscreatekeystype.md - - docs/models/operations/v1migrationscreatekeysratelimit.md - - docs/models/operations/requestbody.md - - docs/models/operations/v1migrationscreatekeysresponsebody.md - - docs/models/operations/v1migrationscreatekeysresponse.md - - docs/models/operations/v1migrationsenqueuekeysvariant.md - - docs/models/operations/v1migrationsenqueuekeyshash.md - - docs/models/operations/v1migrationsenqueuekeysinterval.md - - docs/models/operations/v1migrationsenqueuekeysrefill.md - - docs/models/operations/v1migrationsenqueuekeystype.md - - docs/models/operations/v1migrationsenqueuekeysratelimit.md - - docs/models/operations/keys.md - - docs/models/operations/v1migrationsenqueuekeysrequestbody.md - - docs/models/operations/v1migrationsenqueuekeysresponsebody.md - - docs/models/operations/v1migrationsenqueuekeysresponse.md - - docs/models/operations/createpermissionrequestbody.md - - docs/models/operations/createpermissionresponsebody.md - - docs/models/operations/createpermissionresponse.md + - docs/models/operations/deletekeysresponsebody.md - docs/models/operations/deletepermissionrequestbody.md - - docs/models/operations/deletepermissionresponsebody.md - docs/models/operations/deletepermissionresponse.md - - docs/models/operations/getpermissionrequest.md - - docs/models/operations/getpermissionresponsebody.md - - docs/models/operations/getpermissionresponse.md - - docs/models/operations/listpermissionsresponsebody.md - - docs/models/operations/listpermissionsresponse.md - - docs/models/operations/createrolerequestbody.md - - docs/models/operations/createroleresponsebody.md - - docs/models/operations/createroleresponse.md + - docs/models/operations/deletepermissionresponsebody.md - docs/models/operations/deleterolerequestbody.md - - docs/models/operations/deleteroleresponsebody.md - docs/models/operations/deleteroleresponse.md - - docs/models/operations/getrolerequest.md - - docs/models/operations/getroleresponsebody.md - - docs/models/operations/getroleresponse.md - - docs/models/operations/listrolesresponsebody.md - - docs/models/operations/listrolesresponse.md - - docs/models/operations/ratelimits.md - - docs/models/operations/createidentityrequestbody.md - - docs/models/operations/createidentityresponsebody.md - - docs/models/operations/createidentityresponse.md - - docs/models/operations/getidentityrequest.md + - docs/models/operations/deleteroleresponsebody.md + - docs/models/operations/getapirequest.md + - docs/models/operations/getapiresponse.md + - docs/models/operations/getapiresponsebody.md - docs/models/operations/getidentityratelimits.md - - docs/models/operations/getidentityresponsebody.md + - docs/models/operations/getidentityrequest.md - docs/models/operations/getidentityresponse.md - - docs/models/operations/listidentitiesrequest.md - - docs/models/operations/listidentitiesratelimits.md + - docs/models/operations/getidentityresponsebody.md + - docs/models/operations/getkeyrequest.md + - docs/models/operations/getkeyresponse.md + - docs/models/operations/getpermissionrequest.md + - docs/models/operations/getpermissionresponse.md + - docs/models/operations/getpermissionresponsebody.md + - docs/models/operations/getrolerequest.md + - docs/models/operations/getroleresponse.md + - docs/models/operations/getroleresponsebody.md + - docs/models/operations/getverificationsrequest.md + - docs/models/operations/getverificationsresponse.md + - docs/models/operations/getverificationsresponsebody.md + - docs/models/operations/granularity.md + - docs/models/operations/hash.md - docs/models/operations/identities.md - - docs/models/operations/listidentitiesresponsebody.md + - docs/models/operations/interval.md + - docs/models/operations/keys.md + - docs/models/operations/limitrequestbody.md + - docs/models/operations/limitresponse.md + - docs/models/operations/limitresponsebody.md + - docs/models/operations/listidentitiesratelimits.md + - docs/models/operations/listidentitiesrequest.md - docs/models/operations/listidentitiesresponse.md + - docs/models/operations/listidentitiesresponsebody.md + - docs/models/operations/listkeysrequest.md + - docs/models/operations/listkeysresponse.md + - docs/models/operations/listkeysresponsebody.md + - docs/models/operations/listpermissionsresponse.md + - docs/models/operations/listpermissionsresponsebody.md + - docs/models/operations/listrolesresponse.md + - docs/models/operations/listrolesresponsebody.md + - docs/models/operations/op.md + - docs/models/operations/option.md + - docs/models/operations/permissions.md + - docs/models/operations/ratelimit.md + - docs/models/operations/ratelimits.md + - docs/models/operations/refill.md + - docs/models/operations/removepermissionspermissions.md + - docs/models/operations/removepermissionsrequestbody.md + - docs/models/operations/removepermissionsresponse.md + - docs/models/operations/removepermissionsresponsebody.md + - docs/models/operations/removerolesrequestbody.md + - docs/models/operations/removerolesresponse.md + - docs/models/operations/removerolesresponsebody.md + - docs/models/operations/removerolesroles.md + - docs/models/operations/requestbody.md + - docs/models/operations/resources.md + - docs/models/operations/responsebody.md + - docs/models/operations/roles.md + - docs/models/operations/services.md + - docs/models/operations/setpermissionspermissions.md + - docs/models/operations/setpermissionsrequestbody.md + - docs/models/operations/setpermissionsresponse.md + - docs/models/operations/setpermissionsresponsebody.md + - docs/models/operations/setrolesrequestbody.md + - docs/models/operations/setrolesresponse.md + - docs/models/operations/setrolesresponsebody.md + - docs/models/operations/setrolesroles.md + - docs/models/operations/type.md + - docs/models/operations/updateidentityidentitiesratelimits.md - docs/models/operations/updateidentityratelimits.md - docs/models/operations/updateidentityrequestbody.md - - docs/models/operations/updateidentityidentitiesratelimits.md - - docs/models/operations/updateidentityresponsebody.md - docs/models/operations/updateidentityresponse.md - - docs/models/operations/deleteidentityrequestbody.md - - docs/models/operations/deleteidentityresponsebody.md - - docs/models/operations/deleteidentityresponse.md - - docs/models/components/httpmetadata.md - - docs/models/components/interval.md - - docs/models/components/refill.md - - docs/models/components/type.md - - docs/models/components/ratelimit.md - - docs/models/components/identity.md - - docs/models/components/key.md - - docs/models/components/v1keysverifykeyresponseratelimit.md - - docs/models/components/code.md - - docs/models/components/v1keysverifykeyresponseidentity.md - - docs/models/components/v1keysverifykeyresponse.md - - docs/models/components/authorization.md - - docs/models/components/v1keysverifykeyrequestratelimit.md - - docs/models/components/ratelimits.md - - docs/models/components/v1keysverifykeyrequest.md - - docs/models/components/or.md - - docs/models/components/and.md - - docs/models/components/permissionquery.md - - docs/models/components/security.md + - docs/models/operations/updateidentityresponsebody.md + - docs/models/operations/updatekeyinterval.md + - docs/models/operations/updatekeyratelimit.md + - docs/models/operations/updatekeyrefill.md + - docs/models/operations/updatekeyrequestbody.md + - docs/models/operations/updatekeyresponse.md + - docs/models/operations/updatekeyresponsebody.md + - docs/models/operations/updatekeytype.md + - docs/models/operations/updateremainingrequestbody.md + - docs/models/operations/updateremainingresponse.md + - docs/models/operations/updateremainingresponsebody.md + - docs/models/operations/v1livenessresponse.md + - docs/models/operations/v1livenessresponsebody.md + - docs/models/operations/v1migrationscreatekeysinterval.md + - docs/models/operations/v1migrationscreatekeysratelimit.md + - docs/models/operations/v1migrationscreatekeysrefill.md + - docs/models/operations/v1migrationscreatekeysresponse.md + - docs/models/operations/v1migrationscreatekeysresponsebody.md + - docs/models/operations/v1migrationscreatekeystype.md + - docs/models/operations/v1migrationsenqueuekeyshash.md + - docs/models/operations/v1migrationsenqueuekeysinterval.md + - docs/models/operations/v1migrationsenqueuekeysratelimit.md + - docs/models/operations/v1migrationsenqueuekeysrefill.md + - docs/models/operations/v1migrationsenqueuekeysrequestbody.md + - docs/models/operations/v1migrationsenqueuekeysresponse.md + - docs/models/operations/v1migrationsenqueuekeysresponsebody.md + - docs/models/operations/v1migrationsenqueuekeystype.md + - docs/models/operations/v1migrationsenqueuekeysvariant.md + - docs/models/operations/variant.md + - docs/models/operations/verifications.md + - docs/models/operations/verifykeyresponse.md - docs/models/sdkerrors/code.md - - docs/models/sdkerrors/error.md - docs/models/sdkerrors/errbadrequest.md - - docs/models/sdkerrors/errunauthorizedcode.md - - docs/models/sdkerrors/errunauthorizederror.md - - docs/models/sdkerrors/errunauthorized.md + - docs/models/sdkerrors/errconflict.md + - docs/models/sdkerrors/errconflictcode.md + - docs/models/sdkerrors/errconflicterror.md + - docs/models/sdkerrors/errdeleteprotected.md + - docs/models/sdkerrors/errdeleteprotectedcode.md + - docs/models/sdkerrors/errdeleteprotectederror.md + - docs/models/sdkerrors/errforbidden.md - docs/models/sdkerrors/errforbiddencode.md - docs/models/sdkerrors/errforbiddenerror.md - - docs/models/sdkerrors/errforbidden.md + - docs/models/sdkerrors/errinternalservererror.md + - docs/models/sdkerrors/errinternalservererrorcode.md + - docs/models/sdkerrors/errinternalservererrorerror.md + - docs/models/sdkerrors/errnotfound.md - docs/models/sdkerrors/errnotfoundcode.md - docs/models/sdkerrors/errnotfounderror.md - - docs/models/sdkerrors/errnotfound.md - - docs/models/sdkerrors/errconflictcode.md - - docs/models/sdkerrors/errconflicterror.md - - docs/models/sdkerrors/errconflict.md + - docs/models/sdkerrors/error.md + - docs/models/sdkerrors/errtoomanyrequests.md - docs/models/sdkerrors/errtoomanyrequestscode.md - docs/models/sdkerrors/errtoomanyrequestserror.md - - docs/models/sdkerrors/errtoomanyrequests.md - - docs/models/sdkerrors/errinternalservererrorcode.md - - docs/models/sdkerrors/errinternalservererrorerror.md - - docs/models/sdkerrors/errinternalservererror.md - - docs/models/sdkerrors/errdeleteprotectedcode.md - - docs/models/sdkerrors/errdeleteprotectederror.md - - docs/models/sdkerrors/errdeleteprotected.md - - docs/sdks/unkey/README.md - - docs/models/operations/option.md - - docs/sdks/liveness/README.md - - docs/sdks/keys/README.md + - docs/models/sdkerrors/errunauthorized.md + - docs/models/sdkerrors/errunauthorizedcode.md + - docs/models/sdkerrors/errunauthorizederror.md - docs/sdks/apis/README.md - - docs/sdks/ratelimits/README.md + - docs/sdks/identities/README.md + - docs/sdks/keys/README.md + - docs/sdks/liveness/README.md - docs/sdks/migrations/README.md - docs/sdks/permissions/README.md - - docs/sdks/identities/README.md - - USAGE.md - - models/operations/options.go - - .gitattributes + - docs/sdks/ratelimits/README.md + - docs/sdks/unkey/README.md + - go.mod + - identities.go - internal/hooks/hooks.go - - CONTRIBUTING.md + - internal/utils/contenttype.go + - internal/utils/form.go + - internal/utils/headers.go + - internal/utils/json.go + - internal/utils/pathparams.go + - internal/utils/queryparams.go + - internal/utils/requestbody.go + - internal/utils/retries.go + - internal/utils/security.go + - internal/utils/utils.go + - keys.go + - liveness.go + - migrations.go + - models/operations/options.go + - models/sdkerrors/sdkerror.go + - permissions.go + - ratelimits.go + - retry/config.go + - types/bigint.go + - types/date.go + - types/datetime.go + - types/decimal.go + - types/pointers.go + - unkey.go +examples: + v1.liveness: + speakeasy-default-v1-liveness: + responses: + "200": + application/json: {"status": "", "services": {"metrics": "AxiomMetrics", "logger": "AxiomLogger or ConsoleLogger", "ratelimit": "", "usagelimit": "", "analytics": ""}} + "400": + application/json: {"error": {"code": "BAD_REQUEST", "docs": "https://unkey.dev/docs/api-reference/errors/code/BAD_REQUEST", "message": "", "requestId": "req_1234"}} + "401": + application/json: {"error": {"code": "UNAUTHORIZED", "docs": "https://unkey.dev/docs/api-reference/errors/code/UNAUTHORIZED", "message": "", "requestId": "req_1234"}} + "403": + application/json: {"error": {"code": "FORBIDDEN", "docs": "https://unkey.dev/docs/api-reference/errors/code/FORBIDDEN", "message": "", "requestId": "req_1234"}} + "404": + application/json: {"error": {"code": "NOT_FOUND", "docs": "https://unkey.dev/docs/api-reference/errors/code/NOT_FOUND", "message": "", "requestId": "req_1234"}} + "409": + application/json: {"error": {"code": "CONFLICT", "docs": "https://unkey.dev/docs/api-reference/errors/code/CONFLICT", "message": "", "requestId": "req_1234"}} + "429": + application/json: {"error": {"code": "TOO_MANY_REQUESTS", "docs": "https://unkey.dev/docs/api-reference/errors/code/TOO_MANY_REQUESTS", "message": "", "requestId": "req_1234"}} + "500": + application/json: {"error": {"code": "INTERNAL_SERVER_ERROR", "docs": "https://unkey.dev/docs/api-reference/errors/code/INTERNAL_SERVER_ERROR", "message": "", "requestId": "req_1234"}} + getKey: + speakeasy-default-get-key: + parameters: + query: + keyId: "key_1234" + responses: + "200": + application/json: {"id": "key_1234", "start": "sk_5j1", "workspaceId": "ws_1234", "apiId": "api_1234", "name": "Customer X", "ownerId": "user_123", "meta": {"roles": ["admin", "user"], "stripeCustomerId": "cus_1234"}, "createdAt": 0, "updatedAt": 0, "expires": 0, "remaining": 1000, "refill": {"interval": "daily", "amount": 100, "lastRefillAt": 100}, "ratelimit": {"async": true, "limit": 10, "duration": 60}, "roles": ["admin", "finance"], "permissions": ["domain.dns.create_record", "finance.read_receipt"], "enabled": true} + "400": + application/json: {"error": {"code": "BAD_REQUEST", "docs": "https://unkey.dev/docs/api-reference/errors/code/BAD_REQUEST", "message": "", "requestId": "req_1234"}} + "401": + application/json: {"error": {"code": "UNAUTHORIZED", "docs": "https://unkey.dev/docs/api-reference/errors/code/UNAUTHORIZED", "message": "", "requestId": "req_1234"}} + "403": + application/json: {"error": {"code": "FORBIDDEN", "docs": "https://unkey.dev/docs/api-reference/errors/code/FORBIDDEN", "message": "", "requestId": "req_1234"}} + "404": + application/json: {"error": {"code": "NOT_FOUND", "docs": "https://unkey.dev/docs/api-reference/errors/code/NOT_FOUND", "message": "", "requestId": "req_1234"}} + "409": + application/json: {"error": {"code": "CONFLICT", "docs": "https://unkey.dev/docs/api-reference/errors/code/CONFLICT", "message": "", "requestId": "req_1234"}} + "429": + application/json: {"error": {"code": "TOO_MANY_REQUESTS", "docs": "https://unkey.dev/docs/api-reference/errors/code/TOO_MANY_REQUESTS", "message": "", "requestId": "req_1234"}} + "500": + application/json: {"error": {"code": "INTERNAL_SERVER_ERROR", "docs": "https://unkey.dev/docs/api-reference/errors/code/INTERNAL_SERVER_ERROR", "message": "", "requestId": "req_1234"}} + deleteKey: + speakeasy-default-delete-key: + requestBody: + application/json: {"keyId": "key_1234"} + responses: + "400": + application/json: {"error": {"code": "BAD_REQUEST", "docs": "https://unkey.dev/docs/api-reference/errors/code/BAD_REQUEST", "message": "", "requestId": "req_1234"}} + "401": + application/json: {"error": {"code": "UNAUTHORIZED", "docs": "https://unkey.dev/docs/api-reference/errors/code/UNAUTHORIZED", "message": "", "requestId": "req_1234"}} + "403": + application/json: {"error": {"code": "FORBIDDEN", "docs": "https://unkey.dev/docs/api-reference/errors/code/FORBIDDEN", "message": "", "requestId": "req_1234"}} + "404": + application/json: {"error": {"code": "NOT_FOUND", "docs": "https://unkey.dev/docs/api-reference/errors/code/NOT_FOUND", "message": "", "requestId": "req_1234"}} + "409": + application/json: {"error": {"code": "CONFLICT", "docs": "https://unkey.dev/docs/api-reference/errors/code/CONFLICT", "message": "", "requestId": "req_1234"}} + "429": + application/json: {"error": {"code": "TOO_MANY_REQUESTS", "docs": "https://unkey.dev/docs/api-reference/errors/code/TOO_MANY_REQUESTS", "message": "", "requestId": "req_1234"}} + "500": + application/json: {"error": {"code": "INTERNAL_SERVER_ERROR", "docs": "https://unkey.dev/docs/api-reference/errors/code/INTERNAL_SERVER_ERROR", "message": "", "requestId": "req_1234"}} + createKey: + speakeasy-default-create-key: + requestBody: + application/json: {"apiId": "api_123", "name": "my key", "externalId": "team_123", "meta": {"billingTier": "PRO", "trialEnds": "2023-06-16T17:16:37.161Z"}, "roles": ["admin", "finance"], "permissions": ["domains.create_record", "say_hello"], "expires": 1623869797161, "remaining": 1000, "refill": {"interval": "daily", "amount": 100}, "ratelimit": {"type": "fast", "limit": 10, "duration": 60000}, "enabled": false} + responses: + "200": + application/json: {"keyId": "key_123", "key": "prefix_xxxxxxxxx"} + "400": + application/json: {"error": {"code": "BAD_REQUEST", "docs": "https://unkey.dev/docs/api-reference/errors/code/BAD_REQUEST", "message": "", "requestId": "req_1234"}} + "401": + application/json: {"error": {"code": "UNAUTHORIZED", "docs": "https://unkey.dev/docs/api-reference/errors/code/UNAUTHORIZED", "message": "", "requestId": "req_1234"}} + "403": + application/json: {"error": {"code": "FORBIDDEN", "docs": "https://unkey.dev/docs/api-reference/errors/code/FORBIDDEN", "message": "", "requestId": "req_1234"}} + "404": + application/json: {"error": {"code": "NOT_FOUND", "docs": "https://unkey.dev/docs/api-reference/errors/code/NOT_FOUND", "message": "", "requestId": "req_1234"}} + "409": + application/json: {"error": {"code": "CONFLICT", "docs": "https://unkey.dev/docs/api-reference/errors/code/CONFLICT", "message": "", "requestId": "req_1234"}} + "429": + application/json: {"error": {"code": "TOO_MANY_REQUESTS", "docs": "https://unkey.dev/docs/api-reference/errors/code/TOO_MANY_REQUESTS", "message": "", "requestId": "req_1234"}} + "500": + application/json: {"error": {"code": "INTERNAL_SERVER_ERROR", "docs": "https://unkey.dev/docs/api-reference/errors/code/INTERNAL_SERVER_ERROR", "message": "", "requestId": "req_1234"}} + verifyKey: + speakeasy-default-verify-key: + requestBody: + application/json: {"apiId": "api_1234", "key": "sk_1234", "ratelimits": [{"name": "tokens", "limit": 500, "duration": 3600000}, {"name": "tokens", "limit": 20000, "duration": 86400000}]} + responses: + "200": + application/json: {"keyId": "key_1234", "valid": true, "name": "Customer X", "ownerId": "user_123", "meta": {"roles": ["admin", "user"], "stripeCustomerId": "cus_1234"}, "expires": 123, "ratelimit": {"limit": 10, "remaining": 9, "reset": 3600000}, "remaining": 1000, "code": "DISABLED", "permissions": ["dns.record.update", "dns.record.delete"], "environment": "test"} + "400": + application/json: {"error": {"code": "BAD_REQUEST", "docs": "https://unkey.dev/docs/api-reference/errors/code/BAD_REQUEST", "message": "", "requestId": "req_1234"}} + "401": + application/json: {"error": {"code": "UNAUTHORIZED", "docs": "https://unkey.dev/docs/api-reference/errors/code/UNAUTHORIZED", "message": "", "requestId": "req_1234"}} + "403": + application/json: {"error": {"code": "FORBIDDEN", "docs": "https://unkey.dev/docs/api-reference/errors/code/FORBIDDEN", "message": "", "requestId": "req_1234"}} + "404": + application/json: {"error": {"code": "NOT_FOUND", "docs": "https://unkey.dev/docs/api-reference/errors/code/NOT_FOUND", "message": "", "requestId": "req_1234"}} + "409": + application/json: {"error": {"code": "CONFLICT", "docs": "https://unkey.dev/docs/api-reference/errors/code/CONFLICT", "message": "", "requestId": "req_1234"}} + "429": + application/json: {"error": {"code": "TOO_MANY_REQUESTS", "docs": "https://unkey.dev/docs/api-reference/errors/code/TOO_MANY_REQUESTS", "message": "", "requestId": "req_1234"}} + "500": + application/json: {"error": {"code": "INTERNAL_SERVER_ERROR", "docs": "https://unkey.dev/docs/api-reference/errors/code/INTERNAL_SERVER_ERROR", "message": "", "requestId": "req_1234"}} + updateKey: + speakeasy-default-update-key: + requestBody: + application/json: {"keyId": "key_123", "name": "Customer X", "externalId": "user_123", "meta": {"roles": ["admin", "user"], "stripeCustomerId": "cus_1234"}, "expires": 0, "ratelimit": {"type": "fast", "limit": 10, "refillRate": 1, "refillInterval": 60}, "remaining": 1000, "refill": {"interval": "daily", "amount": 100}, "enabled": true, "roles": [{"id": "perm_123"}, {"name": "dns.record.create"}, {"name": "dns.record.delete", "create": true}], "permissions": [{"id": "perm_123"}, {"name": "dns.record.create"}, {"name": "dns.record.delete", "create": true}]} + responses: + "400": + application/json: {"error": {"code": "BAD_REQUEST", "docs": "https://unkey.dev/docs/api-reference/errors/code/BAD_REQUEST", "message": "", "requestId": "req_1234"}} + "401": + application/json: {"error": {"code": "UNAUTHORIZED", "docs": "https://unkey.dev/docs/api-reference/errors/code/UNAUTHORIZED", "message": "", "requestId": "req_1234"}} + "403": + application/json: {"error": {"code": "FORBIDDEN", "docs": "https://unkey.dev/docs/api-reference/errors/code/FORBIDDEN", "message": "", "requestId": "req_1234"}} + "404": + application/json: {"error": {"code": "NOT_FOUND", "docs": "https://unkey.dev/docs/api-reference/errors/code/NOT_FOUND", "message": "", "requestId": "req_1234"}} + "409": + application/json: {"error": {"code": "CONFLICT", "docs": "https://unkey.dev/docs/api-reference/errors/code/CONFLICT", "message": "", "requestId": "req_1234"}} + "429": + application/json: {"error": {"code": "TOO_MANY_REQUESTS", "docs": "https://unkey.dev/docs/api-reference/errors/code/TOO_MANY_REQUESTS", "message": "", "requestId": "req_1234"}} + "500": + application/json: {"error": {"code": "INTERNAL_SERVER_ERROR", "docs": "https://unkey.dev/docs/api-reference/errors/code/INTERNAL_SERVER_ERROR", "message": "", "requestId": "req_1234"}} + updateRemaining: + speakeasy-default-update-remaining: + requestBody: + application/json: {"keyId": "key_123", "op": "set", "value": 1} + responses: + "200": + application/json: {"remaining": 100} + "400": + application/json: {"error": {"code": "BAD_REQUEST", "docs": "https://unkey.dev/docs/api-reference/errors/code/BAD_REQUEST", "message": "", "requestId": "req_1234"}} + "401": + application/json: {"error": {"code": "UNAUTHORIZED", "docs": "https://unkey.dev/docs/api-reference/errors/code/UNAUTHORIZED", "message": "", "requestId": "req_1234"}} + "403": + application/json: {"error": {"code": "FORBIDDEN", "docs": "https://unkey.dev/docs/api-reference/errors/code/FORBIDDEN", "message": "", "requestId": "req_1234"}} + "404": + application/json: {"error": {"code": "NOT_FOUND", "docs": "https://unkey.dev/docs/api-reference/errors/code/NOT_FOUND", "message": "", "requestId": "req_1234"}} + "409": + application/json: {"error": {"code": "CONFLICT", "docs": "https://unkey.dev/docs/api-reference/errors/code/CONFLICT", "message": "", "requestId": "req_1234"}} + "429": + application/json: {"error": {"code": "TOO_MANY_REQUESTS", "docs": "https://unkey.dev/docs/api-reference/errors/code/TOO_MANY_REQUESTS", "message": "", "requestId": "req_1234"}} + "500": + application/json: {"error": {"code": "INTERNAL_SERVER_ERROR", "docs": "https://unkey.dev/docs/api-reference/errors/code/INTERNAL_SERVER_ERROR", "message": "", "requestId": "req_1234"}} + getVerifications: + speakeasy-default-get-verifications: + parameters: + query: + keyId: "key_1234" + ownerId: "chronark" + start: 1620000000000 + end: 1620000000000 + granularity: "day" + responses: + "200": + application/json: {"verifications": [{"time": 1620000000000, "success": 100, "rateLimited": 10, "usageExceeded": 0}]} + "400": + application/json: {"error": {"code": "BAD_REQUEST", "docs": "https://unkey.dev/docs/api-reference/errors/code/BAD_REQUEST", "message": "", "requestId": "req_1234"}} + "401": + application/json: {"error": {"code": "UNAUTHORIZED", "docs": "https://unkey.dev/docs/api-reference/errors/code/UNAUTHORIZED", "message": "", "requestId": "req_1234"}} + "403": + application/json: {"error": {"code": "FORBIDDEN", "docs": "https://unkey.dev/docs/api-reference/errors/code/FORBIDDEN", "message": "", "requestId": "req_1234"}} + "404": + application/json: {"error": {"code": "NOT_FOUND", "docs": "https://unkey.dev/docs/api-reference/errors/code/NOT_FOUND", "message": "", "requestId": "req_1234"}} + "409": + application/json: {"error": {"code": "CONFLICT", "docs": "https://unkey.dev/docs/api-reference/errors/code/CONFLICT", "message": "", "requestId": "req_1234"}} + "429": + application/json: {"error": {"code": "TOO_MANY_REQUESTS", "docs": "https://unkey.dev/docs/api-reference/errors/code/TOO_MANY_REQUESTS", "message": "", "requestId": "req_1234"}} + "500": + application/json: {"error": {"code": "INTERNAL_SERVER_ERROR", "docs": "https://unkey.dev/docs/api-reference/errors/code/INTERNAL_SERVER_ERROR", "message": "", "requestId": "req_1234"}} + addPermissions: + speakeasy-default-add-permissions: + requestBody: + application/json: {"keyId": ""} + responses: + "200": + application/json: [{"id": "perm_123", "name": "dns.record.create"}] + "400": + application/json: {"error": {"code": "BAD_REQUEST", "docs": "https://unkey.dev/docs/api-reference/errors/code/BAD_REQUEST", "message": "", "requestId": "req_1234"}} + "401": + application/json: {"error": {"code": "UNAUTHORIZED", "docs": "https://unkey.dev/docs/api-reference/errors/code/UNAUTHORIZED", "message": "", "requestId": "req_1234"}} + "403": + application/json: {"error": {"code": "FORBIDDEN", "docs": "https://unkey.dev/docs/api-reference/errors/code/FORBIDDEN", "message": "", "requestId": "req_1234"}} + "404": + application/json: {"error": {"code": "NOT_FOUND", "docs": "https://unkey.dev/docs/api-reference/errors/code/NOT_FOUND", "message": "", "requestId": "req_1234"}} + "409": + application/json: {"error": {"code": "CONFLICT", "docs": "https://unkey.dev/docs/api-reference/errors/code/CONFLICT", "message": "", "requestId": "req_1234"}} + "429": + application/json: {"error": {"code": "TOO_MANY_REQUESTS", "docs": "https://unkey.dev/docs/api-reference/errors/code/TOO_MANY_REQUESTS", "message": "", "requestId": "req_1234"}} + "500": + application/json: {"error": {"code": "INTERNAL_SERVER_ERROR", "docs": "https://unkey.dev/docs/api-reference/errors/code/INTERNAL_SERVER_ERROR", "message": "", "requestId": "req_1234"}} + removePermissions: + speakeasy-default-remove-permissions: + requestBody: + application/json: {"keyId": "", "permissions": [{"id": "perm_123"}, {"name": "dns.record.create"}]} + responses: + "400": + application/json: {"error": {"code": "BAD_REQUEST", "docs": "https://unkey.dev/docs/api-reference/errors/code/BAD_REQUEST", "message": "", "requestId": "req_1234"}} + "401": + application/json: {"error": {"code": "UNAUTHORIZED", "docs": "https://unkey.dev/docs/api-reference/errors/code/UNAUTHORIZED", "message": "", "requestId": "req_1234"}} + "403": + application/json: {"error": {"code": "FORBIDDEN", "docs": "https://unkey.dev/docs/api-reference/errors/code/FORBIDDEN", "message": "", "requestId": "req_1234"}} + "404": + application/json: {"error": {"code": "NOT_FOUND", "docs": "https://unkey.dev/docs/api-reference/errors/code/NOT_FOUND", "message": "", "requestId": "req_1234"}} + "409": + application/json: {"error": {"code": "CONFLICT", "docs": "https://unkey.dev/docs/api-reference/errors/code/CONFLICT", "message": "", "requestId": "req_1234"}} + "429": + application/json: {"error": {"code": "TOO_MANY_REQUESTS", "docs": "https://unkey.dev/docs/api-reference/errors/code/TOO_MANY_REQUESTS", "message": "", "requestId": "req_1234"}} + "500": + application/json: {"error": {"code": "INTERNAL_SERVER_ERROR", "docs": "https://unkey.dev/docs/api-reference/errors/code/INTERNAL_SERVER_ERROR", "message": "", "requestId": "req_1234"}} + setPermissions: + speakeasy-default-set-permissions: + requestBody: + application/json: {"keyId": "", "permissions": [{"id": "perm_123"}, {"name": "dns.record.create"}, {"name": "dns.record.delete", "create": true}]} + responses: + "200": + application/json: [{"id": "perm_123", "name": "dns.record.create"}] + "400": + application/json: {"error": {"code": "BAD_REQUEST", "docs": "https://unkey.dev/docs/api-reference/errors/code/BAD_REQUEST", "message": "", "requestId": "req_1234"}} + "401": + application/json: {"error": {"code": "UNAUTHORIZED", "docs": "https://unkey.dev/docs/api-reference/errors/code/UNAUTHORIZED", "message": "", "requestId": "req_1234"}} + "403": + application/json: {"error": {"code": "FORBIDDEN", "docs": "https://unkey.dev/docs/api-reference/errors/code/FORBIDDEN", "message": "", "requestId": "req_1234"}} + "404": + application/json: {"error": {"code": "NOT_FOUND", "docs": "https://unkey.dev/docs/api-reference/errors/code/NOT_FOUND", "message": "", "requestId": "req_1234"}} + "409": + application/json: {"error": {"code": "CONFLICT", "docs": "https://unkey.dev/docs/api-reference/errors/code/CONFLICT", "message": "", "requestId": "req_1234"}} + "429": + application/json: {"error": {"code": "TOO_MANY_REQUESTS", "docs": "https://unkey.dev/docs/api-reference/errors/code/TOO_MANY_REQUESTS", "message": "", "requestId": "req_1234"}} + "500": + application/json: {"error": {"code": "INTERNAL_SERVER_ERROR", "docs": "https://unkey.dev/docs/api-reference/errors/code/INTERNAL_SERVER_ERROR", "message": "", "requestId": "req_1234"}} + addRoles: + speakeasy-default-add-roles: + requestBody: + application/json: {"keyId": "", "roles": [{"id": "role_123"}, {"name": "dns.record.create"}, {"name": "dns.record.delete", "create": true}]} + responses: + "200": + application/json: [{"id": "role_123", "name": "dns.record.create"}, {"id": "role_123", "name": "dns.record.create"}] + "400": + application/json: {"error": {"code": "BAD_REQUEST", "docs": "https://unkey.dev/docs/api-reference/errors/code/BAD_REQUEST", "message": "", "requestId": "req_1234"}} + "401": + application/json: {"error": {"code": "UNAUTHORIZED", "docs": "https://unkey.dev/docs/api-reference/errors/code/UNAUTHORIZED", "message": "", "requestId": "req_1234"}} + "403": + application/json: {"error": {"code": "FORBIDDEN", "docs": "https://unkey.dev/docs/api-reference/errors/code/FORBIDDEN", "message": "", "requestId": "req_1234"}} + "404": + application/json: {"error": {"code": "NOT_FOUND", "docs": "https://unkey.dev/docs/api-reference/errors/code/NOT_FOUND", "message": "", "requestId": "req_1234"}} + "409": + application/json: {"error": {"code": "CONFLICT", "docs": "https://unkey.dev/docs/api-reference/errors/code/CONFLICT", "message": "", "requestId": "req_1234"}} + "429": + application/json: {"error": {"code": "TOO_MANY_REQUESTS", "docs": "https://unkey.dev/docs/api-reference/errors/code/TOO_MANY_REQUESTS", "message": "", "requestId": "req_1234"}} + "500": + application/json: {"error": {"code": "INTERNAL_SERVER_ERROR", "docs": "https://unkey.dev/docs/api-reference/errors/code/INTERNAL_SERVER_ERROR", "message": "", "requestId": "req_1234"}} + removeRoles: + speakeasy-default-remove-roles: + requestBody: + application/json: {"keyId": "", "roles": [{"id": "role_123"}, {"name": "dns.record.create"}]} + responses: + "400": + application/json: {"error": {"code": "BAD_REQUEST", "docs": "https://unkey.dev/docs/api-reference/errors/code/BAD_REQUEST", "message": "", "requestId": "req_1234"}} + "401": + application/json: {"error": {"code": "UNAUTHORIZED", "docs": "https://unkey.dev/docs/api-reference/errors/code/UNAUTHORIZED", "message": "", "requestId": "req_1234"}} + "403": + application/json: {"error": {"code": "FORBIDDEN", "docs": "https://unkey.dev/docs/api-reference/errors/code/FORBIDDEN", "message": "", "requestId": "req_1234"}} + "404": + application/json: {"error": {"code": "NOT_FOUND", "docs": "https://unkey.dev/docs/api-reference/errors/code/NOT_FOUND", "message": "", "requestId": "req_1234"}} + "409": + application/json: {"error": {"code": "CONFLICT", "docs": "https://unkey.dev/docs/api-reference/errors/code/CONFLICT", "message": "", "requestId": "req_1234"}} + "429": + application/json: {"error": {"code": "TOO_MANY_REQUESTS", "docs": "https://unkey.dev/docs/api-reference/errors/code/TOO_MANY_REQUESTS", "message": "", "requestId": "req_1234"}} + "500": + application/json: {"error": {"code": "INTERNAL_SERVER_ERROR", "docs": "https://unkey.dev/docs/api-reference/errors/code/INTERNAL_SERVER_ERROR", "message": "", "requestId": "req_1234"}} + setRoles: + speakeasy-default-set-roles: + requestBody: + application/json: {"keyId": "", "roles": [{"id": "role_123"}, {"name": "dns.record.create"}, {"name": "dns.record.delete", "create": true}]} + responses: + "200": + application/json: [{"id": "role_123", "name": "dns.record.create"}, {"id": "role_123", "name": "dns.record.create"}, {"id": "role_123", "name": "dns.record.create"}] + "400": + application/json: {"error": {"code": "BAD_REQUEST", "docs": "https://unkey.dev/docs/api-reference/errors/code/BAD_REQUEST", "message": "", "requestId": "req_1234"}} + "401": + application/json: {"error": {"code": "UNAUTHORIZED", "docs": "https://unkey.dev/docs/api-reference/errors/code/UNAUTHORIZED", "message": "", "requestId": "req_1234"}} + "403": + application/json: {"error": {"code": "FORBIDDEN", "docs": "https://unkey.dev/docs/api-reference/errors/code/FORBIDDEN", "message": "", "requestId": "req_1234"}} + "404": + application/json: {"error": {"code": "NOT_FOUND", "docs": "https://unkey.dev/docs/api-reference/errors/code/NOT_FOUND", "message": "", "requestId": "req_1234"}} + "409": + application/json: {"error": {"code": "CONFLICT", "docs": "https://unkey.dev/docs/api-reference/errors/code/CONFLICT", "message": "", "requestId": "req_1234"}} + "429": + application/json: {"error": {"code": "TOO_MANY_REQUESTS", "docs": "https://unkey.dev/docs/api-reference/errors/code/TOO_MANY_REQUESTS", "message": "", "requestId": "req_1234"}} + "500": + application/json: {"error": {"code": "INTERNAL_SERVER_ERROR", "docs": "https://unkey.dev/docs/api-reference/errors/code/INTERNAL_SERVER_ERROR", "message": "", "requestId": "req_1234"}} + getApi: + speakeasy-default-get-api: + parameters: + query: + apiId: "api_1234" + responses: + "200": + application/json: {"id": "key_1234", "workspaceId": "ws_1234", "name": "Unkey - Production"} + "400": + application/json: {"error": {"code": "BAD_REQUEST", "docs": "https://unkey.dev/docs/api-reference/errors/code/BAD_REQUEST", "message": "", "requestId": "req_1234"}} + "401": + application/json: {"error": {"code": "UNAUTHORIZED", "docs": "https://unkey.dev/docs/api-reference/errors/code/UNAUTHORIZED", "message": "", "requestId": "req_1234"}} + "403": + application/json: {"error": {"code": "FORBIDDEN", "docs": "https://unkey.dev/docs/api-reference/errors/code/FORBIDDEN", "message": "", "requestId": "req_1234"}} + "404": + application/json: {"error": {"code": "NOT_FOUND", "docs": "https://unkey.dev/docs/api-reference/errors/code/NOT_FOUND", "message": "", "requestId": "req_1234"}} + "409": + application/json: {"error": {"code": "CONFLICT", "docs": "https://unkey.dev/docs/api-reference/errors/code/CONFLICT", "message": "", "requestId": "req_1234"}} + "429": + application/json: {"error": {"code": "TOO_MANY_REQUESTS", "docs": "https://unkey.dev/docs/api-reference/errors/code/TOO_MANY_REQUESTS", "message": "", "requestId": "req_1234"}} + "500": + application/json: {"error": {"code": "INTERNAL_SERVER_ERROR", "docs": "https://unkey.dev/docs/api-reference/errors/code/INTERNAL_SERVER_ERROR", "message": "", "requestId": "req_1234"}} + createApi: + speakeasy-default-create-api: + requestBody: + application/json: {"name": "my-api"} + responses: + "200": + application/json: {"apiId": "api_134"} + "400": + application/json: {"error": {"code": "BAD_REQUEST", "docs": "https://unkey.dev/docs/api-reference/errors/code/BAD_REQUEST", "message": "", "requestId": "req_1234"}} + "401": + application/json: {"error": {"code": "UNAUTHORIZED", "docs": "https://unkey.dev/docs/api-reference/errors/code/UNAUTHORIZED", "message": "", "requestId": "req_1234"}} + "403": + application/json: {"error": {"code": "FORBIDDEN", "docs": "https://unkey.dev/docs/api-reference/errors/code/FORBIDDEN", "message": "", "requestId": "req_1234"}} + "404": + application/json: {"error": {"code": "NOT_FOUND", "docs": "https://unkey.dev/docs/api-reference/errors/code/NOT_FOUND", "message": "", "requestId": "req_1234"}} + "409": + application/json: {"error": {"code": "CONFLICT", "docs": "https://unkey.dev/docs/api-reference/errors/code/CONFLICT", "message": "", "requestId": "req_1234"}} + "429": + application/json: {"error": {"code": "TOO_MANY_REQUESTS", "docs": "https://unkey.dev/docs/api-reference/errors/code/TOO_MANY_REQUESTS", "message": "", "requestId": "req_1234"}} + "500": + application/json: {"error": {"code": "INTERNAL_SERVER_ERROR", "docs": "https://unkey.dev/docs/api-reference/errors/code/INTERNAL_SERVER_ERROR", "message": "", "requestId": "req_1234"}} + listKeys: + speakeasy-default-list-keys: + parameters: + query: + apiId: "api_1234" + limit: 100 + responses: + "200": + application/json: {"keys": [{"id": "key_1234", "start": "sk_5j1", "workspaceId": "ws_1234", "apiId": "api_1234", "name": "Customer X", "ownerId": "user_123", "meta": {"roles": ["admin", "user"], "stripeCustomerId": "cus_1234"}, "createdAt": 0, "updatedAt": 0, "expires": 0, "remaining": 1000, "refill": {"interval": "daily", "amount": 100, "lastRefillAt": 100}, "ratelimit": {"async": true, "limit": 10, "duration": 60}, "roles": ["admin", "finance"], "permissions": ["domain.dns.create_record", "finance.read_receipt"], "enabled": true}, {"id": "key_1234", "start": "sk_5j1", "workspaceId": "ws_1234", "apiId": "api_1234", "name": "Customer X", "ownerId": "user_123", "meta": {"roles": ["admin", "user"], "stripeCustomerId": "cus_1234"}, "createdAt": 0, "updatedAt": 0, "expires": 0, "remaining": 1000, "refill": {"interval": "daily", "amount": 100, "lastRefillAt": 100}, "ratelimit": {"async": true, "limit": 10, "duration": 60}, "roles": ["admin", "finance"], "permissions": ["domain.dns.create_record", "finance.read_receipt"], "enabled": true}], "cursor": "eyJrZXkiOiJrZXlfMTIzNCJ9", "total": 688970} + "400": + application/json: {"error": {"code": "BAD_REQUEST", "docs": "https://unkey.dev/docs/api-reference/errors/code/BAD_REQUEST", "message": "", "requestId": "req_1234"}} + "401": + application/json: {"error": {"code": "UNAUTHORIZED", "docs": "https://unkey.dev/docs/api-reference/errors/code/UNAUTHORIZED", "message": "", "requestId": "req_1234"}} + "403": + application/json: {"error": {"code": "FORBIDDEN", "docs": "https://unkey.dev/docs/api-reference/errors/code/FORBIDDEN", "message": "", "requestId": "req_1234"}} + "404": + application/json: {"error": {"code": "NOT_FOUND", "docs": "https://unkey.dev/docs/api-reference/errors/code/NOT_FOUND", "message": "", "requestId": "req_1234"}} + "409": + application/json: {"error": {"code": "CONFLICT", "docs": "https://unkey.dev/docs/api-reference/errors/code/CONFLICT", "message": "", "requestId": "req_1234"}} + "429": + application/json: {"error": {"code": "TOO_MANY_REQUESTS", "docs": "https://unkey.dev/docs/api-reference/errors/code/TOO_MANY_REQUESTS", "message": "", "requestId": "req_1234"}} + "500": + application/json: {"error": {"code": "INTERNAL_SERVER_ERROR", "docs": "https://unkey.dev/docs/api-reference/errors/code/INTERNAL_SERVER_ERROR", "message": "", "requestId": "req_1234"}} + deleteApi: + speakeasy-default-delete-api: + requestBody: + application/json: {"apiId": "api_1234"} + responses: + "400": + application/json: {"error": {"code": "BAD_REQUEST", "docs": "https://unkey.dev/docs/api-reference/errors/code/BAD_REQUEST", "message": "", "requestId": "req_1234"}} + "401": + application/json: {"error": {"code": "UNAUTHORIZED", "docs": "https://unkey.dev/docs/api-reference/errors/code/UNAUTHORIZED", "message": "", "requestId": "req_1234"}} + "403": + application/json: {"error": {"code": "FORBIDDEN", "docs": "https://unkey.dev/docs/api-reference/errors/code/FORBIDDEN", "message": "", "requestId": "req_1234"}} + "404": + application/json: {"error": {"code": "NOT_FOUND", "docs": "https://unkey.dev/docs/api-reference/errors/code/NOT_FOUND", "message": "", "requestId": "req_1234"}} + "409": + application/json: {"error": {"code": "CONFLICT", "docs": "https://unkey.dev/docs/api-reference/errors/code/CONFLICT", "message": "", "requestId": "req_1234"}} + "429": + application/json: {"error": {"code": "DELETE_PROTECTED", "docs": "https://unkey.dev/docs/api-reference/errors/code/DELETE_PROTECTED", "message": "", "requestId": "req_1234"}} + "500": + application/json: {"error": {"code": "INTERNAL_SERVER_ERROR", "docs": "https://unkey.dev/docs/api-reference/errors/code/INTERNAL_SERVER_ERROR", "message": "", "requestId": "req_1234"}} + deleteKeys: + speakeasy-default-delete-keys: + requestBody: + application/json: {"apiId": "api_1234"} + responses: + "200": + application/json: {"deletedKeys": 282252} + "400": + application/json: {"error": {"code": "BAD_REQUEST", "docs": "https://unkey.dev/docs/api-reference/errors/code/BAD_REQUEST", "message": "", "requestId": "req_1234"}} + "401": + application/json: {"error": {"code": "UNAUTHORIZED", "docs": "https://unkey.dev/docs/api-reference/errors/code/UNAUTHORIZED", "message": "", "requestId": "req_1234"}} + "403": + application/json: {"error": {"code": "FORBIDDEN", "docs": "https://unkey.dev/docs/api-reference/errors/code/FORBIDDEN", "message": "", "requestId": "req_1234"}} + "404": + application/json: {"error": {"code": "NOT_FOUND", "docs": "https://unkey.dev/docs/api-reference/errors/code/NOT_FOUND", "message": "", "requestId": "req_1234"}} + "409": + application/json: {"error": {"code": "CONFLICT", "docs": "https://unkey.dev/docs/api-reference/errors/code/CONFLICT", "message": "", "requestId": "req_1234"}} + "429": + application/json: {"error": {"code": "TOO_MANY_REQUESTS", "docs": "https://unkey.dev/docs/api-reference/errors/code/TOO_MANY_REQUESTS", "message": "", "requestId": "req_1234"}} + "500": + application/json: {"error": {"code": "INTERNAL_SERVER_ERROR", "docs": "https://unkey.dev/docs/api-reference/errors/code/INTERNAL_SERVER_ERROR", "message": "", "requestId": "req_1234"}} + limit: + speakeasy-default-limit: + requestBody: + application/json: {"namespace": "email.outbound", "identifier": "user_123", "limit": 10, "duration": 60000, "cost": 2, "resources": [{"type": "organization", "id": "org_123", "name": "unkey"}]} + responses: + "200": + application/json: {"success": true, "limit": 10, "remaining": 9, "reset": 1709804263654} + "400": + application/json: {"error": {"code": "BAD_REQUEST", "docs": "https://unkey.dev/docs/api-reference/errors/code/BAD_REQUEST", "message": "", "requestId": "req_1234"}} + "401": + application/json: {"error": {"code": "UNAUTHORIZED", "docs": "https://unkey.dev/docs/api-reference/errors/code/UNAUTHORIZED", "message": "", "requestId": "req_1234"}} + "403": + application/json: {"error": {"code": "FORBIDDEN", "docs": "https://unkey.dev/docs/api-reference/errors/code/FORBIDDEN", "message": "", "requestId": "req_1234"}} + "404": + application/json: {"error": {"code": "NOT_FOUND", "docs": "https://unkey.dev/docs/api-reference/errors/code/NOT_FOUND", "message": "", "requestId": "req_1234"}} + "409": + application/json: {"error": {"code": "CONFLICT", "docs": "https://unkey.dev/docs/api-reference/errors/code/CONFLICT", "message": "", "requestId": "req_1234"}} + "429": + application/json: {"error": {"code": "TOO_MANY_REQUESTS", "docs": "https://unkey.dev/docs/api-reference/errors/code/TOO_MANY_REQUESTS", "message": "", "requestId": "req_1234"}} + "500": + application/json: {"error": {"code": "INTERNAL_SERVER_ERROR", "docs": "https://unkey.dev/docs/api-reference/errors/code/INTERNAL_SERVER_ERROR", "message": "", "requestId": "req_1234"}} + v1.migrations.createKeys: + speakeasy-default-v1-migrations-create-keys: + requestBody: + application/json: [] + responses: + "200": + application/json: {"keyIds": ["key_123", "key_456"]} + "400": + application/json: {"error": {"code": "BAD_REQUEST", "docs": "https://unkey.dev/docs/api-reference/errors/code/BAD_REQUEST", "message": "", "requestId": "req_1234"}} + "401": + application/json: {"error": {"code": "UNAUTHORIZED", "docs": "https://unkey.dev/docs/api-reference/errors/code/UNAUTHORIZED", "message": "", "requestId": "req_1234"}} + "403": + application/json: {"error": {"code": "FORBIDDEN", "docs": "https://unkey.dev/docs/api-reference/errors/code/FORBIDDEN", "message": "", "requestId": "req_1234"}} + "404": + application/json: {"error": {"code": "NOT_FOUND", "docs": "https://unkey.dev/docs/api-reference/errors/code/NOT_FOUND", "message": "", "requestId": "req_1234"}} + "409": + application/json: {"error": {"code": "CONFLICT", "docs": "https://unkey.dev/docs/api-reference/errors/code/CONFLICT", "message": "", "requestId": "req_1234"}} + "429": + application/json: {"error": {"code": "TOO_MANY_REQUESTS", "docs": "https://unkey.dev/docs/api-reference/errors/code/TOO_MANY_REQUESTS", "message": "", "requestId": "req_1234"}} + "500": + application/json: {"error": {"code": "INTERNAL_SERVER_ERROR", "docs": "https://unkey.dev/docs/api-reference/errors/code/INTERNAL_SERVER_ERROR", "message": "", "requestId": "req_1234"}} + v1.migrations.enqueueKeys: + speakeasy-default-v1-migrations-enqueue-keys: + requestBody: + application/json: {"migrationId": "", "apiId": "", "keys": [{"name": "my key", "start": "unkey_32kq", "ownerId": "team_123", "meta": {"billingTier": "PRO", "trialEnds": "2023-06-16T17:16:37.161Z"}, "roles": ["admin", "finance"], "permissions": ["domains.create_record", "say_hello"], "expires": 1623869797161, "remaining": 1000, "refill": {"interval": "daily", "amount": 100}, "ratelimit": {"type": "fast", "limit": 10, "duration": 60000}, "enabled": false}]} + responses: + "400": + application/json: {"error": {"code": "BAD_REQUEST", "docs": "https://unkey.dev/docs/api-reference/errors/code/BAD_REQUEST", "message": "", "requestId": "req_1234"}} + "401": + application/json: {"error": {"code": "UNAUTHORIZED", "docs": "https://unkey.dev/docs/api-reference/errors/code/UNAUTHORIZED", "message": "", "requestId": "req_1234"}} + "403": + application/json: {"error": {"code": "FORBIDDEN", "docs": "https://unkey.dev/docs/api-reference/errors/code/FORBIDDEN", "message": "", "requestId": "req_1234"}} + "404": + application/json: {"error": {"code": "NOT_FOUND", "docs": "https://unkey.dev/docs/api-reference/errors/code/NOT_FOUND", "message": "", "requestId": "req_1234"}} + "409": + application/json: {"error": {"code": "CONFLICT", "docs": "https://unkey.dev/docs/api-reference/errors/code/CONFLICT", "message": "", "requestId": "req_1234"}} + "429": + application/json: {"error": {"code": "TOO_MANY_REQUESTS", "docs": "https://unkey.dev/docs/api-reference/errors/code/TOO_MANY_REQUESTS", "message": "", "requestId": "req_1234"}} + "500": + application/json: {"error": {"code": "INTERNAL_SERVER_ERROR", "docs": "https://unkey.dev/docs/api-reference/errors/code/INTERNAL_SERVER_ERROR", "message": "", "requestId": "req_1234"}} + createPermission: + speakeasy-default-create-permission: + requestBody: + application/json: {"name": "record.write", "description": "record.write can create new dns records for our domains."} + responses: + "200": + application/json: {"permissionId": "perm_123"} + "400": + application/json: {"error": {"code": "BAD_REQUEST", "docs": "https://unkey.dev/docs/api-reference/errors/code/BAD_REQUEST", "message": "", "requestId": "req_1234"}} + "401": + application/json: {"error": {"code": "UNAUTHORIZED", "docs": "https://unkey.dev/docs/api-reference/errors/code/UNAUTHORIZED", "message": "", "requestId": "req_1234"}} + "403": + application/json: {"error": {"code": "FORBIDDEN", "docs": "https://unkey.dev/docs/api-reference/errors/code/FORBIDDEN", "message": "", "requestId": "req_1234"}} + "404": + application/json: {"error": {"code": "NOT_FOUND", "docs": "https://unkey.dev/docs/api-reference/errors/code/NOT_FOUND", "message": "", "requestId": "req_1234"}} + "409": + application/json: {"error": {"code": "CONFLICT", "docs": "https://unkey.dev/docs/api-reference/errors/code/CONFLICT", "message": "", "requestId": "req_1234"}} + "429": + application/json: {"error": {"code": "TOO_MANY_REQUESTS", "docs": "https://unkey.dev/docs/api-reference/errors/code/TOO_MANY_REQUESTS", "message": "", "requestId": "req_1234"}} + "500": + application/json: {"error": {"code": "INTERNAL_SERVER_ERROR", "docs": "https://unkey.dev/docs/api-reference/errors/code/INTERNAL_SERVER_ERROR", "message": "", "requestId": "req_1234"}} + deletePermission: + speakeasy-default-delete-permission: + requestBody: + application/json: {"permissionId": "perm_123"} + responses: + "400": + application/json: {"error": {"code": "BAD_REQUEST", "docs": "https://unkey.dev/docs/api-reference/errors/code/BAD_REQUEST", "message": "", "requestId": "req_1234"}} + "401": + application/json: {"error": {"code": "UNAUTHORIZED", "docs": "https://unkey.dev/docs/api-reference/errors/code/UNAUTHORIZED", "message": "", "requestId": "req_1234"}} + "403": + application/json: {"error": {"code": "FORBIDDEN", "docs": "https://unkey.dev/docs/api-reference/errors/code/FORBIDDEN", "message": "", "requestId": "req_1234"}} + "404": + application/json: {"error": {"code": "NOT_FOUND", "docs": "https://unkey.dev/docs/api-reference/errors/code/NOT_FOUND", "message": "", "requestId": "req_1234"}} + "409": + application/json: {"error": {"code": "CONFLICT", "docs": "https://unkey.dev/docs/api-reference/errors/code/CONFLICT", "message": "", "requestId": "req_1234"}} + "429": + application/json: {"error": {"code": "TOO_MANY_REQUESTS", "docs": "https://unkey.dev/docs/api-reference/errors/code/TOO_MANY_REQUESTS", "message": "", "requestId": "req_1234"}} + "500": + application/json: {"error": {"code": "INTERNAL_SERVER_ERROR", "docs": "https://unkey.dev/docs/api-reference/errors/code/INTERNAL_SERVER_ERROR", "message": "", "requestId": "req_1234"}} + getPermission: + speakeasy-default-get-permission: + parameters: + query: + permissionId: "perm_123" + responses: + "200": + application/json: {"id": "perm_123", "name": "domain.record.manager", "description": "Can manage dns records"} + "400": + application/json: {"error": {"code": "BAD_REQUEST", "docs": "https://unkey.dev/docs/api-reference/errors/code/BAD_REQUEST", "message": "", "requestId": "req_1234"}} + "401": + application/json: {"error": {"code": "UNAUTHORIZED", "docs": "https://unkey.dev/docs/api-reference/errors/code/UNAUTHORIZED", "message": "", "requestId": "req_1234"}} + "403": + application/json: {"error": {"code": "FORBIDDEN", "docs": "https://unkey.dev/docs/api-reference/errors/code/FORBIDDEN", "message": "", "requestId": "req_1234"}} + "404": + application/json: {"error": {"code": "NOT_FOUND", "docs": "https://unkey.dev/docs/api-reference/errors/code/NOT_FOUND", "message": "", "requestId": "req_1234"}} + "409": + application/json: {"error": {"code": "CONFLICT", "docs": "https://unkey.dev/docs/api-reference/errors/code/CONFLICT", "message": "", "requestId": "req_1234"}} + "429": + application/json: {"error": {"code": "TOO_MANY_REQUESTS", "docs": "https://unkey.dev/docs/api-reference/errors/code/TOO_MANY_REQUESTS", "message": "", "requestId": "req_1234"}} + "500": + application/json: {"error": {"code": "INTERNAL_SERVER_ERROR", "docs": "https://unkey.dev/docs/api-reference/errors/code/INTERNAL_SERVER_ERROR", "message": "", "requestId": "req_1234"}} + listPermissions: + speakeasy-default-list-permissions: + responses: + "200": + application/json: [{"id": "perm_123", "name": "domain.record.manager", "description": "Can manage dns records"}] + "400": + application/json: {"error": {"code": "BAD_REQUEST", "docs": "https://unkey.dev/docs/api-reference/errors/code/BAD_REQUEST", "message": "", "requestId": "req_1234"}} + "401": + application/json: {"error": {"code": "UNAUTHORIZED", "docs": "https://unkey.dev/docs/api-reference/errors/code/UNAUTHORIZED", "message": "", "requestId": "req_1234"}} + "403": + application/json: {"error": {"code": "FORBIDDEN", "docs": "https://unkey.dev/docs/api-reference/errors/code/FORBIDDEN", "message": "", "requestId": "req_1234"}} + "404": + application/json: {"error": {"code": "NOT_FOUND", "docs": "https://unkey.dev/docs/api-reference/errors/code/NOT_FOUND", "message": "", "requestId": "req_1234"}} + "409": + application/json: {"error": {"code": "CONFLICT", "docs": "https://unkey.dev/docs/api-reference/errors/code/CONFLICT", "message": "", "requestId": "req_1234"}} + "429": + application/json: {"error": {"code": "TOO_MANY_REQUESTS", "docs": "https://unkey.dev/docs/api-reference/errors/code/TOO_MANY_REQUESTS", "message": "", "requestId": "req_1234"}} + "500": + application/json: {"error": {"code": "INTERNAL_SERVER_ERROR", "docs": "https://unkey.dev/docs/api-reference/errors/code/INTERNAL_SERVER_ERROR", "message": "", "requestId": "req_1234"}} + createRole: + speakeasy-default-create-role: + requestBody: + application/json: {"name": "dns.records.manager", "description": "dns.records.manager can read and write dns records for our domains."} + responses: + "200": + application/json: {"roleId": "role_123"} + "400": + application/json: {"error": {"code": "BAD_REQUEST", "docs": "https://unkey.dev/docs/api-reference/errors/code/BAD_REQUEST", "message": "", "requestId": "req_1234"}} + "401": + application/json: {"error": {"code": "UNAUTHORIZED", "docs": "https://unkey.dev/docs/api-reference/errors/code/UNAUTHORIZED", "message": "", "requestId": "req_1234"}} + "403": + application/json: {"error": {"code": "FORBIDDEN", "docs": "https://unkey.dev/docs/api-reference/errors/code/FORBIDDEN", "message": "", "requestId": "req_1234"}} + "404": + application/json: {"error": {"code": "NOT_FOUND", "docs": "https://unkey.dev/docs/api-reference/errors/code/NOT_FOUND", "message": "", "requestId": "req_1234"}} + "409": + application/json: {"error": {"code": "CONFLICT", "docs": "https://unkey.dev/docs/api-reference/errors/code/CONFLICT", "message": "", "requestId": "req_1234"}} + "429": + application/json: {"error": {"code": "TOO_MANY_REQUESTS", "docs": "https://unkey.dev/docs/api-reference/errors/code/TOO_MANY_REQUESTS", "message": "", "requestId": "req_1234"}} + "500": + application/json: {"error": {"code": "INTERNAL_SERVER_ERROR", "docs": "https://unkey.dev/docs/api-reference/errors/code/INTERNAL_SERVER_ERROR", "message": "", "requestId": "req_1234"}} + deleteRole: + speakeasy-default-delete-role: + requestBody: + application/json: {"roleId": "role_123"} + responses: + "400": + application/json: {"error": {"code": "BAD_REQUEST", "docs": "https://unkey.dev/docs/api-reference/errors/code/BAD_REQUEST", "message": "", "requestId": "req_1234"}} + "401": + application/json: {"error": {"code": "UNAUTHORIZED", "docs": "https://unkey.dev/docs/api-reference/errors/code/UNAUTHORIZED", "message": "", "requestId": "req_1234"}} + "403": + application/json: {"error": {"code": "FORBIDDEN", "docs": "https://unkey.dev/docs/api-reference/errors/code/FORBIDDEN", "message": "", "requestId": "req_1234"}} + "404": + application/json: {"error": {"code": "NOT_FOUND", "docs": "https://unkey.dev/docs/api-reference/errors/code/NOT_FOUND", "message": "", "requestId": "req_1234"}} + "409": + application/json: {"error": {"code": "CONFLICT", "docs": "https://unkey.dev/docs/api-reference/errors/code/CONFLICT", "message": "", "requestId": "req_1234"}} + "429": + application/json: {"error": {"code": "TOO_MANY_REQUESTS", "docs": "https://unkey.dev/docs/api-reference/errors/code/TOO_MANY_REQUESTS", "message": "", "requestId": "req_1234"}} + "500": + application/json: {"error": {"code": "INTERNAL_SERVER_ERROR", "docs": "https://unkey.dev/docs/api-reference/errors/code/INTERNAL_SERVER_ERROR", "message": "", "requestId": "req_1234"}} + getRole: + speakeasy-default-get-role: + parameters: + query: + roleId: "role_123" + responses: + "200": + application/json: {"id": "role_1234", "name": "domain.record.manager", "description": "Can manage dns records"} + "400": + application/json: {"error": {"code": "BAD_REQUEST", "docs": "https://unkey.dev/docs/api-reference/errors/code/BAD_REQUEST", "message": "", "requestId": "req_1234"}} + "401": + application/json: {"error": {"code": "UNAUTHORIZED", "docs": "https://unkey.dev/docs/api-reference/errors/code/UNAUTHORIZED", "message": "", "requestId": "req_1234"}} + "403": + application/json: {"error": {"code": "FORBIDDEN", "docs": "https://unkey.dev/docs/api-reference/errors/code/FORBIDDEN", "message": "", "requestId": "req_1234"}} + "404": + application/json: {"error": {"code": "NOT_FOUND", "docs": "https://unkey.dev/docs/api-reference/errors/code/NOT_FOUND", "message": "", "requestId": "req_1234"}} + "409": + application/json: {"error": {"code": "CONFLICT", "docs": "https://unkey.dev/docs/api-reference/errors/code/CONFLICT", "message": "", "requestId": "req_1234"}} + "429": + application/json: {"error": {"code": "TOO_MANY_REQUESTS", "docs": "https://unkey.dev/docs/api-reference/errors/code/TOO_MANY_REQUESTS", "message": "", "requestId": "req_1234"}} + "500": + application/json: {"error": {"code": "INTERNAL_SERVER_ERROR", "docs": "https://unkey.dev/docs/api-reference/errors/code/INTERNAL_SERVER_ERROR", "message": "", "requestId": "req_1234"}} + listRoles: + speakeasy-default-list-roles: + responses: + "200": + application/json: [{"id": "role_1234", "name": "domain.record.manager", "description": "Can manage dns records"}, {"id": "role_1234", "name": "domain.record.manager", "description": "Can manage dns records"}] + "400": + application/json: {"error": {"code": "BAD_REQUEST", "docs": "https://unkey.dev/docs/api-reference/errors/code/BAD_REQUEST", "message": "", "requestId": "req_1234"}} + "401": + application/json: {"error": {"code": "UNAUTHORIZED", "docs": "https://unkey.dev/docs/api-reference/errors/code/UNAUTHORIZED", "message": "", "requestId": "req_1234"}} + "403": + application/json: {"error": {"code": "FORBIDDEN", "docs": "https://unkey.dev/docs/api-reference/errors/code/FORBIDDEN", "message": "", "requestId": "req_1234"}} + "404": + application/json: {"error": {"code": "NOT_FOUND", "docs": "https://unkey.dev/docs/api-reference/errors/code/NOT_FOUND", "message": "", "requestId": "req_1234"}} + "409": + application/json: {"error": {"code": "CONFLICT", "docs": "https://unkey.dev/docs/api-reference/errors/code/CONFLICT", "message": "", "requestId": "req_1234"}} + "429": + application/json: {"error": {"code": "TOO_MANY_REQUESTS", "docs": "https://unkey.dev/docs/api-reference/errors/code/TOO_MANY_REQUESTS", "message": "", "requestId": "req_1234"}} + "500": + application/json: {"error": {"code": "INTERNAL_SERVER_ERROR", "docs": "https://unkey.dev/docs/api-reference/errors/code/INTERNAL_SERVER_ERROR", "message": "", "requestId": "req_1234"}} + createIdentity: + speakeasy-default-create-identity: + requestBody: + application/json: {"externalId": "user_123", "ratelimits": [{"name": "tokens", "limit": 10, "duration": 1000}, {"name": "tokens", "limit": 10, "duration": 1000}]} + responses: + "200": + application/json: {"identityId": "id_123"} + "400": + application/json: {"error": {"code": "BAD_REQUEST", "docs": "https://unkey.dev/docs/api-reference/errors/code/BAD_REQUEST", "message": "", "requestId": "req_1234"}} + "401": + application/json: {"error": {"code": "UNAUTHORIZED", "docs": "https://unkey.dev/docs/api-reference/errors/code/UNAUTHORIZED", "message": "", "requestId": "req_1234"}} + "403": + application/json: {"error": {"code": "FORBIDDEN", "docs": "https://unkey.dev/docs/api-reference/errors/code/FORBIDDEN", "message": "", "requestId": "req_1234"}} + "404": + application/json: {"error": {"code": "NOT_FOUND", "docs": "https://unkey.dev/docs/api-reference/errors/code/NOT_FOUND", "message": "", "requestId": "req_1234"}} + "409": + application/json: {"error": {"code": "CONFLICT", "docs": "https://unkey.dev/docs/api-reference/errors/code/CONFLICT", "message": "", "requestId": "req_1234"}} + "429": + application/json: {"error": {"code": "TOO_MANY_REQUESTS", "docs": "https://unkey.dev/docs/api-reference/errors/code/TOO_MANY_REQUESTS", "message": "", "requestId": "req_1234"}} + "500": + application/json: {"error": {"code": "INTERNAL_SERVER_ERROR", "docs": "https://unkey.dev/docs/api-reference/errors/code/INTERNAL_SERVER_ERROR", "message": "", "requestId": "req_1234"}} + getIdentity: + speakeasy-default-get-identity: + parameters: + query: + identityId: "id_1234" + externalId: "id_1234" + responses: + "200": + application/json: {"id": "", "externalId": "", "meta": {"key": "", "key1": ""}, "ratelimits": [{"name": "tokens", "limit": 10, "duration": 1000}]} + "400": + application/json: {"error": {"code": "BAD_REQUEST", "docs": "https://unkey.dev/docs/api-reference/errors/code/BAD_REQUEST", "message": "", "requestId": "req_1234"}} + "401": + application/json: {"error": {"code": "UNAUTHORIZED", "docs": "https://unkey.dev/docs/api-reference/errors/code/UNAUTHORIZED", "message": "", "requestId": "req_1234"}} + "403": + application/json: {"error": {"code": "FORBIDDEN", "docs": "https://unkey.dev/docs/api-reference/errors/code/FORBIDDEN", "message": "", "requestId": "req_1234"}} + "404": + application/json: {"error": {"code": "NOT_FOUND", "docs": "https://unkey.dev/docs/api-reference/errors/code/NOT_FOUND", "message": "", "requestId": "req_1234"}} + "409": + application/json: {"error": {"code": "CONFLICT", "docs": "https://unkey.dev/docs/api-reference/errors/code/CONFLICT", "message": "", "requestId": "req_1234"}} + "429": + application/json: {"error": {"code": "TOO_MANY_REQUESTS", "docs": "https://unkey.dev/docs/api-reference/errors/code/TOO_MANY_REQUESTS", "message": "", "requestId": "req_1234"}} + "500": + application/json: {"error": {"code": "INTERNAL_SERVER_ERROR", "docs": "https://unkey.dev/docs/api-reference/errors/code/INTERNAL_SERVER_ERROR", "message": "", "requestId": "req_1234"}} + listIdentities: + speakeasy-default-list-identities: + parameters: + query: + limit: 100 + responses: + "200": + application/json: {"identities": [{"id": "", "externalId": "", "ratelimits": [{"name": "tokens", "limit": 10, "duration": 1000}, {"name": "tokens", "limit": 10, "duration": 1000}]}], "cursor": "eyJrZXkiOiJrZXlfMTIzNCJ9", "total": 777201} + "400": + application/json: {"error": {"code": "BAD_REQUEST", "docs": "https://unkey.dev/docs/api-reference/errors/code/BAD_REQUEST", "message": "", "requestId": "req_1234"}} + "401": + application/json: {"error": {"code": "UNAUTHORIZED", "docs": "https://unkey.dev/docs/api-reference/errors/code/UNAUTHORIZED", "message": "", "requestId": "req_1234"}} + "403": + application/json: {"error": {"code": "FORBIDDEN", "docs": "https://unkey.dev/docs/api-reference/errors/code/FORBIDDEN", "message": "", "requestId": "req_1234"}} + "404": + application/json: {"error": {"code": "NOT_FOUND", "docs": "https://unkey.dev/docs/api-reference/errors/code/NOT_FOUND", "message": "", "requestId": "req_1234"}} + "409": + application/json: {"error": {"code": "CONFLICT", "docs": "https://unkey.dev/docs/api-reference/errors/code/CONFLICT", "message": "", "requestId": "req_1234"}} + "429": + application/json: {"error": {"code": "TOO_MANY_REQUESTS", "docs": "https://unkey.dev/docs/api-reference/errors/code/TOO_MANY_REQUESTS", "message": "", "requestId": "req_1234"}} + "500": + application/json: {"error": {"code": "INTERNAL_SERVER_ERROR", "docs": "https://unkey.dev/docs/api-reference/errors/code/INTERNAL_SERVER_ERROR", "message": "", "requestId": "req_1234"}} + updateIdentity: + speakeasy-default-update-identity: + requestBody: + application/json: {"identityId": "id_1234", "externalId": "user_1234", "ratelimits": [{"name": "tokens", "limit": 10, "duration": 1000}, {"name": "tokens", "limit": 10, "duration": 1000}, {"name": "tokens", "limit": 10, "duration": 1000}]} + responses: + "200": + application/json: {"id": "id_1234", "externalId": "user_1234", "meta": {"stripeSubscriptionId": "sub_1234"}, "ratelimits": [{"name": "tokens", "limit": 10, "duration": 1000}, {"name": "tokens", "limit": 10, "duration": 1000}, {"name": "tokens", "limit": 10, "duration": 1000}]} + "400": + application/json: {"error": {"code": "BAD_REQUEST", "docs": "https://unkey.dev/docs/api-reference/errors/code/BAD_REQUEST", "message": "", "requestId": "req_1234"}} + "401": + application/json: {"error": {"code": "UNAUTHORIZED", "docs": "https://unkey.dev/docs/api-reference/errors/code/UNAUTHORIZED", "message": "", "requestId": "req_1234"}} + "403": + application/json: {"error": {"code": "FORBIDDEN", "docs": "https://unkey.dev/docs/api-reference/errors/code/FORBIDDEN", "message": "", "requestId": "req_1234"}} + "404": + application/json: {"error": {"code": "NOT_FOUND", "docs": "https://unkey.dev/docs/api-reference/errors/code/NOT_FOUND", "message": "", "requestId": "req_1234"}} + "409": + application/json: {"error": {"code": "CONFLICT", "docs": "https://unkey.dev/docs/api-reference/errors/code/CONFLICT", "message": "", "requestId": "req_1234"}} + "429": + application/json: {"error": {"code": "TOO_MANY_REQUESTS", "docs": "https://unkey.dev/docs/api-reference/errors/code/TOO_MANY_REQUESTS", "message": "", "requestId": "req_1234"}} + "500": + application/json: {"error": {"code": "INTERNAL_SERVER_ERROR", "docs": "https://unkey.dev/docs/api-reference/errors/code/INTERNAL_SERVER_ERROR", "message": "", "requestId": "req_1234"}} + deleteIdentity: + speakeasy-default-delete-identity: + requestBody: + application/json: {"identityId": "id_1234"} + responses: + "400": + application/json: {"error": {"code": "BAD_REQUEST", "docs": "https://unkey.dev/docs/api-reference/errors/code/BAD_REQUEST", "message": "", "requestId": "req_1234"}} + "401": + application/json: {"error": {"code": "UNAUTHORIZED", "docs": "https://unkey.dev/docs/api-reference/errors/code/UNAUTHORIZED", "message": "", "requestId": "req_1234"}} + "403": + application/json: {"error": {"code": "FORBIDDEN", "docs": "https://unkey.dev/docs/api-reference/errors/code/FORBIDDEN", "message": "", "requestId": "req_1234"}} + "404": + application/json: {"error": {"code": "NOT_FOUND", "docs": "https://unkey.dev/docs/api-reference/errors/code/NOT_FOUND", "message": "", "requestId": "req_1234"}} + "409": + application/json: {"error": {"code": "CONFLICT", "docs": "https://unkey.dev/docs/api-reference/errors/code/CONFLICT", "message": "", "requestId": "req_1234"}} + "429": + application/json: {"error": {"code": "TOO_MANY_REQUESTS", "docs": "https://unkey.dev/docs/api-reference/errors/code/TOO_MANY_REQUESTS", "message": "", "requestId": "req_1234"}} + "500": + application/json: {"error": {"code": "INTERNAL_SERVER_ERROR", "docs": "https://unkey.dev/docs/api-reference/errors/code/INTERNAL_SERVER_ERROR", "message": "", "requestId": "req_1234"}} diff --git a/.speakeasy/gen.yaml b/.speakeasy/gen.yaml index 6eed0ad..ff7153f 100755 --- a/.speakeasy/gen.yaml +++ b/.speakeasy/gen.yaml @@ -12,7 +12,7 @@ generation: auth: oAuth2ClientCredentialsEnabled: true go: - version: 0.9.0 + version: 0.9.1 additionalDependencies: {} allowUnknownFieldsInWeakUnions: false clientServerStatusCodesAsErrors: true diff --git a/.speakeasy/workflow.lock b/.speakeasy/workflow.lock index 5d4cada..417cb18 100644 --- a/.speakeasy/workflow.lock +++ b/.speakeasy/workflow.lock @@ -1,9 +1,9 @@ -speakeasyVersion: 1.376.0 +speakeasyVersion: 1.402.12 sources: openapi.json: sourceNamespace: openapi-json - sourceRevisionDigest: sha256:22ea6d7a09f92497fce0a4a17b1dc53f4d58c6ca1ac8586d58c7adb6954d94f3 - sourceBlobDigest: sha256:e06355b7e867f452b2de56e1c7505bcdc66cc40551ad9b0b6f8024682e26b709 + sourceRevisionDigest: sha256:b41904850cc6ed437a9445e2fa1371a50078431deefc9c1e03e90a6c57ce919b + sourceBlobDigest: sha256:1f6f650bf87ca70cf40cec759d69bb698c0fa6cb60261d66e3db7b41c168b36e tags: - latest - main @@ -11,9 +11,8 @@ targets: go: source: openapi.json sourceNamespace: openapi-json - sourceRevisionDigest: sha256:22ea6d7a09f92497fce0a4a17b1dc53f4d58c6ca1ac8586d58c7adb6954d94f3 - sourceBlobDigest: sha256:e06355b7e867f452b2de56e1c7505bcdc66cc40551ad9b0b6f8024682e26b709 - outLocation: /github/workspace/repo + sourceRevisionDigest: sha256:b41904850cc6ed437a9445e2fa1371a50078431deefc9c1e03e90a6c57ce919b + sourceBlobDigest: sha256:1f6f650bf87ca70cf40cec759d69bb698c0fa6cb60261d66e3db7b41c168b36e workflow: workflowVersion: 1.0.0 speakeasyVersion: latest diff --git a/README.md b/README.md index 4370e6c..374eefc 100644 --- a/README.md +++ b/README.md @@ -7,9 +7,31 @@ + +## Summary + + + + + +## Table of Contents + +* [SDK Installation](#sdk-installation) +* [SDK Example Usage](#sdk-example-usage) +* [Available Resources and Operations](#available-resources-and-operations) +* [Pagination](#pagination) +* [Retries](#retries) +* [Error Handling](#error-handling) +* [Server Selection](#server-selection) +* [Custom HTTP Client](#custom-http-client) +* [Authentication](#authentication) +* [Special Types](#special-types) + + ## SDK Installation +To add the SDK as a dependency to your project: ```bash go get github.com/unkeyed/unkey-go ``` @@ -50,9 +72,24 @@ func main() { ## Available Resources and Operations -### [Liveness](docs/sdks/liveness/README.md) +
+Available methods -* [V1Liveness](docs/sdks/liveness/README.md#v1liveness) +### [Apis](docs/sdks/apis/README.md) + +* [GetAPI](docs/sdks/apis/README.md#getapi) +* [CreateAPI](docs/sdks/apis/README.md#createapi) +* [ListKeys](docs/sdks/apis/README.md#listkeys) +* [DeleteAPI](docs/sdks/apis/README.md#deleteapi) +* [DeleteKeys](docs/sdks/apis/README.md#deletekeys) + +### [Identities](docs/sdks/identities/README.md) + +* [CreateIdentity](docs/sdks/identities/README.md#createidentity) +* [GetIdentity](docs/sdks/identities/README.md#getidentity) +* [ListIdentities](docs/sdks/identities/README.md#listidentities) +* [UpdateIdentity](docs/sdks/identities/README.md#updateidentity) +* [DeleteIdentity](docs/sdks/identities/README.md#deleteidentity) ### [Keys](docs/sdks/keys/README.md) @@ -70,17 +107,9 @@ func main() { * [RemoveRoles](docs/sdks/keys/README.md#removeroles) * [SetRoles](docs/sdks/keys/README.md#setroles) -### [Apis](docs/sdks/apis/README.md) - -* [GetAPI](docs/sdks/apis/README.md#getapi) -* [CreateAPI](docs/sdks/apis/README.md#createapi) -* [ListKeys](docs/sdks/apis/README.md#listkeys) -* [DeleteAPI](docs/sdks/apis/README.md#deleteapi) -* [DeleteKeys](docs/sdks/apis/README.md#deletekeys) - -### [Ratelimits](docs/sdks/ratelimits/README.md) +### [Liveness](docs/sdks/liveness/README.md) -* [Limit](docs/sdks/ratelimits/README.md#limit) +* [V1Liveness](docs/sdks/liveness/README.md#v1liveness) ### [Migrations](docs/sdks/migrations/README.md) @@ -98,13 +127,12 @@ func main() { * [GetRole](docs/sdks/permissions/README.md#getrole) * [ListRoles](docs/sdks/permissions/README.md#listroles) -### [Identities](docs/sdks/identities/README.md) +### [Ratelimits](docs/sdks/ratelimits/README.md) -* [CreateIdentity](docs/sdks/identities/README.md#createidentity) -* [GetIdentity](docs/sdks/identities/README.md#getidentity) -* [ListIdentities](docs/sdks/identities/README.md#listidentities) -* [UpdateIdentity](docs/sdks/identities/README.md#updateidentity) -* [DeleteIdentity](docs/sdks/identities/README.md#deleteidentity) +* [Limit](docs/sdks/ratelimits/README.md#limit) + + +
@@ -450,11 +478,11 @@ func main() { s := unkeygo.New( unkeygo.WithSecurity(""), ) - request := operations.ListIdentitiesRequest{ - Limit: unkeygo.Int64(100), - } + ctx := context.Background() - res, err := s.Identities.ListIdentities(ctx, request) + res, err := s.Identities.ListIdentities(ctx, operations.ListIdentitiesRequest{ + Limit: unkeygo.Int64(100), + }) if err != nil { log.Fatal(err) } diff --git a/RELEASES.md b/RELEASES.md index 53f4402..e11d0c6 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -208,4 +208,14 @@ Based on: ### Generated - [go v0.9.0] . ### Releases -- [Go v0.9.0] https://github.com/unkeyed/unkey-go/releases/tag/v0.9.0 - . \ No newline at end of file +- [Go v0.9.0] https://github.com/unkeyed/unkey-go/releases/tag/v0.9.0 - . + +## 2024-09-25 00:29:31 +### Changes +Based on: +- OpenAPI Doc +- Speakeasy CLI 1.402.12 (2.422.15) https://github.com/speakeasy-api/speakeasy +### Generated +- [go v0.9.1] . +### Releases +- [Go v0.9.1] https://github.com/unkeyed/unkey-go/releases/tag/v0.9.1 - . \ No newline at end of file diff --git a/apis.go b/apis.go index c6b6dc0..1e8a081 100644 --- a/apis.go +++ b/apis.go @@ -178,17 +178,25 @@ func (s *Apis) GetAPI(ctx context.Context, request operations.GetAPIRequest, opt }, } - rawBody, err := io.ReadAll(httpRes.Body) - if err != nil { - return nil, fmt.Errorf("error reading response body: %w", err) + getRawBody := func() ([]byte, error) { + 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)) + return rawBody, nil } - 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out operations.GetAPIResponseBody if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -196,11 +204,21 @@ func (s *Apis) GetAPI(ctx context.Context, request operations.GetAPIRequest, opt res.Object = &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrBadRequest if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -208,11 +226,21 @@ func (s *Apis) GetAPI(ctx context.Context, request operations.GetAPIRequest, opt return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrUnauthorized if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -220,11 +248,21 @@ func (s *Apis) GetAPI(ctx context.Context, request operations.GetAPIRequest, opt return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrForbidden if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -232,11 +270,21 @@ func (s *Apis) GetAPI(ctx context.Context, request operations.GetAPIRequest, opt return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrNotFound if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -244,11 +292,21 @@ func (s *Apis) GetAPI(ctx context.Context, request operations.GetAPIRequest, opt return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrConflict if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -256,11 +314,21 @@ func (s *Apis) GetAPI(ctx context.Context, request operations.GetAPIRequest, opt return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrTooManyRequests if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -268,11 +336,21 @@ func (s *Apis) GetAPI(ctx context.Context, request operations.GetAPIRequest, opt return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } case httpRes.StatusCode == 500: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrInternalServerError if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -280,13 +358,28 @@ func (s *Apis) GetAPI(ctx context.Context, request operations.GetAPIRequest, opt return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) } @@ -446,17 +539,25 @@ func (s *Apis) CreateAPI(ctx context.Context, request operations.CreateAPIReques }, } - rawBody, err := io.ReadAll(httpRes.Body) - if err != nil { - return nil, fmt.Errorf("error reading response body: %w", err) + getRawBody := func() ([]byte, error) { + 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)) + return rawBody, nil } - 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out operations.CreateAPIResponseBody if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -464,11 +565,21 @@ func (s *Apis) CreateAPI(ctx context.Context, request operations.CreateAPIReques res.Object = &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrBadRequest if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -476,11 +587,21 @@ func (s *Apis) CreateAPI(ctx context.Context, request operations.CreateAPIReques return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrUnauthorized if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -488,11 +609,21 @@ func (s *Apis) CreateAPI(ctx context.Context, request operations.CreateAPIReques return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrForbidden if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -500,11 +631,21 @@ func (s *Apis) CreateAPI(ctx context.Context, request operations.CreateAPIReques return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrNotFound if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -512,11 +653,21 @@ func (s *Apis) CreateAPI(ctx context.Context, request operations.CreateAPIReques return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrConflict if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -524,11 +675,21 @@ func (s *Apis) CreateAPI(ctx context.Context, request operations.CreateAPIReques return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrTooManyRequests if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -536,11 +697,21 @@ func (s *Apis) CreateAPI(ctx context.Context, request operations.CreateAPIReques return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } case httpRes.StatusCode == 500: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrInternalServerError if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -548,13 +719,28 @@ func (s *Apis) CreateAPI(ctx context.Context, request operations.CreateAPIReques return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) } @@ -712,17 +898,25 @@ func (s *Apis) ListKeys(ctx context.Context, request operations.ListKeysRequest, }, } - rawBody, err := io.ReadAll(httpRes.Body) - if err != nil { - return nil, fmt.Errorf("error reading response body: %w", err) + getRawBody := func() ([]byte, error) { + 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)) + return rawBody, nil } - 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out operations.ListKeysResponseBody if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -730,11 +924,21 @@ func (s *Apis) ListKeys(ctx context.Context, request operations.ListKeysRequest, res.Object = &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrBadRequest if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -742,11 +946,21 @@ func (s *Apis) ListKeys(ctx context.Context, request operations.ListKeysRequest, return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrUnauthorized if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -754,11 +968,21 @@ func (s *Apis) ListKeys(ctx context.Context, request operations.ListKeysRequest, return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrForbidden if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -766,11 +990,21 @@ func (s *Apis) ListKeys(ctx context.Context, request operations.ListKeysRequest, return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrNotFound if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -778,11 +1012,21 @@ func (s *Apis) ListKeys(ctx context.Context, request operations.ListKeysRequest, return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrConflict if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -790,11 +1034,21 @@ func (s *Apis) ListKeys(ctx context.Context, request operations.ListKeysRequest, return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrTooManyRequests if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -802,11 +1056,21 @@ func (s *Apis) ListKeys(ctx context.Context, request operations.ListKeysRequest, return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } case httpRes.StatusCode == 500: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrInternalServerError if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -814,13 +1078,28 @@ func (s *Apis) ListKeys(ctx context.Context, request operations.ListKeysRequest, return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) } @@ -980,17 +1259,25 @@ func (s *Apis) DeleteAPI(ctx context.Context, request operations.DeleteAPIReques }, } - rawBody, err := io.ReadAll(httpRes.Body) - if err != nil { - return nil, fmt.Errorf("error reading response body: %w", err) + getRawBody := func() ([]byte, error) { + 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)) + return rawBody, nil } - 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out operations.DeleteAPIResponseBody if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -998,11 +1285,21 @@ func (s *Apis) DeleteAPI(ctx context.Context, request operations.DeleteAPIReques res.Object = &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrBadRequest if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -1010,11 +1307,21 @@ func (s *Apis) DeleteAPI(ctx context.Context, request operations.DeleteAPIReques return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrUnauthorized if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -1022,11 +1329,21 @@ func (s *Apis) DeleteAPI(ctx context.Context, request operations.DeleteAPIReques return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrForbidden if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -1034,11 +1351,21 @@ func (s *Apis) DeleteAPI(ctx context.Context, request operations.DeleteAPIReques return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrNotFound if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -1046,11 +1373,21 @@ func (s *Apis) DeleteAPI(ctx context.Context, request operations.DeleteAPIReques return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrConflict if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -1058,11 +1395,21 @@ func (s *Apis) DeleteAPI(ctx context.Context, request operations.DeleteAPIReques return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrDeleteProtected if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -1070,11 +1417,21 @@ func (s *Apis) DeleteAPI(ctx context.Context, request operations.DeleteAPIReques return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } case httpRes.StatusCode == 500: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrInternalServerError if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -1082,13 +1439,28 @@ func (s *Apis) DeleteAPI(ctx context.Context, request operations.DeleteAPIReques return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) } @@ -1248,17 +1620,25 @@ func (s *Apis) DeleteKeys(ctx context.Context, request operations.DeleteKeysRequ }, } - rawBody, err := io.ReadAll(httpRes.Body) - if err != nil { - return nil, fmt.Errorf("error reading response body: %w", err) + getRawBody := func() ([]byte, error) { + 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)) + return rawBody, nil } - 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out operations.DeleteKeysResponseBody if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -1266,11 +1646,21 @@ func (s *Apis) DeleteKeys(ctx context.Context, request operations.DeleteKeysRequ res.Object = &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrBadRequest if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -1278,11 +1668,21 @@ func (s *Apis) DeleteKeys(ctx context.Context, request operations.DeleteKeysRequ return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrUnauthorized if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -1290,11 +1690,21 @@ func (s *Apis) DeleteKeys(ctx context.Context, request operations.DeleteKeysRequ return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrForbidden if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -1302,11 +1712,21 @@ func (s *Apis) DeleteKeys(ctx context.Context, request operations.DeleteKeysRequ return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrNotFound if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -1314,11 +1734,21 @@ func (s *Apis) DeleteKeys(ctx context.Context, request operations.DeleteKeysRequ return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrConflict if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -1326,11 +1756,21 @@ func (s *Apis) DeleteKeys(ctx context.Context, request operations.DeleteKeysRequ return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrTooManyRequests if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -1338,11 +1778,21 @@ func (s *Apis) DeleteKeys(ctx context.Context, request operations.DeleteKeysRequ return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } case httpRes.StatusCode == 500: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrInternalServerError if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -1350,13 +1800,28 @@ func (s *Apis) DeleteKeys(ctx context.Context, request operations.DeleteKeysRequ return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) } diff --git a/docs/models/operations/ratelimit.md b/docs/models/operations/ratelimit.md index eaa05f3..8068fab 100644 --- a/docs/models/operations/ratelimit.md +++ b/docs/models/operations/ratelimit.md @@ -5,11 +5,11 @@ Unkey comes with per-key fixed-window ratelimiting out of the box. ## Fields -| Field | Type | Required | Description | Example | -| ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `Async` | **bool* | :heavy_minus_sign: | Async will return a response immediately, lowering latency at the cost of accuracy. Will be required soon.

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

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

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

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

The refill timeframe, in milliseconds. | | \ No newline at end of file +| Field | Type | Required | Description | Example | +| ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `Async` | **bool* | :heavy_minus_sign: | Async will return a response immediately, lowering latency at the cost of accuracy. Will be required soon.

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

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

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

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

The refill timeframe, in milliseconds. | | \ No newline at end of file diff --git a/docs/models/operations/type.md b/docs/models/operations/type.md index 4afd5bf..7ee95d1 100644 --- a/docs/models/operations/type.md +++ b/docs/models/operations/type.md @@ -1,6 +1,6 @@ # ~~Type~~ -Deprecated, used `async`. Fast ratelimiting doesn't add latency, while consistent ratelimiting is more accurate. +Deprecated, use `async`. Fast ratelimiting doesn't add latency, while consistent ratelimiting is more accurate. Learn more diff --git a/docs/models/operations/updatekeyrequestbody.md b/docs/models/operations/updatekeyrequestbody.md index 1eb2428..57fc738 100644 --- a/docs/models/operations/updatekeyrequestbody.md +++ b/docs/models/operations/updatekeyrequestbody.md @@ -6,16 +6,17 @@ Update a key's configuration. ## Fields -| Field | Type | Required | Description | Example | -| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `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]*any* | :heavy_minus_sign: | Any additional metadata you want to store with the key | {
"roles": [
"admin",
"user"
],
"stripeCustomerId": "cus_1234"
} | -| `Expires` | **int64* | :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` | **int64* | :heavy_minus_sign: | The number of requests that can be made with this key before it becomes invalid. Set `null` to disable. | 1000 | -| `Refill` | [*operations.UpdateKeyRefill](../../models/operations/updatekeyrefill.md) | :heavy_minus_sign: | Unkey enables you to refill verifications for each key at regular intervals. | {
"interval": "daily",
"amount": 100
} | -| `Enabled` | **bool* | :heavy_minus_sign: | Set if key is enabled or disabled. If disabled, the key cannot be used to verify. | true | -| `Roles` | [][operations.Roles](../../models/operations/roles.md) | :heavy_minus_sign: | The roles you want to set for this key. This overwrites all existing roles.
Setting roles requires the `rbac.*.add_role_to_key` permission. | [
{
"id": "perm_123"
},
{
"name": "dns.record.create"
},
{
"name": "dns.record.delete",
"create": true
}
] | -| `Permissions` | [][operations.Permissions](../../models/operations/permissions.md) | :heavy_minus_sign: | The permissions you want to set for this key. This overwrites all existing permissions.
Setting permissions requires the `rbac.*.add_permission_to_key` permission. | [
{
"id": "perm_123"
},
{
"name": "dns.record.create"
},
{
"name": "dns.record.delete",
"create": true
}
] | \ No newline at end of file +| Field | Type | Required | Description | Example | +| --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `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: | : warning: ** DEPRECATED **: This will be removed in a future release, please migrate away from it as soon as possible.

Deprecated, use `externalId`
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 | +| `ExternalID` | **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 back to you, so you know who is accessing your API.
Under the hood this upserts and connects an `ìdentity` for you.
To disconnect the key from an identity, set `externalId: null`. | user_123 | +| `Meta` | map[string]*any* | :heavy_minus_sign: | Any additional metadata you want to store with the key | {
"roles": [
"admin",
"user"
],
"stripeCustomerId": "cus_1234"
} | +| `Expires` | **int64* | :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` | **int64* | :heavy_minus_sign: | The number of requests that can be made with this key before it becomes invalid. Set `null` to disable. | 1000 | +| `Refill` | [*operations.UpdateKeyRefill](../../models/operations/updatekeyrefill.md) | :heavy_minus_sign: | Unkey enables you to refill verifications for each key at regular intervals. | {
"interval": "daily",
"amount": 100
} | +| `Enabled` | **bool* | :heavy_minus_sign: | Set if key is enabled or disabled. If disabled, the key cannot be used to verify. | true | +| `Roles` | [][operations.Roles](../../models/operations/roles.md) | :heavy_minus_sign: | The roles you want to set for this key. This overwrites all existing roles.
Setting roles requires the `rbac.*.add_role_to_key` permission. | [
{
"id": "perm_123"
},
{
"name": "dns.record.create"
},
{
"name": "dns.record.delete",
"create": true
}
] | +| `Permissions` | [][operations.Permissions](../../models/operations/permissions.md) | :heavy_minus_sign: | The permissions you want to set for this key. This overwrites all existing permissions.
Setting permissions requires the `rbac.*.add_permission_to_key` permission. | [
{
"id": "perm_123"
},
{
"name": "dns.record.create"
},
{
"name": "dns.record.delete",
"create": true
}
] | \ No newline at end of file diff --git a/docs/sdks/apis/README.md b/docs/sdks/apis/README.md index 1da6f62..eea312e 100644 --- a/docs/sdks/apis/README.md +++ b/docs/sdks/apis/README.md @@ -1,6 +1,8 @@ # Apis (*Apis*) +## Overview + ### Available Operations * [GetAPI](#getapi) @@ -18,8 +20,8 @@ package main import( unkeygo "github.com/unkeyed/unkey-go" - "github.com/unkeyed/unkey-go/models/operations" "context" + "github.com/unkeyed/unkey-go/models/operations" "log" ) @@ -27,11 +29,11 @@ func main() { s := unkeygo.New( unkeygo.WithSecurity(""), ) - request := operations.GetAPIRequest{ - APIID: "api_1234", - } + ctx := context.Background() - res, err := s.Apis.GetAPI(ctx, request) + res, err := s.Apis.GetAPI(ctx, operations.GetAPIRequest{ + APIID: "api_1234", + }) if err != nil { log.Fatal(err) } @@ -41,8 +43,6 @@ func main() { } ``` - - ### Parameters | Parameter | Type | Required | Description | @@ -51,10 +51,12 @@ func main() { | `request` | [operations.GetAPIRequest](../../models/operations/getapirequest.md) | :heavy_check_mark: | The request object to use for the request. | | `opts` | [][operations.Option](../../models/operations/option.md) | :heavy_minus_sign: | The options for this request. | - ### Response **[*operations.GetAPIResponse](../../models/operations/getapiresponse.md), error** + +### Errors + | Error Object | Status Code | Content Type | | -------------------------------- | -------------------------------- | -------------------------------- | | sdkerrors.ErrBadRequest | 400 | application/json | @@ -66,6 +68,7 @@ func main() { | sdkerrors.ErrInternalServerError | 500 | application/json | | sdkerrors.SDKError | 4xx-5xx | */* | + ## CreateAPI ### Example Usage @@ -75,8 +78,8 @@ package main import( unkeygo "github.com/unkeyed/unkey-go" - "github.com/unkeyed/unkey-go/models/operations" "context" + "github.com/unkeyed/unkey-go/models/operations" "log" ) @@ -84,11 +87,11 @@ func main() { s := unkeygo.New( unkeygo.WithSecurity(""), ) - request := operations.CreateAPIRequestBody{ - Name: "my-api", - } + ctx := context.Background() - res, err := s.Apis.CreateAPI(ctx, request) + res, err := s.Apis.CreateAPI(ctx, operations.CreateAPIRequestBody{ + Name: "my-api", + }) if err != nil { log.Fatal(err) } @@ -98,8 +101,6 @@ func main() { } ``` - - ### Parameters | Parameter | Type | Required | Description | @@ -108,10 +109,12 @@ func main() { | `request` | [operations.CreateAPIRequestBody](../../models/operations/createapirequestbody.md) | :heavy_check_mark: | The request object to use for the request. | | `opts` | [][operations.Option](../../models/operations/option.md) | :heavy_minus_sign: | The options for this request. | - ### Response **[*operations.CreateAPIResponse](../../models/operations/createapiresponse.md), error** + +### Errors + | Error Object | Status Code | Content Type | | -------------------------------- | -------------------------------- | -------------------------------- | | sdkerrors.ErrBadRequest | 400 | application/json | @@ -123,6 +126,7 @@ func main() { | sdkerrors.ErrInternalServerError | 500 | application/json | | sdkerrors.SDKError | 4xx-5xx | */* | + ## ListKeys ### Example Usage @@ -132,8 +136,8 @@ package main import( unkeygo "github.com/unkeyed/unkey-go" - "github.com/unkeyed/unkey-go/models/operations" "context" + "github.com/unkeyed/unkey-go/models/operations" "log" ) @@ -141,12 +145,12 @@ func main() { s := unkeygo.New( unkeygo.WithSecurity(""), ) - request := operations.ListKeysRequest{ + + ctx := context.Background() + res, err := s.Apis.ListKeys(ctx, operations.ListKeysRequest{ APIID: "api_1234", Limit: unkeygo.Int64(100), - } - ctx := context.Background() - res, err := s.Apis.ListKeys(ctx, request) + }) if err != nil { log.Fatal(err) } @@ -156,8 +160,6 @@ func main() { } ``` - - ### Parameters | Parameter | Type | Required | Description | @@ -166,10 +168,12 @@ func main() { | `request` | [operations.ListKeysRequest](../../models/operations/listkeysrequest.md) | :heavy_check_mark: | The request object to use for the request. | | `opts` | [][operations.Option](../../models/operations/option.md) | :heavy_minus_sign: | The options for this request. | - ### Response **[*operations.ListKeysResponse](../../models/operations/listkeysresponse.md), error** + +### Errors + | Error Object | Status Code | Content Type | | -------------------------------- | -------------------------------- | -------------------------------- | | sdkerrors.ErrBadRequest | 400 | application/json | @@ -181,6 +185,7 @@ func main() { | sdkerrors.ErrInternalServerError | 500 | application/json | | sdkerrors.SDKError | 4xx-5xx | */* | + ## DeleteAPI ### Example Usage @@ -190,8 +195,8 @@ package main import( unkeygo "github.com/unkeyed/unkey-go" - "github.com/unkeyed/unkey-go/models/operations" "context" + "github.com/unkeyed/unkey-go/models/operations" "log" ) @@ -199,11 +204,11 @@ func main() { s := unkeygo.New( unkeygo.WithSecurity(""), ) - request := operations.DeleteAPIRequestBody{ - APIID: "api_1234", - } + ctx := context.Background() - res, err := s.Apis.DeleteAPI(ctx, request) + res, err := s.Apis.DeleteAPI(ctx, operations.DeleteAPIRequestBody{ + APIID: "api_1234", + }) if err != nil { log.Fatal(err) } @@ -213,8 +218,6 @@ func main() { } ``` - - ### Parameters | Parameter | Type | Required | Description | @@ -223,10 +226,12 @@ func main() { | `request` | [operations.DeleteAPIRequestBody](../../models/operations/deleteapirequestbody.md) | :heavy_check_mark: | The request object to use for the request. | | `opts` | [][operations.Option](../../models/operations/option.md) | :heavy_minus_sign: | The options for this request. | - ### Response **[*operations.DeleteAPIResponse](../../models/operations/deleteapiresponse.md), error** + +### Errors + | Error Object | Status Code | Content Type | | -------------------------------- | -------------------------------- | -------------------------------- | | sdkerrors.ErrBadRequest | 400 | application/json | @@ -238,6 +243,7 @@ func main() { | sdkerrors.ErrInternalServerError | 500 | application/json | | sdkerrors.SDKError | 4xx-5xx | */* | + ## DeleteKeys ### Example Usage @@ -247,8 +253,8 @@ package main import( unkeygo "github.com/unkeyed/unkey-go" - "github.com/unkeyed/unkey-go/models/operations" "context" + "github.com/unkeyed/unkey-go/models/operations" "log" ) @@ -256,11 +262,11 @@ func main() { s := unkeygo.New( unkeygo.WithSecurity(""), ) - request := operations.DeleteKeysRequestBody{ - APIID: "api_1234", - } + ctx := context.Background() - res, err := s.Apis.DeleteKeys(ctx, request) + res, err := s.Apis.DeleteKeys(ctx, operations.DeleteKeysRequestBody{ + APIID: "api_1234", + }) if err != nil { log.Fatal(err) } @@ -270,8 +276,6 @@ func main() { } ``` - - ### Parameters | Parameter | Type | Required | Description | @@ -280,10 +284,12 @@ func main() { | `request` | [operations.DeleteKeysRequestBody](../../models/operations/deletekeysrequestbody.md) | :heavy_check_mark: | The request object to use for the request. | | `opts` | [][operations.Option](../../models/operations/option.md) | :heavy_minus_sign: | The options for this request. | - ### Response **[*operations.DeleteKeysResponse](../../models/operations/deletekeysresponse.md), error** + +### Errors + | Error Object | Status Code | Content Type | | -------------------------------- | -------------------------------- | -------------------------------- | | sdkerrors.ErrBadRequest | 400 | application/json | diff --git a/docs/sdks/identities/README.md b/docs/sdks/identities/README.md index 8e115e4..2358782 100644 --- a/docs/sdks/identities/README.md +++ b/docs/sdks/identities/README.md @@ -1,6 +1,8 @@ # Identities (*Identities*) +## Overview + ### Available Operations * [CreateIdentity](#createidentity) @@ -18,8 +20,8 @@ package main import( unkeygo "github.com/unkeyed/unkey-go" - "github.com/unkeyed/unkey-go/models/operations" "context" + "github.com/unkeyed/unkey-go/models/operations" "log" ) @@ -27,7 +29,9 @@ func main() { s := unkeygo.New( unkeygo.WithSecurity(""), ) - request := operations.CreateIdentityRequestBody{ + + ctx := context.Background() + res, err := s.Identities.CreateIdentity(ctx, operations.CreateIdentityRequestBody{ ExternalID: "user_123", Ratelimits: []operations.Ratelimits{ operations.Ratelimits{ @@ -35,10 +39,13 @@ func main() { Limit: 10, Duration: 1000, }, + operations.Ratelimits{ + Name: "tokens", + Limit: 10, + Duration: 1000, + }, }, - } - ctx := context.Background() - res, err := s.Identities.CreateIdentity(ctx, request) + }) if err != nil { log.Fatal(err) } @@ -48,8 +55,6 @@ func main() { } ``` - - ### Parameters | Parameter | Type | Required | Description | @@ -58,10 +63,12 @@ func main() { | `request` | [operations.CreateIdentityRequestBody](../../models/operations/createidentityrequestbody.md) | :heavy_check_mark: | The request object to use for the request. | | `opts` | [][operations.Option](../../models/operations/option.md) | :heavy_minus_sign: | The options for this request. | - ### Response **[*operations.CreateIdentityResponse](../../models/operations/createidentityresponse.md), error** + +### Errors + | Error Object | Status Code | Content Type | | -------------------------------- | -------------------------------- | -------------------------------- | | sdkerrors.ErrBadRequest | 400 | application/json | @@ -73,6 +80,7 @@ func main() { | sdkerrors.ErrInternalServerError | 500 | application/json | | sdkerrors.SDKError | 4xx-5xx | */* | + ## GetIdentity ### Example Usage @@ -82,8 +90,8 @@ package main import( unkeygo "github.com/unkeyed/unkey-go" - "github.com/unkeyed/unkey-go/models/operations" "context" + "github.com/unkeyed/unkey-go/models/operations" "log" ) @@ -91,12 +99,12 @@ func main() { s := unkeygo.New( unkeygo.WithSecurity(""), ) - request := operations.GetIdentityRequest{ + + ctx := context.Background() + res, err := s.Identities.GetIdentity(ctx, operations.GetIdentityRequest{ IdentityID: unkeygo.String("id_1234"), ExternalID: unkeygo.String("id_1234"), - } - ctx := context.Background() - res, err := s.Identities.GetIdentity(ctx, request) + }) if err != nil { log.Fatal(err) } @@ -106,8 +114,6 @@ func main() { } ``` - - ### Parameters | Parameter | Type | Required | Description | @@ -116,10 +122,12 @@ func main() { | `request` | [operations.GetIdentityRequest](../../models/operations/getidentityrequest.md) | :heavy_check_mark: | The request object to use for the request. | | `opts` | [][operations.Option](../../models/operations/option.md) | :heavy_minus_sign: | The options for this request. | - ### Response **[*operations.GetIdentityResponse](../../models/operations/getidentityresponse.md), error** + +### Errors + | Error Object | Status Code | Content Type | | -------------------------------- | -------------------------------- | -------------------------------- | | sdkerrors.ErrBadRequest | 400 | application/json | @@ -131,6 +139,7 @@ func main() { | sdkerrors.ErrInternalServerError | 500 | application/json | | sdkerrors.SDKError | 4xx-5xx | */* | + ## ListIdentities ### Example Usage @@ -140,8 +149,8 @@ package main import( unkeygo "github.com/unkeyed/unkey-go" - "github.com/unkeyed/unkey-go/models/operations" "context" + "github.com/unkeyed/unkey-go/models/operations" "log" ) @@ -149,11 +158,11 @@ func main() { s := unkeygo.New( unkeygo.WithSecurity(""), ) - request := operations.ListIdentitiesRequest{ - Limit: unkeygo.Int64(100), - } + ctx := context.Background() - res, err := s.Identities.ListIdentities(ctx, request) + res, err := s.Identities.ListIdentities(ctx, operations.ListIdentitiesRequest{ + Limit: unkeygo.Int64(100), + }) if err != nil { log.Fatal(err) } @@ -176,8 +185,6 @@ func main() { } ``` - - ### Parameters | Parameter | Type | Required | Description | @@ -186,10 +193,12 @@ func main() { | `request` | [operations.ListIdentitiesRequest](../../models/operations/listidentitiesrequest.md) | :heavy_check_mark: | The request object to use for the request. | | `opts` | [][operations.Option](../../models/operations/option.md) | :heavy_minus_sign: | The options for this request. | - ### Response **[*operations.ListIdentitiesResponse](../../models/operations/listidentitiesresponse.md), error** + +### Errors + | Error Object | Status Code | Content Type | | -------------------------------- | -------------------------------- | -------------------------------- | | sdkerrors.ErrBadRequest | 400 | application/json | @@ -201,6 +210,7 @@ func main() { | sdkerrors.ErrInternalServerError | 500 | application/json | | sdkerrors.SDKError | 4xx-5xx | */* | + ## UpdateIdentity ### Example Usage @@ -210,8 +220,8 @@ package main import( unkeygo "github.com/unkeyed/unkey-go" - "github.com/unkeyed/unkey-go/models/operations" "context" + "github.com/unkeyed/unkey-go/models/operations" "log" ) @@ -219,7 +229,9 @@ func main() { s := unkeygo.New( unkeygo.WithSecurity(""), ) - request := operations.UpdateIdentityRequestBody{ + + ctx := context.Background() + res, err := s.Identities.UpdateIdentity(ctx, operations.UpdateIdentityRequestBody{ IdentityID: unkeygo.String("id_1234"), ExternalID: unkeygo.String("user_1234"), Ratelimits: []operations.UpdateIdentityRatelimits{ @@ -228,10 +240,18 @@ func main() { Limit: 10, Duration: 1000, }, + operations.UpdateIdentityRatelimits{ + Name: "tokens", + Limit: 10, + Duration: 1000, + }, + operations.UpdateIdentityRatelimits{ + Name: "tokens", + Limit: 10, + Duration: 1000, + }, }, - } - ctx := context.Background() - res, err := s.Identities.UpdateIdentity(ctx, request) + }) if err != nil { log.Fatal(err) } @@ -241,8 +261,6 @@ func main() { } ``` - - ### Parameters | Parameter | Type | Required | Description | @@ -251,10 +269,12 @@ func main() { | `request` | [operations.UpdateIdentityRequestBody](../../models/operations/updateidentityrequestbody.md) | :heavy_check_mark: | The request object to use for the request. | | `opts` | [][operations.Option](../../models/operations/option.md) | :heavy_minus_sign: | The options for this request. | - ### Response **[*operations.UpdateIdentityResponse](../../models/operations/updateidentityresponse.md), error** + +### Errors + | Error Object | Status Code | Content Type | | -------------------------------- | -------------------------------- | -------------------------------- | | sdkerrors.ErrBadRequest | 400 | application/json | @@ -266,6 +286,7 @@ func main() { | sdkerrors.ErrInternalServerError | 500 | application/json | | sdkerrors.SDKError | 4xx-5xx | */* | + ## DeleteIdentity ### Example Usage @@ -275,8 +296,8 @@ package main import( unkeygo "github.com/unkeyed/unkey-go" - "github.com/unkeyed/unkey-go/models/operations" "context" + "github.com/unkeyed/unkey-go/models/operations" "log" ) @@ -284,11 +305,11 @@ func main() { s := unkeygo.New( unkeygo.WithSecurity(""), ) - request := operations.DeleteIdentityRequestBody{ - IdentityID: "id_1234", - } + ctx := context.Background() - res, err := s.Identities.DeleteIdentity(ctx, request) + res, err := s.Identities.DeleteIdentity(ctx, operations.DeleteIdentityRequestBody{ + IdentityID: "id_1234", + }) if err != nil { log.Fatal(err) } @@ -298,8 +319,6 @@ func main() { } ``` - - ### Parameters | Parameter | Type | Required | Description | @@ -308,10 +327,12 @@ func main() { | `request` | [operations.DeleteIdentityRequestBody](../../models/operations/deleteidentityrequestbody.md) | :heavy_check_mark: | The request object to use for the request. | | `opts` | [][operations.Option](../../models/operations/option.md) | :heavy_minus_sign: | The options for this request. | - ### Response **[*operations.DeleteIdentityResponse](../../models/operations/deleteidentityresponse.md), error** + +### Errors + | Error Object | Status Code | Content Type | | -------------------------------- | -------------------------------- | -------------------------------- | | sdkerrors.ErrBadRequest | 400 | application/json | diff --git a/docs/sdks/keys/README.md b/docs/sdks/keys/README.md index ad519c5..105ec9a 100644 --- a/docs/sdks/keys/README.md +++ b/docs/sdks/keys/README.md @@ -1,6 +1,8 @@ # Keys (*Keys*) +## Overview + ### Available Operations * [GetKey](#getkey) @@ -26,8 +28,8 @@ package main import( unkeygo "github.com/unkeyed/unkey-go" - "github.com/unkeyed/unkey-go/models/operations" "context" + "github.com/unkeyed/unkey-go/models/operations" "log" ) @@ -35,11 +37,11 @@ func main() { s := unkeygo.New( unkeygo.WithSecurity(""), ) - request := operations.GetKeyRequest{ - KeyID: "key_1234", - } + ctx := context.Background() - res, err := s.Keys.GetKey(ctx, request) + res, err := s.Keys.GetKey(ctx, operations.GetKeyRequest{ + KeyID: "key_1234", + }) if err != nil { log.Fatal(err) } @@ -49,8 +51,6 @@ func main() { } ``` - - ### Parameters | Parameter | Type | Required | Description | @@ -59,10 +59,12 @@ func main() { | `request` | [operations.GetKeyRequest](../../models/operations/getkeyrequest.md) | :heavy_check_mark: | The request object to use for the request. | | `opts` | [][operations.Option](../../models/operations/option.md) | :heavy_minus_sign: | The options for this request. | - ### Response **[*operations.GetKeyResponse](../../models/operations/getkeyresponse.md), error** + +### Errors + | Error Object | Status Code | Content Type | | -------------------------------- | -------------------------------- | -------------------------------- | | sdkerrors.ErrBadRequest | 400 | application/json | @@ -74,6 +76,7 @@ func main() { | sdkerrors.ErrInternalServerError | 500 | application/json | | sdkerrors.SDKError | 4xx-5xx | */* | + ## DeleteKey ### Example Usage @@ -83,8 +86,8 @@ package main import( unkeygo "github.com/unkeyed/unkey-go" - "github.com/unkeyed/unkey-go/models/operations" "context" + "github.com/unkeyed/unkey-go/models/operations" "log" ) @@ -92,11 +95,11 @@ func main() { s := unkeygo.New( unkeygo.WithSecurity(""), ) - request := operations.DeleteKeyRequestBody{ - KeyID: "key_1234", - } + ctx := context.Background() - res, err := s.Keys.DeleteKey(ctx, request) + res, err := s.Keys.DeleteKey(ctx, operations.DeleteKeyRequestBody{ + KeyID: "key_1234", + }) if err != nil { log.Fatal(err) } @@ -106,8 +109,6 @@ func main() { } ``` - - ### Parameters | Parameter | Type | Required | Description | @@ -116,10 +117,12 @@ func main() { | `request` | [operations.DeleteKeyRequestBody](../../models/operations/deletekeyrequestbody.md) | :heavy_check_mark: | The request object to use for the request. | | `opts` | [][operations.Option](../../models/operations/option.md) | :heavy_minus_sign: | The options for this request. | - ### Response **[*operations.DeleteKeyResponse](../../models/operations/deletekeyresponse.md), error** + +### Errors + | Error Object | Status Code | Content Type | | -------------------------------- | -------------------------------- | -------------------------------- | | sdkerrors.ErrBadRequest | 400 | application/json | @@ -131,6 +134,7 @@ func main() { | sdkerrors.ErrInternalServerError | 500 | application/json | | sdkerrors.SDKError | 4xx-5xx | */* | + ## CreateKey ### Example Usage @@ -140,8 +144,8 @@ package main import( unkeygo "github.com/unkeyed/unkey-go" - "github.com/unkeyed/unkey-go/models/operations" "context" + "github.com/unkeyed/unkey-go/models/operations" "log" ) @@ -149,7 +153,9 @@ func main() { s := unkeygo.New( unkeygo.WithSecurity(""), ) - request := operations.CreateKeyRequestBody{ + + ctx := context.Background() + res, err := s.Keys.CreateKey(ctx, operations.CreateKeyRequestBody{ APIID: "api_123", Name: unkeygo.String("my key"), ExternalID: unkeygo.String("team_123"), @@ -177,9 +183,7 @@ func main() { Duration: unkeygo.Int64(60000), }, Enabled: unkeygo.Bool(false), - } - ctx := context.Background() - res, err := s.Keys.CreateKey(ctx, request) + }) if err != nil { log.Fatal(err) } @@ -189,8 +193,6 @@ func main() { } ``` - - ### Parameters | Parameter | Type | Required | Description | @@ -199,10 +201,12 @@ func main() { | `request` | [operations.CreateKeyRequestBody](../../models/operations/createkeyrequestbody.md) | :heavy_check_mark: | The request object to use for the request. | | `opts` | [][operations.Option](../../models/operations/option.md) | :heavy_minus_sign: | The options for this request. | - ### Response **[*operations.CreateKeyResponse](../../models/operations/createkeyresponse.md), error** + +### Errors + | Error Object | Status Code | Content Type | | -------------------------------- | -------------------------------- | -------------------------------- | | sdkerrors.ErrBadRequest | 400 | application/json | @@ -214,6 +218,7 @@ func main() { | sdkerrors.ErrInternalServerError | 500 | application/json | | sdkerrors.SDKError | 4xx-5xx | */* | + ## VerifyKey ### Example Usage @@ -223,8 +228,8 @@ package main import( unkeygo "github.com/unkeyed/unkey-go" - "github.com/unkeyed/unkey-go/models/components" "context" + "github.com/unkeyed/unkey-go/models/components" "log" ) @@ -232,12 +237,14 @@ func main() { s := unkeygo.New( unkeygo.WithSecurity(""), ) - request := components.V1KeysVerifyKeyRequest{ + + ctx := context.Background() + res, err := s.Keys.VerifyKey(ctx, components.V1KeysVerifyKeyRequest{ APIID: unkeygo.String("api_1234"), Key: "sk_1234", Ratelimits: []components.Ratelimits{ components.Ratelimits{ - Name: "requests", + Name: "tokens", Limit: unkeygo.Int64(500), Duration: unkeygo.Int64(3600000), }, @@ -247,9 +254,7 @@ func main() { Duration: unkeygo.Int64(86400000), }, }, - } - ctx := context.Background() - res, err := s.Keys.VerifyKey(ctx, request) + }) if err != nil { log.Fatal(err) } @@ -259,8 +264,6 @@ func main() { } ``` - - ### Parameters | Parameter | Type | Required | Description | @@ -269,10 +272,12 @@ func main() { | `request` | [components.V1KeysVerifyKeyRequest](../../models/components/v1keysverifykeyrequest.md) | :heavy_check_mark: | The request object to use for the request. | | `opts` | [][operations.Option](../../models/operations/option.md) | :heavy_minus_sign: | The options for this request. | - ### Response **[*operations.VerifyKeyResponse](../../models/operations/verifykeyresponse.md), error** + +### Errors + | Error Object | Status Code | Content Type | | -------------------------------- | -------------------------------- | -------------------------------- | | sdkerrors.ErrBadRequest | 400 | application/json | @@ -284,6 +289,7 @@ func main() { | sdkerrors.ErrInternalServerError | 500 | application/json | | sdkerrors.SDKError | 4xx-5xx | */* | + ## UpdateKey ### Example Usage @@ -293,8 +299,8 @@ package main import( unkeygo "github.com/unkeyed/unkey-go" - "github.com/unkeyed/unkey-go/models/operations" "context" + "github.com/unkeyed/unkey-go/models/operations" "log" ) @@ -302,10 +308,12 @@ func main() { s := unkeygo.New( unkeygo.WithSecurity(""), ) - request := operations.UpdateKeyRequestBody{ + + ctx := context.Background() + res, err := s.Keys.UpdateKey(ctx, operations.UpdateKeyRequestBody{ KeyID: "key_123", Name: unkeygo.String("Customer X"), - OwnerID: unkeygo.String("user_123"), + ExternalID: unkeygo.String("user_123"), Meta: map[string]any{ "roles": []any{ "admin", @@ -350,9 +358,7 @@ func main() { Create: unkeygo.Bool(true), }, }, - } - ctx := context.Background() - res, err := s.Keys.UpdateKey(ctx, request) + }) if err != nil { log.Fatal(err) } @@ -362,8 +368,6 @@ func main() { } ``` - - ### Parameters | Parameter | Type | Required | Description | @@ -372,10 +376,12 @@ func main() { | `request` | [operations.UpdateKeyRequestBody](../../models/operations/updatekeyrequestbody.md) | :heavy_check_mark: | The request object to use for the request. | | `opts` | [][operations.Option](../../models/operations/option.md) | :heavy_minus_sign: | The options for this request. | - ### Response **[*operations.UpdateKeyResponse](../../models/operations/updatekeyresponse.md), error** + +### Errors + | Error Object | Status Code | Content Type | | -------------------------------- | -------------------------------- | -------------------------------- | | sdkerrors.ErrBadRequest | 400 | application/json | @@ -387,6 +393,7 @@ func main() { | sdkerrors.ErrInternalServerError | 500 | application/json | | sdkerrors.SDKError | 4xx-5xx | */* | + ## UpdateRemaining ### Example Usage @@ -396,8 +403,8 @@ package main import( unkeygo "github.com/unkeyed/unkey-go" - "github.com/unkeyed/unkey-go/models/operations" "context" + "github.com/unkeyed/unkey-go/models/operations" "log" ) @@ -405,13 +412,13 @@ func main() { s := unkeygo.New( unkeygo.WithSecurity(""), ) - request := operations.UpdateRemainingRequestBody{ + + ctx := context.Background() + res, err := s.Keys.UpdateRemaining(ctx, operations.UpdateRemainingRequestBody{ KeyID: "key_123", Op: operations.OpSet, Value: unkeygo.Int64(1), - } - ctx := context.Background() - res, err := s.Keys.UpdateRemaining(ctx, request) + }) if err != nil { log.Fatal(err) } @@ -421,8 +428,6 @@ func main() { } ``` - - ### Parameters | Parameter | Type | Required | Description | @@ -431,10 +436,12 @@ func main() { | `request` | [operations.UpdateRemainingRequestBody](../../models/operations/updateremainingrequestbody.md) | :heavy_check_mark: | The request object to use for the request. | | `opts` | [][operations.Option](../../models/operations/option.md) | :heavy_minus_sign: | The options for this request. | - ### Response **[*operations.UpdateRemainingResponse](../../models/operations/updateremainingresponse.md), error** + +### Errors + | Error Object | Status Code | Content Type | | -------------------------------- | -------------------------------- | -------------------------------- | | sdkerrors.ErrBadRequest | 400 | application/json | @@ -446,6 +453,7 @@ func main() { | sdkerrors.ErrInternalServerError | 500 | application/json | | sdkerrors.SDKError | 4xx-5xx | */* | + ## GetVerifications ### Example Usage @@ -455,8 +463,8 @@ package main import( unkeygo "github.com/unkeyed/unkey-go" - "github.com/unkeyed/unkey-go/models/operations" "context" + "github.com/unkeyed/unkey-go/models/operations" "log" ) @@ -464,15 +472,15 @@ func main() { s := unkeygo.New( unkeygo.WithSecurity(""), ) - request := operations.GetVerificationsRequest{ + + ctx := context.Background() + res, err := s.Keys.GetVerifications(ctx, operations.GetVerificationsRequest{ KeyID: unkeygo.String("key_1234"), OwnerID: unkeygo.String("chronark"), Start: unkeygo.Int64(1620000000000), End: unkeygo.Int64(1620000000000), Granularity: operations.GranularityDay.ToPointer(), - } - ctx := context.Background() - res, err := s.Keys.GetVerifications(ctx, request) + }) if err != nil { log.Fatal(err) } @@ -482,8 +490,6 @@ func main() { } ``` - - ### Parameters | Parameter | Type | Required | Description | @@ -492,10 +498,12 @@ func main() { | `request` | [operations.GetVerificationsRequest](../../models/operations/getverificationsrequest.md) | :heavy_check_mark: | The request object to use for the request. | | `opts` | [][operations.Option](../../models/operations/option.md) | :heavy_minus_sign: | The options for this request. | - ### Response **[*operations.GetVerificationsResponse](../../models/operations/getverificationsresponse.md), error** + +### Errors + | Error Object | Status Code | Content Type | | -------------------------------- | -------------------------------- | -------------------------------- | | sdkerrors.ErrBadRequest | 400 | application/json | @@ -507,6 +515,7 @@ func main() { | sdkerrors.ErrInternalServerError | 500 | application/json | | sdkerrors.SDKError | 4xx-5xx | */* | + ## AddPermissions ### Example Usage @@ -516,8 +525,8 @@ package main import( unkeygo "github.com/unkeyed/unkey-go" - "github.com/unkeyed/unkey-go/models/operations" "context" + "github.com/unkeyed/unkey-go/models/operations" "log" ) @@ -525,14 +534,14 @@ func main() { s := unkeygo.New( unkeygo.WithSecurity(""), ) - request := operations.AddPermissionsRequestBody{ + + ctx := context.Background() + res, err := s.Keys.AddPermissions(ctx, operations.AddPermissionsRequestBody{ KeyID: "", Permissions: []operations.AddPermissionsPermissions{ operations.AddPermissionsPermissions{}, }, - } - ctx := context.Background() - res, err := s.Keys.AddPermissions(ctx, request) + }) if err != nil { log.Fatal(err) } @@ -542,8 +551,6 @@ func main() { } ``` - - ### Parameters | Parameter | Type | Required | Description | @@ -552,10 +559,12 @@ func main() { | `request` | [operations.AddPermissionsRequestBody](../../models/operations/addpermissionsrequestbody.md) | :heavy_check_mark: | The request object to use for the request. | | `opts` | [][operations.Option](../../models/operations/option.md) | :heavy_minus_sign: | The options for this request. | - ### Response **[*operations.AddPermissionsResponse](../../models/operations/addpermissionsresponse.md), error** + +### Errors + | Error Object | Status Code | Content Type | | -------------------------------- | -------------------------------- | -------------------------------- | | sdkerrors.ErrBadRequest | 400 | application/json | @@ -567,6 +576,7 @@ func main() { | sdkerrors.ErrInternalServerError | 500 | application/json | | sdkerrors.SDKError | 4xx-5xx | */* | + ## RemovePermissions ### Example Usage @@ -576,8 +586,8 @@ package main import( unkeygo "github.com/unkeyed/unkey-go" - "github.com/unkeyed/unkey-go/models/operations" "context" + "github.com/unkeyed/unkey-go/models/operations" "log" ) @@ -585,7 +595,9 @@ func main() { s := unkeygo.New( unkeygo.WithSecurity(""), ) - request := operations.RemovePermissionsRequestBody{ + + ctx := context.Background() + res, err := s.Keys.RemovePermissions(ctx, operations.RemovePermissionsRequestBody{ KeyID: "", Permissions: []operations.RemovePermissionsPermissions{ operations.RemovePermissionsPermissions{ @@ -595,9 +607,7 @@ func main() { Name: unkeygo.String("dns.record.create"), }, }, - } - ctx := context.Background() - res, err := s.Keys.RemovePermissions(ctx, request) + }) if err != nil { log.Fatal(err) } @@ -607,8 +617,6 @@ func main() { } ``` - - ### Parameters | Parameter | Type | Required | Description | @@ -617,10 +625,12 @@ func main() { | `request` | [operations.RemovePermissionsRequestBody](../../models/operations/removepermissionsrequestbody.md) | :heavy_check_mark: | The request object to use for the request. | | `opts` | [][operations.Option](../../models/operations/option.md) | :heavy_minus_sign: | The options for this request. | - ### Response **[*operations.RemovePermissionsResponse](../../models/operations/removepermissionsresponse.md), error** + +### Errors + | Error Object | Status Code | Content Type | | -------------------------------- | -------------------------------- | -------------------------------- | | sdkerrors.ErrBadRequest | 400 | application/json | @@ -632,6 +642,7 @@ func main() { | sdkerrors.ErrInternalServerError | 500 | application/json | | sdkerrors.SDKError | 4xx-5xx | */* | + ## SetPermissions ### Example Usage @@ -641,8 +652,8 @@ package main import( unkeygo "github.com/unkeyed/unkey-go" - "github.com/unkeyed/unkey-go/models/operations" "context" + "github.com/unkeyed/unkey-go/models/operations" "log" ) @@ -650,7 +661,9 @@ func main() { s := unkeygo.New( unkeygo.WithSecurity(""), ) - request := operations.SetPermissionsRequestBody{ + + ctx := context.Background() + res, err := s.Keys.SetPermissions(ctx, operations.SetPermissionsRequestBody{ KeyID: "", Permissions: []operations.SetPermissionsPermissions{ operations.SetPermissionsPermissions{ @@ -664,9 +677,7 @@ func main() { Create: unkeygo.Bool(true), }, }, - } - ctx := context.Background() - res, err := s.Keys.SetPermissions(ctx, request) + }) if err != nil { log.Fatal(err) } @@ -676,8 +687,6 @@ func main() { } ``` - - ### Parameters | Parameter | Type | Required | Description | @@ -686,10 +695,12 @@ func main() { | `request` | [operations.SetPermissionsRequestBody](../../models/operations/setpermissionsrequestbody.md) | :heavy_check_mark: | The request object to use for the request. | | `opts` | [][operations.Option](../../models/operations/option.md) | :heavy_minus_sign: | The options for this request. | - ### Response **[*operations.SetPermissionsResponse](../../models/operations/setpermissionsresponse.md), error** + +### Errors + | Error Object | Status Code | Content Type | | -------------------------------- | -------------------------------- | -------------------------------- | | sdkerrors.ErrBadRequest | 400 | application/json | @@ -701,6 +712,7 @@ func main() { | sdkerrors.ErrInternalServerError | 500 | application/json | | sdkerrors.SDKError | 4xx-5xx | */* | + ## AddRoles ### Example Usage @@ -710,8 +722,8 @@ package main import( unkeygo "github.com/unkeyed/unkey-go" - "github.com/unkeyed/unkey-go/models/operations" "context" + "github.com/unkeyed/unkey-go/models/operations" "log" ) @@ -719,7 +731,9 @@ func main() { s := unkeygo.New( unkeygo.WithSecurity(""), ) - request := operations.AddRolesRequestBody{ + + ctx := context.Background() + res, err := s.Keys.AddRoles(ctx, operations.AddRolesRequestBody{ KeyID: "", Roles: []operations.AddRolesRoles{ operations.AddRolesRoles{ @@ -733,9 +747,7 @@ func main() { Create: unkeygo.Bool(true), }, }, - } - ctx := context.Background() - res, err := s.Keys.AddRoles(ctx, request) + }) if err != nil { log.Fatal(err) } @@ -745,8 +757,6 @@ func main() { } ``` - - ### Parameters | Parameter | Type | Required | Description | @@ -755,10 +765,12 @@ func main() { | `request` | [operations.AddRolesRequestBody](../../models/operations/addrolesrequestbody.md) | :heavy_check_mark: | The request object to use for the request. | | `opts` | [][operations.Option](../../models/operations/option.md) | :heavy_minus_sign: | The options for this request. | - ### Response **[*operations.AddRolesResponse](../../models/operations/addrolesresponse.md), error** + +### Errors + | Error Object | Status Code | Content Type | | -------------------------------- | -------------------------------- | -------------------------------- | | sdkerrors.ErrBadRequest | 400 | application/json | @@ -770,6 +782,7 @@ func main() { | sdkerrors.ErrInternalServerError | 500 | application/json | | sdkerrors.SDKError | 4xx-5xx | */* | + ## RemoveRoles ### Example Usage @@ -779,8 +792,8 @@ package main import( unkeygo "github.com/unkeyed/unkey-go" - "github.com/unkeyed/unkey-go/models/operations" "context" + "github.com/unkeyed/unkey-go/models/operations" "log" ) @@ -788,7 +801,9 @@ func main() { s := unkeygo.New( unkeygo.WithSecurity(""), ) - request := operations.RemoveRolesRequestBody{ + + ctx := context.Background() + res, err := s.Keys.RemoveRoles(ctx, operations.RemoveRolesRequestBody{ KeyID: "", Roles: []operations.RemoveRolesRoles{ operations.RemoveRolesRoles{ @@ -798,9 +813,7 @@ func main() { Name: unkeygo.String("dns.record.create"), }, }, - } - ctx := context.Background() - res, err := s.Keys.RemoveRoles(ctx, request) + }) if err != nil { log.Fatal(err) } @@ -810,8 +823,6 @@ func main() { } ``` - - ### Parameters | Parameter | Type | Required | Description | @@ -820,10 +831,12 @@ func main() { | `request` | [operations.RemoveRolesRequestBody](../../models/operations/removerolesrequestbody.md) | :heavy_check_mark: | The request object to use for the request. | | `opts` | [][operations.Option](../../models/operations/option.md) | :heavy_minus_sign: | The options for this request. | - ### Response **[*operations.RemoveRolesResponse](../../models/operations/removerolesresponse.md), error** + +### Errors + | Error Object | Status Code | Content Type | | -------------------------------- | -------------------------------- | -------------------------------- | | sdkerrors.ErrBadRequest | 400 | application/json | @@ -835,6 +848,7 @@ func main() { | sdkerrors.ErrInternalServerError | 500 | application/json | | sdkerrors.SDKError | 4xx-5xx | */* | + ## SetRoles ### Example Usage @@ -844,8 +858,8 @@ package main import( unkeygo "github.com/unkeyed/unkey-go" - "github.com/unkeyed/unkey-go/models/operations" "context" + "github.com/unkeyed/unkey-go/models/operations" "log" ) @@ -853,7 +867,9 @@ func main() { s := unkeygo.New( unkeygo.WithSecurity(""), ) - request := operations.SetRolesRequestBody{ + + ctx := context.Background() + res, err := s.Keys.SetRoles(ctx, operations.SetRolesRequestBody{ KeyID: "", Roles: []operations.SetRolesRoles{ operations.SetRolesRoles{ @@ -867,9 +883,7 @@ func main() { Create: unkeygo.Bool(true), }, }, - } - ctx := context.Background() - res, err := s.Keys.SetRoles(ctx, request) + }) if err != nil { log.Fatal(err) } @@ -879,8 +893,6 @@ func main() { } ``` - - ### Parameters | Parameter | Type | Required | Description | @@ -889,10 +901,12 @@ func main() { | `request` | [operations.SetRolesRequestBody](../../models/operations/setrolesrequestbody.md) | :heavy_check_mark: | The request object to use for the request. | | `opts` | [][operations.Option](../../models/operations/option.md) | :heavy_minus_sign: | The options for this request. | - ### Response **[*operations.SetRolesResponse](../../models/operations/setrolesresponse.md), error** + +### Errors + | Error Object | Status Code | Content Type | | -------------------------------- | -------------------------------- | -------------------------------- | | sdkerrors.ErrBadRequest | 400 | application/json | diff --git a/docs/sdks/liveness/README.md b/docs/sdks/liveness/README.md index 9e65276..556a30e 100644 --- a/docs/sdks/liveness/README.md +++ b/docs/sdks/liveness/README.md @@ -1,6 +1,8 @@ # Liveness (*Liveness*) +## Overview + ### Available Operations * [V1Liveness](#v1liveness) @@ -34,8 +36,6 @@ func main() { } ``` - - ### Parameters | Parameter | Type | Required | Description | @@ -43,10 +43,12 @@ func main() { | `ctx` | [context.Context](https://pkg.go.dev/context#Context) | :heavy_check_mark: | The context to use for the request. | | `opts` | [][operations.Option](../../models/operations/option.md) | :heavy_minus_sign: | The options for this request. | - ### Response **[*operations.V1LivenessResponse](../../models/operations/v1livenessresponse.md), error** + +### Errors + | Error Object | Status Code | Content Type | | -------------------------------- | -------------------------------- | -------------------------------- | | sdkerrors.ErrBadRequest | 400 | application/json | diff --git a/docs/sdks/migrations/README.md b/docs/sdks/migrations/README.md index a78f975..ff37b03 100644 --- a/docs/sdks/migrations/README.md +++ b/docs/sdks/migrations/README.md @@ -1,6 +1,8 @@ # Migrations (*Migrations*) +## Overview + ### Available Operations * [V1MigrationsCreateKeys](#v1migrationscreatekeys) @@ -15,8 +17,8 @@ package main import( unkeygo "github.com/unkeyed/unkey-go" - "github.com/unkeyed/unkey-go/models/operations" "context" + "github.com/unkeyed/unkey-go/models/operations" "log" ) @@ -24,7 +26,9 @@ func main() { s := unkeygo.New( unkeygo.WithSecurity(""), ) - request := []operations.RequestBody{ + + ctx := context.Background() + res, err := s.Migrations.V1MigrationsCreateKeys(ctx, []operations.RequestBody{ operations.RequestBody{ APIID: "api_123", Name: unkeygo.String("my key"), @@ -56,9 +60,7 @@ func main() { }, Enabled: unkeygo.Bool(false), }, - } - ctx := context.Background() - res, err := s.Migrations.V1MigrationsCreateKeys(ctx, request) + }) if err != nil { log.Fatal(err) } @@ -68,8 +70,6 @@ func main() { } ``` - - ### Parameters | Parameter | Type | Required | Description | @@ -78,10 +78,12 @@ func main() { | `request` | [[]operations.RequestBody](../../.md) | :heavy_check_mark: | The request object to use for the request. | | `opts` | [][operations.Option](../../models/operations/option.md) | :heavy_minus_sign: | The options for this request. | - ### Response **[*operations.V1MigrationsCreateKeysResponse](../../models/operations/v1migrationscreatekeysresponse.md), error** + +### Errors + | Error Object | Status Code | Content Type | | -------------------------------- | -------------------------------- | -------------------------------- | | sdkerrors.ErrBadRequest | 400 | application/json | @@ -93,6 +95,7 @@ func main() { | sdkerrors.ErrInternalServerError | 500 | application/json | | sdkerrors.SDKError | 4xx-5xx | */* | + ## V1MigrationsEnqueueKeys ### Example Usage @@ -102,8 +105,8 @@ package main import( unkeygo "github.com/unkeyed/unkey-go" - "github.com/unkeyed/unkey-go/models/operations" "context" + "github.com/unkeyed/unkey-go/models/operations" "log" ) @@ -111,7 +114,9 @@ func main() { s := unkeygo.New( unkeygo.WithSecurity(""), ) - request := operations.V1MigrationsEnqueueKeysRequestBody{ + + ctx := context.Background() + res, err := s.Migrations.V1MigrationsEnqueueKeys(ctx, operations.V1MigrationsEnqueueKeysRequestBody{ MigrationID: "", APIID: "", Keys: []operations.Keys{ @@ -145,9 +150,7 @@ func main() { Enabled: unkeygo.Bool(false), }, }, - } - ctx := context.Background() - res, err := s.Migrations.V1MigrationsEnqueueKeys(ctx, request) + }) if err != nil { log.Fatal(err) } @@ -157,8 +160,6 @@ func main() { } ``` - - ### Parameters | Parameter | Type | Required | Description | @@ -167,10 +168,12 @@ func main() { | `request` | [operations.V1MigrationsEnqueueKeysRequestBody](../../models/operations/v1migrationsenqueuekeysrequestbody.md) | :heavy_check_mark: | The request object to use for the request. | | `opts` | [][operations.Option](../../models/operations/option.md) | :heavy_minus_sign: | The options for this request. | - ### Response **[*operations.V1MigrationsEnqueueKeysResponse](../../models/operations/v1migrationsenqueuekeysresponse.md), error** + +### Errors + | Error Object | Status Code | Content Type | | -------------------------------- | -------------------------------- | -------------------------------- | | sdkerrors.ErrBadRequest | 400 | application/json | diff --git a/docs/sdks/permissions/README.md b/docs/sdks/permissions/README.md index 186d72c..9116068 100644 --- a/docs/sdks/permissions/README.md +++ b/docs/sdks/permissions/README.md @@ -1,6 +1,8 @@ # Permissions (*Permissions*) +## Overview + ### Available Operations * [CreatePermission](#createpermission) @@ -21,8 +23,8 @@ package main import( unkeygo "github.com/unkeyed/unkey-go" - "github.com/unkeyed/unkey-go/models/operations" "context" + "github.com/unkeyed/unkey-go/models/operations" "log" ) @@ -30,12 +32,12 @@ func main() { s := unkeygo.New( unkeygo.WithSecurity(""), ) - request := operations.CreatePermissionRequestBody{ + + ctx := context.Background() + res, err := s.Permissions.CreatePermission(ctx, operations.CreatePermissionRequestBody{ Name: "record.write", Description: unkeygo.String("record.write can create new dns records for our domains."), - } - ctx := context.Background() - res, err := s.Permissions.CreatePermission(ctx, request) + }) if err != nil { log.Fatal(err) } @@ -45,8 +47,6 @@ func main() { } ``` - - ### Parameters | Parameter | Type | Required | Description | @@ -55,10 +55,12 @@ func main() { | `request` | [operations.CreatePermissionRequestBody](../../models/operations/createpermissionrequestbody.md) | :heavy_check_mark: | The request object to use for the request. | | `opts` | [][operations.Option](../../models/operations/option.md) | :heavy_minus_sign: | The options for this request. | - ### Response **[*operations.CreatePermissionResponse](../../models/operations/createpermissionresponse.md), error** + +### Errors + | Error Object | Status Code | Content Type | | -------------------------------- | -------------------------------- | -------------------------------- | | sdkerrors.ErrBadRequest | 400 | application/json | @@ -70,6 +72,7 @@ func main() { | sdkerrors.ErrInternalServerError | 500 | application/json | | sdkerrors.SDKError | 4xx-5xx | */* | + ## DeletePermission ### Example Usage @@ -79,8 +82,8 @@ package main import( unkeygo "github.com/unkeyed/unkey-go" - "github.com/unkeyed/unkey-go/models/operations" "context" + "github.com/unkeyed/unkey-go/models/operations" "log" ) @@ -88,11 +91,11 @@ func main() { s := unkeygo.New( unkeygo.WithSecurity(""), ) - request := operations.DeletePermissionRequestBody{ - PermissionID: "perm_123", - } + ctx := context.Background() - res, err := s.Permissions.DeletePermission(ctx, request) + res, err := s.Permissions.DeletePermission(ctx, operations.DeletePermissionRequestBody{ + PermissionID: "perm_123", + }) if err != nil { log.Fatal(err) } @@ -102,8 +105,6 @@ func main() { } ``` - - ### Parameters | Parameter | Type | Required | Description | @@ -112,10 +113,12 @@ func main() { | `request` | [operations.DeletePermissionRequestBody](../../models/operations/deletepermissionrequestbody.md) | :heavy_check_mark: | The request object to use for the request. | | `opts` | [][operations.Option](../../models/operations/option.md) | :heavy_minus_sign: | The options for this request. | - ### Response **[*operations.DeletePermissionResponse](../../models/operations/deletepermissionresponse.md), error** + +### Errors + | Error Object | Status Code | Content Type | | -------------------------------- | -------------------------------- | -------------------------------- | | sdkerrors.ErrBadRequest | 400 | application/json | @@ -127,6 +130,7 @@ func main() { | sdkerrors.ErrInternalServerError | 500 | application/json | | sdkerrors.SDKError | 4xx-5xx | */* | + ## GetPermission ### Example Usage @@ -136,8 +140,8 @@ package main import( unkeygo "github.com/unkeyed/unkey-go" - "github.com/unkeyed/unkey-go/models/operations" "context" + "github.com/unkeyed/unkey-go/models/operations" "log" ) @@ -145,11 +149,11 @@ func main() { s := unkeygo.New( unkeygo.WithSecurity(""), ) - request := operations.GetPermissionRequest{ - PermissionID: "perm_123", - } + ctx := context.Background() - res, err := s.Permissions.GetPermission(ctx, request) + res, err := s.Permissions.GetPermission(ctx, operations.GetPermissionRequest{ + PermissionID: "perm_123", + }) if err != nil { log.Fatal(err) } @@ -159,8 +163,6 @@ func main() { } ``` - - ### Parameters | Parameter | Type | Required | Description | @@ -169,10 +171,12 @@ func main() { | `request` | [operations.GetPermissionRequest](../../models/operations/getpermissionrequest.md) | :heavy_check_mark: | The request object to use for the request. | | `opts` | [][operations.Option](../../models/operations/option.md) | :heavy_minus_sign: | The options for this request. | - ### Response **[*operations.GetPermissionResponse](../../models/operations/getpermissionresponse.md), error** + +### Errors + | Error Object | Status Code | Content Type | | -------------------------------- | -------------------------------- | -------------------------------- | | sdkerrors.ErrBadRequest | 400 | application/json | @@ -184,6 +188,7 @@ func main() { | sdkerrors.ErrInternalServerError | 500 | application/json | | sdkerrors.SDKError | 4xx-5xx | */* | + ## ListPermissions ### Example Usage @@ -213,8 +218,6 @@ func main() { } ``` - - ### Parameters | Parameter | Type | Required | Description | @@ -222,10 +225,12 @@ func main() { | `ctx` | [context.Context](https://pkg.go.dev/context#Context) | :heavy_check_mark: | The context to use for the request. | | `opts` | [][operations.Option](../../models/operations/option.md) | :heavy_minus_sign: | The options for this request. | - ### Response **[*operations.ListPermissionsResponse](../../models/operations/listpermissionsresponse.md), error** + +### Errors + | Error Object | Status Code | Content Type | | -------------------------------- | -------------------------------- | -------------------------------- | | sdkerrors.ErrBadRequest | 400 | application/json | @@ -237,6 +242,7 @@ func main() { | sdkerrors.ErrInternalServerError | 500 | application/json | | sdkerrors.SDKError | 4xx-5xx | */* | + ## CreateRole ### Example Usage @@ -246,8 +252,8 @@ package main import( unkeygo "github.com/unkeyed/unkey-go" - "github.com/unkeyed/unkey-go/models/operations" "context" + "github.com/unkeyed/unkey-go/models/operations" "log" ) @@ -255,12 +261,12 @@ func main() { s := unkeygo.New( unkeygo.WithSecurity(""), ) - request := operations.CreateRoleRequestBody{ + + ctx := context.Background() + res, err := s.Permissions.CreateRole(ctx, operations.CreateRoleRequestBody{ Name: "dns.records.manager", Description: unkeygo.String("dns.records.manager can read and write dns records for our domains."), - } - ctx := context.Background() - res, err := s.Permissions.CreateRole(ctx, request) + }) if err != nil { log.Fatal(err) } @@ -270,8 +276,6 @@ func main() { } ``` - - ### Parameters | Parameter | Type | Required | Description | @@ -280,10 +284,12 @@ func main() { | `request` | [operations.CreateRoleRequestBody](../../models/operations/createrolerequestbody.md) | :heavy_check_mark: | The request object to use for the request. | | `opts` | [][operations.Option](../../models/operations/option.md) | :heavy_minus_sign: | The options for this request. | - ### Response **[*operations.CreateRoleResponse](../../models/operations/createroleresponse.md), error** + +### Errors + | Error Object | Status Code | Content Type | | -------------------------------- | -------------------------------- | -------------------------------- | | sdkerrors.ErrBadRequest | 400 | application/json | @@ -295,6 +301,7 @@ func main() { | sdkerrors.ErrInternalServerError | 500 | application/json | | sdkerrors.SDKError | 4xx-5xx | */* | + ## DeleteRole ### Example Usage @@ -304,8 +311,8 @@ package main import( unkeygo "github.com/unkeyed/unkey-go" - "github.com/unkeyed/unkey-go/models/operations" "context" + "github.com/unkeyed/unkey-go/models/operations" "log" ) @@ -313,11 +320,11 @@ func main() { s := unkeygo.New( unkeygo.WithSecurity(""), ) - request := operations.DeleteRoleRequestBody{ - RoleID: "role_123", - } + ctx := context.Background() - res, err := s.Permissions.DeleteRole(ctx, request) + res, err := s.Permissions.DeleteRole(ctx, operations.DeleteRoleRequestBody{ + RoleID: "role_123", + }) if err != nil { log.Fatal(err) } @@ -327,8 +334,6 @@ func main() { } ``` - - ### Parameters | Parameter | Type | Required | Description | @@ -337,10 +342,12 @@ func main() { | `request` | [operations.DeleteRoleRequestBody](../../models/operations/deleterolerequestbody.md) | :heavy_check_mark: | The request object to use for the request. | | `opts` | [][operations.Option](../../models/operations/option.md) | :heavy_minus_sign: | The options for this request. | - ### Response **[*operations.DeleteRoleResponse](../../models/operations/deleteroleresponse.md), error** + +### Errors + | Error Object | Status Code | Content Type | | -------------------------------- | -------------------------------- | -------------------------------- | | sdkerrors.ErrBadRequest | 400 | application/json | @@ -352,6 +359,7 @@ func main() { | sdkerrors.ErrInternalServerError | 500 | application/json | | sdkerrors.SDKError | 4xx-5xx | */* | + ## GetRole ### Example Usage @@ -361,8 +369,8 @@ package main import( unkeygo "github.com/unkeyed/unkey-go" - "github.com/unkeyed/unkey-go/models/operations" "context" + "github.com/unkeyed/unkey-go/models/operations" "log" ) @@ -370,11 +378,11 @@ func main() { s := unkeygo.New( unkeygo.WithSecurity(""), ) - request := operations.GetRoleRequest{ - RoleID: "role_123", - } + ctx := context.Background() - res, err := s.Permissions.GetRole(ctx, request) + res, err := s.Permissions.GetRole(ctx, operations.GetRoleRequest{ + RoleID: "role_123", + }) if err != nil { log.Fatal(err) } @@ -384,8 +392,6 @@ func main() { } ``` - - ### Parameters | Parameter | Type | Required | Description | @@ -394,10 +400,12 @@ func main() { | `request` | [operations.GetRoleRequest](../../models/operations/getrolerequest.md) | :heavy_check_mark: | The request object to use for the request. | | `opts` | [][operations.Option](../../models/operations/option.md) | :heavy_minus_sign: | The options for this request. | - ### Response **[*operations.GetRoleResponse](../../models/operations/getroleresponse.md), error** + +### Errors + | Error Object | Status Code | Content Type | | -------------------------------- | -------------------------------- | -------------------------------- | | sdkerrors.ErrBadRequest | 400 | application/json | @@ -409,6 +417,7 @@ func main() { | sdkerrors.ErrInternalServerError | 500 | application/json | | sdkerrors.SDKError | 4xx-5xx | */* | + ## ListRoles ### Example Usage @@ -438,8 +447,6 @@ func main() { } ``` - - ### Parameters | Parameter | Type | Required | Description | @@ -447,10 +454,12 @@ func main() { | `ctx` | [context.Context](https://pkg.go.dev/context#Context) | :heavy_check_mark: | The context to use for the request. | | `opts` | [][operations.Option](../../models/operations/option.md) | :heavy_minus_sign: | The options for this request. | - ### Response **[*operations.ListRolesResponse](../../models/operations/listrolesresponse.md), error** + +### Errors + | Error Object | Status Code | Content Type | | -------------------------------- | -------------------------------- | -------------------------------- | | sdkerrors.ErrBadRequest | 400 | application/json | diff --git a/docs/sdks/ratelimits/README.md b/docs/sdks/ratelimits/README.md index 0d0f90a..57f3b37 100644 --- a/docs/sdks/ratelimits/README.md +++ b/docs/sdks/ratelimits/README.md @@ -1,6 +1,8 @@ # Ratelimits (*Ratelimits*) +## Overview + ### Available Operations * [Limit](#limit) @@ -14,8 +16,8 @@ package main import( unkeygo "github.com/unkeyed/unkey-go" - "github.com/unkeyed/unkey-go/models/operations" "context" + "github.com/unkeyed/unkey-go/models/operations" "log" ) @@ -23,7 +25,9 @@ func main() { s := unkeygo.New( unkeygo.WithSecurity(""), ) - request := operations.LimitRequestBody{ + + ctx := context.Background() + res, err := s.Ratelimits.Limit(ctx, operations.LimitRequestBody{ Namespace: unkeygo.String("email.outbound"), Identifier: "user_123", Limit: 10, @@ -31,14 +35,12 @@ func main() { Cost: unkeygo.Int64(2), Resources: []operations.Resources{ operations.Resources{ - Type: "project", - ID: "p_123", - Name: unkeygo.String("dub"), + Type: "organization", + ID: "org_123", + Name: unkeygo.String("unkey"), }, }, - } - ctx := context.Background() - res, err := s.Ratelimits.Limit(ctx, request) + }) if err != nil { log.Fatal(err) } @@ -48,8 +50,6 @@ func main() { } ``` - - ### Parameters | Parameter | Type | Required | Description | @@ -58,10 +58,12 @@ func main() { | `request` | [operations.LimitRequestBody](../../models/operations/limitrequestbody.md) | :heavy_check_mark: | The request object to use for the request. | | `opts` | [][operations.Option](../../models/operations/option.md) | :heavy_minus_sign: | The options for this request. | - ### Response **[*operations.LimitResponse](../../models/operations/limitresponse.md), error** + +### Errors + | Error Object | Status Code | Content Type | | -------------------------------- | -------------------------------- | -------------------------------- | | sdkerrors.ErrBadRequest | 400 | application/json | diff --git a/docs/sdks/unkey/README.md b/docs/sdks/unkey/README.md index 3af0971..8de2e7f 100644 --- a/docs/sdks/unkey/README.md +++ b/docs/sdks/unkey/README.md @@ -1,7 +1,3 @@ # Unkey SDK - -## Overview - -### Available Operations - +## Overview \ No newline at end of file diff --git a/identities.go b/identities.go index 124d41b..9f31f71 100644 --- a/identities.go +++ b/identities.go @@ -182,17 +182,25 @@ func (s *Identities) CreateIdentity(ctx context.Context, request operations.Crea }, } - rawBody, err := io.ReadAll(httpRes.Body) - if err != nil { - return nil, fmt.Errorf("error reading response body: %w", err) + getRawBody := func() ([]byte, error) { + 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)) + return rawBody, nil } - 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out operations.CreateIdentityResponseBody if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -200,11 +208,21 @@ func (s *Identities) CreateIdentity(ctx context.Context, request operations.Crea res.Object = &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrBadRequest if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -212,11 +230,21 @@ func (s *Identities) CreateIdentity(ctx context.Context, request operations.Crea return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrUnauthorized if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -224,11 +252,21 @@ func (s *Identities) CreateIdentity(ctx context.Context, request operations.Crea return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrForbidden if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -236,11 +274,21 @@ func (s *Identities) CreateIdentity(ctx context.Context, request operations.Crea return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrNotFound if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -248,11 +296,21 @@ func (s *Identities) CreateIdentity(ctx context.Context, request operations.Crea return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrConflict if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -260,11 +318,21 @@ func (s *Identities) CreateIdentity(ctx context.Context, request operations.Crea return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrTooManyRequests if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -272,11 +340,21 @@ func (s *Identities) CreateIdentity(ctx context.Context, request operations.Crea return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } case httpRes.StatusCode == 500: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrInternalServerError if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -284,13 +362,28 @@ func (s *Identities) CreateIdentity(ctx context.Context, request operations.Crea return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) } @@ -448,17 +541,25 @@ func (s *Identities) GetIdentity(ctx context.Context, request operations.GetIden }, } - rawBody, err := io.ReadAll(httpRes.Body) - if err != nil { - return nil, fmt.Errorf("error reading response body: %w", err) + getRawBody := func() ([]byte, error) { + 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)) + return rawBody, nil } - 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out operations.GetIdentityResponseBody if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -466,11 +567,21 @@ func (s *Identities) GetIdentity(ctx context.Context, request operations.GetIden res.Object = &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrBadRequest if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -478,11 +589,21 @@ func (s *Identities) GetIdentity(ctx context.Context, request operations.GetIden return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrUnauthorized if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -490,11 +611,21 @@ func (s *Identities) GetIdentity(ctx context.Context, request operations.GetIden return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrForbidden if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -502,11 +633,21 @@ func (s *Identities) GetIdentity(ctx context.Context, request operations.GetIden return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrNotFound if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -514,11 +655,21 @@ func (s *Identities) GetIdentity(ctx context.Context, request operations.GetIden return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrConflict if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -526,11 +677,21 @@ func (s *Identities) GetIdentity(ctx context.Context, request operations.GetIden return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrTooManyRequests if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -538,11 +699,21 @@ func (s *Identities) GetIdentity(ctx context.Context, request operations.GetIden return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } case httpRes.StatusCode == 500: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrInternalServerError if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -550,13 +721,28 @@ func (s *Identities) GetIdentity(ctx context.Context, request operations.GetIden return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) } @@ -714,57 +900,70 @@ func (s *Identities) ListIdentities(ctx context.Context, request operations.List }, } - rawBody, err := io.ReadAll(httpRes.Body) - if err != nil { - return nil, fmt.Errorf("error reading response body: %w", err) + getRawBody := func() ([]byte, error) { + 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)) + return rawBody, nil } - httpRes.Body.Close() - httpRes.Body = io.NopCloser(bytes.NewBuffer(rawBody)) - res.Next = - func() (*operations.ListIdentitiesResponse, error) { - b, err := ajson.Unmarshal(rawBody) + + res.Next = func() (*operations.ListIdentitiesResponse, error) { + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + + b, err := ajson.Unmarshal(rawBody) + if err != nil { + return nil, err + } + nC, err := ajson.Eval(b, "$.cursor") + if err != nil { + return nil, err + } + var nCVal string + + if nC.IsNumeric() { + numVal, err := nC.GetNumeric() if err != nil { return nil, err } - nC, err := ajson.Eval(b, "$.cursor") + // GetNumeric returns as float64 so convert to the appropriate type. + nCVal = strconv.FormatFloat(numVal, 'f', 0, 64) + } else { + val, err := nC.Value() if err != nil { return nil, err } - var nCVal string - - if nC.IsNumeric() { - numVal, err := nC.GetNumeric() - if err != nil { - return nil, err - } - // GetNumeric returns as float64 so convert to the appropriate type. - nCVal = strconv.FormatFloat(numVal, 'f', 0, 64) - } else { - val, err := nC.Value() - if err != nil { - return nil, err - } - if val == nil { - return nil, nil - } - nCVal = val.(string) + if val == nil { + return nil, nil } - - return s.ListIdentities( - ctx, - operations.ListIdentitiesRequest{ - Environment: request.Environment, - Limit: request.Limit, - Cursor: &nCVal, - }, - opts..., - ) + nCVal = val.(string) } + return s.ListIdentities( + ctx, + operations.ListIdentitiesRequest{ + Environment: request.Environment, + Limit: request.Limit, + Cursor: &nCVal, + }, + opts..., + ) + } + switch { case httpRes.StatusCode == 200: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out operations.ListIdentitiesResponseBody if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -772,11 +971,21 @@ func (s *Identities) ListIdentities(ctx context.Context, request operations.List res.Object = &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrBadRequest if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -784,11 +993,21 @@ func (s *Identities) ListIdentities(ctx context.Context, request operations.List return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrUnauthorized if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -796,11 +1015,21 @@ func (s *Identities) ListIdentities(ctx context.Context, request operations.List return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrForbidden if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -808,11 +1037,21 @@ func (s *Identities) ListIdentities(ctx context.Context, request operations.List return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrNotFound if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -820,11 +1059,21 @@ func (s *Identities) ListIdentities(ctx context.Context, request operations.List return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrConflict if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -832,11 +1081,21 @@ func (s *Identities) ListIdentities(ctx context.Context, request operations.List return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrTooManyRequests if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -844,11 +1103,21 @@ func (s *Identities) ListIdentities(ctx context.Context, request operations.List return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } case httpRes.StatusCode == 500: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrInternalServerError if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -856,13 +1125,28 @@ func (s *Identities) ListIdentities(ctx context.Context, request operations.List return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) } @@ -1022,17 +1306,25 @@ func (s *Identities) UpdateIdentity(ctx context.Context, request operations.Upda }, } - rawBody, err := io.ReadAll(httpRes.Body) - if err != nil { - return nil, fmt.Errorf("error reading response body: %w", err) + getRawBody := func() ([]byte, error) { + 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)) + return rawBody, nil } - 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out operations.UpdateIdentityResponseBody if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -1040,11 +1332,21 @@ func (s *Identities) UpdateIdentity(ctx context.Context, request operations.Upda res.Object = &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrBadRequest if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -1052,11 +1354,21 @@ func (s *Identities) UpdateIdentity(ctx context.Context, request operations.Upda return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrUnauthorized if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -1064,11 +1376,21 @@ func (s *Identities) UpdateIdentity(ctx context.Context, request operations.Upda return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrForbidden if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -1076,11 +1398,21 @@ func (s *Identities) UpdateIdentity(ctx context.Context, request operations.Upda return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrNotFound if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -1088,11 +1420,21 @@ func (s *Identities) UpdateIdentity(ctx context.Context, request operations.Upda return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrConflict if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -1100,11 +1442,21 @@ func (s *Identities) UpdateIdentity(ctx context.Context, request operations.Upda return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrTooManyRequests if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -1112,11 +1464,21 @@ func (s *Identities) UpdateIdentity(ctx context.Context, request operations.Upda return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } case httpRes.StatusCode == 500: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrInternalServerError if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -1124,13 +1486,28 @@ func (s *Identities) UpdateIdentity(ctx context.Context, request operations.Upda return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) } @@ -1290,17 +1667,25 @@ func (s *Identities) DeleteIdentity(ctx context.Context, request operations.Dele }, } - rawBody, err := io.ReadAll(httpRes.Body) - if err != nil { - return nil, fmt.Errorf("error reading response body: %w", err) + getRawBody := func() ([]byte, error) { + 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)) + return rawBody, nil } - 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out operations.DeleteIdentityResponseBody if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -1308,11 +1693,21 @@ func (s *Identities) DeleteIdentity(ctx context.Context, request operations.Dele res.Object = &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrBadRequest if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -1320,11 +1715,21 @@ func (s *Identities) DeleteIdentity(ctx context.Context, request operations.Dele return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrUnauthorized if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -1332,11 +1737,21 @@ func (s *Identities) DeleteIdentity(ctx context.Context, request operations.Dele return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrForbidden if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -1344,11 +1759,21 @@ func (s *Identities) DeleteIdentity(ctx context.Context, request operations.Dele return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrNotFound if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -1356,11 +1781,21 @@ func (s *Identities) DeleteIdentity(ctx context.Context, request operations.Dele return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrConflict if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -1368,11 +1803,21 @@ func (s *Identities) DeleteIdentity(ctx context.Context, request operations.Dele return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrTooManyRequests if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -1380,11 +1825,21 @@ func (s *Identities) DeleteIdentity(ctx context.Context, request operations.Dele return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } case httpRes.StatusCode == 500: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrInternalServerError if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -1392,13 +1847,28 @@ func (s *Identities) DeleteIdentity(ctx context.Context, request operations.Dele return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) } diff --git a/internal/utils/json.go b/internal/utils/json.go index f25edcb..65c97f6 100644 --- a/internal/utils/json.go +++ b/internal/utils/json.go @@ -487,30 +487,29 @@ func unmarshalValue(value json.RawMessage, v reflect.Value, tag reflect.StructTa v.Set(m) return nil case reflect.Slice, reflect.Array: - if bytes.Equal(value, []byte("null")) || !isComplexValueType(dereferenceTypePointer(typ.Elem())) { - if v.CanAddr() { - return json.Unmarshal(value, v.Addr().Interface()) - } else { - return json.Unmarshal(value, v.Interface()) - } - } - - var unmarhsaled []json.RawMessage + var unmarshaled []json.RawMessage - if err := json.Unmarshal(value, &unmarhsaled); err != nil { + if err := json.Unmarshal(value, &unmarshaled); err != nil { return err } - arrVal := v + arrVal := reflect.MakeSlice(typ, len(unmarshaled), len(unmarshaled)) - for _, value := range unmarhsaled { + for index, value := range unmarshaled { itemVal := reflect.New(typ.Elem()) if err := unmarshalValue(value, itemVal, tag, disallowUnknownFields); err != nil { return err } - arrVal = reflect.Append(arrVal, itemVal.Elem()) + arrVal.Index(index).Set(itemVal.Elem()) + } + + if v.Kind() == reflect.Pointer { + if v.IsNil() { + v.Set(reflect.New(typ)) + } + v = v.Elem() } v.Set(arrVal) diff --git a/internal/utils/requestbody.go b/internal/utils/requestbody.go index 0fd33cf..000226e 100644 --- a/internal/utils/requestbody.go +++ b/internal/utils/requestbody.go @@ -66,15 +66,16 @@ func serializeRequestBody(request interface{}, nullable, optional bool, requestF if tag != nil { // request object (non-flattened) requestVal := requestValType.FieldByName(requestFieldName) + val := reflect.ValueOf(requestVal.Interface()) if isNil(requestField.Type, requestVal) { if !nullable && optional { return nil, "", nil } - return serializeContentType(requestFieldName, tag.MediaType, requestVal, string(requestField.Tag)) + return serializeContentType(requestFieldName, tag.MediaType, val, string(requestField.Tag)) } - return serializeContentType(requestFieldName, tag.MediaType, requestVal, string(requestField.Tag)) + return serializeContentType(requestFieldName, tag.MediaType, val, string(requestField.Tag)) } } @@ -82,7 +83,7 @@ func serializeRequestBody(request interface{}, nullable, optional bool, requestF return serializeContentType(requestFieldName, SerializationMethodToContentType[serializationMethod], reflect.ValueOf(request), tag) } -func serializeContentType(fieldName string, mediaType string, val reflect.Value, tag string) (*bytes.Buffer, string, error) { +func serializeContentType(fieldName string, mediaType string, val reflect.Value, tag string) (io.Reader, string, error) { buf := &bytes.Buffer{} if isNil(val.Type(), val) { @@ -116,6 +117,8 @@ func serializeContentType(fieldName string, mediaType string, val reflect.Value, if err := encodeFormData(fieldName, buf, val.Interface()); err != nil { return nil, "", err } + case val.Type().Implements(reflect.TypeOf((*io.Reader)(nil)).Elem()): + return val.Interface().(io.Reader), mediaType, nil default: val = reflect.Indirect(val) @@ -124,8 +127,8 @@ func serializeContentType(fieldName string, mediaType string, val reflect.Value, if _, err := buf.WriteString(valToString(val.Interface())); err != nil { return nil, "", err } - case val.Type() == reflect.TypeOf([]byte(nil)): - if _, err := buf.Write(val.Bytes()); err != nil { + case reflect.TypeOf(val.Interface()) == reflect.TypeOf([]byte(nil)): + if _, err := buf.Write(val.Interface().([]byte)); err != nil { return nil, "", err } default: @@ -215,7 +218,7 @@ func encodeMultipartFormDataFile(w *multipart.Writer, fieldType reflect.Type, va var fieldName string var fileName string - var content []byte + var reader io.Reader for i := 0; i < fieldType.NumField(); i++ { field := fieldType.Field(i) @@ -226,15 +229,19 @@ func encodeMultipartFormDataFile(w *multipart.Writer, fieldType reflect.Type, va continue } - if tag.Content { - content = val.Bytes() + if tag.Content && val.CanInterface() { + if reflect.TypeOf(val.Interface()) == reflect.TypeOf([]byte(nil)) { + reader = bytes.NewReader(val.Interface().([]byte)) + } else if reflect.TypeOf(val.Interface()).Implements(reflect.TypeOf((*io.Reader)(nil)).Elem()) { + reader = val.Interface().(io.Reader) + } } else { fieldName = tag.Name fileName = val.String() } } - if fieldName == "" || fileName == "" || content == nil { + if fieldName == "" || fileName == "" || reader == nil { return fmt.Errorf("invalid multipart/form-data file") } @@ -242,7 +249,7 @@ func encodeMultipartFormDataFile(w *multipart.Writer, fieldType reflect.Type, va if err != nil { return err } - if _, err := fw.Write(content); err != nil { + if _, err := io.Copy(fw, reader); err != nil { return err } diff --git a/internal/utils/security.go b/internal/utils/security.go index c8503f9..19dfa6f 100644 --- a/internal/utils/security.go +++ b/internal/utils/security.go @@ -119,9 +119,14 @@ func parseSecurityScheme(headers, queryParams map[string]string, schemeTag *secu } if schemeType.Kind() == reflect.Struct { - if schemeTag.Type == "http" && schemeTag.SubType == "basic" { - handleBasicAuthScheme(headers, schemeVal.Interface()) - return + if schemeTag.Type == "http" { + switch schemeTag.SubType { + case "basic": + handleBasicAuthScheme(headers, schemeVal.Interface()) + return + case "custom": + return + } } for i := 0; i < schemeType.NumField(); i++ { @@ -171,6 +176,7 @@ func parseSecuritySchemeValue(headers, queryParams map[string]string, schemeTag switch schemeTag.SubType { case "bearer": headers[secTag.Name] = prefixBearer(valToString(val)) + case "custom": default: panic("not supported") } diff --git a/keys.go b/keys.go index 9b08bbf..810d090 100644 --- a/keys.go +++ b/keys.go @@ -178,17 +178,25 @@ func (s *Keys) GetKey(ctx context.Context, request operations.GetKeyRequest, opt }, } - rawBody, err := io.ReadAll(httpRes.Body) - if err != nil { - return nil, fmt.Errorf("error reading response body: %w", err) + getRawBody := func() ([]byte, error) { + 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)) + return rawBody, nil } - 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out components.Key if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -196,11 +204,21 @@ func (s *Keys) GetKey(ctx context.Context, request operations.GetKeyRequest, opt res.Key = &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrBadRequest if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -208,11 +226,21 @@ func (s *Keys) GetKey(ctx context.Context, request operations.GetKeyRequest, opt return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrUnauthorized if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -220,11 +248,21 @@ func (s *Keys) GetKey(ctx context.Context, request operations.GetKeyRequest, opt return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrForbidden if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -232,11 +270,21 @@ func (s *Keys) GetKey(ctx context.Context, request operations.GetKeyRequest, opt return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrNotFound if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -244,11 +292,21 @@ func (s *Keys) GetKey(ctx context.Context, request operations.GetKeyRequest, opt return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrConflict if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -256,11 +314,21 @@ func (s *Keys) GetKey(ctx context.Context, request operations.GetKeyRequest, opt return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrTooManyRequests if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -268,11 +336,21 @@ func (s *Keys) GetKey(ctx context.Context, request operations.GetKeyRequest, opt return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } case httpRes.StatusCode == 500: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrInternalServerError if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -280,13 +358,28 @@ func (s *Keys) GetKey(ctx context.Context, request operations.GetKeyRequest, opt return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) } @@ -446,17 +539,25 @@ func (s *Keys) DeleteKey(ctx context.Context, request operations.DeleteKeyReques }, } - rawBody, err := io.ReadAll(httpRes.Body) - if err != nil { - return nil, fmt.Errorf("error reading response body: %w", err) + getRawBody := func() ([]byte, error) { + 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)) + return rawBody, nil } - 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out operations.DeleteKeyResponseBody if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -464,11 +565,21 @@ func (s *Keys) DeleteKey(ctx context.Context, request operations.DeleteKeyReques res.Object = &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrBadRequest if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -476,11 +587,21 @@ func (s *Keys) DeleteKey(ctx context.Context, request operations.DeleteKeyReques return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrUnauthorized if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -488,11 +609,21 @@ func (s *Keys) DeleteKey(ctx context.Context, request operations.DeleteKeyReques return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrForbidden if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -500,11 +631,21 @@ func (s *Keys) DeleteKey(ctx context.Context, request operations.DeleteKeyReques return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrNotFound if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -512,11 +653,21 @@ func (s *Keys) DeleteKey(ctx context.Context, request operations.DeleteKeyReques return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrConflict if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -524,11 +675,21 @@ func (s *Keys) DeleteKey(ctx context.Context, request operations.DeleteKeyReques return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrTooManyRequests if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -536,11 +697,21 @@ func (s *Keys) DeleteKey(ctx context.Context, request operations.DeleteKeyReques return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } case httpRes.StatusCode == 500: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrInternalServerError if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -548,13 +719,28 @@ func (s *Keys) DeleteKey(ctx context.Context, request operations.DeleteKeyReques return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) } @@ -714,17 +900,25 @@ func (s *Keys) CreateKey(ctx context.Context, request operations.CreateKeyReques }, } - rawBody, err := io.ReadAll(httpRes.Body) - if err != nil { - return nil, fmt.Errorf("error reading response body: %w", err) + getRawBody := func() ([]byte, error) { + 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)) + return rawBody, nil } - 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out operations.CreateKeyResponseBody if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -732,11 +926,21 @@ func (s *Keys) CreateKey(ctx context.Context, request operations.CreateKeyReques res.Object = &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrBadRequest if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -744,11 +948,21 @@ func (s *Keys) CreateKey(ctx context.Context, request operations.CreateKeyReques return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrUnauthorized if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -756,11 +970,21 @@ func (s *Keys) CreateKey(ctx context.Context, request operations.CreateKeyReques return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrForbidden if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -768,11 +992,21 @@ func (s *Keys) CreateKey(ctx context.Context, request operations.CreateKeyReques return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrNotFound if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -780,11 +1014,21 @@ func (s *Keys) CreateKey(ctx context.Context, request operations.CreateKeyReques return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrConflict if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -792,11 +1036,21 @@ func (s *Keys) CreateKey(ctx context.Context, request operations.CreateKeyReques return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrTooManyRequests if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -804,11 +1058,21 @@ func (s *Keys) CreateKey(ctx context.Context, request operations.CreateKeyReques return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } case httpRes.StatusCode == 500: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrInternalServerError if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -816,13 +1080,28 @@ func (s *Keys) CreateKey(ctx context.Context, request operations.CreateKeyReques return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) } @@ -982,17 +1261,25 @@ func (s *Keys) VerifyKey(ctx context.Context, request components.V1KeysVerifyKey }, } - rawBody, err := io.ReadAll(httpRes.Body) - if err != nil { - return nil, fmt.Errorf("error reading response body: %w", err) + getRawBody := func() ([]byte, error) { + 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)) + return rawBody, nil } - 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out components.V1KeysVerifyKeyResponse if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -1000,11 +1287,21 @@ func (s *Keys) VerifyKey(ctx context.Context, request components.V1KeysVerifyKey res.V1KeysVerifyKeyResponse = &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrBadRequest if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -1012,11 +1309,21 @@ func (s *Keys) VerifyKey(ctx context.Context, request components.V1KeysVerifyKey return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrUnauthorized if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -1024,11 +1331,21 @@ func (s *Keys) VerifyKey(ctx context.Context, request components.V1KeysVerifyKey return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrForbidden if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -1036,11 +1353,21 @@ func (s *Keys) VerifyKey(ctx context.Context, request components.V1KeysVerifyKey return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrNotFound if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -1048,11 +1375,21 @@ func (s *Keys) VerifyKey(ctx context.Context, request components.V1KeysVerifyKey return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrConflict if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -1060,11 +1397,21 @@ func (s *Keys) VerifyKey(ctx context.Context, request components.V1KeysVerifyKey return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrTooManyRequests if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -1072,11 +1419,21 @@ func (s *Keys) VerifyKey(ctx context.Context, request components.V1KeysVerifyKey return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } case httpRes.StatusCode == 500: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrInternalServerError if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -1084,13 +1441,28 @@ func (s *Keys) VerifyKey(ctx context.Context, request components.V1KeysVerifyKey return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) } @@ -1250,17 +1622,25 @@ func (s *Keys) UpdateKey(ctx context.Context, request operations.UpdateKeyReques }, } - rawBody, err := io.ReadAll(httpRes.Body) - if err != nil { - return nil, fmt.Errorf("error reading response body: %w", err) + getRawBody := func() ([]byte, error) { + 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)) + return rawBody, nil } - 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out operations.UpdateKeyResponseBody if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -1268,11 +1648,21 @@ func (s *Keys) UpdateKey(ctx context.Context, request operations.UpdateKeyReques res.Object = &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrBadRequest if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -1280,11 +1670,21 @@ func (s *Keys) UpdateKey(ctx context.Context, request operations.UpdateKeyReques return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrUnauthorized if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -1292,11 +1692,21 @@ func (s *Keys) UpdateKey(ctx context.Context, request operations.UpdateKeyReques return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrForbidden if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -1304,11 +1714,21 @@ func (s *Keys) UpdateKey(ctx context.Context, request operations.UpdateKeyReques return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrNotFound if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -1316,11 +1736,21 @@ func (s *Keys) UpdateKey(ctx context.Context, request operations.UpdateKeyReques return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrConflict if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -1328,11 +1758,21 @@ func (s *Keys) UpdateKey(ctx context.Context, request operations.UpdateKeyReques return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrTooManyRequests if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -1340,11 +1780,21 @@ func (s *Keys) UpdateKey(ctx context.Context, request operations.UpdateKeyReques return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } case httpRes.StatusCode == 500: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrInternalServerError if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -1352,13 +1802,28 @@ func (s *Keys) UpdateKey(ctx context.Context, request operations.UpdateKeyReques return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) } @@ -1518,17 +1983,25 @@ func (s *Keys) UpdateRemaining(ctx context.Context, request operations.UpdateRem }, } - rawBody, err := io.ReadAll(httpRes.Body) - if err != nil { - return nil, fmt.Errorf("error reading response body: %w", err) + getRawBody := func() ([]byte, error) { + 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)) + return rawBody, nil } - 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out operations.UpdateRemainingResponseBody if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -1536,11 +2009,21 @@ func (s *Keys) UpdateRemaining(ctx context.Context, request operations.UpdateRem res.Object = &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrBadRequest if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -1548,11 +2031,21 @@ func (s *Keys) UpdateRemaining(ctx context.Context, request operations.UpdateRem return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrUnauthorized if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -1560,11 +2053,21 @@ func (s *Keys) UpdateRemaining(ctx context.Context, request operations.UpdateRem return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrForbidden if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -1572,11 +2075,21 @@ func (s *Keys) UpdateRemaining(ctx context.Context, request operations.UpdateRem return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrNotFound if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -1584,11 +2097,21 @@ func (s *Keys) UpdateRemaining(ctx context.Context, request operations.UpdateRem return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrConflict if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -1596,11 +2119,21 @@ func (s *Keys) UpdateRemaining(ctx context.Context, request operations.UpdateRem return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrTooManyRequests if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -1608,11 +2141,21 @@ func (s *Keys) UpdateRemaining(ctx context.Context, request operations.UpdateRem return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } case httpRes.StatusCode == 500: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrInternalServerError if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -1620,13 +2163,28 @@ func (s *Keys) UpdateRemaining(ctx context.Context, request operations.UpdateRem return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) } @@ -1784,17 +2342,25 @@ func (s *Keys) GetVerifications(ctx context.Context, request operations.GetVerif }, } - rawBody, err := io.ReadAll(httpRes.Body) - if err != nil { - return nil, fmt.Errorf("error reading response body: %w", err) + getRawBody := func() ([]byte, error) { + 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)) + return rawBody, nil } - 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out operations.GetVerificationsResponseBody if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -1802,11 +2368,21 @@ func (s *Keys) GetVerifications(ctx context.Context, request operations.GetVerif res.Object = &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrBadRequest if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -1814,11 +2390,21 @@ func (s *Keys) GetVerifications(ctx context.Context, request operations.GetVerif return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrUnauthorized if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -1826,11 +2412,21 @@ func (s *Keys) GetVerifications(ctx context.Context, request operations.GetVerif return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrForbidden if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -1838,11 +2434,21 @@ func (s *Keys) GetVerifications(ctx context.Context, request operations.GetVerif return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrNotFound if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -1850,11 +2456,21 @@ func (s *Keys) GetVerifications(ctx context.Context, request operations.GetVerif return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrConflict if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -1862,11 +2478,21 @@ func (s *Keys) GetVerifications(ctx context.Context, request operations.GetVerif return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrTooManyRequests if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -1874,25 +2500,50 @@ func (s *Keys) GetVerifications(ctx context.Context, request operations.GetVerif return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), 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 { + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + + var out sdkerrors.ErrInternalServerError + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err } return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) } @@ -2052,17 +2703,25 @@ func (s *Keys) AddPermissions(ctx context.Context, request operations.AddPermiss }, } - rawBody, err := io.ReadAll(httpRes.Body) - if err != nil { - return nil, fmt.Errorf("error reading response body: %w", err) + getRawBody := func() ([]byte, error) { + 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)) + return rawBody, nil } - 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out []operations.ResponseBody if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -2070,11 +2729,21 @@ func (s *Keys) AddPermissions(ctx context.Context, request operations.AddPermiss res.ResponseBodies = out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrBadRequest if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -2082,11 +2751,21 @@ func (s *Keys) AddPermissions(ctx context.Context, request operations.AddPermiss return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrUnauthorized if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -2094,11 +2773,21 @@ func (s *Keys) AddPermissions(ctx context.Context, request operations.AddPermiss return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrForbidden if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -2106,11 +2795,21 @@ func (s *Keys) AddPermissions(ctx context.Context, request operations.AddPermiss return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrNotFound if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -2118,11 +2817,21 @@ func (s *Keys) AddPermissions(ctx context.Context, request operations.AddPermiss return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrConflict if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -2130,11 +2839,21 @@ func (s *Keys) AddPermissions(ctx context.Context, request operations.AddPermiss return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrTooManyRequests if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -2142,11 +2861,21 @@ func (s *Keys) AddPermissions(ctx context.Context, request operations.AddPermiss return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } case httpRes.StatusCode == 500: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrInternalServerError if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -2154,13 +2883,28 @@ func (s *Keys) AddPermissions(ctx context.Context, request operations.AddPermiss return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) } @@ -2320,17 +3064,25 @@ func (s *Keys) RemovePermissions(ctx context.Context, request operations.RemoveP }, } - rawBody, err := io.ReadAll(httpRes.Body) - if err != nil { - return nil, fmt.Errorf("error reading response body: %w", err) + getRawBody := func() ([]byte, error) { + 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)) + return rawBody, nil } - 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out operations.RemovePermissionsResponseBody if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -2338,11 +3090,21 @@ func (s *Keys) RemovePermissions(ctx context.Context, request operations.RemoveP res.Object = &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrBadRequest if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -2350,11 +3112,21 @@ func (s *Keys) RemovePermissions(ctx context.Context, request operations.RemoveP return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrUnauthorized if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -2362,11 +3134,21 @@ func (s *Keys) RemovePermissions(ctx context.Context, request operations.RemoveP return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrForbidden if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -2374,11 +3156,21 @@ func (s *Keys) RemovePermissions(ctx context.Context, request operations.RemoveP return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrNotFound if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -2386,11 +3178,21 @@ func (s *Keys) RemovePermissions(ctx context.Context, request operations.RemoveP return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrConflict if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -2398,11 +3200,21 @@ func (s *Keys) RemovePermissions(ctx context.Context, request operations.RemoveP return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrTooManyRequests if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -2410,11 +3222,21 @@ func (s *Keys) RemovePermissions(ctx context.Context, request operations.RemoveP return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } case httpRes.StatusCode == 500: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrInternalServerError if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -2422,13 +3244,28 @@ func (s *Keys) RemovePermissions(ctx context.Context, request operations.RemoveP return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) } @@ -2588,17 +3425,25 @@ func (s *Keys) SetPermissions(ctx context.Context, request operations.SetPermiss }, } - rawBody, err := io.ReadAll(httpRes.Body) - if err != nil { - return nil, fmt.Errorf("error reading response body: %w", err) + getRawBody := func() ([]byte, error) { + 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)) + return rawBody, nil } - 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out []operations.SetPermissionsResponseBody if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -2606,11 +3451,21 @@ func (s *Keys) SetPermissions(ctx context.Context, request operations.SetPermiss res.ResponseBodies = out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrBadRequest if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -2618,11 +3473,21 @@ func (s *Keys) SetPermissions(ctx context.Context, request operations.SetPermiss return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrUnauthorized if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -2630,11 +3495,21 @@ func (s *Keys) SetPermissions(ctx context.Context, request operations.SetPermiss return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrForbidden if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -2642,11 +3517,21 @@ func (s *Keys) SetPermissions(ctx context.Context, request operations.SetPermiss return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrNotFound if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -2654,11 +3539,21 @@ func (s *Keys) SetPermissions(ctx context.Context, request operations.SetPermiss return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrConflict if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -2666,11 +3561,21 @@ func (s *Keys) SetPermissions(ctx context.Context, request operations.SetPermiss return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrTooManyRequests if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -2678,11 +3583,21 @@ func (s *Keys) SetPermissions(ctx context.Context, request operations.SetPermiss return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } case httpRes.StatusCode == 500: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrInternalServerError if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -2690,13 +3605,28 @@ func (s *Keys) SetPermissions(ctx context.Context, request operations.SetPermiss return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) } @@ -2856,17 +3786,25 @@ func (s *Keys) AddRoles(ctx context.Context, request operations.AddRolesRequestB }, } - rawBody, err := io.ReadAll(httpRes.Body) - if err != nil { - return nil, fmt.Errorf("error reading response body: %w", err) + getRawBody := func() ([]byte, error) { + 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)) + return rawBody, nil } - 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out []operations.AddRolesResponseBody if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -2874,11 +3812,21 @@ func (s *Keys) AddRoles(ctx context.Context, request operations.AddRolesRequestB res.ResponseBodies = out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrBadRequest if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -2886,11 +3834,21 @@ func (s *Keys) AddRoles(ctx context.Context, request operations.AddRolesRequestB return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrUnauthorized if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -2898,11 +3856,21 @@ func (s *Keys) AddRoles(ctx context.Context, request operations.AddRolesRequestB return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrForbidden if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -2910,11 +3878,21 @@ func (s *Keys) AddRoles(ctx context.Context, request operations.AddRolesRequestB return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrNotFound if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -2922,11 +3900,21 @@ func (s *Keys) AddRoles(ctx context.Context, request operations.AddRolesRequestB return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrConflict if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -2934,11 +3922,21 @@ func (s *Keys) AddRoles(ctx context.Context, request operations.AddRolesRequestB return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrTooManyRequests if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -2946,11 +3944,21 @@ func (s *Keys) AddRoles(ctx context.Context, request operations.AddRolesRequestB return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } case httpRes.StatusCode == 500: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrInternalServerError if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -2958,13 +3966,28 @@ func (s *Keys) AddRoles(ctx context.Context, request operations.AddRolesRequestB return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) } @@ -3124,17 +4147,25 @@ func (s *Keys) RemoveRoles(ctx context.Context, request operations.RemoveRolesRe }, } - rawBody, err := io.ReadAll(httpRes.Body) - if err != nil { - return nil, fmt.Errorf("error reading response body: %w", err) + getRawBody := func() ([]byte, error) { + 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)) + return rawBody, nil } - 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out operations.RemoveRolesResponseBody if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -3142,11 +4173,21 @@ func (s *Keys) RemoveRoles(ctx context.Context, request operations.RemoveRolesRe res.Object = &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrBadRequest if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -3154,11 +4195,21 @@ func (s *Keys) RemoveRoles(ctx context.Context, request operations.RemoveRolesRe return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrUnauthorized if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -3166,11 +4217,21 @@ func (s *Keys) RemoveRoles(ctx context.Context, request operations.RemoveRolesRe return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrForbidden if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -3178,11 +4239,21 @@ func (s *Keys) RemoveRoles(ctx context.Context, request operations.RemoveRolesRe return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrNotFound if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -3190,11 +4261,21 @@ func (s *Keys) RemoveRoles(ctx context.Context, request operations.RemoveRolesRe return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrConflict if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -3202,11 +4283,21 @@ func (s *Keys) RemoveRoles(ctx context.Context, request operations.RemoveRolesRe return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrTooManyRequests if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -3214,11 +4305,21 @@ func (s *Keys) RemoveRoles(ctx context.Context, request operations.RemoveRolesRe return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } case httpRes.StatusCode == 500: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrInternalServerError if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -3226,13 +4327,28 @@ func (s *Keys) RemoveRoles(ctx context.Context, request operations.RemoveRolesRe return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) } @@ -3392,17 +4508,25 @@ func (s *Keys) SetRoles(ctx context.Context, request operations.SetRolesRequestB }, } - rawBody, err := io.ReadAll(httpRes.Body) - if err != nil { - return nil, fmt.Errorf("error reading response body: %w", err) + getRawBody := func() ([]byte, error) { + 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)) + return rawBody, nil } - 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out []operations.SetRolesResponseBody if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -3410,11 +4534,21 @@ func (s *Keys) SetRoles(ctx context.Context, request operations.SetRolesRequestB res.ResponseBodies = out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrBadRequest if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -3422,11 +4556,21 @@ func (s *Keys) SetRoles(ctx context.Context, request operations.SetRolesRequestB return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrUnauthorized if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -3434,11 +4578,21 @@ func (s *Keys) SetRoles(ctx context.Context, request operations.SetRolesRequestB return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrForbidden if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -3446,11 +4600,21 @@ func (s *Keys) SetRoles(ctx context.Context, request operations.SetRolesRequestB return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrNotFound if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -3458,11 +4622,21 @@ func (s *Keys) SetRoles(ctx context.Context, request operations.SetRolesRequestB return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrConflict if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -3470,11 +4644,21 @@ func (s *Keys) SetRoles(ctx context.Context, request operations.SetRolesRequestB return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrTooManyRequests if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -3482,11 +4666,21 @@ func (s *Keys) SetRoles(ctx context.Context, request operations.SetRolesRequestB return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } case httpRes.StatusCode == 500: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrInternalServerError if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -3494,13 +4688,28 @@ func (s *Keys) SetRoles(ctx context.Context, request operations.SetRolesRequestB return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) } diff --git a/liveness.go b/liveness.go index 7b4afc5..6438b18 100644 --- a/liveness.go +++ b/liveness.go @@ -174,17 +174,25 @@ func (s *Liveness) V1Liveness(ctx context.Context, opts ...operations.Option) (* }, } - rawBody, err := io.ReadAll(httpRes.Body) - if err != nil { - return nil, fmt.Errorf("error reading response body: %w", err) + getRawBody := func() ([]byte, error) { + 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)) + return rawBody, nil } - 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out operations.V1LivenessResponseBody if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -192,11 +200,21 @@ func (s *Liveness) V1Liveness(ctx context.Context, opts ...operations.Option) (* res.Object = &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrBadRequest if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -204,11 +222,21 @@ func (s *Liveness) V1Liveness(ctx context.Context, opts ...operations.Option) (* return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrUnauthorized if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -216,11 +244,21 @@ func (s *Liveness) V1Liveness(ctx context.Context, opts ...operations.Option) (* return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrForbidden if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -228,11 +266,21 @@ func (s *Liveness) V1Liveness(ctx context.Context, opts ...operations.Option) (* return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrNotFound if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -240,11 +288,21 @@ func (s *Liveness) V1Liveness(ctx context.Context, opts ...operations.Option) (* return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrConflict if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -252,11 +310,21 @@ func (s *Liveness) V1Liveness(ctx context.Context, opts ...operations.Option) (* return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrTooManyRequests if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -264,11 +332,21 @@ func (s *Liveness) V1Liveness(ctx context.Context, opts ...operations.Option) (* return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } case httpRes.StatusCode == 500: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrInternalServerError if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -276,13 +354,28 @@ func (s *Liveness) V1Liveness(ctx context.Context, opts ...operations.Option) (* return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) } diff --git a/migrations.go b/migrations.go index cbeeee5..b9fb556 100644 --- a/migrations.go +++ b/migrations.go @@ -180,17 +180,25 @@ func (s *Migrations) V1MigrationsCreateKeys(ctx context.Context, request []opera }, } - rawBody, err := io.ReadAll(httpRes.Body) - if err != nil { - return nil, fmt.Errorf("error reading response body: %w", err) + getRawBody := func() ([]byte, error) { + 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)) + return rawBody, nil } - 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out operations.V1MigrationsCreateKeysResponseBody if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -198,11 +206,21 @@ func (s *Migrations) V1MigrationsCreateKeys(ctx context.Context, request []opera res.Object = &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrBadRequest if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -210,11 +228,21 @@ func (s *Migrations) V1MigrationsCreateKeys(ctx context.Context, request []opera return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrUnauthorized if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -222,11 +250,21 @@ func (s *Migrations) V1MigrationsCreateKeys(ctx context.Context, request []opera return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrForbidden if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -234,11 +272,21 @@ func (s *Migrations) V1MigrationsCreateKeys(ctx context.Context, request []opera return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrNotFound if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -246,11 +294,21 @@ func (s *Migrations) V1MigrationsCreateKeys(ctx context.Context, request []opera return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrConflict if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -258,11 +316,21 @@ func (s *Migrations) V1MigrationsCreateKeys(ctx context.Context, request []opera return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrTooManyRequests if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -270,11 +338,21 @@ func (s *Migrations) V1MigrationsCreateKeys(ctx context.Context, request []opera return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } case httpRes.StatusCode == 500: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrInternalServerError if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -282,13 +360,28 @@ func (s *Migrations) V1MigrationsCreateKeys(ctx context.Context, request []opera return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) } @@ -448,17 +541,25 @@ func (s *Migrations) V1MigrationsEnqueueKeys(ctx context.Context, request operat }, } - rawBody, err := io.ReadAll(httpRes.Body) - if err != nil { - return nil, fmt.Errorf("error reading response body: %w", err) + getRawBody := func() ([]byte, error) { + 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)) + return rawBody, nil } - httpRes.Body.Close() - httpRes.Body = io.NopCloser(bytes.NewBuffer(rawBody)) switch { case httpRes.StatusCode == 202: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out operations.V1MigrationsEnqueueKeysResponseBody if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -466,11 +567,21 @@ func (s *Migrations) V1MigrationsEnqueueKeys(ctx context.Context, request operat res.Object = &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrBadRequest if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -478,11 +589,21 @@ func (s *Migrations) V1MigrationsEnqueueKeys(ctx context.Context, request operat return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrUnauthorized if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -490,11 +611,21 @@ func (s *Migrations) V1MigrationsEnqueueKeys(ctx context.Context, request operat return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrForbidden if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -502,11 +633,21 @@ func (s *Migrations) V1MigrationsEnqueueKeys(ctx context.Context, request operat return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrNotFound if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -514,11 +655,21 @@ func (s *Migrations) V1MigrationsEnqueueKeys(ctx context.Context, request operat return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrConflict if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -526,11 +677,21 @@ func (s *Migrations) V1MigrationsEnqueueKeys(ctx context.Context, request operat return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrTooManyRequests if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -538,11 +699,21 @@ func (s *Migrations) V1MigrationsEnqueueKeys(ctx context.Context, request operat return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } case httpRes.StatusCode == 500: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrInternalServerError if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -550,13 +721,28 @@ func (s *Migrations) V1MigrationsEnqueueKeys(ctx context.Context, request operat return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) } diff --git a/models/operations/createkey.go b/models/operations/createkey.go index 7c6a008..797795d 100644 --- a/models/operations/createkey.go +++ b/models/operations/createkey.go @@ -58,7 +58,7 @@ func (o *Refill) GetAmount() int64 { return o.Amount } -// Type - Deprecated, used `async`. Fast ratelimiting doesn't add latency, while consistent ratelimiting is more accurate. +// Type - Deprecated, use `async`. Fast ratelimiting doesn't add latency, while consistent ratelimiting is more accurate. // // https://unkey.dev/docs/features/ratelimiting - Learn more // @@ -93,7 +93,7 @@ func (e *Type) UnmarshalJSON(data []byte) error { type Ratelimit struct { // Async will return a response immediately, lowering latency at the cost of accuracy. Will be required soon. Async *bool `default:"true" json:"async"` - // Deprecated, used `async`. Fast ratelimiting doesn't add latency, while consistent ratelimiting is more accurate. + // Deprecated, use `async`. Fast ratelimiting doesn't add latency, while consistent ratelimiting is more accurate. // // Deprecated field: This will be removed in a future release, please migrate away from it as soon as possible. Type *Type `default:"fast" json:"type"` diff --git a/models/operations/updatekey.go b/models/operations/updatekey.go index 219aa5a..851efd4 100644 --- a/models/operations/updatekey.go +++ b/models/operations/updatekey.go @@ -239,8 +239,15 @@ type UpdateKeyRequestBody struct { KeyID string `json:"keyId"` // The name of the key 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. + // Deprecated, use `externalId` + // 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. + // + // Deprecated field: This will be removed in a future release, please migrate away from it as soon as possible. OwnerID *string `json:"ownerId,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 back to you, so you know who is accessing your API. + // Under the hood this upserts and connects an `ìdentity` for you. + // To disconnect the key from an identity, set `externalId: null`. + ExternalID *string `json:"externalId,omitempty"` // Any additional metadata you want to store with the key Meta map[string]any `json:"meta,omitempty"` // The unix timestamp in milliseconds when the key will expire. If this field is null or undefined, the key is not expiring. @@ -282,6 +289,13 @@ func (o *UpdateKeyRequestBody) GetOwnerID() *string { return o.OwnerID } +func (o *UpdateKeyRequestBody) GetExternalID() *string { + if o == nil { + return nil + } + return o.ExternalID +} + func (o *UpdateKeyRequestBody) GetMeta() map[string]any { if o == nil { return nil diff --git a/permissions.go b/permissions.go index 828e1b3..d8abaa1 100644 --- a/permissions.go +++ b/permissions.go @@ -180,17 +180,25 @@ func (s *Permissions) CreatePermission(ctx context.Context, request operations.C }, } - rawBody, err := io.ReadAll(httpRes.Body) - if err != nil { - return nil, fmt.Errorf("error reading response body: %w", err) + getRawBody := func() ([]byte, error) { + 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)) + return rawBody, nil } - 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out operations.CreatePermissionResponseBody if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -198,11 +206,21 @@ func (s *Permissions) CreatePermission(ctx context.Context, request operations.C res.Object = &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrBadRequest if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -210,11 +228,21 @@ func (s *Permissions) CreatePermission(ctx context.Context, request operations.C return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrUnauthorized if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -222,11 +250,21 @@ func (s *Permissions) CreatePermission(ctx context.Context, request operations.C return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrForbidden if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -234,11 +272,21 @@ func (s *Permissions) CreatePermission(ctx context.Context, request operations.C return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrNotFound if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -246,11 +294,21 @@ func (s *Permissions) CreatePermission(ctx context.Context, request operations.C return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrConflict if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -258,11 +316,21 @@ func (s *Permissions) CreatePermission(ctx context.Context, request operations.C return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrTooManyRequests if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -270,11 +338,21 @@ func (s *Permissions) CreatePermission(ctx context.Context, request operations.C return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } case httpRes.StatusCode == 500: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrInternalServerError if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -282,13 +360,28 @@ func (s *Permissions) CreatePermission(ctx context.Context, request operations.C return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) } @@ -448,17 +541,25 @@ func (s *Permissions) DeletePermission(ctx context.Context, request operations.D }, } - rawBody, err := io.ReadAll(httpRes.Body) - if err != nil { - return nil, fmt.Errorf("error reading response body: %w", err) + getRawBody := func() ([]byte, error) { + 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)) + return rawBody, nil } - 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out operations.DeletePermissionResponseBody if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -466,11 +567,21 @@ func (s *Permissions) DeletePermission(ctx context.Context, request operations.D res.Object = &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrBadRequest if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -478,11 +589,21 @@ func (s *Permissions) DeletePermission(ctx context.Context, request operations.D return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrUnauthorized if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -490,11 +611,21 @@ func (s *Permissions) DeletePermission(ctx context.Context, request operations.D return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrForbidden if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -502,11 +633,21 @@ func (s *Permissions) DeletePermission(ctx context.Context, request operations.D return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrNotFound if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -514,11 +655,21 @@ func (s *Permissions) DeletePermission(ctx context.Context, request operations.D return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrConflict if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -526,11 +677,21 @@ func (s *Permissions) DeletePermission(ctx context.Context, request operations.D return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrTooManyRequests if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -538,11 +699,21 @@ func (s *Permissions) DeletePermission(ctx context.Context, request operations.D return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } case httpRes.StatusCode == 500: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrInternalServerError if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -550,13 +721,28 @@ func (s *Permissions) DeletePermission(ctx context.Context, request operations.D return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) } @@ -714,17 +900,25 @@ func (s *Permissions) GetPermission(ctx context.Context, request operations.GetP }, } - rawBody, err := io.ReadAll(httpRes.Body) - if err != nil { - return nil, fmt.Errorf("error reading response body: %w", err) + getRawBody := func() ([]byte, error) { + 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)) + return rawBody, nil } - 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out operations.GetPermissionResponseBody if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -732,11 +926,21 @@ func (s *Permissions) GetPermission(ctx context.Context, request operations.GetP res.Object = &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrBadRequest if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -744,11 +948,21 @@ func (s *Permissions) GetPermission(ctx context.Context, request operations.GetP return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrUnauthorized if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -756,11 +970,21 @@ func (s *Permissions) GetPermission(ctx context.Context, request operations.GetP return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrForbidden if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -768,11 +992,21 @@ func (s *Permissions) GetPermission(ctx context.Context, request operations.GetP return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrNotFound if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -780,11 +1014,21 @@ func (s *Permissions) GetPermission(ctx context.Context, request operations.GetP return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrConflict if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -792,11 +1036,21 @@ func (s *Permissions) GetPermission(ctx context.Context, request operations.GetP return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrTooManyRequests if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -804,11 +1058,21 @@ func (s *Permissions) GetPermission(ctx context.Context, request operations.GetP return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } case httpRes.StatusCode == 500: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrInternalServerError if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -816,13 +1080,28 @@ func (s *Permissions) GetPermission(ctx context.Context, request operations.GetP return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) } @@ -976,17 +1255,25 @@ func (s *Permissions) ListPermissions(ctx context.Context, opts ...operations.Op }, } - rawBody, err := io.ReadAll(httpRes.Body) - if err != nil { - return nil, fmt.Errorf("error reading response body: %w", err) + getRawBody := func() ([]byte, error) { + 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)) + return rawBody, nil } - 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out []operations.ListPermissionsResponseBody if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -994,11 +1281,21 @@ func (s *Permissions) ListPermissions(ctx context.Context, opts ...operations.Op res.ResponseBodies = out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrBadRequest if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -1006,11 +1303,21 @@ func (s *Permissions) ListPermissions(ctx context.Context, opts ...operations.Op return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrUnauthorized if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -1018,11 +1325,21 @@ func (s *Permissions) ListPermissions(ctx context.Context, opts ...operations.Op return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrForbidden if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -1030,11 +1347,21 @@ func (s *Permissions) ListPermissions(ctx context.Context, opts ...operations.Op return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrNotFound if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -1042,11 +1369,21 @@ func (s *Permissions) ListPermissions(ctx context.Context, opts ...operations.Op return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrConflict if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -1054,11 +1391,21 @@ func (s *Permissions) ListPermissions(ctx context.Context, opts ...operations.Op return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrTooManyRequests if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -1066,11 +1413,21 @@ func (s *Permissions) ListPermissions(ctx context.Context, opts ...operations.Op return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } case httpRes.StatusCode == 500: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrInternalServerError if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -1078,13 +1435,28 @@ func (s *Permissions) ListPermissions(ctx context.Context, opts ...operations.Op return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) } @@ -1244,17 +1616,25 @@ func (s *Permissions) CreateRole(ctx context.Context, request operations.CreateR }, } - rawBody, err := io.ReadAll(httpRes.Body) - if err != nil { - return nil, fmt.Errorf("error reading response body: %w", err) + getRawBody := func() ([]byte, error) { + 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)) + return rawBody, nil } - 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out operations.CreateRoleResponseBody if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -1262,11 +1642,21 @@ func (s *Permissions) CreateRole(ctx context.Context, request operations.CreateR res.Object = &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrBadRequest if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -1274,11 +1664,21 @@ func (s *Permissions) CreateRole(ctx context.Context, request operations.CreateR return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrUnauthorized if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -1286,11 +1686,21 @@ func (s *Permissions) CreateRole(ctx context.Context, request operations.CreateR return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrForbidden if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -1298,11 +1708,21 @@ func (s *Permissions) CreateRole(ctx context.Context, request operations.CreateR return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrNotFound if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -1310,11 +1730,21 @@ func (s *Permissions) CreateRole(ctx context.Context, request operations.CreateR return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrConflict if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -1322,11 +1752,21 @@ func (s *Permissions) CreateRole(ctx context.Context, request operations.CreateR return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrTooManyRequests if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -1334,11 +1774,21 @@ func (s *Permissions) CreateRole(ctx context.Context, request operations.CreateR return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } case httpRes.StatusCode == 500: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrInternalServerError if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -1346,13 +1796,28 @@ func (s *Permissions) CreateRole(ctx context.Context, request operations.CreateR return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) } @@ -1512,17 +1977,25 @@ func (s *Permissions) DeleteRole(ctx context.Context, request operations.DeleteR }, } - rawBody, err := io.ReadAll(httpRes.Body) - if err != nil { - return nil, fmt.Errorf("error reading response body: %w", err) + getRawBody := func() ([]byte, error) { + 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)) + return rawBody, nil } - 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out operations.DeleteRoleResponseBody if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -1530,11 +2003,21 @@ func (s *Permissions) DeleteRole(ctx context.Context, request operations.DeleteR res.Object = &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrBadRequest if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -1542,11 +2025,21 @@ func (s *Permissions) DeleteRole(ctx context.Context, request operations.DeleteR return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrUnauthorized if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -1554,11 +2047,21 @@ func (s *Permissions) DeleteRole(ctx context.Context, request operations.DeleteR return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrForbidden if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -1566,11 +2069,21 @@ func (s *Permissions) DeleteRole(ctx context.Context, request operations.DeleteR return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrNotFound if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -1578,11 +2091,21 @@ func (s *Permissions) DeleteRole(ctx context.Context, request operations.DeleteR return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrConflict if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -1590,11 +2113,21 @@ func (s *Permissions) DeleteRole(ctx context.Context, request operations.DeleteR return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrTooManyRequests if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -1602,11 +2135,21 @@ func (s *Permissions) DeleteRole(ctx context.Context, request operations.DeleteR return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } case httpRes.StatusCode == 500: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrInternalServerError if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -1614,13 +2157,28 @@ func (s *Permissions) DeleteRole(ctx context.Context, request operations.DeleteR return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) } @@ -1778,17 +2336,25 @@ func (s *Permissions) GetRole(ctx context.Context, request operations.GetRoleReq }, } - rawBody, err := io.ReadAll(httpRes.Body) - if err != nil { - return nil, fmt.Errorf("error reading response body: %w", err) + getRawBody := func() ([]byte, error) { + 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)) + return rawBody, nil } - 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out operations.GetRoleResponseBody if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -1796,11 +2362,21 @@ func (s *Permissions) GetRole(ctx context.Context, request operations.GetRoleReq res.Object = &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrBadRequest if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -1808,11 +2384,21 @@ func (s *Permissions) GetRole(ctx context.Context, request operations.GetRoleReq return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrUnauthorized if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -1820,11 +2406,21 @@ func (s *Permissions) GetRole(ctx context.Context, request operations.GetRoleReq return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrForbidden if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -1832,11 +2428,21 @@ func (s *Permissions) GetRole(ctx context.Context, request operations.GetRoleReq return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrNotFound if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -1844,11 +2450,21 @@ func (s *Permissions) GetRole(ctx context.Context, request operations.GetRoleReq return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrConflict if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -1856,11 +2472,21 @@ func (s *Permissions) GetRole(ctx context.Context, request operations.GetRoleReq return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrTooManyRequests if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -1868,11 +2494,21 @@ func (s *Permissions) GetRole(ctx context.Context, request operations.GetRoleReq return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } case httpRes.StatusCode == 500: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrInternalServerError if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -1880,13 +2516,28 @@ func (s *Permissions) GetRole(ctx context.Context, request operations.GetRoleReq return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) } @@ -2040,17 +2691,25 @@ func (s *Permissions) ListRoles(ctx context.Context, opts ...operations.Option) }, } - rawBody, err := io.ReadAll(httpRes.Body) - if err != nil { - return nil, fmt.Errorf("error reading response body: %w", err) + getRawBody := func() ([]byte, error) { + 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)) + return rawBody, nil } - 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out []operations.ListRolesResponseBody if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -2058,11 +2717,21 @@ func (s *Permissions) ListRoles(ctx context.Context, opts ...operations.Option) res.ResponseBodies = out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrBadRequest if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -2070,11 +2739,21 @@ func (s *Permissions) ListRoles(ctx context.Context, opts ...operations.Option) return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrUnauthorized if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -2082,11 +2761,21 @@ func (s *Permissions) ListRoles(ctx context.Context, opts ...operations.Option) return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrForbidden if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -2094,11 +2783,21 @@ func (s *Permissions) ListRoles(ctx context.Context, opts ...operations.Option) return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrNotFound if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -2106,11 +2805,21 @@ func (s *Permissions) ListRoles(ctx context.Context, opts ...operations.Option) return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrConflict if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -2118,11 +2827,21 @@ func (s *Permissions) ListRoles(ctx context.Context, opts ...operations.Option) return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrTooManyRequests if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -2130,11 +2849,21 @@ func (s *Permissions) ListRoles(ctx context.Context, opts ...operations.Option) return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } case httpRes.StatusCode == 500: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrInternalServerError if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -2142,13 +2871,28 @@ func (s *Permissions) ListRoles(ctx context.Context, opts ...operations.Option) return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) } diff --git a/ratelimits.go b/ratelimits.go index 6450ccf..17358e7 100644 --- a/ratelimits.go +++ b/ratelimits.go @@ -180,17 +180,25 @@ func (s *Ratelimits) Limit(ctx context.Context, request operations.LimitRequestB }, } - rawBody, err := io.ReadAll(httpRes.Body) - if err != nil { - return nil, fmt.Errorf("error reading response body: %w", err) + getRawBody := func() ([]byte, error) { + 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)) + return rawBody, nil } - 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out operations.LimitResponseBody if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -198,11 +206,21 @@ func (s *Ratelimits) Limit(ctx context.Context, request operations.LimitRequestB res.Object = &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrBadRequest if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -210,11 +228,21 @@ func (s *Ratelimits) Limit(ctx context.Context, request operations.LimitRequestB return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrUnauthorized if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -222,11 +250,21 @@ func (s *Ratelimits) Limit(ctx context.Context, request operations.LimitRequestB return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrForbidden if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -234,11 +272,21 @@ func (s *Ratelimits) Limit(ctx context.Context, request operations.LimitRequestB return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrNotFound if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -246,11 +294,21 @@ func (s *Ratelimits) Limit(ctx context.Context, request operations.LimitRequestB return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrConflict if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -258,11 +316,21 @@ func (s *Ratelimits) Limit(ctx context.Context, request operations.LimitRequestB return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrTooManyRequests if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -270,11 +338,21 @@ func (s *Ratelimits) Limit(ctx context.Context, request operations.LimitRequestB return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } case httpRes.StatusCode == 500: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + var out sdkerrors.ErrInternalServerError if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err @@ -282,13 +360,28 @@ func (s *Ratelimits) Limit(ctx context.Context, request operations.LimitRequestB return nil, &out default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + 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: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) default: + rawBody, err := getRawBody() + if err != nil { + return nil, err + } + return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) } diff --git a/types/pointers.go b/types/pointers.go index 950d6a3..35c439d 100644 --- a/types/pointers.go +++ b/types/pointers.go @@ -8,3 +8,4 @@ func Int(i int) *int { return &i } func Int64(i int64) *int64 { return &i } func Float32(f float32) *float32 { return &f } func Float64(f float64) *float64 { return &f } +func Pointer[T any](v T) *T { return &v } diff --git a/unkey.go b/unkey.go index d992a03..acfb2fd 100644 --- a/unkey.go +++ b/unkey.go @@ -42,6 +42,9 @@ func Float32(f float32) *float32 { return &f } // Float64 provides a helper function to return a pointer to a float64 func Float64(f float64) *float64 { return &f } +// Pointer provides a helper function to return a pointer to a type +func Pointer[T any](v T) *T { return &v } + type sdkConfiguration struct { Client HTTPClient Security func(context.Context) (interface{}, error) @@ -151,9 +154,9 @@ func New(opts ...SDKOption) *Unkey { sdkConfiguration: sdkConfiguration{ Language: "go", OpenAPIDocVersion: "1.0.0", - SDKVersion: "0.9.0", - GenVersion: "2.402.5", - UserAgent: "speakeasy-sdk/go 0.9.0 2.402.5 1.0.0 github.com/unkeyed/unkey-go", + SDKVersion: "0.9.1", + GenVersion: "2.422.15", + UserAgent: "speakeasy-sdk/go 0.9.1 2.422.15 1.0.0 github.com/unkeyed/unkey-go", Hooks: hooks.New(), }, }