reports

package
v1.14.1 Latest Latest
Warning

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

Go to latest
Published: Sep 15, 2025 License: Apache-2.0, Apache-2.0 Imports: 16 Imported by: 16

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Create

func Create(r *http.Request, cfg config.Config) (int, http.Header, []byte, error)

Create function is used to implement the create report request. The request is an http POST request with the report description provided as json structure in the request body

func Delete

func Delete(r *http.Request, cfg config.Config) (int, http.Header, []byte, error)

Delete function used to implement remove report request

func GetMetricProfile

func GetMetricProfile(input MongoInterface) (string, error)

GetMetricProfile is a function that takes a report struc element and returns the name of the metric profile (if exists)

func HandleSubrouter

func HandleSubrouter(s *mux.Router, confhandler *respond.ConfHandler)

HandleSubrouter uses the subrouter for a specific calls and creates a tree of sorts handling each route with a different subrouter

func List

func List(r *http.Request, cfg config.Config) (int, http.Header, []byte, error)

List function that implements the http GET request that retrieves all available report information

func ListOne

func ListOne(r *http.Request, cfg config.Config) (int, http.Header, []byte, error)

ListOne function that implements the http GET request that retrieves the specified report's information

func Options

func Options(r *http.Request, cfg config.Config) (int, http.Header, []byte, error)

func ReportNotFound

func ReportNotFound(contentType string) ([]byte, error)

ReportNotFound consructs marshals a response struct when the requested report is not found

func SubmitSuccesful

func SubmitSuccesful(inserted MongoInterface, contentType string, link string) ([]byte, error)

SubmitSuccesful marshals a response struct when a report is successfully inserted in the database

func Update

func Update(r *http.Request, cfg config.Config) (int, http.Header, []byte, error)

Update function used to implement update report request. This is an http PUT request that gets a specific report's name as a urlvar parameter input and a json structure in the request body in order to update the datastore document for the specific report

Types

type Computations

type Computations struct {
	AR     bool     `bson:"ar" json:"ar"`
	Status bool     `bson:"status" json:"status"`
	Trends []string `bson:"trends" json:"trends"`
}

Computations struct holds information about what needs to be computed in this report e.g. a/r, status and specific trends

type Info

type Info struct {
	Name        string `bson:"name,omitempty" json:"name" xml:"name"`
	Description string `bson:"description,omitempty" json:"description" xml:"description"`
	Created     string `bson:"created,omitempty" json:"created,omitempty" xml:"created,omitempty"`
	Updated     string `bson:"updated,omitempty" json:"updated,omitempty" xml:"updated,omitempty"`
}

Info contains info about a report and is used inside the main MongoInterface struct

type Message

type Message struct {
	XMLName xml.Name `xml:"root"`
	Message string
}

Message struct for xml message response

type MongoInterface

type MongoInterface struct {
	ID           string        `bson:"id,omitempty" json:"id,omitempty" xml:"id,omitempty"`
	Tenant       string        `json:"tenant" xml:"tenant"`
	Weight       string        `bson:"weight,omitempty"  json:"weight,omitempty"  xml:"weight,omitempty"`
	Disabled     bool          `bson:"disabled" json:"disabled" xml:"disabled"`
	Info         Info          `bson:"info" json:"info" xml:"info"`
	Computations *Computations `bson:"computations" json:"computations" xml:"-"`
	Thresholds   *Thresholds   `bson:"thresholds,omitempty" json:"thresholds,omitempty" xml:"thresholds"`
	Topology     Topology      `bson:"topology_schema" json:"topology_schema" xml:"topology_schema"`
	Profiles     []Profile     `bson:"profiles" json:"profiles" xml:"profiles"`
	Tags         []Tag         `bson:"filter_tags" json:"filter_tags" xml:"filter_tags"`
}

MongoInterface is used as an interface to Marshal and Unmarshal from different formats

func (MongoInterface) DetermineGroupType

func (report MongoInterface) DetermineGroupType(groupType string) string

DetermineGroupType looks into a report struct topology group pointers and determines whether a given groupType is a lesser_group or group or does not exist in the report.

func (MongoInterface) GetEndpointGroupType

func (report MongoInterface) GetEndpointGroupType() string

GetEndpointGroupType retrieves the deepest type nested inside the group hierarchy

func (MongoInterface) GetGroupType

func (report MongoInterface) GetGroupType() string

GetGroupType retrieves the first type nested inside the group hierarchy

func (*MongoInterface) ValidateProfiles

func (report *MongoInterface) ValidateProfiles(db *mongo.Database) []respond.ErrorResponse

ValidateProfiles ensures that the profiles in a report actually exist in the database and corrects possible name inconsistencies

func (*MongoInterface) ValidateTrends

func (report *MongoInterface) ValidateTrends() []respond.ErrorResponse

type Profile

type Profile struct {
	XMLName xml.Name `bson:"-"          json:"-"     xml:"profile"`
	ID      string   `bson:"id"         json:"id"    xml:"id,attr"`
	Name    string   `bson:"name"       json:"name"  xml:"name,attr"`
	Type    string   `bson:"type"       json:"type"  xml:"type,attr"`
}

Profile holds info about the profiles included in a report definition

type RootXML

type RootXML struct {
	XMLName xml.Name `xml:"root" json:"-"`
	Reports interface{}
}

RootXML struct to represent the root of the xml document

type Tag

type Tag struct {
	XMLName xml.Name `bson:",omitempty" json:"-"     xml:"tag"`
	Name    string   `bson:"name"       json:"name"  xml:"name,attr"`
	Value   string   `bson:"value"      json:"value" xml:"value,attr"`
	Context string   `bson:"context"    json:"context" xml:"context,attr"`
}

Tag holds info about the tags used in filtering in a report definition

type Thresholds

type Thresholds struct {
	Availabilty float32 `bson:"availability" json:"availability" xml:"availability"`
	Reliability float32 `bson:"reliability" json:"reliability" xml:"reliability"`
	Uptime      float32 `bson:"uptime" json:"uptime" xml:"uptime"`
	Unknown     float32 `bson:"unknown" json:"unknown" xml:"unknown"`
	Downtime    float32 `bson:"downtime" json:"downtime" xml:"downtime"`
}

Thresholds contains information about the percentage thresholds used to color report scores

type Topology

type Topology struct {
	// Nesting int            `bson:"nesting" json:"nesting" xml:"nesting"`
	Group *TopologyLevel `bson:"group,omitempty" json:"group,omitempty" xml:"group,omitempty"`
}

Topology contains the topology used in this report and is used inside the main MongoInterface struct

type TopologyLevel

type TopologyLevel struct {
	Type  string         `bson:"type" json:"type" xml:"type"`
	Group *TopologyLevel `bson:"group,omitempty" json:"group,omitempty" xml:"group,omitempty"`
}

TopologyLevel is used to create the multiple nesting levels for the Topology struct

Jump to

Keyboard shortcuts

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