api

package
v0.4.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 14, 2020 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client facilitates making HTTP requests to the GitHub API

func NewClient

func NewClient(opts ...ClientOption) *Client

NewClient initializes a Client

func (Client) GraphQL

func (c Client) GraphQL(query string, variables map[string]interface{}, data interface{}) error

GraphQL performs a GraphQL request and parses the response

func (Client) REST

func (c Client) REST(method string, p string, body io.Reader, data interface{}) error

REST performs a REST request and parses the response.

type ClientOption

type ClientOption = func(http.RoundTripper) http.RoundTripper

ClientOption represents an argument to NewClient

func AddHeader

func AddHeader(name, value string) ClientOption

AddHeader turns a RoundTripper into one that adds a request header

func ReplaceTripper

func ReplaceTripper(tr http.RoundTripper) ClientOption

ReplaceTripper substitutes the underlying RoundTripper with a custom one

func VerboseLog

func VerboseLog(out io.Writer) ClientOption

VerboseLog enables request/response logging within a RoundTripper

type FakeHTTP

type FakeHTTP struct {
	// Requests stores references to sequental requests that RoundTrip has received
	Requests []*http.Request
	// contains filtered or unexported fields
}

FakeHTTP provides a mechanism by which to stub HTTP responses through

func (*FakeHTTP) RoundTrip

func (f *FakeHTTP) RoundTrip(req *http.Request) (*http.Response, error)

RoundTrip satisfies http.RoundTripper

func (*FakeHTTP) StubResponse

func (f *FakeHTTP) StubResponse(status int, body io.Reader)

StubResponse pre-records an HTTP response

type Issue

type Issue struct {
	Number   int
	Title    string
	URL      string
	State    string
	Body     string
	Comments struct {
		TotalCount int
	}
	Author struct {
		Login string
	}

	Labels struct {
		Nodes      []IssueLabel
		TotalCount int
	}
}

func IssueByNumber

func IssueByNumber(client *Client, ghRepo Repo, number int) (*Issue, error)

func IssueCreate

func IssueCreate(client *Client, repo *Repository, params map[string]interface{}) (*Issue, error)

IssueCreate creates an issue in a GitHub repository

func IssueList

func IssueList(client *Client, ghRepo Repo, state string, labels []string, assigneeString string, limit int) ([]Issue, error)

type IssueLabel

type IssueLabel struct {
	Name string
}

type IssuesAndTotalCount

type IssuesAndTotalCount struct {
	Issues     []Issue
	TotalCount int
}

type IssuesPayload

type IssuesPayload struct {
	Assigned  IssuesAndTotalCount
	Mentioned IssuesAndTotalCount
	Authored  IssuesAndTotalCount
}

func IssueStatus

func IssueStatus(client *Client, ghRepo Repo, currentUsername string) (*IssuesPayload, error)

type NotFoundError

type NotFoundError struct {
	// contains filtered or unexported fields
}

type PullRequest

type PullRequest struct {
	Number      int
	Title       string
	State       string
	URL         string
	BaseRefName string
	HeadRefName string
	Body        string

	Author struct {
		Login string
	}
	HeadRepositoryOwner struct {
		Login string
	}
	HeadRepository struct {
		Name             string
		DefaultBranchRef struct {
			Name string
		}
	}
	IsCrossRepository   bool
	MaintainerCanModify bool

	ReviewDecision string

	Commits struct {
		TotalCount int
		Nodes      []struct {
			Commit struct {
				StatusCheckRollup struct {
					Contexts struct {
						Nodes []struct {
							State      string
							Status     string
							Conclusion string
						}
					}
				}
			}
		}
	}
}

func CreatePullRequest

func CreatePullRequest(client *Client, ghRepo Repo, params map[string]interface{}) (*PullRequest, error)

func PullRequestByNumber

func PullRequestByNumber(client *Client, ghRepo Repo, number int) (*PullRequest, error)

func PullRequestForBranch

func PullRequestForBranch(client *Client, ghRepo Repo, branch string) (*PullRequest, error)

func PullRequestList

func PullRequestList(client *Client, vars map[string]interface{}, limit int) ([]PullRequest, error)

func (*PullRequest) ChecksStatus

func (pr *PullRequest) ChecksStatus() (summary PullRequestChecksStatus)

func (PullRequest) HeadLabel

func (pr PullRequest) HeadLabel() string

func (*PullRequest) ReviewStatus

func (pr *PullRequest) ReviewStatus() PullRequestReviewStatus

type PullRequestAndTotalCount

type PullRequestAndTotalCount struct {
	TotalCount   int
	PullRequests []PullRequest
}

type PullRequestChecksStatus

type PullRequestChecksStatus struct {
	Pending int
	Failing int
	Passing int
	Total   int
}

type PullRequestReviewStatus

type PullRequestReviewStatus struct {
	ChangesRequested bool
	Approved         bool
	ReviewRequired   bool
}

type PullRequestsPayload

type PullRequestsPayload struct {
	ViewerCreated   PullRequestAndTotalCount
	ReviewRequested PullRequestAndTotalCount
	CurrentPR       *PullRequest
}

func PullRequests

func PullRequests(client *Client, ghRepo Repo, currentPRNumber int, currentPRHeadRef, currentUsername string) (*PullRequestsPayload, error)

type Repo

type Repo interface {
	RepoName() string
	RepoOwner() string
}

type Repository

type Repository struct {
	ID               string
	HasIssuesEnabled bool
}

Repository contains information about a GitHub repo

func GitHubRepo

func GitHubRepo(client *Client, ghRepo Repo) (*Repository, error)

GitHubRepo looks up the node ID of a named repository

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL