webhook

package
v1.0.0-beta.225 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2025 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EntitlementsEventGroupName = "entitlements"

	EntitlementsBalanceThresholdType        = "entitlements.balance.threshold"
	EntitlementsBalanceThresholdDescription = "Notification event for entitlements balance threshold violations"

	EntitlementResetType        = "entitlements.reset"
	EntitlementResetDescription = "Notification event for entitlement reset events."
)
View Source
const (
	InvoiceEventGroupName = "invoice"

	InvoiceCreatedType        = "invoice.created"
	InvoiceCreatedDescription = "Notification event for new invoice created."

	InvoiceUpdatedType        = "invoice.updated"
	InvoiceUpdatedDescription = "Notification event for new invoice updated."
)
View Source
const (
	DefaultRegistrationTimeout = 30 * time.Second
)
View Source
const DefaultRetryAfter = 15 * time.Second

Variables

View Source
var ErrNotImplemented = errors.New("not implemented")
View Source
var EventTypeEntitlementsBalanceThreshold = EventType{
	Name:        EntitlementsBalanceThresholdType,
	Description: EntitlementsBalanceThresholdDescription,
	GroupName:   EntitlementsEventGroupName,
}
View Source
var EventTypeEntitlementsReset = EventType{
	Name:        EntitlementResetType,
	Description: EntitlementResetDescription,
	GroupName:   EntitlementsEventGroupName,
}
View Source
var EventTypeInvoiceCreated = EventType{
	Name:        InvoiceCreatedType,
	Description: InvoiceCreatedDescription,
	GroupName:   InvoiceEventGroupName,
}
View Source
var EventTypeInvoiceUpdated = EventType{
	Name:        InvoiceUpdatedType,
	Description: InvoiceUpdatedDescription,
	GroupName:   InvoiceEventGroupName,
}

FIXME: add JSON schema for events FIXME: refactor notifications to keep these in one place

Functions

func IgnoreNotImplemented

func IgnoreNotImplemented(err error) error

func IsMessageNotReadyError

func IsMessageNotReadyError(err error) bool

func IsNotFoundError

func IsNotFoundError(err error) bool

func IsNotImplemented

func IsNotImplemented(err error) bool

func IsRetryableError

func IsRetryableError(err error) bool

func IsUnrecoverableError

func IsUnrecoverableError(err error) bool

func IsValidationError

func IsValidationError(err error) bool

func NewMessageNotReadyError

func NewMessageNotReadyError(namespace string, eventID string) error

func NewNotFoundError

func NewNotFoundError(err error) error

func NewRetryableError

func NewRetryableError(err error, after time.Duration) error

func NewUnrecoverableError

func NewUnrecoverableError(err error) error

func NewValidationError

func NewValidationError(err error) error

Types

type CreateWebhookInput

type CreateWebhookInput struct {
	Namespace string

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

func (CreateWebhookInput) Validate

func (i CreateWebhookInput) Validate() error

type DeleteWebhookInput

type DeleteWebhookInput = GetWebhookInput

type EvenTypeSchemaVersion

type EvenTypeSchemaVersion = string

type EventType

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

type EventTypeHandler

type EventTypeHandler interface {
	RegisterEventTypes(ctx context.Context, params RegisterEventTypesInputs) error
}

type EventTypeSchema

type EventTypeSchema = interface{}

type ExpandParams

type ExpandParams struct {
	// Payload stores whether the message payload for the webhook message should be included in the response or not.
	Payload bool
	// DeliveryStatus stores whether the delivery status for the webhook message should be included in the response or not.
	DeliveryStatus bool
}

type GetMessageInput

type GetMessageInput struct {
	Namespace string

	ID      string
	EventID string

	Expand ExpandParams
}

func (GetMessageInput) Validate

func (i GetMessageInput) Validate() error

type GetWebhookInput

type GetWebhookInput struct {
	Namespace string

	ID string
}

func (GetWebhookInput) Validate

func (i GetWebhookInput) Validate() error

type Handler

type Handler interface {
	WebhookHandler
	MessageHandler
	EventTypeHandler
}

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

	Annotations models.Annotations

	// Payload stores the message payload if it was requested.
	Payload *Payload

	// DeliveryStatuses stores the message delivery status if it was requested.
	DeliveryStatuses *[]MessageDeliveryStatus
}

type MessageDeliveryStatus

type MessageDeliveryStatus struct {
	NextAttempt *time.Time                            `json:"nextAttempt"`
	State       notification.EventDeliveryStatusState `json:"state"`
	ChannelID   string                                `json:"channel_id"`
	Attempts    []notification.EventDeliveryAttempt   `json:"attempts"`
}

type MessageHandler

type MessageHandler interface {
	SendMessage(ctx context.Context, params SendMessageInput) (*Message, error)
	GetMessage(ctx context.Context, params GetMessageInput) (*Message, error)
	ResendMessage(ctx context.Context, params ResendMessageInput) error
}

type MessageNotReadyError

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

func (MessageNotReadyError) Error

func (e MessageNotReadyError) Error() string

type NotFoundError

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

func (NotFoundError) Error

func (e NotFoundError) Error() string

func (NotFoundError) Unwrap

func (e NotFoundError) Unwrap() error

type Payload

type Payload = map[string]any

type RegisterEventTypesInputs

type RegisterEventTypesInputs struct {
	EventTypes  []EventType
	AllowUpdate bool
}

type ResendMessageInput

type ResendMessageInput struct {
	Namespace string

	ID        string
	EventID   string
	ChannelID string
}

func (ResendMessageInput) Validate

func (i ResendMessageInput) Validate() error

type RetryableError

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

func (RetryableError) Error

func (e RetryableError) Error() string

func (RetryableError) RetryAfter

func (e RetryableError) RetryAfter() time.Duration

func (RetryableError) Unwrap

func (e RetryableError) Unwrap() error

type SendMessageInput

type SendMessageInput struct {
	Namespace string

	EventID   string
	EventType string
	Channels  []string
	Payload   Payload
}

func (SendMessageInput) Validate

func (i SendMessageInput) Validate() error

type UnrecoverableError

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

func (UnrecoverableError) Error

func (e UnrecoverableError) Error() string

func (UnrecoverableError) Unwrap

func (e UnrecoverableError) Unwrap() 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     *uint16
	Description   *string
	EventTypes    []string
	Channels      []string
	Metadata      map[string]string
}

func (UpdateWebhookInput) Validate

func (i UpdateWebhookInput) Validate() error

type ValidationError

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

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     *uint16
	Description   string
	EventTypes    []string
	Channels      []string
	CreatedAt     time.Time
	UpdatedAt     time.Time
}

type WebhookHandler

type WebhookHandler interface {
	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
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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