devo

package module
v0.0.0-...-5dec1bb Latest Latest
Warning

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

Go to latest
Published: May 25, 2022 License: BSD-3-Clause, MIT Imports: 7 Imported by: 0

README

No Logo Yet

go-devo - GoLang wrapper for Devo's REST API's

Report a Bug · Request a Feature . Ask a Question

go.dev reference

license Go Report Card Go Report Card


About

This GoLang module provides a wrapper around Devo's REST API's.

This project is NOT production ready right now.

Additional info

Devo is a cloud-native logging and security analytics SaaS offering. This project is community maintained and not officially endorsed or supported by Devo.

Built With

Getting Started

Prerequisites

GoLang is required to properly use this module. You can find information on how to install GoLang for your platform here.

Hopefully, it goes without saying that you'll also need access to an instance of Devo. You can get in touch with Devo using this form.

Usage

For detailed usage information, please refer to the official reference documentation.

Manual setup

Installation of the module is as simple as running go get https://github.com/MadsRC/go-devo in your GoLang project.

Roadmap

See the open issues for a list of proposed features (and known issues).

Contributing

Support

Reach out to the maintainer at one of the following places:

License

This project is licensed under the MIT license. Feel free to edit and distribute this template as you like.

See LICENSE for more information.

Acknowledgements

Documentation

Overview

Package devo provides a client library for working with the REST API interfaces available with https://devo.com.

This package is NOT production ready as is.

The official API documentation for the upstream Devo API's can be found at https://docs.devo.com/confluence/ndt/latest/api-reference.

Index

Constants

View Source
const (
	// Default endpoint for US based Devo domains.
	ALERTS_API_US_DEFAULT_ENDPOINT = "https://api-us.devo.com/alerts"

	// Default endpoint for EU based Devo domains.
	ALERTS_API_EU_DEFAULT_ENDPOINT = "https://api-eu.devo.com/alerts"

	// Default path for API Alerting
	ALERTS_API_PATH_ALERT_DEFINITIONS = "/v1/alertDefinitions"

	// Default path for API Alerting status
	ALERTS_API_PATH_ALERT_DEFINITIONS_STATUS = "/v1/alertDefinitions/status"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Alert

type Alert struct {
	ID                      string `json:"id"`
	CreationDate            int    `json:"creationDate"`
	Name                    string `json:"name"`
	Message                 string `json:"message"`
	Description             string `json:"description"`
	Subcategory             string `json:"subcategory"`
	CategoryID              string `json:"categoryId"`
	SubcategoryID           string `json:"subcategoryId"`
	IsActive                bool   `json:"isActive"`
	IsAlertChain            bool   `json:"isAlertChain"`
	AlertCorrelationContext AlertCorrelationContext
	ActionPolicyID          []interface{} `json:"actionPolicyId"`
}

Alert represents an alert definition.

type AlertCorrelationContext

type AlertCorrelationContext struct {
	QuerySourceCode    string                  `json:"querySourceCode"`
	Priority           int                     `json:"priority"`
	CorrelationTrigger AlertCorrelationTrigger `json:"correlationTrigger"`
}

AlertCorrelationContext represents an alert correlation context.

type AlertCorrelationTrigger

type AlertCorrelationTrigger struct {
	Kind              string `json:"kind"`
	ExternalOffset    string `json:"externalOffset"`
	InternalPeriod    string `json:"internalPeriod"`
	InternalOffset    string `json:"internalOffset"`
	Period            string `json:"period"`
	Threshold         string `json:"threshold"`
	BackPeriod        string `json:"backPeriod"`
	Absolute          string `json:"absolute"`
	AggregationColumn string `json:"aggregationColumn"`
}

AlertCorrelationTrigger represents an alert correlation trigger.

type AlertCreateRequest

type AlertCreateRequest struct {
	Name                    string                  `json:"name"`
	Message                 string                  `json:"message,omitempty"`
	Description             string                  `json:"description,omitempty"`
	Subcategory             string                  `json:"subcategory"`
	AlertCorrelationContext AlertCorrelationContext `json:"alertCorrelationContext"`
}

AlertCreateRequest contains parameters used when creating a new alert definition in your Devo domain using Create. The parameters Name, Subcategory and AlertCorrelationContext are required by the upstream API, more information can be found in the upstream documentation here: https://docs.devo.com/confluence/ndt/latest/api-reference/alerts-api/working-with-alert-definitions

type AlertDeleteRequest

type AlertDeleteRequest struct {
	AlertIDs []string
}

AlertDeleteRequest contains parameters used when deleting an alert definition in your Devo domain using Delete.

type AlertListRequest

type AlertListRequest struct {
	// Define the group to get. See parent struct documentation.
	Page string

	// Define the number of alerts to get. See parent struct documentation.
	Size string

	// Use this parameter to filter alerts by their names. You will only get
	// alerts that contain the terms specified in their names. The filter is
	// case insensitive.
	NameFilter string

	// Indicate an alert definition ID to get only that specific alert. You
	// will get the ID of an alert definition after creating a new alert
	// definition through the Alerting API. Note that this ID cannot be
	// found in the Devo application.
	IDFilter string
}

AlertListRequest contains the parameters that can be provided to the List method.

The documentation for the upstream Devo API can be found here: https://docs.devo.com/confluence/ndt/latest/api-reference/alerting-api/working-with-alert-definitions#id-.Workingwithalertdefinitionsvv7.11.0-createalertCreateanewalertdefinition

Use these parameters to group your list of alerts by a specific number (size) and get only one of the resulting groups (page). This comes in handy if you need to get only a specific set of alerts and have a long list.

Note that the count of both the selected page and groups defined starts at 0, so for example, if you enter page=2 and size=5 and have 22 alerts in your list, the API will divide the list into groups of 5 alerts (0-4, 5-9, 10-14, 15-19, and 20-22) and will return the group of alerts 10-14.

Some struct attributes here is intentionally strings, and not ints, to allow us to distinguish between empty/no-value and 0.

type AlertStatusUpdateRequest

type AlertStatusUpdateRequest struct {
	AlertIDs []string
	Enable   bool
}

AlertStatusUpdateRequest contains parameters used when changing the status of alert definitions in your Devo domain using Status.

type AlertUpdateRequest

type AlertUpdateRequest struct {
	Name                    string                  `json:"name"`
	Message                 string                  `json:"message,omitempty"`
	Description             string                  `json:"description,omitempty"`
	Subcategory             string                  `json:"subcategory,omitempty"`
	AlertCorrelationContext AlertCorrelationContext `json:"alertCorrelationContext,omitempty"`
}

AlertUpdateRequest contains parameters used when updating an alert definition in your Devo domain using Update. The parameter Name are required by the upstream API, more information can be found in the upstream documentation here: https://docs.devo.com/confluence/ndt/latest/api-reference/alerts-api/working-with-alert-definitions

type AlertsService

type AlertsService interface {
	List(parameters *AlertListRequest) ([]Alert, error)
	Create(createRequest *AlertCreateRequest) (*Alert, error)
	Update(updateRequest *AlertUpdateRequest) (*Alert, error)
	Delete(deleteRequest *AlertDeleteRequest) error
	Status(statusRequest *AlertStatusUpdateRequest) error
}

AlertService is an interface for interfacing with the Devo Alerting API.

type AlertsServiceOp

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

AlertsServiceOp implements the AlertService interface and handles the communication with the Devo Alerting API using its methods.

func (*AlertsServiceOp) Create

func (s *AlertsServiceOp) Create(createRequest *AlertCreateRequest) (*Alert, error)

Create creates a new alert definition in your Devo domain. Accepts parameters in the form of a pointer to a AlertCreateRequest struct.

As per AlertCreateRequest documentation, certain attributes are required by the upstream API. These attributes aren't checked before submitting an API request and any errors from the API will be returned by this function. FIXME: Tests for this cannot be created right now, as Devo doesn't document what an error response looks like.

Upstream API documentation can be found here: https://docs.devo.com/confluence/ndt/latest/api-reference/alerts-api/working-with-alert-definitions

Returns an error if createRequest isn't provided.

func (*AlertsServiceOp) Delete

func (s *AlertsServiceOp) Delete(deleteRequest *AlertDeleteRequest) error

Delete deletes one or more alerts in your Devo domain. Accepts parameters in the form of a pointer to a AlertDeleteRequest struct.

Returns an error if deleteRequest isn't provided. Returns an error if deleteRequest.AlertIDs is empty.

func (*AlertsServiceOp) List

func (s *AlertsServiceOp) List(parameters *AlertListRequest) ([]Alert, error)

List lists all the alert definitions in your Devo domain. Accepts parameters in the form of a pointer to an AlertListRequest struct.

func (*AlertsServiceOp) Status

func (s *AlertsServiceOp) Status(statusRequest *AlertStatusUpdateRequest) error

Status sets the status of one or more alerts in your Devo domain. Accepts parameters in the form of a pointer to a AlertStatusUpdateRequest.

Returns an error if statusRequest isn't provided. Returns an error if statusRequest.AlertIDs is empty.

func (*AlertsServiceOp) Update

func (s *AlertsServiceOp) Update(updateRequest *AlertUpdateRequest) (*Alert, error)

Update updates an existing alert definition in your Devo domain. Accepts parameters in the form of a pointer to a AlertUpdateRequst struct.

As per AlertUpdateRequest documentation, certain attributes are required by the upstream API. These attributes aren't checked before submitting an API request and any errors from the API will be returned by this function. FIXME: Tests for this cannot be created right now, as Devo doesn't document what an error response looks like.

Upstream API documentation can be found here: https://docs.devo.com/confluence/ndt/latest/api-reference/alerts-api/working-with-alert-definitions

Returns an error if updateRequest isn't provided.

type Client

type Client struct {
	UserAgent string

	Alerts         AlertsService
	AlertsEndpoint *url.URL
	AlertsToken    string
	// contains filtered or unexported fields
}

func New

func New(httpClient *http.Client, opts ...ClientOpt) (*Client, error)

type ClientOpt

type ClientOpt func(*Client) error

func SetAlertsEndpoint

func SetAlertsEndpoint(endpoint string) ClientOpt

func SetAlertsToken

func SetAlertsToken(token string) ClientOpt

func SetUserAgent

func SetUserAgent(userAgent string) ClientOpt

Jump to

Keyboard shortcuts

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