aboutsummaryrefslogtreecommitdiff
path: root/vendor/github.com/google/go-github/github/github.go
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/github.com/google/go-github/github/github.go')
-rw-r--r--vendor/github.com/google/go-github/github/github.go80
1 files changed, 51 insertions, 29 deletions
diff --git a/vendor/github.com/google/go-github/github/github.go b/vendor/github.com/google/go-github/github/github.go
index 01e573d..4faf09c 100644
--- a/vendor/github.com/google/go-github/github/github.go
+++ b/vendor/github.com/google/go-github/github/github.go
@@ -29,7 +29,7 @@ const (
)
const (
- libraryVersion = "0.1"
+ libraryVersion = "2"
defaultBaseURL = "https://api.github.com/"
uploadBaseURL = "https://uploads.github.com/"
userAgent = "go-github/" + libraryVersion
@@ -39,9 +39,10 @@ const (
headerRateReset = "X-RateLimit-Reset"
headerOTP = "X-GitHub-OTP"
- mediaTypeV3 = "application/vnd.github.v3+json"
- defaultMediaType = "application/octet-stream"
- mediaTypeV3SHA = "application/vnd.github.v3.sha"
+ mediaTypeV3 = "application/vnd.github.v3+json"
+ defaultMediaType = "application/octet-stream"
+ mediaTypeV3SHA = "application/vnd.github.v3.sha"
+ mediaTypeOrgPermissionRepo = "application/vnd.github.v3.repository+json"
// Media Type values to access preview APIs
@@ -51,16 +52,9 @@ const (
// https://developer.github.com/changes/2014-12-09-new-attributes-for-stars-api/
mediaTypeStarringPreview = "application/vnd.github.v3.star+json"
- // https://developer.github.com/changes/2015-06-24-api-enhancements-for-working-with-organization-permissions/
- mediaTypeOrgPermissionPreview = "application/vnd.github.ironman-preview+json"
- mediaTypeOrgPermissionRepoPreview = "application/vnd.github.ironman-preview.repository+json"
-
// https://developer.github.com/changes/2015-11-11-protected-branches-api/
mediaTypeProtectedBranchesPreview = "application/vnd.github.loki-preview+json"
- // https://developer.github.com/changes/2016-02-11-issue-locking-api/
- mediaTypeIssueLockingPreview = "application/vnd.github.the-key-preview+json"
-
// https://help.github.com/enterprise/2.4/admin/guides/migrations/exporting-the-github-com-organization-s-repositories/
mediaTypeMigrationsPreview = "application/vnd.github.wyandotte-preview+json"
@@ -72,14 +66,27 @@ const (
// https://developer.github.com/changes/2016-05-12-reactions-api-preview/
mediaTypeReactionsPreview = "application/vnd.github.squirrel-girl-preview"
+
+ // https://developer.github.com/changes/2016-04-01-squash-api-preview/
+ mediaTypeSquashPreview = "application/vnd.github.polaris-preview+json"
+
+ // https://developer.github.com/changes/2016-04-04-git-signing-api-preview/
+ mediaTypeGitSigningPreview = "application/vnd.github.cryptographer-preview+json"
+
+ // https://developer.github.com/changes/2016-05-23-timeline-preview-api/
+ mediaTypeTimelinePreview = "application/vnd.github.mockingbird-preview+json"
+
+ // https://developer.github.com/changes/2016-06-14-repository-invitations/
+ mediaTypeRepositoryInvitationsPreview = "application/vnd.github.swamp-thing-preview+json"
+
+ // https://developer.github.com/changes/2016-04-21-oauth-authorizations-grants-api-preview/
+ mediaTypeOAuthGrantAuthorizationsPreview = "application/vnd.github.damage-preview+json"
)
// A Client manages communication with the GitHub API.
type Client struct {
- // HTTP client used to communicate with the API.
- client *http.Client
- // clientMu protects the client during calls that modify the CheckRedirect func.
- clientMu sync.Mutex
+ clientMu sync.Mutex // clientMu protects the client during calls that modify the CheckRedirect func.
+ client *http.Client // HTTP client used to communicate with the API.
// Base URL for API requests. Defaults to the public GitHub API, but can be
// set to a domain endpoint to use with GitHub Enterprise. BaseURL should
@@ -96,6 +103,8 @@ type Client struct {
rateLimits [categories]Rate // Rate limits for the client as determined by the most recent API calls.
mostRecent rateLimitCategory
+ common service // Reuse a single struct instead of allocating one for each service on the heap.
+
// Services used for talking to different parts of the GitHub API.
Activity *ActivityService
Authorizations *AuthorizationsService
@@ -113,6 +122,10 @@ type Client struct {
Reactions *ReactionsService
}
+type service struct {
+ client *Client
+}
+
// ListOptions specifies the optional parameters to various List methods that
// support pagination.
type ListOptions struct {
@@ -162,20 +175,21 @@ func NewClient(httpClient *http.Client) *Client {
uploadURL, _ := url.Parse(uploadBaseURL)
c := &Client{client: httpClient, BaseURL: baseURL, UserAgent: userAgent, UploadURL: uploadURL}
- c.Activity = &ActivityService{client: c}
- c.Authorizations = &AuthorizationsService{client: c}
- c.Gists = &GistsService{client: c}
- c.Git = &GitService{client: c}
- c.Gitignores = &GitignoresService{client: c}
- c.Issues = &IssuesService{client: c}
- c.Organizations = &OrganizationsService{client: c}
- c.PullRequests = &PullRequestsService{client: c}
- c.Repositories = &RepositoriesService{client: c}
- c.Search = &SearchService{client: c}
- c.Users = &UsersService{client: c}
- c.Licenses = &LicensesService{client: c}
- c.Migrations = &MigrationService{client: c}
- c.Reactions = &ReactionsService{client: c}
+ c.common.client = c
+ c.Activity = (*ActivityService)(&c.common)
+ c.Authorizations = (*AuthorizationsService)(&c.common)
+ c.Gists = (*GistsService)(&c.common)
+ c.Git = (*GitService)(&c.common)
+ c.Gitignores = (*GitignoresService)(&c.common)
+ c.Issues = (*IssuesService)(&c.common)
+ c.Licenses = (*LicensesService)(&c.common)
+ c.Migrations = (*MigrationService)(&c.common)
+ c.Organizations = (*OrganizationsService)(&c.common)
+ c.PullRequests = (*PullRequestsService)(&c.common)
+ c.Reactions = (*ReactionsService)(&c.common)
+ c.Repositories = (*RepositoriesService)(&c.common)
+ c.Search = (*SearchService)(&c.common)
+ c.Users = (*UsersService)(&c.common)
return c
}
@@ -435,6 +449,10 @@ type ErrorResponse struct {
Reason string `json:"reason,omitempty"`
CreatedAt *Timestamp `json:"created_at,omitempty"`
} `json:"block,omitempty"`
+ // Most errors will also include a documentation_url field pointing
+ // to some content that might help you resolve the error, see
+ // https://developer.github.com/v3/#client-errors
+ DocumentationURL string `json:"documentation_url,omitempty"`
}
func (r *ErrorResponse) Error() string {
@@ -490,6 +508,9 @@ These are the possible validation error codes:
the formatting of a field is invalid
already_exists:
another resource has the same valid as this field
+ custom:
+ some resources return this (e.g. github.User.CreateKey()), additional
+ information is set in the Message field of the Error
GitHub API docs: http://developer.github.com/v3/#client-errors
*/
@@ -497,6 +518,7 @@ type Error struct {
Resource string `json:"resource"` // resource on which the error occurred
Field string `json:"field"` // field on which the error occurred
Code string `json:"code"` // validation error code
+ Message string `json:"message"` // Message describing the error. Errors with Code == "custom" will always have this set.
}
func (e *Error) Error() string {