endpoints

package
v1.17.0 Latest Latest
Warning

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

Go to latest
Published: May 14, 2023 License: MIT Imports: 6 Imported by: 2

README

Endpoints

Compatible with Logz.io's endpoints API.

For each type of endpoint there is a different structure, below you can find an example for creating a Slack endpoint. For more info, see: https://docs.logz.io/api/#tag/Manage-notification-endpoints or check our endpoints tests for more examples.

client, _ := endpoints.New(apiToken, apiServerAddress)
endpoint, err := client.CreateEndpoint(endpoints.CreateOrUpdateEndpoint{
                Title:         "New endpoint",
                Description:   "this is a description",
                Type:          "slack",
                Url:           "https://jsonplaceholder.typicode.com/todos/1",
            })
function func name
create endpoint func (c *EndpointsClient) CreateEndpoint(endpoint CreateOrUpdateEndpoint) (*CreateOrUpdateEndpointResponse, error)
delete endpoint func (c *EndpointsClient) DeleteEndpoint(endpointId int64) error
get endpoint func (c *EndpointsClient) GetEndpoint(endpointId int64) (*Endpoint, error)
list endpoints func (c *EndpointsClient) ListEndpoints() ([]Endpoint, error)
update endpoint func (c *EndpointsClient) UpdateEndpoint(id int64, endpoint CreateOrUpdateEndpoint) (*CreateOrUpdateEndpointResponse, error)

Documentation

Index

Constants

View Source
const (
	EndpointTypeSlack          string = "slack"
	EndpointTypeCustom         string = "custom"
	EndpointTypePagerDuty      string = "pagerduty"
	EndpointTypeBigPanda       string = "bigpanda"
	EndpointTypeDataDog        string = "datadog"
	EndpointTypeVictorOps      string = "victorops"
	EndpointTypeOpsGenie       string = "opsgenie"
	EndpointTypeServiceNow     string = "servicenow"
	EndpointTypeMicrosoftTeams string = "microsoftteams"
)

supported endpoint types

Variables

This section is empty.

Functions

This section is empty.

Types

type CreateOrUpdateEndpoint added in v1.8.0

type CreateOrUpdateEndpoint struct {
	Title         string      `json:"title"`                   // all
	Description   string      `json:"description"`             // all
	Url           string      `json:"url,omitempty"`           // slack, custom, serviceNow, microsoftTeams
	Method        string      `json:"method,omitempty'"`       // custom
	Headers       *string     `json:"headers,omitempty"`       // custom. Set to pointer to allow an empty string
	BodyTemplate  interface{} `json:"bodyTemplate,omitempty"`  // custom
	ServiceKey    string      `json:"serviceKey,omitempty"`    // pagerDuty
	ApiToken      string      `json:"apiToken,omitempty"`      // bigPanda
	AppKey        string      `json:"appKey,omitempty"`        // bigPanda
	ApiKey        string      `json:"apiKey,omitempty"`        // dataDog, opsGenie
	RoutingKey    string      `json:"routingKey,omitempty"`    // victorOps
	MessageType   string      `json:"messageType,omitempty"`   // victorOps
	ServiceApiKey string      `json:"serviceApiKey,omitempty"` // victorOps
	Username      string      `json:"username,omitempty"`      // serviceNow
	Password      string      `json:"password,omitempty"`      // serviceNow
	Type          string      `json:"-"`                       // only for identification of the endpoint
}

type CreateOrUpdateEndpointResponse added in v1.8.0

type CreateOrUpdateEndpointResponse struct {
	Id int32 `json:"id"`
}

type Endpoint

type Endpoint struct {
	Type          string      `json:"endpointType"`
	Id            int32       `json:"id"`
	Title         string      `json:"title"`
	Description   string      `json:"description"`
	Url           string      `json:"url,omitempty"`           // slack, custom, serviceNow, microsoftTeams
	Method        string      `json:"method,omitempty'"`       // custom
	Headers       string      `json:"headers,omitempty"`       // custom
	BodyTemplate  interface{} `json:"bodyTemplate,omitempty"`  // custom
	ServiceKey    string      `json:"serviceKey,omitempty"`    // pagerDuty
	ApiToken      string      `json:"apiToken,omitempty"`      // bigPanda
	AppKey        string      `json:"appKey,omitempty"`        // bigPanda
	ApiKey        string      `json:"apiKey,omitempty"`        // dataDog, opsGenie
	RoutingKey    string      `json:"routingKey,omitempty"`    // victorOps
	MessageType   string      `json:"messageType,omitempty"`   //victorOps
	ServiceApiKey string      `json:"serviceApiKey,omitempty"` // victorOps
	Username      string      `json:"username,omitempty"`      // serviceNow
	Password      string      `json:"password,omitempty"`      // serviceNow
}

type EndpointsClient

type EndpointsClient struct {
	*client.Client
}

func New

func New(apiToken, baseUrl string) (*EndpointsClient, error)

func (*EndpointsClient) CreateEndpoint

CreateEndpoint creates a notification endpoint, return the created endpoint's id if successful, an error otherwise

func (*EndpointsClient) DeleteEndpoint

func (c *EndpointsClient) DeleteEndpoint(endpointId int64) error

DeleteEndpoint deletes an endpoint, specified by its unique id, returns an error if a problem is encountered

func (*EndpointsClient) GetEndpoint

func (c *EndpointsClient) GetEndpoint(endpointId int64) (*Endpoint, error)

GetEndpoint returns an endpoint given its unique identifier, an error otherwise

func (*EndpointsClient) ListEndpoints

func (c *EndpointsClient) ListEndpoints() ([]Endpoint, error)

ListEndpoints returns all the endpoints in an array associated with the account identified by the supplied API token, returns an error if any problem occurs during the API call

func (*EndpointsClient) UpdateEndpoint

UpdateEndpoint updates an existing endpoint, based on the supplied identifier, using the parameters of the specified endpoint Returns the updated endpoint id if successful, an error otherwise

Jump to

Keyboard shortcuts

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