webhook

package
v0.0.0-...-d125d34 Latest Latest
Warning

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

Go to latest
Published: May 8, 2024 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckIfEventMatch

func CheckIfEventMatch(webhook *wmodels.Webhook, event *models.Event) (bool, error)

func JoinTriggers

func JoinTriggers(triggers []string) string

func ParseTriggerStr

func ParseTriggerStr(triggerStr string) []string

Types

type Controller

type Controller interface {
	CreateWebhook(ctx context.Context, resourceType string,
		resourceID uint, w *CreateWebhookRequest) (*Webhook, error)
	GetWebhook(ctx context.Context, id uint) (*Webhook, error)
	ListWebhooks(ctx context.Context, resourceType string,
		resourceID uint, query *q.Query) ([]*Webhook, int64, error)
	UpdateWebhook(ctx context.Context, id uint,
		w *UpdateWebhookRequest) (*Webhook, error)
	DeleteWebhook(ctx context.Context, id uint) error
	ListWebhookLogs(ctx context.Context, wID uint, query *q.Query) ([]*LogSummary, int64, error)
	GetWebhookLog(ctx context.Context, id uint) (*Log, error)
	ResendWebhook(ctx context.Context, id uint) (*models.WebhookLog, error)
}

func NewController

func NewController(param *param.Param) Controller

type CreateWebhookRequest

type CreateWebhookRequest struct {
	Enabled          bool     `json:"enabled"`
	URL              string   `json:"url"`
	SSLVerifyEnabled bool     `json:"sslVerifyEnabled"`
	Description      string   `json:"description"`
	Secret           string   `json:"secret"`
	Triggers         []string `json:"triggers"`
}

type Log

type Log struct {
	LogSummary
	RequestHeaders  string `json:"requestHeaders"`
	RequestData     string `json:"requestData"`
	ResponseHeaders string `json:"responseHeaders"`
	ResponseBody    string `json:"responseBody"`
}

type LogSummary

type LogSummary struct {
	ID           uint                  `json:"id"`
	WebhookID    uint                  `json:"webhookID"`
	EventID      uint                  `json:"eventID"`
	URL          string                `json:"url"`
	Status       string                `json:"status"`
	ResourceType string                `json:"resourceType"`
	ResourceName string                `json:"resourceName"`
	ResourceID   uint                  `json:"resourceID"`
	EventType    string                `json:"eventType"`
	Extra        *string               `json:"extra"`
	ErrorMessage string                `json:"errorMessage"`
	CreatedAt    time.Time             `json:"createdAt"`
	CreatedBy    *usermodels.UserBasic `json:"createdBy,omitempty"`
	UpdatedAt    time.Time             `json:"updatedAt"`
	UpdatedBy    *usermodels.UserBasic `json:"updatedBy,omitempty"`
}

type UpdateWebhookRequest

type UpdateWebhookRequest struct {
	Enabled          *bool    `json:"enabled"`
	URL              *string  `json:"url"`
	SSLVerifyEnabled *bool    `json:"sslVerifyEnabled"`
	Description      *string  `json:"description"`
	Secret           *string  `json:"secret"`
	Triggers         []string `json:"triggers"`
}

type Webhook

type Webhook struct {
	CreateWebhookRequest
	ID        uint                  `json:"id"`
	CreatedAt time.Time             `json:"createdAt"`
	CreatedBy *usermodels.UserBasic `json:"createdBy,omitempty"`
	UpdatedAt time.Time             `json:"updatedAt"`
	UpdatedBy *usermodels.UserBasic `json:"updatedBy,omitempty"`
}

Jump to

Keyboard shortcuts

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