Skip to content

Commit 0930c13

Browse files
fankclaude
andcommitted
fix(confluence): correct restriction API endpoint paths
- Fixed comment typo: GET endpoint is /restriction/byOperation not /restriction - Fixed group restriction endpoints to consistently use /byGroupId/ path - Removed unnecessary UUID detection logic for group IDs - Updated tests to match correct API endpoint patterns - Removed unused imports (uuid, strings packages) All group restriction endpoints now use the standard /byGroupId/{groupId} pattern as specified in the OpenAPI spec, regardless of whether a group name or ID is provided. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 2775a6b commit 0930c13

3 files changed

Lines changed: 13 additions & 48 deletions

File tree

confluence/internal/restriction_operation_content_impl.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ type RestrictionOperationService struct {
3939
//
4040
// of the return object, rather than items in a results array.
4141
//
42-
// GET /wiki/rest/api/content/{id}/restriction
42+
// GET /wiki/rest/api/content/{id}/restriction/byOperation
4343
//
4444
// https://docs.go-atlassian.io/confluence-cloud/content/restrictions/operations#get-restrictions-by-operation
4545
func (r *RestrictionOperationService) Gets(ctx context.Context, contentID string, expand []string) (*model.ContentRestrictionByOperationScheme, *model.ResponseScheme, error) {

confluence/internal/restriction_operation_group_content_impl.go

Lines changed: 6 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,7 @@ import (
66
model "github.com/ctreminiom/go-atlassian/v2/pkg/infra/models"
77
"github.com/ctreminiom/go-atlassian/v2/service"
88
"github.com/ctreminiom/go-atlassian/v2/service/confluence"
9-
"github.com/google/uuid"
109
"net/http"
11-
"strings"
1210
)
1311

1412
// NewRestrictionOperationGroupService creates a new instance of RestrictionOperationGroupService.
@@ -78,20 +76,9 @@ func (i *internalRestrictionOperationGroupImpl) Get(ctx context.Context, content
7876
return nil, fmt.Errorf("confluence: %w", model.ErrNoConfluenceGroup)
7977
}
8078

81-
var endpoint strings.Builder
82-
endpoint.WriteString(fmt.Sprintf("wiki/rest/api/content/%v/restriction/byOperation/%v/", contentID, operationKey))
79+
endpoint := fmt.Sprintf("wiki/rest/api/content/%v/restriction/byOperation/%v/byGroupId/%v", contentID, operationKey, groupNameOrID)
8380

84-
// check if the group id is an uuid type
85-
// if so, it's the group id
86-
groupID, err := uuid.Parse(groupNameOrID)
87-
88-
if err == nil {
89-
endpoint.WriteString(fmt.Sprintf("byGroupId/%v", groupID.String()))
90-
} else {
91-
endpoint.WriteString(fmt.Sprintf("group/%v", groupNameOrID))
92-
}
93-
94-
request, err := i.c.NewRequest(ctx, http.MethodGet, endpoint.String(), "", nil)
81+
request, err := i.c.NewRequest(ctx, http.MethodGet, endpoint, "", nil)
9582
if err != nil {
9683
return nil, err
9784
}
@@ -113,20 +100,9 @@ func (i *internalRestrictionOperationGroupImpl) Add(ctx context.Context, content
113100
return nil, fmt.Errorf("confluence: %w", model.ErrNoConfluenceGroup)
114101
}
115102

116-
var endpoint strings.Builder
117-
endpoint.WriteString(fmt.Sprintf("wiki/rest/api/content/%v/restriction/byOperation/%v/", contentID, operationKey))
103+
endpoint := fmt.Sprintf("wiki/rest/api/content/%v/restriction/byOperation/%v/byGroupId/%v", contentID, operationKey, groupNameOrID)
118104

119-
// check if the group id is an uuid type
120-
// if so, it's the group id
121-
groupID, err := uuid.Parse(groupNameOrID)
122-
123-
if err == nil {
124-
endpoint.WriteString(fmt.Sprintf("byGroupId/%v", groupID.String()))
125-
} else {
126-
endpoint.WriteString(fmt.Sprintf("group/%v", groupNameOrID))
127-
}
128-
129-
request, err := i.c.NewRequest(ctx, http.MethodPut, endpoint.String(), "", nil)
105+
request, err := i.c.NewRequest(ctx, http.MethodPut, endpoint, "", nil)
130106
if err != nil {
131107
return nil, err
132108
}
@@ -148,20 +124,9 @@ func (i *internalRestrictionOperationGroupImpl) Remove(ctx context.Context, cont
148124
return nil, fmt.Errorf("confluence: %w", model.ErrNoConfluenceGroup)
149125
}
150126

151-
var endpoint strings.Builder
152-
endpoint.WriteString(fmt.Sprintf("wiki/rest/api/content/%v/restriction/byOperation/%v/", contentID, operationKey))
153-
154-
// check if the group id is an uuid type
155-
// if so, it's the group id
156-
groupID, err := uuid.Parse(groupNameOrID)
157-
158-
if err == nil {
159-
endpoint.WriteString(fmt.Sprintf("byGroupId/%v", groupID.String()))
160-
} else {
161-
endpoint.WriteString(fmt.Sprintf("group/%v", groupNameOrID))
162-
}
127+
endpoint := fmt.Sprintf("wiki/rest/api/content/%v/restriction/byOperation/%v/byGroupId/%v", contentID, operationKey, groupNameOrID)
163128

164-
request, err := i.c.NewRequest(ctx, http.MethodDelete, endpoint.String(), "", nil)
129+
request, err := i.c.NewRequest(ctx, http.MethodDelete, endpoint, "", nil)
165130
if err != nil {
166131
return nil, err
167132
}

confluence/internal/restriction_operation_group_content_impl_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ func Test_internalRestrictionOperationGroupImpl_Get(t *testing.T) {
4747
client.On("NewRequest",
4848
context.Background(),
4949
http.MethodGet,
50-
"wiki/rest/api/content/100001/restriction/byOperation/read/group/confluence-users",
50+
"wiki/rest/api/content/100001/restriction/byOperation/read/byGroupId/confluence-users",
5151
"", nil).
5252
Return(&http.Request{}, nil)
5353

@@ -76,7 +76,7 @@ func Test_internalRestrictionOperationGroupImpl_Get(t *testing.T) {
7676
client.On("NewRequest",
7777
context.Background(),
7878
http.MethodGet,
79-
"wiki/rest/api/content/100001/restriction/byOperation/read/group/confluence-users",
79+
"wiki/rest/api/content/100001/restriction/byOperation/read/byGroupId/confluence-users",
8080
"", nil).
8181
Return(&http.Request{}, model.ErrCreateHttpReq)
8282

@@ -188,7 +188,7 @@ func Test_internalRestrictionOperationGroupImpl_Add(t *testing.T) {
188188
client.On("NewRequest",
189189
context.Background(),
190190
http.MethodPut,
191-
"wiki/rest/api/content/100001/restriction/byOperation/read/group/confluence-users",
191+
"wiki/rest/api/content/100001/restriction/byOperation/read/byGroupId/confluence-users",
192192
"", nil).
193193
Return(&http.Request{}, nil)
194194

@@ -217,7 +217,7 @@ func Test_internalRestrictionOperationGroupImpl_Add(t *testing.T) {
217217
client.On("NewRequest",
218218
context.Background(),
219219
http.MethodPut,
220-
"wiki/rest/api/content/100001/restriction/byOperation/read/group/confluence-users",
220+
"wiki/rest/api/content/100001/restriction/byOperation/read/byGroupId/confluence-users",
221221
"", nil).
222222
Return(&http.Request{}, model.ErrCreateHttpReq)
223223

@@ -329,7 +329,7 @@ func Test_internalRestrictionOperationGroupImpl_Remove(t *testing.T) {
329329
client.On("NewRequest",
330330
context.Background(),
331331
http.MethodDelete,
332-
"wiki/rest/api/content/100001/restriction/byOperation/read/group/confluence-users",
332+
"wiki/rest/api/content/100001/restriction/byOperation/read/byGroupId/confluence-users",
333333
"", nil).
334334
Return(&http.Request{}, nil)
335335

@@ -387,7 +387,7 @@ func Test_internalRestrictionOperationGroupImpl_Remove(t *testing.T) {
387387
client.On("NewRequest",
388388
context.Background(),
389389
http.MethodDelete,
390-
"wiki/rest/api/content/100001/restriction/byOperation/read/group/confluence-users",
390+
"wiki/rest/api/content/100001/restriction/byOperation/read/byGroupId/confluence-users",
391391
"", nil).
392392
Return(&http.Request{}, model.ErrCreateHttpReq)
393393

0 commit comments

Comments
 (0)