diff --git a/.speakeasy/gen.lock b/.speakeasy/gen.lock index 29b50ea..0f2fc1c 100755 --- a/.speakeasy/gen.lock +++ b/.speakeasy/gen.lock @@ -3,10 +3,10 @@ id: 4fc4737a-135f-4840-8e6d-42a2b2a2884b management: docChecksum: 547602f40f6ad29534bfdf081cab8873 docVersion: 1.0.0 - speakeasyVersion: 1.323.0 - generationVersion: 2.356.0 - releaseVersion: 0.5.0 - configChecksum: c40e320661f7800a66c6e3a1a4f1848e + speakeasyVersion: 1.326.0 + generationVersion: 2.359.0 + releaseVersion: 0.6.0 + configChecksum: 2a6062478c58c77a364cffd8940a8f10 repoURL: https://github.com/unkeyed/unkey-go.git installationURL: https://github.com/unkeyed/unkey-go features: @@ -23,7 +23,7 @@ features: intellisenseMarkdownSupport: 0.1.0 nullables: 0.1.0 responseFormat: 0.1.2 - retries: 2.82.3 + retries: 2.83.0 sdkHooks: 0.1.0 unions: 2.85.8 generatedFiles: @@ -35,6 +35,7 @@ generatedFiles: - unkey.go - go.mod - models/sdkerrors/sdkerror.go + - retry/config.go - types/bigint.go - types/date.go - types/datetime.go diff --git a/.speakeasy/gen.yaml b/.speakeasy/gen.yaml index d98b900..7f16f13 100755 --- a/.speakeasy/gen.yaml +++ b/.speakeasy/gen.yaml @@ -12,7 +12,7 @@ generation: auth: oAuth2ClientCredentialsEnabled: true go: - version: 0.5.0 + version: 0.6.0 additionalDependencies: {} allowUnknownFieldsInWeakUnions: false clientServerStatusCodesAsErrors: true diff --git a/.speakeasy/workflow.lock b/.speakeasy/workflow.lock index 9a9e71f..0450fec 100644 --- a/.speakeasy/workflow.lock +++ b/.speakeasy/workflow.lock @@ -1,9 +1,9 @@ -speakeasyVersion: 1.323.0 +speakeasyVersion: 1.326.0 sources: openapi.json: sourceNamespace: openapi-json - sourceRevisionDigest: sha256:daa279be1b2180ce5cf7921e155470a69575ec657399a60954d3dc35fa06c240 - sourceBlobDigest: sha256:786c8a969b1dea1edf088eb35e0a33aee288802e4b9ce4e3deffb9a2489357b9 + sourceRevisionDigest: sha256:5755e12422b9cd83ab813c9d2ffd43a55d73bbbf981cbee7da4d4da7a0380903 + sourceBlobDigest: sha256:ef83f05349e97390bd3543fff7b29fb47c0067e347d53e75922e5e1c52d2b721 tags: - latest - main @@ -11,8 +11,8 @@ targets: go: source: openapi.json sourceNamespace: openapi-json - sourceRevisionDigest: sha256:daa279be1b2180ce5cf7921e155470a69575ec657399a60954d3dc35fa06c240 - sourceBlobDigest: sha256:786c8a969b1dea1edf088eb35e0a33aee288802e4b9ce4e3deffb9a2489357b9 + sourceRevisionDigest: sha256:5755e12422b9cd83ab813c9d2ffd43a55d73bbbf981cbee7da4d4da7a0380903 + sourceBlobDigest: sha256:ef83f05349e97390bd3543fff7b29fb47c0067e347d53e75922e5e1c52d2b721 outLocation: /github/workspace/repo workflow: workflowVersion: 1.0.0 diff --git a/README.md b/README.md index bb452d2..6107d4a 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,6 @@ ! - ## SDK Installation ```bash @@ -341,15 +340,15 @@ func main() { Some of the endpoints in this SDK support retries. If you use the SDK without any configuration, it will fall back to the default retry strategy provided by the API. However, the default retry strategy can be overridden on a per-operation basis, or across the entire SDK. -To change the default retry strategy for a single API call, simply provide a `RetryConfig` object to the call by using the `WithRetries` option: +To change the default retry strategy for a single API call, simply provide a `retry.Config` object to the call by using the `WithRetries` option: ```go package main import ( "context" unkeygo "github.com/unkeyed/unkey-go" - "github.com/unkeyed/unkey-go/internal/utils" "github.com/unkeyed/unkey-go/models/operations" + "github.com/unkeyed/unkey-go/retry" "log" "models/operations" ) @@ -363,9 +362,9 @@ func main() { } ctx := context.Background() res, err := s.CreateAPI(ctx, request, operations.WithRetries( - utils.RetryConfig{ + retry.Config{ Strategy: "backoff", - Backoff: &utils.BackoffStrategy{ + Backoff: &retry.BackoffStrategy{ InitialInterval: 1, MaxInterval: 50, Exponent: 1.1, @@ -390,17 +389,17 @@ package main import ( "context" unkeygo "github.com/unkeyed/unkey-go" - "github.com/unkeyed/unkey-go/internal/utils" "github.com/unkeyed/unkey-go/models/operations" + "github.com/unkeyed/unkey-go/retry" "log" ) func main() { s := unkeygo.New( unkeygo.WithRetryConfig( - utils.RetryConfig{ + retry.Config{ Strategy: "backoff", - Backoff: &utils.BackoffStrategy{ + Backoff: &retry.BackoffStrategy{ InitialInterval: 1, MaxInterval: 50, Exponent: 1.1, diff --git a/RELEASES.md b/RELEASES.md index 49fb109..723f573 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -98,4 +98,14 @@ Based on: ### Generated - [go v0.5.0] . ### Releases -- [Go v0.5.0] https://github.com/unkeyed/unkey-go/releases/tag/v0.5.0 - . \ No newline at end of file +- [Go v0.5.0] https://github.com/unkeyed/unkey-go/releases/tag/v0.5.0 - . + +## 2024-07-02 16:36:20 +### Changes +Based on: +- OpenAPI Doc +- Speakeasy CLI 1.326.0 (2.359.0) https://github.com/speakeasy-api/speakeasy +### Generated +- [go v0.6.0] . +### Releases +- [Go v0.6.0] https://github.com/unkeyed/unkey-go/releases/tag/v0.6.0 - . \ No newline at end of file diff --git a/apis.go b/apis.go index 6283496..561208b 100644 --- a/apis.go +++ b/apis.go @@ -12,6 +12,7 @@ import ( "github.com/unkeyed/unkey-go/models/components" "github.com/unkeyed/unkey-go/models/operations" "github.com/unkeyed/unkey-go/models/sdkerrors" + "github.com/unkeyed/unkey-go/retry" "io" "net/http" "net/url" @@ -70,9 +71,9 @@ func (s *Apis) GetAPI(ctx context.Context, request operations.GetAPIRequest, opt retryConfig := o.Retries if retryConfig == nil { if globalRetryConfig == nil { - retryConfig = &utils.RetryConfig{ + retryConfig = &retry.Config{ Strategy: "backoff", - Backoff: &utils.BackoffStrategy{ + Backoff: &retry.BackoffStrategy{ InitialInterval: 50, MaxInterval: 1000, Exponent: 1.5, @@ -291,9 +292,9 @@ func (s *Apis) ListKeys(ctx context.Context, request operations.ListKeysRequest, retryConfig := o.Retries if retryConfig == nil { if globalRetryConfig == nil { - retryConfig = &utils.RetryConfig{ + retryConfig = &retry.Config{ Strategy: "backoff", - Backoff: &utils.BackoffStrategy{ + Backoff: &retry.BackoffStrategy{ InitialInterval: 50, MaxInterval: 1000, Exponent: 1.5, @@ -514,9 +515,9 @@ func (s *Apis) DeleteKeys(ctx context.Context, request operations.DeleteKeysRequ retryConfig := o.Retries if retryConfig == nil { if globalRetryConfig == nil { - retryConfig = &utils.RetryConfig{ + retryConfig = &retry.Config{ Strategy: "backoff", - Backoff: &utils.BackoffStrategy{ + Backoff: &retry.BackoffStrategy{ InitialInterval: 50, MaxInterval: 1000, Exponent: 1.5, diff --git a/docs/models/operations/option.md b/docs/models/operations/option.md index 9167702..35d8a1e 100644 --- a/docs/models/operations/option.md +++ b/docs/models/operations/option.md @@ -24,9 +24,9 @@ operations.WithTemplatedServerURL("http://{host}:{port}", map[string]string{ WithRetries allows customizing the default retry configuration. Only usable with methods that mention they support retries. ```go -operations.WithRetries(utils.RetryConfig{ +operations.WithRetries(retry.Config{ Strategy: "backoff", - Backoff: utils.BackoffStrategy{ + Backoff: retry.BackoffStrategy{ InitialInterval: 500 * time.Millisecond, MaxInterval: 60 * time.Second, Exponent: 1.5, diff --git a/internal/utils/retries.go b/internal/utils/retries.go index ff39d0d..c0e0c9e 100644 --- a/internal/utils/retries.go +++ b/internal/utils/retries.go @@ -6,32 +6,25 @@ import ( "context" "errors" "fmt" + "github.com/cenkalti/backoff/v4" + "github.com/unkeyed/unkey-go/retry" "net/http" "net/url" "strconv" "strings" "time" - - "github.com/cenkalti/backoff/v4" ) var errRequestFailed = errors.New("request failed") -type BackoffStrategy struct { - InitialInterval int - MaxInterval int - Exponent float64 - MaxElapsedTime int -} +// Deprecated: Use retry.BackoffStrategy instead. +type BackoffStrategy = retry.BackoffStrategy -type RetryConfig struct { - Strategy string - Backoff *BackoffStrategy - RetryConnectionErrors bool -} +// Deprecated: Use retry.Config instead. +type RetryConfig = retry.Config type Retries struct { - Config *RetryConfig + Config *retry.Config StatusCodes []string } diff --git a/keys.go b/keys.go index 34f10d9..3d93d6c 100644 --- a/keys.go +++ b/keys.go @@ -12,6 +12,7 @@ import ( "github.com/unkeyed/unkey-go/models/components" "github.com/unkeyed/unkey-go/models/operations" "github.com/unkeyed/unkey-go/models/sdkerrors" + "github.com/unkeyed/unkey-go/retry" "io" "net/http" "net/url" @@ -70,9 +71,9 @@ func (s *Keys) GetKey(ctx context.Context, request operations.GetKeyRequest, opt retryConfig := o.Retries if retryConfig == nil { if globalRetryConfig == nil { - retryConfig = &utils.RetryConfig{ + retryConfig = &retry.Config{ Strategy: "backoff", - Backoff: &utils.BackoffStrategy{ + Backoff: &retry.BackoffStrategy{ InitialInterval: 50, MaxInterval: 1000, Exponent: 1.5, @@ -293,9 +294,9 @@ func (s *Keys) DeleteKey(ctx context.Context, request operations.DeleteKeyReques retryConfig := o.Retries if retryConfig == nil { if globalRetryConfig == nil { - retryConfig = &utils.RetryConfig{ + retryConfig = &retry.Config{ Strategy: "backoff", - Backoff: &utils.BackoffStrategy{ + Backoff: &retry.BackoffStrategy{ InitialInterval: 50, MaxInterval: 1000, Exponent: 1.5, @@ -516,9 +517,9 @@ func (s *Keys) CreateKey(ctx context.Context, request operations.CreateKeyReques retryConfig := o.Retries if retryConfig == nil { if globalRetryConfig == nil { - retryConfig = &utils.RetryConfig{ + retryConfig = &retry.Config{ Strategy: "backoff", - Backoff: &utils.BackoffStrategy{ + Backoff: &retry.BackoffStrategy{ InitialInterval: 50, MaxInterval: 1000, Exponent: 1.5, @@ -739,9 +740,9 @@ func (s *Keys) VerifyKey(ctx context.Context, request components.V1KeysVerifyKey retryConfig := o.Retries if retryConfig == nil { if globalRetryConfig == nil { - retryConfig = &utils.RetryConfig{ + retryConfig = &retry.Config{ Strategy: "backoff", - Backoff: &utils.BackoffStrategy{ + Backoff: &retry.BackoffStrategy{ InitialInterval: 50, MaxInterval: 1000, Exponent: 1.5, @@ -962,9 +963,9 @@ func (s *Keys) UpdateKey(ctx context.Context, request operations.UpdateKeyReques retryConfig := o.Retries if retryConfig == nil { if globalRetryConfig == nil { - retryConfig = &utils.RetryConfig{ + retryConfig = &retry.Config{ Strategy: "backoff", - Backoff: &utils.BackoffStrategy{ + Backoff: &retry.BackoffStrategy{ InitialInterval: 50, MaxInterval: 1000, Exponent: 1.5, @@ -1185,9 +1186,9 @@ func (s *Keys) UpdateRemaining(ctx context.Context, request operations.UpdateRem retryConfig := o.Retries if retryConfig == nil { if globalRetryConfig == nil { - retryConfig = &utils.RetryConfig{ + retryConfig = &retry.Config{ Strategy: "backoff", - Backoff: &utils.BackoffStrategy{ + Backoff: &retry.BackoffStrategy{ InitialInterval: 50, MaxInterval: 1000, Exponent: 1.5, @@ -1406,9 +1407,9 @@ func (s *Keys) GetVerifications(ctx context.Context, request operations.GetVerif retryConfig := o.Retries if retryConfig == nil { if globalRetryConfig == nil { - retryConfig = &utils.RetryConfig{ + retryConfig = &retry.Config{ Strategy: "backoff", - Backoff: &utils.BackoffStrategy{ + Backoff: &retry.BackoffStrategy{ InitialInterval: 50, MaxInterval: 1000, Exponent: 1.5, diff --git a/liveness.go b/liveness.go index 4e389a1..368fe05 100644 --- a/liveness.go +++ b/liveness.go @@ -12,6 +12,7 @@ import ( "github.com/unkeyed/unkey-go/models/components" "github.com/unkeyed/unkey-go/models/operations" "github.com/unkeyed/unkey-go/models/sdkerrors" + "github.com/unkeyed/unkey-go/retry" "io" "net/http" "net/url" @@ -66,9 +67,9 @@ func (s *Liveness) V1Liveness(ctx context.Context, opts ...operations.Option) (* retryConfig := o.Retries if retryConfig == nil { if globalRetryConfig == nil { - retryConfig = &utils.RetryConfig{ + retryConfig = &retry.Config{ Strategy: "backoff", - Backoff: &utils.BackoffStrategy{ + Backoff: &retry.BackoffStrategy{ InitialInterval: 50, MaxInterval: 1000, Exponent: 1.5, diff --git a/migrations.go b/migrations.go index bb795e7..180bbfd 100644 --- a/migrations.go +++ b/migrations.go @@ -12,6 +12,7 @@ import ( "github.com/unkeyed/unkey-go/models/components" "github.com/unkeyed/unkey-go/models/operations" "github.com/unkeyed/unkey-go/models/sdkerrors" + "github.com/unkeyed/unkey-go/retry" "io" "net/http" "net/url" @@ -72,9 +73,9 @@ func (s *Migrations) V1MigrationsCreateKeys(ctx context.Context, request []opera retryConfig := o.Retries if retryConfig == nil { if globalRetryConfig == nil { - retryConfig = &utils.RetryConfig{ + retryConfig = &retry.Config{ Strategy: "backoff", - Backoff: &utils.BackoffStrategy{ + Backoff: &retry.BackoffStrategy{ InitialInterval: 50, MaxInterval: 1000, Exponent: 1.5, @@ -295,9 +296,9 @@ func (s *Migrations) V1MigrationsEnqueueKeys(ctx context.Context, request operat retryConfig := o.Retries if retryConfig == nil { if globalRetryConfig == nil { - retryConfig = &utils.RetryConfig{ + retryConfig = &retry.Config{ Strategy: "backoff", - Backoff: &utils.BackoffStrategy{ + Backoff: &retry.BackoffStrategy{ InitialInterval: 50, MaxInterval: 1000, Exponent: 1.5, diff --git a/models/operations/options.go b/models/operations/options.go index 3830284..78fb08f 100644 --- a/models/operations/options.go +++ b/models/operations/options.go @@ -5,6 +5,7 @@ package operations import ( "errors" "github.com/unkeyed/unkey-go/internal/utils" + "github.com/unkeyed/unkey-go/retry" ) var ErrUnsupportedOption = errors.New("unsupported option") @@ -17,7 +18,7 @@ const ( type Options struct { ServerURL *string - Retries *utils.RetryConfig + Retries *retry.Config } type Option func(*Options, ...string) error @@ -51,7 +52,7 @@ func WithTemplatedServerURL(serverURL string, params map[string]string) Option { } // WithRetries allows customizing the default retry configuration. -func WithRetries(config utils.RetryConfig) Option { +func WithRetries(config retry.Config) Option { return func(opts *Options, supportedOptions ...string) error { if !utils.Contains(supportedOptions, SupportedOptionRetries) { return ErrUnsupportedOption diff --git a/ratelimits.go b/ratelimits.go index 1343c75..dfd9e09 100644 --- a/ratelimits.go +++ b/ratelimits.go @@ -12,6 +12,7 @@ import ( "github.com/unkeyed/unkey-go/models/components" "github.com/unkeyed/unkey-go/models/operations" "github.com/unkeyed/unkey-go/models/sdkerrors" + "github.com/unkeyed/unkey-go/retry" "io" "net/http" "net/url" @@ -72,9 +73,9 @@ func (s *Ratelimits) Limit(ctx context.Context, request operations.LimitRequestB retryConfig := o.Retries if retryConfig == nil { if globalRetryConfig == nil { - retryConfig = &utils.RetryConfig{ + retryConfig = &retry.Config{ Strategy: "backoff", - Backoff: &utils.BackoffStrategy{ + Backoff: &retry.BackoffStrategy{ InitialInterval: 50, MaxInterval: 1000, Exponent: 1.5, diff --git a/retry/config.go b/retry/config.go new file mode 100644 index 0000000..dbbd57e --- /dev/null +++ b/retry/config.go @@ -0,0 +1,16 @@ +// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + +package retry + +type BackoffStrategy struct { + InitialInterval int + MaxInterval int + Exponent float64 + MaxElapsedTime int +} + +type Config struct { + Strategy string + Backoff *BackoffStrategy + RetryConnectionErrors bool +} diff --git a/unkey.go b/unkey.go index 22d1582..e00c05c 100644 --- a/unkey.go +++ b/unkey.go @@ -12,6 +12,7 @@ import ( "github.com/unkeyed/unkey-go/models/components" "github.com/unkeyed/unkey-go/models/operations" "github.com/unkeyed/unkey-go/models/sdkerrors" + "github.com/unkeyed/unkey-go/retry" "io" "net/http" "net/url" @@ -57,7 +58,7 @@ type sdkConfiguration struct { SDKVersion string GenVersion string UserAgent string - RetryConfig *utils.RetryConfig + RetryConfig *retry.Config Hooks *hooks.Hooks } @@ -134,7 +135,7 @@ func WithSecuritySource(security func(context.Context) (components.Security, err } } -func WithRetryConfig(retryConfig utils.RetryConfig) SDKOption { +func WithRetryConfig(retryConfig retry.Config) SDKOption { return func(sdk *Unkey) { sdk.sdkConfiguration.RetryConfig = &retryConfig } @@ -146,9 +147,9 @@ func New(opts ...SDKOption) *Unkey { sdkConfiguration: sdkConfiguration{ Language: "go", OpenAPIDocVersion: "1.0.0", - SDKVersion: "0.5.0", - GenVersion: "2.356.0", - UserAgent: "speakeasy-sdk/go 0.5.0 2.356.0 1.0.0 github.com/unkeyed/unkey-go", + SDKVersion: "0.6.0", + GenVersion: "2.359.0", + UserAgent: "speakeasy-sdk/go 0.6.0 2.359.0 1.0.0 github.com/unkeyed/unkey-go", Hooks: hooks.New(), }, } @@ -226,9 +227,9 @@ func (s *Unkey) CreateAPI(ctx context.Context, request operations.CreateAPIReque retryConfig := o.Retries if retryConfig == nil { if globalRetryConfig == nil { - retryConfig = &utils.RetryConfig{ + retryConfig = &retry.Config{ Strategy: "backoff", - Backoff: &utils.BackoffStrategy{ + Backoff: &retry.BackoffStrategy{ InitialInterval: 50, MaxInterval: 1000, Exponent: 1.5, @@ -449,9 +450,9 @@ func (s *Unkey) DeleteAPI(ctx context.Context, request operations.DeleteAPIReque retryConfig := o.Retries if retryConfig == nil { if globalRetryConfig == nil { - retryConfig = &utils.RetryConfig{ + retryConfig = &retry.Config{ Strategy: "backoff", - Backoff: &utils.BackoffStrategy{ + Backoff: &retry.BackoffStrategy{ InitialInterval: 50, MaxInterval: 1000, Exponent: 1.5,