webhook

package
v1.0.0-beta.172 Latest Latest
Warning

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

Go to latest
Published: Aug 30, 2024 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EntitlementsEventGroupName              = "entitlements"
	EntitlementsBalanceThresholdType        = "entitlements.balance.threshold"
	EntitlementsBalanceThresholdDescription = "Notification event for entitlements balance threshold violations"
)
View Source
const DefaultSigningSecretSize = 32
View Source
const (
	// NullChannel is an internal channel type which should receive no messages at any time.
	// Channels and EventTypes are used as message filters in Svix
	// which means that a webhook without any filtering will receive all messages
	// sent to the application the webhook belongs to. In order to prevent this we
	// use the NoMessageChannel as a dummy filter, so it is possible to set up webhook endpoint
	// prior knowing what type of messages are going to be routed to it.
	NullChannel = "__null_channel"
)
View Source
const (
	SigningSecretPrefix = "whsec_"
)

Variables

View Source
var EntitlementsBalanceThresholdEventType = EventType{
	Name:        EntitlementsBalanceThresholdType,
	Description: EntitlementsBalanceThresholdDescription,
	GroupName:   EntitlementsEventGroupName,
}
View Source
var NotificationEventTypes = []EventType{
	EntitlementsBalanceThresholdEventType,
}

Functions

func NewSigningSecret

func NewSigningSecret(size int) (string, error)

func NewSigningSecretWithDefaultSize

func NewSigningSecretWithDefaultSize() (string, error)

func ValidateSigningSecret

func ValidateSigningSecret(secret string) error

Types

type Config

type Config struct {
	SvixConfig

	RegisterEvenTypes []EventType
}

type CreateWebhookInput

type CreateWebhookInput struct {
	Namespace string

	ID            *string
	URL           string
	CustomHeaders map[string]string
	Disabled      bool
	Secret        *string
	RateLimit     *int32
	Description   *string
	EventTypes    []string
	Channels      []string
	Metadata      map[string]string
}

func (CreateWebhookInput) Validate

func (i CreateWebhookInput) Validate() error

type DeleteWebhookInput

type DeleteWebhookInput = GetWebhookInput

type EventType

type EventType struct {
	Name        string
	Description string
	GroupName   string
	// Schemas defines the list of schemas for each event type version
	Schemas map[string]map[string]interface{}
}

type GetWebhookInput

type GetWebhookInput struct {
	Namespace string

	ID string
}

func (GetWebhookInput) Validate

func (i GetWebhookInput) Validate() error

type Handler

type Handler interface {
	RegisterEventTypes(ctx context.Context, params RegisterEventTypesInputs) error
	ListWebhooks(ctx context.Context, params ListWebhooksInput) ([]Webhook, error)
	CreateWebhook(ctx context.Context, params CreateWebhookInput) (*Webhook, error)
	UpdateWebhook(ctx context.Context, params UpdateWebhookInput) (*Webhook, error)
	UpdateWebhookChannels(ctx context.Context, params UpdateWebhookChannelsInput) (*Webhook, error)
	GetWebhook(ctx context.Context, params GetWebhookInput) (*Webhook, error)
	DeleteWebhook(ctx context.Context, params DeleteWebhookInput) error
	SendMessage(ctx context.Context, params SendMessageInput) (*Message, error)
}

func New

func New(config Config) (Handler, error)

type ListWebhooksInput

type ListWebhooksInput struct {
	Namespace string

	IDs        []string
	EventTypes []string
	Channels   []string
}

func (ListWebhooksInput) Validate

func (i ListWebhooksInput) Validate() error

type Message

type Message struct {
	Namespace string

	ID        string
	EventID   string
	EventType string
	Channels  []string
	Payload   map[string]interface{}
}

type RegisterEventTypesInputs

type RegisterEventTypesInputs struct {
	EvenTypes   []EventType
	AllowUpdate bool
}

type SendMessageInput

type SendMessageInput struct {
	Namespace string

	EventID   string
	EventType string
	Channels  []string
	Payload   map[string]interface{}
}

func (SendMessageInput) Validate

func (i SendMessageInput) Validate() error

type SvixConfig

type SvixConfig struct {
	APIKey string

	ServerURL string
	Debug     bool
}

func (SvixConfig) Validate

func (c SvixConfig) Validate() error

type UpdateWebhookChannelsInput

type UpdateWebhookChannelsInput struct {
	Namespace string

	ID             string
	AddChannels    []string
	RemoveChannels []string
}

func (UpdateWebhookChannelsInput) Validate

func (i UpdateWebhookChannelsInput) Validate() error

type UpdateWebhookInput

type UpdateWebhookInput struct {
	Namespace string

	ID            string
	URL           string
	CustomHeaders map[string]string
	Disabled      bool
	Secret        *string
	RateLimit     *int32
	Description   *string
	EventTypes    []string
	Channels      []string
	Metadata      map[string]string
}

func (UpdateWebhookInput) Validate

func (i UpdateWebhookInput) Validate() error

type ValidationError

type ValidationError genericError

func (ValidationError) Error

func (e ValidationError) Error() string

func (ValidationError) Unwrap

func (e ValidationError) Unwrap() error

type Webhook

type Webhook struct {
	Namespace string

	ID            string
	URL           string
	Secret        string
	CustomHeaders map[string]string
	Disabled      bool
	RateLimit     *int32
	Description   string
	EventTypes    []string
	Channels      []string
	CreatedAt     time.Time
	UpdatedAt     time.Time
}

func WebhookFromSvixEndpointOut

func WebhookFromSvixEndpointOut(e *svix.EndpointOut) *Webhook

Jump to

Keyboard shortcuts

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