1
2
3
4
5
6 package github
7
8 import (
9 "context"
10 "encoding/json"
11 "fmt"
12 )
13
14
15
16
17
18 type SCIMService service
19
20
21
22
23 type SCIMUserAttributes struct {
24 UserName string `json:"userName"`
25 Name SCIMUserName `json:"name"`
26 DisplayName *string `json:"displayName,omitempty"`
27 Emails []*SCIMUserEmail `json:"emails"`
28 Schemas []string `json:"schemas,omitempty"`
29 ExternalID *string `json:"externalId,omitempty"`
30 Groups []string `json:"groups,omitempty"`
31 Active *bool `json:"active,omitempty"`
32 }
33
34
35 type SCIMUserName struct {
36 GivenName string `json:"givenName"`
37 FamilyName string `json:"familyName"`
38 Formatted *string `json:"formatted,omitempty"`
39 }
40
41
42 type SCIMUserEmail struct {
43 Value string `json:"value"`
44 Primary *bool `json:"primary,omitempty"`
45 Type *string `json:"type,omitempty"`
46 }
47
48
49
50
51 type ListSCIMProvisionedIdentitiesOptions struct {
52 StartIndex *int `json:"startIndex,omitempty"`
53 Count *int `json:"count,omitempty"`
54
55
56
57
58
59 Filter *string `json:"filter,omitempty"`
60 }
61
62
63
64
65 func (s *SCIMService) ListSCIMProvisionedIdentities(ctx context.Context, org string, opts *ListSCIMProvisionedIdentitiesOptions) (*Response, error) {
66 u := fmt.Sprintf("scim/v2/organizations/%v/Users", org)
67 u, err := addOptions(u, opts)
68 if err != nil {
69 return nil, err
70 }
71 req, err := s.client.NewRequest("GET", u, nil)
72 if err != nil {
73 return nil, err
74 }
75 return s.client.Do(ctx, req, nil)
76 }
77
78
79
80
81 func (s *SCIMService) ProvisionAndInviteSCIMUser(ctx context.Context, org string, opts *SCIMUserAttributes) (*Response, error) {
82 u := fmt.Sprintf("scim/v2/organizations/%v/Users", org)
83 u, err := addOptions(u, opts)
84 if err != nil {
85 return nil, err
86 }
87 req, err := s.client.NewRequest("POST", u, nil)
88 if err != nil {
89 return nil, err
90 }
91 return s.client.Do(ctx, req, nil)
92 }
93
94
95
96
97 func (s *SCIMService) GetSCIMProvisioningInfoForUser(ctx context.Context, org, scimUserID string) (*Response, error) {
98 u := fmt.Sprintf("scim/v2/organizations/%v/Users/%v", org, scimUserID)
99 req, err := s.client.NewRequest("GET", u, nil)
100 if err != nil {
101 return nil, err
102 }
103 return s.client.Do(ctx, req, nil)
104 }
105
106
107
108
109 func (s *SCIMService) UpdateProvisionedOrgMembership(ctx context.Context, org, scimUserID string, opts *SCIMUserAttributes) (*Response, error) {
110 u := fmt.Sprintf("scim/v2/organizations/%v/Users/%v", org, scimUserID)
111 u, err := addOptions(u, opts)
112 if err != nil {
113 return nil, err
114 }
115 req, err := s.client.NewRequest("PUT", u, nil)
116 if err != nil {
117 return nil, err
118 }
119 return s.client.Do(ctx, req, nil)
120 }
121
122
123
124
125 type UpdateAttributeForSCIMUserOptions struct {
126 Schemas []string `json:"schemas,omitempty"`
127 Operations UpdateAttributeForSCIMUserOperations `json:"operations"`
128 }
129
130
131 type UpdateAttributeForSCIMUserOperations struct {
132 Op string `json:"op"`
133 Path *string `json:"path,omitempty"`
134 Value json.RawMessage `json:"value,omitempty"`
135 }
136
137
138
139
140 func (s *SCIMService) UpdateAttributeForSCIMUser(ctx context.Context, org, scimUserID string, opts *UpdateAttributeForSCIMUserOptions) (*Response, error) {
141 u := fmt.Sprintf("scim/v2/organizations/%v/Users/%v", org, scimUserID)
142 u, err := addOptions(u, opts)
143 if err != nil {
144 return nil, err
145 }
146 req, err := s.client.NewRequest("PATCH", u, nil)
147 if err != nil {
148 return nil, err
149 }
150 return s.client.Do(ctx, req, nil)
151 }
152
153
154
155
156 func (s *SCIMService) DeleteSCIMUserFromOrg(ctx context.Context, org, scimUserID string) (*Response, error) {
157 u := fmt.Sprintf("scim/v2/organizations/%v/Users/%v", org, scimUserID)
158 req, err := s.client.NewRequest("DELETE", u, nil)
159 if err != nil {
160 return nil, err
161 }
162 return s.client.Do(ctx, req, nil)
163 }
164
View as plain text