Documentation ¶
Index ¶
Constants ¶
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
const Version = "1.0.0"
Version the client version
Variables ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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)
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 ¶
Timestamp custom timestamp to support assembly api timestamps
func NewTimestamp ¶
NewTimestamp make a new timestamp using the time suplied.
func (Timestamp) MarshalJSON ¶
MarshalJSON implements the json.Marshaler interface.
func (*Timestamp) UnmarshalJSON ¶
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 ¶
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.