api

package
v0.0.0-...-a5817e7 Latest Latest
Warning

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

Go to latest
Published: Jun 6, 2025 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EndpointNeedsScopes

func EndpointNeedsScopes(resp *http.Response, s string) *http.Response

EndpointNeedsScopes adds additional OAuth scopes to an HTTP response as if they were returned from the server endpoint. This improves HTTP 4xx error messaging for endpoints that don't explicitly list the OAuth scopes they need.

func HandleHTTPError

func HandleHTTPError(resp *http.Response) error

HandleHTTPError parses a http.Response into a HTTPError.

func ScopesSuggestion

func ScopesSuggestion(resp *http.Response) string

ScopesSuggestion is an error messaging utility that prints the suggestion to request additional OAuth scopes in case a server response indicates that there are missing scopes.

Types

type Client

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

func NewClientFromHTTP

func NewClientFromHTTP(httpClient *http.Client) *Client

func (Client) GraphQL

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

GraphQL performs a GraphQL request using the query string and parses the response into data receiver. If there are errors in the response, GraphQLError will be returned, but the receiver will also be partially populated.

func (*Client) HTTP

func (c *Client) HTTP() *http.Client

func (Client) Mutate

func (c Client) Mutate(hostname, name string, mutation interface{}, variables map[string]interface{}) error

Mutate performs a GraphQL mutation based on a struct and parses the response with the same struct as the receiver. If there are errors in the response, GraphQLError will be returned, but the receiver will also be partially populated.

func (Client) Query

func (c Client) Query(hostname, name string, query interface{}, variables map[string]interface{}) error

Query performs a GraphQL query based on a struct and parses the response with the same struct as the receiver. If there are errors in the response, GraphQLError will be returned, but the receiver will also be partially populated.

func (Client) QueryWithContext

func (c Client) QueryWithContext(ctx context.Context, hostname, name string, query interface{}, variables map[string]interface{}) error

QueryWithContext performs a GraphQL query based on a struct and parses the response with the same struct as the receiver. If there are errors in the response, GraphQLError will be returned, but the receiver will also be partially populated.

func (Client) REST

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

REST performs a REST request and parses the response.

func (Client) RESTWithNext

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

type GraphQLError

type GraphQLError struct {
	*ghAPI.GraphQLError
}

type HTTPError

type HTTPError struct {
	*ghAPI.HTTPError
	// contains filtered or unexported fields
}

func (HTTPError) ScopesSuggestion

func (err HTTPError) ScopesSuggestion() string

Jump to

Keyboard shortcuts

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