v1

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2016 License: Unlicense Imports: 8 Imported by: 3 modules, 24 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	RouteNameBase  = "base"
	RouteNameHooks = "hooks"
	RouteNameHook  = "hook"
)
View Source
const ErrorGroup = "csense.api.v1"

Variables

View Source
var API = struct {
	Routes []describe.Route `json:"routes"`
}{
	Routes: routeDescriptors,
}
View Source
var (
	ErrorCodeHookUnknown = errcode.Register(ErrorGroup, errcode.ErrorDescriptor{
		Value:          "HOOK_UNKNOWN",
		Message:        "hook not known to server",
		Description:    "This is returned if the hook ID used during an operation is unknown to the server.",
		HTTPStatusCode: http.StatusNotFound,
	})
)
View Source
var (
	IDRegex = regexp.MustCompile(`(?i)[0-9A-F]{8}-[0-9A-F]{4}-[4][0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}`)
)

Functions

func Router

func Router() *mux.Router

func RouterWithPrefix

func RouterWithPrefix(prefix string) *mux.Router

func ServeJSON

func ServeJSON(w http.ResponseWriter, data interface{}) error

Types

type BodyFormat

type BodyFormat string
var (
	FormatNone      BodyFormat
	FormatJSON      BodyFormat = "json"
	FormatSlackJSON BodyFormat = "json+slack"
)

type Condition

type Condition struct {
	Op    Operand `json:"op"`
	Value string  `json:"value"`
}

type ContainerEvent

type ContainerEvent struct {
	Type      ContainerEventType `json:"type"`
	Container *ContainerInfo     `json:"container"`
	Timestamp int64              `json:"timestamp"`
}

type ContainerEventType

type ContainerEventType string
const (
	EventContainerCreation ContainerEventType = "containerCreation"
	EventContainerDeletion ContainerEventType = "containerDeletion"
	EventContainerOom      ContainerEventType = "oom"
	EventContainerOomKill  ContainerEventType = "oomKill"
	EventContainerExisted  ContainerEventType = "containerExisted"
)

type ContainerField

type ContainerField string
var (
	FieldName      ContainerField = "name"
	FieldImageName ContainerField = "image_name"
)

type ContainerInfo

type ContainerInfo struct {
	Name      string            `json:"name"`
	ImageName string            `json:"image_name"`
	ImageTag  string            `json:"image_tag"`
	Labels    map[string]string `json:"labels"`
}

type ContainerState

type ContainerState string
const (
	StateRunning ContainerState = "running"
	StateStopped ContainerState = "stopped"
	StateUnknown ContainerState = "unknown"
)

func StateFromEvent

func StateFromEvent(eventType ContainerEventType) ContainerState

type Criteria

type Criteria struct {
	Fields map[ContainerField]*Condition
	Labels map[string]string `json:"labels,omitempty"`
}

type EventType

type EventType string
var (
	EventCreate EventType = "create"
	EventDelete EventType = "delete"
)

type Hook

type Hook struct {
	ID       string      `json:"id"`
	Name     string      `json:"name"`
	Url      string      `json:"url"`
	Events   []EventType `json:"events"`
	Criteria *Criteria   `json:"criteria"`
	TTL      int64       `json:"ttl"`
	Created  int64       `json:"created"`
	Format   BodyFormat  `json:"format"`
}

type HostInfo

type HostInfo struct {
	Hostname string `json:"hostname"`
}

type ModifyHookRequest

type ModifyHookRequest struct {
	Name         string      `json:"name"`
	Url          string      `json:"url"`
	AddEvents    []EventType `json:"add_events"`
	RemoveEvents []EventType `json:"remove_events"`
	Criteria     *Criteria   `json:"criteria"`
	Format       BodyFormat  `json:"format"`
}

type NewHookRequest

type NewHookRequest struct {
	Name     string      `json:"name"`
	Url      string      `json:"url"`
	Events   []EventType `json:"events"`
	Criteria *Criteria   `json:"criteria"`
	TTL      int64       `json:"ttl"`
	Format   BodyFormat  `json:"format"`
}

type Operand

type Operand string
var (
	OperandEqual         Operand = "equal"
	OperandEqualShort    Operand = "eq"
	OperandNotEqual      Operand = "not_equal"
	OperandNotEqualShort Operand = "ne"
	OperandMatch         Operand = "match"
)

type Reaction

type Reaction struct {
	Timestamp int64          `json:"timestamp"`
	Hook      *Hook          `json:"hook"`
	Host      *HostInfo      `json:"host"`
	Container *ContainerInfo `json:"container"`
}

type StateChange

type StateChange struct {
	State     ContainerState  `json:"state"`
	Source    *ContainerEvent `json:"source_event"`
	Container *ContainerInfo  `json:"container"`
}

type URLBuilder

type URLBuilder struct {
	// contains filtered or unexported fields
}

func NewURLBuilder

func NewURLBuilder(root *url.URL, relative bool) *URLBuilder

func NewURLBuilderFromRequest

func NewURLBuilderFromRequest(r *http.Request, relative bool) *URLBuilder

func NewURLBuilderFromString

func NewURLBuilderFromString(root string, relative bool) (*URLBuilder, error)

func (*URLBuilder) BuildBaseURL

func (ub *URLBuilder) BuildBaseURL() (string, error)

func (*URLBuilder) BuildHooks

func (ub *URLBuilder) BuildHooks() (string, error)

Jump to

Keyboard shortcuts

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