@@ -15,6 +15,7 @@ import (
15
15
"github.com/cloudflare/cloudflare-go/v4/internal/param"
16
16
"github.com/cloudflare/cloudflare-go/v4/internal/requestconfig"
17
17
"github.com/cloudflare/cloudflare-go/v4/option"
18
+ "github.com/cloudflare/cloudflare-go/v4/packages/pagination"
18
19
)
19
20
20
21
// EvaluationTypeService contains methods and other services that help with
@@ -37,37 +38,47 @@ func NewEvaluationTypeService(opts ...option.RequestOption) (r *EvaluationTypeSe
37
38
}
38
39
39
40
// 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
42
43
opts = append (r .Options [:], opts ... )
44
+ opts = append ([]option.RequestOption {option .WithResponseInto (& raw )}, opts ... )
43
45
if params .AccountID .Value == "" {
44
46
err = errors .New ("missing required account_id parameter" )
45
47
return
46
48
}
47
49
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 ... )
49
51
if err != nil {
50
- return
52
+ return nil , err
51
53
}
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
54
60
}
55
61
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:"-"`
66
77
}
67
78
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 {
71
82
ID apijson.Field
72
83
CreatedAt apijson.Field
73
84
Description apijson.Field
@@ -80,94 +91,42 @@ type evaluationTypeGetResponseJSON struct {
80
91
ExtraFields map [string ]apijson.Field
81
92
}
82
93
83
- func (r * EvaluationTypeGetResponse ) UnmarshalJSON (data []byte ) (err error ) {
94
+ func (r * EvaluationTypeListResponse ) UnmarshalJSON (data []byte ) (err error ) {
84
95
return apijson .UnmarshalRoot (data , r )
85
96
}
86
97
87
- func (r evaluationTypeGetResponseJSON ) RawJSON () string {
98
+ func (r evaluationTypeListResponseJSON ) RawJSON () string {
88
99
return r .raw
89
100
}
90
101
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"`
97
108
}
98
109
99
- // URLQuery serializes [EvaluationTypeGetParams ]'s query parameters as
110
+ // URLQuery serializes [EvaluationTypeListParams ]'s query parameters as
100
111
// `url.Values`.
101
- func (r EvaluationTypeGetParams ) URLQuery () (v url.Values ) {
112
+ func (r EvaluationTypeListParams ) URLQuery () (v url.Values ) {
102
113
return apiquery .MarshalWithSettings (r , apiquery.QuerySettings {
103
114
ArrayFormat : apiquery .ArrayQueryFormatRepeat ,
104
115
NestedFormat : apiquery .NestedQueryFormatDots ,
105
116
})
106
117
}
107
118
108
- type EvaluationTypeGetParamsOrderByDirection string
119
+ type EvaluationTypeListParamsOrderByDirection string
109
120
110
121
const (
111
- EvaluationTypeGetParamsOrderByDirectionAsc EvaluationTypeGetParamsOrderByDirection = "asc"
112
- EvaluationTypeGetParamsOrderByDirectionDesc EvaluationTypeGetParamsOrderByDirection = "desc"
122
+ EvaluationTypeListParamsOrderByDirectionAsc EvaluationTypeListParamsOrderByDirection = "asc"
123
+ EvaluationTypeListParamsOrderByDirectionDesc EvaluationTypeListParamsOrderByDirection = "desc"
113
124
)
114
125
115
- func (r EvaluationTypeGetParamsOrderByDirection ) IsKnown () bool {
126
+ func (r EvaluationTypeListParamsOrderByDirection ) IsKnown () bool {
116
127
switch r {
117
- case EvaluationTypeGetParamsOrderByDirectionAsc , EvaluationTypeGetParamsOrderByDirectionDesc :
128
+ case EvaluationTypeListParamsOrderByDirectionAsc , EvaluationTypeListParamsOrderByDirectionDesc :
118
129
return true
119
130
}
120
131
return false
121
132
}
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
- }
0 commit comments