Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
140 changes: 140 additions & 0 deletions github/enterprise_scim.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
// Copyright 2025 The go-github AUTHORS. All rights reserved.
//
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

package github

// The URIs that are used to indicate the namespaces of the SCIM schemas (only core schemas are supported).
const SCIMSchemasURINamespacesUsers string = "urn:ietf:params:scim:schemas:core:2.0:User"
const SCIMSchemasURINamespacesGroups string = "urn:ietf:params:scim:schemas:core:2.0:Group"

// SCIMEnterpriseGroupAttributes represents supported SCIM Enterprise group attributes.
// GitHub API docs:https://docs.github.com/en/enterprise-cloud@latest/rest/enterprise-admin/scim#supported-scim-group-attributes
type SCIMEnterpriseGroupAttributes struct {
DisplayName *string `json:"displayName,omitempty"` // Human-readable name for a group.
Members []*SCIMEnterpriseDisplayReference `json:"members,omitempty"` // (Optional.)
ExternalID *string `json:"externalId,omitempty"` // (Optional.)
// Only populated as a result of calling ListSCIMProvisionedIdentitiesOptions:
Schemas []string `json:"schemas"` // (Optional.)
ID *string `json:"id,omitempty"`
Meta *SCIMMeta `json:"meta,omitempty"`
}

// SCIMEnterpriseDisplayReference represents a JSON SCIM (System for Cross-domain Identity Management) resource.
type SCIMEnterpriseDisplayReference struct {
Value string `json:"value"` // (Required.)
Ref string `json:"$+ref"` // (Required.)
Display *string `json:"displayName,omitempty"` // (Optional.)
}

// SCIMEnterpriseUserAttributes represents supported SCIM enterprise user attributes.
// GitHub API docs: https://docs.github.com/en/enterprise-cloud@latest/rest/enterprise-admin/scim#supported-scim-user-attributes
type SCIMEnterpriseUserAttributes struct {
DisplayName *string `json:"displayName,omitempty"` // Human-readable name for a user (Optional)
Name SCIMEnterpriseUserName `json:"name"` // (Required.)
UserName string `json:"userName"` // The username for the user (GitHub Account after normalized), generated by the SCIM provider. Must be unique per user.
Emails []*SCIMEnterpriseUserEmail `json:"emails"` // Must be unique per user.
Roles []*SCIMEnterpriseUserRole `json:"roles,omitempty"` // List of the user's roles.
Schemas []string `json:"schemas,omitempty"` // (Optional.)
ExternalID *string `json:"externalId,omitempty"` // This identifier is generated by a SCIM provider. Must be unique per user.
ID *string `json:"id,omitempty"` // Identifier generated by the GitHub's SCIM endpoint.
Active *bool `json:"active,omitempty"` // Indicates whether the identity is active (true) or should be suspended (false).
Groups []string `json:"groups,omitempty"` // (Optional.)
Meta *SCIMEnterpriseMeta `json:"meta,omitempty"`
}

// SCIMEnterpriseUserName represents SCIM enterprise user's name information.
*type SCIMEnterpriseUserName struct {

Check failure on line 48 in github/enterprise_scim.go

View workflow job for this annotation

GitHub Actions / lint

syntax error: non-declaration statement outside function body

Check failure on line 48 in github/enterprise_scim.go

View workflow job for this annotation

GitHub Actions / test (1.x, ubuntu-latest)

syntax error: non-declaration statement outside function body

Check failure on line 48 in github/enterprise_scim.go

View workflow job for this annotation

GitHub Actions / test (1.24.0, ubuntu-latest)

syntax error: non-declaration statement outside function body
GivenName string `json:"givenName"` // The first name of the user.
FamilyName string `json:"familyName"` // The last name of the user.
Formatted *string `json:"formatted,omitempty"` // The user's full name, including all middle names, titles, and suffixes, formatted for display (Optional)
}

// SCIMEnterpriseUserEmail represents SCIM enterprise user's emails.
*type SCIMEnterpriseUserEmail struct {

Check failure on line 55 in github/enterprise_scim.go

View workflow job for this annotation

GitHub Actions / lint

syntax error: non-declaration statement outside function body) (typecheck)

Check failure on line 55 in github/enterprise_scim.go

View workflow job for this annotation

GitHub Actions / test (1.x, ubuntu-latest)

syntax error: non-declaration statement outside function body

Check failure on line 55 in github/enterprise_scim.go

View workflow job for this annotation

GitHub Actions / test (1.24.0, ubuntu-latest)

syntax error: non-declaration statement outside function body
Value string `json:"value"` // (Required.)
Primary *bool `json:"primary,omitempty"` // (Optional.)
Type *string `json:"type,omitempty"` // (Optional.)
}

// ListSCIMProvisionedGroupsForEnterprise lists SCIM provisioned groups for an enterprise.
// GitHub API docs: https://docs.github.com/enterprise-cloud@latest/rest/enterprise-admin/scim#list-provisioned-scim-groups-for-an-enterprise
//
//meta:operation GET /scim/v2/enterprises/{enterprise}
// ----- Already present in scim.go file -----

// ProvisionSCIMEnterpriseGroup creates a SCIM group for an enterprise.
// GitHub API docs: https://docs.github.com/en/enterprise-cloud@latest/rest/enterprise-admin/scim#provision-a-scim-enterprise-group
//
//meta:operation POST scim/v2/enterprises/{enterprise}/Groups
//func (s *SCIMService) ProvisionSCIMEnterpriseGroup(ctx context.Context, enterprise string, opts *SCIMGroupAttributes) (*SCIMGroupAttributes, *Response, error) {
//}

// GetSCIMProvisioningInformationForEnterpriseGroup gets information about a SCIM group for an enterprise.
// GitHub API docs: https://docs.github.com/en/enterprise-cloud@latest/rest/enterprise-admin/scim#get-scim-provisioning-information-for-an-enterprise-group
//
//meta:operation GET /scim/v2/enterprises/{enterprise}/Groups/{scim_group_id}
//func (s *SCIMService) GetSCIMProvisioningInformationForEnterpriseGroup(ctx context.Context, enterprise string, scimGroupID string) (*SCIMGroupAttributes, *Response, error) {
//}

// SetSCIMInformationForProvisionedEnterpriseGroup replaces an existing provisioned group’s information for an enterprise.
// GitHub API docs: https://docs.github.com/en/enterprise-cloud@latest/rest/enterprise-admin/scim#set-scim-information-for-a-provisioned-enterprise-group
//
//meta:operation PUT /scim/v2/enterprises/{enterprise}/Groups/{scim_group_id}
//func (s *SCIMService) SetSCIMInformationForProvisionedEnterpriseGroup(ctx context.Context, enterprise string, scimGroupID string, opts *SCIMGroupAttributes) (*SCIMGroupAttributes, *Response, error) {
//}

// UpdateAttributeForSCIMEnterpriseGroup updates a provisioned group’s individual attributes for an enterprise.
// GitHub API docs: https://docs.github.com/en/enterprise-cloud@latest/rest/enterprise-admin/scim#update-an-attribute-for-a-scim-enterprise-group
//
//meta:operation PATCH /scim/v2/enterprises/{enterprise}/Groups/{scim_group_id}
//func (s *SCIMService) UpdateAttributeForSCIMEnterpriseGroup(ctx context.Context, enterprise string, scimGroupID string, opts *SCIMGroupAttributes) (*SCIMGroupAttributes, *Response, error) {
//}

// DeleteSCIMGroupFromEnterprise deletes a SCIM group from an enterprise.
// GitHub API docs: https://docs.github.com/en/enterprise-cloud@latest/rest/enterprise-admin/scim#delete-a-scim-group-from-an-enterprise
//
//meta:operation DELETE /scim/v2/enterprises/{enterprise}/Groups/{scim_group_id}

// ListSCIMProvisionedIdentitiesForEnterprise lists provisioned SCIM enterprise users.
// GitHub API docs: https://docs.github.com/en/enterprise-cloud@latest/rest/enterprise-admin/scim#list-scim-provisioned-identities-for-an-enterprise
//
//meta:operation GET /scim/v2/enterprises/{enterprise}/Users
//func (s *SCIMService) ListSCIMProvisionedIdentitiesForEnterprise(ctx context.Context, enterprise string, opts *ListOptions) ([]*SCIMEnterpriseUser, *Response, error) {
//}

// ProvisionSCIMEnterpriseUser creates an external identity for a new SCIM enterprise user.
// GitHub API docs: https://docs.github.com/en/enterprise-cloud@latest/rest/enterprise-admin/scim#provision-a-scim-enterprise-user
//
//meta:operation POST /scim/v2/enterprises/{enterprise}/Users
//func (s *SCIMService) ProvisionSCIMEnterpriseUser(ctx context.Context, enterprise string, opts *SCIMEnterpriseUser) (*SCIMEnterpriseUser, *Response, error) {
//}

// GetSCIMProvisioningInformationForEnterpriseUser gets information about a SCIM enterprise user.
// GitHub API docs: https://docs.github.com/en/enterprise-cloud@latest/rest/enterprise-admin/scim#get-scim-provisioning-information-for-an-enterprise-user
//
//meta:operation GET /scim/v2/enterprises/{enterprise}/Users/{scim_user_id}
//func (s *SCIMService) GetSCIMProvisioningInformationForEnterpriseUser(ctx context.Context, enterprise string, scimUserID string) (*SCIMEnterpriseUser, *Response, error) {
//}

// SetSCIMInformationForProvisionedEnterpriseUser replaces an existing provisioned enterprise user's information.
// GitHub API docs: https://docs.github.com/en/enterprise-cloud@latest/rest/enterprise-admin/scim#set-scim-information-for-a-provisioned-enterprise-user
//
//meta:operation PUT /scim/v2/enterprises/{enterprise}/Users/{scim_user_id}
//func (s *SCIMService) SetSCIMInformationForProvisionedEnterpriseUser(ctx context.Context, enterprise string, scimUserID string, opts *SCIMEnterpriseUser) (*SCIMEnterpriseUser, *Response, error) {
//}

// UpdateAttributeForSCIMEnterpriseUser update a provisioned enterprise user's individual attributes.
// GitHub API docs: https://docs.github.com/en/enterprise-cloud@latest/rest/enterprise-admin/scim#update-an-attribute-for-a-scim-enterprise-user
//
//meta:operation PATCH /scim/v2/enterprises/{enterprise}/Users/{scim_user_id}
//func (s *SCIMService) UpdateAttributeForSCIMEnterpriseUser(ctx context.Context, enterprise string, scimUserID string, opts *SCIMEnterpriseUser) (*SCIMEnterpriseUser, *Response, error) {
//}

// DeleteSCIMUserFromEnterprise suspends a SCIM user permanently from an enterprise, removes all the user's data, etc. This action is irreversible.
// GitHub API docs: https://docs.github.com/en/enterprise-cloud@latest/rest/enterprise-admin/scim#delete-a-scim-user-from-an-enterprise
//
//meta:operation DELETE /scim/v2/enterprises/{enterprise}/Users/{scim_user_id}
//func (s *SCIMService) DeleteSCIMUserFromEnterprise(ctx context.Context, enterprise string, scimUserID string) (*Response, error) {
//}
14 changes: 14 additions & 0 deletions github/enterprise_scim_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// Copyright 2025 The go-github AUTHORS. All rights reserved.
//
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

package github

import (
"fmt"
"net/http"
"testing"

"github.com/google/go-cmp/cmp"
)
Loading