Skip to content

Commit c184a56

Browse files
committedFeb 6, 2025
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

+45-86
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

+3-3
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("user@example.com"),
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

+6-6
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

‎load_balancers/search.go

+63-132
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import (
1414
"github.com/cloudflare/cloudflare-go/v4/internal/param"
1515
"github.com/cloudflare/cloudflare-go/v4/internal/requestconfig"
1616
"github.com/cloudflare/cloudflare-go/v4/option"
17-
"github.com/cloudflare/cloudflare-go/v4/shared"
17+
"github.com/cloudflare/cloudflare-go/v4/packages/pagination"
1818
)
1919

2020
// SearchService contains methods and other services that help with interacting
@@ -37,61 +37,71 @@ func NewSearchService(opts ...option.RequestOption) (r *SearchService) {
3737
}
3838

3939
// Search for Load Balancing resources.
40-
func (r *SearchService) Get(ctx context.Context, params SearchGetParams, opts ...option.RequestOption) (res *SearchGetResponse, err error) {
41-
var env SearchGetResponseEnvelope
40+
func (r *SearchService) List(ctx context.Context, params SearchListParams, opts ...option.RequestOption) (res *pagination.V4PagePagination[SearchListResponse], err error) {
41+
var raw *http.Response
4242
opts = append(r.Options[:], opts...)
43+
opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...)
4344
if params.AccountID.Value == "" {
4445
err = errors.New("missing required account_id parameter")
4546
return
4647
}
4748
path := fmt.Sprintf("accounts/%s/load_balancers/search", params.AccountID)
48-
err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, params, &env, opts...)
49+
cfg, err := requestconfig.NewRequestConfig(ctx, http.MethodGet, path, params, &res, opts...)
4950
if err != nil {
50-
return
51+
return nil, err
5152
}
52-
res = &env.Result
53-
return
53+
err = cfg.Execute()
54+
if err != nil {
55+
return nil, err
56+
}
57+
res.SetPageConfig(cfg, raw)
58+
return res, nil
5459
}
5560

56-
type SearchGetResponse struct {
61+
// Search for Load Balancing resources.
62+
func (r *SearchService) ListAutoPaging(ctx context.Context, params SearchListParams, opts ...option.RequestOption) *pagination.V4PagePaginationAutoPager[SearchListResponse] {
63+
return pagination.NewV4PagePaginationAutoPager(r.List(ctx, params, opts...))
64+
}
65+
66+
type SearchListResponse struct {
5767
// A list of resources matching the search query.
58-
Resources []SearchGetResponseResource `json:"resources"`
59-
JSON searchGetResponseJSON `json:"-"`
68+
Resources []SearchListResponseResource `json:"resources"`
69+
JSON searchListResponseJSON `json:"-"`
6070
}
6171

62-
// searchGetResponseJSON contains the JSON metadata for the struct
63-
// [SearchGetResponse]
64-
type searchGetResponseJSON struct {
72+
// searchListResponseJSON contains the JSON metadata for the struct
73+
// [SearchListResponse]
74+
type searchListResponseJSON struct {
6575
Resources apijson.Field
6676
raw string
6777
ExtraFields map[string]apijson.Field
6878
}
6979

70-
func (r *SearchGetResponse) UnmarshalJSON(data []byte) (err error) {
80+
func (r *SearchListResponse) UnmarshalJSON(data []byte) (err error) {
7181
return apijson.UnmarshalRoot(data, r)
7282
}
7383

74-
func (r searchGetResponseJSON) RawJSON() string {
84+
func (r searchListResponseJSON) RawJSON() string {
7585
return r.raw
7686
}
7787

7888
// A reference to a load balancer resource.
79-
type SearchGetResponseResource struct {
89+
type SearchListResponseResource struct {
8090
// When listed as a reference, the type (direction) of the reference.
81-
ReferenceType SearchGetResponseResourcesReferenceType `json:"reference_type"`
91+
ReferenceType SearchListResponseResourcesReferenceType `json:"reference_type"`
8292
// A list of references to (referrer) or from (referral) this resource.
8393
References []interface{} `json:"references"`
8494
ResourceID string `json:"resource_id"`
8595
// The human-identifiable name of the resource.
8696
ResourceName string `json:"resource_name"`
8797
// The type of the resource.
88-
ResourceType SearchGetResponseResourcesResourceType `json:"resource_type"`
89-
JSON searchGetResponseResourceJSON `json:"-"`
98+
ResourceType SearchListResponseResourcesResourceType `json:"resource_type"`
99+
JSON searchListResponseResourceJSON `json:"-"`
90100
}
91101

92-
// searchGetResponseResourceJSON contains the JSON metadata for the struct
93-
// [SearchGetResponseResource]
94-
type searchGetResponseResourceJSON struct {
102+
// searchListResponseResourceJSON contains the JSON metadata for the struct
103+
// [SearchListResponseResource]
104+
type searchListResponseResourceJSON struct {
95105
ReferenceType apijson.Field
96106
References apijson.Field
97107
ResourceID apijson.Field
@@ -101,172 +111,93 @@ type searchGetResponseResourceJSON struct {
101111
ExtraFields map[string]apijson.Field
102112
}
103113

104-
func (r *SearchGetResponseResource) UnmarshalJSON(data []byte) (err error) {
114+
func (r *SearchListResponseResource) UnmarshalJSON(data []byte) (err error) {
105115
return apijson.UnmarshalRoot(data, r)
106116
}
107117

108-
func (r searchGetResponseResourceJSON) RawJSON() string {
118+
func (r searchListResponseResourceJSON) RawJSON() string {
109119
return r.raw
110120
}
111121

112122
// When listed as a reference, the type (direction) of the reference.
113-
type SearchGetResponseResourcesReferenceType string
123+
type SearchListResponseResourcesReferenceType string
114124

115125
const (
116-
SearchGetResponseResourcesReferenceTypeReferral SearchGetResponseResourcesReferenceType = "referral"
117-
SearchGetResponseResourcesReferenceTypeReferrer SearchGetResponseResourcesReferenceType = "referrer"
126+
SearchListResponseResourcesReferenceTypeReferral SearchListResponseResourcesReferenceType = "referral"
127+
SearchListResponseResourcesReferenceTypeReferrer SearchListResponseResourcesReferenceType = "referrer"
118128
)
119129

120-
func (r SearchGetResponseResourcesReferenceType) IsKnown() bool {
130+
func (r SearchListResponseResourcesReferenceType) IsKnown() bool {
121131
switch r {
122-
case SearchGetResponseResourcesReferenceTypeReferral, SearchGetResponseResourcesReferenceTypeReferrer:
132+
case SearchListResponseResourcesReferenceTypeReferral, SearchListResponseResourcesReferenceTypeReferrer:
123133
return true
124134
}
125135
return false
126136
}
127137

128138
// The type of the resource.
129-
type SearchGetResponseResourcesResourceType string
139+
type SearchListResponseResourcesResourceType string
130140

131141
const (
132-
SearchGetResponseResourcesResourceTypeLoadBalancer SearchGetResponseResourcesResourceType = "load_balancer"
133-
SearchGetResponseResourcesResourceTypeMonitor SearchGetResponseResourcesResourceType = "monitor"
134-
SearchGetResponseResourcesResourceTypePool SearchGetResponseResourcesResourceType = "pool"
142+
SearchListResponseResourcesResourceTypeLoadBalancer SearchListResponseResourcesResourceType = "load_balancer"
143+
SearchListResponseResourcesResourceTypeMonitor SearchListResponseResourcesResourceType = "monitor"
144+
SearchListResponseResourcesResourceTypePool SearchListResponseResourcesResourceType = "pool"
135145
)
136146

137-
func (r SearchGetResponseResourcesResourceType) IsKnown() bool {
147+
func (r SearchListResponseResourcesResourceType) IsKnown() bool {
138148
switch r {
139-
case SearchGetResponseResourcesResourceTypeLoadBalancer, SearchGetResponseResourcesResourceTypeMonitor, SearchGetResponseResourcesResourceTypePool:
149+
case SearchListResponseResourcesResourceTypeLoadBalancer, SearchListResponseResourcesResourceTypeMonitor, SearchListResponseResourcesResourceTypePool:
140150
return true
141151
}
142152
return false
143153
}
144154

145-
type SearchGetParams struct {
155+
type SearchListParams struct {
146156
// Identifier
147-
AccountID param.Field[string] `path:"account_id,required"`
148-
Page param.Field[float64] `query:"page"`
149-
PerPage param.Field[float64] `query:"per_page"`
150-
SearchParams param.Field[SearchGetParamsSearchParams] `query:"search_params"`
157+
AccountID param.Field[string] `path:"account_id,required"`
158+
Page param.Field[float64] `query:"page"`
159+
PerPage param.Field[float64] `query:"per_page"`
160+
SearchParams param.Field[SearchListParamsSearchParams] `query:"search_params"`
151161
}
152162

153-
// URLQuery serializes [SearchGetParams]'s query parameters as `url.Values`.
154-
func (r SearchGetParams) URLQuery() (v url.Values) {
163+
// URLQuery serializes [SearchListParams]'s query parameters as `url.Values`.
164+
func (r SearchListParams) URLQuery() (v url.Values) {
155165
return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{
156166
ArrayFormat: apiquery.ArrayQueryFormatRepeat,
157167
NestedFormat: apiquery.NestedQueryFormatDots,
158168
})
159169
}
160170

161-
type SearchGetParamsSearchParams struct {
171+
type SearchListParamsSearchParams struct {
162172
// Search query term.
163173
Query param.Field[string] `query:"query"`
164174
// The type of references to include ("\*" for all).
165-
References param.Field[SearchGetParamsSearchParamsReferences] `query:"references"`
175+
References param.Field[SearchListParamsSearchParamsReferences] `query:"references"`
166176
}
167177

168-
// URLQuery serializes [SearchGetParamsSearchParams]'s query parameters as
178+
// URLQuery serializes [SearchListParamsSearchParams]'s query parameters as
169179
// `url.Values`.
170-
func (r SearchGetParamsSearchParams) URLQuery() (v url.Values) {
180+
func (r SearchListParamsSearchParams) URLQuery() (v url.Values) {
171181
return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{
172182
ArrayFormat: apiquery.ArrayQueryFormatRepeat,
173183
NestedFormat: apiquery.NestedQueryFormatDots,
174184
})
175185
}
176186

177187
// The type of references to include ("\*" for all).
178-
type SearchGetParamsSearchParamsReferences string
188+
type SearchListParamsSearchParamsReferences string
179189

180190
const (
181-
SearchGetParamsSearchParamsReferencesEmpty SearchGetParamsSearchParamsReferences = ""
182-
SearchGetParamsSearchParamsReferencesStar SearchGetParamsSearchParamsReferences = "*"
183-
SearchGetParamsSearchParamsReferencesReferral SearchGetParamsSearchParamsReferences = "referral"
184-
SearchGetParamsSearchParamsReferencesReferrer SearchGetParamsSearchParamsReferences = "referrer"
191+
SearchListParamsSearchParamsReferencesEmpty SearchListParamsSearchParamsReferences = ""
192+
SearchListParamsSearchParamsReferencesStar SearchListParamsSearchParamsReferences = "*"
193+
SearchListParamsSearchParamsReferencesReferral SearchListParamsSearchParamsReferences = "referral"
194+
SearchListParamsSearchParamsReferencesReferrer SearchListParamsSearchParamsReferences = "referrer"
185195
)
186196

187-
func (r SearchGetParamsSearchParamsReferences) IsKnown() bool {
197+
func (r SearchListParamsSearchParamsReferences) IsKnown() bool {
188198
switch r {
189-
case SearchGetParamsSearchParamsReferencesEmpty, SearchGetParamsSearchParamsReferencesStar, SearchGetParamsSearchParamsReferencesReferral, SearchGetParamsSearchParamsReferencesReferrer:
199+
case SearchListParamsSearchParamsReferencesEmpty, SearchListParamsSearchParamsReferencesStar, SearchListParamsSearchParamsReferencesReferral, SearchListParamsSearchParamsReferencesReferrer:
190200
return true
191201
}
192202
return false
193203
}
194-
195-
type SearchGetResponseEnvelope struct {
196-
Errors []shared.ResponseInfo `json:"errors,required"`
197-
Messages []shared.ResponseInfo `json:"messages,required"`
198-
Result SearchGetResponse `json:"result,required"`
199-
// Whether the API call was successful
200-
Success SearchGetResponseEnvelopeSuccess `json:"success,required"`
201-
ResultInfo SearchGetResponseEnvelopeResultInfo `json:"result_info"`
202-
JSON searchGetResponseEnvelopeJSON `json:"-"`
203-
}
204-
205-
// searchGetResponseEnvelopeJSON contains the JSON metadata for the struct
206-
// [SearchGetResponseEnvelope]
207-
type searchGetResponseEnvelopeJSON struct {
208-
Errors apijson.Field
209-
Messages apijson.Field
210-
Result apijson.Field
211-
Success apijson.Field
212-
ResultInfo apijson.Field
213-
raw string
214-
ExtraFields map[string]apijson.Field
215-
}
216-
217-
func (r *SearchGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) {
218-
return apijson.UnmarshalRoot(data, r)
219-
}
220-
221-
func (r searchGetResponseEnvelopeJSON) RawJSON() string {
222-
return r.raw
223-
}
224-
225-
// Whether the API call was successful
226-
type SearchGetResponseEnvelopeSuccess bool
227-
228-
const (
229-
SearchGetResponseEnvelopeSuccessTrue SearchGetResponseEnvelopeSuccess = true
230-
)
231-
232-
func (r SearchGetResponseEnvelopeSuccess) IsKnown() bool {
233-
switch r {
234-
case SearchGetResponseEnvelopeSuccessTrue:
235-
return true
236-
}
237-
return false
238-
}
239-
240-
type SearchGetResponseEnvelopeResultInfo struct {
241-
// Total number of results on the current page
242-
Count float64 `json:"count"`
243-
// Current page within paginated list of results
244-
Page float64 `json:"page"`
245-
// Number of results per page
246-
PerPage float64 `json:"per_page"`
247-
// Total results available without any search parameters
248-
TotalCount float64 `json:"total_count"`
249-
// Total number of pages available
250-
TotalPages float64 `json:"total_pages"`
251-
JSON searchGetResponseEnvelopeResultInfoJSON `json:"-"`
252-
}
253-
254-
// searchGetResponseEnvelopeResultInfoJSON contains the JSON metadata for the
255-
// struct [SearchGetResponseEnvelopeResultInfo]
256-
type searchGetResponseEnvelopeResultInfoJSON struct {
257-
Count apijson.Field
258-
Page apijson.Field
259-
PerPage apijson.Field
260-
TotalCount apijson.Field
261-
TotalPages apijson.Field
262-
raw string
263-
ExtraFields map[string]apijson.Field
264-
}
265-
266-
func (r *SearchGetResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) {
267-
return apijson.UnmarshalRoot(data, r)
268-
}
269-
270-
func (r searchGetResponseEnvelopeResultInfoJSON) RawJSON() string {
271-
return r.raw
272-
}

‎load_balancers/search_test.go

+4-4
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 TestSearchGetWithOptionalParams(t *testing.T) {
17+
func TestSearchListWithOptionalParams(t *testing.T) {
1818
t.Skip("TODO: investigate broken test")
1919
baseURL := "http://localhost:4010"
2020
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
@@ -28,13 +28,13 @@ func TestSearchGetWithOptionalParams(t *testing.T) {
2828
option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"),
2929
option.WithAPIEmail("user@example.com"),
3030
)
31-
_, err := client.LoadBalancers.Searches.Get(context.TODO(), load_balancers.SearchGetParams{
31+
_, err := client.LoadBalancers.Searches.List(context.TODO(), load_balancers.SearchListParams{
3232
AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"),
3333
Page: cloudflare.F(1.000000),
3434
PerPage: cloudflare.F(1.000000),
35-
SearchParams: cloudflare.F(load_balancers.SearchGetParamsSearchParams{
35+
SearchParams: cloudflare.F(load_balancers.SearchListParamsSearchParams{
3636
Query: cloudflare.F("primary"),
37-
References: cloudflare.F(load_balancers.SearchGetParamsSearchParamsReferencesEmpty),
37+
References: cloudflare.F(load_balancers.SearchListParamsSearchParamsReferencesEmpty),
3838
}),
3939
})
4040
if err != nil {

‎security_center/insight.go

+107-139
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import (
1616
"github.com/cloudflare/cloudflare-go/v4/internal/param"
1717
"github.com/cloudflare/cloudflare-go/v4/internal/requestconfig"
1818
"github.com/cloudflare/cloudflare-go/v4/option"
19+
"github.com/cloudflare/cloudflare-go/v4/packages/pagination"
1920
"github.com/cloudflare/cloudflare-go/v4/shared"
2021
)
2122

@@ -44,9 +45,11 @@ func NewInsightService(opts ...option.RequestOption) (r *InsightService) {
4445
return
4546
}
4647

47-
// Archive Security Center Insight
48-
func (r *InsightService) Dismiss(ctx context.Context, issueID string, params InsightDismissParams, opts ...option.RequestOption) (res *InsightDismissResponse, err error) {
48+
// Get Security Center Insights
49+
func (r *InsightService) List(ctx context.Context, params InsightListParams, opts ...option.RequestOption) (res *pagination.V4PagePagination[InsightListResponse], err error) {
50+
var raw *http.Response
4951
opts = append(r.Options[:], opts...)
52+
opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...)
5053
var accountOrZone string
5154
var accountOrZoneID param.Field[string]
5255
if params.AccountID.Value != "" && params.ZoneID.Value != "" {
@@ -65,18 +68,26 @@ func (r *InsightService) Dismiss(ctx context.Context, issueID string, params Ins
6568
accountOrZone = "zones"
6669
accountOrZoneID = params.ZoneID
6770
}
68-
if issueID == "" {
69-
err = errors.New("missing required issue_id parameter")
70-
return
71+
path := fmt.Sprintf("%s/%s/security-center/insights", accountOrZone, accountOrZoneID)
72+
cfg, err := requestconfig.NewRequestConfig(ctx, http.MethodGet, path, params, &res, opts...)
73+
if err != nil {
74+
return nil, err
7175
}
72-
path := fmt.Sprintf("%s/%s/security-center/insights/%s/dismiss", accountOrZone, accountOrZoneID, issueID)
73-
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, params, &res, opts...)
74-
return
76+
err = cfg.Execute()
77+
if err != nil {
78+
return nil, err
79+
}
80+
res.SetPageConfig(cfg, raw)
81+
return res, nil
7582
}
7683

7784
// Get Security Center Insights
78-
func (r *InsightService) Get(ctx context.Context, params InsightGetParams, opts ...option.RequestOption) (res *InsightGetResponse, err error) {
79-
var env InsightGetResponseEnvelope
85+
func (r *InsightService) ListAutoPaging(ctx context.Context, params InsightListParams, opts ...option.RequestOption) *pagination.V4PagePaginationAutoPager[InsightListResponse] {
86+
return pagination.NewV4PagePaginationAutoPager(r.List(ctx, params, opts...))
87+
}
88+
89+
// Archive Security Center Insight
90+
func (r *InsightService) Dismiss(ctx context.Context, issueID string, params InsightDismissParams, opts ...option.RequestOption) (res *InsightDismissResponse, err error) {
8091
opts = append(r.Options[:], opts...)
8192
var accountOrZone string
8293
var accountOrZoneID param.Field[string]
@@ -96,70 +107,29 @@ func (r *InsightService) Get(ctx context.Context, params InsightGetParams, opts
96107
accountOrZone = "zones"
97108
accountOrZoneID = params.ZoneID
98109
}
99-
path := fmt.Sprintf("%s/%s/security-center/insights", accountOrZone, accountOrZoneID)
100-
err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, params, &env, opts...)
101-
if err != nil {
110+
if issueID == "" {
111+
err = errors.New("missing required issue_id parameter")
102112
return
103113
}
104-
res = &env.Result
114+
path := fmt.Sprintf("%s/%s/security-center/insights/%s/dismiss", accountOrZone, accountOrZoneID, issueID)
115+
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, params, &res, opts...)
105116
return
106117
}
107118

108-
type InsightDismissResponse struct {
109-
Errors []shared.ResponseInfo `json:"errors,required"`
110-
Messages []shared.ResponseInfo `json:"messages,required"`
111-
// Whether the API call was successful
112-
Success InsightDismissResponseSuccess `json:"success,required"`
113-
JSON insightDismissResponseJSON `json:"-"`
114-
}
115-
116-
// insightDismissResponseJSON contains the JSON metadata for the struct
117-
// [InsightDismissResponse]
118-
type insightDismissResponseJSON struct {
119-
Errors apijson.Field
120-
Messages apijson.Field
121-
Success apijson.Field
122-
raw string
123-
ExtraFields map[string]apijson.Field
124-
}
125-
126-
func (r *InsightDismissResponse) UnmarshalJSON(data []byte) (err error) {
127-
return apijson.UnmarshalRoot(data, r)
128-
}
129-
130-
func (r insightDismissResponseJSON) RawJSON() string {
131-
return r.raw
132-
}
133-
134-
// Whether the API call was successful
135-
type InsightDismissResponseSuccess bool
136-
137-
const (
138-
InsightDismissResponseSuccessTrue InsightDismissResponseSuccess = true
139-
)
140-
141-
func (r InsightDismissResponseSuccess) IsKnown() bool {
142-
switch r {
143-
case InsightDismissResponseSuccessTrue:
144-
return true
145-
}
146-
return false
147-
}
148-
149-
type InsightGetResponse struct {
119+
type InsightListResponse struct {
150120
// Total number of results
151-
Count int64 `json:"count"`
152-
Issues []InsightGetResponseIssue `json:"issues"`
121+
Count int64 `json:"count"`
122+
Issues []InsightListResponseIssue `json:"issues"`
153123
// Current page within paginated list of results
154124
Page int64 `json:"page"`
155125
// Number of results per page of results
156-
PerPage int64 `json:"per_page"`
157-
JSON insightGetResponseJSON `json:"-"`
126+
PerPage int64 `json:"per_page"`
127+
JSON insightListResponseJSON `json:"-"`
158128
}
159129

160-
// insightGetResponseJSON contains the JSON metadata for the struct
161-
// [InsightGetResponse]
162-
type insightGetResponseJSON struct {
130+
// insightListResponseJSON contains the JSON metadata for the struct
131+
// [InsightListResponse]
132+
type insightListResponseJSON struct {
163133
Count apijson.Field
164134
Issues apijson.Field
165135
Page apijson.Field
@@ -168,32 +138,32 @@ type insightGetResponseJSON struct {
168138
ExtraFields map[string]apijson.Field
169139
}
170140

171-
func (r *InsightGetResponse) UnmarshalJSON(data []byte) (err error) {
141+
func (r *InsightListResponse) UnmarshalJSON(data []byte) (err error) {
172142
return apijson.UnmarshalRoot(data, r)
173143
}
174144

175-
func (r insightGetResponseJSON) RawJSON() string {
145+
func (r insightListResponseJSON) RawJSON() string {
176146
return r.raw
177147
}
178148

179-
type InsightGetResponseIssue struct {
180-
ID string `json:"id"`
181-
Dismissed bool `json:"dismissed"`
182-
IssueClass string `json:"issue_class"`
183-
IssueType intel.IssueType `json:"issue_type"`
184-
Payload interface{} `json:"payload"`
185-
ResolveLink string `json:"resolve_link"`
186-
ResolveText string `json:"resolve_text"`
187-
Severity InsightGetResponseIssuesSeverity `json:"severity"`
188-
Since time.Time `json:"since" format:"date-time"`
189-
Subject string `json:"subject"`
190-
Timestamp time.Time `json:"timestamp" format:"date-time"`
191-
JSON insightGetResponseIssueJSON `json:"-"`
149+
type InsightListResponseIssue struct {
150+
ID string `json:"id"`
151+
Dismissed bool `json:"dismissed"`
152+
IssueClass string `json:"issue_class"`
153+
IssueType intel.IssueType `json:"issue_type"`
154+
Payload interface{} `json:"payload"`
155+
ResolveLink string `json:"resolve_link"`
156+
ResolveText string `json:"resolve_text"`
157+
Severity InsightListResponseIssuesSeverity `json:"severity"`
158+
Since time.Time `json:"since" format:"date-time"`
159+
Subject string `json:"subject"`
160+
Timestamp time.Time `json:"timestamp" format:"date-time"`
161+
JSON insightListResponseIssueJSON `json:"-"`
192162
}
193163

194-
// insightGetResponseIssueJSON contains the JSON metadata for the struct
195-
// [InsightGetResponseIssue]
196-
type insightGetResponseIssueJSON struct {
164+
// insightListResponseIssueJSON contains the JSON metadata for the struct
165+
// [InsightListResponseIssue]
166+
type insightListResponseIssueJSON struct {
197167
ID apijson.Field
198168
Dismissed apijson.Field
199169
IssueClass apijson.Field
@@ -209,43 +179,72 @@ type insightGetResponseIssueJSON struct {
209179
ExtraFields map[string]apijson.Field
210180
}
211181

212-
func (r *InsightGetResponseIssue) UnmarshalJSON(data []byte) (err error) {
182+
func (r *InsightListResponseIssue) UnmarshalJSON(data []byte) (err error) {
213183
return apijson.UnmarshalRoot(data, r)
214184
}
215185

216-
func (r insightGetResponseIssueJSON) RawJSON() string {
186+
func (r insightListResponseIssueJSON) RawJSON() string {
217187
return r.raw
218188
}
219189

220-
type InsightGetResponseIssuesSeverity string
190+
type InsightListResponseIssuesSeverity string
221191

222192
const (
223-
InsightGetResponseIssuesSeverityLow InsightGetResponseIssuesSeverity = "Low"
224-
InsightGetResponseIssuesSeverityModerate InsightGetResponseIssuesSeverity = "Moderate"
225-
InsightGetResponseIssuesSeverityCritical InsightGetResponseIssuesSeverity = "Critical"
193+
InsightListResponseIssuesSeverityLow InsightListResponseIssuesSeverity = "Low"
194+
InsightListResponseIssuesSeverityModerate InsightListResponseIssuesSeverity = "Moderate"
195+
InsightListResponseIssuesSeverityCritical InsightListResponseIssuesSeverity = "Critical"
226196
)
227197

228-
func (r InsightGetResponseIssuesSeverity) IsKnown() bool {
198+
func (r InsightListResponseIssuesSeverity) IsKnown() bool {
229199
switch r {
230-
case InsightGetResponseIssuesSeverityLow, InsightGetResponseIssuesSeverityModerate, InsightGetResponseIssuesSeverityCritical:
200+
case InsightListResponseIssuesSeverityLow, InsightListResponseIssuesSeverityModerate, InsightListResponseIssuesSeverityCritical:
231201
return true
232202
}
233203
return false
234204
}
235205

236-
type InsightDismissParams struct {
237-
// The Account ID to use for this endpoint. Mutually exclusive with the Zone ID.
238-
AccountID param.Field[string] `path:"account_id"`
239-
// The Zone ID to use for this endpoint. Mutually exclusive with the Account ID.
240-
ZoneID param.Field[string] `path:"zone_id"`
241-
Dismiss param.Field[bool] `json:"dismiss"`
206+
type InsightDismissResponse struct {
207+
Errors []shared.ResponseInfo `json:"errors,required"`
208+
Messages []shared.ResponseInfo `json:"messages,required"`
209+
// Whether the API call was successful
210+
Success InsightDismissResponseSuccess `json:"success,required"`
211+
JSON insightDismissResponseJSON `json:"-"`
242212
}
243213

244-
func (r InsightDismissParams) MarshalJSON() (data []byte, err error) {
245-
return apijson.MarshalRoot(r)
214+
// insightDismissResponseJSON contains the JSON metadata for the struct
215+
// [InsightDismissResponse]
216+
type insightDismissResponseJSON struct {
217+
Errors apijson.Field
218+
Messages apijson.Field
219+
Success apijson.Field
220+
raw string
221+
ExtraFields map[string]apijson.Field
222+
}
223+
224+
func (r *InsightDismissResponse) UnmarshalJSON(data []byte) (err error) {
225+
return apijson.UnmarshalRoot(data, r)
226+
}
227+
228+
func (r insightDismissResponseJSON) RawJSON() string {
229+
return r.raw
246230
}
247231

248-
type InsightGetParams struct {
232+
// Whether the API call was successful
233+
type InsightDismissResponseSuccess bool
234+
235+
const (
236+
InsightDismissResponseSuccessTrue InsightDismissResponseSuccess = true
237+
)
238+
239+
func (r InsightDismissResponseSuccess) IsKnown() bool {
240+
switch r {
241+
case InsightDismissResponseSuccessTrue:
242+
return true
243+
}
244+
return false
245+
}
246+
247+
type InsightListParams struct {
249248
// The Account ID to use for this endpoint. Mutually exclusive with the Zone ID.
250249
AccountID param.Field[string] `path:"account_id"`
251250
// The Zone ID to use for this endpoint. Mutually exclusive with the Account ID.
@@ -267,53 +266,22 @@ type InsightGetParams struct {
267266
SubjectNeq param.Field[[]string] `query:"subject~neq"`
268267
}
269268

270-
// URLQuery serializes [InsightGetParams]'s query parameters as `url.Values`.
271-
func (r InsightGetParams) URLQuery() (v url.Values) {
269+
// URLQuery serializes [InsightListParams]'s query parameters as `url.Values`.
270+
func (r InsightListParams) URLQuery() (v url.Values) {
272271
return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{
273272
ArrayFormat: apiquery.ArrayQueryFormatRepeat,
274273
NestedFormat: apiquery.NestedQueryFormatDots,
275274
})
276275
}
277276

278-
type InsightGetResponseEnvelope struct {
279-
Errors []shared.ResponseInfo `json:"errors,required"`
280-
Messages []shared.ResponseInfo `json:"messages,required"`
281-
// Whether the API call was successful
282-
Success InsightGetResponseEnvelopeSuccess `json:"success,required"`
283-
Result InsightGetResponse `json:"result"`
284-
JSON insightGetResponseEnvelopeJSON `json:"-"`
285-
}
286-
287-
// insightGetResponseEnvelopeJSON contains the JSON metadata for the struct
288-
// [InsightGetResponseEnvelope]
289-
type insightGetResponseEnvelopeJSON struct {
290-
Errors apijson.Field
291-
Messages apijson.Field
292-
Success apijson.Field
293-
Result apijson.Field
294-
raw string
295-
ExtraFields map[string]apijson.Field
296-
}
297-
298-
func (r *InsightGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) {
299-
return apijson.UnmarshalRoot(data, r)
300-
}
301-
302-
func (r insightGetResponseEnvelopeJSON) RawJSON() string {
303-
return r.raw
277+
type InsightDismissParams struct {
278+
// The Account ID to use for this endpoint. Mutually exclusive with the Zone ID.
279+
AccountID param.Field[string] `path:"account_id"`
280+
// The Zone ID to use for this endpoint. Mutually exclusive with the Account ID.
281+
ZoneID param.Field[string] `path:"zone_id"`
282+
Dismiss param.Field[bool] `json:"dismiss"`
304283
}
305284

306-
// Whether the API call was successful
307-
type InsightGetResponseEnvelopeSuccess bool
308-
309-
const (
310-
InsightGetResponseEnvelopeSuccessTrue InsightGetResponseEnvelopeSuccess = true
311-
)
312-
313-
func (r InsightGetResponseEnvelopeSuccess) IsKnown() bool {
314-
switch r {
315-
case InsightGetResponseEnvelopeSuccessTrue:
316-
return true
317-
}
318-
return false
285+
func (r InsightDismissParams) MarshalJSON() (data []byte, err error) {
286+
return apijson.MarshalRoot(r)
319287
}

‎security_center/insight_test.go

+26-26
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import (
1515
"github.com/cloudflare/cloudflare-go/v4/security_center"
1616
)
1717

18-
func TestInsightDismissWithOptionalParams(t *testing.T) {
18+
func TestInsightListWithOptionalParams(t *testing.T) {
1919
baseURL := "http://localhost:4010"
2020
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
2121
baseURL = envURL
@@ -28,14 +28,22 @@ func TestInsightDismissWithOptionalParams(t *testing.T) {
2828
option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"),
2929
option.WithAPIEmail("user@example.com"),
3030
)
31-
_, err := client.SecurityCenter.Insights.Dismiss(
32-
context.TODO(),
33-
"issue_id",
34-
security_center.InsightDismissParams{
35-
AccountID: cloudflare.F("account_id"),
36-
Dismiss: cloudflare.F(true),
37-
},
38-
)
31+
_, err := client.SecurityCenter.Insights.List(context.TODO(), security_center.InsightListParams{
32+
AccountID: cloudflare.F("account_id"),
33+
Dismissed: cloudflare.F(false),
34+
IssueClass: cloudflare.F([]string{"a_record_dangling", "always_use_https_not_enabled"}),
35+
IssueClassNeq: cloudflare.F([]string{"a_record_dangling", "always_use_https_not_enabled"}),
36+
IssueType: cloudflare.F([]intel.IssueType{intel.IssueTypeComplianceViolation, intel.IssueTypeEmailSecurity}),
37+
IssueTypeNeq: cloudflare.F([]intel.IssueType{intel.IssueTypeComplianceViolation, intel.IssueTypeEmailSecurity}),
38+
Page: cloudflare.F(int64(1)),
39+
PerPage: cloudflare.F(int64(25)),
40+
Product: cloudflare.F([]string{"access", "dns"}),
41+
ProductNeq: cloudflare.F([]string{"access", "dns"}),
42+
Severity: cloudflare.F([]intel.SeverityQueryParam{intel.SeverityQueryParamLow, intel.SeverityQueryParamModerate}),
43+
SeverityNeq: cloudflare.F([]intel.SeverityQueryParam{intel.SeverityQueryParamLow, intel.SeverityQueryParamModerate}),
44+
Subject: cloudflare.F([]string{"example.com"}),
45+
SubjectNeq: cloudflare.F([]string{"example.com"}),
46+
})
3947
if err != nil {
4048
var apierr *cloudflare.Error
4149
if errors.As(err, &apierr) {
@@ -45,7 +53,7 @@ func TestInsightDismissWithOptionalParams(t *testing.T) {
4553
}
4654
}
4755

48-
func TestInsightGetWithOptionalParams(t *testing.T) {
56+
func TestInsightDismissWithOptionalParams(t *testing.T) {
4957
baseURL := "http://localhost:4010"
5058
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
5159
baseURL = envURL
@@ -58,22 +66,14 @@ func TestInsightGetWithOptionalParams(t *testing.T) {
5866
option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"),
5967
option.WithAPIEmail("user@example.com"),
6068
)
61-
_, err := client.SecurityCenter.Insights.Get(context.TODO(), security_center.InsightGetParams{
62-
AccountID: cloudflare.F("account_id"),
63-
Dismissed: cloudflare.F(false),
64-
IssueClass: cloudflare.F([]string{"a_record_dangling", "always_use_https_not_enabled"}),
65-
IssueClassNeq: cloudflare.F([]string{"a_record_dangling", "always_use_https_not_enabled"}),
66-
IssueType: cloudflare.F([]intel.IssueType{intel.IssueTypeComplianceViolation, intel.IssueTypeEmailSecurity}),
67-
IssueTypeNeq: cloudflare.F([]intel.IssueType{intel.IssueTypeComplianceViolation, intel.IssueTypeEmailSecurity}),
68-
Page: cloudflare.F(int64(1)),
69-
PerPage: cloudflare.F(int64(25)),
70-
Product: cloudflare.F([]string{"access", "dns"}),
71-
ProductNeq: cloudflare.F([]string{"access", "dns"}),
72-
Severity: cloudflare.F([]intel.SeverityQueryParam{intel.SeverityQueryParamLow, intel.SeverityQueryParamModerate}),
73-
SeverityNeq: cloudflare.F([]intel.SeverityQueryParam{intel.SeverityQueryParamLow, intel.SeverityQueryParamModerate}),
74-
Subject: cloudflare.F([]string{"example.com"}),
75-
SubjectNeq: cloudflare.F([]string{"example.com"}),
76-
})
69+
_, err := client.SecurityCenter.Insights.Dismiss(
70+
context.TODO(),
71+
"issue_id",
72+
security_center.InsightDismissParams{
73+
AccountID: cloudflare.F("account_id"),
74+
Dismiss: cloudflare.F(true),
75+
},
76+
)
7777
if err != nil {
7878
var apierr *cloudflare.Error
7979
if errors.As(err, &apierr) {

0 commit comments

Comments
 (0)
Please sign in to comment.