api

package
v0.5.6 Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2020 License: MIT Imports: 11 Imported by: 4

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, logBodies bool) 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) StubRepoResponse added in v0.5.5

func (f *FakeHTTP) StubRepoResponse(owner, repo string)

func (*FakeHTTP) StubResponse

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

StubResponse pre-records an HTTP response

type GraphQLError

type GraphQLError struct {
	Type    string
	Path    []string
	Message string
}

GraphQLError is a single error returned in a GraphQL response

type GraphQLErrorResponse

type GraphQLErrorResponse struct {
	Errors []GraphQLError
}

GraphQLErrorResponse contains errors returned in a GraphQL response

func (GraphQLErrorResponse) Error

func (gr GraphQLErrorResponse) Error() string

type Issue

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

	Labels struct {
		Nodes      []IssueLabel
		TotalCount int
	}
}

func IssueByNumber

func IssueByNumber(client *Client, repo ghrepo.Interface, 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, repo ghrepo.Interface, 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, repo ghrepo.Interface, 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, repo *Repository, params map[string]interface{}) (*PullRequest, error)

CreatePullRequest creates a pull request in a GitHub repository

func PullRequestByNumber

func PullRequestByNumber(client *Client, repo ghrepo.Interface, number int) (*PullRequest, error)

func PullRequestForBranch

func PullRequestForBranch(client *Client, repo ghrepo.Interface, 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, repo ghrepo.Interface, currentPRNumber int, currentPRHeadRef, currentUsername string) (*PullRequestsPayload, error)

type RepoNetworkResult

type RepoNetworkResult struct {
	ViewerLogin  string
	Repositories []*Repository
}

RepoNetworkResult describes the relationship between related repositories

func RepoNetwork

func RepoNetwork(client *Client, repos []ghrepo.Interface) (RepoNetworkResult, error)

RepoNetwork inspects the relationship between multiple GitHub repositories

type Repository

type Repository struct {
	ID    string
	Name  string
	Owner RepositoryOwner

	IsPrivate        bool
	HasIssuesEnabled bool
	ViewerPermission string
	DefaultBranchRef struct {
		Name   string
		Target struct {
			OID string
		}
	}

	Parent *Repository
}

Repository contains information about a GitHub repo

func ForkRepo

func ForkRepo(client *Client, repo ghrepo.Interface) (*Repository, error)

ForkRepo forks the repository on GitHub and returns the new repository

func GitHubRepo

func GitHubRepo(client *Client, repo ghrepo.Interface) (*Repository, error)

GitHubRepo looks up the node ID of a named repository

func (Repository) IsFork

func (r Repository) IsFork() bool

IsFork is true when this repository has a parent repository

func (Repository) RepoName

func (r Repository) RepoName() string

RepoName is the name of the repository

func (Repository) RepoOwner

func (r Repository) RepoOwner() string

RepoOwner is the login name of the owner

func (Repository) ViewerCanPush

func (r Repository) ViewerCanPush() bool

ViewerCanPush is true when the requesting user has push access

type RepositoryOwner

type RepositoryOwner struct {
	Login string
}

RepositoryOwner is the owner of a GitHub repository

Jump to

Keyboard shortcuts

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