From 6c9c526e2cd0ada09132feb91d4fadbe545b6d82 Mon Sep 17 00:00:00 2001 From: auyer Date: Tue, 30 Jan 2024 13:57:30 -0300 Subject: [PATCH] Adds separate struct for UpdateAccessUsersSeats This was done to abide by convention --- access_seats.go | 9 ++++++++- access_seats_test.go | 4 ++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/access_seats.go b/access_seats.go index 7c7d0f06f87..ea44eebc7b1 100644 --- a/access_seats.go +++ b/access_seats.go @@ -28,6 +28,13 @@ type UpdateAccessUserSeatParams struct { GatewaySeat *bool `json:"gateway_seat"` } +// UpdateAccessUsersSeatsParams represents the update payload for multiple access seats. +type UpdateAccessUsersSeatsParams []struct { + SeatUID string `json:"seat_uid,omitempty"` + AccessSeat *bool `json:"access_seat"` + GatewaySeat *bool `json:"gateway_seat"` +} + // AccessUserSeatResponse represents the response from the access user seat endpoints. type UpdateAccessUserSeatResponse struct { Response @@ -71,7 +78,7 @@ func (api *API) UpdateAccessUserSeat(ctx context.Context, rc *ResourceContainer, // UpdateAccessUsersSeats updates many Access User Seats. // // API documentation: https://developers.cloudflare.com/api/operations/zero-trust-seats-update-a-user-seat -func (api *API) UpdateAccessUsersSeats(ctx context.Context, rc *ResourceContainer, params []UpdateAccessUserSeatParams) ([]AccessUpdateAccessUserSeatResult, error) { +func (api *API) UpdateAccessUsersSeats(ctx context.Context, rc *ResourceContainer, params UpdateAccessUsersSeatsParams) ([]AccessUpdateAccessUserSeatResult, error) { if rc.Level != AccountRouteLevel { return []AccessUpdateAccessUserSeatResult{}, fmt.Errorf(errInvalidResourceContainerAccess, rc.Level) } diff --git a/access_seats_test.go b/access_seats_test.go index d54dbd4ec1b..90ef47511db 100644 --- a/access_seats_test.go +++ b/access_seats_test.go @@ -34,7 +34,7 @@ func TestUpdateAccessUsersSeats_MissingUID(t *testing.T) { setup() defer teardown() - _, err := client.UpdateAccessUsersSeats(context.Background(), testAccountRC, []UpdateAccessUserSeatParams{{GatewaySeat: BoolPtr(false), SeatUID: "seat_id"}, {SeatUID: "", AccessSeat: BoolPtr(true)}}) + _, err := client.UpdateAccessUsersSeats(context.Background(), testAccountRC, UpdateAccessUsersSeatsParams{{GatewaySeat: BoolPtr(false), SeatUID: "seat_id"}, {SeatUID: "", AccessSeat: BoolPtr(true)}}) assert.EqualError(t, err, "missing required access seat UID") } @@ -164,7 +164,7 @@ func TestUpdateAccessUsersSeats(t *testing.T) { }, } - actual, err := client.UpdateAccessUsersSeats(context.Background(), testAccountRC, []UpdateAccessUserSeatParams{ + actual, err := client.UpdateAccessUsersSeats(context.Background(), testAccountRC, UpdateAccessUsersSeatsParams{ { SeatUID: testAccessGroupSeatUID, AccessSeat: BoolPtr(false),