diff --git a/.gitignore b/.gitignore index 96942a4..5f88fc7 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,5 @@ +.DS_Store +**/.speakeasy/temp/ +**/.speakeasy/logs/ .speakeasy/reports # .gitignore diff --git a/.speakeasy/gen.lock b/.speakeasy/gen.lock index f2f996e..174b727 100755 --- a/.speakeasy/gen.lock +++ b/.speakeasy/gen.lock @@ -1,32 +1,32 @@ lockVersion: 2.0.0 id: 4fc4737a-135f-4840-8e6d-42a2b2a2884b management: - docChecksum: 36d57d2ebcc889f6998d500ec8899dbb + docChecksum: b4ac05b4a0cca7fbb5cf9ca1ddc3ade9 docVersion: 1.0.0 - speakeasyVersion: 1.481.1 - generationVersion: 2.500.5 - releaseVersion: 0.12.0 - configChecksum: 71353dbefee1832b29202864ab261760 + speakeasyVersion: 1.542.3 + generationVersion: 2.597.9 + releaseVersion: 0.13.0 + configChecksum: 285fce97f154d54ad5754de54b55c5c8 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.6.12 + constsAndDefaults: 0.1.12 + core: 3.7.4 defaultEnabledRetries: 0.2.0 - deprecations: 2.81.2 + deprecations: 2.81.3 envVarSecurityUsage: 0.3.2 examples: 2.81.4 - globalSecurity: 2.82.10 + globalSecurity: 2.82.11 globalSecurityCallbacks: 0.1.0 globalSecurityFlattening: 0.1.0 globalServerURLs: 2.82.2 ignores: 2.81.1 intellisenseMarkdownSupport: 0.1.0 nameOverrides: 2.81.2 - nullables: 0.1.0 - pagination: 2.82.2 + nullables: 0.1.1 + pagination: 2.82.4 responseFormat: 0.1.2 retries: 2.83.2 sdkHooks: 0.1.0 @@ -86,6 +86,7 @@ generatedFiles: - /models/sdkerrors/errforbidden.go - /models/sdkerrors/errinternalservererror.go - /models/sdkerrors/errnotfound.go + - /models/sdkerrors/errpreconditionfailed.go - /models/sdkerrors/errtoomanyrequests.go - /models/sdkerrors/errunauthorized.go - USAGE.md @@ -130,6 +131,7 @@ generatedFiles: - docs/models/operations/createpermissionrequestbody.md - docs/models/operations/createpermissionresponse.md - docs/models/operations/createpermissionresponsebody.md + - docs/models/operations/createroledescription.md - docs/models/operations/createrolerequestbody.md - docs/models/operations/createroleresponse.md - docs/models/operations/createroleresponsebody.md @@ -154,6 +156,8 @@ generatedFiles: - docs/models/operations/deleterolerequestbody.md - docs/models/operations/deleteroleresponse.md - docs/models/operations/deleteroleresponsebody.md + - docs/models/operations/description.md + - docs/models/operations/description2.md - docs/models/operations/getapirequest.md - docs/models/operations/getapiresponse.md - docs/models/operations/getapiresponsebody.md @@ -211,6 +215,7 @@ generatedFiles: - docs/models/operations/orderby.md - docs/models/operations/overrides.md - docs/models/operations/permissions.md + - docs/models/operations/queryparam2.md - docs/models/operations/ratelimit.md - docs/models/operations/ratelimits.md - docs/models/operations/refill.md @@ -297,6 +302,9 @@ generatedFiles: - docs/models/sdkerrors/errnotfoundcode.md - docs/models/sdkerrors/errnotfounderror.md - docs/models/sdkerrors/error.md + - docs/models/sdkerrors/errpreconditionfailed.md + - docs/models/sdkerrors/errpreconditionfailedcode.md + - docs/models/sdkerrors/errpreconditionfailederror.md - docs/models/sdkerrors/errtoomanyrequests.md - docs/models/sdkerrors/errtoomanyrequestscode.md - docs/models/sdkerrors/errtoomanyrequestserror.md @@ -358,6 +366,8 @@ examples: 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"}} + "412": + application/json: {"error": {"code": "PRECONDITION_FAILED", "docs": "https://unkey.dev/docs/api-reference/errors/code/PRECONDITION_FAILED", "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": @@ -369,7 +379,7 @@ examples: 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, "refillDay": 15}, "ratelimit": {"async": true, "limit": 10, "duration": 60}, "roles": ["admin", "finance"], "permissions": ["domain.dns.create_record", "finance.read_receipt"], "enabled": true} + 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, "refillDay": 15, "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": @@ -380,6 +390,8 @@ examples: 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"}} + "412": + application/json: {"error": {"code": "PRECONDITION_FAILED", "docs": "https://unkey.dev/docs/api-reference/errors/code/PRECONDITION_FAILED", "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": @@ -401,6 +413,8 @@ examples: 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"}} + "412": + application/json: {"error": {"code": "PRECONDITION_FAILED", "docs": "https://unkey.dev/docs/api-reference/errors/code/PRECONDITION_FAILED", "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": @@ -422,6 +436,8 @@ examples: 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"}} + "412": + application/json: {"error": {"code": "PRECONDITION_FAILED", "docs": "https://unkey.dev/docs/api-reference/errors/code/PRECONDITION_FAILED", "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": @@ -443,6 +459,8 @@ examples: 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"}} + "412": + application/json: {"error": {"code": "PRECONDITION_FAILED", "docs": "https://unkey.dev/docs/api-reference/errors/code/PRECONDITION_FAILED", "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": @@ -453,7 +471,7 @@ examples: application/json: {"apiId": "api_1234", "key": "sk_1234", "tags": ["path=/v1/users/123", "region=us-east-1"], "ratelimits": [{"name": "tokens", "cost": 1, "limit": 500, "duration": 3600000}, {"name": "tokens", "cost": 1, "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"} + 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"], "roles": ["admin"], "environment": "test", "requestId": ""} "400": application/json: {"error": {"code": "BAD_REQUEST", "docs": "https://unkey.dev/docs/api-reference/errors/code/BAD_REQUEST", "message": "", "requestId": "req_1234"}} "401": @@ -464,6 +482,8 @@ examples: 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"}} + "412": + application/json: {"error": {"code": "PRECONDITION_FAILED", "docs": "https://unkey.dev/docs/api-reference/errors/code/PRECONDITION_FAILED", "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": @@ -485,6 +505,8 @@ examples: 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"}} + "412": + application/json: {"error": {"code": "PRECONDITION_FAILED", "docs": "https://unkey.dev/docs/api-reference/errors/code/PRECONDITION_FAILED", "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": @@ -506,6 +528,8 @@ examples: 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"}} + "412": + application/json: {"error": {"code": "PRECONDITION_FAILED", "docs": "https://unkey.dev/docs/api-reference/errors/code/PRECONDITION_FAILED", "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": @@ -532,6 +556,8 @@ examples: 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"}} + "412": + application/json: {"error": {"code": "PRECONDITION_FAILED", "docs": "https://unkey.dev/docs/api-reference/errors/code/PRECONDITION_FAILED", "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": @@ -553,6 +579,8 @@ examples: 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"}} + "412": + application/json: {"error": {"code": "PRECONDITION_FAILED", "docs": "https://unkey.dev/docs/api-reference/errors/code/PRECONDITION_FAILED", "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": @@ -574,6 +602,8 @@ examples: 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"}} + "412": + application/json: {"error": {"code": "PRECONDITION_FAILED", "docs": "https://unkey.dev/docs/api-reference/errors/code/PRECONDITION_FAILED", "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": @@ -595,6 +625,8 @@ examples: 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"}} + "412": + application/json: {"error": {"code": "PRECONDITION_FAILED", "docs": "https://unkey.dev/docs/api-reference/errors/code/PRECONDITION_FAILED", "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": @@ -616,6 +648,8 @@ examples: 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"}} + "412": + application/json: {"error": {"code": "PRECONDITION_FAILED", "docs": "https://unkey.dev/docs/api-reference/errors/code/PRECONDITION_FAILED", "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": @@ -637,6 +671,8 @@ examples: 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"}} + "412": + application/json: {"error": {"code": "PRECONDITION_FAILED", "docs": "https://unkey.dev/docs/api-reference/errors/code/PRECONDITION_FAILED", "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": @@ -658,6 +694,8 @@ examples: 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"}} + "412": + application/json: {"error": {"code": "PRECONDITION_FAILED", "docs": "https://unkey.dev/docs/api-reference/errors/code/PRECONDITION_FAILED", "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": @@ -680,6 +718,8 @@ examples: 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"}} + "412": + application/json: {"error": {"code": "PRECONDITION_FAILED", "docs": "https://unkey.dev/docs/api-reference/errors/code/PRECONDITION_FAILED", "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": @@ -701,6 +741,8 @@ examples: 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"}} + "412": + application/json: {"error": {"code": "PRECONDITION_FAILED", "docs": "https://unkey.dev/docs/api-reference/errors/code/PRECONDITION_FAILED", "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": @@ -714,7 +756,7 @@ examples: revalidateKeysCache: false 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, "refillDay": 15}, "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, "refillDay": 15}, "ratelimit": {"async": true, "limit": 10, "duration": 60}, "roles": ["admin", "finance"], "permissions": ["domain.dns.create_record", "finance.read_receipt"], "enabled": true}], "cursor": "eyJrZXkiOiJrZXlfMTIzNCJ9", "total": 688970} + 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, "refillDay": 15, "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, "refillDay": 15, "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": @@ -725,6 +767,8 @@ examples: 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"}} + "412": + application/json: {"error": {"code": "PRECONDITION_FAILED", "docs": "https://unkey.dev/docs/api-reference/errors/code/PRECONDITION_FAILED", "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": @@ -746,6 +790,8 @@ examples: 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"}} + "412": + application/json: {"error": {"code": "PRECONDITION_FAILED", "docs": "https://unkey.dev/docs/api-reference/errors/code/PRECONDITION_FAILED", "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": @@ -767,6 +813,8 @@ examples: 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"}} + "412": + application/json: {"error": {"code": "PRECONDITION_FAILED", "docs": "https://unkey.dev/docs/api-reference/errors/code/PRECONDITION_FAILED", "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": @@ -788,6 +836,8 @@ examples: 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"}} + "412": + application/json: {"error": {"code": "PRECONDITION_FAILED", "docs": "https://unkey.dev/docs/api-reference/errors/code/PRECONDITION_FAILED", "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": @@ -809,6 +859,8 @@ examples: 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"}} + "412": + application/json: {"error": {"code": "PRECONDITION_FAILED", "docs": "https://unkey.dev/docs/api-reference/errors/code/PRECONDITION_FAILED", "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": @@ -830,6 +882,8 @@ examples: 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"}} + "412": + application/json: {"error": {"code": "PRECONDITION_FAILED", "docs": "https://unkey.dev/docs/api-reference/errors/code/PRECONDITION_FAILED", "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": @@ -854,6 +908,8 @@ examples: 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"}} + "412": + application/json: {"error": {"code": "PRECONDITION_FAILED", "docs": "https://unkey.dev/docs/api-reference/errors/code/PRECONDITION_FAILED", "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": @@ -878,6 +934,8 @@ examples: 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"}} + "412": + application/json: {"error": {"code": "PRECONDITION_FAILED", "docs": "https://unkey.dev/docs/api-reference/errors/code/PRECONDITION_FAILED", "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": @@ -899,6 +957,8 @@ examples: 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"}} + "412": + application/json: {"error": {"code": "PRECONDITION_FAILED", "docs": "https://unkey.dev/docs/api-reference/errors/code/PRECONDITION_FAILED", "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": @@ -920,6 +980,8 @@ examples: 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"}} + "412": + application/json: {"error": {"code": "PRECONDITION_FAILED", "docs": "https://unkey.dev/docs/api-reference/errors/code/PRECONDITION_FAILED", "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": @@ -941,6 +1003,8 @@ examples: 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"}} + "412": + application/json: {"error": {"code": "PRECONDITION_FAILED", "docs": "https://unkey.dev/docs/api-reference/errors/code/PRECONDITION_FAILED", "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": @@ -962,6 +1026,8 @@ examples: 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"}} + "412": + application/json: {"error": {"code": "PRECONDITION_FAILED", "docs": "https://unkey.dev/docs/api-reference/errors/code/PRECONDITION_FAILED", "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": @@ -984,6 +1050,8 @@ examples: 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"}} + "412": + application/json: {"error": {"code": "PRECONDITION_FAILED", "docs": "https://unkey.dev/docs/api-reference/errors/code/PRECONDITION_FAILED", "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": @@ -1003,6 +1071,8 @@ examples: 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"}} + "412": + application/json: {"error": {"code": "PRECONDITION_FAILED", "docs": "https://unkey.dev/docs/api-reference/errors/code/PRECONDITION_FAILED", "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": @@ -1024,6 +1094,8 @@ examples: 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"}} + "412": + application/json: {"error": {"code": "PRECONDITION_FAILED", "docs": "https://unkey.dev/docs/api-reference/errors/code/PRECONDITION_FAILED", "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": @@ -1045,6 +1117,8 @@ examples: 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"}} + "412": + application/json: {"error": {"code": "PRECONDITION_FAILED", "docs": "https://unkey.dev/docs/api-reference/errors/code/PRECONDITION_FAILED", "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": @@ -1067,6 +1141,8 @@ examples: 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"}} + "412": + application/json: {"error": {"code": "PRECONDITION_FAILED", "docs": "https://unkey.dev/docs/api-reference/errors/code/PRECONDITION_FAILED", "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": @@ -1086,6 +1162,8 @@ examples: 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"}} + "412": + application/json: {"error": {"code": "PRECONDITION_FAILED", "docs": "https://unkey.dev/docs/api-reference/errors/code/PRECONDITION_FAILED", "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": @@ -1107,6 +1185,8 @@ examples: 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"}} + "412": + application/json: {"error": {"code": "PRECONDITION_FAILED", "docs": "https://unkey.dev/docs/api-reference/errors/code/PRECONDITION_FAILED", "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": @@ -1130,6 +1210,8 @@ examples: 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"}} + "412": + application/json: {"error": {"code": "PRECONDITION_FAILED", "docs": "https://unkey.dev/docs/api-reference/errors/code/PRECONDITION_FAILED", "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": @@ -1153,6 +1235,8 @@ examples: 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"}} + "412": + application/json: {"error": {"code": "PRECONDITION_FAILED", "docs": "https://unkey.dev/docs/api-reference/errors/code/PRECONDITION_FAILED", "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": @@ -1174,6 +1258,8 @@ examples: 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"}} + "412": + application/json: {"error": {"code": "PRECONDITION_FAILED", "docs": "https://unkey.dev/docs/api-reference/errors/code/PRECONDITION_FAILED", "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": @@ -1195,6 +1281,8 @@ examples: 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"}} + "412": + application/json: {"error": {"code": "PRECONDITION_FAILED", "docs": "https://unkey.dev/docs/api-reference/errors/code/PRECONDITION_FAILED", "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": @@ -1222,9 +1310,11 @@ examples: 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"}} + "412": + application/json: {"error": {"code": "PRECONDITION_FAILED", "docs": "https://unkey.dev/docs/api-reference/errors/code/PRECONDITION_FAILED", "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"}} -examplesVersion: 1.0.0 +examplesVersion: 1.0.1 generatedTests: {} diff --git a/.speakeasy/gen.yaml b/.speakeasy/gen.yaml index 72bb43f..2662f10 100755 --- a/.speakeasy/gen.yaml +++ b/.speakeasy/gen.yaml @@ -7,13 +7,16 @@ generation: useClassNamesForArrayFields: true fixes: nameResolutionDec2023: true + nameResolutionFeb2025: false parameterOrderingFeb2024: true requestResponseComponentNamesFeb2024: true + securityFeb2025: false + sharedErrorComponentsApr2025: false auth: oAuth2ClientCredentialsEnabled: true oAuth2PasswordEnabled: false go: - version: 0.12.0 + version: 0.13.0 additionalDependencies: {} allowUnknownFieldsInWeakUnions: false clientServerStatusCodesAsErrors: true diff --git a/.speakeasy/workflow.lock b/.speakeasy/workflow.lock index 91023a3..d18d739 100644 --- a/.speakeasy/workflow.lock +++ b/.speakeasy/workflow.lock @@ -1,21 +1,21 @@ -speakeasyVersion: 1.481.1 +speakeasyVersion: 1.542.3 sources: openapi.json: sourceNamespace: openapi-json - sourceRevisionDigest: sha256:4178e9da06ec543aefb7c30ed1950f75bb58d07a258c3af060c361017cea7d5c - sourceBlobDigest: sha256:80c886c09d00fa411bdbabd47b78ae9f876f36f600ae342c9a7c300e79c15d98 + sourceRevisionDigest: sha256:659bee904b6d370b335bcc63d8041efb96e0a8ab05f440b941bffc476b3cde06 + sourceBlobDigest: sha256:b98f7d2c560a644a3e7449388f73759520ecbfe5b64c57deda338cfad258b527 tags: - latest - - speakeasy-sdk-regen-1736900992 + - speakeasy-sdk-regen-1738542651 - 1.0.0 targets: go: source: openapi.json sourceNamespace: openapi-json - sourceRevisionDigest: sha256:4178e9da06ec543aefb7c30ed1950f75bb58d07a258c3af060c361017cea7d5c - sourceBlobDigest: sha256:80c886c09d00fa411bdbabd47b78ae9f876f36f600ae342c9a7c300e79c15d98 + sourceRevisionDigest: sha256:659bee904b6d370b335bcc63d8041efb96e0a8ab05f440b941bffc476b3cde06 + sourceBlobDigest: sha256:b98f7d2c560a644a3e7449388f73759520ecbfe5b64c57deda338cfad258b527 codeSamplesNamespace: openapi-json-go-code-samples - codeSamplesRevisionDigest: sha256:f629299411e3cfd98aafaaf5c6e0e5fa8d23ed4546d7c7d1128e6f9e59be7353 + codeSamplesRevisionDigest: sha256:8869a502c3887b06a2685bf60bac3ac08307791da57bfeb4694c18cf217cc032 workflow: workflowVersion: 1.0.0 speakeasyVersion: latest diff --git a/README.md b/README.md index fa3b652..bd2f4c8 100644 --- a/README.md +++ b/README.md @@ -167,6 +167,7 @@ For example, the `V1Liveness` function may return the following errors: | sdkerrors.ErrForbidden | 403 | application/json | | sdkerrors.ErrNotFound | 404 | application/json | | sdkerrors.ErrConflict | 409 | application/json | +| sdkerrors.ErrPreconditionFailed | 412 | application/json | | sdkerrors.ErrTooManyRequests | 429 | application/json | | sdkerrors.ErrInternalServerError | 500 | application/json | | sdkerrors.SDKError | 4XX, 5XX | \*/\* | @@ -224,6 +225,12 @@ func main() { log.Fatal(e.Error()) } + var e *sdkerrors.ErrPreconditionFailed + if errors.As(err, &e) { + // handle error + log.Fatal(e.Error()) + } + var e *sdkerrors.ErrTooManyRequests if errors.As(err, &e) { // handle error @@ -252,7 +259,7 @@ func main() { ### Override Server URL Per-Client -The default server can also be overridden globally using the `WithServerURL(serverURL string)` option when initializing the SDK client instance. For example: +The default server can be overridden globally using the `WithServerURL(serverURL string)` option when initializing the SDK client instance. For example: ```go package main diff --git a/RELEASES.md b/RELEASES.md index bcf9753..21e9ed8 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -288,4 +288,14 @@ Based on: ### Generated - [go v0.12.0] . ### Releases -- [Go v0.12.0] https://github.com/unkeyed/unkey-go/releases/tag/v0.12.0 - . \ No newline at end of file +- [Go v0.12.0] https://github.com/unkeyed/unkey-go/releases/tag/v0.12.0 - . + +## 2025-05-08 00:34:20 +### Changes +Based on: +- OpenAPI Doc +- Speakeasy CLI 1.542.3 (2.597.9) https://github.com/speakeasy-api/speakeasy +### Generated +- [go v0.13.0] . +### Releases +- [Go v0.13.0] https://github.com/unkeyed/unkey-go/releases/tag/v0.13.0 - . \ No newline at end of file diff --git a/analytics.go b/analytics.go index ee06fc3..d851a59 100644 --- a/analytics.go +++ b/analytics.go @@ -27,13 +27,6 @@ func newAnalytics(sdkConfig sdkConfiguration) *Analytics { } func (s *Analytics) GetVerifications(ctx context.Context, request operations.GetVerificationsRequest, opts ...operations.Option) (*operations.GetVerificationsResponse, error) { - hookCtx := hooks.HookContext{ - Context: ctx, - OperationID: "getVerifications", - OAuth2Scopes: []string{}, - SecuritySource: s.sdkConfiguration.Security, - } - o := operations.Options{} supportedOptions := []string{ operations.SupportedOptionRetries, @@ -57,6 +50,14 @@ func (s *Analytics) GetVerifications(ctx context.Context, request operations.Get return nil, fmt.Errorf("error generating URL: %w", err) } + hookCtx := hooks.HookContext{ + BaseURL: baseURL, + Context: ctx, + OperationID: "getVerifications", + OAuth2Scopes: []string{}, + SecuritySource: s.sdkConfiguration.Security, + } + timeout := o.Timeout if timeout == nil { timeout = s.sdkConfiguration.Timeout @@ -167,7 +168,7 @@ func (s *Analytics) GetVerifications(ctx context.Context, request operations.Get _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) return nil, err - } else if utils.MatchStatusCodes([]string{"400", "401", "403", "404", "409", "429", "4XX", "500", "5XX"}, httpRes.StatusCode) { + } else if utils.MatchStatusCodes([]string{"400", "401", "403", "404", "409", "412", "429", "4XX", "500", "5XX"}, httpRes.StatusCode) { _httpRes, err := s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) if err != nil { return nil, err @@ -308,6 +309,27 @@ func (s *Analytics) GetVerifications(ctx context.Context, request operations.Get return nil, err } + return nil, &out + default: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + case httpRes.StatusCode == 412: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + + var out sdkerrors.ErrPreconditionFailed + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + return nil, &out default: rawBody, err := utils.ConsumeRawBody(httpRes) diff --git a/apis.go b/apis.go index 6dba4ac..fdff63a 100644 --- a/apis.go +++ b/apis.go @@ -27,13 +27,6 @@ func newApis(sdkConfig sdkConfiguration) *Apis { } func (s *Apis) GetAPI(ctx context.Context, request operations.GetAPIRequest, opts ...operations.Option) (*operations.GetAPIResponse, error) { - hookCtx := hooks.HookContext{ - Context: ctx, - OperationID: "getApi", - OAuth2Scopes: []string{}, - SecuritySource: s.sdkConfiguration.Security, - } - o := operations.Options{} supportedOptions := []string{ operations.SupportedOptionRetries, @@ -57,6 +50,14 @@ func (s *Apis) GetAPI(ctx context.Context, request operations.GetAPIRequest, opt return nil, fmt.Errorf("error generating URL: %w", err) } + hookCtx := hooks.HookContext{ + BaseURL: baseURL, + Context: ctx, + OperationID: "getApi", + OAuth2Scopes: []string{}, + SecuritySource: s.sdkConfiguration.Security, + } + timeout := o.Timeout if timeout == nil { timeout = s.sdkConfiguration.Timeout @@ -167,7 +168,7 @@ func (s *Apis) GetAPI(ctx context.Context, request operations.GetAPIRequest, opt _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) return nil, err - } else if utils.MatchStatusCodes([]string{"400", "401", "403", "404", "409", "429", "4XX", "500", "5XX"}, httpRes.StatusCode) { + } else if utils.MatchStatusCodes([]string{"400", "401", "403", "404", "409", "412", "429", "4XX", "500", "5XX"}, httpRes.StatusCode) { _httpRes, err := s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) if err != nil { return nil, err @@ -308,6 +309,27 @@ func (s *Apis) GetAPI(ctx context.Context, request operations.GetAPIRequest, opt return nil, err } + return nil, &out + default: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + case httpRes.StatusCode == 412: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + + var out sdkerrors.ErrPreconditionFailed + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + return nil, &out default: rawBody, err := utils.ConsumeRawBody(httpRes) @@ -383,13 +405,6 @@ func (s *Apis) GetAPI(ctx context.Context, request operations.GetAPIRequest, opt } func (s *Apis) CreateAPI(ctx context.Context, request operations.CreateAPIRequestBody, opts ...operations.Option) (*operations.CreateAPIResponse, error) { - hookCtx := hooks.HookContext{ - Context: ctx, - OperationID: "createApi", - OAuth2Scopes: []string{}, - SecuritySource: s.sdkConfiguration.Security, - } - o := operations.Options{} supportedOptions := []string{ operations.SupportedOptionRetries, @@ -413,6 +428,13 @@ func (s *Apis) CreateAPI(ctx context.Context, request operations.CreateAPIReques return nil, fmt.Errorf("error generating URL: %w", err) } + hookCtx := hooks.HookContext{ + BaseURL: baseURL, + Context: ctx, + OperationID: "createApi", + OAuth2Scopes: []string{}, + SecuritySource: s.sdkConfiguration.Security, + } bodyReader, reqContentType, err := utils.SerializeRequestBody(ctx, request, false, false, "Request", "json", `request:"mediaType=application/json"`) if err != nil { return nil, err @@ -527,7 +549,7 @@ func (s *Apis) CreateAPI(ctx context.Context, request operations.CreateAPIReques _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) return nil, err - } else if utils.MatchStatusCodes([]string{"400", "401", "403", "404", "409", "429", "4XX", "500", "5XX"}, httpRes.StatusCode) { + } else if utils.MatchStatusCodes([]string{"400", "401", "403", "404", "409", "412", "429", "4XX", "500", "5XX"}, httpRes.StatusCode) { _httpRes, err := s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) if err != nil { return nil, err @@ -668,6 +690,27 @@ func (s *Apis) CreateAPI(ctx context.Context, request operations.CreateAPIReques return nil, err } + return nil, &out + default: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + case httpRes.StatusCode == 412: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + + var out sdkerrors.ErrPreconditionFailed + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + return nil, &out default: rawBody, err := utils.ConsumeRawBody(httpRes) @@ -743,13 +786,6 @@ func (s *Apis) CreateAPI(ctx context.Context, request operations.CreateAPIReques } func (s *Apis) ListKeys(ctx context.Context, request operations.ListKeysRequest, opts ...operations.Option) (*operations.ListKeysResponse, error) { - hookCtx := hooks.HookContext{ - Context: ctx, - OperationID: "listKeys", - OAuth2Scopes: []string{}, - SecuritySource: s.sdkConfiguration.Security, - } - o := operations.Options{} supportedOptions := []string{ operations.SupportedOptionRetries, @@ -773,6 +809,14 @@ func (s *Apis) ListKeys(ctx context.Context, request operations.ListKeysRequest, return nil, fmt.Errorf("error generating URL: %w", err) } + hookCtx := hooks.HookContext{ + BaseURL: baseURL, + Context: ctx, + OperationID: "listKeys", + OAuth2Scopes: []string{}, + SecuritySource: s.sdkConfiguration.Security, + } + timeout := o.Timeout if timeout == nil { timeout = s.sdkConfiguration.Timeout @@ -883,7 +927,7 @@ func (s *Apis) ListKeys(ctx context.Context, request operations.ListKeysRequest, _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) return nil, err - } else if utils.MatchStatusCodes([]string{"400", "401", "403", "404", "409", "429", "4XX", "500", "5XX"}, httpRes.StatusCode) { + } else if utils.MatchStatusCodes([]string{"400", "401", "403", "404", "409", "412", "429", "4XX", "500", "5XX"}, httpRes.StatusCode) { _httpRes, err := s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) if err != nil { return nil, err @@ -1024,6 +1068,27 @@ func (s *Apis) ListKeys(ctx context.Context, request operations.ListKeysRequest, return nil, err } + return nil, &out + default: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + case httpRes.StatusCode == 412: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + + var out sdkerrors.ErrPreconditionFailed + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + return nil, &out default: rawBody, err := utils.ConsumeRawBody(httpRes) @@ -1099,13 +1164,6 @@ func (s *Apis) ListKeys(ctx context.Context, request operations.ListKeysRequest, } func (s *Apis) DeleteAPI(ctx context.Context, request operations.DeleteAPIRequestBody, opts ...operations.Option) (*operations.DeleteAPIResponse, error) { - hookCtx := hooks.HookContext{ - Context: ctx, - OperationID: "deleteApi", - OAuth2Scopes: []string{}, - SecuritySource: s.sdkConfiguration.Security, - } - o := operations.Options{} supportedOptions := []string{ operations.SupportedOptionRetries, @@ -1129,6 +1187,13 @@ func (s *Apis) DeleteAPI(ctx context.Context, request operations.DeleteAPIReques return nil, fmt.Errorf("error generating URL: %w", err) } + hookCtx := hooks.HookContext{ + BaseURL: baseURL, + Context: ctx, + OperationID: "deleteApi", + OAuth2Scopes: []string{}, + SecuritySource: s.sdkConfiguration.Security, + } bodyReader, reqContentType, err := utils.SerializeRequestBody(ctx, request, false, false, "Request", "json", `request:"mediaType=application/json"`) if err != nil { return nil, err @@ -1243,7 +1308,7 @@ func (s *Apis) DeleteAPI(ctx context.Context, request operations.DeleteAPIReques _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) return nil, err - } else if utils.MatchStatusCodes([]string{"400", "401", "403", "404", "409", "429", "4XX", "500", "5XX"}, httpRes.StatusCode) { + } else if utils.MatchStatusCodes([]string{"400", "401", "403", "404", "409", "412", "429", "4XX", "500", "5XX"}, httpRes.StatusCode) { _httpRes, err := s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) if err != nil { return nil, err @@ -1384,6 +1449,27 @@ func (s *Apis) DeleteAPI(ctx context.Context, request operations.DeleteAPIReques return nil, err } + return nil, &out + default: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + case httpRes.StatusCode == 412: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + + var out sdkerrors.ErrPreconditionFailed + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + return nil, &out default: rawBody, err := utils.ConsumeRawBody(httpRes) @@ -1459,13 +1545,6 @@ func (s *Apis) DeleteAPI(ctx context.Context, request operations.DeleteAPIReques } func (s *Apis) DeleteKeys(ctx context.Context, request operations.DeleteKeysRequestBody, opts ...operations.Option) (*operations.DeleteKeysResponse, error) { - hookCtx := hooks.HookContext{ - Context: ctx, - OperationID: "deleteKeys", - OAuth2Scopes: []string{}, - SecuritySource: s.sdkConfiguration.Security, - } - o := operations.Options{} supportedOptions := []string{ operations.SupportedOptionRetries, @@ -1489,6 +1568,13 @@ func (s *Apis) DeleteKeys(ctx context.Context, request operations.DeleteKeysRequ return nil, fmt.Errorf("error generating URL: %w", err) } + hookCtx := hooks.HookContext{ + BaseURL: baseURL, + Context: ctx, + OperationID: "deleteKeys", + OAuth2Scopes: []string{}, + SecuritySource: s.sdkConfiguration.Security, + } bodyReader, reqContentType, err := utils.SerializeRequestBody(ctx, request, false, false, "Request", "json", `request:"mediaType=application/json"`) if err != nil { return nil, err @@ -1603,7 +1689,7 @@ func (s *Apis) DeleteKeys(ctx context.Context, request operations.DeleteKeysRequ _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) return nil, err - } else if utils.MatchStatusCodes([]string{"400", "401", "403", "404", "409", "429", "4XX", "500", "5XX"}, httpRes.StatusCode) { + } else if utils.MatchStatusCodes([]string{"400", "401", "403", "404", "409", "412", "429", "4XX", "500", "5XX"}, httpRes.StatusCode) { _httpRes, err := s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) if err != nil { return nil, err @@ -1744,6 +1830,27 @@ func (s *Apis) DeleteKeys(ctx context.Context, request operations.DeleteKeysRequ return nil, err } + return nil, &out + default: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + case httpRes.StatusCode == 412: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + + var out sdkerrors.ErrPreconditionFailed + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + return nil, &out default: rawBody, err := utils.ConsumeRawBody(httpRes) diff --git a/docs/models/components/v1keysverifykeyresponse.md b/docs/models/components/v1keysverifykeyresponse.md index a99ac4d..ea7c516 100644 --- a/docs/models/components/v1keysverifykeyresponse.md +++ b/docs/models/components/v1keysverifykeyresponse.md @@ -16,5 +16,7 @@ | `Code` | [components.Code](../../models/components/code.md) | :heavy_check_mark: | A machine readable code why the key is not valid.
Possible values are:
- VALID: the key is valid and you should proceed
- NOT_FOUND: the key does not exist or has expired
- FORBIDDEN: the key is not allowed to access the api
- USAGE_EXCEEDED: the key has exceeded its request limit
- RATE_LIMITED: the key has been ratelimited
- UNAUTHORIZED: the key is not authorized
- DISABLED: the key is disabled
- INSUFFICIENT_PERMISSIONS: you do not have the required permissions to perform this action
- EXPIRED: The key was only valid for a certain time and has expired.

These are validation codes, the HTTP status will be 200.
| | | `Enabled` | **bool* | :heavy_minus_sign: | Sets the key to be enabled or disabled. Disabled keys will not verify. | | | `Permissions` | []*string* | :heavy_minus_sign: | A list of all the permissions this key is connected to. | [
"dns.record.update",
"dns.record.delete"
] | +| `Roles` | []*string* | :heavy_minus_sign: | A list of all the roles this key is connected to. | [
"admin"
] | | `Environment` | **string* | :heavy_minus_sign: | The environment of the key, this is what what you set when you crated the key | test | -| `Identity` | [*components.V1KeysVerifyKeyResponseIdentity](../../models/components/v1keysverifykeyresponseidentity.md) | :heavy_minus_sign: | The associated identity of this key. | | \ No newline at end of file +| `Identity` | [*components.V1KeysVerifyKeyResponseIdentity](../../models/components/v1keysverifykeyresponseidentity.md) | :heavy_minus_sign: | The associated identity of this key. | | +| `RequestID` | *string* | :heavy_check_mark: | A unique id for this request, please provide it to Unkey support to help us debug your issue. | | \ No newline at end of file diff --git a/docs/models/operations/createidentityrequestbody.md b/docs/models/operations/createidentityrequestbody.md index a292fe7..71dc8ac 100644 --- a/docs/models/operations/createidentityrequestbody.md +++ b/docs/models/operations/createidentityrequestbody.md @@ -3,8 +3,8 @@ ## Fields -| Field | Type | Required | Description | Example | -| --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `ExternalID` | *string* | :heavy_check_mark: | The id of this identity in your system.

This usually comes from your authentication provider and could be a userId, organisationId or even an email.
It does not matter what you use, as long as it uniquely identifies something in your application.

`externalId`s are unique across your workspace and therefore a `PRECONDITION_FAILED` error is returned when you try to create duplicates.
| user_123 | -| `Meta` | map[string]*any* | :heavy_minus_sign: | Attach metadata to this identity that you need to have access to when verifying a key.

This will be returned as part of the `verifyKey` response.
| | -| `Ratelimits` | [][operations.Ratelimits](../../models/operations/ratelimits.md) | :heavy_minus_sign: | Attach ratelimits to this identity.

When verifying keys, you can specify which limits you want to use and all keys attached to this identity, will share the limits. | | \ No newline at end of file +| Field | Type | Required | Description | Example | +| ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `ExternalID` | *string* | :heavy_check_mark: | The id of this identity in your system.

This usually comes from your authentication provider and could be a userId, organisationId or even an email.
It does not matter what you use, as long as it uniquely identifies something in your application.

`externalId`s are unique across your workspace and therefore a `CONFLICT` error is returned when you try to create duplicates.
| user_123 | +| `Meta` | map[string]*any* | :heavy_minus_sign: | Attach metadata to this identity that you need to have access to when verifying a key.

This will be returned as part of the `verifyKey` response.
| | +| `Ratelimits` | [][operations.Ratelimits](../../models/operations/ratelimits.md) | :heavy_minus_sign: | Attach ratelimits to this identity.

When verifying keys, you can specify which limits you want to use and all keys attached to this identity, will share the limits. | | \ No newline at end of file diff --git a/docs/models/operations/createpermissionrequestbody.md b/docs/models/operations/createpermissionrequestbody.md index 87a393d..206acb4 100644 --- a/docs/models/operations/createpermissionrequestbody.md +++ b/docs/models/operations/createpermissionrequestbody.md @@ -6,4 +6,4 @@ | Field | Type | Required | Description | Example | | -------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------- | | `Name` | *string* | :heavy_check_mark: | The unique name of your permission. | record.write | -| `Description` | **string* | :heavy_minus_sign: | Explain what this permission does. This is just for your team, your users will not see this. | record.write can create new dns records for our domains. | \ No newline at end of file +| `Description` | [*operations.Description](../../models/operations/description.md) | :heavy_minus_sign: | Explain what this permission does. This is just for your team, your users will not see this. | record.write can create new dns records for our domains. | \ No newline at end of file diff --git a/docs/models/operations/createroledescription.md b/docs/models/operations/createroledescription.md new file mode 100644 index 0000000..06ffe01 --- /dev/null +++ b/docs/models/operations/createroledescription.md @@ -0,0 +1,19 @@ +# CreateRoleDescription + +Explain what this role does. This is just for your team, your users will not see this. + + +## Supported Types + +### + +```go +createRoleDescription := operations.CreateCreateRoleDescriptionStr(string{/* values here */}) +``` + +### Description2 + +```go +createRoleDescription := operations.CreateCreateRoleDescriptionDescription2(operations.Description2{/* values here */}) +``` + diff --git a/docs/models/operations/createrolerequestbody.md b/docs/models/operations/createrolerequestbody.md index 5e3c805..4c639ca 100644 --- a/docs/models/operations/createrolerequestbody.md +++ b/docs/models/operations/createrolerequestbody.md @@ -6,4 +6,4 @@ | Field | Type | Required | Description | Example | | -------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------- | | `Name` | *string* | :heavy_check_mark: | The unique name of your role. | dns.records.manager | -| `Description` | **string* | :heavy_minus_sign: | Explain what this role does. This is just for your team, your users will not see this. | dns.records.manager can read and write dns records for our domains. | \ No newline at end of file +| `Description` | [*operations.CreateRoleDescription](../../models/operations/createroledescription.md) | :heavy_minus_sign: | Explain what this role does. This is just for your team, your users will not see this. | dns.records.manager can read and write dns records for our domains. | \ No newline at end of file diff --git a/docs/models/operations/deletekeyrequestbody.md b/docs/models/operations/deletekeyrequestbody.md index f9cac91..f8dbd36 100644 --- a/docs/models/operations/deletekeyrequestbody.md +++ b/docs/models/operations/deletekeyrequestbody.md @@ -3,7 +3,7 @@ ## Fields -| Field | Type | Required | Description | Example | -| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `KeyID` | *string* | :heavy_check_mark: | The id of the key to revoke | key_1234 | -| `Permanent` | **bool* | :heavy_minus_sign: | By default Unkey soft deletes keys, so they may be recovered later. If you want to permanently delete it, set permanent=true. This might be necessary if you run into NOT_UNIQUE errors during key migration. | | \ No newline at end of file +| Field | Type | Required | Description | Example | +| ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `KeyID` | *string* | :heavy_check_mark: | The id of the key to revoke | key_1234 | +| `Permanent` | **bool* | :heavy_minus_sign: | By default Unkey soft deletes keys, so they may be recovered later. If you want to permanently delete it, set permanent=true. This might be necessary if you run into CONFLICT errors during key migration. | | \ No newline at end of file diff --git a/docs/models/operations/description.md b/docs/models/operations/description.md new file mode 100644 index 0000000..fd6f9a2 --- /dev/null +++ b/docs/models/operations/description.md @@ -0,0 +1,19 @@ +# Description + +Explain what this permission does. This is just for your team, your users will not see this. + + +## Supported Types + +### + +```go +description := operations.CreateDescriptionStr(string{/* values here */}) +``` + +### Two + +```go +description := operations.CreateDescriptionTwo(operations.Two{/* values here */}) +``` + diff --git a/docs/models/operations/description2.md b/docs/models/operations/description2.md new file mode 100644 index 0000000..79c0f67 --- /dev/null +++ b/docs/models/operations/description2.md @@ -0,0 +1,8 @@ +# Description2 + + +## Values + +| Name | Value | +| --------------------- | --------------------- | +| `Description2Unknown` | | \ No newline at end of file diff --git a/docs/models/operations/groupby.md b/docs/models/operations/groupby.md index 39a4ae8..ceb602e 100644 --- a/docs/models/operations/groupby.md +++ b/docs/models/operations/groupby.md @@ -16,6 +16,6 @@ groupBy := operations.CreateGroupByOne(operations.One{/* values here */}) ### ```go -groupBy := operations.CreateGroupByArrayOf2([]operations.Two{/* values here */}) +groupBy := operations.CreateGroupByArrayOfQueryParam2([]operations.QueryParam2{/* values here */}) ``` diff --git a/docs/models/operations/queryparam2.md b/docs/models/operations/queryparam2.md new file mode 100644 index 0000000..c85bae8 --- /dev/null +++ b/docs/models/operations/queryparam2.md @@ -0,0 +1,14 @@ +# QueryParam2 + + +## Values + +| Name | Value | +| --------------------- | --------------------- | +| `QueryParam2Key` | key | +| `QueryParam2Identity` | identity | +| `QueryParam2Tags` | tags | +| `QueryParam2Tag` | tag | +| `QueryParam2Month` | month | +| `QueryParam2Day` | day | +| `QueryParam2Hour` | hour | \ No newline at end of file diff --git a/docs/models/operations/two.md b/docs/models/operations/two.md index 5902bef..2f21be5 100644 --- a/docs/models/operations/two.md +++ b/docs/models/operations/two.md @@ -3,12 +3,6 @@ ## Values -| Name | Value | -| ------------- | ------------- | -| `TwoKey` | key | -| `TwoIdentity` | identity | -| `TwoTags` | tags | -| `TwoTag` | tag | -| `TwoMonth` | month | -| `TwoDay` | day | -| `TwoHour` | hour | \ No newline at end of file +| Name | Value | +| ------------ | ------------ | +| `TwoUnknown` | | \ No newline at end of file diff --git a/docs/models/sdkerrors/errpreconditionfailed.md b/docs/models/sdkerrors/errpreconditionfailed.md new file mode 100644 index 0000000..2d1646d --- /dev/null +++ b/docs/models/sdkerrors/errpreconditionfailed.md @@ -0,0 +1,8 @@ +# ErrPreconditionFailed + + +## Fields + +| Field | Type | Required | Description | +| -------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------- | +| `Error` | [sdkerrors.ErrPreconditionFailedError](../../models/sdkerrors/errpreconditionfailederror.md) | :heavy_check_mark: | N/A | \ No newline at end of file diff --git a/docs/models/sdkerrors/errpreconditionfailedcode.md b/docs/models/sdkerrors/errpreconditionfailedcode.md new file mode 100644 index 0000000..b5f9189 --- /dev/null +++ b/docs/models/sdkerrors/errpreconditionfailedcode.md @@ -0,0 +1,10 @@ +# ErrPreconditionFailedCode + +A machine readable error code. + + +## Values + +| Name | Value | +| --------------------------------------------- | --------------------------------------------- | +| `ErrPreconditionFailedCodePreconditionFailed` | PRECONDITION_FAILED | \ No newline at end of file diff --git a/docs/models/sdkerrors/errpreconditionfailederror.md b/docs/models/sdkerrors/errpreconditionfailederror.md new file mode 100644 index 0000000..1e83173 --- /dev/null +++ b/docs/models/sdkerrors/errpreconditionfailederror.md @@ -0,0 +1,11 @@ +# ErrPreconditionFailedError + + +## Fields + +| Field | Type | Required | Description | Example | +| ------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------ | +| `Code` | [sdkerrors.ErrPreconditionFailedCode](../../models/sdkerrors/errpreconditionfailedcode.md) | :heavy_check_mark: | A machine readable error code. | PRECONDITION_FAILED | +| `Docs` | *string* | :heavy_check_mark: | A link to our documentation with more details about this error code | https://unkey.dev/docs/api-reference/errors/code/PRECONDITION_FAILED | +| `Message` | *string* | :heavy_check_mark: | A human readable explanation of what went wrong | | +| `RequestID` | *string* | :heavy_check_mark: | Please always include the requestId in your error report | req_1234 | \ No newline at end of file diff --git a/docs/sdks/analytics/README.md b/docs/sdks/analytics/README.md index 19ab831..af42b75 100644 --- a/docs/sdks/analytics/README.md +++ b/docs/sdks/analytics/README.md @@ -23,7 +23,7 @@ import( func main() { ctx := context.Background() - + s := unkeygo.New( unkeygo.WithSecurity("UNKEY_ROOT_KEY"), ) @@ -72,6 +72,7 @@ func main() { | sdkerrors.ErrForbidden | 403 | application/json | | sdkerrors.ErrNotFound | 404 | application/json | | sdkerrors.ErrConflict | 409 | application/json | +| sdkerrors.ErrPreconditionFailed | 412 | application/json | | sdkerrors.ErrTooManyRequests | 429 | application/json | | sdkerrors.ErrInternalServerError | 500 | application/json | | sdkerrors.SDKError | 4XX, 5XX | \*/\* | \ No newline at end of file diff --git a/docs/sdks/apis/README.md b/docs/sdks/apis/README.md index b18d897..d5579c1 100644 --- a/docs/sdks/apis/README.md +++ b/docs/sdks/apis/README.md @@ -27,7 +27,7 @@ import( func main() { ctx := context.Background() - + s := unkeygo.New( unkeygo.WithSecurity("UNKEY_ROOT_KEY"), ) @@ -65,6 +65,7 @@ func main() { | sdkerrors.ErrForbidden | 403 | application/json | | sdkerrors.ErrNotFound | 404 | application/json | | sdkerrors.ErrConflict | 409 | application/json | +| sdkerrors.ErrPreconditionFailed | 412 | application/json | | sdkerrors.ErrTooManyRequests | 429 | application/json | | sdkerrors.ErrInternalServerError | 500 | application/json | | sdkerrors.SDKError | 4XX, 5XX | \*/\* | @@ -85,7 +86,7 @@ import( func main() { ctx := context.Background() - + s := unkeygo.New( unkeygo.WithSecurity("UNKEY_ROOT_KEY"), ) @@ -123,6 +124,7 @@ func main() { | sdkerrors.ErrForbidden | 403 | application/json | | sdkerrors.ErrNotFound | 404 | application/json | | sdkerrors.ErrConflict | 409 | application/json | +| sdkerrors.ErrPreconditionFailed | 412 | application/json | | sdkerrors.ErrTooManyRequests | 429 | application/json | | sdkerrors.ErrInternalServerError | 500 | application/json | | sdkerrors.SDKError | 4XX, 5XX | \*/\* | @@ -143,7 +145,7 @@ import( func main() { ctx := context.Background() - + s := unkeygo.New( unkeygo.WithSecurity("UNKEY_ROOT_KEY"), ) @@ -181,6 +183,7 @@ func main() { | sdkerrors.ErrForbidden | 403 | application/json | | sdkerrors.ErrNotFound | 404 | application/json | | sdkerrors.ErrConflict | 409 | application/json | +| sdkerrors.ErrPreconditionFailed | 412 | application/json | | sdkerrors.ErrTooManyRequests | 429 | application/json | | sdkerrors.ErrInternalServerError | 500 | application/json | | sdkerrors.SDKError | 4XX, 5XX | \*/\* | @@ -201,7 +204,7 @@ import( func main() { ctx := context.Background() - + s := unkeygo.New( unkeygo.WithSecurity("UNKEY_ROOT_KEY"), ) @@ -239,6 +242,7 @@ func main() { | sdkerrors.ErrForbidden | 403 | application/json | | sdkerrors.ErrNotFound | 404 | application/json | | sdkerrors.ErrConflict | 409 | application/json | +| sdkerrors.ErrPreconditionFailed | 412 | application/json | | sdkerrors.ErrDeleteProtected | 429 | application/json | | sdkerrors.ErrInternalServerError | 500 | application/json | | sdkerrors.SDKError | 4XX, 5XX | \*/\* | @@ -259,7 +263,7 @@ import( func main() { ctx := context.Background() - + s := unkeygo.New( unkeygo.WithSecurity("UNKEY_ROOT_KEY"), ) @@ -297,6 +301,7 @@ func main() { | sdkerrors.ErrForbidden | 403 | application/json | | sdkerrors.ErrNotFound | 404 | application/json | | sdkerrors.ErrConflict | 409 | application/json | +| sdkerrors.ErrPreconditionFailed | 412 | application/json | | sdkerrors.ErrTooManyRequests | 429 | application/json | | sdkerrors.ErrInternalServerError | 500 | application/json | | sdkerrors.SDKError | 4XX, 5XX | \*/\* | \ No newline at end of file diff --git a/docs/sdks/identities/README.md b/docs/sdks/identities/README.md index b45ac47..6782fcd 100644 --- a/docs/sdks/identities/README.md +++ b/docs/sdks/identities/README.md @@ -27,7 +27,7 @@ import( func main() { ctx := context.Background() - + s := unkeygo.New( unkeygo.WithSecurity("UNKEY_ROOT_KEY"), ) @@ -82,6 +82,7 @@ func main() { | sdkerrors.ErrForbidden | 403 | application/json | | sdkerrors.ErrNotFound | 404 | application/json | | sdkerrors.ErrConflict | 409 | application/json | +| sdkerrors.ErrPreconditionFailed | 412 | application/json | | sdkerrors.ErrTooManyRequests | 429 | application/json | | sdkerrors.ErrInternalServerError | 500 | application/json | | sdkerrors.SDKError | 4XX, 5XX | \*/\* | @@ -102,7 +103,7 @@ import( func main() { ctx := context.Background() - + s := unkeygo.New( unkeygo.WithSecurity("UNKEY_ROOT_KEY"), ) @@ -141,6 +142,7 @@ func main() { | sdkerrors.ErrForbidden | 403 | application/json | | sdkerrors.ErrNotFound | 404 | application/json | | sdkerrors.ErrConflict | 409 | application/json | +| sdkerrors.ErrPreconditionFailed | 412 | application/json | | sdkerrors.ErrTooManyRequests | 429 | application/json | | sdkerrors.ErrInternalServerError | 500 | application/json | | sdkerrors.SDKError | 4XX, 5XX | \*/\* | @@ -161,7 +163,7 @@ import( func main() { ctx := context.Background() - + s := unkeygo.New( unkeygo.WithSecurity("UNKEY_ROOT_KEY"), ) @@ -209,6 +211,7 @@ func main() { | sdkerrors.ErrForbidden | 403 | application/json | | sdkerrors.ErrNotFound | 404 | application/json | | sdkerrors.ErrConflict | 409 | application/json | +| sdkerrors.ErrPreconditionFailed | 412 | application/json | | sdkerrors.ErrTooManyRequests | 429 | application/json | | sdkerrors.ErrInternalServerError | 500 | application/json | | sdkerrors.SDKError | 4XX, 5XX | \*/\* | @@ -229,7 +232,7 @@ import( func main() { ctx := context.Background() - + s := unkeygo.New( unkeygo.WithSecurity("UNKEY_ROOT_KEY"), ) @@ -285,6 +288,7 @@ func main() { | sdkerrors.ErrForbidden | 403 | application/json | | sdkerrors.ErrNotFound | 404 | application/json | | sdkerrors.ErrConflict | 409 | application/json | +| sdkerrors.ErrPreconditionFailed | 412 | application/json | | sdkerrors.ErrTooManyRequests | 429 | application/json | | sdkerrors.ErrInternalServerError | 500 | application/json | | sdkerrors.SDKError | 4XX, 5XX | \*/\* | @@ -305,7 +309,7 @@ import( func main() { ctx := context.Background() - + s := unkeygo.New( unkeygo.WithSecurity("UNKEY_ROOT_KEY"), ) @@ -343,6 +347,7 @@ func main() { | sdkerrors.ErrForbidden | 403 | application/json | | sdkerrors.ErrNotFound | 404 | application/json | | sdkerrors.ErrConflict | 409 | application/json | +| sdkerrors.ErrPreconditionFailed | 412 | application/json | | sdkerrors.ErrTooManyRequests | 429 | application/json | | sdkerrors.ErrInternalServerError | 500 | application/json | | sdkerrors.SDKError | 4XX, 5XX | \*/\* | \ No newline at end of file diff --git a/docs/sdks/keys/README.md b/docs/sdks/keys/README.md index 8c89053..3f0eb55 100644 --- a/docs/sdks/keys/README.md +++ b/docs/sdks/keys/README.md @@ -36,7 +36,7 @@ import( func main() { ctx := context.Background() - + s := unkeygo.New( unkeygo.WithSecurity("UNKEY_ROOT_KEY"), ) @@ -74,6 +74,7 @@ func main() { | sdkerrors.ErrForbidden | 403 | application/json | | sdkerrors.ErrNotFound | 404 | application/json | | sdkerrors.ErrConflict | 409 | application/json | +| sdkerrors.ErrPreconditionFailed | 412 | application/json | | sdkerrors.ErrTooManyRequests | 429 | application/json | | sdkerrors.ErrInternalServerError | 500 | application/json | | sdkerrors.SDKError | 4XX, 5XX | \*/\* | @@ -94,7 +95,7 @@ import( func main() { ctx := context.Background() - + s := unkeygo.New( unkeygo.WithSecurity("UNKEY_ROOT_KEY"), ) @@ -132,6 +133,7 @@ func main() { | sdkerrors.ErrForbidden | 403 | application/json | | sdkerrors.ErrNotFound | 404 | application/json | | sdkerrors.ErrConflict | 409 | application/json | +| sdkerrors.ErrPreconditionFailed | 412 | application/json | | sdkerrors.ErrTooManyRequests | 429 | application/json | | sdkerrors.ErrInternalServerError | 500 | application/json | | sdkerrors.SDKError | 4XX, 5XX | \*/\* | @@ -152,7 +154,7 @@ import( func main() { ctx := context.Background() - + s := unkeygo.New( unkeygo.WithSecurity("UNKEY_ROOT_KEY"), ) @@ -190,6 +192,7 @@ func main() { | sdkerrors.ErrForbidden | 403 | application/json | | sdkerrors.ErrNotFound | 404 | application/json | | sdkerrors.ErrConflict | 409 | application/json | +| sdkerrors.ErrPreconditionFailed | 412 | application/json | | sdkerrors.ErrTooManyRequests | 429 | application/json | | sdkerrors.ErrInternalServerError | 500 | application/json | | sdkerrors.SDKError | 4XX, 5XX | \*/\* | @@ -210,7 +213,7 @@ import( func main() { ctx := context.Background() - + s := unkeygo.New( unkeygo.WithSecurity("UNKEY_ROOT_KEY"), ) @@ -273,6 +276,7 @@ func main() { | sdkerrors.ErrForbidden | 403 | application/json | | sdkerrors.ErrNotFound | 404 | application/json | | sdkerrors.ErrConflict | 409 | application/json | +| sdkerrors.ErrPreconditionFailed | 412 | application/json | | sdkerrors.ErrTooManyRequests | 429 | application/json | | sdkerrors.ErrInternalServerError | 500 | application/json | | sdkerrors.SDKError | 4XX, 5XX | \*/\* | @@ -293,7 +297,7 @@ import( func main() { ctx := context.Background() - + s := unkeygo.New( unkeygo.WithSecurity("UNKEY_ROOT_KEY"), ) @@ -348,6 +352,7 @@ func main() { | sdkerrors.ErrForbidden | 403 | application/json | | sdkerrors.ErrNotFound | 404 | application/json | | sdkerrors.ErrConflict | 409 | application/json | +| sdkerrors.ErrPreconditionFailed | 412 | application/json | | sdkerrors.ErrTooManyRequests | 429 | application/json | | sdkerrors.ErrInternalServerError | 500 | application/json | | sdkerrors.SDKError | 4XX, 5XX | \*/\* | @@ -368,7 +373,7 @@ import( func main() { ctx := context.Background() - + s := unkeygo.New( unkeygo.WithSecurity("UNKEY_ROOT_KEY"), ) @@ -452,6 +457,7 @@ func main() { | sdkerrors.ErrForbidden | 403 | application/json | | sdkerrors.ErrNotFound | 404 | application/json | | sdkerrors.ErrConflict | 409 | application/json | +| sdkerrors.ErrPreconditionFailed | 412 | application/json | | sdkerrors.ErrTooManyRequests | 429 | application/json | | sdkerrors.ErrInternalServerError | 500 | application/json | | sdkerrors.SDKError | 4XX, 5XX | \*/\* | @@ -472,7 +478,7 @@ import( func main() { ctx := context.Background() - + s := unkeygo.New( unkeygo.WithSecurity("UNKEY_ROOT_KEY"), ) @@ -512,6 +518,7 @@ func main() { | sdkerrors.ErrForbidden | 403 | application/json | | sdkerrors.ErrNotFound | 404 | application/json | | sdkerrors.ErrConflict | 409 | application/json | +| sdkerrors.ErrPreconditionFailed | 412 | application/json | | sdkerrors.ErrTooManyRequests | 429 | application/json | | sdkerrors.ErrInternalServerError | 500 | application/json | | sdkerrors.SDKError | 4XX, 5XX | \*/\* | @@ -532,7 +539,7 @@ import( func main() { ctx := context.Background() - + s := unkeygo.New( unkeygo.WithSecurity("UNKEY_ROOT_KEY"), ) @@ -573,6 +580,7 @@ func main() { | sdkerrors.ErrForbidden | 403 | application/json | | sdkerrors.ErrNotFound | 404 | application/json | | sdkerrors.ErrConflict | 409 | application/json | +| sdkerrors.ErrPreconditionFailed | 412 | application/json | | sdkerrors.ErrTooManyRequests | 429 | application/json | | sdkerrors.ErrInternalServerError | 500 | application/json | | sdkerrors.SDKError | 4XX, 5XX | \*/\* | @@ -593,7 +601,7 @@ import( func main() { ctx := context.Background() - + s := unkeygo.New( unkeygo.WithSecurity("UNKEY_ROOT_KEY"), ) @@ -636,6 +644,7 @@ func main() { | sdkerrors.ErrForbidden | 403 | application/json | | sdkerrors.ErrNotFound | 404 | application/json | | sdkerrors.ErrConflict | 409 | application/json | +| sdkerrors.ErrPreconditionFailed | 412 | application/json | | sdkerrors.ErrTooManyRequests | 429 | application/json | | sdkerrors.ErrInternalServerError | 500 | application/json | | sdkerrors.SDKError | 4XX, 5XX | \*/\* | @@ -656,7 +665,7 @@ import( func main() { ctx := context.Background() - + s := unkeygo.New( unkeygo.WithSecurity("UNKEY_ROOT_KEY"), ) @@ -702,6 +711,7 @@ func main() { | sdkerrors.ErrForbidden | 403 | application/json | | sdkerrors.ErrNotFound | 404 | application/json | | sdkerrors.ErrConflict | 409 | application/json | +| sdkerrors.ErrPreconditionFailed | 412 | application/json | | sdkerrors.ErrTooManyRequests | 429 | application/json | | sdkerrors.ErrInternalServerError | 500 | application/json | | sdkerrors.SDKError | 4XX, 5XX | \*/\* | @@ -722,7 +732,7 @@ import( func main() { ctx := context.Background() - + s := unkeygo.New( unkeygo.WithSecurity("UNKEY_ROOT_KEY"), ) @@ -772,6 +782,7 @@ func main() { | sdkerrors.ErrForbidden | 403 | application/json | | sdkerrors.ErrNotFound | 404 | application/json | | sdkerrors.ErrConflict | 409 | application/json | +| sdkerrors.ErrPreconditionFailed | 412 | application/json | | sdkerrors.ErrTooManyRequests | 429 | application/json | | sdkerrors.ErrInternalServerError | 500 | application/json | | sdkerrors.SDKError | 4XX, 5XX | \*/\* | @@ -792,7 +803,7 @@ import( func main() { ctx := context.Background() - + s := unkeygo.New( unkeygo.WithSecurity("UNKEY_ROOT_KEY"), ) @@ -842,6 +853,7 @@ func main() { | sdkerrors.ErrForbidden | 403 | application/json | | sdkerrors.ErrNotFound | 404 | application/json | | sdkerrors.ErrConflict | 409 | application/json | +| sdkerrors.ErrPreconditionFailed | 412 | application/json | | sdkerrors.ErrTooManyRequests | 429 | application/json | | sdkerrors.ErrInternalServerError | 500 | application/json | | sdkerrors.SDKError | 4XX, 5XX | \*/\* | @@ -862,7 +874,7 @@ import( func main() { ctx := context.Background() - + s := unkeygo.New( unkeygo.WithSecurity("UNKEY_ROOT_KEY"), ) @@ -908,6 +920,7 @@ func main() { | sdkerrors.ErrForbidden | 403 | application/json | | sdkerrors.ErrNotFound | 404 | application/json | | sdkerrors.ErrConflict | 409 | application/json | +| sdkerrors.ErrPreconditionFailed | 412 | application/json | | sdkerrors.ErrTooManyRequests | 429 | application/json | | sdkerrors.ErrInternalServerError | 500 | application/json | | sdkerrors.SDKError | 4XX, 5XX | \*/\* | @@ -928,7 +941,7 @@ import( func main() { ctx := context.Background() - + s := unkeygo.New( unkeygo.WithSecurity("UNKEY_ROOT_KEY"), ) @@ -978,6 +991,7 @@ func main() { | sdkerrors.ErrForbidden | 403 | application/json | | sdkerrors.ErrNotFound | 404 | application/json | | sdkerrors.ErrConflict | 409 | application/json | +| sdkerrors.ErrPreconditionFailed | 412 | application/json | | sdkerrors.ErrTooManyRequests | 429 | application/json | | sdkerrors.ErrInternalServerError | 500 | application/json | | sdkerrors.SDKError | 4XX, 5XX | \*/\* | \ No newline at end of file diff --git a/docs/sdks/liveness/README.md b/docs/sdks/liveness/README.md index b648cc5..cac149e 100644 --- a/docs/sdks/liveness/README.md +++ b/docs/sdks/liveness/README.md @@ -22,7 +22,7 @@ import( func main() { ctx := context.Background() - + s := unkeygo.New( unkeygo.WithSecurity("UNKEY_ROOT_KEY"), ) @@ -57,6 +57,7 @@ func main() { | sdkerrors.ErrForbidden | 403 | application/json | | sdkerrors.ErrNotFound | 404 | application/json | | sdkerrors.ErrConflict | 409 | application/json | +| sdkerrors.ErrPreconditionFailed | 412 | application/json | | sdkerrors.ErrTooManyRequests | 429 | application/json | | sdkerrors.ErrInternalServerError | 500 | application/json | | sdkerrors.SDKError | 4XX, 5XX | \*/\* | \ No newline at end of file diff --git a/docs/sdks/migrations/README.md b/docs/sdks/migrations/README.md index ed7f155..43ea8be 100644 --- a/docs/sdks/migrations/README.md +++ b/docs/sdks/migrations/README.md @@ -24,14 +24,12 @@ import( func main() { ctx := context.Background() - + s := unkeygo.New( unkeygo.WithSecurity("UNKEY_ROOT_KEY"), ) - res, err := s.Migrations.V1MigrationsCreateKeys(ctx, []operations.RequestBody{ - - }) + res, err := s.Migrations.V1MigrationsCreateKeys(ctx, []operations.RequestBody{}) if err != nil { log.Fatal(err) } @@ -62,6 +60,7 @@ func main() { | sdkerrors.ErrForbidden | 403 | application/json | | sdkerrors.ErrNotFound | 404 | application/json | | sdkerrors.ErrConflict | 409 | application/json | +| sdkerrors.ErrPreconditionFailed | 412 | application/json | | sdkerrors.ErrTooManyRequests | 429 | application/json | | sdkerrors.ErrInternalServerError | 500 | application/json | | sdkerrors.SDKError | 4XX, 5XX | \*/\* | @@ -82,7 +81,7 @@ import( func main() { ctx := context.Background() - + s := unkeygo.New( unkeygo.WithSecurity("UNKEY_ROOT_KEY"), ) @@ -150,6 +149,7 @@ func main() { | sdkerrors.ErrForbidden | 403 | application/json | | sdkerrors.ErrNotFound | 404 | application/json | | sdkerrors.ErrConflict | 409 | application/json | +| sdkerrors.ErrPreconditionFailed | 412 | application/json | | sdkerrors.ErrTooManyRequests | 429 | application/json | | sdkerrors.ErrInternalServerError | 500 | application/json | | sdkerrors.SDKError | 4XX, 5XX | \*/\* | \ No newline at end of file diff --git a/docs/sdks/permissions/README.md b/docs/sdks/permissions/README.md index 458a4eb..2510e1d 100644 --- a/docs/sdks/permissions/README.md +++ b/docs/sdks/permissions/README.md @@ -30,14 +30,16 @@ import( func main() { ctx := context.Background() - + s := unkeygo.New( unkeygo.WithSecurity("UNKEY_ROOT_KEY"), ) res, err := s.Permissions.CreatePermission(ctx, operations.CreatePermissionRequestBody{ Name: "record.write", - Description: unkeygo.String("record.write can create new dns records for our domains."), + Description: unkeygo.Pointer(operations.CreateDescriptionStr( + "record.write can create new dns records for our domains.", + )), }) if err != nil { log.Fatal(err) @@ -69,6 +71,7 @@ func main() { | sdkerrors.ErrForbidden | 403 | application/json | | sdkerrors.ErrNotFound | 404 | application/json | | sdkerrors.ErrConflict | 409 | application/json | +| sdkerrors.ErrPreconditionFailed | 412 | application/json | | sdkerrors.ErrTooManyRequests | 429 | application/json | | sdkerrors.ErrInternalServerError | 500 | application/json | | sdkerrors.SDKError | 4XX, 5XX | \*/\* | @@ -89,7 +92,7 @@ import( func main() { ctx := context.Background() - + s := unkeygo.New( unkeygo.WithSecurity("UNKEY_ROOT_KEY"), ) @@ -127,6 +130,7 @@ func main() { | sdkerrors.ErrForbidden | 403 | application/json | | sdkerrors.ErrNotFound | 404 | application/json | | sdkerrors.ErrConflict | 409 | application/json | +| sdkerrors.ErrPreconditionFailed | 412 | application/json | | sdkerrors.ErrTooManyRequests | 429 | application/json | | sdkerrors.ErrInternalServerError | 500 | application/json | | sdkerrors.SDKError | 4XX, 5XX | \*/\* | @@ -147,7 +151,7 @@ import( func main() { ctx := context.Background() - + s := unkeygo.New( unkeygo.WithSecurity("UNKEY_ROOT_KEY"), ) @@ -185,6 +189,7 @@ func main() { | sdkerrors.ErrForbidden | 403 | application/json | | sdkerrors.ErrNotFound | 404 | application/json | | sdkerrors.ErrConflict | 409 | application/json | +| sdkerrors.ErrPreconditionFailed | 412 | application/json | | sdkerrors.ErrTooManyRequests | 429 | application/json | | sdkerrors.ErrInternalServerError | 500 | application/json | | sdkerrors.SDKError | 4XX, 5XX | \*/\* | @@ -204,7 +209,7 @@ import( func main() { ctx := context.Background() - + s := unkeygo.New( unkeygo.WithSecurity("UNKEY_ROOT_KEY"), ) @@ -239,6 +244,7 @@ func main() { | sdkerrors.ErrForbidden | 403 | application/json | | sdkerrors.ErrNotFound | 404 | application/json | | sdkerrors.ErrConflict | 409 | application/json | +| sdkerrors.ErrPreconditionFailed | 412 | application/json | | sdkerrors.ErrTooManyRequests | 429 | application/json | | sdkerrors.ErrInternalServerError | 500 | application/json | | sdkerrors.SDKError | 4XX, 5XX | \*/\* | @@ -259,14 +265,16 @@ import( func main() { ctx := context.Background() - + s := unkeygo.New( unkeygo.WithSecurity("UNKEY_ROOT_KEY"), ) 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."), + Description: unkeygo.Pointer(operations.CreateCreateRoleDescriptionStr( + "dns.records.manager can read and write dns records for our domains.", + )), }) if err != nil { log.Fatal(err) @@ -298,6 +306,7 @@ func main() { | sdkerrors.ErrForbidden | 403 | application/json | | sdkerrors.ErrNotFound | 404 | application/json | | sdkerrors.ErrConflict | 409 | application/json | +| sdkerrors.ErrPreconditionFailed | 412 | application/json | | sdkerrors.ErrTooManyRequests | 429 | application/json | | sdkerrors.ErrInternalServerError | 500 | application/json | | sdkerrors.SDKError | 4XX, 5XX | \*/\* | @@ -318,7 +327,7 @@ import( func main() { ctx := context.Background() - + s := unkeygo.New( unkeygo.WithSecurity("UNKEY_ROOT_KEY"), ) @@ -356,6 +365,7 @@ func main() { | sdkerrors.ErrForbidden | 403 | application/json | | sdkerrors.ErrNotFound | 404 | application/json | | sdkerrors.ErrConflict | 409 | application/json | +| sdkerrors.ErrPreconditionFailed | 412 | application/json | | sdkerrors.ErrTooManyRequests | 429 | application/json | | sdkerrors.ErrInternalServerError | 500 | application/json | | sdkerrors.SDKError | 4XX, 5XX | \*/\* | @@ -376,7 +386,7 @@ import( func main() { ctx := context.Background() - + s := unkeygo.New( unkeygo.WithSecurity("UNKEY_ROOT_KEY"), ) @@ -414,6 +424,7 @@ func main() { | sdkerrors.ErrForbidden | 403 | application/json | | sdkerrors.ErrNotFound | 404 | application/json | | sdkerrors.ErrConflict | 409 | application/json | +| sdkerrors.ErrPreconditionFailed | 412 | application/json | | sdkerrors.ErrTooManyRequests | 429 | application/json | | sdkerrors.ErrInternalServerError | 500 | application/json | | sdkerrors.SDKError | 4XX, 5XX | \*/\* | @@ -433,7 +444,7 @@ import( func main() { ctx := context.Background() - + s := unkeygo.New( unkeygo.WithSecurity("UNKEY_ROOT_KEY"), ) @@ -468,6 +479,7 @@ func main() { | sdkerrors.ErrForbidden | 403 | application/json | | sdkerrors.ErrNotFound | 404 | application/json | | sdkerrors.ErrConflict | 409 | application/json | +| sdkerrors.ErrPreconditionFailed | 412 | application/json | | sdkerrors.ErrTooManyRequests | 429 | application/json | | sdkerrors.ErrInternalServerError | 500 | application/json | | sdkerrors.SDKError | 4XX, 5XX | \*/\* | \ No newline at end of file diff --git a/docs/sdks/ratelimit/README.md b/docs/sdks/ratelimit/README.md index 3af6ebc..307757c 100644 --- a/docs/sdks/ratelimit/README.md +++ b/docs/sdks/ratelimit/README.md @@ -25,7 +25,7 @@ import( func main() { ctx := context.Background() - + s := unkeygo.New( unkeygo.WithSecurity("UNKEY_ROOT_KEY"), ) @@ -67,6 +67,7 @@ func main() { | sdkerrors.ErrForbidden | 403 | application/json | | sdkerrors.ErrNotFound | 404 | application/json | | sdkerrors.ErrConflict | 409 | application/json | +| sdkerrors.ErrPreconditionFailed | 412 | application/json | | sdkerrors.ErrTooManyRequests | 429 | application/json | | sdkerrors.ErrInternalServerError | 500 | application/json | | sdkerrors.SDKError | 4XX, 5XX | \*/\* | @@ -87,7 +88,7 @@ import( func main() { ctx := context.Background() - + s := unkeygo.New( unkeygo.WithSecurity("UNKEY_ROOT_KEY"), ) @@ -126,6 +127,7 @@ func main() { | sdkerrors.ErrForbidden | 403 | application/json | | sdkerrors.ErrNotFound | 404 | application/json | | sdkerrors.ErrConflict | 409 | application/json | +| sdkerrors.ErrPreconditionFailed | 412 | application/json | | sdkerrors.ErrTooManyRequests | 429 | application/json | | sdkerrors.ErrInternalServerError | 500 | application/json | | sdkerrors.SDKError | 4XX, 5XX | \*/\* | @@ -146,7 +148,7 @@ import( func main() { ctx := context.Background() - + s := unkeygo.New( unkeygo.WithSecurity("UNKEY_ROOT_KEY"), ) @@ -186,6 +188,7 @@ func main() { | sdkerrors.ErrForbidden | 403 | application/json | | sdkerrors.ErrNotFound | 404 | application/json | | sdkerrors.ErrConflict | 409 | application/json | +| sdkerrors.ErrPreconditionFailed | 412 | application/json | | sdkerrors.ErrTooManyRequests | 429 | application/json | | sdkerrors.ErrInternalServerError | 500 | application/json | | sdkerrors.SDKError | 4XX, 5XX | \*/\* | \ No newline at end of file diff --git a/docs/sdks/ratelimits/README.md b/docs/sdks/ratelimits/README.md index 16ca1a7..bb32d04 100644 --- a/docs/sdks/ratelimits/README.md +++ b/docs/sdks/ratelimits/README.md @@ -24,7 +24,7 @@ import( func main() { ctx := context.Background() - + s := unkeygo.New( unkeygo.WithSecurity("UNKEY_ROOT_KEY"), ) @@ -71,6 +71,7 @@ func main() { | sdkerrors.ErrForbidden | 403 | application/json | | sdkerrors.ErrNotFound | 404 | application/json | | sdkerrors.ErrConflict | 409 | application/json | +| sdkerrors.ErrPreconditionFailed | 412 | application/json | | sdkerrors.ErrTooManyRequests | 429 | application/json | | sdkerrors.ErrInternalServerError | 500 | application/json | | sdkerrors.SDKError | 4XX, 5XX | \*/\* | @@ -91,7 +92,7 @@ import( func main() { ctx := context.Background() - + s := unkeygo.New( unkeygo.WithSecurity("UNKEY_ROOT_KEY"), ) @@ -131,6 +132,7 @@ func main() { | sdkerrors.ErrForbidden | 403 | application/json | | sdkerrors.ErrNotFound | 404 | application/json | | sdkerrors.ErrConflict | 409 | application/json | +| sdkerrors.ErrPreconditionFailed | 412 | application/json | | sdkerrors.ErrTooManyRequests | 429 | application/json | | sdkerrors.ErrInternalServerError | 500 | application/json | | sdkerrors.SDKError | 4XX, 5XX | \*/\* | \ No newline at end of file diff --git a/identities.go b/identities.go index 137ea1e..eebbabe 100644 --- a/identities.go +++ b/identities.go @@ -29,13 +29,6 @@ func newIdentities(sdkConfig sdkConfiguration) *Identities { } func (s *Identities) CreateIdentity(ctx context.Context, request operations.CreateIdentityRequestBody, opts ...operations.Option) (*operations.CreateIdentityResponse, error) { - hookCtx := hooks.HookContext{ - Context: ctx, - OperationID: "createIdentity", - OAuth2Scopes: []string{}, - SecuritySource: s.sdkConfiguration.Security, - } - o := operations.Options{} supportedOptions := []string{ operations.SupportedOptionRetries, @@ -59,6 +52,13 @@ func (s *Identities) CreateIdentity(ctx context.Context, request operations.Crea return nil, fmt.Errorf("error generating URL: %w", err) } + hookCtx := hooks.HookContext{ + BaseURL: baseURL, + Context: ctx, + OperationID: "createIdentity", + OAuth2Scopes: []string{}, + SecuritySource: s.sdkConfiguration.Security, + } bodyReader, reqContentType, err := utils.SerializeRequestBody(ctx, request, false, false, "Request", "json", `request:"mediaType=application/json"`) if err != nil { return nil, err @@ -173,7 +173,7 @@ func (s *Identities) CreateIdentity(ctx context.Context, request operations.Crea _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) return nil, err - } else if utils.MatchStatusCodes([]string{"400", "401", "403", "404", "409", "429", "4XX", "500", "5XX"}, httpRes.StatusCode) { + } else if utils.MatchStatusCodes([]string{"400", "401", "403", "404", "409", "412", "429", "4XX", "500", "5XX"}, httpRes.StatusCode) { _httpRes, err := s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) if err != nil { return nil, err @@ -314,6 +314,27 @@ func (s *Identities) CreateIdentity(ctx context.Context, request operations.Crea return nil, err } + return nil, &out + default: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + case httpRes.StatusCode == 412: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + + var out sdkerrors.ErrPreconditionFailed + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + return nil, &out default: rawBody, err := utils.ConsumeRawBody(httpRes) @@ -389,13 +410,6 @@ func (s *Identities) CreateIdentity(ctx context.Context, request operations.Crea } func (s *Identities) GetIdentity(ctx context.Context, request operations.GetIdentityRequest, opts ...operations.Option) (*operations.GetIdentityResponse, error) { - hookCtx := hooks.HookContext{ - Context: ctx, - OperationID: "getIdentity", - OAuth2Scopes: []string{}, - SecuritySource: s.sdkConfiguration.Security, - } - o := operations.Options{} supportedOptions := []string{ operations.SupportedOptionRetries, @@ -419,6 +433,14 @@ func (s *Identities) GetIdentity(ctx context.Context, request operations.GetIden return nil, fmt.Errorf("error generating URL: %w", err) } + hookCtx := hooks.HookContext{ + BaseURL: baseURL, + Context: ctx, + OperationID: "getIdentity", + OAuth2Scopes: []string{}, + SecuritySource: s.sdkConfiguration.Security, + } + timeout := o.Timeout if timeout == nil { timeout = s.sdkConfiguration.Timeout @@ -529,7 +551,7 @@ func (s *Identities) GetIdentity(ctx context.Context, request operations.GetIden _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) return nil, err - } else if utils.MatchStatusCodes([]string{"400", "401", "403", "404", "409", "429", "4XX", "500", "5XX"}, httpRes.StatusCode) { + } else if utils.MatchStatusCodes([]string{"400", "401", "403", "404", "409", "412", "429", "4XX", "500", "5XX"}, httpRes.StatusCode) { _httpRes, err := s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) if err != nil { return nil, err @@ -670,6 +692,27 @@ func (s *Identities) GetIdentity(ctx context.Context, request operations.GetIden return nil, err } + return nil, &out + default: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + case httpRes.StatusCode == 412: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + + var out sdkerrors.ErrPreconditionFailed + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + return nil, &out default: rawBody, err := utils.ConsumeRawBody(httpRes) @@ -745,13 +788,6 @@ func (s *Identities) GetIdentity(ctx context.Context, request operations.GetIden } func (s *Identities) ListIdentities(ctx context.Context, request operations.ListIdentitiesRequest, opts ...operations.Option) (*operations.ListIdentitiesResponse, error) { - hookCtx := hooks.HookContext{ - Context: ctx, - OperationID: "listIdentities", - OAuth2Scopes: []string{}, - SecuritySource: s.sdkConfiguration.Security, - } - o := operations.Options{} supportedOptions := []string{ operations.SupportedOptionRetries, @@ -775,6 +811,14 @@ func (s *Identities) ListIdentities(ctx context.Context, request operations.List return nil, fmt.Errorf("error generating URL: %w", err) } + hookCtx := hooks.HookContext{ + BaseURL: baseURL, + Context: ctx, + OperationID: "listIdentities", + OAuth2Scopes: []string{}, + SecuritySource: s.sdkConfiguration.Security, + } + timeout := o.Timeout if timeout == nil { timeout = s.sdkConfiguration.Timeout @@ -885,7 +929,7 @@ func (s *Identities) ListIdentities(ctx context.Context, request operations.List _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) return nil, err - } else if utils.MatchStatusCodes([]string{"400", "401", "403", "404", "409", "429", "4XX", "500", "5XX"}, httpRes.StatusCode) { + } else if utils.MatchStatusCodes([]string{"400", "401", "403", "404", "409", "412", "429", "4XX", "500", "5XX"}, httpRes.StatusCode) { _httpRes, err := s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) if err != nil { return nil, err @@ -1070,6 +1114,27 @@ func (s *Identities) ListIdentities(ctx context.Context, request operations.List return nil, err } + return nil, &out + default: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + case httpRes.StatusCode == 412: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + + var out sdkerrors.ErrPreconditionFailed + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + return nil, &out default: rawBody, err := utils.ConsumeRawBody(httpRes) @@ -1145,13 +1210,6 @@ func (s *Identities) ListIdentities(ctx context.Context, request operations.List } func (s *Identities) UpdateIdentity(ctx context.Context, request operations.UpdateIdentityRequestBody, opts ...operations.Option) (*operations.UpdateIdentityResponse, error) { - hookCtx := hooks.HookContext{ - Context: ctx, - OperationID: "updateIdentity", - OAuth2Scopes: []string{}, - SecuritySource: s.sdkConfiguration.Security, - } - o := operations.Options{} supportedOptions := []string{ operations.SupportedOptionRetries, @@ -1175,6 +1233,13 @@ func (s *Identities) UpdateIdentity(ctx context.Context, request operations.Upda return nil, fmt.Errorf("error generating URL: %w", err) } + hookCtx := hooks.HookContext{ + BaseURL: baseURL, + Context: ctx, + OperationID: "updateIdentity", + OAuth2Scopes: []string{}, + SecuritySource: s.sdkConfiguration.Security, + } bodyReader, reqContentType, err := utils.SerializeRequestBody(ctx, request, false, false, "Request", "json", `request:"mediaType=application/json"`) if err != nil { return nil, err @@ -1289,7 +1354,7 @@ func (s *Identities) UpdateIdentity(ctx context.Context, request operations.Upda _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) return nil, err - } else if utils.MatchStatusCodes([]string{"400", "401", "403", "404", "409", "429", "4XX", "500", "5XX"}, httpRes.StatusCode) { + } else if utils.MatchStatusCodes([]string{"400", "401", "403", "404", "409", "412", "429", "4XX", "500", "5XX"}, httpRes.StatusCode) { _httpRes, err := s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) if err != nil { return nil, err @@ -1430,6 +1495,27 @@ func (s *Identities) UpdateIdentity(ctx context.Context, request operations.Upda return nil, err } + return nil, &out + default: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + case httpRes.StatusCode == 412: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + + var out sdkerrors.ErrPreconditionFailed + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + return nil, &out default: rawBody, err := utils.ConsumeRawBody(httpRes) @@ -1505,13 +1591,6 @@ func (s *Identities) UpdateIdentity(ctx context.Context, request operations.Upda } func (s *Identities) DeleteIdentity(ctx context.Context, request operations.DeleteIdentityRequestBody, opts ...operations.Option) (*operations.DeleteIdentityResponse, error) { - hookCtx := hooks.HookContext{ - Context: ctx, - OperationID: "deleteIdentity", - OAuth2Scopes: []string{}, - SecuritySource: s.sdkConfiguration.Security, - } - o := operations.Options{} supportedOptions := []string{ operations.SupportedOptionRetries, @@ -1535,6 +1614,13 @@ func (s *Identities) DeleteIdentity(ctx context.Context, request operations.Dele return nil, fmt.Errorf("error generating URL: %w", err) } + hookCtx := hooks.HookContext{ + BaseURL: baseURL, + Context: ctx, + OperationID: "deleteIdentity", + OAuth2Scopes: []string{}, + SecuritySource: s.sdkConfiguration.Security, + } bodyReader, reqContentType, err := utils.SerializeRequestBody(ctx, request, false, false, "Request", "json", `request:"mediaType=application/json"`) if err != nil { return nil, err @@ -1649,7 +1735,7 @@ func (s *Identities) DeleteIdentity(ctx context.Context, request operations.Dele _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) return nil, err - } else if utils.MatchStatusCodes([]string{"400", "401", "403", "404", "409", "429", "4XX", "500", "5XX"}, httpRes.StatusCode) { + } else if utils.MatchStatusCodes([]string{"400", "401", "403", "404", "409", "412", "429", "4XX", "500", "5XX"}, httpRes.StatusCode) { _httpRes, err := s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) if err != nil { return nil, err @@ -1790,6 +1876,27 @@ func (s *Identities) DeleteIdentity(ctx context.Context, request operations.Dele return nil, err } + return nil, &out + default: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + case httpRes.StatusCode == 412: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + + var out sdkerrors.ErrPreconditionFailed + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + return nil, &out default: rawBody, err := utils.ConsumeRawBody(httpRes) diff --git a/internal/hooks/hooks.go b/internal/hooks/hooks.go index 8ea491a..a0b49da 100644 --- a/internal/hooks/hooks.go +++ b/internal/hooks/hooks.go @@ -24,6 +24,7 @@ type HTTPClient interface { } type HookContext struct { + BaseURL string Context context.Context OperationID string OAuth2Scopes []string diff --git a/internal/utils/form.go b/internal/utils/form.go index 879f829..5e98f83 100644 --- a/internal/utils/form.go +++ b/internal/utils/form.go @@ -15,11 +15,15 @@ import ( "github.com/unkeyed/unkey-go/types" ) -func populateForm(paramName string, explode bool, objType reflect.Type, objValue reflect.Value, delimiter string, getFieldName func(reflect.StructField) string) url.Values { +func populateForm(paramName string, explode bool, objType reflect.Type, objValue reflect.Value, delimiter string, defaultValue *string, getFieldName func(reflect.StructField) string) url.Values { formValues := url.Values{} if isNil(objType, objValue) { + if defaultValue != nil { + formValues.Add(paramName, *defaultValue) + } + return formValues } diff --git a/internal/utils/json.go b/internal/utils/json.go index 65c97f6..6b682e7 100644 --- a/internal/utils/json.go +++ b/internal/utils/json.go @@ -186,8 +186,8 @@ func UnmarshalJSON(b []byte, v interface{}, tag reflect.StructTag, topLevel bool value, ok := unmarhsaled[fieldName] if !ok { - defaultTag := field.Tag.Get("default") - if defaultTag != "" { + defaultTag, defaultOk := field.Tag.Lookup("default") + if defaultOk { value = handleDefaultConstValue(defaultTag, fieldVal.Interface(), field.Tag) ok = true } @@ -257,8 +257,8 @@ func marshalValue(v interface{}, tag reflect.StructTag) (json.RawMessage, error) } if isNil(reflect.TypeOf(v), reflect.ValueOf(v)) { - defaultTag := tag.Get("default") - if defaultTag != "" { + defaultTag, ok := tag.Lookup("default") + if ok { return handleDefaultConstValue(defaultTag, v, tag), nil } diff --git a/internal/utils/queryparams.go b/internal/utils/queryparams.go index f5c2f33..8f37ae6 100644 --- a/internal/utils/queryparams.go +++ b/internal/utils/queryparams.go @@ -65,6 +65,14 @@ func populateQueryParams(queryParams interface{}, globals interface{}, values ur continue } + constValue := parseConstTag(fieldType) + if constValue != nil { + values.Add(qpTag.ParamName, *constValue) + continue + } + + defaultValue := parseDefaultTag(fieldType) + if globals != nil { var globalFound bool fieldType, valType, globalFound = populateFromGlobals(fieldType, valType, queryParamTagKey, globals) @@ -91,14 +99,14 @@ func populateQueryParams(queryParams interface{}, globals interface{}, values ur } } case "form": - vals := populateFormParams(qpTag, fieldType.Type, valType, ",") + vals := populateFormParams(qpTag, fieldType.Type, valType, ",", defaultValue) for k, v := range vals { for _, vv := range v { values.Add(k, vv) } } case "pipeDelimited": - vals := populateFormParams(qpTag, fieldType.Type, valType, "|") + vals := populateFormParams(qpTag, fieldType.Type, valType, "|", defaultValue) for k, v := range vals { for _, vv := range v { values.Add(k, vv) @@ -240,8 +248,8 @@ func populateDeepObjectParamsStruct(qsValues url.Values, priorScope string, stru } } -func populateFormParams(tag *paramTag, objType reflect.Type, objValue reflect.Value, delimiter string) url.Values { - return populateForm(tag.ParamName, tag.Explode, objType, objValue, delimiter, func(fieldType reflect.StructField) string { +func populateFormParams(tag *paramTag, objType reflect.Type, objValue reflect.Value, delimiter string, defaultValue *string) url.Values { + return populateForm(tag.ParamName, tag.Explode, objType, objValue, delimiter, defaultValue, func(fieldType reflect.StructField) string { qpTag := parseQueryParamTag(fieldType) if qpTag == nil { return "" diff --git a/internal/utils/requestbody.go b/internal/utils/requestbody.go index 78479c6..8fe01ad 100644 --- a/internal/utils/requestbody.go +++ b/internal/utils/requestbody.go @@ -292,7 +292,7 @@ func encodeFormData(fieldName string, w io.Writer, data interface{}) error { switch tag.Style { // TODO: support other styles case "form": - values := populateForm(tag.Name, tag.Explode, fieldType, valType, ",", func(sf reflect.StructField) string { + values := populateForm(tag.Name, tag.Explode, fieldType, valType, ",", nil, func(sf reflect.StructField) string { tag := parseFormTag(field) if tag == nil { return "" diff --git a/internal/utils/utils.go b/internal/utils/utils.go index 031a71a..6f1f538 100644 --- a/internal/utils/utils.go +++ b/internal/utils/utils.go @@ -96,6 +96,26 @@ func AsSecuritySource(security interface{}) func(context.Context) (interface{}, } } +func parseConstTag(field reflect.StructField) *string { + value := field.Tag.Get("const") + + if value == "" { + return nil + } + + return &value +} + +func parseDefaultTag(field reflect.StructField) *string { + value := field.Tag.Get("default") + + if value == "" { + return nil + } + + return &value +} + func parseStructTag(tagKey string, field reflect.StructField) map[string]string { tag := field.Tag.Get(tagKey) if tag == "" { diff --git a/keys.go b/keys.go index 609b7a9..35e825f 100644 --- a/keys.go +++ b/keys.go @@ -27,13 +27,6 @@ func newKeys(sdkConfig sdkConfiguration) *Keys { } func (s *Keys) GetKey(ctx context.Context, request operations.GetKeyRequest, opts ...operations.Option) (*operations.GetKeyResponse, error) { - hookCtx := hooks.HookContext{ - Context: ctx, - OperationID: "getKey", - OAuth2Scopes: []string{}, - SecuritySource: s.sdkConfiguration.Security, - } - o := operations.Options{} supportedOptions := []string{ operations.SupportedOptionRetries, @@ -57,6 +50,14 @@ func (s *Keys) GetKey(ctx context.Context, request operations.GetKeyRequest, opt return nil, fmt.Errorf("error generating URL: %w", err) } + hookCtx := hooks.HookContext{ + BaseURL: baseURL, + Context: ctx, + OperationID: "getKey", + OAuth2Scopes: []string{}, + SecuritySource: s.sdkConfiguration.Security, + } + timeout := o.Timeout if timeout == nil { timeout = s.sdkConfiguration.Timeout @@ -167,7 +168,7 @@ func (s *Keys) GetKey(ctx context.Context, request operations.GetKeyRequest, opt _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) return nil, err - } else if utils.MatchStatusCodes([]string{"400", "401", "403", "404", "409", "429", "4XX", "500", "5XX"}, httpRes.StatusCode) { + } else if utils.MatchStatusCodes([]string{"400", "401", "403", "404", "409", "412", "429", "4XX", "500", "5XX"}, httpRes.StatusCode) { _httpRes, err := s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) if err != nil { return nil, err @@ -308,6 +309,27 @@ func (s *Keys) GetKey(ctx context.Context, request operations.GetKeyRequest, opt return nil, err } + return nil, &out + default: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + case httpRes.StatusCode == 412: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + + var out sdkerrors.ErrPreconditionFailed + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + return nil, &out default: rawBody, err := utils.ConsumeRawBody(httpRes) @@ -383,13 +405,6 @@ func (s *Keys) GetKey(ctx context.Context, request operations.GetKeyRequest, opt } func (s *Keys) Whoami(ctx context.Context, request operations.WhoamiRequestBody, opts ...operations.Option) (*operations.WhoamiResponse, error) { - hookCtx := hooks.HookContext{ - Context: ctx, - OperationID: "whoami", - OAuth2Scopes: []string{}, - SecuritySource: s.sdkConfiguration.Security, - } - o := operations.Options{} supportedOptions := []string{ operations.SupportedOptionRetries, @@ -413,6 +428,13 @@ func (s *Keys) Whoami(ctx context.Context, request operations.WhoamiRequestBody, return nil, fmt.Errorf("error generating URL: %w", err) } + hookCtx := hooks.HookContext{ + BaseURL: baseURL, + Context: ctx, + OperationID: "whoami", + OAuth2Scopes: []string{}, + SecuritySource: s.sdkConfiguration.Security, + } bodyReader, reqContentType, err := utils.SerializeRequestBody(ctx, request, false, false, "Request", "json", `request:"mediaType=application/json"`) if err != nil { return nil, err @@ -527,7 +549,7 @@ func (s *Keys) Whoami(ctx context.Context, request operations.WhoamiRequestBody, _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) return nil, err - } else if utils.MatchStatusCodes([]string{"400", "401", "403", "404", "409", "429", "4XX", "500", "5XX"}, httpRes.StatusCode) { + } else if utils.MatchStatusCodes([]string{"400", "401", "403", "404", "409", "412", "429", "4XX", "500", "5XX"}, httpRes.StatusCode) { _httpRes, err := s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) if err != nil { return nil, err @@ -668,6 +690,27 @@ func (s *Keys) Whoami(ctx context.Context, request operations.WhoamiRequestBody, return nil, err } + return nil, &out + default: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + case httpRes.StatusCode == 412: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + + var out sdkerrors.ErrPreconditionFailed + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + return nil, &out default: rawBody, err := utils.ConsumeRawBody(httpRes) @@ -743,13 +786,6 @@ func (s *Keys) Whoami(ctx context.Context, request operations.WhoamiRequestBody, } func (s *Keys) DeleteKey(ctx context.Context, request operations.DeleteKeyRequestBody, opts ...operations.Option) (*operations.DeleteKeyResponse, error) { - hookCtx := hooks.HookContext{ - Context: ctx, - OperationID: "deleteKey", - OAuth2Scopes: []string{}, - SecuritySource: s.sdkConfiguration.Security, - } - o := operations.Options{} supportedOptions := []string{ operations.SupportedOptionRetries, @@ -773,6 +809,13 @@ func (s *Keys) DeleteKey(ctx context.Context, request operations.DeleteKeyReques return nil, fmt.Errorf("error generating URL: %w", err) } + hookCtx := hooks.HookContext{ + BaseURL: baseURL, + Context: ctx, + OperationID: "deleteKey", + OAuth2Scopes: []string{}, + SecuritySource: s.sdkConfiguration.Security, + } bodyReader, reqContentType, err := utils.SerializeRequestBody(ctx, request, false, false, "Request", "json", `request:"mediaType=application/json"`) if err != nil { return nil, err @@ -887,7 +930,7 @@ func (s *Keys) DeleteKey(ctx context.Context, request operations.DeleteKeyReques _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) return nil, err - } else if utils.MatchStatusCodes([]string{"400", "401", "403", "404", "409", "429", "4XX", "500", "5XX"}, httpRes.StatusCode) { + } else if utils.MatchStatusCodes([]string{"400", "401", "403", "404", "409", "412", "429", "4XX", "500", "5XX"}, httpRes.StatusCode) { _httpRes, err := s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) if err != nil { return nil, err @@ -1028,6 +1071,27 @@ func (s *Keys) DeleteKey(ctx context.Context, request operations.DeleteKeyReques return nil, err } + return nil, &out + default: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + case httpRes.StatusCode == 412: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + + var out sdkerrors.ErrPreconditionFailed + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + return nil, &out default: rawBody, err := utils.ConsumeRawBody(httpRes) @@ -1103,13 +1167,6 @@ func (s *Keys) DeleteKey(ctx context.Context, request operations.DeleteKeyReques } func (s *Keys) CreateKey(ctx context.Context, request operations.CreateKeyRequestBody, opts ...operations.Option) (*operations.CreateKeyResponse, error) { - hookCtx := hooks.HookContext{ - Context: ctx, - OperationID: "createKey", - OAuth2Scopes: []string{}, - SecuritySource: s.sdkConfiguration.Security, - } - o := operations.Options{} supportedOptions := []string{ operations.SupportedOptionRetries, @@ -1133,6 +1190,13 @@ func (s *Keys) CreateKey(ctx context.Context, request operations.CreateKeyReques return nil, fmt.Errorf("error generating URL: %w", err) } + hookCtx := hooks.HookContext{ + BaseURL: baseURL, + Context: ctx, + OperationID: "createKey", + OAuth2Scopes: []string{}, + SecuritySource: s.sdkConfiguration.Security, + } bodyReader, reqContentType, err := utils.SerializeRequestBody(ctx, request, false, false, "Request", "json", `request:"mediaType=application/json"`) if err != nil { return nil, err @@ -1247,7 +1311,7 @@ func (s *Keys) CreateKey(ctx context.Context, request operations.CreateKeyReques _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) return nil, err - } else if utils.MatchStatusCodes([]string{"400", "401", "403", "404", "409", "429", "4XX", "500", "5XX"}, httpRes.StatusCode) { + } else if utils.MatchStatusCodes([]string{"400", "401", "403", "404", "409", "412", "429", "4XX", "500", "5XX"}, httpRes.StatusCode) { _httpRes, err := s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) if err != nil { return nil, err @@ -1388,6 +1452,27 @@ func (s *Keys) CreateKey(ctx context.Context, request operations.CreateKeyReques return nil, err } + return nil, &out + default: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + case httpRes.StatusCode == 412: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + + var out sdkerrors.ErrPreconditionFailed + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + return nil, &out default: rawBody, err := utils.ConsumeRawBody(httpRes) @@ -1463,13 +1548,6 @@ func (s *Keys) CreateKey(ctx context.Context, request operations.CreateKeyReques } func (s *Keys) VerifyKey(ctx context.Context, request components.V1KeysVerifyKeyRequest, opts ...operations.Option) (*operations.VerifyKeyResponse, error) { - hookCtx := hooks.HookContext{ - Context: ctx, - OperationID: "verifyKey", - OAuth2Scopes: []string{}, - SecuritySource: s.sdkConfiguration.Security, - } - o := operations.Options{} supportedOptions := []string{ operations.SupportedOptionRetries, @@ -1493,6 +1571,13 @@ func (s *Keys) VerifyKey(ctx context.Context, request components.V1KeysVerifyKey return nil, fmt.Errorf("error generating URL: %w", err) } + hookCtx := hooks.HookContext{ + BaseURL: baseURL, + Context: ctx, + OperationID: "verifyKey", + OAuth2Scopes: []string{}, + SecuritySource: s.sdkConfiguration.Security, + } bodyReader, reqContentType, err := utils.SerializeRequestBody(ctx, request, false, false, "Request", "json", `request:"mediaType=application/json"`) if err != nil { return nil, err @@ -1607,7 +1692,7 @@ func (s *Keys) VerifyKey(ctx context.Context, request components.V1KeysVerifyKey _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) return nil, err - } else if utils.MatchStatusCodes([]string{"400", "401", "403", "404", "409", "429", "4XX", "500", "5XX"}, httpRes.StatusCode) { + } else if utils.MatchStatusCodes([]string{"400", "401", "403", "404", "409", "412", "429", "4XX", "500", "5XX"}, httpRes.StatusCode) { _httpRes, err := s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) if err != nil { return nil, err @@ -1748,6 +1833,27 @@ func (s *Keys) VerifyKey(ctx context.Context, request components.V1KeysVerifyKey return nil, err } + return nil, &out + default: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + case httpRes.StatusCode == 412: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + + var out sdkerrors.ErrPreconditionFailed + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + return nil, &out default: rawBody, err := utils.ConsumeRawBody(httpRes) @@ -1823,13 +1929,6 @@ func (s *Keys) VerifyKey(ctx context.Context, request components.V1KeysVerifyKey } func (s *Keys) UpdateKey(ctx context.Context, request operations.UpdateKeyRequestBody, opts ...operations.Option) (*operations.UpdateKeyResponse, error) { - hookCtx := hooks.HookContext{ - Context: ctx, - OperationID: "updateKey", - OAuth2Scopes: []string{}, - SecuritySource: s.sdkConfiguration.Security, - } - o := operations.Options{} supportedOptions := []string{ operations.SupportedOptionRetries, @@ -1853,6 +1952,13 @@ func (s *Keys) UpdateKey(ctx context.Context, request operations.UpdateKeyReques return nil, fmt.Errorf("error generating URL: %w", err) } + hookCtx := hooks.HookContext{ + BaseURL: baseURL, + Context: ctx, + OperationID: "updateKey", + OAuth2Scopes: []string{}, + SecuritySource: s.sdkConfiguration.Security, + } bodyReader, reqContentType, err := utils.SerializeRequestBody(ctx, request, false, false, "Request", "json", `request:"mediaType=application/json"`) if err != nil { return nil, err @@ -1967,7 +2073,7 @@ func (s *Keys) UpdateKey(ctx context.Context, request operations.UpdateKeyReques _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) return nil, err - } else if utils.MatchStatusCodes([]string{"400", "401", "403", "404", "409", "429", "4XX", "500", "5XX"}, httpRes.StatusCode) { + } else if utils.MatchStatusCodes([]string{"400", "401", "403", "404", "409", "412", "429", "4XX", "500", "5XX"}, httpRes.StatusCode) { _httpRes, err := s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) if err != nil { return nil, err @@ -2108,6 +2214,27 @@ func (s *Keys) UpdateKey(ctx context.Context, request operations.UpdateKeyReques return nil, err } + return nil, &out + default: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + case httpRes.StatusCode == 412: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + + var out sdkerrors.ErrPreconditionFailed + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + return nil, &out default: rawBody, err := utils.ConsumeRawBody(httpRes) @@ -2183,13 +2310,6 @@ func (s *Keys) UpdateKey(ctx context.Context, request operations.UpdateKeyReques } func (s *Keys) UpdateRemaining(ctx context.Context, request operations.UpdateRemainingRequestBody, opts ...operations.Option) (*operations.UpdateRemainingResponse, error) { - hookCtx := hooks.HookContext{ - Context: ctx, - OperationID: "updateRemaining", - OAuth2Scopes: []string{}, - SecuritySource: s.sdkConfiguration.Security, - } - o := operations.Options{} supportedOptions := []string{ operations.SupportedOptionRetries, @@ -2213,6 +2333,13 @@ func (s *Keys) UpdateRemaining(ctx context.Context, request operations.UpdateRem return nil, fmt.Errorf("error generating URL: %w", err) } + hookCtx := hooks.HookContext{ + BaseURL: baseURL, + Context: ctx, + OperationID: "updateRemaining", + OAuth2Scopes: []string{}, + SecuritySource: s.sdkConfiguration.Security, + } bodyReader, reqContentType, err := utils.SerializeRequestBody(ctx, request, false, false, "Request", "json", `request:"mediaType=application/json"`) if err != nil { return nil, err @@ -2327,7 +2454,7 @@ func (s *Keys) UpdateRemaining(ctx context.Context, request operations.UpdateRem _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) return nil, err - } else if utils.MatchStatusCodes([]string{"400", "401", "403", "404", "409", "429", "4XX", "500", "5XX"}, httpRes.StatusCode) { + } else if utils.MatchStatusCodes([]string{"400", "401", "403", "404", "409", "412", "429", "4XX", "500", "5XX"}, httpRes.StatusCode) { _httpRes, err := s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) if err != nil { return nil, err @@ -2468,6 +2595,27 @@ func (s *Keys) UpdateRemaining(ctx context.Context, request operations.UpdateRem return nil, err } + return nil, &out + default: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + case httpRes.StatusCode == 412: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + + var out sdkerrors.ErrPreconditionFailed + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + return nil, &out default: rawBody, err := utils.ConsumeRawBody(httpRes) @@ -2543,13 +2691,6 @@ func (s *Keys) UpdateRemaining(ctx context.Context, request operations.UpdateRem } func (s *Keys) GetVerifications(ctx context.Context, request operations.KeysGetVerificationsRequest, opts ...operations.Option) (*operations.KeysGetVerificationsResponse, error) { - hookCtx := hooks.HookContext{ - Context: ctx, - OperationID: "keys.getVerifications", - OAuth2Scopes: []string{}, - SecuritySource: s.sdkConfiguration.Security, - } - o := operations.Options{} supportedOptions := []string{ operations.SupportedOptionRetries, @@ -2573,6 +2714,14 @@ func (s *Keys) GetVerifications(ctx context.Context, request operations.KeysGetV return nil, fmt.Errorf("error generating URL: %w", err) } + hookCtx := hooks.HookContext{ + BaseURL: baseURL, + Context: ctx, + OperationID: "keys.getVerifications", + OAuth2Scopes: []string{}, + SecuritySource: s.sdkConfiguration.Security, + } + timeout := o.Timeout if timeout == nil { timeout = s.sdkConfiguration.Timeout @@ -2683,7 +2832,7 @@ func (s *Keys) GetVerifications(ctx context.Context, request operations.KeysGetV _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) return nil, err - } else if utils.MatchStatusCodes([]string{"400", "401", "403", "404", "409", "429", "4XX", "500", "5XX"}, httpRes.StatusCode) { + } else if utils.MatchStatusCodes([]string{"400", "401", "403", "404", "409", "412", "429", "4XX", "500", "5XX"}, httpRes.StatusCode) { _httpRes, err := s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) if err != nil { return nil, err @@ -2824,6 +2973,27 @@ func (s *Keys) GetVerifications(ctx context.Context, request operations.KeysGetV return nil, err } + return nil, &out + default: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + case httpRes.StatusCode == 412: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + + var out sdkerrors.ErrPreconditionFailed + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + return nil, &out default: rawBody, err := utils.ConsumeRawBody(httpRes) @@ -2899,13 +3069,6 @@ func (s *Keys) GetVerifications(ctx context.Context, request operations.KeysGetV } func (s *Keys) AddPermissions(ctx context.Context, request operations.AddPermissionsRequestBody, opts ...operations.Option) (*operations.AddPermissionsResponse, error) { - hookCtx := hooks.HookContext{ - Context: ctx, - OperationID: "addPermissions", - OAuth2Scopes: []string{}, - SecuritySource: s.sdkConfiguration.Security, - } - o := operations.Options{} supportedOptions := []string{ operations.SupportedOptionRetries, @@ -2929,6 +3092,13 @@ func (s *Keys) AddPermissions(ctx context.Context, request operations.AddPermiss return nil, fmt.Errorf("error generating URL: %w", err) } + hookCtx := hooks.HookContext{ + BaseURL: baseURL, + Context: ctx, + OperationID: "addPermissions", + OAuth2Scopes: []string{}, + SecuritySource: s.sdkConfiguration.Security, + } bodyReader, reqContentType, err := utils.SerializeRequestBody(ctx, request, false, false, "Request", "json", `request:"mediaType=application/json"`) if err != nil { return nil, err @@ -3043,7 +3213,7 @@ func (s *Keys) AddPermissions(ctx context.Context, request operations.AddPermiss _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) return nil, err - } else if utils.MatchStatusCodes([]string{"400", "401", "403", "404", "409", "429", "4XX", "500", "5XX"}, httpRes.StatusCode) { + } else if utils.MatchStatusCodes([]string{"400", "401", "403", "404", "409", "412", "429", "4XX", "500", "5XX"}, httpRes.StatusCode) { _httpRes, err := s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) if err != nil { return nil, err @@ -3184,6 +3354,27 @@ func (s *Keys) AddPermissions(ctx context.Context, request operations.AddPermiss return nil, err } + return nil, &out + default: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + case httpRes.StatusCode == 412: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + + var out sdkerrors.ErrPreconditionFailed + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + return nil, &out default: rawBody, err := utils.ConsumeRawBody(httpRes) @@ -3259,13 +3450,6 @@ func (s *Keys) AddPermissions(ctx context.Context, request operations.AddPermiss } func (s *Keys) RemovePermissions(ctx context.Context, request operations.RemovePermissionsRequestBody, opts ...operations.Option) (*operations.RemovePermissionsResponse, error) { - hookCtx := hooks.HookContext{ - Context: ctx, - OperationID: "removePermissions", - OAuth2Scopes: []string{}, - SecuritySource: s.sdkConfiguration.Security, - } - o := operations.Options{} supportedOptions := []string{ operations.SupportedOptionRetries, @@ -3289,6 +3473,13 @@ func (s *Keys) RemovePermissions(ctx context.Context, request operations.RemoveP return nil, fmt.Errorf("error generating URL: %w", err) } + hookCtx := hooks.HookContext{ + BaseURL: baseURL, + Context: ctx, + OperationID: "removePermissions", + OAuth2Scopes: []string{}, + SecuritySource: s.sdkConfiguration.Security, + } bodyReader, reqContentType, err := utils.SerializeRequestBody(ctx, request, false, false, "Request", "json", `request:"mediaType=application/json"`) if err != nil { return nil, err @@ -3403,7 +3594,7 @@ func (s *Keys) RemovePermissions(ctx context.Context, request operations.RemoveP _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) return nil, err - } else if utils.MatchStatusCodes([]string{"400", "401", "403", "404", "409", "429", "4XX", "500", "5XX"}, httpRes.StatusCode) { + } else if utils.MatchStatusCodes([]string{"400", "401", "403", "404", "409", "412", "429", "4XX", "500", "5XX"}, httpRes.StatusCode) { _httpRes, err := s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) if err != nil { return nil, err @@ -3544,6 +3735,27 @@ func (s *Keys) RemovePermissions(ctx context.Context, request operations.RemoveP return nil, err } + return nil, &out + default: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + case httpRes.StatusCode == 412: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + + var out sdkerrors.ErrPreconditionFailed + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + return nil, &out default: rawBody, err := utils.ConsumeRawBody(httpRes) @@ -3619,13 +3831,6 @@ func (s *Keys) RemovePermissions(ctx context.Context, request operations.RemoveP } func (s *Keys) SetPermissions(ctx context.Context, request operations.SetPermissionsRequestBody, opts ...operations.Option) (*operations.SetPermissionsResponse, error) { - hookCtx := hooks.HookContext{ - Context: ctx, - OperationID: "setPermissions", - OAuth2Scopes: []string{}, - SecuritySource: s.sdkConfiguration.Security, - } - o := operations.Options{} supportedOptions := []string{ operations.SupportedOptionRetries, @@ -3649,6 +3854,13 @@ func (s *Keys) SetPermissions(ctx context.Context, request operations.SetPermiss return nil, fmt.Errorf("error generating URL: %w", err) } + hookCtx := hooks.HookContext{ + BaseURL: baseURL, + Context: ctx, + OperationID: "setPermissions", + OAuth2Scopes: []string{}, + SecuritySource: s.sdkConfiguration.Security, + } bodyReader, reqContentType, err := utils.SerializeRequestBody(ctx, request, false, false, "Request", "json", `request:"mediaType=application/json"`) if err != nil { return nil, err @@ -3763,7 +3975,7 @@ func (s *Keys) SetPermissions(ctx context.Context, request operations.SetPermiss _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) return nil, err - } else if utils.MatchStatusCodes([]string{"400", "401", "403", "404", "409", "429", "4XX", "500", "5XX"}, httpRes.StatusCode) { + } else if utils.MatchStatusCodes([]string{"400", "401", "403", "404", "409", "412", "429", "4XX", "500", "5XX"}, httpRes.StatusCode) { _httpRes, err := s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) if err != nil { return nil, err @@ -3904,6 +4116,27 @@ func (s *Keys) SetPermissions(ctx context.Context, request operations.SetPermiss return nil, err } + return nil, &out + default: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + case httpRes.StatusCode == 412: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + + var out sdkerrors.ErrPreconditionFailed + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + return nil, &out default: rawBody, err := utils.ConsumeRawBody(httpRes) @@ -3979,13 +4212,6 @@ func (s *Keys) SetPermissions(ctx context.Context, request operations.SetPermiss } func (s *Keys) AddRoles(ctx context.Context, request operations.AddRolesRequestBody, opts ...operations.Option) (*operations.AddRolesResponse, error) { - hookCtx := hooks.HookContext{ - Context: ctx, - OperationID: "addRoles", - OAuth2Scopes: []string{}, - SecuritySource: s.sdkConfiguration.Security, - } - o := operations.Options{} supportedOptions := []string{ operations.SupportedOptionRetries, @@ -4009,6 +4235,13 @@ func (s *Keys) AddRoles(ctx context.Context, request operations.AddRolesRequestB return nil, fmt.Errorf("error generating URL: %w", err) } + hookCtx := hooks.HookContext{ + BaseURL: baseURL, + Context: ctx, + OperationID: "addRoles", + OAuth2Scopes: []string{}, + SecuritySource: s.sdkConfiguration.Security, + } bodyReader, reqContentType, err := utils.SerializeRequestBody(ctx, request, false, false, "Request", "json", `request:"mediaType=application/json"`) if err != nil { return nil, err @@ -4123,7 +4356,7 @@ func (s *Keys) AddRoles(ctx context.Context, request operations.AddRolesRequestB _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) return nil, err - } else if utils.MatchStatusCodes([]string{"400", "401", "403", "404", "409", "429", "4XX", "500", "5XX"}, httpRes.StatusCode) { + } else if utils.MatchStatusCodes([]string{"400", "401", "403", "404", "409", "412", "429", "4XX", "500", "5XX"}, httpRes.StatusCode) { _httpRes, err := s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) if err != nil { return nil, err @@ -4264,6 +4497,27 @@ func (s *Keys) AddRoles(ctx context.Context, request operations.AddRolesRequestB return nil, err } + return nil, &out + default: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + case httpRes.StatusCode == 412: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + + var out sdkerrors.ErrPreconditionFailed + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + return nil, &out default: rawBody, err := utils.ConsumeRawBody(httpRes) @@ -4339,13 +4593,6 @@ func (s *Keys) AddRoles(ctx context.Context, request operations.AddRolesRequestB } func (s *Keys) RemoveRoles(ctx context.Context, request operations.RemoveRolesRequestBody, opts ...operations.Option) (*operations.RemoveRolesResponse, error) { - hookCtx := hooks.HookContext{ - Context: ctx, - OperationID: "removeRoles", - OAuth2Scopes: []string{}, - SecuritySource: s.sdkConfiguration.Security, - } - o := operations.Options{} supportedOptions := []string{ operations.SupportedOptionRetries, @@ -4369,6 +4616,13 @@ func (s *Keys) RemoveRoles(ctx context.Context, request operations.RemoveRolesRe return nil, fmt.Errorf("error generating URL: %w", err) } + hookCtx := hooks.HookContext{ + BaseURL: baseURL, + Context: ctx, + OperationID: "removeRoles", + OAuth2Scopes: []string{}, + SecuritySource: s.sdkConfiguration.Security, + } bodyReader, reqContentType, err := utils.SerializeRequestBody(ctx, request, false, false, "Request", "json", `request:"mediaType=application/json"`) if err != nil { return nil, err @@ -4483,7 +4737,7 @@ func (s *Keys) RemoveRoles(ctx context.Context, request operations.RemoveRolesRe _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) return nil, err - } else if utils.MatchStatusCodes([]string{"400", "401", "403", "404", "409", "429", "4XX", "500", "5XX"}, httpRes.StatusCode) { + } else if utils.MatchStatusCodes([]string{"400", "401", "403", "404", "409", "412", "429", "4XX", "500", "5XX"}, httpRes.StatusCode) { _httpRes, err := s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) if err != nil { return nil, err @@ -4624,6 +4878,27 @@ func (s *Keys) RemoveRoles(ctx context.Context, request operations.RemoveRolesRe return nil, err } + return nil, &out + default: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + case httpRes.StatusCode == 412: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + + var out sdkerrors.ErrPreconditionFailed + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + return nil, &out default: rawBody, err := utils.ConsumeRawBody(httpRes) @@ -4699,13 +4974,6 @@ func (s *Keys) RemoveRoles(ctx context.Context, request operations.RemoveRolesRe } func (s *Keys) SetRoles(ctx context.Context, request operations.SetRolesRequestBody, opts ...operations.Option) (*operations.SetRolesResponse, error) { - hookCtx := hooks.HookContext{ - Context: ctx, - OperationID: "setRoles", - OAuth2Scopes: []string{}, - SecuritySource: s.sdkConfiguration.Security, - } - o := operations.Options{} supportedOptions := []string{ operations.SupportedOptionRetries, @@ -4729,6 +4997,13 @@ func (s *Keys) SetRoles(ctx context.Context, request operations.SetRolesRequestB return nil, fmt.Errorf("error generating URL: %w", err) } + hookCtx := hooks.HookContext{ + BaseURL: baseURL, + Context: ctx, + OperationID: "setRoles", + OAuth2Scopes: []string{}, + SecuritySource: s.sdkConfiguration.Security, + } bodyReader, reqContentType, err := utils.SerializeRequestBody(ctx, request, false, false, "Request", "json", `request:"mediaType=application/json"`) if err != nil { return nil, err @@ -4843,7 +5118,7 @@ func (s *Keys) SetRoles(ctx context.Context, request operations.SetRolesRequestB _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) return nil, err - } else if utils.MatchStatusCodes([]string{"400", "401", "403", "404", "409", "429", "4XX", "500", "5XX"}, httpRes.StatusCode) { + } else if utils.MatchStatusCodes([]string{"400", "401", "403", "404", "409", "412", "429", "4XX", "500", "5XX"}, httpRes.StatusCode) { _httpRes, err := s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) if err != nil { return nil, err @@ -4984,6 +5259,27 @@ func (s *Keys) SetRoles(ctx context.Context, request operations.SetRolesRequestB return nil, err } + return nil, &out + default: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + case httpRes.StatusCode == 412: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + + var out sdkerrors.ErrPreconditionFailed + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + return nil, &out default: rawBody, err := utils.ConsumeRawBody(httpRes) diff --git a/liveness.go b/liveness.go index e5e10bf..26673c8 100644 --- a/liveness.go +++ b/liveness.go @@ -27,13 +27,6 @@ func newLiveness(sdkConfig sdkConfiguration) *Liveness { } func (s *Liveness) V1Liveness(ctx context.Context, opts ...operations.Option) (*operations.V1LivenessResponse, error) { - hookCtx := hooks.HookContext{ - Context: ctx, - OperationID: "v1.liveness", - OAuth2Scopes: []string{}, - SecuritySource: s.sdkConfiguration.Security, - } - o := operations.Options{} supportedOptions := []string{ operations.SupportedOptionRetries, @@ -57,6 +50,14 @@ func (s *Liveness) V1Liveness(ctx context.Context, opts ...operations.Option) (* return nil, fmt.Errorf("error generating URL: %w", err) } + hookCtx := hooks.HookContext{ + BaseURL: baseURL, + Context: ctx, + OperationID: "v1.liveness", + OAuth2Scopes: []string{}, + SecuritySource: s.sdkConfiguration.Security, + } + timeout := o.Timeout if timeout == nil { timeout = s.sdkConfiguration.Timeout @@ -163,7 +164,7 @@ func (s *Liveness) V1Liveness(ctx context.Context, opts ...operations.Option) (* _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) return nil, err - } else if utils.MatchStatusCodes([]string{"400", "401", "403", "404", "409", "429", "4XX", "500", "5XX"}, httpRes.StatusCode) { + } else if utils.MatchStatusCodes([]string{"400", "401", "403", "404", "409", "412", "429", "4XX", "500", "5XX"}, httpRes.StatusCode) { _httpRes, err := s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) if err != nil { return nil, err @@ -304,6 +305,27 @@ func (s *Liveness) V1Liveness(ctx context.Context, opts ...operations.Option) (* return nil, err } + return nil, &out + default: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + case httpRes.StatusCode == 412: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + + var out sdkerrors.ErrPreconditionFailed + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + return nil, &out default: rawBody, err := utils.ConsumeRawBody(httpRes) diff --git a/migrations.go b/migrations.go index f81db7f..a06662c 100644 --- a/migrations.go +++ b/migrations.go @@ -27,13 +27,6 @@ func newMigrations(sdkConfig sdkConfiguration) *Migrations { } func (s *Migrations) V1MigrationsCreateKeys(ctx context.Context, request []operations.RequestBody, opts ...operations.Option) (*operations.V1MigrationsCreateKeysResponse, error) { - hookCtx := hooks.HookContext{ - Context: ctx, - OperationID: "v1.migrations.createKeys", - OAuth2Scopes: []string{}, - SecuritySource: s.sdkConfiguration.Security, - } - o := operations.Options{} supportedOptions := []string{ operations.SupportedOptionRetries, @@ -57,6 +50,13 @@ func (s *Migrations) V1MigrationsCreateKeys(ctx context.Context, request []opera return nil, fmt.Errorf("error generating URL: %w", err) } + hookCtx := hooks.HookContext{ + BaseURL: baseURL, + Context: ctx, + OperationID: "v1.migrations.createKeys", + OAuth2Scopes: []string{}, + SecuritySource: s.sdkConfiguration.Security, + } bodyReader, reqContentType, err := utils.SerializeRequestBody(ctx, request, false, false, "Request", "json", `request:"mediaType=application/json"`) if err != nil { return nil, err @@ -171,7 +171,7 @@ func (s *Migrations) V1MigrationsCreateKeys(ctx context.Context, request []opera _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) return nil, err - } else if utils.MatchStatusCodes([]string{"400", "401", "403", "404", "409", "429", "4XX", "500", "5XX"}, httpRes.StatusCode) { + } else if utils.MatchStatusCodes([]string{"400", "401", "403", "404", "409", "412", "429", "4XX", "500", "5XX"}, httpRes.StatusCode) { _httpRes, err := s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) if err != nil { return nil, err @@ -312,6 +312,27 @@ func (s *Migrations) V1MigrationsCreateKeys(ctx context.Context, request []opera return nil, err } + return nil, &out + default: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + case httpRes.StatusCode == 412: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + + var out sdkerrors.ErrPreconditionFailed + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + return nil, &out default: rawBody, err := utils.ConsumeRawBody(httpRes) @@ -387,13 +408,6 @@ func (s *Migrations) V1MigrationsCreateKeys(ctx context.Context, request []opera } func (s *Migrations) V1MigrationsEnqueueKeys(ctx context.Context, request operations.V1MigrationsEnqueueKeysRequestBody, opts ...operations.Option) (*operations.V1MigrationsEnqueueKeysResponse, error) { - hookCtx := hooks.HookContext{ - Context: ctx, - OperationID: "v1.migrations.enqueueKeys", - OAuth2Scopes: []string{}, - SecuritySource: s.sdkConfiguration.Security, - } - o := operations.Options{} supportedOptions := []string{ operations.SupportedOptionRetries, @@ -417,6 +431,13 @@ func (s *Migrations) V1MigrationsEnqueueKeys(ctx context.Context, request operat return nil, fmt.Errorf("error generating URL: %w", err) } + hookCtx := hooks.HookContext{ + BaseURL: baseURL, + Context: ctx, + OperationID: "v1.migrations.enqueueKeys", + OAuth2Scopes: []string{}, + SecuritySource: s.sdkConfiguration.Security, + } bodyReader, reqContentType, err := utils.SerializeRequestBody(ctx, request, false, false, "Request", "json", `request:"mediaType=application/json"`) if err != nil { return nil, err @@ -531,7 +552,7 @@ func (s *Migrations) V1MigrationsEnqueueKeys(ctx context.Context, request operat _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) return nil, err - } else if utils.MatchStatusCodes([]string{"400", "401", "403", "404", "409", "429", "4XX", "500", "5XX"}, httpRes.StatusCode) { + } else if utils.MatchStatusCodes([]string{"400", "401", "403", "404", "409", "412", "429", "4XX", "500", "5XX"}, httpRes.StatusCode) { _httpRes, err := s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) if err != nil { return nil, err @@ -672,6 +693,27 @@ func (s *Migrations) V1MigrationsEnqueueKeys(ctx context.Context, request operat return nil, err } + return nil, &out + default: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + case httpRes.StatusCode == 412: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + + var out sdkerrors.ErrPreconditionFailed + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + return nil, &out default: rawBody, err := utils.ConsumeRawBody(httpRes) diff --git a/models/components/permissionquery.go b/models/components/permissionquery.go index 14b93ff..3b42461 100644 --- a/models/components/permissionquery.go +++ b/models/components/permissionquery.go @@ -9,23 +9,23 @@ import ( ) type Or struct { - Or []PermissionQuery `json:"or"` + Or []*PermissionQuery `json:"or"` } -func (o *Or) GetOr() []PermissionQuery { +func (o *Or) GetOr() []*PermissionQuery { if o == nil { - return []PermissionQuery{} + return []*PermissionQuery{} } return o.Or } type And struct { - And []PermissionQuery `json:"and"` + And []*PermissionQuery `json:"and"` } -func (o *And) GetAnd() []PermissionQuery { +func (o *And) GetAnd() []*PermissionQuery { if o == nil { - return []PermissionQuery{} + return []*PermissionQuery{} } return o.And } diff --git a/models/components/v1keysverifykeyresponse.go b/models/components/v1keysverifykeyresponse.go index 58d88e5..cbd2a27 100644 --- a/models/components/v1keysverifykeyresponse.go +++ b/models/components/v1keysverifykeyresponse.go @@ -163,10 +163,14 @@ type V1KeysVerifyKeyResponse struct { Enabled *bool `json:"enabled,omitempty"` // A list of all the permissions this key is connected to. Permissions []string `json:"permissions,omitempty"` + // A list of all the roles this key is connected to. + Roles []string `json:"roles,omitempty"` // The environment of the key, this is what what you set when you crated the key Environment *string `json:"environment,omitempty"` // The associated identity of this key. Identity *V1KeysVerifyKeyResponseIdentity `json:"identity,omitempty"` + // A unique id for this request, please provide it to Unkey support to help us debug your issue. + RequestID string `json:"requestId"` } func (o *V1KeysVerifyKeyResponse) GetKeyID() *string { @@ -246,6 +250,13 @@ func (o *V1KeysVerifyKeyResponse) GetPermissions() []string { return o.Permissions } +func (o *V1KeysVerifyKeyResponse) GetRoles() []string { + if o == nil { + return nil + } + return o.Roles +} + func (o *V1KeysVerifyKeyResponse) GetEnvironment() *string { if o == nil { return nil @@ -259,3 +270,10 @@ func (o *V1KeysVerifyKeyResponse) GetIdentity() *V1KeysVerifyKeyResponseIdentity } return o.Identity } + +func (o *V1KeysVerifyKeyResponse) GetRequestID() string { + if o == nil { + return "" + } + return o.RequestID +} diff --git a/models/operations/createidentity.go b/models/operations/createidentity.go index 51f68f4..568c001 100644 --- a/models/operations/createidentity.go +++ b/models/operations/createidentity.go @@ -42,7 +42,7 @@ type CreateIdentityRequestBody struct { // This usually comes from your authentication provider and could be a userId, organisationId or even an email. // It does not matter what you use, as long as it uniquely identifies something in your application. // - // `externalId`s are unique across your workspace and therefore a `PRECONDITION_FAILED` error is returned when you try to create duplicates. + // `externalId`s are unique across your workspace and therefore a `CONFLICT` error is returned when you try to create duplicates. // ExternalID string `json:"externalId"` // Attach metadata to this identity that you need to have access to when verifying a key. diff --git a/models/operations/createpermission.go b/models/operations/createpermission.go index 81e74b2..79b8280 100644 --- a/models/operations/createpermission.go +++ b/models/operations/createpermission.go @@ -3,14 +3,105 @@ package operations import ( + "encoding/json" + "errors" + "fmt" + "github.com/unkeyed/unkey-go/internal/utils" "github.com/unkeyed/unkey-go/models/components" ) +type Two string + +const ( + TwoUnknown Two = "" +) + +func (e Two) ToPointer() *Two { + return &e +} +func (e *Two) UnmarshalJSON(data []byte) error { + var v string + if err := json.Unmarshal(data, &v); err != nil { + return err + } + switch v { + case "": + *e = Two(v) + return nil + default: + return fmt.Errorf("invalid value for Two: %v", v) + } +} + +type DescriptionType string + +const ( + DescriptionTypeStr DescriptionType = "str" + DescriptionTypeTwo DescriptionType = "2" +) + +// Description - Explain what this permission does. This is just for your team, your users will not see this. +type Description struct { + Str *string `queryParam:"inline"` + Two *Two `queryParam:"inline"` + + Type DescriptionType +} + +func CreateDescriptionStr(str string) Description { + typ := DescriptionTypeStr + + return Description{ + Str: &str, + Type: typ, + } +} + +func CreateDescriptionTwo(two Two) Description { + typ := DescriptionTypeTwo + + return Description{ + Two: &two, + Type: typ, + } +} + +func (u *Description) UnmarshalJSON(data []byte) error { + + var str string = "" + if err := utils.UnmarshalJSON(data, &str, "", true, true); err == nil { + u.Str = &str + u.Type = DescriptionTypeStr + return nil + } + + var two Two = Two("") + if err := utils.UnmarshalJSON(data, &two, "", true, true); err == nil { + u.Two = &two + u.Type = DescriptionTypeTwo + return nil + } + + return fmt.Errorf("could not unmarshal `%s` into any supported union types for Description", string(data)) +} + +func (u Description) MarshalJSON() ([]byte, error) { + if u.Str != nil { + return utils.MarshalJSON(u.Str, "", true) + } + + if u.Two != nil { + return utils.MarshalJSON(u.Two, "", true) + } + + return nil, errors.New("could not marshal union type Description: all fields are null") +} + type CreatePermissionRequestBody struct { // The unique name of your permission. Name string `json:"name"` // Explain what this permission does. This is just for your team, your users will not see this. - Description *string `json:"description,omitempty"` + Description *Description `json:"description,omitempty"` } func (o *CreatePermissionRequestBody) GetName() string { @@ -20,7 +111,7 @@ func (o *CreatePermissionRequestBody) GetName() string { return o.Name } -func (o *CreatePermissionRequestBody) GetDescription() *string { +func (o *CreatePermissionRequestBody) GetDescription() *Description { if o == nil { return nil } diff --git a/models/operations/createrole.go b/models/operations/createrole.go index 370715a..cc9f474 100644 --- a/models/operations/createrole.go +++ b/models/operations/createrole.go @@ -3,14 +3,105 @@ package operations import ( + "encoding/json" + "errors" + "fmt" + "github.com/unkeyed/unkey-go/internal/utils" "github.com/unkeyed/unkey-go/models/components" ) +type Description2 string + +const ( + Description2Unknown Description2 = "" +) + +func (e Description2) ToPointer() *Description2 { + return &e +} +func (e *Description2) UnmarshalJSON(data []byte) error { + var v string + if err := json.Unmarshal(data, &v); err != nil { + return err + } + switch v { + case "": + *e = Description2(v) + return nil + default: + return fmt.Errorf("invalid value for Description2: %v", v) + } +} + +type CreateRoleDescriptionType string + +const ( + CreateRoleDescriptionTypeStr CreateRoleDescriptionType = "str" + CreateRoleDescriptionTypeDescription2 CreateRoleDescriptionType = "description_2" +) + +// CreateRoleDescription - Explain what this role does. This is just for your team, your users will not see this. +type CreateRoleDescription struct { + Str *string `queryParam:"inline"` + Description2 *Description2 `queryParam:"inline"` + + Type CreateRoleDescriptionType +} + +func CreateCreateRoleDescriptionStr(str string) CreateRoleDescription { + typ := CreateRoleDescriptionTypeStr + + return CreateRoleDescription{ + Str: &str, + Type: typ, + } +} + +func CreateCreateRoleDescriptionDescription2(description2 Description2) CreateRoleDescription { + typ := CreateRoleDescriptionTypeDescription2 + + return CreateRoleDescription{ + Description2: &description2, + Type: typ, + } +} + +func (u *CreateRoleDescription) UnmarshalJSON(data []byte) error { + + var str string = "" + if err := utils.UnmarshalJSON(data, &str, "", true, true); err == nil { + u.Str = &str + u.Type = CreateRoleDescriptionTypeStr + return nil + } + + var description2 Description2 = Description2("") + if err := utils.UnmarshalJSON(data, &description2, "", true, true); err == nil { + u.Description2 = &description2 + u.Type = CreateRoleDescriptionTypeDescription2 + return nil + } + + return fmt.Errorf("could not unmarshal `%s` into any supported union types for CreateRoleDescription", string(data)) +} + +func (u CreateRoleDescription) MarshalJSON() ([]byte, error) { + if u.Str != nil { + return utils.MarshalJSON(u.Str, "", true) + } + + if u.Description2 != nil { + return utils.MarshalJSON(u.Description2, "", true) + } + + return nil, errors.New("could not marshal union type CreateRoleDescription: all fields are null") +} + type CreateRoleRequestBody struct { // The unique name of your role. Name string `json:"name"` // Explain what this role does. This is just for your team, your users will not see this. - Description *string `json:"description,omitempty"` + Description *CreateRoleDescription `json:"description,omitempty"` } func (o *CreateRoleRequestBody) GetName() string { @@ -20,7 +111,7 @@ func (o *CreateRoleRequestBody) GetName() string { return o.Name } -func (o *CreateRoleRequestBody) GetDescription() *string { +func (o *CreateRoleRequestBody) GetDescription() *CreateRoleDescription { if o == nil { return nil } diff --git a/models/operations/deletekey.go b/models/operations/deletekey.go index 0c78c02..21a0471 100644 --- a/models/operations/deletekey.go +++ b/models/operations/deletekey.go @@ -10,7 +10,7 @@ import ( type DeleteKeyRequestBody struct { // The id of the key to revoke KeyID string `json:"keyId"` - // By default Unkey soft deletes keys, so they may be recovered later. If you want to permanently delete it, set permanent=true. This might be necessary if you run into NOT_UNIQUE errors during key migration. + // By default Unkey soft deletes keys, so they may be recovered later. If you want to permanently delete it, set permanent=true. This might be necessary if you run into CONFLICT errors during key migration. Permanent *bool `default:"false" json:"permanent"` } diff --git a/models/operations/getverifications.go b/models/operations/getverifications.go index d8bc86f..3906523 100644 --- a/models/operations/getverifications.go +++ b/models/operations/getverifications.go @@ -142,22 +142,22 @@ func (u Tag) MarshalJSON() ([]byte, error) { return nil, errors.New("could not marshal union type Tag: all fields are null") } -type Two string +type QueryParam2 string const ( - TwoKey Two = "key" - TwoIdentity Two = "identity" - TwoTags Two = "tags" - TwoTag Two = "tag" - TwoMonth Two = "month" - TwoDay Two = "day" - TwoHour Two = "hour" + QueryParam2Key QueryParam2 = "key" + QueryParam2Identity QueryParam2 = "identity" + QueryParam2Tags QueryParam2 = "tags" + QueryParam2Tag QueryParam2 = "tag" + QueryParam2Month QueryParam2 = "month" + QueryParam2Day QueryParam2 = "day" + QueryParam2Hour QueryParam2 = "hour" ) -func (e Two) ToPointer() *Two { +func (e QueryParam2) ToPointer() *QueryParam2 { return &e } -func (e *Two) UnmarshalJSON(data []byte) error { +func (e *QueryParam2) UnmarshalJSON(data []byte) error { var v string if err := json.Unmarshal(data, &v); err != nil { return err @@ -176,10 +176,10 @@ func (e *Two) UnmarshalJSON(data []byte) error { case "day": fallthrough case "hour": - *e = Two(v) + *e = QueryParam2(v) return nil default: - return fmt.Errorf("invalid value for Two: %v", v) + return fmt.Errorf("invalid value for QueryParam2: %v", v) } } @@ -227,16 +227,16 @@ func (e *One) UnmarshalJSON(data []byte) error { type GroupByType string const ( - GroupByTypeOne GroupByType = "1" - GroupByTypeArrayOf2 GroupByType = "arrayOf2" + GroupByTypeOne GroupByType = "1" + GroupByTypeArrayOfQueryParam2 GroupByType = "arrayOfQueryParam2" ) // GroupBy - By default, datapoints are not aggregated, however you probably want to get a breakdown per time, key or identity. // // Grouping by tags and by tag is mutually exclusive. type GroupBy struct { - One *One `queryParam:"inline"` - ArrayOf2 []Two `queryParam:"inline"` + One *One `queryParam:"inline"` + ArrayOfQueryParam2 []QueryParam2 `queryParam:"inline"` Type GroupByType } @@ -250,12 +250,12 @@ func CreateGroupByOne(one One) GroupBy { } } -func CreateGroupByArrayOf2(arrayOf2 []Two) GroupBy { - typ := GroupByTypeArrayOf2 +func CreateGroupByArrayOfQueryParam2(arrayOfQueryParam2 []QueryParam2) GroupBy { + typ := GroupByTypeArrayOfQueryParam2 return GroupBy{ - ArrayOf2: arrayOf2, - Type: typ, + ArrayOfQueryParam2: arrayOfQueryParam2, + Type: typ, } } @@ -268,10 +268,10 @@ func (u *GroupBy) UnmarshalJSON(data []byte) error { return nil } - var arrayOf2 []Two = []Two{} - if err := utils.UnmarshalJSON(data, &arrayOf2, "", true, true); err == nil { - u.ArrayOf2 = arrayOf2 - u.Type = GroupByTypeArrayOf2 + var arrayOfQueryParam2 []QueryParam2 = []QueryParam2{} + if err := utils.UnmarshalJSON(data, &arrayOfQueryParam2, "", true, true); err == nil { + u.ArrayOfQueryParam2 = arrayOfQueryParam2 + u.Type = GroupByTypeArrayOfQueryParam2 return nil } @@ -283,8 +283,8 @@ func (u GroupBy) MarshalJSON() ([]byte, error) { return utils.MarshalJSON(u.One, "", true) } - if u.ArrayOf2 != nil { - return utils.MarshalJSON(u.ArrayOf2, "", true) + if u.ArrayOfQueryParam2 != nil { + return utils.MarshalJSON(u.ArrayOfQueryParam2, "", true) } return nil, errors.New("could not marshal union type GroupBy: all fields are null") @@ -385,7 +385,7 @@ type GetVerificationsRequest struct { // When you are providing zero or more than one tag, all usage counts are aggregated and summed up. Send multiple requests with one tag each if you need counts per tag. Tag *Tag `queryParam:"style=form,explode=true,name=tag"` Start *int64 `queryParam:"style=form,explode=true,name=start"` - End *int64 `default:"1738456331924" queryParam:"style=form,explode=true,name=end"` + End *int64 `default:"1746664478444" queryParam:"style=form,explode=true,name=end"` // By default, datapoints are not aggregated, however you probably want to get a breakdown per time, key or identity. // // Grouping by tags and by tag is mutually exclusive. diff --git a/models/sdkerrors/errpreconditionfailed.go b/models/sdkerrors/errpreconditionfailed.go new file mode 100644 index 0000000..5b28d2d --- /dev/null +++ b/models/sdkerrors/errpreconditionfailed.go @@ -0,0 +1,82 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package sdkerrors + +import ( + "encoding/json" + "fmt" +) + +// ErrPreconditionFailedCode - A machine readable error code. +type ErrPreconditionFailedCode string + +const ( + ErrPreconditionFailedCodePreconditionFailed ErrPreconditionFailedCode = "PRECONDITION_FAILED" +) + +func (e ErrPreconditionFailedCode) ToPointer() *ErrPreconditionFailedCode { + return &e +} +func (e *ErrPreconditionFailedCode) UnmarshalJSON(data []byte) error { + var v string + if err := json.Unmarshal(data, &v); err != nil { + return err + } + switch v { + case "PRECONDITION_FAILED": + *e = ErrPreconditionFailedCode(v) + return nil + default: + return fmt.Errorf("invalid value for ErrPreconditionFailedCode: %v", v) + } +} + +type ErrPreconditionFailedError struct { + // A machine readable error code. + Code ErrPreconditionFailedCode `json:"code"` + // A link to our documentation with more details about this error code + Docs string `json:"docs"` + // A human readable explanation of what went wrong + Message string `json:"message"` + // Please always include the requestId in your error report + RequestID string `json:"requestId"` +} + +func (o *ErrPreconditionFailedError) GetCode() ErrPreconditionFailedCode { + if o == nil { + return ErrPreconditionFailedCode("") + } + return o.Code +} + +func (o *ErrPreconditionFailedError) GetDocs() string { + if o == nil { + return "" + } + return o.Docs +} + +func (o *ErrPreconditionFailedError) GetMessage() string { + if o == nil { + return "" + } + return o.Message +} + +func (o *ErrPreconditionFailedError) GetRequestID() string { + if o == nil { + return "" + } + return o.RequestID +} + +type ErrPreconditionFailed struct { + Error_ ErrPreconditionFailedError `json:"error"` +} + +var _ error = &ErrPreconditionFailed{} + +func (e *ErrPreconditionFailed) Error() string { + data, _ := json.Marshal(e) + return string(data) +} diff --git a/permissions.go b/permissions.go index 50ca8a8..4cd00a2 100644 --- a/permissions.go +++ b/permissions.go @@ -27,13 +27,6 @@ func newPermissions(sdkConfig sdkConfiguration) *Permissions { } func (s *Permissions) CreatePermission(ctx context.Context, request operations.CreatePermissionRequestBody, opts ...operations.Option) (*operations.CreatePermissionResponse, error) { - hookCtx := hooks.HookContext{ - Context: ctx, - OperationID: "createPermission", - OAuth2Scopes: []string{}, - SecuritySource: s.sdkConfiguration.Security, - } - o := operations.Options{} supportedOptions := []string{ operations.SupportedOptionRetries, @@ -57,6 +50,13 @@ func (s *Permissions) CreatePermission(ctx context.Context, request operations.C return nil, fmt.Errorf("error generating URL: %w", err) } + hookCtx := hooks.HookContext{ + BaseURL: baseURL, + Context: ctx, + OperationID: "createPermission", + OAuth2Scopes: []string{}, + SecuritySource: s.sdkConfiguration.Security, + } bodyReader, reqContentType, err := utils.SerializeRequestBody(ctx, request, false, false, "Request", "json", `request:"mediaType=application/json"`) if err != nil { return nil, err @@ -171,7 +171,7 @@ func (s *Permissions) CreatePermission(ctx context.Context, request operations.C _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) return nil, err - } else if utils.MatchStatusCodes([]string{"400", "401", "403", "404", "409", "429", "4XX", "500", "5XX"}, httpRes.StatusCode) { + } else if utils.MatchStatusCodes([]string{"400", "401", "403", "404", "409", "412", "429", "4XX", "500", "5XX"}, httpRes.StatusCode) { _httpRes, err := s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) if err != nil { return nil, err @@ -312,6 +312,27 @@ func (s *Permissions) CreatePermission(ctx context.Context, request operations.C return nil, err } + return nil, &out + default: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + case httpRes.StatusCode == 412: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + + var out sdkerrors.ErrPreconditionFailed + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + return nil, &out default: rawBody, err := utils.ConsumeRawBody(httpRes) @@ -387,13 +408,6 @@ func (s *Permissions) CreatePermission(ctx context.Context, request operations.C } func (s *Permissions) DeletePermission(ctx context.Context, request operations.DeletePermissionRequestBody, opts ...operations.Option) (*operations.DeletePermissionResponse, error) { - hookCtx := hooks.HookContext{ - Context: ctx, - OperationID: "deletePermission", - OAuth2Scopes: []string{}, - SecuritySource: s.sdkConfiguration.Security, - } - o := operations.Options{} supportedOptions := []string{ operations.SupportedOptionRetries, @@ -417,6 +431,13 @@ func (s *Permissions) DeletePermission(ctx context.Context, request operations.D return nil, fmt.Errorf("error generating URL: %w", err) } + hookCtx := hooks.HookContext{ + BaseURL: baseURL, + Context: ctx, + OperationID: "deletePermission", + OAuth2Scopes: []string{}, + SecuritySource: s.sdkConfiguration.Security, + } bodyReader, reqContentType, err := utils.SerializeRequestBody(ctx, request, false, false, "Request", "json", `request:"mediaType=application/json"`) if err != nil { return nil, err @@ -531,7 +552,7 @@ func (s *Permissions) DeletePermission(ctx context.Context, request operations.D _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) return nil, err - } else if utils.MatchStatusCodes([]string{"400", "401", "403", "404", "409", "429", "4XX", "500", "5XX"}, httpRes.StatusCode) { + } else if utils.MatchStatusCodes([]string{"400", "401", "403", "404", "409", "412", "429", "4XX", "500", "5XX"}, httpRes.StatusCode) { _httpRes, err := s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) if err != nil { return nil, err @@ -672,6 +693,27 @@ func (s *Permissions) DeletePermission(ctx context.Context, request operations.D return nil, err } + return nil, &out + default: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + case httpRes.StatusCode == 412: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + + var out sdkerrors.ErrPreconditionFailed + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + return nil, &out default: rawBody, err := utils.ConsumeRawBody(httpRes) @@ -747,13 +789,6 @@ func (s *Permissions) DeletePermission(ctx context.Context, request operations.D } func (s *Permissions) GetPermission(ctx context.Context, request operations.GetPermissionRequest, opts ...operations.Option) (*operations.GetPermissionResponse, error) { - hookCtx := hooks.HookContext{ - Context: ctx, - OperationID: "getPermission", - OAuth2Scopes: []string{}, - SecuritySource: s.sdkConfiguration.Security, - } - o := operations.Options{} supportedOptions := []string{ operations.SupportedOptionRetries, @@ -777,6 +812,14 @@ func (s *Permissions) GetPermission(ctx context.Context, request operations.GetP return nil, fmt.Errorf("error generating URL: %w", err) } + hookCtx := hooks.HookContext{ + BaseURL: baseURL, + Context: ctx, + OperationID: "getPermission", + OAuth2Scopes: []string{}, + SecuritySource: s.sdkConfiguration.Security, + } + timeout := o.Timeout if timeout == nil { timeout = s.sdkConfiguration.Timeout @@ -887,7 +930,7 @@ func (s *Permissions) GetPermission(ctx context.Context, request operations.GetP _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) return nil, err - } else if utils.MatchStatusCodes([]string{"400", "401", "403", "404", "409", "429", "4XX", "500", "5XX"}, httpRes.StatusCode) { + } else if utils.MatchStatusCodes([]string{"400", "401", "403", "404", "409", "412", "429", "4XX", "500", "5XX"}, httpRes.StatusCode) { _httpRes, err := s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) if err != nil { return nil, err @@ -1028,6 +1071,27 @@ func (s *Permissions) GetPermission(ctx context.Context, request operations.GetP return nil, err } + return nil, &out + default: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + case httpRes.StatusCode == 412: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + + var out sdkerrors.ErrPreconditionFailed + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + return nil, &out default: rawBody, err := utils.ConsumeRawBody(httpRes) @@ -1103,13 +1167,6 @@ func (s *Permissions) GetPermission(ctx context.Context, request operations.GetP } func (s *Permissions) ListPermissions(ctx context.Context, opts ...operations.Option) (*operations.ListPermissionsResponse, error) { - hookCtx := hooks.HookContext{ - Context: ctx, - OperationID: "listPermissions", - OAuth2Scopes: []string{}, - SecuritySource: s.sdkConfiguration.Security, - } - o := operations.Options{} supportedOptions := []string{ operations.SupportedOptionRetries, @@ -1133,6 +1190,14 @@ func (s *Permissions) ListPermissions(ctx context.Context, opts ...operations.Op return nil, fmt.Errorf("error generating URL: %w", err) } + hookCtx := hooks.HookContext{ + BaseURL: baseURL, + Context: ctx, + OperationID: "listPermissions", + OAuth2Scopes: []string{}, + SecuritySource: s.sdkConfiguration.Security, + } + timeout := o.Timeout if timeout == nil { timeout = s.sdkConfiguration.Timeout @@ -1239,7 +1304,7 @@ func (s *Permissions) ListPermissions(ctx context.Context, opts ...operations.Op _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) return nil, err - } else if utils.MatchStatusCodes([]string{"400", "401", "403", "404", "409", "429", "4XX", "500", "5XX"}, httpRes.StatusCode) { + } else if utils.MatchStatusCodes([]string{"400", "401", "403", "404", "409", "412", "429", "4XX", "500", "5XX"}, httpRes.StatusCode) { _httpRes, err := s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) if err != nil { return nil, err @@ -1380,6 +1445,27 @@ func (s *Permissions) ListPermissions(ctx context.Context, opts ...operations.Op return nil, err } + return nil, &out + default: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + case httpRes.StatusCode == 412: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + + var out sdkerrors.ErrPreconditionFailed + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + return nil, &out default: rawBody, err := utils.ConsumeRawBody(httpRes) @@ -1455,13 +1541,6 @@ func (s *Permissions) ListPermissions(ctx context.Context, opts ...operations.Op } func (s *Permissions) CreateRole(ctx context.Context, request operations.CreateRoleRequestBody, opts ...operations.Option) (*operations.CreateRoleResponse, error) { - hookCtx := hooks.HookContext{ - Context: ctx, - OperationID: "createRole", - OAuth2Scopes: []string{}, - SecuritySource: s.sdkConfiguration.Security, - } - o := operations.Options{} supportedOptions := []string{ operations.SupportedOptionRetries, @@ -1485,6 +1564,13 @@ func (s *Permissions) CreateRole(ctx context.Context, request operations.CreateR return nil, fmt.Errorf("error generating URL: %w", err) } + hookCtx := hooks.HookContext{ + BaseURL: baseURL, + Context: ctx, + OperationID: "createRole", + OAuth2Scopes: []string{}, + SecuritySource: s.sdkConfiguration.Security, + } bodyReader, reqContentType, err := utils.SerializeRequestBody(ctx, request, false, false, "Request", "json", `request:"mediaType=application/json"`) if err != nil { return nil, err @@ -1599,7 +1685,7 @@ func (s *Permissions) CreateRole(ctx context.Context, request operations.CreateR _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) return nil, err - } else if utils.MatchStatusCodes([]string{"400", "401", "403", "404", "409", "429", "4XX", "500", "5XX"}, httpRes.StatusCode) { + } else if utils.MatchStatusCodes([]string{"400", "401", "403", "404", "409", "412", "429", "4XX", "500", "5XX"}, httpRes.StatusCode) { _httpRes, err := s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) if err != nil { return nil, err @@ -1740,6 +1826,27 @@ func (s *Permissions) CreateRole(ctx context.Context, request operations.CreateR return nil, err } + return nil, &out + default: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + case httpRes.StatusCode == 412: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + + var out sdkerrors.ErrPreconditionFailed + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + return nil, &out default: rawBody, err := utils.ConsumeRawBody(httpRes) @@ -1815,13 +1922,6 @@ func (s *Permissions) CreateRole(ctx context.Context, request operations.CreateR } func (s *Permissions) DeleteRole(ctx context.Context, request operations.DeleteRoleRequestBody, opts ...operations.Option) (*operations.DeleteRoleResponse, error) { - hookCtx := hooks.HookContext{ - Context: ctx, - OperationID: "deleteRole", - OAuth2Scopes: []string{}, - SecuritySource: s.sdkConfiguration.Security, - } - o := operations.Options{} supportedOptions := []string{ operations.SupportedOptionRetries, @@ -1845,6 +1945,13 @@ func (s *Permissions) DeleteRole(ctx context.Context, request operations.DeleteR return nil, fmt.Errorf("error generating URL: %w", err) } + hookCtx := hooks.HookContext{ + BaseURL: baseURL, + Context: ctx, + OperationID: "deleteRole", + OAuth2Scopes: []string{}, + SecuritySource: s.sdkConfiguration.Security, + } bodyReader, reqContentType, err := utils.SerializeRequestBody(ctx, request, false, false, "Request", "json", `request:"mediaType=application/json"`) if err != nil { return nil, err @@ -1959,7 +2066,7 @@ func (s *Permissions) DeleteRole(ctx context.Context, request operations.DeleteR _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) return nil, err - } else if utils.MatchStatusCodes([]string{"400", "401", "403", "404", "409", "429", "4XX", "500", "5XX"}, httpRes.StatusCode) { + } else if utils.MatchStatusCodes([]string{"400", "401", "403", "404", "409", "412", "429", "4XX", "500", "5XX"}, httpRes.StatusCode) { _httpRes, err := s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) if err != nil { return nil, err @@ -2100,6 +2207,27 @@ func (s *Permissions) DeleteRole(ctx context.Context, request operations.DeleteR return nil, err } + return nil, &out + default: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + case httpRes.StatusCode == 412: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + + var out sdkerrors.ErrPreconditionFailed + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + return nil, &out default: rawBody, err := utils.ConsumeRawBody(httpRes) @@ -2175,13 +2303,6 @@ func (s *Permissions) DeleteRole(ctx context.Context, request operations.DeleteR } func (s *Permissions) GetRole(ctx context.Context, request operations.GetRoleRequest, opts ...operations.Option) (*operations.GetRoleResponse, error) { - hookCtx := hooks.HookContext{ - Context: ctx, - OperationID: "getRole", - OAuth2Scopes: []string{}, - SecuritySource: s.sdkConfiguration.Security, - } - o := operations.Options{} supportedOptions := []string{ operations.SupportedOptionRetries, @@ -2205,6 +2326,14 @@ func (s *Permissions) GetRole(ctx context.Context, request operations.GetRoleReq return nil, fmt.Errorf("error generating URL: %w", err) } + hookCtx := hooks.HookContext{ + BaseURL: baseURL, + Context: ctx, + OperationID: "getRole", + OAuth2Scopes: []string{}, + SecuritySource: s.sdkConfiguration.Security, + } + timeout := o.Timeout if timeout == nil { timeout = s.sdkConfiguration.Timeout @@ -2315,7 +2444,7 @@ func (s *Permissions) GetRole(ctx context.Context, request operations.GetRoleReq _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) return nil, err - } else if utils.MatchStatusCodes([]string{"400", "401", "403", "404", "409", "429", "4XX", "500", "5XX"}, httpRes.StatusCode) { + } else if utils.MatchStatusCodes([]string{"400", "401", "403", "404", "409", "412", "429", "4XX", "500", "5XX"}, httpRes.StatusCode) { _httpRes, err := s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) if err != nil { return nil, err @@ -2456,6 +2585,27 @@ func (s *Permissions) GetRole(ctx context.Context, request operations.GetRoleReq return nil, err } + return nil, &out + default: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + case httpRes.StatusCode == 412: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + + var out sdkerrors.ErrPreconditionFailed + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + return nil, &out default: rawBody, err := utils.ConsumeRawBody(httpRes) @@ -2531,13 +2681,6 @@ func (s *Permissions) GetRole(ctx context.Context, request operations.GetRoleReq } func (s *Permissions) ListRoles(ctx context.Context, opts ...operations.Option) (*operations.ListRolesResponse, error) { - hookCtx := hooks.HookContext{ - Context: ctx, - OperationID: "listRoles", - OAuth2Scopes: []string{}, - SecuritySource: s.sdkConfiguration.Security, - } - o := operations.Options{} supportedOptions := []string{ operations.SupportedOptionRetries, @@ -2561,6 +2704,14 @@ func (s *Permissions) ListRoles(ctx context.Context, opts ...operations.Option) return nil, fmt.Errorf("error generating URL: %w", err) } + hookCtx := hooks.HookContext{ + BaseURL: baseURL, + Context: ctx, + OperationID: "listRoles", + OAuth2Scopes: []string{}, + SecuritySource: s.sdkConfiguration.Security, + } + timeout := o.Timeout if timeout == nil { timeout = s.sdkConfiguration.Timeout @@ -2667,7 +2818,7 @@ func (s *Permissions) ListRoles(ctx context.Context, opts ...operations.Option) _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) return nil, err - } else if utils.MatchStatusCodes([]string{"400", "401", "403", "404", "409", "429", "4XX", "500", "5XX"}, httpRes.StatusCode) { + } else if utils.MatchStatusCodes([]string{"400", "401", "403", "404", "409", "412", "429", "4XX", "500", "5XX"}, httpRes.StatusCode) { _httpRes, err := s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) if err != nil { return nil, err @@ -2808,6 +2959,27 @@ func (s *Permissions) ListRoles(ctx context.Context, opts ...operations.Option) return nil, err } + return nil, &out + default: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + case httpRes.StatusCode == 412: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + + var out sdkerrors.ErrPreconditionFailed + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + return nil, &out default: rawBody, err := utils.ConsumeRawBody(httpRes) diff --git a/ratelimit.go b/ratelimit.go index ebfbd59..8deb7bf 100644 --- a/ratelimit.go +++ b/ratelimit.go @@ -27,13 +27,6 @@ func newRatelimit(sdkConfig sdkConfiguration) *Ratelimit { } func (s *Ratelimit) SetOverride(ctx context.Context, request operations.SetOverrideRequestBody, opts ...operations.Option) (*operations.SetOverrideResponse, error) { - hookCtx := hooks.HookContext{ - Context: ctx, - OperationID: "setOverride", - OAuth2Scopes: []string{}, - SecuritySource: s.sdkConfiguration.Security, - } - o := operations.Options{} supportedOptions := []string{ operations.SupportedOptionRetries, @@ -57,6 +50,13 @@ func (s *Ratelimit) SetOverride(ctx context.Context, request operations.SetOverr return nil, fmt.Errorf("error generating URL: %w", err) } + hookCtx := hooks.HookContext{ + BaseURL: baseURL, + Context: ctx, + OperationID: "setOverride", + OAuth2Scopes: []string{}, + SecuritySource: s.sdkConfiguration.Security, + } bodyReader, reqContentType, err := utils.SerializeRequestBody(ctx, request, false, false, "Request", "json", `request:"mediaType=application/json"`) if err != nil { return nil, err @@ -171,7 +171,7 @@ func (s *Ratelimit) SetOverride(ctx context.Context, request operations.SetOverr _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) return nil, err - } else if utils.MatchStatusCodes([]string{"400", "401", "403", "404", "409", "429", "4XX", "500", "5XX"}, httpRes.StatusCode) { + } else if utils.MatchStatusCodes([]string{"400", "401", "403", "404", "409", "412", "429", "4XX", "500", "5XX"}, httpRes.StatusCode) { _httpRes, err := s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) if err != nil { return nil, err @@ -312,6 +312,27 @@ func (s *Ratelimit) SetOverride(ctx context.Context, request operations.SetOverr return nil, err } + return nil, &out + default: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + case httpRes.StatusCode == 412: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + + var out sdkerrors.ErrPreconditionFailed + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + return nil, &out default: rawBody, err := utils.ConsumeRawBody(httpRes) @@ -387,13 +408,6 @@ func (s *Ratelimit) SetOverride(ctx context.Context, request operations.SetOverr } func (s *Ratelimit) ListOverrides(ctx context.Context, request operations.ListOverridesRequest, opts ...operations.Option) (*operations.ListOverridesResponse, error) { - hookCtx := hooks.HookContext{ - Context: ctx, - OperationID: "listOverrides", - OAuth2Scopes: []string{}, - SecuritySource: s.sdkConfiguration.Security, - } - o := operations.Options{} supportedOptions := []string{ operations.SupportedOptionRetries, @@ -417,6 +431,14 @@ func (s *Ratelimit) ListOverrides(ctx context.Context, request operations.ListOv return nil, fmt.Errorf("error generating URL: %w", err) } + hookCtx := hooks.HookContext{ + BaseURL: baseURL, + Context: ctx, + OperationID: "listOverrides", + OAuth2Scopes: []string{}, + SecuritySource: s.sdkConfiguration.Security, + } + timeout := o.Timeout if timeout == nil { timeout = s.sdkConfiguration.Timeout @@ -527,7 +549,7 @@ func (s *Ratelimit) ListOverrides(ctx context.Context, request operations.ListOv _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) return nil, err - } else if utils.MatchStatusCodes([]string{"400", "401", "403", "404", "409", "429", "4XX", "500", "5XX"}, httpRes.StatusCode) { + } else if utils.MatchStatusCodes([]string{"400", "401", "403", "404", "409", "412", "429", "4XX", "500", "5XX"}, httpRes.StatusCode) { _httpRes, err := s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) if err != nil { return nil, err @@ -668,6 +690,27 @@ func (s *Ratelimit) ListOverrides(ctx context.Context, request operations.ListOv return nil, err } + return nil, &out + default: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + case httpRes.StatusCode == 412: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + + var out sdkerrors.ErrPreconditionFailed + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + return nil, &out default: rawBody, err := utils.ConsumeRawBody(httpRes) @@ -743,13 +786,6 @@ func (s *Ratelimit) ListOverrides(ctx context.Context, request operations.ListOv } func (s *Ratelimit) GetOverride(ctx context.Context, request operations.GetOverrideRequest, opts ...operations.Option) (*operations.GetOverrideResponse, error) { - hookCtx := hooks.HookContext{ - Context: ctx, - OperationID: "getOverride", - OAuth2Scopes: []string{}, - SecuritySource: s.sdkConfiguration.Security, - } - o := operations.Options{} supportedOptions := []string{ operations.SupportedOptionRetries, @@ -773,6 +809,14 @@ func (s *Ratelimit) GetOverride(ctx context.Context, request operations.GetOverr return nil, fmt.Errorf("error generating URL: %w", err) } + hookCtx := hooks.HookContext{ + BaseURL: baseURL, + Context: ctx, + OperationID: "getOverride", + OAuth2Scopes: []string{}, + SecuritySource: s.sdkConfiguration.Security, + } + timeout := o.Timeout if timeout == nil { timeout = s.sdkConfiguration.Timeout @@ -883,7 +927,7 @@ func (s *Ratelimit) GetOverride(ctx context.Context, request operations.GetOverr _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) return nil, err - } else if utils.MatchStatusCodes([]string{"400", "401", "403", "404", "409", "429", "4XX", "500", "5XX"}, httpRes.StatusCode) { + } else if utils.MatchStatusCodes([]string{"400", "401", "403", "404", "409", "412", "429", "4XX", "500", "5XX"}, httpRes.StatusCode) { _httpRes, err := s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) if err != nil { return nil, err @@ -1024,6 +1068,27 @@ func (s *Ratelimit) GetOverride(ctx context.Context, request operations.GetOverr return nil, err } + return nil, &out + default: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + case httpRes.StatusCode == 412: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + + var out sdkerrors.ErrPreconditionFailed + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + return nil, &out default: rawBody, err := utils.ConsumeRawBody(httpRes) diff --git a/ratelimits.go b/ratelimits.go index e76d6d9..39c412f 100644 --- a/ratelimits.go +++ b/ratelimits.go @@ -27,13 +27,6 @@ func newRatelimits(sdkConfig sdkConfiguration) *Ratelimits { } func (s *Ratelimits) Limit(ctx context.Context, request operations.LimitRequestBody, opts ...operations.Option) (*operations.LimitResponse, error) { - hookCtx := hooks.HookContext{ - Context: ctx, - OperationID: "limit", - OAuth2Scopes: []string{}, - SecuritySource: s.sdkConfiguration.Security, - } - o := operations.Options{} supportedOptions := []string{ operations.SupportedOptionRetries, @@ -57,6 +50,13 @@ func (s *Ratelimits) Limit(ctx context.Context, request operations.LimitRequestB return nil, fmt.Errorf("error generating URL: %w", err) } + hookCtx := hooks.HookContext{ + BaseURL: baseURL, + Context: ctx, + OperationID: "limit", + OAuth2Scopes: []string{}, + SecuritySource: s.sdkConfiguration.Security, + } bodyReader, reqContentType, err := utils.SerializeRequestBody(ctx, request, false, false, "Request", "json", `request:"mediaType=application/json"`) if err != nil { return nil, err @@ -171,7 +171,7 @@ func (s *Ratelimits) Limit(ctx context.Context, request operations.LimitRequestB _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) return nil, err - } else if utils.MatchStatusCodes([]string{"400", "401", "403", "404", "409", "429", "4XX", "500", "5XX"}, httpRes.StatusCode) { + } else if utils.MatchStatusCodes([]string{"400", "401", "403", "404", "409", "412", "429", "4XX", "500", "5XX"}, httpRes.StatusCode) { _httpRes, err := s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) if err != nil { return nil, err @@ -312,6 +312,27 @@ func (s *Ratelimits) Limit(ctx context.Context, request operations.LimitRequestB return nil, err } + return nil, &out + default: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + case httpRes.StatusCode == 412: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + + var out sdkerrors.ErrPreconditionFailed + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + return nil, &out default: rawBody, err := utils.ConsumeRawBody(httpRes) @@ -387,13 +408,6 @@ func (s *Ratelimits) Limit(ctx context.Context, request operations.LimitRequestB } func (s *Ratelimits) DeleteOverride(ctx context.Context, request operations.DeleteOverrideRequestBody, opts ...operations.Option) (*operations.DeleteOverrideResponse, error) { - hookCtx := hooks.HookContext{ - Context: ctx, - OperationID: "deleteOverride", - OAuth2Scopes: []string{}, - SecuritySource: s.sdkConfiguration.Security, - } - o := operations.Options{} supportedOptions := []string{ operations.SupportedOptionRetries, @@ -417,6 +431,13 @@ func (s *Ratelimits) DeleteOverride(ctx context.Context, request operations.Dele return nil, fmt.Errorf("error generating URL: %w", err) } + hookCtx := hooks.HookContext{ + BaseURL: baseURL, + Context: ctx, + OperationID: "deleteOverride", + OAuth2Scopes: []string{}, + SecuritySource: s.sdkConfiguration.Security, + } bodyReader, reqContentType, err := utils.SerializeRequestBody(ctx, request, false, false, "Request", "json", `request:"mediaType=application/json"`) if err != nil { return nil, err @@ -531,7 +552,7 @@ func (s *Ratelimits) DeleteOverride(ctx context.Context, request operations.Dele _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) return nil, err - } else if utils.MatchStatusCodes([]string{"400", "401", "403", "404", "409", "429", "4XX", "500", "5XX"}, httpRes.StatusCode) { + } else if utils.MatchStatusCodes([]string{"400", "401", "403", "404", "409", "412", "429", "4XX", "500", "5XX"}, httpRes.StatusCode) { _httpRes, err := s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) if err != nil { return nil, err @@ -672,6 +693,27 @@ func (s *Ratelimits) DeleteOverride(ctx context.Context, request operations.Dele return nil, err } + return nil, &out + default: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + case httpRes.StatusCode == 412: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + + var out sdkerrors.ErrPreconditionFailed + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + return nil, &out default: rawBody, err := utils.ConsumeRawBody(httpRes) diff --git a/unkey.go b/unkey.go index 06eb7bf..1369e9e 100644 --- a/unkey.go +++ b/unkey.go @@ -156,9 +156,9 @@ func New(opts ...SDKOption) *Unkey { sdkConfiguration: sdkConfiguration{ Language: "go", OpenAPIDocVersion: "1.0.0", - SDKVersion: "0.12.0", - GenVersion: "2.500.5", - UserAgent: "speakeasy-sdk/go 0.12.0 2.500.5 1.0.0 github.com/unkeyed/unkey-go", + SDKVersion: "0.13.0", + GenVersion: "2.597.9", + UserAgent: "speakeasy-sdk/go 0.13.0 2.597.9 1.0.0 github.com/unkeyed/unkey-go", Hooks: hooks.New(), }, }