Documentation ¶
Index ¶
Constants ¶
const ( GetMeRequest = "GetMe" GetProjectsRequest = "GetProjects" )
Naming convention:
Method + non-parameter parts of the path
If the request returns a single entity by GUID, use the singular (for example /projects/{project_id} is GetProject).
The const name should always be the const value + Request.
Variables ¶
var APIRoutes = rata.Routes{ {Path: "/me", Method: http.MethodGet, Name: GetMeRequest}, {Path: "/projects", Method: http.MethodGet, Name: GetProjectsRequest}, }
APIRoutes is a list of routes used by the rata library to construct request URLs.
Functions ¶
func DecodeJSON ¶
DecodeJSON unmarshals JSON into the given object with the appropriate settings.
Types ¶
type Connection ¶
Connection creates and executes http requests
type ConnectionConfig ¶
type ConnectionConfig struct {
SkipSSLValidation bool
}
ConnectionConfig is for configuring a TrackerConnection.
type ConnectionWrapper ¶
type ConnectionWrapper interface { Connection Wrap(innerconnection Connection) Connection }
ConnectionWrapper can wrap a given connection allowing the wrapper to modify all requests going in and out of the given connection.
type ErrorWrapper ¶
type ErrorWrapper struct {
// contains filtered or unexported fields
}
ErrorWrapper is the wrapper that converts responses with 4xx and 5xx status codes to an error.
func NewErrorWrapper ¶
func NewErrorWrapper() *ErrorWrapper
func (*ErrorWrapper) Make ¶
func (e *ErrorWrapper) Make(request *Request, passedResponse *Response) error
Make creates a connection in the wrapped connection and handles errors that it returns.
func (*ErrorWrapper) Wrap ¶
func (e *ErrorWrapper) Wrap(inner Connection) Connection
Wrap wraps a connection in this error handling wrapper.
type Request ¶
Request represents the request of the cloud controller.
func NewRequest ¶
func NewRequest(request *http.Request, body io.ReadSeeker) *Request
type Response ¶
type Response struct { // DecodeJSONResponseInto represents the resource entity type that is // expected in the response JSON. DecodeJSONResponseInto interface{} // RawResponse represents the response body. RawResponse []byte // Warnings represents warnings parsed from the custom warnings headers of a // Tracker response. Warnings []string // HTTPResponse represents the HTTP response object. HTTPResponse *http.Response // ResourceLocationURL represents the Location header value ResourceLocationURL string }
Response represents a Tracker response object.
type TokenWrapper ¶
type TokenWrapper struct { APIToken string // contains filtered or unexported fields }
TokenWrapper adds the API Token to every request.
func NewTokenWrapper ¶
func NewTokenWrapper(token string) *TokenWrapper
func (*TokenWrapper) Make ¶
func (e *TokenWrapper) Make(request *Request, passedResponse *Response) error
Make adds the API Token header to every request before sending it.
func (*TokenWrapper) Wrap ¶
func (e *TokenWrapper) Wrap(inner Connection) Connection
Wrap wraps a connection with this wrapper.
type TrackerConnection ¶
TrackerConnection represents a connection to the Cloud Controller server.
func NewTrackerConnection ¶
func NewTrackerConnection(config ConnectionConfig) *TrackerConnection
NewTrackerConnection returns a new TrackerConnection with provided configuration.