Documentation ¶
Index ¶
- Constants
- func ApplyManifest(filename string, session *Session)
- func FormatBool(value bool) string
- func FormatDate(date string) string
- func FormatUrl(url string) string
- func JSONDecoder(b bytes.Buffer, into interface{}) error
- func PrintTable(data FormattedData)
- func UserAgent() string
- func YAMLDecoder(b []byte, into interface{}) error
- type Client
- type Config
- type CreateSessionResp
- type Cronjob
- type CronjobData
- type CronjobsData
- type DeleteMsg
- type Endpoint
- type EndpointData
- type EndpointsData
- type ErrBadStatusCode
- type ErrNotExpectedJSON
- type ErrNotExpectedYAML
- type FormattedData
- type HTTPService
- type Health
- type HealthData
- type HealthStatus
- type Incident
- type IncidentData
- type Iter
- type LineReader
- type ManifestReq
- type Mapper
- type NotificationChannel
- type NotificationChannelData
- type NotificationPolicy
- type NotificationPolicyData
- type Reader
- type Server
- type Session
- func (s *Session) ApplyManifest(doc TypeMeta) (bytes.Buffer, error)
- func (s *Session) DeleteEndpoints(name []string)
- func (s *Session) DeleteNotificationChannels(name []string)
- func (s *Session) DeleteNotificationPolicies(name []string)
- func (s *Session) GetCronjob(cronjobName string) (*CronjobData, error)
- func (s *Session) GetCronjobs() (*CronjobsData, error)
- func (s *Session) GetEndpoint(epName string) (*EndpointData, error)
- func (s *Session) GetEndpoints() (*EndpointsData, error)
- func (s *Session) GetHealthStatus() (*HealthData, error)
- func (s *Session) GetIncidents() (*IncidentData, error)
- func (s *Session) GetNotificationChannels() (*NotificationChannelData, error)
- func (s *Session) GetNotificationPolicies() (*NotificationPolicyData, error)
- func (s *Session) GetServerVersion() (*VersionData, error)
- type TypeMeta
- type VersionData
- type YAMLReader
Constants ¶
const DefaultBaseURL = "http://localhost:4000/api"
DefaultBaseURL is where pingaling expects API calls
Variables ¶
This section is empty.
Functions ¶
func ApplyManifest ¶
func FormatBool ¶
func FormatDate ¶
func JSONDecoder ¶
JSONDecoder decode response into target struct
func PrintTable ¶
func PrintTable(data FormattedData)
Prints a table to the console Parameters
headers: slice of strings to use as column headers rows: slice of tab-delimited strings to use as row data
func YAMLDecoder ¶
YAMLDecoder unmarshal []byte to struct
Types ¶
type Client ¶
Client interacts with the pingaling API
func (*Client) CreateSession ¶
CreateSession is a required for further API use.
type Config ¶
type Config struct { CurrentServer string `json:"current-server" yaml:"current-server"` Servers []Server `json:"servers" yaml:"servers"` }
Config is a struct of configuration file data
func (*Config) GetServerURI ¶
GetServerURI returns the current serverURI
func (*Config) ListServers ¶
func (c *Config) ListServers() FormattedData
func (*Config) SetCurrentServer ¶
type CreateSessionResp ¶
type Cronjob ¶
type Cronjob struct { Description string `json:"description"` Status string `json:"status"` Name string `json:"name"` }
Cronjob
type CronjobData ¶
type CronjobData struct {
Data Cronjob `json:"data"`
}
CronjobData single cronjob
func (CronjobData) FormatShow ¶
func (cronjobData CronjobData) FormatShow() FormattedData
type CronjobsData ¶
type CronjobsData struct {
Data []Cronjob `json:"data"`
}
CronjobsData list of cronjobs
func (CronjobsData) FormatList ¶
func (cronjobData CronjobsData) FormatList() FormattedData
type DeleteMsg ¶
type DeleteMsg struct {
Message string `json:"message"`
}
DeleteMsg returns the response of delete request
type Endpoint ¶
type Endpoint struct { URL string `json:"url"` NextCheck string `json:"next_check"` Name string `json:"name"` Status string `json:"status"` Description string `json:"description"` HealthStatuses []HealthStatus `json:"health_statuses"` }
Endpoint
type EndpointData ¶
type EndpointData struct {
Data Endpoint `json:"data"`
}
EndpointData single endpoint with health status
func (EndpointData) FormatShow ¶
func (endpointData EndpointData) FormatShow() FormattedData
func (EndpointData) PrintDescribe ¶
func (endpointData EndpointData) PrintDescribe()
type EndpointsData ¶
type EndpointsData struct {
Data []Endpoint `json:"data"`
}
EndpointsData list of endpoints with health status
func (EndpointsData) FormatList ¶
func (endpointData EndpointsData) FormatList() FormattedData
type ErrBadStatusCode ¶
ErrBadStatusCode is returned when the API returns a non 200 error code
func (*ErrBadStatusCode) Error ¶
func (e *ErrBadStatusCode) Error() string
type ErrNotExpectedJSON ¶
ErrNotExpectedJSON is returned when the API response isn't expected JSON
func (*ErrNotExpectedJSON) Error ¶
func (e *ErrNotExpectedJSON) Error() string
type ErrNotExpectedYAML ¶
ErrNotExpectedYAML is returned when the content isn't expected YAML
func (*ErrNotExpectedYAML) Error ¶
func (e *ErrNotExpectedYAML) Error() string
type FormattedData ¶
type HTTPService ¶
type HTTPService interface { Get(string) (bytes.Buffer, error) Delete(string) (bytes.Buffer, error) Post(string, io.Reader) (bytes.Buffer, error) }
HTTPService allow session features to call client functions
type Health ¶
type Health struct { URL string `json:"url"` Updated string `json:"updated"` Type string `json:"type"` Status string `json:"status"` Name string `json:"name"` }
Health status struct
type HealthData ¶
type HealthData struct {
Data []Health `json:"data"`
}
HealthData list of Health status
func (HealthData) FormatList ¶
func (healthData HealthData) FormatList() FormattedData
type HealthStatus ¶
type Incident ¶
type Incident struct { URL string `json:"url"` UpdatedAt string `json:"updated_at"` Status string `json:"status"` NextAttempt string `json:"next_attempt"` Name string `json:"name"` ID int `json:"id"` }
Incident describes incident data
type IncidentData ¶
type IncidentData struct {
Data []Incident `json:"data"`
}
IncidentData describes list of incidents
func (IncidentData) FormatList ¶
func (incidentData IncidentData) FormatList() FormattedData
type LineReader ¶
type LineReader struct {
// contains filtered or unexported fields
}
LineReader struct
func (*LineReader) Read ¶
func (r *LineReader) Read() ([]byte, error)
Read returns a single line (with '\n' ended) from the underlying reader. An error is returned iff there is an error with the underlying reader.
type ManifestReq ¶
type ManifestReq struct {
Manifest TypeMeta `json:"manifest" yaml:"manifest"`
}
ManifestReq wrap the manifest specification into a post request body
type NotificationChannel ¶
type NotificationChannel struct { UpdatedAt string `json:"updated_at"` Type string `json:"type"` Name string `json:"name"` }
NotificationChannel describes alert toolings
type NotificationChannelData ¶
type NotificationChannelData struct {
Data []NotificationChannel `json:"data"`
}
NotificationChannelData describes list of alert toolings
func (NotificationChannelData) FormatList ¶
func (notificationChannels NotificationChannelData) FormatList() FormattedData
type NotificationPolicy ¶
type NotificationPolicy struct { UpdatedAt string `json:"updated_at"` Type string `json:"type"` Name string `json:"name"` Endpoint string `json:"endpoint"` Channel string `json:"channel"` }
NotificationPolicy describes how alerts notify user
type NotificationPolicyData ¶
type NotificationPolicyData struct {
Data []NotificationPolicy `json:"data"`
}
NotificationPolicyData describes list of policies
func (NotificationPolicyData) FormatList ¶
func (notificationPolicies NotificationPolicyData) FormatList() FormattedData
type Server ¶
type Server struct { URI string `json:"server" yaml:"server"` Name string `json:"name" yaml:"name"` Current bool `yaml:"-"` }
Server is the API endpoint
type Session ¶
type Session struct { SessionID string HTTPService HTTPService // contains filtered or unexported fields }
Session establish connection to API
func (*Session) ApplyManifest ¶
ApplyManifest post manifest to API to upsert resource
func (*Session) DeleteEndpoints ¶
DeleteEndpoints delete specific endpoint
func (*Session) DeleteNotificationChannels ¶
DeleteNotificationChannels delete specific notification channels
func (*Session) DeleteNotificationPolicies ¶
DeleteNotificationPolicies delete specific notification policies
func (*Session) GetCronjob ¶
func (s *Session) GetCronjob(cronjobName string) (*CronjobData, error)
GetCronjob return specific endpoint data
func (*Session) GetCronjobs ¶
func (s *Session) GetCronjobs() (*CronjobsData, error)
GetCronjobs returns all Cronjobs
func (*Session) GetEndpoint ¶
func (s *Session) GetEndpoint(epName string) (*EndpointData, error)
GetEndpoint return specific endpoint data
func (*Session) GetEndpoints ¶
func (s *Session) GetEndpoints() (*EndpointsData, error)
GetEndpoints returns all Endpoints
func (*Session) GetHealthStatus ¶
func (s *Session) GetHealthStatus() (*HealthData, error)
GetHealthStatus return Health check data
func (*Session) GetIncidents ¶
func (s *Session) GetIncidents() (*IncidentData, error)
GetIncidents return specific endpoint data
func (*Session) GetNotificationChannels ¶
func (s *Session) GetNotificationChannels() (*NotificationChannelData, error)
GetNotificationChannels return specific endpoint data
func (*Session) GetNotificationPolicies ¶
func (s *Session) GetNotificationPolicies() (*NotificationPolicyData, error)
GetNotificationPolicies return all notification policies
func (*Session) GetServerVersion ¶
func (s *Session) GetServerVersion() (*VersionData, error)
GetServerVersion gets the version of the current server
type TypeMeta ¶
type TypeMeta struct { APIVersion int `json:"apiVersion,omitempty" yaml:"apiVersion,omitempty"` Kind string `json:"kind,omitempty" yaml:"kind,omitempty"` Spec map[string]interface{} `json:"spec" yaml:"spec"` }
TypeMeta describes the manifest specifications
func SplitYAMLDocuments ¶
SplitYAMLDocuments read multiple YAML docs to []TypeMeta struct
type VersionData ¶
type VersionData struct {
Version string `json:"version"`
}
type YAMLReader ¶
type YAMLReader struct {
// contains filtered or unexported fields
}
YAMLReader struct for reader
func NewYAMLReader ¶
func NewYAMLReader(r *bufio.Reader) *YAMLReader
NewYAMLReader returns YAMLReader struct
func (*YAMLReader) Read ¶
func (r *YAMLReader) Read() ([]byte, error)
Read returns a full YAML document.