/
admin_scim_user.go
192 lines (159 loc) · 6.84 KB
/
admin_scim_user.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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
package models
import "fmt"
type SCIMUserScheme struct {
ID string `json:"id"`
ExternalID string `json:"externalId"`
Meta *SCIMUserMetaScheme `json:"meta,omitempty"`
Groups []*SCIMUserGroupScheme `json:"groups,omitempty"`
UserName string `json:"userName,omitempty"`
Emails []*SCIMUserEmailScheme `json:"emails,omitempty"`
Name *SCIMUserNameScheme `json:"name,omitempty"`
DisplayName string `json:"displayName,omitempty"`
NickName string `json:"nickName,omitempty"`
Title string `json:"title,omitempty"`
PreferredLanguage string `json:"preferredLanguage,omitempty"`
Department string `json:"department,omitempty"`
Organization string `json:"organization,omitempty"`
Timezone string `json:"timezone,omitempty"`
PhoneNumbers []*SCIMUserPhoneNumberScheme `json:"phoneNumbers,omitempty"`
Active bool `json:"active,omitempty"`
EnterpriseInfo *SCIMEnterpriseUserInfoScheme `json:"urn:ietf:params:scim:schemas:extension:enterprise:2.1:User,omitempty"`
SCIMExtension *SCIMExtensionScheme `json:"urn:scim:schemas:extension:atlassian-external:1.1,omitempty"`
}
type SCIMUserEmailScheme struct {
Value string `json:"value,omitempty"`
Type string `json:"type,omitempty"`
Primary bool `json:"primary,omitempty"`
}
type SCIMUserNameScheme struct {
Formatted string `json:"formatted,omitempty"`
FamilyName string `json:"familyName,omitempty"`
GivenName string `json:"givenName,omitempty"`
MiddleName string `json:"middleName,omitempty"`
HonorificPrefix string `json:"honorificPrefix,omitempty"`
HonorificSuffix string `json:"honorificSuffix,omitempty"`
}
type SCIMUserPhoneNumberScheme struct {
Value string `json:"value,omitempty"`
Type string `json:"type,omitempty"`
Primary bool `json:"primary,omitempty"`
}
type SCIMUserMetaScheme struct {
ResourceType string `json:"resourceType,omitempty"`
Location string `json:"location,omitempty"`
LastModified string `json:"lastModified,omitempty"`
Created string `json:"created,omitempty"`
}
type SCIMUserGroupScheme struct {
Type string `json:"type,omitempty"`
Value string `json:"value,omitempty"`
Display string `json:"display,omitempty"`
Ref string `json:"$ref,omitempty"`
}
type SCIMEnterpriseUserInfoScheme struct {
Organization string `json:"organization,omitempty"`
Department string `json:"department,omitempty"`
}
type SCIMExtensionScheme struct {
AtlassianAccountID string `json:"atlassianAccountId,omitempty"`
}
type SCIMUserGetsOptionsScheme struct {
Attributes []string
ExcludedAttributes []string
Filter string
}
type SCIMUserPageScheme struct {
Schemas []string `json:"schemas,omitempty"`
TotalResults int `json:"totalResults,omitempty"`
StartIndex int `json:"startIndex,omitempty"`
ItemsPerPage int `json:"itemsPerPage,omitempty"`
Resources []*SCIMUserScheme `json:"Resources,omitempty"`
}
type SCIMUserToPathScheme struct {
Schemas []string `json:"schemas,omitempty"`
Operations []*SCIMUserToPathOperationScheme `json:"operations,omitempty"`
}
func (s *SCIMUserToPathScheme) AddStringOperation(operation, path, value string) (err error) {
if len(operation) == 0 {
return fmt.Errorf("error!, please provide a valid operation value, you can check the availables values calling the user schemas")
}
if len(path) == 0 {
return fmt.Errorf("error!, please provide a valid path value")
}
if len(value) == 0 {
return fmt.Errorf("error!, please provide a valid value value")
}
s.Operations = append(s.Operations, &SCIMUserToPathOperationScheme{
Op: operation,
Path: path,
Value: value,
})
return
}
func (s *SCIMUserToPathScheme) AddBoolOperation(operation, path string, value bool) (err error) {
if len(operation) == 0 {
return fmt.Errorf("error!, please provide a valid operation value, you can check the availables values calling the user schemas")
}
if len(path) == 0 {
return fmt.Errorf("error!, please provide a valid path value")
}
s.Operations = append(s.Operations, &SCIMUserToPathOperationScheme{
Op: operation,
Path: path,
Value: value,
})
return
}
func (s *SCIMUserToPathScheme) AddComplexOperation(operation, path string, values []*SCIMUserComplexOperationScheme) (err error) {
if len(operation) == 0 {
return fmt.Errorf("error!, please provide a valid operation value, you can check the availables values calling the user schemas")
}
if len(path) == 0 {
return fmt.Errorf("error!, please provide a valid path value")
}
if values == nil {
return fmt.Errorf("error!, please provide a valid SCIMUserComplexOperationScheme slice pointer")
}
if len(values) == 0 {
return fmt.Errorf("error!, the values variable must contains SCIMUserComplexOperationScheme nodes")
}
s.Operations = append(s.Operations, &SCIMUserToPathOperationScheme{
Op: operation,
Path: path,
Value: values,
})
return
}
type SCIMUserComplexOperationScheme struct {
Value string `json:"value,omitempty"`
ValueType string `json:"type,omitempty"` // Available values (work, home, other)
Primary bool `json:"primary,omitempty"`
}
type SCIMUserToPathValueScheme struct {
Array bool `json:"array,omitempty"`
Null bool `json:"null,omitempty"`
ValueNode bool `json:"valueNode,omitempty"`
ContainerNode bool `json:"containerNode,omitempty"`
MissingNode bool `json:"missingNode,omitempty"`
Object bool `json:"object,omitempty"`
NodeType string `json:"nodeType,omitempty"`
Pojo bool `json:"pojo,omitempty"`
Number bool `json:"number,omitempty"`
IntegralNumber bool `json:"integralNumber,omitempty"`
FloatingPointNumber bool `json:"floatingPointNumber,omitempty"`
Short bool `json:"short,omitempty"`
Int bool `json:"int,omitempty"`
Long bool `json:"long,omitempty"`
Double bool `json:"double,omitempty"`
BigDecimal bool `json:"bigDecimal,omitempty"`
BigInteger bool `json:"bigInteger,omitempty"`
Textual bool `json:"textual,omitempty"`
Boolean bool `json:"boolean,omitempty"`
Binary bool `json:"binary,omitempty"`
Float bool `json:"float,omitempty"`
}
type SCIMUserToPathOperationScheme struct {
Op string `json:"op,omitempty"`
Path string `json:"path,omitempty"`
Value interface{} `json:"value,omitempty"`
}