This repository was archived by the owner on Sep 2, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 33
/
Copy pathtenant.go
88 lines (75 loc) · 1.59 KB
/
tenant.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
package models
// swagger:model
type Tenant struct {
Validation
Access
Meta
Owned
Bundled
Name string `index:",key"`
Description string
// Documentation of this tenant. This should tell what
// the tenant is for, any special considerations that
// should be taken into account when using it, etc. in rich structured text (rst).
Documentation string
Members map[string][]string
Users []string
}
func (t *Tenant) Fill() {
t.Validation.fill(t)
if t.Meta == nil {
t.Meta = Meta{}
}
if t.Members == nil {
t.Members = map[string][]string{}
}
if t.Users == nil {
t.Users = []string{}
}
}
func (t *Tenant) GetMeta() Meta {
return t.Meta
}
func (t *Tenant) SetMeta(d Meta) {
t.Meta = d
}
// GetDocumentaiton returns the object's Documentation
func (t *Tenant) GetDocumentation() string {
return t.Documentation
}
// GetDescription returns the object's Description
func (t *Tenant) GetDescription() string {
return t.Description
}
func (t *Tenant) Validate() {
t.AddError(ValidName("Invalid Name", t.Name))
for k := range t.Members {
if _, ok := baseModels[k]; !ok {
t.Errorf("Invalid ")
}
}
}
func (t *Tenant) Prefix() string {
return "tenants"
}
func (t *Tenant) Key() string {
return t.Name
}
func (t *Tenant) KeyName() string {
return "Name"
}
func (t *Tenant) AuthKey() string {
return t.Key()
}
func (t *Tenant) SliceOf() interface{} {
ts := []*Tenant{}
return &ts
}
func (t *Tenant) ToModels(obj interface{}) []Model {
items := obj.(*[]*Tenant)
res := make([]Model, len(*items))
for i, item := range *items {
res[i] = Model(item)
}
return res
}