@@ -7,12 +7,15 @@ import (
7
7
"errors"
8
8
"fmt"
9
9
"net/http"
10
+ "net/url"
10
11
"time"
11
12
12
13
"github.com/cloudflare/cloudflare-go/v4/internal/apijson"
14
+ "github.com/cloudflare/cloudflare-go/v4/internal/apiquery"
13
15
"github.com/cloudflare/cloudflare-go/v4/internal/param"
14
16
"github.com/cloudflare/cloudflare-go/v4/internal/requestconfig"
15
17
"github.com/cloudflare/cloudflare-go/v4/option"
18
+ "github.com/cloudflare/cloudflare-go/v4/packages/pagination"
16
19
)
17
20
18
21
// WaitingRoomService contains methods and other services that help with
@@ -82,6 +85,47 @@ func (r *WaitingRoomService) Update(ctx context.Context, waitingRoomID string, p
82
85
return
83
86
}
84
87
88
+ // Lists waiting rooms for account or zone.
89
+ func (r * WaitingRoomService ) List (ctx context.Context , params WaitingRoomListParams , opts ... option.RequestOption ) (res * pagination.V4PagePaginationArray [WaitingRoom ], err error ) {
90
+ var raw * http.Response
91
+ opts = append (r .Options [:], opts ... )
92
+ opts = append ([]option.RequestOption {option .WithResponseInto (& raw )}, opts ... )
93
+ var accountOrZone string
94
+ var accountOrZoneID param.Field [string ]
95
+ if params .AccountID .Value != "" && params .ZoneID .Value != "" {
96
+ err = errors .New ("account ID and zone ID are mutually exclusive" )
97
+ return
98
+ }
99
+ if params .AccountID .Value == "" && params .ZoneID .Value == "" {
100
+ err = errors .New ("either account ID or zone ID must be provided" )
101
+ return
102
+ }
103
+ if params .AccountID .Value != "" {
104
+ accountOrZone = "accounts"
105
+ accountOrZoneID = params .AccountID
106
+ }
107
+ if params .ZoneID .Value != "" {
108
+ accountOrZone = "zones"
109
+ accountOrZoneID = params .ZoneID
110
+ }
111
+ path := fmt .Sprintf ("%s/%s/waiting_rooms" , accountOrZone , accountOrZoneID )
112
+ cfg , err := requestconfig .NewRequestConfig (ctx , http .MethodGet , path , params , & res , opts ... )
113
+ if err != nil {
114
+ return nil , err
115
+ }
116
+ err = cfg .Execute ()
117
+ if err != nil {
118
+ return nil , err
119
+ }
120
+ res .SetPageConfig (cfg , raw )
121
+ return res , nil
122
+ }
123
+
124
+ // Lists waiting rooms for account or zone.
125
+ func (r * WaitingRoomService ) ListAutoPaging (ctx context.Context , params WaitingRoomListParams , opts ... option.RequestOption ) * pagination.V4PagePaginationArrayAutoPager [WaitingRoom ] {
126
+ return pagination .NewV4PagePaginationArrayAutoPager (r .List (ctx , params , opts ... ))
127
+ }
128
+
85
129
// Deletes a waiting room.
86
130
func (r * WaitingRoomService ) Delete (ctx context.Context , waitingRoomID string , body WaitingRoomDeleteParams , opts ... option.RequestOption ) (res * WaitingRoomDeleteResponse , err error ) {
87
131
var env WaitingRoomDeleteResponseEnvelope
@@ -1305,6 +1349,25 @@ func (r waitingRoomUpdateResponseEnvelopeJSON) RawJSON() string {
1305
1349
return r .raw
1306
1350
}
1307
1351
1352
+ type WaitingRoomListParams struct {
1353
+ // The Account ID to use for this endpoint. Mutually exclusive with the Zone ID.
1354
+ AccountID param.Field [string ] `path:"account_id"`
1355
+ // The Zone ID to use for this endpoint. Mutually exclusive with the Account ID.
1356
+ ZoneID param.Field [string ] `path:"zone_id"`
1357
+ // Page number of paginated results.
1358
+ Page param.Field [float64 ] `query:"page"`
1359
+ // Maximum number of results per page. Must be a multiple of 5.
1360
+ PerPage param.Field [float64 ] `query:"per_page"`
1361
+ }
1362
+
1363
+ // URLQuery serializes [WaitingRoomListParams]'s query parameters as `url.Values`.
1364
+ func (r WaitingRoomListParams ) URLQuery () (v url.Values ) {
1365
+ return apiquery .MarshalWithSettings (r , apiquery.QuerySettings {
1366
+ ArrayFormat : apiquery .ArrayQueryFormatRepeat ,
1367
+ NestedFormat : apiquery .NestedQueryFormatDots ,
1368
+ })
1369
+ }
1370
+
1308
1371
type WaitingRoomDeleteParams struct {
1309
1372
// Identifier
1310
1373
ZoneID param.Field [string ] `path:"zone_id,required"`
0 commit comments