GitHub Enterprise management including audit logs, SCIM user provisioning, and enterprise-level settings.
The EnterpriseService provides methods for GitHub Enterprise operations.
type EnterpriseService struct{}// GetAuditLog gets the audit log for an enterprise
func (s *EnterpriseService) GetAuditLog(ctx context.Context, enterprise string, opts *GetAuditLogOptions) ([]*AuditEntry, *Response, error)
type GetAuditLogOptions struct {
Phrase *string // Search query
Include *string // "web", "git", "all"
After *string // Cursor for pagination
Before *string // Cursor for pagination
Order *string // "asc", "desc"
Page *int
PerPage *int
}
type AuditEntry struct {
Timestamp *int64
Action *string
Active *bool
Actor *string
ActorID *int64
ActorLocation *ActorLocation
Data map[string]interface{}
Org *string
OrgID *int64
Business *string
BusinessID *int64
User *string
UserID *int64
}// ListEnterpriseUsers lists all SCIM provisioned enterprise members
func (s *EnterpriseService) ListEnterpriseUsers(ctx context.Context, enterprise string, opts *ListSCIMUsersOptions) (*SCIMUserList, *Response, error)
// GetEnterpriseUserByID gets a SCIM provisioned user by ID
func (s *EnterpriseService) GetEnterpriseUserByID(ctx context.Context, enterprise string, userID string) (*EnterpriseUser, *Response, error)
type ListSCIMUsersOptions struct {
StartIndex *int
Count *int
Filter string
}
type SCIMUserList struct {
Schemas []string
TotalResults int
ItemsPerPage int
StartIndex int
Resources []*EnterpriseUser
}
type EnterpriseUser struct {
Schemas []string
ID string
ExternalID string
UserName string
Name EnterpriseUserName
Emails []EnterpriseUserEmail
Groups []EnterpriseUserGroup
Active bool
Meta *SCIMUserMeta
}
type EnterpriseUserName struct {
GivenName string
FamilyName string
}
type EnterpriseUserEmail struct {
Value string
Primary bool
Type string
}// CreateEnterpriseUser provisions an enterprise member
func (s *EnterpriseService) CreateEnterpriseUser(ctx context.Context, enterprise string, user *EnterpriseUser) (*EnterpriseUser, *Response, error)
// UpdateEnterpriseUserByID updates a SCIM provisioned user
func (s *EnterpriseService) UpdateEnterpriseUserByID(ctx context.Context, enterprise string, userID string, user *EnterpriseUser) (*EnterpriseUser, *Response, error)
// DeleteEnterpriseUserByID deletes a SCIM provisioned user
func (s *EnterpriseService) DeleteEnterpriseUserByID(ctx context.Context, enterprise string, userID string) (*Response, error)Usage:
// Create a SCIM user
newUser := &github.EnterpriseUser{
Schemas: []string{"urn:ietf:params:scim:schemas:core:2.0:User"},
UserName: "jdoe",
ExternalID: "12345",
Name: github.EnterpriseUserName{
GivenName: "John",
FamilyName: "Doe",
},
Emails: []github.EnterpriseUserEmail{
{
Value: "john.doe@example.com",
Primary: true,
Type: "work",
},
},
Active: true,
}
user, _, err := client.Enterprise.CreateEnterpriseUser(ctx, "enterprise-slug", newUser)// ListEnterpriseGroups lists all SCIM provisioned enterprise groups
func (s *EnterpriseService) ListEnterpriseGroups(ctx context.Context, enterprise string, opts *ListSCIMGroupsOptions) (*SCIMGroupList, *Response, error)
// GetEnterpriseGroupByID gets a SCIM provisioned group by ID
func (s *EnterpriseService) GetEnterpriseGroupByID(ctx context.Context, enterprise string, groupID string) (*EnterpriseGroup, *Response, error)
type ListSCIMGroupsOptions struct {
StartIndex *int
Count *int
Filter string
}
type SCIMGroupList struct {
Schemas []string
TotalResults int
ItemsPerPage int
StartIndex int
Resources []*EnterpriseGroup
}
type EnterpriseGroup struct {
Schemas []string
ID string
ExternalID string
DisplayName string
Members []EnterpriseGroupMember
Meta *SCIMGroupMeta
}// CreateEnterpriseGroup provisions an enterprise group
func (s *EnterpriseService) CreateEnterpriseGroup(ctx context.Context, enterprise string, group *EnterpriseGroup) (*EnterpriseGroup, *Response, error)
// UpdateEnterpriseGroupByID updates a SCIM provisioned group
func (s *EnterpriseService) UpdateEnterpriseGroupByID(ctx context.Context, enterprise string, groupID string, group *EnterpriseGroup) (*EnterpriseGroup, *Response, error)
// DeleteEnterpriseGroupByID deletes a SCIM provisioned group
func (s *EnterpriseService) DeleteEnterpriseGroupByID(ctx context.Context, enterprise string, groupID string) (*Response, error)// GetServerStatistics gets GitHub Enterprise Server statistics
func (s *EnterpriseService) GetServerStatistics(ctx context.Context, opts *GetServerStatisticsOptions) (*ServerStatistics, *Response, error)
type ServerStatistics struct {
ServerID *string
CollectionDate *string
SchemaVersion *string
GHESVersion *string
HostName *string
// Additional statistics fields
}// GetCodeSecurityAndAnalysis gets code security and analysis features for an enterprise
func (s *EnterpriseService) GetCodeSecurityAndAnalysis(ctx context.Context, enterprise string) (*EnterpriseSecurityAnalysisSettings, *Response, error)
// UpdateCodeSecurityAndAnalysis updates code security and analysis features for an enterprise
func (s *EnterpriseService) UpdateCodeSecurityAndAnalysis(ctx context.Context, enterprise string, settings *EnterpriseSecurityAnalysisSettings) (*Response, error)The AdminService provides GitHub Enterprise Server admin operations.
type AdminService struct {
// Service fields
}// GetAdminStats gets admin statistics
func (s *AdminService) GetAdminStats(ctx context.Context, opts *GetAdminStatsOptions) (*AdminStats, *Response, error)
type AdminStats struct {
Repos *RepoStats
Hooks *HookStats
Pages *PageStats
Orgs *OrgStats
Users *UserStats
Pulls *PullStats
Issues *IssueStats
Milestones *MilestoneStats
Gists *GistStats
Comments *CommentStats
}// CreateOrg creates a new organization
func (s *AdminService) CreateOrg(ctx context.Context, org *Organization, admin string) (*Organization, *Response, error)
// RenameOrg renames an organization
func (s *AdminService) RenameOrg(ctx context.Context, org, newName string) (*RenameOrgResponse, *Response, error)
// RenameOrgByID renames an organization by ID
func (s *AdminService) RenameOrgByID(ctx context.Context, orgID int64, newName string) (*RenameOrgResponse, *Response, error)// CreateUser creates a new user
func (s *AdminService) CreateUser(ctx context.Context, login, email string) (*User, *Response, error)
// DeleteUser deletes a user
func (s *AdminService) DeleteUser(ctx context.Context, username string) (*Response, error)
// SuspendUser suspends a user
func (s *AdminService) SuspendUser(ctx context.Context, username string, opts *UserSuspendOptions) (*Response, error)
// UnsuspendUser unsuspends a user
func (s *AdminService) UnsuspendUser(ctx context.Context, username string) (*Response, error)
type UserSuspendOptions struct {
Reason *string
}// CreateUserImpersonation creates an impersonation token
func (s *AdminService) CreateUserImpersonation(ctx context.Context, username string, opts *ImpersonateUserOptions) (*UserAuthorization, *Response, error)
// DeleteUserImpersonation deletes an impersonation token
func (s *AdminService) DeleteUserImpersonation(ctx context.Context, username string) (*Response, error)
type ImpersonateUserOptions struct {
Scopes []string
}// CreateTeam creates a new team
func (s *AdminService) CreateTeam(ctx context.Context, org string, team *CreateTeamOptions) (*Team, *Response, error)// ListPreReceiveHooks lists all pre-receive hooks
func (s *AdminService) ListPreReceiveHooks(ctx context.Context, opts *ListOptions) ([]*PreReceiveHook, *Response, error)
// GetPreReceiveHook gets a single pre-receive hook
func (s *AdminService) GetPreReceiveHook(ctx context.Context, id int64) (*PreReceiveHook, *Response, error)
// CreatePreReceiveHook creates a new pre-receive hook
func (s *AdminService) CreatePreReceiveHook(ctx context.Context, hook *PreReceiveHook) (*PreReceiveHook, *Response, error)
// UpdatePreReceiveHook updates a pre-receive hook
func (s *AdminService) UpdatePreReceiveHook(ctx context.Context, id int64, hook *PreReceiveHook) (*PreReceiveHook, *Response, error)
// DeletePreReceiveHook deletes a pre-receive hook
func (s *AdminService) DeletePreReceiveHook(ctx context.Context, id int64) (*Response, error)
type PreReceiveHook struct {
ID *int64
Name *string
Script *string
ScriptRepository *Repository
Environment *PreReceiveEnvironment
Enforcement *string
AllowDownstreamConfiguration *bool
}// QueueIndexingJob queues a repository for indexing
func (s *AdminService) QueueIndexingJob(ctx context.Context, owner, repo string) (*Response, error)