-
Notifications
You must be signed in to change notification settings - Fork 12
/
owner.go
46 lines (39 loc) · 844 Bytes
/
owner.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
package opslevel
type EntityOwnerGroup struct {
Alias string `json:"alias,omitempty" graphql:"groupAlias:alias"`
Id ID `json:"id"`
}
type EntityOwnerTeam struct {
Alias string `json:"alias,omitempty" graphql:"teamAlias:alias"`
Id ID `json:"id"`
}
type EntityOwner struct {
OnGroup EntityOwnerGroup `graphql:"... on Group"`
OnTeam EntityOwnerTeam `graphql:"... on Team"`
}
func (s *EntityOwner) Alias() string {
if s.OnGroup.Id == "" {
return s.OnTeam.Alias
} else {
return s.OnGroup.Alias
}
}
func (s *EntityOwner) Id() ID {
if s.OnGroup.Id == "" {
return s.OnTeam.Id
} else {
return s.OnGroup.Id
}
}
func (s *EntityOwnerGroup) AsGroup() GroupId {
return GroupId{
Alias: s.Alias,
Id: s.Id,
}
}
func (s *EntityOwnerTeam) AsTeam() TeamId {
return TeamId{
Alias: s.Alias,
Id: s.Id,
}
}