2023-03-21 09:58:16 +00:00
|
|
|
package resources
|
|
|
|
|
2024-10-10 13:16:06 +00:00
|
|
|
import "fmt"
|
|
|
|
|
2023-03-21 09:58:16 +00:00
|
|
|
// Permission holds the permission level setting for a single principal.
|
|
|
|
// Multiple of these can be defined on any resource.
|
|
|
|
type Permission struct {
|
|
|
|
Level string `json:"level"`
|
|
|
|
|
|
|
|
UserName string `json:"user_name,omitempty"`
|
|
|
|
ServicePrincipalName string `json:"service_principal_name,omitempty"`
|
|
|
|
GroupName string `json:"group_name,omitempty"`
|
|
|
|
}
|
2024-10-10 13:16:06 +00:00
|
|
|
|
|
|
|
func (p Permission) String() string {
|
|
|
|
if p.UserName != "" {
|
|
|
|
return fmt.Sprintf("level: %s, user_name: %s", p.Level, p.UserName)
|
|
|
|
}
|
|
|
|
|
|
|
|
if p.ServicePrincipalName != "" {
|
|
|
|
return fmt.Sprintf("level: %s, service_principal_name: %s", p.Level, p.ServicePrincipalName)
|
|
|
|
}
|
|
|
|
|
|
|
|
if p.GroupName != "" {
|
|
|
|
return fmt.Sprintf("level: %s, group_name: %s", p.Level, p.GroupName)
|
|
|
|
}
|
|
|
|
|
|
|
|
return fmt.Sprintf("level: %s", p.Level)
|
|
|
|
}
|