-
Notifications
You must be signed in to change notification settings - Fork 0
/
user.go
49 lines (42 loc) · 1.04 KB
/
user.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package qsgpm
import (
"fmt"
"strings"
"github.com/aws/aws-sdk-go-v2/service/quicksight/types"
)
type User struct {
types.User
Namespace string
}
func (u *User) String() string {
return fmt.Sprintf("user<%s %s, CustomPermission:%s>", u.IdentityType, *u.UserName, viewStarString(u.CustomPermissionsName))
}
func (u *User) SessionName() string {
if u.IdentityType != types.IdentityTypeIam {
return ""
}
parts := strings.SplitAfterN(*u.UserName, "/", 2)
if len(parts) == 2 {
return parts[1]
}
return ""
}
func (u *User) IAMRoleName() string {
if u.IdentityType != types.IdentityTypeIam {
return ""
}
parts := strings.SplitAfterN(*u.UserName, "/", 2)
if len(parts) == 2 {
return strings.TrimRight(parts[0], "/")
}
return ""
}
func (u *User) IsNeedUpdateCustomPermission(customPermissionName *string) bool {
if u.CustomPermissionsName == nil && customPermissionName == nil {
return false
}
if u.CustomPermissionsName != nil && customPermissionName != nil {
return *u.CustomPermissionsName != *customPermissionName
}
return true
}