@@ -14,19 +14,20 @@ type UserService service
14
14
15
15
// User represents a Jira user.
16
16
type User struct {
17
- Self string `json:"self,omitempty" structs:"self,omitempty"`
18
- AccountID string `json:"accountId,omitempty" structs:"accountId,omitempty"`
19
- AccountType string `json:"accountType,omitempty" structs:"accountType,omitempty"`
20
- Name string `json:"name,omitempty" structs:"name,omitempty"`
21
- Key string `json:"key,omitempty" structs:"key,omitempty"`
22
- Password string `json:"-"`
23
- EmailAddress string `json:"emailAddress,omitempty" structs:"emailAddress,omitempty"`
24
- AvatarUrls AvatarUrls `json:"avatarUrls,omitempty" structs:"avatarUrls,omitempty"`
25
- DisplayName string `json:"displayName,omitempty" structs:"displayName,omitempty"`
26
- Active bool `json:"active,omitempty" structs:"active,omitempty"`
27
- TimeZone string `json:"timeZone,omitempty" structs:"timeZone,omitempty"`
28
- Locale string `json:"locale,omitempty" structs:"locale,omitempty"`
29
- ApplicationKeys []string `json:"applicationKeys,omitempty" structs:"applicationKeys,omitempty"`
17
+ Self string `json:"self,omitempty" structs:"self,omitempty"`
18
+ AccountID string `json:"accountId,omitempty" structs:"accountId,omitempty"`
19
+ AccountType string `json:"accountType,omitempty" structs:"accountType,omitempty"`
20
+ Name string `json:"name,omitempty" structs:"name,omitempty"`
21
+ Key string `json:"key,omitempty" structs:"key,omitempty"`
22
+ Password string `json:"-"`
23
+ EmailAddress string `json:"emailAddress,omitempty" structs:"emailAddress,omitempty"`
24
+ AvatarUrls AvatarUrls `json:"avatarUrls,omitempty" structs:"avatarUrls,omitempty"`
25
+ DisplayName string `json:"displayName,omitempty" structs:"displayName,omitempty"`
26
+ Active bool `json:"active,omitempty" structs:"active,omitempty"`
27
+ TimeZone string `json:"timeZone,omitempty" structs:"timeZone,omitempty"`
28
+ Locale string `json:"locale,omitempty" structs:"locale,omitempty"`
29
+ Groups UserGroups `json:"groups,omitempty" structs:"groups,omitempty"`
30
+ ApplicationRoles ApplicationRoles `json:"applicationRoles,omitempty" structs:"applicationRoles,omitempty"`
30
31
}
31
32
32
33
// UserGroup represents the group list
@@ -35,6 +36,37 @@ type UserGroup struct {
35
36
Name string `json:"name,omitempty" structs:"name,omitempty"`
36
37
}
37
38
39
+ // Groups is a wrapper for UserGroup
40
+ type UserGroups struct {
41
+ Size int `json:"size,omitempty" structs:"size,omitempty"`
42
+ Items []UserGroup `json:"items,omitempty" structs:"items,omitempty"`
43
+ }
44
+
45
+ // ApplicationRoles is a wrapper for ApplicationRole
46
+ type ApplicationRoles struct {
47
+ Size int `json:"size,omitempty" structs:"size,omitempty"`
48
+ Items []ApplicationRole `json:"items,omitempty" structs:"items,omitempty"`
49
+ }
50
+
51
+ // ApplicationRole represents a role assigned to a user
52
+ type ApplicationRole struct {
53
+ Key string `json:"key"`
54
+ Groups []string `json:"groups"`
55
+ Name string `json:"name"`
56
+ DefaultGroups []string `json:"defaultGroups"`
57
+ SelectedByDefault bool `json:"selectedByDefault"`
58
+ Defined bool `json:"defined"`
59
+ NumberOfSeats int `json:"numberOfSeats"`
60
+ RemainingSeats int `json:"remainingSeats"`
61
+ UserCount int `json:"userCount"`
62
+ UserCountDescription string `json:"userCountDescription"`
63
+ HasUnlimitedSeats bool `json:"hasUnlimitedSeats"`
64
+ Platform bool `json:"platform"`
65
+
66
+ // Key `groupDetails` missing - https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-application-roles/#api-rest-api-3-applicationrole-key-get
67
+ // Key `defaultGroupsDetails` missing - https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-application-roles/#api-rest-api-3-applicationrole-key-get
68
+ }
69
+
38
70
type userSearchParam struct {
39
71
name string
40
72
value string
@@ -158,23 +190,22 @@ func (s *UserService) GetGroups(ctx context.Context, accountId string) (*[]UserG
158
190
return userGroups , resp , nil
159
191
}
160
192
161
- // GetSelf information about the current logged-in user
162
- //
163
- // Jira API docs: https://developer.atlassian.com/cloud/jira/platform/rest/v2/#api-rest-api-2-myself-get
193
+ // GetCurrentUser returns details for the current user.
164
194
//
165
- // TODO Double check this method if this works as expected, is using the latest API and the response is complete
166
- // This double check effort is done for v2 - Remove this two lines if this is completed.
167
- func (s * UserService ) GetSelf (ctx context.Context ) (* User , * Response , error ) {
168
- const apiEndpoint = "rest/api/2/myself"
195
+ // Jira API docs: https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-myself/#api-rest-api-3-myself-get
196
+ func (s * UserService ) GetCurrentUser (ctx context.Context ) (* User , * Response , error ) {
197
+ const apiEndpoint = "rest/api/3/myself"
169
198
req , err := s .client .NewRequest (ctx , http .MethodGet , apiEndpoint , nil )
170
199
if err != nil {
171
200
return nil , nil , err
172
201
}
202
+
173
203
var user User
174
204
resp , err := s .client .Do (req , & user )
175
205
if err != nil {
176
206
return nil , resp , NewJiraError (resp , err )
177
207
}
208
+
178
209
return & user , resp , nil
179
210
}
180
211
0 commit comments