Skip to content

Commit a3bedb3

Browse files
committed
Implement POST for SCIM
1 parent c8bf5f7 commit a3bedb3

1 file changed

Lines changed: 31 additions & 5 deletions

File tree

github/enterprise_scim.go

Lines changed: 31 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,10 @@ type SCIMEnterpriseGroupAttributes struct {
3333
DisplayName *string `json:"displayName,omitempty"` // Human-readable name for a group.
3434
Members []*SCIMEnterpriseDisplayReference `json:"members,omitempty"` // List of members who are assigned to the group in SCIM provider
3535
ExternalID *string `json:"externalId,omitempty"` // This identifier is generated by a SCIM provider. Must be unique per user.
36+
Schemas []string `json:"schemas,omitempty"` // The URIs that are used to indicate the namespaces of the SCIM schemas.
3637
// Bellow: Only populated as a result of calling UpdateSCIMGroupAttribute:
37-
Schemas []string `json:"schemas,omitempty"` // The URIs that are used to indicate the namespaces of the SCIM schemas.
38-
ID *string `json:"id,omitempty"` // The internally generated id for the group object.
39-
Meta *SCIMEnterpriseMeta `json:"meta,omitempty"` // The metadata associated with the creation/updates to the group.
38+
ID *string `json:"id,omitempty"` // The internally generated id for the group object.
39+
Meta *SCIMEnterpriseMeta `json:"meta,omitempty"` // The metadata associated with the creation/updates to the group.
4040
}
4141

4242
// SCIMEnterpriseDisplayReference represents a JSON SCIM (System for Cross-domain Identity Management) resource reference.
@@ -264,7 +264,20 @@ func (s *EnterpriseService) UpdateSCIMUserAttribute(ctx context.Context, enterpr
264264
//
265265
//meta:operation POST /scim/v2/enterprises/{enterprise}/Groups
266266
func (s *EnterpriseService) ProvisionSCIMGroup(ctx context.Context, enterprise string, group SCIMEnterpriseGroupAttributes) (*SCIMEnterpriseGroupAttributes, *Response, error) {
267-
return nil, nil, nil
267+
u := fmt.Sprintf("scim/v2/enterprises/%v/Groups", enterprise)
268+
req, err := s.client.NewRequest("POST", u, group)
269+
if err != nil {
270+
return nil, nil, err
271+
}
272+
req.Header.Set("Accept", mediaTypeSCIM)
273+
274+
groupProvisioned := new(SCIMEnterpriseGroupAttributes)
275+
resp, err := s.client.Do(ctx, req, groupProvisioned)
276+
if err != nil {
277+
return nil, resp, err
278+
}
279+
280+
return groupProvisioned, resp, nil
268281
}
269282

270283
// ProvisionSCIMUser creates an external identity for a new SCIM enterprise user.
@@ -273,5 +286,18 @@ func (s *EnterpriseService) ProvisionSCIMGroup(ctx context.Context, enterprise s
273286
//
274287
//meta:operation POST /scim/v2/enterprises/{enterprise}/Users
275288
func (s *EnterpriseService) ProvisionSCIMUser(ctx context.Context, enterprise string, user SCIMEnterpriseUserAttributes) (*SCIMEnterpriseUserAttributes, *Response, error) {
276-
return nil, nil, nil
289+
u := fmt.Sprintf("scim/v2/enterprises/%v/Users", enterprise)
290+
req, err := s.client.NewRequest("POST", u, user)
291+
if err != nil {
292+
return nil, nil, err
293+
}
294+
req.Header.Set("Accept", mediaTypeSCIM)
295+
296+
userProvisioned := new(SCIMEnterpriseUserAttributes)
297+
resp, err := s.client.Do(ctx, req, userProvisioned)
298+
if err != nil {
299+
return nil, resp, err
300+
}
301+
302+
return userProvisioned, resp, nil
277303
}

0 commit comments

Comments
 (0)