Skip to content

Commit adea168

Browse files
authored
feat(iam): new method to add group members (#1694)
1 parent c9ad832 commit adea168

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

api/iam/v1alpha1/iam_sdk.go

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1532,6 +1532,44 @@ func (s *API) AddGroupMember(req *AddGroupMemberRequest, opts ...scw.RequestOpti
15321532
return &resp, nil
15331533
}
15341534

1535+
type AddGroupMembersRequest struct {
1536+
// GroupID: ID of the group.
1537+
GroupID string `json:"-"`
1538+
// UserIDs: iDs of the users to add.
1539+
UserIDs []string `json:"user_ids"`
1540+
// ApplicationIDs: iDs of the applications to add.
1541+
ApplicationIDs []string `json:"application_ids"`
1542+
}
1543+
1544+
// AddGroupMembers: add multiple users and applications to a group.
1545+
// Add multiple users and applications to a group in a single call. You can specify an array of `user_id`s and `application_id`s. Note that any existing users and applications in the group will remain. To add new users/applications and delete pre-existing ones, use the [Overwrite users and applications of a group](#path-groups-overwrite-users-and-applications-of-a-group) method.
1546+
func (s *API) AddGroupMembers(req *AddGroupMembersRequest, opts ...scw.RequestOption) (*Group, error) {
1547+
var err error
1548+
1549+
if fmt.Sprint(req.GroupID) == "" {
1550+
return nil, errors.New("field GroupID cannot be empty in request")
1551+
}
1552+
1553+
scwReq := &scw.ScalewayRequest{
1554+
Method: "POST",
1555+
Path: "/iam/v1alpha1/groups/" + fmt.Sprint(req.GroupID) + "/add-members",
1556+
Headers: http.Header{},
1557+
}
1558+
1559+
err = scwReq.SetBody(req)
1560+
if err != nil {
1561+
return nil, err
1562+
}
1563+
1564+
var resp Group
1565+
1566+
err = s.client.Do(scwReq, &resp, opts...)
1567+
if err != nil {
1568+
return nil, err
1569+
}
1570+
return &resp, nil
1571+
}
1572+
15351573
type RemoveGroupMemberRequest struct {
15361574
// GroupID: ID of the group.
15371575
GroupID string `json:"-"`

0 commit comments

Comments
 (0)