Skip to content

Commit c184a56

Browse files
feat(api): automatic updates (#3902)
1 parent 1550391 commit c184a56

File tree

7 files changed

+254
-396
lines changed

7 files changed

+254
-396
lines changed

ai_gateway/evaluationtype.go

Lines changed: 45 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import (
1515
"github.com/cloudflare/cloudflare-go/v4/internal/param"
1616
"github.com/cloudflare/cloudflare-go/v4/internal/requestconfig"
1717
"github.com/cloudflare/cloudflare-go/v4/option"
18+
"github.com/cloudflare/cloudflare-go/v4/packages/pagination"
1819
)
1920

2021
// EvaluationTypeService contains methods and other services that help with
@@ -37,37 +38,47 @@ func NewEvaluationTypeService(opts ...option.RequestOption) (r *EvaluationTypeSe
3738
}
3839

3940
// List Evaluators
40-
func (r *EvaluationTypeService) Get(ctx context.Context, params EvaluationTypeGetParams, opts ...option.RequestOption) (res *[]EvaluationTypeGetResponse, err error) {
41-
var env EvaluationTypeGetResponseEnvelope
41+
func (r *EvaluationTypeService) List(ctx context.Context, params EvaluationTypeListParams, opts ...option.RequestOption) (res *pagination.V4PagePaginationArray[EvaluationTypeListResponse], err error) {
42+
var raw *http.Response
4243
opts = append(r.Options[:], opts...)
44+
opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...)
4345
if params.AccountID.Value == "" {
4446
err = errors.New("missing required account_id parameter")
4547
return
4648
}
4749
path := fmt.Sprintf("accounts/%s/ai-gateway/evaluation-types", params.AccountID)
48-
err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, params, &env, opts...)
50+
cfg, err := requestconfig.NewRequestConfig(ctx, http.MethodGet, path, params, &res, opts...)
4951
if err != nil {
50-
return
52+
return nil, err
5153
}
52-
res = &env.Result
53-
return
54+
err = cfg.Execute()
55+
if err != nil {
56+
return nil, err
57+
}
58+
res.SetPageConfig(cfg, raw)
59+
return res, nil
5460
}
5561

56-
type EvaluationTypeGetResponse struct {
57-
ID string `json:"id,required"`
58-
CreatedAt time.Time `json:"created_at,required" format:"date-time"`
59-
Description string `json:"description,required"`
60-
Enable bool `json:"enable,required"`
61-
Mandatory bool `json:"mandatory,required"`
62-
ModifiedAt time.Time `json:"modified_at,required" format:"date-time"`
63-
Name string `json:"name,required"`
64-
Type string `json:"type,required"`
65-
JSON evaluationTypeGetResponseJSON `json:"-"`
62+
// List Evaluators
63+
func (r *EvaluationTypeService) ListAutoPaging(ctx context.Context, params EvaluationTypeListParams, opts ...option.RequestOption) *pagination.V4PagePaginationArrayAutoPager[EvaluationTypeListResponse] {
64+
return pagination.NewV4PagePaginationArrayAutoPager(r.List(ctx, params, opts...))
65+
}
66+
67+
type EvaluationTypeListResponse struct {
68+
ID string `json:"id,required"`
69+
CreatedAt time.Time `json:"created_at,required" format:"date-time"`
70+
Description string `json:"description,required"`
71+
Enable bool `json:"enable,required"`
72+
Mandatory bool `json:"mandatory,required"`
73+
ModifiedAt time.Time `json:"modified_at,required" format:"date-time"`
74+
Name string `json:"name,required"`
75+
Type string `json:"type,required"`
76+
JSON evaluationTypeListResponseJSON `json:"-"`
6677
}
6778

68-
// evaluationTypeGetResponseJSON contains the JSON metadata for the struct
69-
// [EvaluationTypeGetResponse]
70-
type evaluationTypeGetResponseJSON struct {
79+
// evaluationTypeListResponseJSON contains the JSON metadata for the struct
80+
// [EvaluationTypeListResponse]
81+
type evaluationTypeListResponseJSON struct {
7182
ID apijson.Field
7283
CreatedAt apijson.Field
7384
Description apijson.Field
@@ -80,94 +91,42 @@ type evaluationTypeGetResponseJSON struct {
8091
ExtraFields map[string]apijson.Field
8192
}
8293

83-
func (r *EvaluationTypeGetResponse) UnmarshalJSON(data []byte) (err error) {
94+
func (r *EvaluationTypeListResponse) UnmarshalJSON(data []byte) (err error) {
8495
return apijson.UnmarshalRoot(data, r)
8596
}
8697

87-
func (r evaluationTypeGetResponseJSON) RawJSON() string {
98+
func (r evaluationTypeListResponseJSON) RawJSON() string {
8899
return r.raw
89100
}
90101

91-
type EvaluationTypeGetParams struct {
92-
AccountID param.Field[string] `path:"account_id,required"`
93-
OrderBy param.Field[string] `query:"order_by"`
94-
OrderByDirection param.Field[EvaluationTypeGetParamsOrderByDirection] `query:"order_by_direction"`
95-
Page param.Field[int64] `query:"page"`
96-
PerPage param.Field[int64] `query:"per_page"`
102+
type EvaluationTypeListParams struct {
103+
AccountID param.Field[string] `path:"account_id,required"`
104+
OrderBy param.Field[string] `query:"order_by"`
105+
OrderByDirection param.Field[EvaluationTypeListParamsOrderByDirection] `query:"order_by_direction"`
106+
Page param.Field[int64] `query:"page"`
107+
PerPage param.Field[int64] `query:"per_page"`
97108
}
98109

99-
// URLQuery serializes [EvaluationTypeGetParams]'s query parameters as
110+
// URLQuery serializes [EvaluationTypeListParams]'s query parameters as
100111
// `url.Values`.
101-
func (r EvaluationTypeGetParams) URLQuery() (v url.Values) {
112+
func (r EvaluationTypeListParams) URLQuery() (v url.Values) {
102113
return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{
103114
ArrayFormat: apiquery.ArrayQueryFormatRepeat,
104115
NestedFormat: apiquery.NestedQueryFormatDots,
105116
})
106117
}
107118

108-
type EvaluationTypeGetParamsOrderByDirection string
119+
type EvaluationTypeListParamsOrderByDirection string
109120

110121
const (
111-
EvaluationTypeGetParamsOrderByDirectionAsc EvaluationTypeGetParamsOrderByDirection = "asc"
112-
EvaluationTypeGetParamsOrderByDirectionDesc EvaluationTypeGetParamsOrderByDirection = "desc"
122+
EvaluationTypeListParamsOrderByDirectionAsc EvaluationTypeListParamsOrderByDirection = "asc"
123+
EvaluationTypeListParamsOrderByDirectionDesc EvaluationTypeListParamsOrderByDirection = "desc"
113124
)
114125

115-
func (r EvaluationTypeGetParamsOrderByDirection) IsKnown() bool {
126+
func (r EvaluationTypeListParamsOrderByDirection) IsKnown() bool {
116127
switch r {
117-
case EvaluationTypeGetParamsOrderByDirectionAsc, EvaluationTypeGetParamsOrderByDirectionDesc:
128+
case EvaluationTypeListParamsOrderByDirectionAsc, EvaluationTypeListParamsOrderByDirectionDesc:
118129
return true
119130
}
120131
return false
121132
}
122-
123-
type EvaluationTypeGetResponseEnvelope struct {
124-
Result []EvaluationTypeGetResponse `json:"result,required"`
125-
ResultInfo EvaluationTypeGetResponseEnvelopeResultInfo `json:"result_info,required"`
126-
Success bool `json:"success,required"`
127-
JSON evaluationTypeGetResponseEnvelopeJSON `json:"-"`
128-
}
129-
130-
// evaluationTypeGetResponseEnvelopeJSON contains the JSON metadata for the struct
131-
// [EvaluationTypeGetResponseEnvelope]
132-
type evaluationTypeGetResponseEnvelopeJSON struct {
133-
Result apijson.Field
134-
ResultInfo apijson.Field
135-
Success apijson.Field
136-
raw string
137-
ExtraFields map[string]apijson.Field
138-
}
139-
140-
func (r *EvaluationTypeGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) {
141-
return apijson.UnmarshalRoot(data, r)
142-
}
143-
144-
func (r evaluationTypeGetResponseEnvelopeJSON) RawJSON() string {
145-
return r.raw
146-
}
147-
148-
type EvaluationTypeGetResponseEnvelopeResultInfo struct {
149-
Count float64 `json:"count,required"`
150-
Page float64 `json:"page,required"`
151-
PerPage float64 `json:"per_page,required"`
152-
TotalCount float64 `json:"total_count,required"`
153-
JSON evaluationTypeGetResponseEnvelopeResultInfoJSON `json:"-"`
154-
}
155-
156-
// evaluationTypeGetResponseEnvelopeResultInfoJSON contains the JSON metadata for
157-
// the struct [EvaluationTypeGetResponseEnvelopeResultInfo]
158-
type evaluationTypeGetResponseEnvelopeResultInfoJSON struct {
159-
Count apijson.Field
160-
Page apijson.Field
161-
PerPage apijson.Field
162-
TotalCount apijson.Field
163-
raw string
164-
ExtraFields map[string]apijson.Field
165-
}
166-
167-
func (r *EvaluationTypeGetResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) {
168-
return apijson.UnmarshalRoot(data, r)
169-
}
170-
171-
func (r evaluationTypeGetResponseEnvelopeResultInfoJSON) RawJSON() string {
172-
return r.raw
173-
}

ai_gateway/evaluationtype_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import (
1414
"github.com/cloudflare/cloudflare-go/v4/option"
1515
)
1616

17-
func TestEvaluationTypeGetWithOptionalParams(t *testing.T) {
17+
func TestEvaluationTypeListWithOptionalParams(t *testing.T) {
1818
baseURL := "http://localhost:4010"
1919
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
2020
baseURL = envURL
@@ -27,10 +27,10 @@ func TestEvaluationTypeGetWithOptionalParams(t *testing.T) {
2727
option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"),
2828
option.WithAPIEmail("[email protected]"),
2929
)
30-
_, err := client.AIGateway.EvaluationTypes.Get(context.TODO(), ai_gateway.EvaluationTypeGetParams{
30+
_, err := client.AIGateway.EvaluationTypes.List(context.TODO(), ai_gateway.EvaluationTypeListParams{
3131
AccountID: cloudflare.F("0d37909e38d3e99c29fa2cd343ac421a"),
3232
OrderBy: cloudflare.F("order_by"),
33-
OrderByDirection: cloudflare.F(ai_gateway.EvaluationTypeGetParamsOrderByDirectionAsc),
33+
OrderByDirection: cloudflare.F(ai_gateway.EvaluationTypeListParamsOrderByDirectionAsc),
3434
Page: cloudflare.F(int64(1)),
3535
PerPage: cloudflare.F(int64(5)),
3636
})

api.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -625,11 +625,11 @@ Methods:
625625

626626
Response Types:
627627

628-
- <a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v4/load_balancers">load_balancers</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v4/load_balancers#SearchGetResponse">SearchGetResponse</a>
628+
- <a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v4/load_balancers">load_balancers</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v4/load_balancers#SearchListResponse">SearchListResponse</a>
629629

630630
Methods:
631631

632-
- <code title="get /accounts/{account_id}/load_balancers/search">client.LoadBalancers.Searches.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v4/load_balancers#SearchService.Get">Get</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/v4/load_balancers">load_balancers</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v4/load_balancers#SearchGetParams">SearchGetParams</a>) (<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v4/load_balancers">load_balancers</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v4/load_balancers#SearchGetResponse">SearchGetResponse</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code>
632+
- <code title="get /accounts/{account_id}/load_balancers/search">client.LoadBalancers.Searches.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v4/load_balancers#SearchService.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/v4/load_balancers">load_balancers</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v4/load_balancers#SearchListParams">SearchListParams</a>) (<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v4/packages/pagination">pagination</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v4/packages/pagination#V4PagePagination">V4PagePagination</a>[<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v4/load_balancers">load_balancers</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v4/load_balancers#SearchListResponse">SearchListResponse</a>], <a href="https://pkg.go.dev/builtin#error">error</a>)</code>
633633

634634
# Cache
635635

@@ -7542,11 +7542,11 @@ Methods:
75427542

75437543
Response Types:
75447544

7545-
- <a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v4/ai_gateway">ai_gateway</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v4/ai_gateway#EvaluationTypeGetResponse">EvaluationTypeGetResponse</a>
7545+
- <a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v4/ai_gateway">ai_gateway</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v4/ai_gateway#EvaluationTypeListResponse">EvaluationTypeListResponse</a>
75467546

75477547
Methods:
75487548

7549-
- <code title="get /accounts/{account_id}/ai-gateway/evaluation-types">client.AIGateway.EvaluationTypes.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v4/ai_gateway#EvaluationTypeService.Get">Get</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/v4/ai_gateway">ai_gateway</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v4/ai_gateway#EvaluationTypeGetParams">EvaluationTypeGetParams</a>) ([]<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v4/ai_gateway">ai_gateway</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v4/ai_gateway#EvaluationTypeGetResponse">EvaluationTypeGetResponse</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code>
7549+
- <code title="get /accounts/{account_id}/ai-gateway/evaluation-types">client.AIGateway.EvaluationTypes.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v4/ai_gateway#EvaluationTypeService.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/v4/ai_gateway">ai_gateway</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v4/ai_gateway#EvaluationTypeListParams">EvaluationTypeListParams</a>) (<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v4/packages/pagination">pagination</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v4/packages/pagination#V4PagePaginationArray">V4PagePaginationArray</a>[<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v4/ai_gateway">ai_gateway</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v4/ai_gateway#EvaluationTypeListResponse">EvaluationTypeListResponse</a>], <a href="https://pkg.go.dev/builtin#error">error</a>)</code>
75507550

75517551
## Logs
75527552

@@ -7950,13 +7950,13 @@ Methods:
79507950

79517951
Response Types:
79527952

7953+
- <a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v4/security_center">security_center</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v4/security_center#InsightListResponse">InsightListResponse</a>
79537954
- <a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v4/security_center">security_center</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v4/security_center#InsightDismissResponse">InsightDismissResponse</a>
7954-
- <a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v4/security_center">security_center</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v4/security_center#InsightGetResponse">InsightGetResponse</a>
79557955

79567956
Methods:
79577957

7958+
- <code title="get /{account_or_zone}/{account_or_zone_id}/security-center/insights">client.SecurityCenter.Insights.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v4/security_center#InsightService.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/v4/security_center">security_center</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v4/security_center#InsightListParams">InsightListParams</a>) (<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v4/packages/pagination">pagination</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v4/packages/pagination#V4PagePagination">V4PagePagination</a>[<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v4/security_center">security_center</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v4/security_center#InsightListResponse">InsightListResponse</a>], <a href="https://pkg.go.dev/builtin#error">error</a>)</code>
79587959
- <code title="put /{account_or_zone}/{account_or_zone_id}/security-center/insights/{issue_id}/dismiss">client.SecurityCenter.Insights.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v4/security_center#InsightService.Dismiss">Dismiss</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, issueID <a href="https://pkg.go.dev/builtin#string">string</a>, params <a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v4/security_center">security_center</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v4/security_center#InsightDismissParams">InsightDismissParams</a>) (<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v4/security_center">security_center</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v4/security_center#InsightDismissResponse">InsightDismissResponse</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code>
7959-
- <code title="get /{account_or_zone}/{account_or_zone_id}/security-center/insights">client.SecurityCenter.Insights.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v4/security_center#InsightService.Get">Get</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/v4/security_center">security_center</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v4/security_center#InsightGetParams">InsightGetParams</a>) (<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v4/security_center">security_center</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v4/security_center#InsightGetResponse">InsightGetResponse</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code>
79607960

79617961
### Class
79627962

0 commit comments

Comments
 (0)