v0.0.0-...-4463b27 Latest Latest

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

Go to latest
Published: Dec 19, 2018 License: Apache-2.0 Imports: 19 Imported by: 0




View Source
const DefaultBaseURL = "http://localhost:4000/api"

DefaultBaseURL is where pingaling expects API calls


This section is empty.


func ApplyManifest

func ApplyManifest(filename string, session *Session)

func FormatBool

func FormatBool(value bool) string

func FormatDate

func FormatDate(date string) string

func FormatUrl

func FormatUrl(url string) string

func JSONDecoder

func JSONDecoder(b bytes.Buffer, into interface{}) error

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 UserAgent

func UserAgent() string

func YAMLDecoder

func YAMLDecoder(b []byte, into interface{}) error

YAMLDecoder unmarshal []byte to struct


type Client

type Client struct {
	HTTPClient http.Client
	BaseURL    string

Client interacts with the pingaling API

func (*Client) CreateSession

func (c *Client) CreateSession() (*Session, error)

CreateSession is a required for further API use.

func (*Client) Delete

func (c *Client) Delete(url string) (bytes.Buffer, error)

Delete request

func (*Client) Get

func (c *Client) Get(url string) (bytes.Buffer, error)

Get request

func (*Client) Post

func (c *Client) Post(url string, body io.Reader) (bytes.Buffer, error)

Post request

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

func (c *Config) GetServerURI() string

GetServerURI returns the current serverURI

func (*Config) ListServers

func (c *Config) ListServers() FormattedData

func (*Config) NewConfig

func (c *Config) NewConfig(cfgFile string) error

NewConfig reads from .pingaling config file, write into Config struct

func (*Config) SetCurrentServer

func (c *Config) SetCurrentServer(server string)

type CreateSessionResp

type CreateSessionResp struct {
	RetMsg    string `json:"ret_msg"`
	SessionID string `json:"session_id"`
	Timestamp string `json:"timestamp"`

type Cronjob

type Cronjob struct {
	Description string `json:"description"`
	Status      string `json:"status"`
	Name        string `json:"name"`


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"`


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

type ErrBadStatusCode struct {
	OriginalBody string
	Code         int

ErrBadStatusCode is returned when the API returns a non 200 error code

func (*ErrBadStatusCode) Error

func (e *ErrBadStatusCode) Error() string

type ErrNotExpectedJSON

type ErrNotExpectedJSON struct {
	OriginalBody string
	Err          error

ErrNotExpectedJSON is returned when the API response isn't expected JSON

func (*ErrNotExpectedJSON) Error

func (e *ErrNotExpectedJSON) Error() string

type ErrNotExpectedYAML

type ErrNotExpectedYAML struct {
	OriginalBody string
	Err          error

ErrNotExpectedYAML is returned when the content isn't expected YAML

func (*ErrNotExpectedYAML) Error

func (e *ErrNotExpectedYAML) Error() string

type FormattedData

type FormattedData struct {
	Headers []string
	Rows    []string

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 HealthStatus struct {
	UpdatedAt string `json:"updated_at"`
	Status    string `json:"status"`

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 Iter

type Iter chan interface{}

Iter is channel of interface{}

func Map

func Map(fn Mapper, it Iter) Iter

Map an iterator to fn(el) for el in it

func New

func New(els ...interface{}) Iter

New returns chan of variadic interfaces

func StrIter

func StrIter(els []string) Iter

StrIter returns channels of string

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 Mapper

type Mapper func(interface{}) interface{}

Mapper map Iter to a function

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 Reader

type Reader interface {
	Read() ([]byte, error)

Reader interface for Read()

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

func (s *Session) ApplyManifest(doc TypeMeta) (bytes.Buffer, error)

ApplyManifest post manifest to API to upsert resource

func (*Session) DeleteEndpoints

func (s *Session) DeleteEndpoints(name []string)

DeleteEndpoints delete specific endpoint

func (*Session) DeleteNotificationChannels

func (s *Session) DeleteNotificationChannels(name []string)

DeleteNotificationChannels delete specific notification channels

func (*Session) DeleteNotificationPolicies

func (s *Session) DeleteNotificationPolicies(name []string)

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

func SplitYAMLDocuments(ymlBytes []byte) ([]TypeMeta, error)

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.


Path Synopsis

Jump to

Keyboard shortcuts

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