2022-03-31 15:18:48 +00:00
|
|
|
package responses
|
|
|
|
|
|
|
|
import "encoding/xml"
|
|
|
|
|
|
|
|
type GetCallerIdentityResponse struct {
|
|
|
|
XMLName xml.Name `xml:"GetCallerIdentityResponse"`
|
|
|
|
GetCallerIdentityResult []GetCallerIdentityResult `xml:"GetCallerIdentityResult"`
|
|
|
|
ResponseMetadata []ResponseMetadata `xml:"ResponseMetadata"`
|
|
|
|
}
|
|
|
|
|
|
|
|
type GetCallerIdentityResult struct {
|
|
|
|
Arn string `xml:"Arn"`
|
|
|
|
UserId string `xml:"UserId"`
|
|
|
|
Account string `xml:"Account"`
|
|
|
|
}
|
|
|
|
|
|
|
|
type ResponseMetadata struct {
|
|
|
|
RequestId string `xml:"RequestId"`
|
|
|
|
}
|
|
|
|
|
|
|
|
// IAMEntity is an interface for getting details from an IAM Role or User.
|
|
|
|
type IAMEntity interface {
|
|
|
|
EntityPath() string
|
|
|
|
EntityArn() string
|
|
|
|
EntityName() string
|
|
|
|
EntityId() string
|
|
|
|
EntityTags() map[string]string
|
|
|
|
}
|
|
|
|
|
|
|
|
var _ IAMEntity = (*Role)(nil)
|
|
|
|
var _ IAMEntity = (*User)(nil)
|
|
|
|
|
|
|
|
type GetRoleResponse struct {
|
|
|
|
XMLName xml.Name `xml:"GetRoleResponse"`
|
|
|
|
GetRoleResult []GetRoleResult `xml:"GetRoleResult"`
|
|
|
|
ResponseMetadata []ResponseMetadata `xml:"ResponseMetadata"`
|
|
|
|
}
|
|
|
|
|
|
|
|
type GetRoleResult struct {
|
|
|
|
Role Role `xml:"Role"`
|
|
|
|
}
|
|
|
|
|
|
|
|
type Role struct {
|
|
|
|
Arn string `xml:"Arn"`
|
|
|
|
Path string `xml:"Path"`
|
|
|
|
RoleId string `xml:"RoleId"`
|
|
|
|
RoleName string `xml:"RoleName"`
|
2022-04-14 21:45:35 +00:00
|
|
|
Tags Tags `xml:"Tags"`
|
2022-03-31 15:18:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (r *Role) EntityPath() string { return r.Path }
|
|
|
|
func (r *Role) EntityArn() string { return r.Arn }
|
|
|
|
func (r *Role) EntityName() string { return r.RoleName }
|
|
|
|
func (r *Role) EntityId() string { return r.RoleId }
|
|
|
|
func (r *Role) EntityTags() map[string]string { return tagsToMap(r.Tags) }
|
|
|
|
|
|
|
|
type GetUserResponse struct {
|
|
|
|
XMLName xml.Name `xml:"GetUserResponse"`
|
|
|
|
GetUserResult []GetUserResult `xml:"GetUserResult"`
|
|
|
|
ResponseMetadata []ResponseMetadata `xml:"ResponseMetadata"`
|
|
|
|
}
|
|
|
|
|
|
|
|
type GetUserResult struct {
|
|
|
|
User User `xml:"User"`
|
|
|
|
}
|
|
|
|
|
|
|
|
type User struct {
|
|
|
|
Arn string `xml:"Arn"`
|
|
|
|
Path string `xml:"Path"`
|
|
|
|
UserId string `xml:"UserId"`
|
|
|
|
UserName string `xml:"UserName"`
|
2022-04-14 21:45:35 +00:00
|
|
|
Tags Tags `xml:"Tags"`
|
2022-03-31 15:18:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (u *User) EntityPath() string { return u.Path }
|
|
|
|
func (u *User) EntityArn() string { return u.Arn }
|
|
|
|
func (u *User) EntityName() string { return u.UserName }
|
|
|
|
func (u *User) EntityId() string { return u.UserId }
|
|
|
|
func (u *User) EntityTags() map[string]string { return tagsToMap(u.Tags) }
|
|
|
|
|
2022-04-14 21:45:35 +00:00
|
|
|
type Tags struct {
|
|
|
|
Members []TagMember `xml:"member"`
|
|
|
|
}
|
|
|
|
|
|
|
|
type TagMember struct {
|
2022-03-31 15:18:48 +00:00
|
|
|
Key string `xml:"Key"`
|
|
|
|
Value string `xml:"Value"`
|
|
|
|
}
|
|
|
|
|
2022-04-14 21:45:35 +00:00
|
|
|
func tagsToMap(tags Tags) map[string]string {
|
2022-03-31 15:18:48 +00:00
|
|
|
result := map[string]string{}
|
2022-04-14 21:45:35 +00:00
|
|
|
for _, tag := range tags.Members {
|
2022-03-31 15:18:48 +00:00
|
|
|
result[tag.Key] = tag.Value
|
|
|
|
}
|
|
|
|
return result
|
|
|
|
}
|