mirror of
https://github.com/documize/community.git
synced 2025-07-20 21:59:42 +02:00
go dep
Migrated from plain /vendor to go dep
This commit is contained in:
parent
0262763c95
commit
fd693f4ff4
957 changed files with 36866 additions and 177595 deletions
142
vendor/github.com/google/go-github/github/authorizations.go
generated
vendored
142
vendor/github.com/google/go-github/github/authorizations.go
generated
vendored
|
@ -5,11 +5,14 @@
|
|||
|
||||
package github
|
||||
|
||||
import "fmt"
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
// Scope models a GitHub authorization scope.
|
||||
//
|
||||
// GitHub API docs:https://developer.github.com/v3/oauth/#scopes
|
||||
// GitHub API docs: https://developer.github.com/v3/oauth/#scopes
|
||||
type Scope string
|
||||
|
||||
// This is the set of scopes for GitHub API V3
|
||||
|
@ -47,13 +50,11 @@ const (
|
|||
// an OAuth token.
|
||||
//
|
||||
// GitHub API docs: https://developer.github.com/v3/oauth_authorizations/
|
||||
type AuthorizationsService struct {
|
||||
client *Client
|
||||
}
|
||||
type AuthorizationsService service
|
||||
|
||||
// Authorization represents an individual GitHub authorization.
|
||||
type Authorization struct {
|
||||
ID *int `json:"id,omitempty"`
|
||||
ID *int64 `json:"id,omitempty"`
|
||||
URL *string `json:"url,omitempty"`
|
||||
Scopes []Scope `json:"scopes,omitempty"`
|
||||
Token *string `json:"token,omitempty"`
|
||||
|
@ -62,7 +63,7 @@ type Authorization struct {
|
|||
App *AuthorizationApp `json:"app,omitempty"`
|
||||
Note *string `json:"note,omitempty"`
|
||||
NoteURL *string `json:"note_url,omitempty"`
|
||||
UpdateAt *Timestamp `json:"updated_at,omitempty"`
|
||||
UpdatedAt *Timestamp `json:"updated_at,omitempty"`
|
||||
CreatedAt *Timestamp `json:"created_at,omitempty"`
|
||||
Fingerprint *string `json:"fingerprint,omitempty"`
|
||||
|
||||
|
@ -87,7 +88,7 @@ func (a AuthorizationApp) String() string {
|
|||
|
||||
// Grant represents an OAuth application that has been granted access to an account.
|
||||
type Grant struct {
|
||||
ID *int `json:"id,omitempty"`
|
||||
ID *int64 `json:"id,omitempty"`
|
||||
URL *string `json:"url,omitempty"`
|
||||
App *AuthorizationApp `json:"app,omitempty"`
|
||||
CreatedAt *Timestamp `json:"created_at,omitempty"`
|
||||
|
@ -116,7 +117,7 @@ func (a AuthorizationRequest) String() string {
|
|||
// AuthorizationUpdateRequest represents a request to update an authorization.
|
||||
//
|
||||
// Note that for any one update, you must only provide one of the "scopes"
|
||||
// fields. That is, you may provide only one of "Scopes", or "AddScopes", or
|
||||
// fields. That is, you may provide only one of "Scopes", or "AddScopes", or
|
||||
// "RemoveScopes".
|
||||
//
|
||||
// GitHub API docs: https://developer.github.com/v3/oauth_authorizations/#update-an-existing-authorization
|
||||
|
@ -136,7 +137,7 @@ func (a AuthorizationUpdateRequest) String() string {
|
|||
// List the authorizations for the authenticated user.
|
||||
//
|
||||
// GitHub API docs: https://developer.github.com/v3/oauth_authorizations/#list-your-authorizations
|
||||
func (s *AuthorizationsService) List(opt *ListOptions) ([]*Authorization, *Response, error) {
|
||||
func (s *AuthorizationsService) List(ctx context.Context, opt *ListOptions) ([]*Authorization, *Response, error) {
|
||||
u := "authorizations"
|
||||
u, err := addOptions(u, opt)
|
||||
if err != nil {
|
||||
|
@ -148,18 +149,18 @@ func (s *AuthorizationsService) List(opt *ListOptions) ([]*Authorization, *Respo
|
|||
return nil, nil, err
|
||||
}
|
||||
|
||||
auths := new([]*Authorization)
|
||||
resp, err := s.client.Do(req, auths)
|
||||
var auths []*Authorization
|
||||
resp, err := s.client.Do(ctx, req, &auths)
|
||||
if err != nil {
|
||||
return nil, resp, err
|
||||
}
|
||||
return *auths, resp, err
|
||||
return auths, resp, nil
|
||||
}
|
||||
|
||||
// Get a single authorization.
|
||||
//
|
||||
// GitHub API docs: https://developer.github.com/v3/oauth_authorizations/#get-a-single-authorization
|
||||
func (s *AuthorizationsService) Get(id int) (*Authorization, *Response, error) {
|
||||
func (s *AuthorizationsService) Get(ctx context.Context, id int64) (*Authorization, *Response, error) {
|
||||
u := fmt.Sprintf("authorizations/%d", id)
|
||||
|
||||
req, err := s.client.NewRequest("GET", u, nil)
|
||||
|
@ -168,17 +169,17 @@ func (s *AuthorizationsService) Get(id int) (*Authorization, *Response, error) {
|
|||
}
|
||||
|
||||
a := new(Authorization)
|
||||
resp, err := s.client.Do(req, a)
|
||||
resp, err := s.client.Do(ctx, req, a)
|
||||
if err != nil {
|
||||
return nil, resp, err
|
||||
}
|
||||
return a, resp, err
|
||||
return a, resp, nil
|
||||
}
|
||||
|
||||
// Create a new authorization for the specified OAuth application.
|
||||
//
|
||||
// GitHub API docs: https://developer.github.com/v3/oauth_authorizations/#create-a-new-authorization
|
||||
func (s *AuthorizationsService) Create(auth *AuthorizationRequest) (*Authorization, *Response, error) {
|
||||
func (s *AuthorizationsService) Create(ctx context.Context, auth *AuthorizationRequest) (*Authorization, *Response, error) {
|
||||
u := "authorizations"
|
||||
|
||||
req, err := s.client.NewRequest("POST", u, auth)
|
||||
|
@ -187,11 +188,11 @@ func (s *AuthorizationsService) Create(auth *AuthorizationRequest) (*Authorizati
|
|||
}
|
||||
|
||||
a := new(Authorization)
|
||||
resp, err := s.client.Do(req, a)
|
||||
resp, err := s.client.Do(ctx, req, a)
|
||||
if err != nil {
|
||||
return nil, resp, err
|
||||
}
|
||||
return a, resp, err
|
||||
return a, resp, nil
|
||||
}
|
||||
|
||||
// GetOrCreateForApp creates a new authorization for the specified OAuth
|
||||
|
@ -206,9 +207,9 @@ func (s *AuthorizationsService) Create(auth *AuthorizationRequest) (*Authorizati
|
|||
// clientID is the OAuth Client ID with which to create the token.
|
||||
//
|
||||
// GitHub API docs:
|
||||
// - https://developer.github.com/v3/oauth_authorizations/#get-or-create-an-authorization-for-a-specific-app
|
||||
// - https://developer.github.com/v3/oauth_authorizations/#get-or-create-an-authorization-for-a-specific-app-and-fingerprint
|
||||
func (s *AuthorizationsService) GetOrCreateForApp(clientID string, auth *AuthorizationRequest) (*Authorization, *Response, error) {
|
||||
// https://developer.github.com/v3/oauth_authorizations/#get-or-create-an-authorization-for-a-specific-app
|
||||
// https://developer.github.com/v3/oauth_authorizations/#get-or-create-an-authorization-for-a-specific-app-and-fingerprint
|
||||
func (s *AuthorizationsService) GetOrCreateForApp(ctx context.Context, clientID string, auth *AuthorizationRequest) (*Authorization, *Response, error) {
|
||||
var u string
|
||||
if auth.Fingerprint == nil || *auth.Fingerprint == "" {
|
||||
u = fmt.Sprintf("authorizations/clients/%v", clientID)
|
||||
|
@ -222,18 +223,18 @@ func (s *AuthorizationsService) GetOrCreateForApp(clientID string, auth *Authori
|
|||
}
|
||||
|
||||
a := new(Authorization)
|
||||
resp, err := s.client.Do(req, a)
|
||||
resp, err := s.client.Do(ctx, req, a)
|
||||
if err != nil {
|
||||
return nil, resp, err
|
||||
}
|
||||
|
||||
return a, resp, err
|
||||
return a, resp, nil
|
||||
}
|
||||
|
||||
// Edit a single authorization.
|
||||
//
|
||||
// GitHub API docs: https://developer.github.com/v3/oauth_authorizations/#update-an-existing-authorization
|
||||
func (s *AuthorizationsService) Edit(id int, auth *AuthorizationUpdateRequest) (*Authorization, *Response, error) {
|
||||
func (s *AuthorizationsService) Edit(ctx context.Context, id int64, auth *AuthorizationUpdateRequest) (*Authorization, *Response, error) {
|
||||
u := fmt.Sprintf("authorizations/%d", id)
|
||||
|
||||
req, err := s.client.NewRequest("PATCH", u, auth)
|
||||
|
@ -242,18 +243,18 @@ func (s *AuthorizationsService) Edit(id int, auth *AuthorizationUpdateRequest) (
|
|||
}
|
||||
|
||||
a := new(Authorization)
|
||||
resp, err := s.client.Do(req, a)
|
||||
resp, err := s.client.Do(ctx, req, a)
|
||||
if err != nil {
|
||||
return nil, resp, err
|
||||
}
|
||||
|
||||
return a, resp, err
|
||||
return a, resp, nil
|
||||
}
|
||||
|
||||
// Delete a single authorization.
|
||||
//
|
||||
// GitHub API docs: https://developer.github.com/v3/oauth_authorizations/#delete-an-authorization
|
||||
func (s *AuthorizationsService) Delete(id int) (*Response, error) {
|
||||
func (s *AuthorizationsService) Delete(ctx context.Context, id int64) (*Response, error) {
|
||||
u := fmt.Sprintf("authorizations/%d", id)
|
||||
|
||||
req, err := s.client.NewRequest("DELETE", u, nil)
|
||||
|
@ -261,7 +262,7 @@ func (s *AuthorizationsService) Delete(id int) (*Response, error) {
|
|||
return nil, err
|
||||
}
|
||||
|
||||
return s.client.Do(req, nil)
|
||||
return s.client.Do(ctx, req, nil)
|
||||
}
|
||||
|
||||
// Check if an OAuth token is valid for a specific app.
|
||||
|
@ -273,7 +274,7 @@ func (s *AuthorizationsService) Delete(id int) (*Response, error) {
|
|||
// The returned Authorization.User field will be populated.
|
||||
//
|
||||
// GitHub API docs: https://developer.github.com/v3/oauth_authorizations/#check-an-authorization
|
||||
func (s *AuthorizationsService) Check(clientID string, token string) (*Authorization, *Response, error) {
|
||||
func (s *AuthorizationsService) Check(ctx context.Context, clientID string, token string) (*Authorization, *Response, error) {
|
||||
u := fmt.Sprintf("applications/%v/tokens/%v", clientID, token)
|
||||
|
||||
req, err := s.client.NewRequest("GET", u, nil)
|
||||
|
@ -282,12 +283,12 @@ func (s *AuthorizationsService) Check(clientID string, token string) (*Authoriza
|
|||
}
|
||||
|
||||
a := new(Authorization)
|
||||
resp, err := s.client.Do(req, a)
|
||||
resp, err := s.client.Do(ctx, req, a)
|
||||
if err != nil {
|
||||
return nil, resp, err
|
||||
}
|
||||
|
||||
return a, resp, err
|
||||
return a, resp, nil
|
||||
}
|
||||
|
||||
// Reset is used to reset a valid OAuth token without end user involvement.
|
||||
|
@ -301,7 +302,7 @@ func (s *AuthorizationsService) Check(clientID string, token string) (*Authoriza
|
|||
// The returned Authorization.User field will be populated.
|
||||
//
|
||||
// GitHub API docs: https://developer.github.com/v3/oauth_authorizations/#reset-an-authorization
|
||||
func (s *AuthorizationsService) Reset(clientID string, token string) (*Authorization, *Response, error) {
|
||||
func (s *AuthorizationsService) Reset(ctx context.Context, clientID string, token string) (*Authorization, *Response, error) {
|
||||
u := fmt.Sprintf("applications/%v/tokens/%v", clientID, token)
|
||||
|
||||
req, err := s.client.NewRequest("POST", u, nil)
|
||||
|
@ -310,12 +311,12 @@ func (s *AuthorizationsService) Reset(clientID string, token string) (*Authoriza
|
|||
}
|
||||
|
||||
a := new(Authorization)
|
||||
resp, err := s.client.Do(req, a)
|
||||
resp, err := s.client.Do(ctx, req, a)
|
||||
if err != nil {
|
||||
return nil, resp, err
|
||||
}
|
||||
|
||||
return a, resp, err
|
||||
return a, resp, nil
|
||||
}
|
||||
|
||||
// Revoke an authorization for an application.
|
||||
|
@ -325,7 +326,7 @@ func (s *AuthorizationsService) Reset(clientID string, token string) (*Authoriza
|
|||
// clientSecret. Invalid tokens will return a 404 Not Found.
|
||||
//
|
||||
// GitHub API docs: https://developer.github.com/v3/oauth_authorizations/#revoke-an-authorization-for-an-application
|
||||
func (s *AuthorizationsService) Revoke(clientID string, token string) (*Response, error) {
|
||||
func (s *AuthorizationsService) Revoke(ctx context.Context, clientID string, token string) (*Response, error) {
|
||||
u := fmt.Sprintf("applications/%v/tokens/%v", clientID, token)
|
||||
|
||||
req, err := s.client.NewRequest("DELETE", u, nil)
|
||||
|
@ -333,7 +334,7 @@ func (s *AuthorizationsService) Revoke(clientID string, token string) (*Response
|
|||
return nil, err
|
||||
}
|
||||
|
||||
return s.client.Do(req, nil)
|
||||
return s.client.Do(ctx, req, nil)
|
||||
}
|
||||
|
||||
// ListGrants lists the set of OAuth applications that have been granted
|
||||
|
@ -342,44 +343,43 @@ func (s *AuthorizationsService) Revoke(clientID string, token string) (*Response
|
|||
// tokens an application has generated for the user.
|
||||
//
|
||||
// GitHub API docs: https://developer.github.com/v3/oauth_authorizations/#list-your-grants
|
||||
func (s *AuthorizationsService) ListGrants() ([]*Grant, *Response, error) {
|
||||
req, err := s.client.NewRequest("GET", "applications/grants", nil)
|
||||
func (s *AuthorizationsService) ListGrants(ctx context.Context, opt *ListOptions) ([]*Grant, *Response, error) {
|
||||
u, err := addOptions("applications/grants", opt)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
// TODO: remove custom Accept header when this API fully launches.
|
||||
req.Header.Set("Accept", mediaTypeOAuthGrantAuthorizationsPreview)
|
||||
req, err := s.client.NewRequest("GET", u, nil)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
grants := []*Grant{}
|
||||
resp, err := s.client.Do(req, &grants)
|
||||
resp, err := s.client.Do(ctx, req, &grants)
|
||||
if err != nil {
|
||||
return nil, resp, err
|
||||
}
|
||||
|
||||
return grants, resp, err
|
||||
return grants, resp, nil
|
||||
}
|
||||
|
||||
// GetGrant gets a single OAuth application grant.
|
||||
//
|
||||
// GitHub API docs: https://developer.github.com/v3/oauth_authorizations/#get-a-single-grant
|
||||
func (s *AuthorizationsService) GetGrant(id int) (*Grant, *Response, error) {
|
||||
func (s *AuthorizationsService) GetGrant(ctx context.Context, id int64) (*Grant, *Response, error) {
|
||||
u := fmt.Sprintf("applications/grants/%d", id)
|
||||
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", mediaTypeOAuthGrantAuthorizationsPreview)
|
||||
|
||||
grant := new(Grant)
|
||||
resp, err := s.client.Do(req, grant)
|
||||
resp, err := s.client.Do(ctx, req, grant)
|
||||
if err != nil {
|
||||
return nil, resp, err
|
||||
}
|
||||
|
||||
return grant, resp, err
|
||||
return grant, resp, nil
|
||||
}
|
||||
|
||||
// DeleteGrant deletes an OAuth application grant. Deleting an application's
|
||||
|
@ -387,15 +387,49 @@ func (s *AuthorizationsService) GetGrant(id int) (*Grant, *Response, error) {
|
|||
// the user.
|
||||
//
|
||||
// GitHub API docs: https://developer.github.com/v3/oauth_authorizations/#delete-a-grant
|
||||
func (s *AuthorizationsService) DeleteGrant(id int) (*Response, error) {
|
||||
func (s *AuthorizationsService) DeleteGrant(ctx context.Context, id int64) (*Response, error) {
|
||||
u := fmt.Sprintf("applications/grants/%d", id)
|
||||
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", mediaTypeOAuthGrantAuthorizationsPreview)
|
||||
|
||||
return s.client.Do(req, nil)
|
||||
return s.client.Do(ctx, req, nil)
|
||||
}
|
||||
|
||||
// CreateImpersonation creates an impersonation OAuth token.
|
||||
//
|
||||
// This requires admin permissions. With the returned Authorization.Token
|
||||
// you can e.g. create or delete a user's public SSH key. NOTE: creating a
|
||||
// new token automatically revokes an existing one.
|
||||
//
|
||||
// GitHub API docs: https://developer.github.com/enterprise/2.5/v3/users/administration/#create-an-impersonation-oauth-token
|
||||
func (s *AuthorizationsService) CreateImpersonation(ctx context.Context, username string, authReq *AuthorizationRequest) (*Authorization, *Response, error) {
|
||||
u := fmt.Sprintf("admin/users/%v/authorizations", username)
|
||||
req, err := s.client.NewRequest("POST", u, authReq)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
a := new(Authorization)
|
||||
resp, err := s.client.Do(ctx, req, a)
|
||||
if err != nil {
|
||||
return nil, resp, err
|
||||
}
|
||||
return a, resp, nil
|
||||
}
|
||||
|
||||
// DeleteImpersonation deletes an impersonation OAuth token.
|
||||
//
|
||||
// NOTE: there can be only one at a time.
|
||||
//
|
||||
// GitHub API docs: https://developer.github.com/enterprise/2.5/v3/users/administration/#delete-an-impersonation-oauth-token
|
||||
func (s *AuthorizationsService) DeleteImpersonation(ctx context.Context, username string) (*Response, error) {
|
||||
u := fmt.Sprintf("admin/users/%v/authorizations", username)
|
||||
req, err := s.client.NewRequest("DELETE", u, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return s.client.Do(ctx, req, nil)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue