Skip to content

Commit

Permalink
feat(api): api update (#3612)
Browse files Browse the repository at this point in the history
  • Loading branch information
stainless-app[bot] authored and stainless-bot committed Nov 15, 2024
1 parent b8814b0 commit 708c85a
Show file tree
Hide file tree
Showing 9 changed files with 154 additions and 228 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: 1381
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare/cloudflare-34e58184c8582fbfa6e469d190a541a701067980fa9d9158ed1ffc1eed88d681.yml
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare/cloudflare-d6dc39cc9dc12992f205f2436d49fb9c8b2e58090dfbbfbeec2d431ab75349a7.yml
2 changes: 0 additions & 2 deletions ai_gateway/aigateway.go
Original file line number Diff line number Diff line change
Expand Up @@ -549,8 549,6 @@ func (r aiGatewayUpdateResponseEnvelopeJSON) RawJSON() string {

type AIGatewayListParams struct {
AccountID param.Field[string] `path:"account_id,required"`
// gateway id
ID param.Field[string] `query:"id"`
// Order By Column Name
OrderBy param.Field[string] `query:"order_by"`
// Order By Direction
Expand Down
5 changes: 2 additions & 3 deletions ai_gateway/aigateway_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 100,10 @@ func TestAIGatewayListWithOptionalParams(t *testing.T) {
)
_, err := client.AIGateway.List(context.TODO(), ai_gateway.AIGatewayListParams{
AccountID: cloudflare.F("3ebbcb006d4d46d7bb6a8c7f14676cb0"),
ID: cloudflare.F("my-gateway"),
OrderBy: cloudflare.F("order_by"),
OrderByDirection: cloudflare.F(ai_gateway.AIGatewayListParamsOrderByDirectionAsc),
Page: cloudflare.F(int64(1)),
PerPage: cloudflare.F(int64(5)),
PerPage: cloudflare.F(int64(1)),
})
if err != nil {
var apierr *cloudflare.Error
Expand All @@ -130,7 129,7 @@ func TestAIGatewayDelete(t *testing.T) {
)
_, err := client.AIGateway.Delete(
context.TODO(),
"id",
"my-gateway",
ai_gateway.AIGatewayDeleteParams{
AccountID: cloudflare.F("3ebbcb006d4d46d7bb6a8c7f14676cb0"),
},
Expand Down
156 changes: 48 additions & 108 deletions ai_gateway/dataset.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,14 168,15 @@ func (r *DatasetService) Get(ctx context.Context, gatewayID string, id string, q
}

type DatasetNewResponse struct {
ID string `json:"id,required"`
CreatedAt time.Time `json:"created_at,required" format:"date-time"`
Enable bool `json:"enable,required"`
Filters []DatasetNewResponseFilter `json:"filters,required"`
GatewayID string `json:"gateway_id,required"`
ModifiedAt time.Time `json:"modified_at,required" format:"date-time"`
Name string `json:"name,required"`
JSON datasetNewResponseJSON `json:"-"`
ID string `json:"id,required"`
CreatedAt time.Time `json:"created_at,required" format:"date-time"`
Enable bool `json:"enable,required"`
Filters []DatasetNewResponseFilter `json:"filters,required"`
// gateway id
GatewayID string `json:"gateway_id,required"`
ModifiedAt time.Time `json:"modified_at,required" format:"date-time"`
Name string `json:"name,required"`
JSON datasetNewResponseJSON `json:"-"`
}

// datasetNewResponseJSON contains the JSON metadata for the struct
Expand Down Expand Up @@ -298,14 299,15 @@ func init() {
}

type DatasetUpdateResponse struct {
ID string `json:"id,required"`
CreatedAt time.Time `json:"created_at,required" format:"date-time"`
Enable bool `json:"enable,required"`
Filters []DatasetUpdateResponseFilter `json:"filters,required"`
GatewayID string `json:"gateway_id,required"`
ModifiedAt time.Time `json:"modified_at,required" format:"date-time"`
Name string `json:"name,required"`
JSON datasetUpdateResponseJSON `json:"-"`
ID string `json:"id,required"`
CreatedAt time.Time `json:"created_at,required" format:"date-time"`
Enable bool `json:"enable,required"`
Filters []DatasetUpdateResponseFilter `json:"filters,required"`
// gateway id
GatewayID string `json:"gateway_id,required"`
ModifiedAt time.Time `json:"modified_at,required" format:"date-time"`
Name string `json:"name,required"`
JSON datasetUpdateResponseJSON `json:"-"`
}

// datasetUpdateResponseJSON contains the JSON metadata for the struct
Expand Down Expand Up @@ -428,14 430,15 @@ func init() {
}

type DatasetListResponse struct {
ID string `json:"id,required"`
CreatedAt time.Time `json:"created_at,required" format:"date-time"`
Enable bool `json:"enable,required"`
Filters []DatasetListResponseFilter `json:"filters,required"`
GatewayID string `json:"gateway_id,required"`
ModifiedAt time.Time `json:"modified_at,required" format:"date-time"`
Name string `json:"name,required"`
JSON datasetListResponseJSON `json:"-"`
ID string `json:"id,required"`
CreatedAt time.Time `json:"created_at,required" format:"date-time"`
Enable bool `json:"enable,required"`
Filters []DatasetListResponseFilter `json:"filters,required"`
// gateway id
GatewayID string `json:"gateway_id,required"`
ModifiedAt time.Time `json:"modified_at,required" format:"date-time"`
Name string `json:"name,required"`
JSON datasetListResponseJSON `json:"-"`
}

// datasetListResponseJSON contains the JSON metadata for the struct
Expand Down Expand Up @@ -558,14 561,15 @@ func init() {
}

type DatasetDeleteResponse struct {
ID string `json:"id,required"`
CreatedAt time.Time `json:"created_at,required" format:"date-time"`
Enable bool `json:"enable,required"`
Filters []DatasetDeleteResponseFilter `json:"filters,required"`
GatewayID string `json:"gateway_id,required"`
ModifiedAt time.Time `json:"modified_at,required" format:"date-time"`
Name string `json:"name,required"`
JSON datasetDeleteResponseJSON `json:"-"`
ID string `json:"id,required"`
CreatedAt time.Time `json:"created_at,required" format:"date-time"`
Enable bool `json:"enable,required"`
Filters []DatasetDeleteResponseFilter `json:"filters,required"`
// gateway id
GatewayID string `json:"gateway_id,required"`
ModifiedAt time.Time `json:"modified_at,required" format:"date-time"`
Name string `json:"name,required"`
JSON datasetDeleteResponseJSON `json:"-"`
}

// datasetDeleteResponseJSON contains the JSON metadata for the struct
Expand Down Expand Up @@ -688,14 692,15 @@ func init() {
}

type DatasetGetResponse struct {
ID string `json:"id,required"`
CreatedAt time.Time `json:"created_at,required" format:"date-time"`
Enable bool `json:"enable,required"`
Filters []DatasetGetResponseFilter `json:"filters,required"`
GatewayID string `json:"gateway_id,required"`
ModifiedAt time.Time `json:"modified_at,required" format:"date-time"`
Name string `json:"name,required"`
JSON datasetGetResponseJSON `json:"-"`
ID string `json:"id,required"`
CreatedAt time.Time `json:"created_at,required" format:"date-time"`
Enable bool `json:"enable,required"`
Filters []DatasetGetResponseFilter `json:"filters,required"`
// gateway id
GatewayID string `json:"gateway_id,required"`
ModifiedAt time.Time `json:"modified_at,required" format:"date-time"`
Name string `json:"name,required"`
JSON datasetGetResponseJSON `json:"-"`
}

// datasetGetResponseJSON contains the JSON metadata for the struct
Expand Down Expand Up @@ -1002,11 1007,9 @@ func (r datasetUpdateResponseEnvelopeJSON) RawJSON() string {
}

type DatasetListParams struct {
AccountID param.Field[string] `path:"account_id,required"`
ID param.Field[string] `query:"id"`
Enable param.Field[bool] `query:"enable"`
Filters param.Field[[]DatasetListParamsFilter] `query:"filters"`
Name param.Field[string] `query:"name"`
AccountID param.Field[string] `path:"account_id,required"`
Enable param.Field[bool] `query:"enable"`
Name param.Field[string] `query:"name"`
// Order By Column Name
OrderBy param.Field[string] `query:"order_by"`
// Order By Direction
Expand All @@ -1025,69 1028,6 @@ func (r DatasetListParams) URLQuery() (v url.Values) {
})
}

type DatasetListParamsFilter struct {
Key param.Field[DatasetListParamsFiltersKey] `query:"key,required"`
Operator param.Field[DatasetListParamsFiltersOperator] `query:"operator,required"`
Value param.Field[[]DatasetListParamsFiltersValueUnion] `query:"value,required"`
}

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

type DatasetListParamsFiltersKey string

const (
DatasetListParamsFiltersKeyCreatedAt DatasetListParamsFiltersKey = "created_at"
DatasetListParamsFiltersKeyRequestContentType DatasetListParamsFiltersKey = "request_content_type"
DatasetListParamsFiltersKeyResponseContentType DatasetListParamsFiltersKey = "response_content_type"
DatasetListParamsFiltersKeySuccess DatasetListParamsFiltersKey = "success"
DatasetListParamsFiltersKeyCached DatasetListParamsFiltersKey = "cached"
DatasetListParamsFiltersKeyProvider DatasetListParamsFiltersKey = "provider"
DatasetListParamsFiltersKeyModel DatasetListParamsFiltersKey = "model"
DatasetListParamsFiltersKeyCost DatasetListParamsFiltersKey = "cost"
DatasetListParamsFiltersKeyTokens DatasetListParamsFiltersKey = "tokens"
DatasetListParamsFiltersKeyTokensIn DatasetListParamsFiltersKey = "tokens_in"
DatasetListParamsFiltersKeyTokensOut DatasetListParamsFiltersKey = "tokens_out"
DatasetListParamsFiltersKeyDuration DatasetListParamsFiltersKey = "duration"
DatasetListParamsFiltersKeyFeedback DatasetListParamsFiltersKey = "feedback"
)

func (r DatasetListParamsFiltersKey) IsKnown() bool {
switch r {
case DatasetListParamsFiltersKeyCreatedAt, DatasetListParamsFiltersKeyRequestContentType, DatasetListParamsFiltersKeyResponseContentType, DatasetListParamsFiltersKeySuccess, DatasetListParamsFiltersKeyCached, DatasetListParamsFiltersKeyProvider, DatasetListParamsFiltersKeyModel, DatasetListParamsFiltersKeyCost, DatasetListParamsFiltersKeyTokens, DatasetListParamsFiltersKeyTokensIn, DatasetListParamsFiltersKeyTokensOut, DatasetListParamsFiltersKeyDuration, DatasetListParamsFiltersKeyFeedback:
return true
}
return false
}

type DatasetListParamsFiltersOperator string

const (
DatasetListParamsFiltersOperatorEq DatasetListParamsFiltersOperator = "eq"
DatasetListParamsFiltersOperatorContains DatasetListParamsFiltersOperator = "contains"
DatasetListParamsFiltersOperatorLt DatasetListParamsFiltersOperator = "lt"
DatasetListParamsFiltersOperatorGt DatasetListParamsFiltersOperator = "gt"
)

func (r DatasetListParamsFiltersOperator) IsKnown() bool {
switch r {
case DatasetListParamsFiltersOperatorEq, DatasetListParamsFiltersOperatorContains, DatasetListParamsFiltersOperatorLt, DatasetListParamsFiltersOperatorGt:
return true
}
return false
}

// Satisfied by [shared.UnionString], [shared.UnionFloat], [shared.UnionBool].
type DatasetListParamsFiltersValueUnion interface {
ImplementsAIGatewayDatasetListParamsFiltersValueUnion()
}

// Order By Direction
type DatasetListParamsOrderByDirection string

Expand Down
30 changes: 8 additions & 22 deletions ai_gateway/dataset_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 30,7 @@ func TestDatasetNew(t *testing.T) {
)
_, err := client.AIGateway.Datasets.New(
context.TODO(),
"gateway_id",
"my-gateway",
ai_gateway.DatasetNewParams{
AccountID: cloudflare.F("3ebbcb006d4d46d7bb6a8c7f14676cb0"),
Enable: cloudflare.F(true),
Expand Down Expand Up @@ -74,7 74,7 @@ func TestDatasetUpdate(t *testing.T) {
)
_, err := client.AIGateway.Datasets.Update(
context.TODO(),
"gateway_id",
"my-gateway",
"id",
ai_gateway.DatasetUpdateParams{
AccountID: cloudflare.F("3ebbcb006d4d46d7bb6a8c7f14676cb0"),
Expand Down Expand Up @@ -119,29 119,15 @@ func TestDatasetListWithOptionalParams(t *testing.T) {
)
_, err := client.AIGateway.Datasets.List(
context.TODO(),
"gateway_id",
"my-gateway",
ai_gateway.DatasetListParams{
AccountID: cloudflare.F("3ebbcb006d4d46d7bb6a8c7f14676cb0"),
ID: cloudflare.F("id"),
Enable: cloudflare.F(true),
Filters: cloudflare.F([]ai_gateway.DatasetListParamsFilter{{
Key: cloudflare.F(ai_gateway.DatasetListParamsFiltersKeyCreatedAt),
Operator: cloudflare.F(ai_gateway.DatasetListParamsFiltersOperatorEq),
Value: cloudflare.F([]ai_gateway.DatasetListParamsFiltersValueUnion{shared.UnionString("string"), shared.UnionString("string"), shared.UnionString("string")}),
}, {
Key: cloudflare.F(ai_gateway.DatasetListParamsFiltersKeyCreatedAt),
Operator: cloudflare.F(ai_gateway.DatasetListParamsFiltersOperatorEq),
Value: cloudflare.F([]ai_gateway.DatasetListParamsFiltersValueUnion{shared.UnionString("string"), shared.UnionString("string"), shared.UnionString("string")}),
}, {
Key: cloudflare.F(ai_gateway.DatasetListParamsFiltersKeyCreatedAt),
Operator: cloudflare.F(ai_gateway.DatasetListParamsFiltersOperatorEq),
Value: cloudflare.F([]ai_gateway.DatasetListParamsFiltersValueUnion{shared.UnionString("string"), shared.UnionString("string"), shared.UnionString("string")}),
}}),
AccountID: cloudflare.F("3ebbcb006d4d46d7bb6a8c7f14676cb0"),
Enable: cloudflare.F(true),
Name: cloudflare.F("name"),
OrderBy: cloudflare.F("order_by"),
OrderByDirection: cloudflare.F(ai_gateway.DatasetListParamsOrderByDirectionAsc),
Page: cloudflare.F(int64(1)),
PerPage: cloudflare.F(int64(5)),
PerPage: cloudflare.F(int64(1)),
Search: cloudflare.F("search"),
},
)
Expand Down Expand Up @@ -169,7 155,7 @@ func TestDatasetDelete(t *testing.T) {
)
_, err := client.AIGateway.Datasets.Delete(
context.TODO(),
"gateway_id",
"my-gateway",
"id",
ai_gateway.DatasetDeleteParams{
AccountID: cloudflare.F("3ebbcb006d4d46d7bb6a8c7f14676cb0"),
Expand Down Expand Up @@ -199,7 185,7 @@ func TestDatasetGet(t *testing.T) {
)
_, err := client.AIGateway.Datasets.Get(
context.TODO(),
"gateway_id",
"my-gateway",
"id",
ai_gateway.DatasetGetParams{
AccountID: cloudflare.F("3ebbcb006d4d46d7bb6a8c7f14676cb0"),
Expand Down
Loading

0 comments on commit 708c85a

Please sign in to comment.