Skip to content

Commit

Permalink
feat(sdk): automated oas update (#60)
Browse files Browse the repository at this point in the history
* feat(sdk): automated oas update

* Bump .speakeasy/gen.yaml based on label

* Update provider based on openapi.yaml changes

---------

Co-authored-by: pmalek <[email protected]>
Co-authored-by: team-k8s-bot <[email protected]>
  • Loading branch information
3 people authored Jan 30, 2025
1 parent ea9a9b4 commit 08223d2
Show file tree
Hide file tree
Showing 265 changed files with 25,920 additions and 5,608 deletions.
669 changes: 666 additions & 3 deletions .speakeasy/gen.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion .speakeasy/gen.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ generation:
oAuth2ClientCredentialsEnabled: false
oAuth2PasswordEnabled: false
go:
version: 0.1.29
version: 0.2.0
additionalDependencies: {}
allowUnknownFieldsInWeakUnions: false
clientServerStatusCodesAsErrors: true
Expand Down
123 changes: 22 additions & 101 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,14 @@ Handling errors in this SDK should largely match your expectations. All operatio

By Default, an API error will return `sdkerrors.SDKError`. When custom error responses are specified for an operation, the SDK may also return their associated error. You can refer to respective *Errors* tables in SDK docs for more details on possible error types for each operation.

For example, the `ListControlPlanes` function may return the following errors:
For example, the `ListConfigurations` function may return the following errors:

| Error Type | Status Code | Content Type |
| ---------------------------- | ----------- | ------------------------ |
| sdkerrors.BadRequestError | 400 | application/problem+json |
| sdkerrors.UnauthorizedError | 401 | application/problem+json |
| sdkerrors.ForbiddenError | 403 | application/problem+json |
| sdkerrors.ServiceUnavailable | 503 | application/problem+json |
| sdkerrors.SDKError | 4XX, 5XX | \*/\* |
| Error Type | Status Code | Content Type |
| --------------------------- | ----------- | ------------------------ |
| sdkerrors.BadRequestError | 400 | application/problem+json |
| sdkerrors.UnauthorizedError | 401 | application/problem+json |
| sdkerrors.ForbiddenError | 403 | application/problem+json |
| sdkerrors.SDKError | 4XX, 5XX | \*/\* |

### Example

Expand All @@ -46,14 +45,9 @@ func main() {
}),
)

res, err := s.ControlPlanes.ListControlPlanes(ctx, operations.ListControlPlanesRequest{
res, err := s.CloudGateways.ListConfigurations(ctx, operations.ListConfigurationsRequest{
PageSize: sdkkonnectgo.Int64(10),
PageNumber: sdkkonnectgo.Int64(1),
Filter: &components.ControlPlaneFilterParameters{
CloudGateway: sdkkonnectgo.Bool(true),
},
Labels: sdkkonnectgo.String("key:value,existCheck"),
Sort: sdkkonnectgo.String("name,created_at desc"),
})
if err != nil {

Expand All @@ -75,12 +69,6 @@ func main() {
log.Fatal(e.Error())
}

var e *sdkerrors.ServiceUnavailable
if errors.As(err, &e) {
// handle error
log.Fatal(e.Error())
}

var e *sdkerrors.SDKError
if errors.As(err, &e) {
// handle error
Expand Down Expand Up @@ -114,8 +102,6 @@ package main
import (
"context"
sdkkonnectgo "github.com/Kong/sdk-konnect-go"
"github.com/Kong/sdk-konnect-go/models/components"
"github.com/Kong/sdk-konnect-go/models/operations"
"log"
)

Expand All @@ -124,24 +110,13 @@ func main() {

s := sdkkonnectgo.New(
sdkkonnectgo.WithServerIndex(3),
sdkkonnectgo.WithSecurity(components.Security{
PersonalAccessToken: sdkkonnectgo.String("<YOUR_BEARER_TOKEN_HERE>"),
}),
)

res, err := s.ControlPlanes.ListControlPlanes(ctx, operations.ListControlPlanesRequest{
PageSize: sdkkonnectgo.Int64(10),
PageNumber: sdkkonnectgo.Int64(1),
Filter: &components.ControlPlaneFilterParameters{
CloudGateway: sdkkonnectgo.Bool(true),
},
Labels: sdkkonnectgo.String("key:value,existCheck"),
Sort: sdkkonnectgo.String("name,created_at desc"),
})
res, err := s.CloudGateways.GetAvailabilityJSON(ctx)
if err != nil {
log.Fatal(err)
}
if res.ListControlPlanesResponse != nil {
if res.AvailabilityDocument != nil {
// handle response
}
}
Expand All @@ -157,8 +132,6 @@ package main
import (
"context"
sdkkonnectgo "github.com/Kong/sdk-konnect-go"
"github.com/Kong/sdk-konnect-go/models/components"
"github.com/Kong/sdk-konnect-go/models/operations"
"log"
)

Expand All @@ -167,24 +140,13 @@ func main() {

s := sdkkonnectgo.New(
sdkkonnectgo.WithServerURL("https://global.api.konghq.com"),
sdkkonnectgo.WithSecurity(components.Security{
PersonalAccessToken: sdkkonnectgo.String("<YOUR_BEARER_TOKEN_HERE>"),
}),
)

res, err := s.ControlPlanes.ListControlPlanes(ctx, operations.ListControlPlanesRequest{
PageSize: sdkkonnectgo.Int64(10),
PageNumber: sdkkonnectgo.Int64(1),
Filter: &components.ControlPlaneFilterParameters{
CloudGateway: sdkkonnectgo.Bool(true),
},
Labels: sdkkonnectgo.String("key:value,existCheck"),
Sort: sdkkonnectgo.String("name,created_at desc"),
})
res, err := s.CloudGateways.GetAvailabilityJSON(ctx)
if err != nil {
log.Fatal(err)
}
if res.ListControlPlanesResponse != nil {
if res.AvailabilityDocument != nil {
// handle response
}
}
Expand All @@ -200,25 +162,20 @@ package main
import (
"context"
sdkkonnectgo "github.com/Kong/sdk-konnect-go"
"github.com/Kong/sdk-konnect-go/models/components"
"github.com/Kong/sdk-konnect-go/models/operations"
"log"
)

func main() {
ctx := context.Background()

s := sdkkonnectgo.New(
sdkkonnectgo.WithSecurity(components.Security{
PersonalAccessToken: sdkkonnectgo.String("<YOUR_BEARER_TOKEN_HERE>"),
}),
)
s := sdkkonnectgo.New()

res, err := s.Authentication.AuthenticateSso(ctx, "<value>", nil, operations.WithServerURL("https://global.api.konghq.com/"))
res, err := s.CloudGateways.GetAvailabilityJSON(ctx, operations.WithServerURL("https://global.api.konghq.com/"))
if err != nil {
log.Fatal(err)
}
if res != nil {
if res.AvailabilityDocument != nil {
// handle response
}
}
Expand Down Expand Up @@ -276,7 +233,6 @@ import (
"context"
sdkkonnectgo "github.com/Kong/sdk-konnect-go"
"github.com/Kong/sdk-konnect-go/models/components"
"github.com/Kong/sdk-konnect-go/models/operations"
"log"
)

Expand All @@ -289,19 +245,11 @@ func main() {
}),
)

res, err := s.ControlPlanes.ListControlPlanes(ctx, operations.ListControlPlanesRequest{
PageSize: sdkkonnectgo.Int64(10),
PageNumber: sdkkonnectgo.Int64(1),
Filter: &components.ControlPlaneFilterParameters{
CloudGateway: sdkkonnectgo.Bool(true),
},
Labels: sdkkonnectgo.String("key:value,existCheck"),
Sort: sdkkonnectgo.String("name,created_at desc"),
})
res, err := s.CloudGateways.GetAvailabilityJSON(ctx)
if err != nil {
log.Fatal(err)
}
if res.ListControlPlanesResponse != nil {
if res.AvailabilityDocument != nil {
// handle response
}
}
Expand Down Expand Up @@ -341,8 +289,6 @@ package main
import (
"context"
sdkkonnectgo "github.com/Kong/sdk-konnect-go"
"github.com/Kong/sdk-konnect-go/models/components"
"github.com/Kong/sdk-konnect-go/models/operations"
"github.com/Kong/sdk-konnect-go/retry"
"log"
"models/operations"
Expand All @@ -351,21 +297,9 @@ import (
func main() {
ctx := context.Background()

s := sdkkonnectgo.New(
sdkkonnectgo.WithSecurity(components.Security{
PersonalAccessToken: sdkkonnectgo.String("<YOUR_BEARER_TOKEN_HERE>"),
}),
)
s := sdkkonnectgo.New()

res, err := s.ControlPlanes.ListControlPlanes(ctx, operations.ListControlPlanesRequest{
PageSize: sdkkonnectgo.Int64(10),
PageNumber: sdkkonnectgo.Int64(1),
Filter: &components.ControlPlaneFilterParameters{
CloudGateway: sdkkonnectgo.Bool(true),
},
Labels: sdkkonnectgo.String("key:value,existCheck"),
Sort: sdkkonnectgo.String("name,created_at desc"),
}, operations.WithRetries(
res, err := s.CloudGateways.GetAvailabilityJSON(ctx, operations.WithRetries(
retry.Config{
Strategy: "backoff",
Backoff: &retry.BackoffStrategy{
Expand All @@ -379,7 +313,7 @@ func main() {
if err != nil {
log.Fatal(err)
}
if res.ListControlPlanesResponse != nil {
if res.AvailabilityDocument != nil {
// handle response
}
}
Expand All @@ -393,8 +327,6 @@ package main
import (
"context"
sdkkonnectgo "github.com/Kong/sdk-konnect-go"
"github.com/Kong/sdk-konnect-go/models/components"
"github.com/Kong/sdk-konnect-go/models/operations"
"github.com/Kong/sdk-konnect-go/retry"
"log"
)
Expand All @@ -414,24 +346,13 @@ func main() {
},
RetryConnectionErrors: false,
}),
sdkkonnectgo.WithSecurity(components.Security{
PersonalAccessToken: sdkkonnectgo.String("<YOUR_BEARER_TOKEN_HERE>"),
}),
)

res, err := s.ControlPlanes.ListControlPlanes(ctx, operations.ListControlPlanesRequest{
PageSize: sdkkonnectgo.Int64(10),
PageNumber: sdkkonnectgo.Int64(1),
Filter: &components.ControlPlaneFilterParameters{
CloudGateway: sdkkonnectgo.Bool(true),
},
Labels: sdkkonnectgo.String("key:value,existCheck"),
Sort: sdkkonnectgo.String("name,created_at desc"),
})
res, err := s.CloudGateways.GetAvailabilityJSON(ctx)
if err != nil {
log.Fatal(err)
}
if res.ListControlPlanesResponse != nil {
if res.AvailabilityDocument != nil {
// handle response
}
}
Expand Down
20 changes: 3 additions & 17 deletions USAGE.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,33 +5,19 @@ package main
import (
"context"
sdkkonnectgo "github.com/Kong/sdk-konnect-go"
"github.com/Kong/sdk-konnect-go/models/components"
"github.com/Kong/sdk-konnect-go/models/operations"
"log"
)

func main() {
ctx := context.Background()

s := sdkkonnectgo.New(
sdkkonnectgo.WithSecurity(components.Security{
PersonalAccessToken: sdkkonnectgo.String("<YOUR_BEARER_TOKEN_HERE>"),
}),
)
s := sdkkonnectgo.New()

res, err := s.ControlPlanes.ListControlPlanes(ctx, operations.ListControlPlanesRequest{
PageSize: sdkkonnectgo.Int64(10),
PageNumber: sdkkonnectgo.Int64(1),
Filter: &components.ControlPlaneFilterParameters{
CloudGateway: sdkkonnectgo.Bool(true),
},
Labels: sdkkonnectgo.String("key:value,existCheck"),
Sort: sdkkonnectgo.String("name,created_at desc"),
})
res, err := s.CloudGateways.GetAvailabilityJSON(ctx)
if err != nil {
log.Fatal(err)
}
if res.ListControlPlanesResponse != nil {
if res.AvailabilityDocument != nil {
// handle response
}
}
Expand Down
Loading

0 comments on commit 08223d2

Please sign in to comment.