@@ -5,6 +5,7 @@ package clients
55
66import (
77 "github.com/cenkalti/backoff/v4"
8+ sharedmodels "github.com/hashicorp/hcp-sdk-go/clients/cloud-shared/v1/models"
89
910 "github.com/hashicorp/hcp-sdk-go/clients/cloud-iam/stable/2019-12-10/client/groups_service"
1011)
@@ -19,7 +20,14 @@ func CreateGroupRetry(client *Client, params *groups_service.GroupsServiceCreate
1920 op := func () error {
2021 var err error
2122 res , err = client .Groups .GroupsServiceCreateGroup (params , nil )
22- return err
23+ if err != nil {
24+ return err
25+ }
26+ if res .Payload .OperationID != "" {
27+ loc := & sharedmodels.HashicorpCloudLocationLocation {OrganizationID : client .Config .OrganizationID }
28+ return WaitForOperation (params .Context , client , "create group" , loc , res .Payload .OperationID )
29+ }
30+ return nil
2331 }
2432
2533 serviceErr := & groups_service.GroupsServiceCreateGroupDefault {}
@@ -34,7 +42,14 @@ func UpdateGroupRetry(client *Client, params *groups_service.GroupsServiceUpdate
3442 op := func () error {
3543 var err error
3644 res , err = client .Groups .GroupsServiceUpdateGroup2 (params , nil )
37- return err
45+ if err != nil {
46+ return err
47+ }
48+ if res .Payload .OperationID != "" {
49+ loc := & sharedmodels.HashicorpCloudLocationLocation {OrganizationID : client .Config .OrganizationID }
50+ return WaitForOperation (params .Context , client , "update group" , loc , res .Payload .OperationID )
51+ }
52+ return nil
3853 }
3954
4055 serviceErr := & groups_service.GroupsServiceUpdateGroup2Default {}
@@ -49,7 +64,14 @@ func DeleteGroupRetry(client *Client, params *groups_service.GroupsServiceDelete
4964 op := func () error {
5065 var err error
5166 res , err = client .Groups .GroupsServiceDeleteGroup (params , nil )
52- return err
67+ if err != nil {
68+ return err
69+ }
70+ if res .Payload .OperationID != "" {
71+ loc := & sharedmodels.HashicorpCloudLocationLocation {OrganizationID : client .Config .OrganizationID }
72+ return WaitForOperation (params .Context , client , "delete group" , loc , res .Payload .OperationID )
73+ }
74+ return nil
5375 }
5476
5577 serviceErr := & groups_service.GroupsServiceDeleteGroupDefault {}
@@ -66,7 +88,14 @@ func UpdateGroupMembersRetry(client *Client, params *groups_service.GroupsServic
6688 op := func () error {
6789 var err error
6890 res , err = client .Groups .GroupsServiceUpdateGroupMembers (params , nil )
69- return err
91+ if err != nil {
92+ return err
93+ }
94+ if res .Payload .OperationID != "" {
95+ loc := & sharedmodels.HashicorpCloudLocationLocation {OrganizationID : client .Config .OrganizationID }
96+ return WaitForOperation (params .Context , client , "update group members" , loc , res .Payload .OperationID )
97+ }
98+ return nil
7099 }
71100
72101 serviceErr := & groups_service.GroupsServiceUpdateGroupMembersDefault {}
0 commit comments