Skip to content

Commit

Permalink
feat(api): OpenAPI spec update via Stainless API (#1810)
Browse files Browse the repository at this point in the history
  • Loading branch information
stainless-app[bot] committed Apr 24, 2024
1 parent cd8df2d commit 69ef87c
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 8 deletions.
2 changes: 1 addition & 1 deletion api.md
Original file line number Diff line number Diff line change
Expand Up @@ -1851,7 +1851,7 @@ Methods:

- <code title="post /zones/{zone_id}/healthchecks">client.Healthchecks.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/healthchecks#HealthcheckService.New">New</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, params <a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/healthchecks">healthchecks</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/healthchecks#HealthcheckNewParams">HealthcheckNewParams</a>) (<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/healthchecks">healthchecks</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/healthchecks#Healthcheck">Healthcheck</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code>
- <code title="put /zones/{zone_id}/healthchecks/{healthcheck_id}">client.Healthchecks.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/healthchecks#HealthcheckService.Update">Update</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, healthcheckID <a href="https://pkg.go.dev/builtin#string">string</a>, params <a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/healthchecks">healthchecks</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/healthchecks#HealthcheckUpdateParams">HealthcheckUpdateParams</a>) (<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/healthchecks">healthchecks</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/healthchecks#Healthcheck">Healthcheck</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code>
- <code title="get /zones/{zone_id}/healthchecks">client.Healthchecks.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/healthchecks#HealthcheckService.List">List</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, query <a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/healthchecks">healthchecks</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/healthchecks#HealthcheckListParams">HealthcheckListParams</a>) (<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/internal/pagination">pagination</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/internal/pagination#SinglePage">SinglePage</a>[<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/healthchecks">healthchecks</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/healthchecks#Healthcheck">Healthcheck</a>], <a href="https://pkg.go.dev/builtin#error">error</a>)</code>
- <code title="get /zones/{zone_id}/healthchecks">client.Healthchecks.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/healthchecks#HealthcheckService.List">List</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, params <a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/healthchecks">healthchecks</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/healthchecks#HealthcheckListParams">HealthcheckListParams</a>) (<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/internal/pagination">pagination</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/internal/pagination#SinglePage">SinglePage</a>[<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/healthchecks">healthchecks</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/healthchecks#Healthcheck">Healthcheck</a>], <a href="https://pkg.go.dev/builtin#error">error</a>)</code>
- <code title="delete /zones/{zone_id}/healthchecks/{healthcheck_id}">client.Healthchecks.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/healthchecks#HealthcheckService.Delete">Delete</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, healthcheckID <a href="https://pkg.go.dev/builtin#string">string</a>, params <a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/healthchecks">healthchecks</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/healthchecks#HealthcheckDeleteParams">HealthcheckDeleteParams</a>) (<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/healthchecks">healthchecks</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/healthchecks#HealthcheckDeleteResponse">HealthcheckDeleteResponse</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code>
- <code title="patch /zones/{zone_id}/healthchecks/{healthcheck_id}">client.Healthchecks.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/healthchecks#HealthcheckService.Edit">Edit</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, healthcheckID <a href="https://pkg.go.dev/builtin#string">string</a>, params <a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/healthchecks">healthchecks</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/healthchecks#HealthcheckEditParams">HealthcheckEditParams</a>) (<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/healthchecks">healthchecks</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/healthchecks#Healthcheck">Healthcheck</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code>
- <code title="get /zones/{zone_id}/healthchecks/{healthcheck_id}">client.Healthchecks.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/healthchecks#HealthcheckService.Get">Get</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, healthcheckID <a href="https://pkg.go.dev/builtin#string">string</a>, query <a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/healthchecks">healthchecks</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/healthchecks#HealthcheckGetParams">HealthcheckGetParams</a>) (<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/healthchecks">healthchecks</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/healthchecks#Healthcheck">Healthcheck</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code>
Expand Down
24 changes: 19 additions & 5 deletions healthchecks/healthcheck.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@ import (
"context"
"fmt"
"net/http"
"net/url"
"time"

"github.com/cloudflare/cloudflare-go/v2/internal/apijson"
"github.com/cloudflare/cloudflare-go/v2/internal/apiquery"
"github.com/cloudflare/cloudflare-go/v2/internal/pagination"
"github.com/cloudflare/cloudflare-go/v2/internal/param"
"github.com/cloudflare/cloudflare-go/v2/internal/requestconfig"
Expand Down Expand Up @@ -63,12 +65,12 @@ func (r *HealthcheckService) Update(ctx context.Context, healthcheckID string, p
}

// List configured health checks.
func (r *HealthcheckService) List(ctx context.Context, query HealthcheckListParams, opts ...option.RequestOption) (res *pagination.SinglePage[Healthcheck], err error) {
func (r *HealthcheckService) List(ctx context.Context, params HealthcheckListParams, opts ...option.RequestOption) (res *pagination.SinglePage[Healthcheck], err error) {
var raw *http.Response
opts = append(r.Options, opts...)
opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...)
path := fmt.Sprintf("zones/%s/healthchecks", query.ZoneID)
cfg, err := requestconfig.NewRequestConfig(ctx, http.MethodGet, path, query, &res, opts...)
path := fmt.Sprintf("zones/%s/healthchecks", params.ZoneID)
cfg, err := requestconfig.NewRequestConfig(ctx, http.MethodGet, path, params, &res, opts...)
if err != nil {
return nil, err
}
Expand All @@ -81,8 +83,8 @@ func (r *HealthcheckService) List(ctx context.Context, query HealthcheckListPara
}

// List configured health checks.
func (r *HealthcheckService) ListAutoPaging(ctx context.Context, query HealthcheckListParams, opts ...option.RequestOption) *pagination.SinglePageAutoPager[Healthcheck] {
return pagination.NewSinglePageAutoPager(r.List(ctx, query, opts...))
func (r *HealthcheckService) ListAutoPaging(ctx context.Context, params HealthcheckListParams, opts ...option.RequestOption) *pagination.SinglePageAutoPager[Healthcheck] {
return pagination.NewSinglePageAutoPager(r.List(ctx, params, opts...))
}

// Delete a health check.
Expand Down Expand Up @@ -569,6 +571,18 @@ func (r HealthcheckUpdateResponseEnvelopeSuccess) IsKnown() bool {
type HealthcheckListParams struct {
// Identifier
ZoneID param.Field[string] `path:"zone_id,required"`
// Page number of paginated results.
Page param.Field[interface{}] `query:"page"`
// Maximum number of results per page. Must be a multiple of 5.
PerPage param.Field[interface{}] `query:"per_page"`
}

// URLQuery serializes [HealthcheckListParams]'s query parameters as `url.Values`.
func (r HealthcheckListParams) URLQuery() (v url.Values) {
return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{
ArrayFormat: apiquery.ArrayQueryFormatRepeat,
NestedFormat: apiquery.NestedQueryFormatBrackets,
})
}

type HealthcheckDeleteParams struct {
Expand Down
6 changes: 4 additions & 2 deletions healthchecks/healthcheck_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ func TestHealthcheckUpdateWithOptionalParams(t *testing.T) {
}
}

func TestHealthcheckList(t *testing.T) {
func TestHealthcheckListWithOptionalParams(t *testing.T) {
t.Skip("skipped: tests are disabled for the time being")
baseURL := "http://localhost:4010"
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
Expand All @@ -153,7 +153,9 @@ func TestHealthcheckList(t *testing.T) {
option.WithAPIEmail("[email protected]"),
)
_, err := client.Healthchecks.List(context.TODO(), healthchecks.HealthcheckListParams{
ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"),
ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"),
Page: cloudflare.F[any](map[string]interface{}{}),
PerPage: cloudflare.F[any](map[string]interface{}{}),
})
if err != nil {
var apierr *cloudflare.Error
Expand Down

0 comments on commit 69ef87c

Please sign in to comment.