cap

package module
v0.0.0-...-d7ef56f Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2018 License: MIT Imports: 9 Imported by: 11

README

Overview

A golang library for the Common Alerting Protocol (CAP).

Testing

This library has been tested with alerts issued via Canada's National Alert Aggregation and Dissemination System (NAAD).

Documentation

Index

Constants

View Source
const (
	CategoryUnknown = iota
	CategoryGeological
	CategoryMeteorological
	CategorySafety
	CategorySecurity
	CategoryRescue
	CategoryFire
	CategoryHealth
	CategoryEnvironment
	CategoryTransport
	CategoryInfrastructure
	CategoryCBRNE
	CategoryOther
)
View Source
const (
	CertaintyUnknown = iota
	CertaintyObserved
	CertaintyLikely
	CertaintyPossible
	CertaintyUnlikely
)
View Source
const (
	MessageTypeUnknown = iota
	MessageTypeAlert
	MessageTypeUpdate
	MessageTypeCancel
	MessageTypeAck
	MessageTypeError
)
View Source
const (
	ResponseTypeUnknown = iota
	ResponseTypeShelter
	ResponseTypeEvacuate
	ResponseTypePrepare
	ResponseTypeExecute
	ResponseTypeAvoid
	ResponseTypeMonitor
	ResponseTypeAssess
	ResponseTypeAllClear
	ResponseTypeNone
)
View Source
const (
	ScopeUnknown = iota
	ScopePublic
	ScopeRestricted
	ScopePrivate
)
View Source
const (
	SeverityUnknown = iota
	SeverityExtreme
	SeveritySevere
	SeverityModerate
	SeverityMinor
)
View Source
const (
	StatusUnknown = iota
	StatusActual
	StatusExcercise
	StatusSystem
	StatusTest
	StatusDraft
)
View Source
const (
	UrgencyUnknown = iota
	UrgencyImmediate
	UrgencyExpected
	UrgencyFuture
	UrgencyPast
)
View Source
const (
	TimeFormat = "2006-01-02T15:04:05-07:00"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Alert

type Alert struct {
	XMLName xml.Name `xml:"alert" json:"-"`

	Identifier  string      `xml:"identifier" json:"identifier"`
	Sender      string      `xml:"sender" json:"sender"`
	Sent        Time        `xml:"sent" json:"sent"`
	Status      Status      `xml:"status" json:"status"`
	MessageType MessageType `xml:"msgType" json:"message_type"`
	Source      *string     `xml:"source" json:"source"`
	Scope       Scope       `xml:"scope" json:"scope"`
	Restriction *string     `xml:"restriction" json:"restriction"`
	Addresses   List        `xml:"addresses" json:"addresses"`
	Codes       []string    `xml:"code" json:"codes"`
	Note        *string     `xml:"note" json:"note"`
	References  References  `xml:"references" json:"references"`
	Incidents   List        `xml:"incidents" json:"incidents"`
	Infos       []Info      `xml:"info" json:"infos"`
}

func (*Alert) Id

func (alert *Alert) Id() string

type Area

type Area struct {
	XMLName xml.Name `xml:"area" json:"-"`

	Description string   `xml:"areaDesc" json:"description"`
	Polygons    Polygons `xml:"polygon" json:"polygons"`
	Circles     Circles  `xml:"circle" json:"circles"`
	GeoCodes    KeyValue `xml:"geocode" json:"geocodes"`
	Altitude    *int     `xml:"altitude" json:"altitude"`
	Ceiling     *int     `xml:"ceiling" json:"ceiling"`
}

type Category

type Category int

func (*Category) MarshalJSON

func (category *Category) MarshalJSON() ([]byte, error)

MarshalJSON returns the string version of the category.

func (*Category) MarshalXML

func (category *Category) MarshalXML(e *xml.Encoder, start xml.StartElement) error

MarshalXML returns the string version of the status.

func (Category) String

func (category Category) String() string

String returns a Category as a string

func (*Category) UnmarshalJSON

func (category *Category) UnmarshalJSON(b []byte) error

UnmarshalJSON unmarshals the JSON into a Category value.

func (*Category) UnmarshalString

func (category *Category) UnmarshalString(value string) error

UnmarshalString unmarshals the string into a Category value

func (*Category) UnmarshalXML

func (category *Category) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error

UnmarshalXML unmarshals the XML into a Category value.

type Certainty

type Certainty int

func (*Certainty) MarshalJSON

func (certainty *Certainty) MarshalJSON() ([]byte, error)

MarshalJSON returns the string version of the certainty.

func (*Certainty) MarshalXML

func (certainty *Certainty) MarshalXML(e *xml.Encoder, start xml.StartElement) error

MarshalXML returns the string version of the certainty.

func (Certainty) String

func (certainty Certainty) String() string

String returns a Certainty as a string

func (*Certainty) UnmarshalJSON

func (certainty *Certainty) UnmarshalJSON(b []byte) error

UnmarshalJSON unmarshals the JSON into a Certainty value.

func (*Certainty) UnmarshalString

func (certainty *Certainty) UnmarshalString(str string) error

UnmarshalString unmarshals the string into a Certainty value.

func (*Certainty) UnmarshalXML

func (certainty *Certainty) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error

UnmarshalXML unmarshals the XML into a Certainty value.

type Circle

type Circle struct {
	Type        string    `json:"type"`
	Coordinates []float64 `json:"coordinates"`
	Radius      float64   `json:"radius"`
}

type Circles

type Circles []*Circle

func (*Circles) MarshalXML

func (m *Circles) MarshalXML(e *xml.Encoder, start xml.StartElement) error

func (*Circles) UnmarshalXML

func (m *Circles) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error

type Info

type Info struct {
	XMLName xml.Name `xml:"info" json:"-"`

	Language      string         `xml:"language" json:"language"`
	Categories    []Category     `xml:"category" json:"categories"`
	Event         string         `xml:"event" json:"event"`
	ResponseTypes []ResponseType `xml:"responseType" json:"response_types"`
	Urgency       Urgency        `xml:"urgency" json:"urgency"`
	Severity      Severity       `xml:"severity" json:"severity"`
	Certainty     Certainty      `xml:"certainty" json:"certainty"`
	Audience      string         `xml:"audience" json:"audience"`
	EventCodes    KeyValue       `xml:"eventCode" json:"event_codes"`
	Effective     *Time          `xml:"effective" json:"effective"`
	Onset         *Time          `xml:"onset" json:"onset"`
	Expires       *Time          `xml:"expires" json:"expires"`
	SenderName    string         `xml:"senderName" json:"sender_name"`
	Headline      string         `xml:"headline" json:"headline"`
	Description   string         `xml:"description" json:"description"`
	Instruction   string         `xml:"instruction" json:"instruction"`
	Web           string         `xml:"web" json:"web"`
	Contact       string         `xml:"contact" json:"contact"`
	Parameters    KeyValue       `xml:"parameter" json:"parameters"`
	Resources     []Resource     `xml:"resource" json:"resources"`
	Areas         []Area         `xml:"area" json:"areas"`
}

type KeyValue

type KeyValue map[string][]string

func (*KeyValue) MarshalXML

func (m *KeyValue) MarshalXML(e *xml.Encoder, start xml.StartElement) error

func (*KeyValue) UnmarshalXML

func (m *KeyValue) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error

type List

type List []string

func (*List) UnmarshalXML

func (m *List) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error

type MessageType

type MessageType int

func (*MessageType) MarshalJSON

func (messageType *MessageType) MarshalJSON() ([]byte, error)

MarshalJSON returns the string version of the message type.

func (*MessageType) MarshalXML

func (messageType *MessageType) MarshalXML(e *xml.Encoder, start xml.StartElement) error

MarshalXML returns the string version of the message type.

func (MessageType) String

func (messageType MessageType) String() string

String returns a MessageType as a string

func (*MessageType) UnmarshalJSON

func (messageType *MessageType) UnmarshalJSON(b []byte) error

UnmarshalJSON unmarshals the XML into a MessageType value.

func (*MessageType) UnmarshalString

func (messageType *MessageType) UnmarshalString(str string) error

UnmarshalString unmarshals the string into a MessageType value.

func (*MessageType) UnmarshalXML

func (messageType *MessageType) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error

UnmarshalXML unmarshals the XML into a MessageType value.

type Polygon

type Polygon struct {
	Type        string        `json:"type"`
	Coordinates [][][]float64 `json:"coordinates"`
}

func (*Polygon) UnmarshalXML

func (p *Polygon) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error

type Polygons

type Polygons []*Polygon

func (*Polygons) MarshalXML

func (m *Polygons) MarshalXML(e *xml.Encoder, start xml.StartElement) error

type Reference

type Reference struct {
	Sender     string `json:"sender"`
	Identifier string `json:"identifier"`
	Sent       Time   `json:"sent"`
}

func (*Reference) Id

func (reference *Reference) Id() string

type References

type References []*Reference

func (*References) MarshalXML

func (m *References) MarshalXML(e *xml.Encoder, start xml.StartElement) error

func (*References) UnmarshalXML

func (m *References) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error

type Resource

type Resource struct {
	XMLName xml.Name `xml:"resource" json:"-"`

	Description string  `xml:"resourceDesc" json:"description"`
	MimeType    string  `xml:"mimeType" json:"mime_type"`
	Size        int     `xml:"size" json:"size"`
	Uri         string  `xml:"uri" json:"uri"`
	Digest      string  `xml:"digest" json:"digest"`
	DerefUri    *string `xml:"derefUri" json:"deref_uri"`
}

func (*Resource) Checksum

func (res *Resource) Checksum() string

type ResponseType

type ResponseType int

func (*ResponseType) MarshalJSON

func (responseType *ResponseType) MarshalJSON() ([]byte, error)

MarshalJSON returns the string version of the response type.

func (*ResponseType) MarshalXML

func (responseType *ResponseType) MarshalXML(e *xml.Encoder, start xml.StartElement) error

MarshalXML returns the string version of the response type.

func (ResponseType) String

func (responseType ResponseType) String() string

String returns a ResponseType as a string

func (*ResponseType) UnmarshalJSON

func (responseType *ResponseType) UnmarshalJSON(b []byte) error

UnmarshalJSON unmarshals the JSON into a ResponseType value.

func (*ResponseType) UnmarshalString

func (responseType *ResponseType) UnmarshalString(str string) error

UnmarshalString unmarshals the string into a ResponseType value.

func (*ResponseType) UnmarshalXML

func (responseType *ResponseType) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error

UnmarshalXML unmarshals the XML into a ResponseType value.

type Scope

type Scope int

func (*Scope) MarshalJSON

func (scope *Scope) MarshalJSON() ([]byte, error)

MarshalJSON returns the string version of the scope.

func (*Scope) MarshalXML

func (scope *Scope) MarshalXML(e *xml.Encoder, start xml.StartElement) error

MarshalXML returns the string version of the scope.

func (Scope) String

func (scope Scope) String() string

String returns a Scope as a string

func (*Scope) UnmarshalJSON

func (scope *Scope) UnmarshalJSON(b []byte) error

UnmarshalJSON unmarshals the JSON into a Scope value.

func (*Scope) UnmarshalString

func (scope *Scope) UnmarshalString(str string) error

UnmarshalString unmarshals the string into a Scope value.

func (*Scope) UnmarshalXML

func (scope *Scope) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error

UnmarshalXML unmarshals the XML into a Scope value.

type Severity

type Severity int

func (*Severity) MarshalJSON

func (severity *Severity) MarshalJSON() ([]byte, error)

MarshalJSON returns the string version of the severity.

func (*Severity) MarshalXML

func (severity *Severity) MarshalXML(e *xml.Encoder, start xml.StartElement) error

MarshalXML returns the string version of the severity.

func (Severity) String

func (severity Severity) String() string

String returns a Severity as a string

func (*Severity) UnmarshalJSON

func (severity *Severity) UnmarshalJSON(b []byte) error

UnmarshalJSON unmarshals the JSON into a Severity value.

func (*Severity) UnmarshalString

func (severity *Severity) UnmarshalString(str string) error

UnmarshalString unmarshals the string into a Severity value.

func (*Severity) UnmarshalXML

func (severity *Severity) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error

UnmarshalXML unmarshals the XML into a Severity value.

type Status

type Status int

func (*Status) MarshalJSON

func (status *Status) MarshalJSON() ([]byte, error)

MarshalJSON returns the string version of the status.

func (*Status) MarshalXML

func (status *Status) MarshalXML(e *xml.Encoder, start xml.StartElement) error

MarshalXML returns the string version of the status.

func (Status) String

func (status Status) String() string

String returns a Status as a string

func (*Status) UnmarshalJSON

func (status *Status) UnmarshalJSON(b []byte) error

UnmarshalJSON unmarshals the JSON into a Status value.

func (*Status) UnmarshalString

func (status *Status) UnmarshalString(str string) error

UnmarshalString unmarshals the string into a Status value.

func (*Status) UnmarshalXML

func (status *Status) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error

UnmarshalXML unmarshals the XML into a Status value.

type Time

type Time struct {
	time.Time
}

Time represents an instant in time.

func (Time) FormatCAP

func (time Time) FormatCAP() string

func (Time) MarshalXML

func (time Time) MarshalXML(e *xml.Encoder, start xml.StartElement) error

type Urgency

type Urgency int

func (*Urgency) MarshalJSON

func (urgency *Urgency) MarshalJSON() ([]byte, error)

MarshalJSON returns the string version of the urgency.

func (*Urgency) MarshalXML

func (urgency *Urgency) MarshalXML(e *xml.Encoder, start xml.StartElement) error

MarshalXML returns the string version of the urgency.

func (Urgency) String

func (urgency Urgency) String() string

String returns a Urgency as a string

func (*Urgency) UnmarshalJSON

func (urgency *Urgency) UnmarshalJSON(b []byte) error

UnmarshalJSON unmarshals the JSON into a Urgency value.

func (*Urgency) UnmarshalString

func (urgency *Urgency) UnmarshalString(str string) error

UnmarshalString unmarshals the string into a Urgency value.

func (*Urgency) UnmarshalXML

func (urgency *Urgency) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error

UnmarshalXML unmarshals the XML into a Urgency value.

Jump to

Keyboard shortcuts

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