ans

package
v1.240.0 Latest Latest
Warning

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

Go to latest
Published: Aug 18, 2022 License: Apache-2.0 Imports: 14 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ANS

type ANS struct {
	XSUAA xsuaa.XSUAA
	URL   string
}

ANS holds the setup for the xsuaa service to retrieve a bearer token for authorization and the URL to the SAP Alert Notification Service backend

func (*ANS) CheckCorrectSetup

func (ans *ANS) CheckCorrectSetup() error

CheckCorrectSetup of the SAP Alert Notification Service

func (*ANS) Send

func (ans *ANS) Send(event Event) error

Send an event to the SAP Alert Notification Service

func (*ANS) SetServiceKey

func (ans *ANS) SetServiceKey(serviceKey ServiceKey)

SetServiceKey sets the xsuaa service key

type Client

type Client interface {
	Send(event Event) error
	CheckCorrectSetup() error
	SetServiceKey(serviceKey ServiceKey)
}

Client to send the event to the SAP Alert Notification Service

type Event

type Event struct {
	EventType      string                 `json:"eventType,omitempty"`
	EventTimestamp int64                  `json:"eventTimestamp,omitempty" validate:"omitempty,min=0"`
	Severity       string                 `json:"severity,omitempty" validate:"omitempty,oneof=INFO NOTICE WARNING ERROR FATAL"`
	Category       string                 `json:"category,omitempty" validate:"omitempty,oneof=EXCEPTION ALERT NOTIFICATION"`
	Subject        string                 `json:"subject,omitempty"`
	Body           string                 `json:"body,omitempty"`
	Priority       int                    `json:"priority,omitempty" validate:"omitempty,min=1,max=1000"`
	Tags           map[string]interface{} `json:"tags,omitempty"`
	Resource       *Resource              `json:"resource,omitempty"`
}

Event structure of the SAP Alert Notification Service

func (*Event) Copy added in v1.226.0

func (event *Event) Copy() (destination Event, err error)

Copy will copy an ANS Event

func (*Event) MergeWithJSON

func (event *Event) MergeWithJSON(eventJSON []byte) (err error)

MergeWithJSON unmarshalls an ANS Event JSON string and merges it with the existing receiver Event

func (*Event) SetSeverityAndCategory

func (event *Event) SetSeverityAndCategory(level logrus.Level)

SetSeverityAndCategory takes the logrus log level and sets the corresponding ANS severity and category string

func (*Event) Validate

func (event *Event) Validate() (err error)

Validate will validate the Event according to the 'validate' tags in the struct

type Resource

type Resource struct {
	ResourceName     string                 `json:"resourceName,omitempty"`
	ResourceType     string                 `json:"resourceType,omitempty"`
	ResourceInstance string                 `json:"resourceInstance,omitempty"`
	Tags             map[string]interface{} `json:"tags,omitempty"`
}

Resource structure of the SAP Alert Notification Service Event

type ServiceKey

type ServiceKey struct {
	Url          string `json:"url"`
	ClientId     string `json:"client_id"`
	ClientSecret string `json:"client_secret"`
	OauthUrl     string `json:"oauth_url"`
}

ServiceKey holds the information about the SAP Alert Notification Service to send the events to

func UnmarshallServiceKeyJSON

func UnmarshallServiceKeyJSON(serviceKeyJSON string) (ansServiceKey ServiceKey, err error)

UnmarshallServiceKeyJSON unmarshalls the given json service key string.

Jump to

Keyboard shortcuts

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