@@ -14,19 +14,20 @@ type UserService service
1414
1515// User represents a Jira user.
1616type 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"`
3031}
3132
3233// UserGroup represents the group list
@@ -35,6 +36,37 @@ type UserGroup struct {
3536 Name string `json:"name,omitempty" structs:"name,omitempty"`
3637}
3738
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+
3870type userSearchParam struct {
3971 name string
4072 value string
@@ -158,23 +190,22 @@ func (s *UserService) GetGroups(ctx context.Context, accountId string) (*[]UserG
158190 return userGroups , resp , nil
159191}
160192
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.
164194//
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"
169198 req , err := s .client .NewRequest (ctx , http .MethodGet , apiEndpoint , nil )
170199 if err != nil {
171200 return nil , nil , err
172201 }
202+
173203 var user User
174204 resp , err := s .client .Do (req , & user )
175205 if err != nil {
176206 return nil , resp , NewJiraError (resp , err )
177207 }
208+
178209 return & user , resp , nil
179210}
180211
0 commit comments