Documentation ¶
Overview ¶
Package api provides a client for using the sloppy.io API.
Index ¶
- Variables
- func Bool(v bool) *bool
- func Float64(v float64) *float64
- func Int(v int) *int
- func RetrieveLogs(c *Client, urlStr string, limit int, fromDate string, toDate string) (<-chan LogEntry, <-chan error)
- func String(v string) *string
- func Stringify(message interface{}) string
- func ValidateProject(project *Project) error
- type App
- type AppsDeleter
- type AppsEndpoint
- func (a *AppsEndpoint) Delete(project, service, app string, force bool) (*StatusResponse, *http.Response, error)
- func (a *AppsEndpoint) Get(project, service, id string) (*App, *http.Response, error)
- func (a *AppsEndpoint) GetLogs(project, service, app string, limit int, fromDate string, toDate string) (<-chan LogEntry, <-chan error)
- func (a *AppsEndpoint) GetMetrics(project, service, app string) (Metrics, *http.Response, error)
- func (a *AppsEndpoint) List(project, service string) ([]*App, *http.Response, error)
- func (a *AppsEndpoint) Restart(project, service, app string) (*StatusResponse, *http.Response, error)
- func (a *AppsEndpoint) Rollback(project, service, app, version string) (*App, *http.Response, error)
- func (a *AppsEndpoint) Scale(project, service, app string, n int) (*App, *http.Response, error)
- func (a *AppsEndpoint) Update(project, service, id string, input *App) (*App, *http.Response, error)
- type AppsGetMetricer
- type AppsGetter
- type AppsLogger
- type AppsRestarter
- type AppsRollbacker
- type AppsScaler
- type AppsUpdater
- type Client
- func (c *Client) Do(req *http.Request, v interface{}) (*http.Response, error)
- func (c *Client) GetBaseURL() string
- func (c *Client) GetHeader(h string) []string
- func (c *Client) NewRequest(method, path string, body interface{}) (*http.Request, error)
- func (c *Client) SetAccessToken(t string)
- func (c *Client) SetBaseURL(u string) error
- func (c *Client) SetUserAgent(ua string)
- type DataPoint
- type DataPoints
- type Domain
- type ErrorResponse
- type HealthCheck
- type LogEntry
- type Logging
- type Metrics
- type PortMap
- type Project
- type ProjectsCreater
- type ProjectsDeleter
- type ProjectsEndpoint
- func (p *ProjectsEndpoint) Create(input *Project) (*Project, *http.Response, error)
- func (p *ProjectsEndpoint) Delete(name string, force bool) (*StatusResponse, *http.Response, error)
- func (p *ProjectsEndpoint) Get(name string) (*Project, *http.Response, error)
- func (p *ProjectsEndpoint) GetLogs(name string, limit int, fromDate string, toDate string) (<-chan LogEntry, <-chan error)
- func (p *ProjectsEndpoint) List() ([]Project, *http.Response, error)
- func (p *ProjectsEndpoint) Update(name string, input *Project, force bool) (*Project, *http.Response, error)
- type ProjectsGetLister
- type ProjectsGetter
- type ProjectsLister
- type ProjectsLogger
- type ProjectsUpdater
- type RegistryCredentialsCheckDeleter
- type RegistryCredentialsEndpoint
- type RegistryCredentialsUploader
- type Series
- type Service
- type ServicesDeleter
- type ServicesEndpoint
- func (s *ServicesEndpoint) Delete(project, id string, force bool) (*StatusResponse, *http.Response, error)
- func (s *ServicesEndpoint) Get(project, id string) (*Service, *http.Response, error)
- func (s *ServicesEndpoint) GetLogs(project, service string, limit int, fromDate string, toDate string) (<-chan LogEntry, <-chan error)
- func (s *ServicesEndpoint) List(project string) ([]*Service, *http.Response, error)
- type ServicesGetter
- type ServicesLogger
- type StatusResponse
- type Timestamp
- type Volume
Constants ¶
This section is empty.
Variables ¶
var (
ErrMissingAccessToken = errors.New(`Missing "SLOPPY_APITOKEN", please login by exporting your token https://admin.sloppy.io/account/tokens`)
)
Functions ¶
func Bool ¶
Bool is a helper routine that allocates a new bool value to store v and returns a pointer to it.
func Float64 ¶
Float64 is a helper routine that allocates a new float64 value to store v and returns a pointer to it.
func Int ¶
Int is a helper routine that allocates a new int value to store v and returns a pointer to it.
func RetrieveLogs ¶
func String ¶
String is a helper routine that allocates a new string value to store v and returns a pointer to it.
func Stringify ¶
func Stringify(message interface{}) string
Stringify attempts to create a reasonable string representation of types in the api library. It does things like resolve pointers to their values and omits struct fields with nil values.
func ValidateProject ¶
ValidateProject checks whether project's attributes are missing.
Types ¶
type App ¶
type App struct { ID *string `json:"id,omitempty"` Status []string `json:"status,omitempty"` Domain *Domain `json:"domain,omitempty"` SSL *bool `json:"ssl,omitempty"` ForceRollingDeploy *bool `json:"forceRollingDeploy,omitempty"` Memory *int `json:"mem,omitempty"` Instances *int `json:"instances,omitempty"` Image *string `json:"image,omitempty"` Version *string `json:"version,omitempty"` Versions []string `json:"versions,omitempty"` Command *string `json:"cmd,omitempty"` PortMappings []*PortMap `json:"port_mappings,omitempty"` Dependencies []string `json:"dependencies,omitempty"` EnvVars map[string]string `json:"env,omitempty"` Volumes []*Volume `json:"volumes,omitempty"` HealthChecks []*HealthCheck `json:"health_checks,omitempty"` Logging *Logging `json:"logging,omitempty"` }
App represents a sloppy app.
func (*App) StatusCount ¶
Returns the count how often the given status was found
type AppsDeleter ¶
type AppsDeleter interface {
Delete(project, service, id string, force bool) (*StatusResponse, *http.Response, error)
}
AppsDeleter is an interface which provides the Delete method.
type AppsEndpoint ¶
type AppsEndpoint struct {
// contains filtered or unexported fields
}
AppsEndpoint handles communication with the app related methods of the sloppy API.
func (*AppsEndpoint) Delete ¶
func (a *AppsEndpoint) Delete(project, service, app string, force bool) (*StatusResponse, *http.Response, error)
Delete deletes a sloppy app.
func (*AppsEndpoint) GetLogs ¶
func (a *AppsEndpoint) GetLogs(project, service, app string, limit int, fromDate string, toDate string) (<-chan LogEntry, <-chan error)
GetLogs returns logs for specific app.
func (*AppsEndpoint) GetMetrics ¶
GetMetrics fetches a sloppy app's stats by name and project, service.
func (*AppsEndpoint) Restart ¶
func (a *AppsEndpoint) Restart(project, service, app string) (*StatusResponse, *http.Response, error)
Restart sends a restart request for a sloppy app.
func (*AppsEndpoint) Rollback ¶
func (a *AppsEndpoint) Rollback(project, service, app, version string) (*App, *http.Response, error)
Rollback reverts a sloppy app to a previous version.
type AppsGetMetricer ¶
type AppsGetMetricer interface {
GetMetrics(project, service, id string) (Metrics, *http.Response, error)
}
AppsGetMetricer is an interface which provides the getMetrics method.
type AppsGetter ¶
AppsGetter is an interface which provides the Get method.
type AppsLogger ¶
type AppsLogger interface {
GetLogs(project, service, id string, limit int, fromDate string, toDate string) (<-chan LogEntry, <-chan error)
}
AppsLogger is an interface which provides the GetLogs method.
type AppsRestarter ¶
type AppsRestarter interface {
Restart(project, service, id string) (*StatusResponse, *http.Response, error)
}
AppsRestarter is an interface which provides the Restart method.
type AppsRollbacker ¶
type AppsRollbacker interface {
Rollback(project, service, id, version string) (*App, *http.Response, error)
}
AppsRollbacker is an interface which provides the Rollback method.
type AppsScaler ¶
type AppsScaler interface {
Scale(project, service, id string, n int) (*App, *http.Response, error)
}
AppsScaler is an interface which provides the Scale method.
type AppsUpdater ¶
type AppsUpdater interface {
Update(project, service, id string, input *App) (*App, *http.Response, error)
}
AppsUpdater is an interface which provides the Update method.
type Client ¶
type Client struct { // API endpoints Projects *ProjectsEndpoint Services *ServicesEndpoint Apps *AppsEndpoint RegistryCredentials *RegistryCredentialsEndpoint // contains filtered or unexported fields }
A Client handles communication with the sloppy.io API.
func (*Client) Do ¶
Do sends an API request and returns an API response. The API response is decoded and stored in the value pointed to by v, or returned as an error if an API error has occurred.
func (*Client) GetBaseURL ¶
func (*Client) NewRequest ¶
NewRequest returns a new Request given a method, URL, and a value pointed to by body. If a relative URL is provided in urlStr, it is resolved relative to the Client's BaseURL. Relative URLs should never have a preceding slash. If body is specified, body is JSON encoded and included as request body.
func (*Client) SetAccessToken ¶
SetAccessToken sets Client's access token header.
func (*Client) SetBaseURL ¶
SetBaseURL sets client's baseURL and appends version path.
func (*Client) SetUserAgent ¶
type Domain ¶
type Domain struct { URI *string `json:"uri,omitempty"` RedirectHttps *bool `json:"redirectHttps,omitempty"` HstsHeader *bool `json:"hstsHeader,omitempty"` BasicAuth *string `json:"basicAuth,omitempty"` }
Domain represents sloppy domain.
type ErrorResponse ¶
type ErrorResponse struct { Response *http.Response StatusResponse Reason string `json:"reason,omitempty"` }
ErrorResponse represents errors caused by an API request.
func (*ErrorResponse) Error ¶
func (e *ErrorResponse) Error() string
type HealthCheck ¶
type HealthCheck struct { Timeout *int `json:"timeout_seconds,omitempty"` Interval *int `json:"interval_seconds,omitempty"` MaxConsectiveFailure *int `json:"max_consecutive_failures,omitempty"` Path *string `json:"path,omitempty"` Type *string `json:"type,omitempty"` GracePeriod *int `json:"grace_period_seconds,omitempty"` }
HealthCheck represents a sloppy health check.
type LogEntry ¶
type LogEntry struct { Project *string `json:"project,omitempty"` Service *string `json:"service,omitempty"` App *string `json:"app,omitempty"` CreatedAt *Timestamp `json:"createdAt,omitempty"` Log *string `json:"body,omitempty"` }
LogEntry represents a sloppy log entry.
type Logging ¶
type Logging struct { Driver *string `json:"driver,omitempty"` Options map[string]string `json:"options,omitempty"` }
Logging represents a sloppy app logging configuration.
type Metrics ¶
Metrics represents all sloppy stats.
func (Metrics) UnmarshalJSON ¶
UnmarshalJSON decodes sloppy's metric format.
type PortMap ¶
type PortMap struct { Port *int `json:"container_port,omitempty"` ServicePort *int `json:"service_port,omitempty"` }
PortMap represents a sloppy port map.
type Project ¶
type Project struct { Name *string `json:"project,omitempty"` Services []*Service `json:"services,omitempty"` }
Project represents a sloppy project.
type ProjectsCreater ¶
ProjectsCreater is an interface which provides the Create method.
type ProjectsDeleter ¶
type ProjectsDeleter interface {
Delete(name string, force bool) (*StatusResponse, *http.Response, error)
}
ProjectsDeleter is an interface which provides the delete method.
type ProjectsEndpoint ¶
type ProjectsEndpoint struct {
// contains filtered or unexported fields
}
ProjectsEndpoint handles communication with the project related methods of the sloppy API.
func (*ProjectsEndpoint) Delete ¶
func (p *ProjectsEndpoint) Delete(name string, force bool) (*StatusResponse, *http.Response, error)
Delete deletes a sloppy project.
func (*ProjectsEndpoint) GetLogs ¶
func (p *ProjectsEndpoint) GetLogs(name string, limit int, fromDate string, toDate string) (<-chan LogEntry, <-chan error)
GetLogs returns logs for all apps included in a specific project.
type ProjectsGetLister ¶
type ProjectsGetLister interface { ProjectsGetter ProjectsLister }
ProjectsGetLister is an interface which provides the Get and List method.
type ProjectsGetter ¶
ProjectsGetter is an interface which provides the Get method.
type ProjectsLister ¶
ProjectsLister is an interface which provides the List method.
type ProjectsLogger ¶
type ProjectsLogger interface {
GetLogs(project string, limit int, fromDate string, toDate string) (<-chan LogEntry, <-chan error)
}
ProjectsLogger is an interface which provides the getLogs method.
type ProjectsUpdater ¶
type ProjectsUpdater interface {
Update(name string, input *Project, force bool) (*Project, *http.Response, error)
}
ProjectsUpdater is an interface which provides the update method.
type RegistryCredentialsCheckDeleter ¶
type RegistryCredentialsCheckDeleter interface { Check() (*StatusResponse, *http.Response, error) Delete() (*StatusResponse, *http.Response, error) }
RegistryCredentialsCheckDeleter is an interface which combines delete and check.
type RegistryCredentialsEndpoint ¶
type RegistryCredentialsEndpoint struct {
// contains filtered or unexported fields
}
RegistryCredentialsEndpoint handles communication with the registry credentails related methods of the sloppy API.
func (*RegistryCredentialsEndpoint) Check ¶
func (r *RegistryCredentialsEndpoint) Check() (*StatusResponse, *http.Response, error)
Check checks if docker credentials exist.
func (*RegistryCredentialsEndpoint) Delete ¶
func (r *RegistryCredentialsEndpoint) Delete() (*StatusResponse, *http.Response, error)
Delete removes docker credentials.
func (*RegistryCredentialsEndpoint) Upload ¶
func (r *RegistryCredentialsEndpoint) Upload(reader io.Reader) (*StatusResponse, *http.Response, error)
Upload uploads docker credentials.
type RegistryCredentialsUploader ¶
type RegistryCredentialsUploader interface {
Upload(reader io.Reader) (*StatusResponse, *http.Response, error)
}
RegistryCredentialsUploader is an interface which provides the Upload method.
type ServicesDeleter ¶
type ServicesDeleter interface {
Delete(project, id string, force bool) (*StatusResponse, *http.Response, error)
}
ServicesDeleter is an interface which provides the Delete method.
type ServicesEndpoint ¶
type ServicesEndpoint struct {
// contains filtered or unexported fields
}
ServicesEndpoint handles communication with the service related methods of the sloppy API.
func (*ServicesEndpoint) Delete ¶
func (s *ServicesEndpoint) Delete(project, id string, force bool) (*StatusResponse, *http.Response, error)
Delete deletes a sloppy service by project and id.
type ServicesGetter ¶
ServicesGetter is an interface which provides the Get method.
type ServicesLogger ¶
type ServicesLogger interface {
GetLogs(project, id string, limit int, fromDate string, toDate string) (<-chan LogEntry, <-chan error)
}
ServicesLogger is an interface which provides the getLogs method.
type StatusResponse ¶
type StatusResponse struct { Status string `json:"status,omitempty"` Message string `json:"message,omitempty"` Data json.RawMessage `json:"data,omitempty"` }
StatusResponse represents common API response received by delete or restart requests.
func (*StatusResponse) String ¶
func (s *StatusResponse) String() string
type Timestamp ¶
Timestamp represents a sloppy timestamp.
func (*Timestamp) UnmarshalJSON ¶
UnmarshalJSON decodes sloppy's date format.