From 921818bca208f0c70e85ec670074cb3905cbbc82 Mon Sep 17 00:00:00 2001 From: Niall Sheridan Date: Sat, 27 Aug 2016 01:32:30 +0100 Subject: Update dependencies --- .../go-github/github/activity_notifications.go | 21 +-- .../google/go-github/github/authorizations.go | 4 +- vendor/github.com/google/go-github/github/doc.go | 4 +- .../google/go-github/github/event_types.go | 5 +- .../github.com/google/go-github/github/github.go | 27 +++- .../go-github/github/migrations_source_import.go | 2 +- vendor/github.com/google/go-github/github/orgs.go | 3 + vendor/github.com/google/go-github/github/pulls.go | 3 +- vendor/github.com/google/go-github/github/repos.go | 2 + .../google/go-github/github/repos_pages.go | 26 ++++ .../google/go-github/github/repos_traffic.go | 173 +++++++++++++++++++++ .../github.com/google/go-github/github/search.go | 20 ++- 12 files changed, 253 insertions(+), 37 deletions(-) create mode 100644 vendor/github.com/google/go-github/github/repos_traffic.go (limited to 'vendor/github.com/google/go-github') diff --git a/vendor/github.com/google/go-github/github/activity_notifications.go b/vendor/github.com/google/go-github/github/activity_notifications.go index 8890388..b538a7b 100644 --- a/vendor/github.com/google/go-github/github/activity_notifications.go +++ b/vendor/github.com/google/go-github/github/activity_notifications.go @@ -96,20 +96,17 @@ func (s *ActivityService) ListRepositoryNotifications(owner, repo string, opt *N } type markReadOptions struct { - LastReadAt time.Time `url:"last_read_at,omitempty"` + LastReadAt time.Time `json:"last_read_at,omitempty"` } // MarkNotificationsRead marks all notifications up to lastRead as read. // // GitHub API Docs: https://developer.github.com/v3/activity/notifications/#mark-as-read func (s *ActivityService) MarkNotificationsRead(lastRead time.Time) (*Response, error) { - u := fmt.Sprintf("notifications") - u, err := addOptions(u, markReadOptions{lastRead}) - if err != nil { - return nil, err + opts := &markReadOptions{ + LastReadAt: lastRead, } - - req, err := s.client.NewRequest("PUT", u, nil) + req, err := s.client.NewRequest("PUT", "notifications", opts) if err != nil { return nil, err } @@ -122,13 +119,11 @@ func (s *ActivityService) MarkNotificationsRead(lastRead time.Time) (*Response, // // GitHub API Docs: https://developer.github.com/v3/activity/notifications/#mark-notifications-as-read-in-a-repository func (s *ActivityService) MarkRepositoryNotificationsRead(owner, repo string, lastRead time.Time) (*Response, error) { - u := fmt.Sprintf("repos/%v/%v/notifications", owner, repo) - u, err := addOptions(u, markReadOptions{lastRead}) - if err != nil { - return nil, err + opts := &markReadOptions{ + LastReadAt: lastRead, } - - req, err := s.client.NewRequest("PUT", u, nil) + u := fmt.Sprintf("repos/%v/%v/notifications", owner, repo) + req, err := s.client.NewRequest("PUT", u, opts) if err != nil { return nil, err } diff --git a/vendor/github.com/google/go-github/github/authorizations.go b/vendor/github.com/google/go-github/github/authorizations.go index 58fcc4e..35ce9a9 100644 --- a/vendor/github.com/google/go-github/github/authorizations.go +++ b/vendor/github.com/google/go-github/github/authorizations.go @@ -398,7 +398,7 @@ func (s *AuthorizationsService) DeleteGrant(id int) (*Response, error) { return s.client.Do(req, nil) } -// Create an impersonation OAuth token. +// 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 @@ -420,7 +420,7 @@ func (s *AuthorizationsService) CreateImpersonation(username string, authReq *Au return a, resp, err } -// Delete an impersonation OAuth token. +// DeleteImpersonation deletes an impersonation OAuth token. // // NOTE: there can be only one at a time. // diff --git a/vendor/github.com/google/go-github/github/doc.go b/vendor/github.com/google/go-github/github/doc.go index ba7b089..2b61068 100644 --- a/vendor/github.com/google/go-github/github/doc.go +++ b/vendor/github.com/google/go-github/github/doc.go @@ -22,8 +22,8 @@ Some API methods have optional parameters that can be passed. For example: client := github.NewClient(nil) - // list recently updated repositories for org "github" - opt := &github.RepositoryListByOrgOptions{Sort: "updated"} + // list public repositories for org "github" + opt := &github.RepositoryListByOrgOptions{Type: "public"} repos, _, err := client.Repositories.ListByOrg("github", opt) The services of a client divide the API into logical chunks and correspond to diff --git a/vendor/github.com/google/go-github/github/event_types.go b/vendor/github.com/google/go-github/github/event_types.go index f3e163d..20f509a 100644 --- a/vendor/github.com/google/go-github/github/event_types.go +++ b/vendor/github.com/google/go-github/github/event_types.go @@ -123,8 +123,9 @@ type GollumEvent struct { Sender *User `json:"sender,omitempty"` } -// DEPRECATED: IssueActivityEvent represents the payload delivered by Issue webhook -// Use IssuesEvent instead. +// IssueActivityEvent represents the payload delivered by Issue webhook. +// +// Deprecated: Use IssuesEvent instead. type IssueActivityEvent struct { Action *string `json:"action,omitempty"` Issue *Issue `json:"issue,omitempty"` diff --git a/vendor/github.com/google/go-github/github/github.go b/vendor/github.com/google/go-github/github/github.go index 4faf09c..8448982 100644 --- a/vendor/github.com/google/go-github/github/github.go +++ b/vendor/github.com/google/go-github/github/github.go @@ -81,6 +81,12 @@ const ( // https://developer.github.com/changes/2016-04-21-oauth-authorizations-grants-api-preview/ mediaTypeOAuthGrantAuthorizationsPreview = "application/vnd.github.damage-preview+json" + + // https://developer.github.com/changes/2016-07-06-github-pages-preiew-api/ + mediaTypePagesPreview = "application/vnd.github.mister-fantastic-preview+json" + + // https://developer.github.com/v3/repos/traffic/ + mediaTypeTrafficPreview = "application/vnd.github.spiderman-preview+json" ) // A Client manages communication with the GitHub API. @@ -220,9 +226,12 @@ func (c *Client) NewRequest(method, urlStr string, body interface{}) (*http.Requ return nil, err } - req.Header.Add("Accept", mediaTypeV3) + if body != nil { + req.Header.Set("Content-Type", "application/json") + } + req.Header.Set("Accept", mediaTypeV3) if c.UserAgent != "" { - req.Header.Add("User-Agent", c.UserAgent) + req.Header.Set("User-Agent", c.UserAgent) } return req, nil } @@ -243,12 +252,12 @@ func (c *Client) NewUploadRequest(urlStr string, reader io.Reader, size int64, m } req.ContentLength = size - if len(mediaType) == 0 { + if mediaType == "" { mediaType = defaultMediaType } - req.Header.Add("Content-Type", mediaType) - req.Header.Add("Accept", mediaTypeV3) - req.Header.Add("User-Agent", c.UserAgent) + req.Header.Set("Content-Type", mediaType) + req.Header.Set("Accept", mediaTypeV3) + req.Header.Set("User-Agent", c.UserAgent) return req, nil } @@ -408,7 +417,7 @@ func (c *Client) Do(req *http.Request, v interface{}) (*Response, error) { // checkRateLimitBeforeDo does not make any network calls, but uses existing knowledge from // current client state in order to quickly check if *RateLimitError can be immediately returned -// from Client.Do, and if so, returns it so that Client.Do can skip making a network API call unneccessarily. +// from Client.Do, and if so, returns it so that Client.Do can skip making a network API call unnecessarily. // Otherwise it returns nil, and Client.Do should proceed normally. func (c *Client) checkRateLimitBeforeDo(req *http.Request, rateLimitCategory rateLimitCategory) error { c.rateMu.Lock() @@ -632,6 +641,8 @@ func category(path string) rateLimitCategory { } } +// RateLimit returns the core rate limit for the current client. +// // Deprecated: RateLimit is deprecated, use RateLimits instead. func (c *Client) RateLimit() (*Rate, *Response, error) { limits, resp, err := c.RateLimits() @@ -756,7 +767,7 @@ func (t *BasicAuthTransport) RoundTrip(req *http.Request) (*http.Response, error req = cloneRequest(req) // per RoundTrip contract req.SetBasicAuth(t.Username, t.Password) if t.OTP != "" { - req.Header.Add(headerOTP, t.OTP) + req.Header.Set(headerOTP, t.OTP) } return t.transport().RoundTrip(req) } diff --git a/vendor/github.com/google/go-github/github/migrations_source_import.go b/vendor/github.com/google/go-github/github/migrations_source_import.go index 6ed4acf..44505fa 100644 --- a/vendor/github.com/google/go-github/github/migrations_source_import.go +++ b/vendor/github.com/google/go-github/github/migrations_source_import.go @@ -163,7 +163,7 @@ func (s *MigrationService) StartImport(owner, repo string, in *Import) (*Import, return out, resp, err } -// QueryImport queries for the status and progress of an ongoing repository import. +// ImportProgress queries for the status and progress of an ongoing repository import. // // GitHub API docs: https://developer.github.com/v3/migration/source_imports/#get-import-progress func (s *MigrationService) ImportProgress(owner, repo string) (*Import, *Response, error) { diff --git a/vendor/github.com/google/go-github/github/orgs.go b/vendor/github.com/google/go-github/github/orgs.go index e71055c..d137e3e 100644 --- a/vendor/github.com/google/go-github/github/orgs.go +++ b/vendor/github.com/google/go-github/github/orgs.go @@ -27,6 +27,7 @@ type Organization struct { Blog *string `json:"blog,omitempty"` Location *string `json:"location,omitempty"` Email *string `json:"email,omitempty"` + Description *string `json:"description,omitempty"` PublicRepos *int `json:"public_repos,omitempty"` PublicGists *int `json:"public_gists,omitempty"` Followers *int `json:"followers,omitempty"` @@ -45,6 +46,8 @@ type Organization struct { // API URLs URL *string `json:"url,omitempty"` EventsURL *string `json:"events_url,omitempty"` + HooksURL *string `json:"hooks_url,omitempty"` + IssuesURL *string `json:"issues_url,omitempty"` MembersURL *string `json:"members_url,omitempty"` PublicMembersURL *string `json:"public_members_url,omitempty"` ReposURL *string `json:"repos_url,omitempty"` diff --git a/vendor/github.com/google/go-github/github/pulls.go b/vendor/github.com/google/go-github/github/pulls.go index 0900766..0611507 100644 --- a/vendor/github.com/google/go-github/github/pulls.go +++ b/vendor/github.com/google/go-github/github/pulls.go @@ -42,7 +42,8 @@ type PullRequest struct { StatusesURL *string `json:"statuses_url,omitempty"` DiffURL *string `json:"diff_url,omitempty"` PatchURL *string `json:"patch_url,omitempty"` - Assignee *User `json:"assignee,omitempty"` // probably only in webhooks + Assignee *User `json:"assignee,omitempty"` + Assignees []*User `json:"assignees,omitempty"` Head *PullRequestBranch `json:"head,omitempty"` Base *PullRequestBranch `json:"base,omitempty"` diff --git a/vendor/github.com/google/go-github/github/repos.go b/vendor/github.com/google/go-github/github/repos.go index fb402ee..2bcaacc 100644 --- a/vendor/github.com/google/go-github/github/repos.go +++ b/vendor/github.com/google/go-github/github/repos.go @@ -54,6 +54,7 @@ type Repository struct { Private *bool `json:"private"` HasIssues *bool `json:"has_issues"` HasWiki *bool `json:"has_wiki"` + HasPages *bool `json:"has_pages"` HasDownloads *bool `json:"has_downloads"` // Creating an organization repository. Required for non-owners. TeamID *int `json:"team_id"` @@ -70,6 +71,7 @@ type Repository struct { CompareURL *string `json:"compare_url,omitempty"` ContentsURL *string `json:"contents_url,omitempty"` ContributorsURL *string `json:"contributors_url,omitempty"` + DeploymentsURL *string `json:"deployments_url,omitempty"` DownloadsURL *string `json:"downloads_url,omitempty"` EventsURL *string `json:"events_url,omitempty"` ForksURL *string `json:"forks_url,omitempty"` diff --git a/vendor/github.com/google/go-github/github/repos_pages.go b/vendor/github.com/google/go-github/github/repos_pages.go index 8594edc..ccd24f3 100644 --- a/vendor/github.com/google/go-github/github/repos_pages.go +++ b/vendor/github.com/google/go-github/github/repos_pages.go @@ -13,6 +13,7 @@ type Pages struct { Status *string `json:"status,omitempty"` CNAME *string `json:"cname,omitempty"` Custom404 *bool `json:"custom_404,omitempty"` + HTMLURL *string `json:"html_url,omitempty"` } // PagesError represents a build error for a GitHub Pages site. @@ -42,6 +43,9 @@ func (s *RepositoriesService) GetPagesInfo(owner string, repo string) (*Pages, * return nil, nil, err } + // TODO: remove custom Accept header when this API fully launches. + req.Header.Set("Accept", mediaTypePagesPreview) + site := new(Pages) resp, err := s.client.Do(req, site) if err != nil { @@ -88,3 +92,25 @@ func (s *RepositoriesService) GetLatestPagesBuild(owner string, repo string) (*P return build, resp, err } + +// RequestPageBuild requests a build of a GitHub Pages site without needing to push new commit. +// +// GitHub API docs: https://developer.github.com/v3/repos/pages/#request-a-page-build +func (s *RepositoriesService) RequestPageBuild(owner string, repo string) (*PagesBuild, *Response, error) { + u := fmt.Sprintf("repos/%v/%v/pages/builds", owner, repo) + req, err := s.client.NewRequest("POST", u, nil) + if err != nil { + return nil, nil, err + } + + // TODO: remove custom Accept header when this API fully launches. + req.Header.Set("Accept", mediaTypePagesPreview) + + build := new(PagesBuild) + resp, err := s.client.Do(req, build) + if err != nil { + return nil, resp, err + } + + return build, resp, err +} diff --git a/vendor/github.com/google/go-github/github/repos_traffic.go b/vendor/github.com/google/go-github/github/repos_traffic.go new file mode 100644 index 0000000..b6c8d83 --- /dev/null +++ b/vendor/github.com/google/go-github/github/repos_traffic.go @@ -0,0 +1,173 @@ +// Copyright 2016 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 ( + "fmt" + "strconv" + "time" +) + +// TrafficReferrer represent information about traffic from a referrer . +type TrafficReferrer struct { + Referrer *string `json:"referrer,omitempty"` + Count *int `json:"count,omitempty"` + Uniques *int `json:"uniques,omitempty"` +} + +// TrafficPath represent information about the traffic on a path of the repo. +type TrafficPath struct { + Path *string `json:"path,omitempty"` + Title *string `json:"title,omitempty"` + Count *int `json:"count,omitempty"` + Uniques *int `json:"uniques,omitempty"` +} + +// TimestampMS represents a timestamp as used in datapoint. +// +// It's only used to parse the result given by the API which are unix timestamp in milliseonds. +type TimestampMS struct { + time.Time +} + +// UnmarshalJSON parse unix timestamp. +func (t *TimestampMS) UnmarshalJSON(b []byte) error { + s := string(b) + i, err := strconv.ParseInt(s, 10, 64) + if err != nil { + return err + } + // We can drop the reaminder as returned values are days and it will always be 0 + *t = TimestampMS{time.Unix(i/1000, 0)} + return nil +} + +// TrafficData represent information about a specific timestamp in views or clones list. +type TrafficData struct { + Timestamp *TimestampMS `json:"timestamp,omitempty"` + Count *int `json:"count,omitempty"` + Uniques *int `json:"uniques,omitempty"` +} + +// TrafficViews represent information about the number of views in the last 14 days. +type TrafficViews struct { + Views []*TrafficData `json:"views,omitempty"` + Count *int `json:"count,omitempty"` + Uniques *int `json:"uniques,omitempty"` +} + +// TrafficClones represent information about the number of clones in the last 14 days. +type TrafficClones struct { + Clones []*TrafficData `json:"clones,omitempty"` + Count *int `json:"count,omitempty"` + Uniques *int `json:"uniques,omitempty"` +} + +// TrafficBreakdownOptions specifies the parameters to methods that support breakdown per day or week. +// Can be one of: day, week. Default: day. +type TrafficBreakdownOptions struct { + Per string `url:"per,omitempty"` +} + +// ListTrafficReferrers list the top 10 referrers over the last 14 days. +// +// GitHub API docs: https://developer.github.com/v3/repos/traffic/#list-referrers +func (s *RepositoriesService) ListTrafficReferrers(owner, repo string) ([]*TrafficReferrer, *Response, error) { + u := fmt.Sprintf("repos/%v/%v/traffic/popular/referrers", owner, repo) + + 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", mediaTypeTrafficPreview) + + trafficReferrers := new([]*TrafficReferrer) + resp, err := s.client.Do(req, &trafficReferrers) + if err != nil { + return nil, resp, err + } + + return *trafficReferrers, resp, err +} + +// ListTrafficPaths list the top 10 popular content over the last 14 days. +// +// GitHub API docs: https://developer.github.com/v3/repos/traffic/#list-paths +func (s *RepositoriesService) ListTrafficPaths(owner, repo string) ([]*TrafficPath, *Response, error) { + u := fmt.Sprintf("repos/%v/%v/traffic/popular/paths", owner, repo) + + 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", mediaTypeTrafficPreview) + + var paths = new([]*TrafficPath) + resp, err := s.client.Do(req, &paths) + if err != nil { + return nil, resp, err + } + + return *paths, resp, err +} + +// ListTrafficViews get total number of views for the last 14 days and breaks it down either per day or week. +// +// GitHub API docs: https://developer.github.com/v3/repos/traffic/#views +func (s *RepositoriesService) ListTrafficViews(owner, repo string, opt *TrafficBreakdownOptions) (*TrafficViews, *Response, error) { + u := fmt.Sprintf("repos/%v/%v/traffic/views", owner, repo) + u, err := addOptions(u, opt) + if err != nil { + return nil, nil, err + } + + 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", mediaTypeTrafficPreview) + + trafficViews := new(TrafficViews) + resp, err := s.client.Do(req, &trafficViews) + if err != nil { + return nil, resp, err + } + + return trafficViews, resp, err +} + +// ListTrafficClones get total number of clones for the last 14 days and breaks it down either per day or week for the last 14 days. +// +// GitHub API docs: https://developer.github.com/v3/repos/traffic/#views +func (s *RepositoriesService) ListTrafficClones(owner, repo string, opt *TrafficBreakdownOptions) (*TrafficClones, *Response, error) { + u := fmt.Sprintf("repos/%v/%v/traffic/clones", owner, repo) + u, err := addOptions(u, opt) + if err != nil { + return nil, nil, err + } + + 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", mediaTypeTrafficPreview) + + trafficClones := new(TrafficClones) + resp, err := s.client.Do(req, &trafficClones) + if err != nil { + return nil, resp, err + } + + return trafficClones, resp, err +} diff --git a/vendor/github.com/google/go-github/github/search.go b/vendor/github.com/google/go-github/github/search.go index 0c7ffcb..916a2dc 100644 --- a/vendor/github.com/google/go-github/github/search.go +++ b/vendor/github.com/google/go-github/github/search.go @@ -40,8 +40,9 @@ type SearchOptions struct { // RepositoriesSearchResult represents the result of a repositories search. type RepositoriesSearchResult struct { - Total *int `json:"total_count,omitempty"` - Repositories []Repository `json:"items,omitempty"` + Total *int `json:"total_count,omitempty"` + IncompleteResults *bool `json:"incomplete_results,omitempty"` + Repositories []Repository `json:"items,omitempty"` } // Repositories searches repositories via various criteria. @@ -55,8 +56,9 @@ func (s *SearchService) Repositories(query string, opt *SearchOptions) (*Reposit // IssuesSearchResult represents the result of an issues search. type IssuesSearchResult struct { - Total *int `json:"total_count,omitempty"` - Issues []Issue `json:"items,omitempty"` + Total *int `json:"total_count,omitempty"` + IncompleteResults *bool `json:"incomplete_results,omitempty"` + Issues []Issue `json:"items,omitempty"` } // Issues searches issues via various criteria. @@ -70,8 +72,9 @@ func (s *SearchService) Issues(query string, opt *SearchOptions) (*IssuesSearchR // UsersSearchResult represents the result of an issues search. type UsersSearchResult struct { - Total *int `json:"total_count,omitempty"` - Users []User `json:"items,omitempty"` + Total *int `json:"total_count,omitempty"` + IncompleteResults *bool `json:"incomplete_results,omitempty"` + Users []User `json:"items,omitempty"` } // Users searches users via various criteria. @@ -104,8 +107,9 @@ func (tm TextMatch) String() string { // CodeSearchResult represents the result of an code search. type CodeSearchResult struct { - Total *int `json:"total_count,omitempty"` - CodeResults []CodeResult `json:"items,omitempty"` + Total *int `json:"total_count,omitempty"` + IncompleteResults *bool `json:"incomplete_results,omitempty"` + CodeResults []CodeResult `json:"items,omitempty"` } // CodeResult represents a single search result. -- cgit v1.2.3