Skip to content

Commit

Permalink
feat(api): OpenAPI spec update via Stainless API (#2035)
Browse files Browse the repository at this point in the history
  • Loading branch information
stainless-app[bot] authored and stainless-bot committed May 16, 2024
1 parent f60e29a commit 1ca623b
Show file tree
Hide file tree
Showing 8 changed files with 159 additions and 264 deletions.
2 changes: 1 addition & 1 deletion .stats.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
configured_endpoints: 1286
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-e0c654af9fa84e81609b00c616ca5bbdcd5dc66ac4e5b2c185cc167ee6569d00.yml
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-8ed1feaaa675343ade60163c51b1b39494c9bff519d1b15fa00c5ec0fe182abf.yml
28 changes: 15 additions & 13 deletions ai_gateway/log.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,19 +49,20 @@ func (r *LogService) Get(ctx context.Context, id string, params LogGetParams, op
}

type LogGetResponse struct {
ID string `json:"id,required" format:"uuid"`
Cached bool `json:"cached,required"`
CreatedAt time.Time `json:"created_at,required" format:"date-time"`
Duration int64 `json:"duration,required"`
Model string `json:"model,required"`
Path string `json:"path,required"`
Provider string `json:"provider,required"`
Request string `json:"request,required"`
Response string `json:"response,required"`
Success bool `json:"success,required"`
TokensIn int64 `json:"tokens_in,required"`
TokensOut int64 `json:"tokens_out,required"`
JSON logGetResponseJSON `json:"-"`
ID string `json:"id,required" format:"uuid"`
Cached bool `json:"cached,required"`
CreatedAt time.Time `json:"created_at,required" format:"date-time"`
Duration int64 `json:"duration,required"`
Model string `json:"model,required"`
Path string `json:"path,required"`
Provider string `json:"provider,required"`
Request string `json:"request,required"`
Response string `json:"response,required"`
Success bool `json:"success,required"`
TokensIn int64 `json:"tokens_in,required"`
TokensOut int64 `json:"tokens_out,required"`
StatusCode int64 `json:"status_code"`
JSON logGetResponseJSON `json:"-"`
}

// logGetResponseJSON contains the JSON metadata for the struct [LogGetResponse]
Expand All @@ -78,6 +79,7 @@ type logGetResponseJSON struct {
Success apijson.Field
TokensIn apijson.Field
TokensOut apijson.Field
StatusCode apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
Expand Down
12 changes: 6 additions & 6 deletions api.md

Large diffs are not rendered by default.

132 changes: 49 additions & 83 deletions cloudforce_one/request.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"context"
"fmt"
"net/http"
"reflect"
"time"

"github.com/cloudflare/cloudflare-go/v2/internal/apijson"
Expand All @@ -15,7 +14,6 @@ import (
"github.com/cloudflare/cloudflare-go/v2/internal/requestconfig"
"github.com/cloudflare/cloudflare-go/v2/option"
"github.com/cloudflare/cloudflare-go/v2/shared"
"github.com/tidwall/gjson"
)

// RequestService contains methods and other services that help with interacting
Expand Down Expand Up @@ -95,15 +93,10 @@ func (r *RequestService) ListAutoPaging(ctx context.Context, accountIdentifier s
}

// Delete a Request
func (r *RequestService) Delete(ctx context.Context, accountIdentifier string, requestIdentifier string, opts ...option.RequestOption) (res *RequestDeleteResponseUnion, err error) {
func (r *RequestService) Delete(ctx context.Context, accountIdentifier string, requestIdentifier string, opts ...option.RequestOption) (res *RequestDeleteResponse, err error) {
opts = append(r.Options[:], opts...)
var env RequestDeleteResponseEnvelope
path := fmt.Sprintf("accounts/%s/cloudforce-one/requests/%s", accountIdentifier, requestIdentifier)
err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &env, opts...)
if err != nil {
return
}
res = &env.Result
err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &res, opts...)
return
}

Expand Down Expand Up @@ -471,30 +464,46 @@ func (r RequestConstantsTlp) IsKnown() bool {

type RequestTypes []string

// Union satisfied by [cloudforce_one.RequestDeleteResponseUnknown],
// [cloudforce_one.RequestDeleteResponseArray] or [shared.UnionString].
type RequestDeleteResponseUnion interface {
ImplementsCloudforceOneRequestDeleteResponseUnion()
type RequestDeleteResponse struct {
Errors []shared.ResponseInfo `json:"errors,required"`
Messages []shared.ResponseInfo `json:"messages,required"`
// Whether the API call was successful
Success RequestDeleteResponseSuccess `json:"success,required"`
JSON requestDeleteResponseJSON `json:"-"`
}

// requestDeleteResponseJSON contains the JSON metadata for the struct
// [RequestDeleteResponse]
type requestDeleteResponseJSON struct {
Errors apijson.Field
Messages apijson.Field
Success apijson.Field
raw string
ExtraFields map[string]apijson.Field
}

func (r *RequestDeleteResponse) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}

func init() {
apijson.RegisterUnion(
reflect.TypeOf((*RequestDeleteResponseUnion)(nil)).Elem(),
"",
apijson.UnionVariant{
TypeFilter: gjson.JSON,
Type: reflect.TypeOf(RequestDeleteResponseArray{}),
},
apijson.UnionVariant{
TypeFilter: gjson.String,
Type: reflect.TypeOf(shared.UnionString("")),
},
)
func (r requestDeleteResponseJSON) RawJSON() string {
return r.raw
}

type RequestDeleteResponseArray []interface{}
// Whether the API call was successful
type RequestDeleteResponseSuccess bool

func (r RequestDeleteResponseArray) ImplementsCloudforceOneRequestDeleteResponseUnion() {}
const (
RequestDeleteResponseSuccessTrue RequestDeleteResponseSuccess = true
)

func (r RequestDeleteResponseSuccess) IsKnown() bool {
switch r {
case RequestDeleteResponseSuccessTrue:
return true
}
return false
}

type RequestNewParams struct {
// Request content
Expand Down Expand Up @@ -535,9 +544,9 @@ func (r RequestNewParamsTlp) IsKnown() bool {
type RequestNewResponseEnvelope struct {
Errors []shared.ResponseInfo `json:"errors,required"`
Messages []shared.ResponseInfo `json:"messages,required"`
Result Item `json:"result,required"`
// Whether the API call was successful
Success RequestNewResponseEnvelopeSuccess `json:"success,required"`
Result Item `json:"result"`
JSON requestNewResponseEnvelopeJSON `json:"-"`
}

Expand All @@ -546,8 +555,8 @@ type RequestNewResponseEnvelope struct {
type requestNewResponseEnvelopeJSON struct {
Errors apijson.Field
Messages apijson.Field
Result apijson.Field
Success apijson.Field
Result apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
Expand Down Expand Up @@ -614,9 +623,9 @@ func (r RequestUpdateParamsTlp) IsKnown() bool {
type RequestUpdateResponseEnvelope struct {
Errors []shared.ResponseInfo `json:"errors,required"`
Messages []shared.ResponseInfo `json:"messages,required"`
Result Item `json:"result,required"`
// Whether the API call was successful
Success RequestUpdateResponseEnvelopeSuccess `json:"success,required"`
Result Item `json:"result"`
JSON requestUpdateResponseEnvelopeJSON `json:"-"`
}

Expand All @@ -625,8 +634,8 @@ type RequestUpdateResponseEnvelope struct {
type requestUpdateResponseEnvelopeJSON struct {
Errors apijson.Field
Messages apijson.Field
Result apijson.Field
Success apijson.Field
Result apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
Expand Down Expand Up @@ -717,55 +726,12 @@ func (r RequestListParamsStatus) IsKnown() bool {
return false
}

type RequestDeleteResponseEnvelope struct {
Errors []shared.ResponseInfo `json:"errors,required"`
Messages []shared.ResponseInfo `json:"messages,required"`
Result RequestDeleteResponseUnion `json:"result,required"`
// Whether the API call was successful
Success RequestDeleteResponseEnvelopeSuccess `json:"success,required"`
JSON requestDeleteResponseEnvelopeJSON `json:"-"`
}

// requestDeleteResponseEnvelopeJSON contains the JSON metadata for the struct
// [RequestDeleteResponseEnvelope]
type requestDeleteResponseEnvelopeJSON struct {
Errors apijson.Field
Messages apijson.Field
Result apijson.Field
Success apijson.Field
raw string
ExtraFields map[string]apijson.Field
}

func (r *RequestDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}

func (r requestDeleteResponseEnvelopeJSON) RawJSON() string {
return r.raw
}

// Whether the API call was successful
type RequestDeleteResponseEnvelopeSuccess bool

const (
RequestDeleteResponseEnvelopeSuccessTrue RequestDeleteResponseEnvelopeSuccess = true
)

func (r RequestDeleteResponseEnvelopeSuccess) IsKnown() bool {
switch r {
case RequestDeleteResponseEnvelopeSuccessTrue:
return true
}
return false
}

type RequestConstantsResponseEnvelope struct {
Errors []shared.ResponseInfo `json:"errors,required"`
Messages []shared.ResponseInfo `json:"messages,required"`
Result RequestConstants `json:"result,required"`
// Whether the API call was successful
Success RequestConstantsResponseEnvelopeSuccess `json:"success,required"`
Result RequestConstants `json:"result"`
JSON requestConstantsResponseEnvelopeJSON `json:"-"`
}

Expand All @@ -774,8 +740,8 @@ type RequestConstantsResponseEnvelope struct {
type requestConstantsResponseEnvelopeJSON struct {
Errors apijson.Field
Messages apijson.Field
Result apijson.Field
Success apijson.Field
Result apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
Expand Down Expand Up @@ -806,9 +772,9 @@ func (r RequestConstantsResponseEnvelopeSuccess) IsKnown() bool {
type RequestGetResponseEnvelope struct {
Errors []shared.ResponseInfo `json:"errors,required"`
Messages []shared.ResponseInfo `json:"messages,required"`
Result Item `json:"result,required"`
// Whether the API call was successful
Success RequestGetResponseEnvelopeSuccess `json:"success,required"`
Result Item `json:"result"`
JSON requestGetResponseEnvelopeJSON `json:"-"`
}

Expand All @@ -817,8 +783,8 @@ type RequestGetResponseEnvelope struct {
type requestGetResponseEnvelopeJSON struct {
Errors apijson.Field
Messages apijson.Field
Result apijson.Field
Success apijson.Field
Result apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
Expand Down Expand Up @@ -849,9 +815,9 @@ func (r RequestGetResponseEnvelopeSuccess) IsKnown() bool {
type RequestQuotaResponseEnvelope struct {
Errors []shared.ResponseInfo `json:"errors,required"`
Messages []shared.ResponseInfo `json:"messages,required"`
Result Quota `json:"result,required"`
// Whether the API call was successful
Success RequestQuotaResponseEnvelopeSuccess `json:"success,required"`
Result Quota `json:"result"`
JSON requestQuotaResponseEnvelopeJSON `json:"-"`
}

Expand All @@ -860,8 +826,8 @@ type RequestQuotaResponseEnvelope struct {
type requestQuotaResponseEnvelopeJSON struct {
Errors apijson.Field
Messages apijson.Field
Result apijson.Field
Success apijson.Field
Result apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
Expand Down Expand Up @@ -892,9 +858,9 @@ func (r RequestQuotaResponseEnvelopeSuccess) IsKnown() bool {
type RequestTypesResponseEnvelope struct {
Errors []shared.ResponseInfo `json:"errors,required"`
Messages []shared.ResponseInfo `json:"messages,required"`
Result RequestTypes `json:"result,required"`
// Whether the API call was successful
Success RequestTypesResponseEnvelopeSuccess `json:"success,required"`
Result RequestTypes `json:"result"`
JSON requestTypesResponseEnvelopeJSON `json:"-"`
}

Expand All @@ -903,8 +869,8 @@ type RequestTypesResponseEnvelope struct {
type requestTypesResponseEnvelopeJSON struct {
Errors apijson.Field
Messages apijson.Field
Result apijson.Field
Success apijson.Field
Result apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
Expand Down

0 comments on commit 1ca623b

Please sign in to comment.