08069dc465
* add migrations * fix package dependency * fix lints * implements migrations except pull requests * add releases * migrating releases * fix bug * fix lint * fix migrate releases * fix tests * add rollback * pull request migtations * fix import * fix go module vendor * add tests for upload to gitea * more migrate options * fix swagger-check * fix misspell * add options on migration UI * fix log error * improve UI options on migrating * add support for username password when migrating from github * fix tests * remove comments and fix migrate limitation * improve error handles * migrate API will also support migrate milestones/labels/issues/pulls/releases * fix tests and remove unused codes * add DownloaderFactory and docs about how to create a new Downloader * fix misspell * fix migration docs * Add hints about migrate options on migration page * fix tests
72 lines
2.2 KiB
Go
Vendored
72 lines
2.2 KiB
Go
Vendored
// Copyright 2014 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 (
|
|
"context"
|
|
"fmt"
|
|
)
|
|
|
|
// PromoteSiteAdmin promotes a user to a site administrator of a GitHub Enterprise instance.
|
|
//
|
|
// GitHub API docs: https://developer.github.com/enterprise/v3/enterprise-admin/users/#promote-an-ordinary-user-to-a-site-administrator
|
|
func (s *UsersService) PromoteSiteAdmin(ctx context.Context, user string) (*Response, error) {
|
|
u := fmt.Sprintf("users/%v/site_admin", user)
|
|
|
|
req, err := s.client.NewRequest("PUT", u, nil)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return s.client.Do(ctx, req, nil)
|
|
}
|
|
|
|
// DemoteSiteAdmin demotes a user from site administrator of a GitHub Enterprise instance.
|
|
//
|
|
// GitHub API docs: https://developer.github.com/enterprise/v3/enterprise-admin/users/#demote-a-site-administrator-to-an-ordinary-user
|
|
func (s *UsersService) DemoteSiteAdmin(ctx context.Context, user string) (*Response, error) {
|
|
u := fmt.Sprintf("users/%v/site_admin", user)
|
|
|
|
req, err := s.client.NewRequest("DELETE", u, nil)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return s.client.Do(ctx, req, nil)
|
|
}
|
|
|
|
// UserSuspendOptions represents the reason a user is being suspended.
|
|
type UserSuspendOptions struct {
|
|
Reason *string `json:"reason,omitempty"`
|
|
}
|
|
|
|
// Suspend a user on a GitHub Enterprise instance.
|
|
//
|
|
// GitHub API docs: https://developer.github.com/enterprise/v3/enterprise-admin/users/#suspend-a-user
|
|
func (s *UsersService) Suspend(ctx context.Context, user string, opt *UserSuspendOptions) (*Response, error) {
|
|
u := fmt.Sprintf("users/%v/suspended", user)
|
|
|
|
req, err := s.client.NewRequest("PUT", u, opt)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return s.client.Do(ctx, req, nil)
|
|
}
|
|
|
|
// Unsuspend a user on a GitHub Enterprise instance.
|
|
//
|
|
// GitHub API docs: https://developer.github.com/enterprise/v3/enterprise-admin/users/#unsuspend-a-user
|
|
func (s *UsersService) Unsuspend(ctx context.Context, user string) (*Response, error) {
|
|
u := fmt.Sprintf("users/%v/suspended", user)
|
|
|
|
req, err := s.client.NewRequest("DELETE", u, nil)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return s.client.Do(ctx, req, nil)
|
|
}
|