-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathytsaurus_models.go
54 lines (44 loc) · 1.23 KB
/
ytsaurus_models.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
50
51
52
53
54
package main
import (
"time"
)
type YtsaurusUser struct {
// Username is a unique @name attribute of a user.
Username string
SourceRaw map[string]any
BannedSince time.Time
}
// IsManuallyManaged true if user doesn't have @azure attribute (system or manually created user).
func (u YtsaurusUser) IsManuallyManaged() bool {
return u.SourceRaw == nil
}
func (u YtsaurusUser) IsBanned() bool {
return !u.BannedSince.IsZero()
}
func (u YtsaurusUser) BannedSinceString() string {
if u.BannedSince.IsZero() {
return ""
}
return u.BannedSince.Format(appTimeFormat)
}
type YtsaurusGroup struct {
// Name is a unique @name attribute of a group.
Name string
SourceRaw map[string]any
}
// IsManuallyManaged true if group doesn't have @azure attribute (system or manually created group).
func (g YtsaurusGroup) IsManuallyManaged() bool {
return g.SourceRaw == nil
}
type YtsaurusGroupWithMembers struct {
YtsaurusGroup
// Members is a set of group members' @name attribute.
Members StringSet
}
func NewEmptyYtsaurusGroupWithMembers(group YtsaurusGroup) YtsaurusGroupWithMembers {
return YtsaurusGroupWithMembers{YtsaurusGroup: group, Members: NewStringSet()}
}
type YtsaurusMembership struct {
GroupName string
Username string
}