@@ -7,8 +7,10 @@ import (
7
7
"errors"
8
8
"fmt"
9
9
"net/http"
10
+ "net/url"
10
11
11
12
"github.com/cloudflare/cloudflare-go/v4/internal/apijson"
13
+ "github.com/cloudflare/cloudflare-go/v4/internal/apiquery"
12
14
"github.com/cloudflare/cloudflare-go/v4/internal/param"
13
15
"github.com/cloudflare/cloudflare-go/v4/internal/requestconfig"
14
16
"github.com/cloudflare/cloudflare-go/v4/option"
@@ -36,16 +38,16 @@ func NewRoleService(opts ...option.RequestOption) (r *RoleService) {
36
38
}
37
39
38
40
// 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 ) {
41
+ func (r * RoleService ) List (ctx context.Context , params RoleListParams , opts ... option.RequestOption ) (res * pagination.V4PagePaginationArray [shared.Role ], err error ) {
40
42
var raw * http.Response
41
43
opts = append (r .Options [:], opts ... )
42
44
opts = append ([]option.RequestOption {option .WithResponseInto (& raw )}, opts ... )
43
- if query .AccountID .Value == "" {
45
+ if params .AccountID .Value == "" {
44
46
err = errors .New ("missing required account_id parameter" )
45
47
return
46
48
}
47
- path := fmt .Sprintf ("accounts/%s/roles" , query .AccountID )
48
- cfg , err := requestconfig .NewRequestConfig (ctx , http .MethodGet , path , nil , & res , opts ... )
49
+ path := fmt .Sprintf ("accounts/%s/roles" , params .AccountID )
50
+ cfg , err := requestconfig .NewRequestConfig (ctx , http .MethodGet , path , params , & res , opts ... )
49
51
if err != nil {
50
52
return nil , err
51
53
}
@@ -58,8 +60,8 @@ func (r *RoleService) List(ctx context.Context, query RoleListParams, opts ...op
58
60
}
59
61
60
62
// 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 ... ))
63
+ func (r * RoleService ) ListAutoPaging (ctx context.Context , params RoleListParams , opts ... option.RequestOption ) * pagination.V4PagePaginationArrayAutoPager [shared.Role ] {
64
+ return pagination .NewV4PagePaginationArrayAutoPager (r .List (ctx , params , opts ... ))
63
65
}
64
66
65
67
// Get information about a specific role for an account.
@@ -86,6 +88,18 @@ func (r *RoleService) Get(ctx context.Context, roleID string, query RoleGetParam
86
88
type RoleListParams struct {
87
89
// Account identifier tag.
88
90
AccountID param.Field [string ] `path:"account_id,required"`
91
+ // Page number of paginated results.
92
+ Page param.Field [float64 ] `query:"page"`
93
+ // Number of roles per page.
94
+ PerPage param.Field [float64 ] `query:"per_page"`
95
+ }
96
+
97
+ // URLQuery serializes [RoleListParams]'s query parameters as `url.Values`.
98
+ func (r RoleListParams ) URLQuery () (v url.Values ) {
99
+ return apiquery .MarshalWithSettings (r , apiquery.QuerySettings {
100
+ ArrayFormat : apiquery .ArrayQueryFormatRepeat ,
101
+ NestedFormat : apiquery .NestedQueryFormatDots ,
102
+ })
89
103
}
90
104
91
105
type RoleGetParams struct {
0 commit comments