githubapi

package
v0.0.1-alpha Latest Latest
Warning

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

Go to latest
Published: Dec 17, 2024 License: Apache-2.0 Imports: 15 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const DefaultGraphQLEndpoint = "https://api.github.com/graphql"

DefaultGraphQLEndpoint is the default URL for the GitHub GraphQL API.

Variables

View Source
var (
	// ErrGraphQLNotFound is an error used to test when GitHub GraphQL query
	// returns a single error with the type "NOT_FOUND".
	//
	// It should be used with errors.Is.
	ErrGraphQLNotFound = errors.New("GraphQL resource not found")

	// ErrGraphQLForbidden is an error used to test when GitHub GraphQL query
	// returns a single error with the type "FORBIDDEN".
	//
	// It should be used with errors.Is.
	ErrGraphQLForbidden = errors.New("GraphQL access forbidden")
)

Functions

func BatchQuery

func BatchQuery[T any](ctx context.Context, c *Client, queries map[string]string) (map[string]T, error)

BatchQuery can be used to batch a set of requests together to GitHub's GraphQL API.

The queries must be for objects represented by type T. T should be a struct to work correctly.

func ErrorResponseStatusCode

func ErrorResponseStatusCode(err error) int

ErrorResponseStatusCode will unwrap a github.ErrorResponse and return the status code inside.

If the error is nil, or not an ErrorResponse it will return a status code of 0.

func NewRetryRoundTripper

func NewRetryRoundTripper(rt http.RoundTripper, logger *zap.Logger) http.RoundTripper

Types

type Client

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

Client provides simple access to GitHub's REST and GraphQL APIs.

func NewClient

func NewClient(client *http.Client) *Client

NewClient creates a new instances of Client.

func (*Client) GraphQL

func (c *Client) GraphQL() *graphql.Client

GraphQL returns a client for communicating with GitHub's GraphQL API.

func (*Client) Rest

func (c *Client) Rest() *github.Client

Rest returns a client for communicating with GitHub's REST API.

type GitTimestamp

type GitTimestamp struct{ time.Time }

type GraphQLError

type GraphQLError struct {
	Message   string
	Type      string // GitHub specific GraphQL error field
	Locations []struct {
		Line   int
		Column int
	}
}

GraphQLError stores the error result from a GitHub GraphQL query.

type GraphQLErrors

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

GraphQLErrors wraps all the errors returned by a GraphQL response.

func (*GraphQLErrors) Error

func (e *GraphQLErrors) Error() string

Error implements error interface.

func (*GraphQLErrors) Errors

func (e *GraphQLErrors) Errors() []GraphQLError

Errors returns a slice with each Error returned by the GraphQL API.

func (*GraphQLErrors) HasType

func (e *GraphQLErrors) HasType(t string) bool

HasType returns true if one of the errors matches the supplied type.

func (*GraphQLErrors) Is

func (e *GraphQLErrors) Is(target error) bool

Is implements the errors.Is interface.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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