Skip to content

Commit

Permalink
Allow clearing user group users (#137)
Browse files Browse the repository at this point in the history
  • Loading branch information
deanhuynh authored Aug 12, 2024
1 parent 14b3ec3 commit 89d6e51
Showing 1 changed file with 12 additions and 14 deletions.
26 changes: 12 additions & 14 deletions internal/provider/user_group_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -352,21 +352,19 @@ func (r *userGroupResource) Update(ctx context.Context, req resource.UpdateReque
for _, member := range plan.Members {
members = append(members, member.ValueString())
}
if len(members) > 0 {
_, body, err = r.client.IAMGroupsAPI.ReplaceUsersInUserGroup(r.authContext, config.ID.ValueString()).ReplaceUsersInUserGroupV1Input(api.ReplaceUsersInUserGroupV1Input{
Emails: members,
}).Execute()
if body != nil {
defer body.Body.Close()
}
if err != nil {
resp.Diagnostics.AddError(
"Unable to add users/invites to User Group",
getError(err, body),
)
_, body, err = r.client.IAMGroupsAPI.ReplaceUsersInUserGroup(r.authContext, config.ID.ValueString()).ReplaceUsersInUserGroupV1Input(api.ReplaceUsersInUserGroupV1Input{
Emails: members,
}).Execute()
if body != nil {
defer body.Body.Close()
}
if err != nil {
resp.Diagnostics.AddError(
"Unable to add users/invites to User Group",
getError(err, body),
)

return
}
return
}

getOut, body, err := r.client.IAMGroupsAPI.GetUserGroup(r.authContext, config.ID.ValueString()).Execute()
Expand Down

0 comments on commit 89d6e51

Please sign in to comment.