Skip to content

Commit 704fe20

Browse files
committed
Implement DELETE for SCIM Groups
1 parent 66f826c commit 704fe20

File tree

2 files changed

+43
-0
lines changed

2 files changed

+43
-0
lines changed

github/enterprise_scim.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,3 +257,19 @@ func (s *EnterpriseService) UpdateSCIMUserAttribute(ctx context.Context, enterpr
257257

258258
return user, resp, nil
259259
}
260+
261+
// DeleteSCIMGroup deletes a SCIM group from an enterprise.
262+
//
263+
// GitHub API docs: https://docs.github.com/enterprise-cloud@latest/rest/enterprise-admin/scim#delete-a-scim-group-from-an-enterprise
264+
//
265+
//meta:operation DELETE /scim/v2/enterprises/{enterprise}/Groups/{scim_group_id}
266+
func (s *EnterpriseService) DeleteSCIMGroup(ctx context.Context, enterprise, scimGroupID string) (*Response, error) {
267+
u := fmt.Sprintf("scim/v2/enterprises/%v/Groups/%v", enterprise, scimGroupID)
268+
req, err := s.client.NewRequest("DELETE", u, nil)
269+
if err != nil {
270+
return nil, err
271+
}
272+
req.Header.Set("Accept", mediaTypeV3)
273+
274+
return s.client.Do(ctx, req, nil)
275+
}

github/enterprise_scim_test.go

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -660,3 +660,30 @@ func TestEnterpriseService_UpdateSCIMUserAttribute(t *testing.T) {
660660
return resp, err
661661
})
662662
}
663+
664+
func TestEnterpriseService_DeleteSCIMGroup(t *testing.T) {
665+
t.Parallel()
666+
client, mux, _ := setup(t)
667+
668+
mux.HandleFunc("/scim/v2/enterprises/ee/Groups/abcd", func(w http.ResponseWriter, r *http.Request) {
669+
testMethod(t, r, "DELETE")
670+
testHeader(t, r, "Accept", mediaTypeV3)
671+
w.WriteHeader(http.StatusNoContent)
672+
})
673+
674+
ctx := t.Context()
675+
_, err := client.Enterprise.DeleteSCIMGroup(ctx, "ee", "abcd")
676+
if err != nil {
677+
t.Fatalf("Enterprise.DeleteSCIMGroup returned unexpected error: %v", err)
678+
}
679+
680+
const methodName = "DeleteSCIMGroup"
681+
testBadOptions(t, methodName, func() (err error) {
682+
_, err = client.Enterprise.DeleteSCIMGroup(ctx, "\n", "\n")
683+
return err
684+
})
685+
686+
testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) {
687+
return client.Enterprise.DeleteSCIMGroup(ctx, "ee", "abcd")
688+
})
689+
}

0 commit comments

Comments
 (0)