client

package
v0.1.3815 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2018 License: MIT, Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client added in v0.1.2969

type Client struct {
	Endpoint string
	Host     string
	Token    string
	// contains filtered or unexported fields
}

A Client is an HTTP client for our GraphQL endpoint.

func NewClient

func NewClient(host, endpoint, token string) *Client

NewClient returns a reference to a Client.

func (*Client) Run added in v0.1.2969

func (cl *Client) Run(ctx context.Context, log *logger.Logger, request *Request, resp interface{}) error

Run sends an HTTP request to the GraphQL server and deserializes the response or returns an error.

type Request added in v0.1.2969

type Request struct {
	Query     string                 `json:"query"`
	Variables map[string]interface{} `json:"variables"`

	// Header represent any request headers that will be set
	// when the request is made.
	Header http.Header `json:"-"`
}

Request is a GraphQL request.

func NewAuthorizedRequest

func NewAuthorizedRequest(query string, token string) (*Request, error)

NewAuthorizedRequest returns a new GraphQL request with the authorization headers set for CircleCI auth.

func NewUnauthorizedRequest added in v0.1.3397

func NewUnauthorizedRequest(query string) *Request

NewUnauthorizedRequest returns a new GraphQL request without any authorization header.

func (*Request) Encode added in v0.1.3397

func (request *Request) Encode() (bytes.Buffer, error)

Encode will return a buffer of the JSON encoded request body

func (*Request) Var added in v0.1.2969

func (request *Request) Var(key string, value interface{})

Var sets a variable.

type Response added in v0.1.3397

type Response struct {
	Data   interface{}
	Errors ResponseErrorsCollection
}

Response wraps the result from our GraphQL server response including out-of-band errors and the data itself.

type ResponseError added in v0.1.3397

type ResponseError struct {
	Message string
}

ResponseError represents the key-value pair of data returned by the GraphQL server to represent errors.

type ResponseErrorsCollection added in v0.1.3397

type ResponseErrorsCollection []ResponseError

ResponseErrorsCollection represents a slice of errors returned by the GraphQL server out-of-band from the actual data.

func (ResponseErrorsCollection) Error added in v0.1.3397

func (errs ResponseErrorsCollection) Error() string

Error turns a ResponseErrorsCollection into an acceptable error string that can be printed to the user.

Jump to

Keyboard shortcuts

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