assembly

package
v0.0.0-...-25e39c5 Latest Latest
Warning

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

Go to latest
Published: Jun 7, 2015 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const AssemblyDateFormat = "2006-01-02 15:04:05 MST"

AssemblyDateFormat is the format of the dates used throughout the api, note this odd string is used to parse/format dates in go

View Source
const Version = "1.0.0"

Version the client version

Variables

View Source
var (
	// ErrUserNotFound user was not found.
	ErrUserNotFound    = errors.New("user not found")
	ErrUserLoginExists = errors.New("user already exists in the system with that login")
)

Functions

func Int

func Int(v int) *int

Int is a helper routine that allocates a new int value to store v and returns a pointer to it, but unlike Int its argument value is an int.

func String

func String(v string) *string

String is a helper routine that allocates a new string value to store v and returns a pointer to it.

Types

type Client

type Client struct {

	// Base URL for API requests.  Defaults to the public buildkite API. BaseURL should
	// always be specified with a trailing slash.
	BaseURL *url.URL

	// User agent used when communicating with the buildkite API.
	UserAgent string

	// Services used for talking to different parts of the buildkite API.
	Users UsersService
	// contains filtered or unexported fields
}

A Client manages communication with the buildkite API.

func NewClient

func NewClient(httpClient *http.Client) *Client

NewClient returns a new buildkite API client. As API calls require authentication you MUST supply a client which provides the required API key.

func (*Client) Do

func (c *Client) Do(req *http.Request, v interface{}) (Response, error)

Do sends an API request and returns the API response. The API response is JSON decoded and stored in the value pointed to by v, or returned as an error if an API error has occurred. If v implements the io.Writer interface, the raw response body will be written to v, without attempting to first decode it.

func (*Client) NewRequest

func (c *Client) NewRequest(method, urlStr string, body interface{}) (*http.Request, error)

NewRequest creates an API request. A relative URL can be provided in urlStr, in which case it is resolved relative to the BaseURL of the Client. Relative URLs should always be specified without a preceding slash. If specified, the value pointed to by body is JSON encoded and included as the request body.

type EmailAddr

type EmailAddr struct {
	Email string
}

EmailAddr is an email address associated with a user.

type ErrorResponse

type ErrorResponse struct {
	Response *http.Response // HTTP response that caused this error
	Message  string         `json:"message"` // error message
}

ErrorResponse provides a message.

func (*ErrorResponse) Error

func (r *ErrorResponse) Error() string

type HTTPResponse

type HTTPResponse struct {
	*http.Response
}

HTTPResponse is a wrapped HTTP response from the assembly API with additional assembly-specific response information parsed out. It implements Response.

type MockUsersService

type MockUsersService struct {
	GetFunc    func(login string) (*User, Response, error)
	CreateFunc func(user *User) (*User, Response, error)
	UpdateFunc func(user *User) (*User, Response, error)
	ListFunc   func(opt *UsersListOptions) ([]*User, Response, error)
}

func (*MockUsersService) Create

func (s *MockUsersService) Create(user *User) (*User, Response, error)

func (*MockUsersService) Get

func (s *MockUsersService) Get(login string) (*User, Response, error)

func (*MockUsersService) List

func (s *MockUsersService) List(opt *UsersListOptions) ([]*User, Response, error)

func (*MockUsersService) Update

func (s *MockUsersService) Update(user *User) (*User, Response, error)

type Response

type Response interface {
}

Response is a response from the assembly API. When using the HTTP API, API methods return *HTTPResponse values that implement Response.

type Timestamp

type Timestamp struct {
	time.Time
}

Timestamp custom timestamp to support assembly api timestamps

func NewTimestamp

func NewTimestamp(t time.Time) *Timestamp

NewTimestamp make a new timestamp using the time suplied.

func (Timestamp) Equal

func (ts Timestamp) Equal(u Timestamp) bool

Equal reports whether t and u are equal based on time.Equal

func (Timestamp) MarshalJSON

func (ts Timestamp) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaler interface.

func (Timestamp) String

func (ts Timestamp) String() string

func (*Timestamp) UnmarshalJSON

func (ts *Timestamp) UnmarshalJSON(data []byte) (err error)

UnmarshalJSON implements the json.Unmarshaler interface.

type User

type User struct {
	ID        int        `json:"id,omitempty"`
	Login     *string    `json:"login,omitempty"`
	Password  *string    `json:"password,omitempty"`
	Name      *string    `json:"name,omitempty"`
	Email     *string    `json:"email,omitempty"`
	CreatedAt *Timestamp `json:"created_at,omitempty"`
}

User represents an assembly user.

type UsersListOptions

type UsersListOptions struct {
	Sort      string `url:",omitempty"`
	Direction string `url:",omitempty"`
}

UsersListOptions specifies the optional parameters to the UsersService.List method.

type UsersService

type UsersService interface {
	// Get fetches a user.
	Get(login string) (*User, Response, error)

	// Registers a new user.
	Create(user *User) (*User, Response, error)

	// Updates an existing user.
	Update(user *User) (*User, Response, error)

	// List fetches all user.
	List(opt *UsersListOptions) ([]*User, Response, error)
}

UsersService communicates with the users-related endpoints in the assembly API.

Jump to

Keyboard shortcuts

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