Skip to content

Commit c1d6a56

Browse files
Fix: Updating Policy Boundaries may return 204 instead of 201.
1 parent c3176e1 commit c1d6a56

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

dynatrace/api/iam/boundaries/service.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -128,11 +128,11 @@ func (me *BoundaryServiceClient) Update(ctx context.Context, id string, v *bound
128128

129129
client := iam.NewIAMClient(me)
130130

131-
if responseBytes, err = client.PUT(
131+
if responseBytes, err = client.PUT_MULTI_RESPONSE(
132132
ctx,
133133
fmt.Sprintf("%s/iam/v1/repo/account/%s/boundaries/%s", me.endpointURL, strings.TrimPrefix(me.AccountID(), "urn:dtaccount:"), id),
134134
v,
135-
201,
135+
[]int{201, 204},
136136
false,
137137
); err != nil {
138138
return err

dynatrace/api/iam/iam_client.go

+5
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ func (me IAMError) Error() string {
3333
type IAMClient interface {
3434
POST(ctx context.Context, url string, payload any, expectedResponseCode int, forceNewBearer bool) ([]byte, error)
3535
PUT(ctx context.Context, url string, payload any, expectedResponseCode int, forceNewBearer bool) ([]byte, error)
36+
PUT_MULTI_RESPONSE(ctx context.Context, url string, payload any, expectedResponseCodes []int, forceNewBearer bool) ([]byte, error)
3637
GET(ctx context.Context, url string, expectedResponseCode int, forceNewBearer bool) ([]byte, error)
3738
DELETE(ctx context.Context, url string, expectedResponseCode int, forceNewBearer bool) ([]byte, error)
3839
DELETE_MULTI_RESPONSE(ctx context.Context, url string, expectedResponseCodes []int, forceNewBearer bool) ([]byte, error)
@@ -76,6 +77,10 @@ func (me *iamClient) PUT(ctx context.Context, url string, payload any, expectedR
7677
return me.request(ctx, url, http.MethodPut, []int{expectedResponseCode}, forceNewBearer, 0, payload, map[string]string{"Content-Type": "application/json"})
7778
}
7879

80+
func (me *iamClient) PUT_MULTI_RESPONSE(ctx context.Context, url string, payload any, expectedResponseCodes []int, forceNewBearer bool) ([]byte, error) {
81+
return me.request(ctx, url, http.MethodPut, expectedResponseCodes, forceNewBearer, 0, payload, map[string]string{"Content-Type": "application/json"})
82+
}
83+
7984
func (me *iamClient) GET(ctx context.Context, url string, expectedResponseCode int, forceNewBearer bool) ([]byte, error) {
8085
return me.request(ctx, url, http.MethodGet, []int{expectedResponseCode}, forceNewBearer, 0, nil, nil)
8186
}

0 commit comments

Comments
 (0)