@@ -12,7 +12,6 @@ import (
12
12
"github.com/cloudflare/cloudflare-go/v4/internal/param"
13
13
"github.com/cloudflare/cloudflare-go/v4/internal/requestconfig"
14
14
"github.com/cloudflare/cloudflare-go/v4/option"
15
- "github.com/cloudflare/cloudflare-go/v4/packages/pagination"
16
15
"github.com/cloudflare/cloudflare-go/v4/shared"
17
16
)
18
17
@@ -36,30 +35,20 @@ func NewRoleService(opts ...option.RequestOption) (r *RoleService) {
36
35
}
37
36
38
37
// Get all available roles for an account.
39
- func (r * RoleService ) List (ctx context.Context , query RoleListParams , opts ... option.RequestOption ) (res * pagination. SinglePage [ shared.Role ] , err error ) {
40
- var raw * http. Response
38
+ func (r * RoleService ) List (ctx context.Context , query RoleListParams , opts ... option.RequestOption ) (res * [] shared.Role , err error ) {
39
+ var env RoleListResponseEnvelope
41
40
opts = append (r .Options [:], opts ... )
42
- opts = append ([]option.RequestOption {option .WithResponseInto (& raw )}, opts ... )
43
41
if query .AccountID .Value == "" {
44
42
err = errors .New ("missing required account_id parameter" )
45
43
return
46
44
}
47
45
path := fmt .Sprintf ("accounts/%s/roles" , query .AccountID )
48
- cfg , err := requestconfig .NewRequestConfig (ctx , http .MethodGet , path , nil , & res , opts ... )
49
- if err != nil {
50
- return nil , err
51
- }
52
- err = cfg .Execute ()
46
+ err = requestconfig .ExecuteNewRequest (ctx , http .MethodGet , path , nil , & env , opts ... )
53
47
if err != nil {
54
- return nil , err
48
+ return
55
49
}
56
- res .SetPageConfig (cfg , raw )
57
- return res , nil
58
- }
59
-
60
- // Get all available roles for an account.
61
- func (r * RoleService ) ListAutoPaging (ctx context.Context , query RoleListParams , opts ... option.RequestOption ) * pagination.SinglePageAutoPager [shared.Role ] {
62
- return pagination .NewSinglePageAutoPager (r .List (ctx , query , opts ... ))
50
+ res = & env .Result
51
+ return
63
52
}
64
53
65
54
// Get information about a specific role for an account.
@@ -88,6 +77,82 @@ type RoleListParams struct {
88
77
AccountID param.Field [string ] `path:"account_id,required"`
89
78
}
90
79
80
+ type RoleListResponseEnvelope struct {
81
+ Errors []shared.ResponseInfo `json:"errors,required"`
82
+ Messages []shared.ResponseInfo `json:"messages,required"`
83
+ // Whether the API call was successful
84
+ Success RoleListResponseEnvelopeSuccess `json:"success,required"`
85
+ Result []shared.Role `json:"result,nullable"`
86
+ ResultInfo RoleListResponseEnvelopeResultInfo `json:"result_info"`
87
+ JSON roleListResponseEnvelopeJSON `json:"-"`
88
+ }
89
+
90
+ // roleListResponseEnvelopeJSON contains the JSON metadata for the struct
91
+ // [RoleListResponseEnvelope]
92
+ type roleListResponseEnvelopeJSON struct {
93
+ Errors apijson.Field
94
+ Messages apijson.Field
95
+ Success apijson.Field
96
+ Result apijson.Field
97
+ ResultInfo apijson.Field
98
+ raw string
99
+ ExtraFields map [string ]apijson.Field
100
+ }
101
+
102
+ func (r * RoleListResponseEnvelope ) UnmarshalJSON (data []byte ) (err error ) {
103
+ return apijson .UnmarshalRoot (data , r )
104
+ }
105
+
106
+ func (r roleListResponseEnvelopeJSON ) RawJSON () string {
107
+ return r .raw
108
+ }
109
+
110
+ // Whether the API call was successful
111
+ type RoleListResponseEnvelopeSuccess bool
112
+
113
+ const (
114
+ RoleListResponseEnvelopeSuccessTrue RoleListResponseEnvelopeSuccess = true
115
+ )
116
+
117
+ func (r RoleListResponseEnvelopeSuccess ) IsKnown () bool {
118
+ switch r {
119
+ case RoleListResponseEnvelopeSuccessTrue :
120
+ return true
121
+ }
122
+ return false
123
+ }
124
+
125
+ type RoleListResponseEnvelopeResultInfo struct {
126
+ // Total number of results for the requested service
127
+ Count float64 `json:"count"`
128
+ // Current page within paginated list of results
129
+ Page float64 `json:"page"`
130
+ // Number of results per page of results
131
+ PerPage float64 `json:"per_page"`
132
+ // Total results available without any search parameters
133
+ TotalCount float64 `json:"total_count"`
134
+ JSON roleListResponseEnvelopeResultInfoJSON `json:"-"`
135
+ }
136
+
137
+ // roleListResponseEnvelopeResultInfoJSON contains the JSON metadata for the struct
138
+ // [RoleListResponseEnvelopeResultInfo]
139
+ type roleListResponseEnvelopeResultInfoJSON struct {
140
+ Count apijson.Field
141
+ Page apijson.Field
142
+ PerPage apijson.Field
143
+ TotalCount apijson.Field
144
+ raw string
145
+ ExtraFields map [string ]apijson.Field
146
+ }
147
+
148
+ func (r * RoleListResponseEnvelopeResultInfo ) UnmarshalJSON (data []byte ) (err error ) {
149
+ return apijson .UnmarshalRoot (data , r )
150
+ }
151
+
152
+ func (r roleListResponseEnvelopeResultInfoJSON ) RawJSON () string {
153
+ return r .raw
154
+ }
155
+
91
156
type RoleGetParams struct {
92
157
// Account identifier tag.
93
158
AccountID param.Field [string ] `path:"account_id,required"`
0 commit comments