mirror of
https://github.com/go-gitea/gitea
synced 2024-09-18 09:46:04 +00:00
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
81 lines
2.8 KiB
Go
81 lines
2.8 KiB
Go
// Copyright 2019 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"
|
|
)
|
|
|
|
// GetRestrictionsForOrg fetches the interaction restrictions for an organization.
|
|
//
|
|
// GitHub API docs: https://developer.github.com/v3/interactions/orgs/#get-interaction-restrictions-for-an-organization
|
|
func (s *InteractionsService) GetRestrictionsForOrg(ctx context.Context, organization string) (*InteractionRestriction, *Response, error) {
|
|
u := fmt.Sprintf("orgs/%v/interaction-limits", organization)
|
|
req, err := s.client.NewRequest("GET", u, nil)
|
|
if err != nil {
|
|
return nil, nil, err
|
|
}
|
|
|
|
// TODO: remove custom Accept header when this API fully launches.
|
|
req.Header.Set("Accept", mediaTypeInteractionRestrictionsPreview)
|
|
|
|
organizationInteractions := new(InteractionRestriction)
|
|
|
|
resp, err := s.client.Do(ctx, req, organizationInteractions)
|
|
if err != nil {
|
|
return nil, resp, err
|
|
}
|
|
|
|
return organizationInteractions, resp, nil
|
|
}
|
|
|
|
// UpdateRestrictionsForOrg adds or updates the interaction restrictions for an organization.
|
|
//
|
|
// limit specifies the group of GitHub users who can comment, open issues, or create pull requests
|
|
// in public repositories for the given organization.
|
|
// Possible values are: "existing_users", "contributors_only", "collaborators_only".
|
|
//
|
|
// GitHub API docs: https://developer.github.com/v3/interactions/orgs/#add-or-update-interaction-restrictions-for-an-organization
|
|
func (s *InteractionsService) UpdateRestrictionsForOrg(ctx context.Context, organization, limit string) (*InteractionRestriction, *Response, error) {
|
|
u := fmt.Sprintf("orgs/%v/interaction-limits", organization)
|
|
|
|
interaction := &InteractionRestriction{Limit: String(limit)}
|
|
|
|
req, err := s.client.NewRequest("PUT", u, interaction)
|
|
if err != nil {
|
|
return nil, nil, err
|
|
}
|
|
|
|
// TODO: remove custom Accept header when this API fully launches.
|
|
req.Header.Set("Accept", mediaTypeInteractionRestrictionsPreview)
|
|
|
|
organizationInteractions := new(InteractionRestriction)
|
|
|
|
resp, err := s.client.Do(ctx, req, organizationInteractions)
|
|
if err != nil {
|
|
return nil, resp, err
|
|
}
|
|
|
|
return organizationInteractions, resp, nil
|
|
}
|
|
|
|
// RemoveRestrictionsFromOrg removes the interaction restrictions for an organization.
|
|
//
|
|
// GitHub API docs: https://developer.github.com/v3/interactions/orgs/#remove-interaction-restrictions-for-an-organization
|
|
func (s *InteractionsService) RemoveRestrictionsFromOrg(ctx context.Context, organization string) (*Response, error) {
|
|
u := fmt.Sprintf("orgs/%v/interaction-limits", organization)
|
|
req, err := s.client.NewRequest("DELETE", u, nil)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
// TODO: remove custom Accept header when this API fully launches.
|
|
req.Header.Set("Accept", mediaTypeInteractionRestrictionsPreview)
|
|
|
|
return s.client.Do(ctx, req, nil)
|
|
}
|