api

package
v0.0.0-...-95f6ed8 Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2023 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetGraphQLAPIForHost

func GetGraphQLAPIForHost(host string) string

func GetV3APIForHost

func GetV3APIForHost(host string) string

func Mask

func Mask(in string) string

func ReplaceAllGroupFunc

func ReplaceAllGroupFunc(re *regexp.Regexp, str string, repl func([]string) string) string

Types

type Client

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

Client facilitates making HTTP requests to the GitHub API.

func BasicClient

func BasicClient(config auth.Config) (*Client, error)

func NewClient

func NewClient(authConfig auth.Config, opts ...ClientOption) *Client

NewClient initializes a Client.

func (*Client) Do

func (c *Client) Do(req *http.Request) (*http.Response, error)

func (*Client) Download

func (c *Client) Download(url string) (*http.Response, error)

Download performs a REST request and parses the response.

func (*Client) GraphQL

func (c *Client) GraphQL(host string, 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(host string, method string, path 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 AddAuthorizationHeader

func AddAuthorizationHeader(config auth.Config) ClientOption

AddAuthorizationHeader turns a RoundTripper into one that adds an authorization header.

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.

type FakeHTTP

type FakeHTTP struct {
	// Requests stores references to sequential 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) StubForkedRepoResponse

func (f *FakeHTTP) StubForkedRepoResponse(forkFullName, parentFullName string)

func (*FakeHTTP) StubRepoResponse

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

func (*FakeHTTP) StubRepoResponseWithPermission

func (f *FakeHTTP) StubRepoResponseWithPermission(owner, repo, permission string)

func (*FakeHTTP) StubResponse

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

StubResponse pre-records an HTTP response.

func (*FakeHTTP) StubWithFixture

func (f *FakeHTTP) StubWithFixture(status int, fixtureFileName string) func()

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

Jump to

Keyboard shortcuts

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