@@ -23,19 +23,19 @@ type groupMembersResult struct {
23
23
24
24
// Group represents a Jira group
25
25
type Group struct {
26
- ID string `json:"id"`
27
- Title string `json:"title"`
28
- Type string `json:"type"`
29
- Properties groupProperties `json:"properties"`
30
- AdditionalProperties bool `json:"additionalProperties"`
26
+ Name string `json:"name,omitempty" structs:"name,omitempty"`
27
+ Self string `json:"self,omitempty" structs:"self,omitempty"`
28
+ Users GroupMembers `json:"users,omitempty" structs:"users,omitempty"`
29
+ Expand string `json:"expand,omitempty" structs:"expand,omitempty"`
31
30
}
32
31
33
- type groupProperties struct {
34
- Name groupPropertiesName `json:"name"`
35
- }
36
-
37
- type groupPropertiesName struct {
38
- Type string `json:"type"`
32
+ // GroupMembers represent members in a Jira group
33
+ type GroupMembers struct {
34
+ Size int `json:"size,omitempty" structs:"size,omitempty"`
35
+ Items []GroupMember `json:"items,omitempty" structs:"items,omitempty"`
36
+ MaxResults int `json:"max-results,omitempty" structs:"max-results.omitempty"`
37
+ StartIndex int `json:"start-index,omitempty" structs:"start-index,omitempty"`
38
+ EndIndex int `json:"end-index,omitempty" structs:"end-index,omitempty"`
39
39
}
40
40
41
41
// GroupMember reflects a single member of a group
@@ -95,18 +95,18 @@ func (s *GroupService) Get(ctx context.Context, name string, options *GroupSearc
95
95
return group .Members , resp , nil
96
96
}
97
97
98
- // Add adds user to group
98
+ // Add adds a user to a group.
99
99
//
100
- // Jira API docs: https://docs.atlassian.com/jira/REST/cloud/#api/2/group-addUserToGroup
100
+ // The account ID of the user, which uniquely identifies the user across all Atlassian products.
101
+ // For example, 5b10ac8d82e05b22cc7d4ef5.
101
102
//
102
- // TODO Double check this method if this works as expected, is using the latest API and the response is complete
103
- // This double check effort is done for v2 - Remove this two lines if this is completed.
104
- func (s * GroupService ) Add (ctx context.Context , groupname string , username string ) (* Group , * Response , error ) {
105
- apiEndpoint := fmt .Sprintf ("/rest/api/2/group/user?groupname=%s" , groupname )
103
+ // Jira API docs: https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-groups/#api-rest-api-3-group-user-post
104
+ func (s * GroupService ) AddUserByGroupName (ctx context.Context , groupName string , accountID string ) (* Group , * Response , error ) {
105
+ apiEndpoint := fmt .Sprintf ("/rest/api/3/group/user?groupname=%s" , groupName )
106
106
var user struct {
107
- Name string `json:"name "`
107
+ AccountID string `json:"accountId "`
108
108
}
109
- user .Name = username
109
+ user .AccountID = accountID
110
110
req , err := s .client .NewRequest (ctx , http .MethodPost , apiEndpoint , & user )
111
111
if err != nil {
112
112
return nil , nil , err
@@ -122,15 +122,15 @@ func (s *GroupService) Add(ctx context.Context, groupname string, username strin
122
122
return responseGroup , resp , nil
123
123
}
124
124
125
- // Remove removes user from group
125
+ // Remove removes a user from a group.
126
126
//
127
- // Jira API docs: https://docs.atlassian.com/jira/REST/cloud/#api/2/group-removeUserFromGroup
128
- // Caller must close resp.Body
127
+ // The account ID of the user, which uniquely identifies the user across all Atlassian products.
128
+ // For example, 5b10ac8d82e05b22cc7d4ef5.
129
129
//
130
- // TODO Double check this method if this works as expected, is using the latest API and the response is complete
131
- // This double check effort is done for v2 - Remove this two lines if this is completed.
132
- func (s * GroupService ) Remove (ctx context.Context , groupname string , username string ) (* Response , error ) {
133
- apiEndpoint := fmt .Sprintf ("/rest/api/2 /group/user?groupname=%s&username =%s" , groupname , username )
130
+ // Jira API docs: https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-groups/#api-rest-api-3-group-user-delete
131
+ // Caller must close resp.Body
132
+ func (s * GroupService ) RemoveUserByGroupName (ctx context.Context , groupName string , accountID string ) (* Response , error ) {
133
+ apiEndpoint := fmt .Sprintf ("/rest/api/3 /group/user?groupname=%s&accountId =%s" , groupName , accountID )
134
134
req , err := s .client .NewRequest (ctx , http .MethodDelete , apiEndpoint , nil )
135
135
if err != nil {
136
136
return nil , err
0 commit comments