Documentation
¶
Index ¶
- Variables
- type Delivery
- type DeliveryFilter
- type DeliveryListResult
- type DeliveryStatus
- type Filter
- type ID
- type ListResult
- type Repository
- type Status
- type Webhook
- func (w *Webhook) AssetGroupIDs() []string
- func (w *Webhook) CreatedAt() time.Time
- func (w *Webhook) CreatedBy() *ID
- func (w *Webhook) Description() string
- func (w *Webhook) Disable()
- func (w *Webhook) Enable()
- func (w *Webhook) EventTypes() []string
- func (w *Webhook) ID() ID
- func (w *Webhook) LastError() string
- func (w *Webhook) LastErrorAt() *time.Time
- func (w *Webhook) LastSentAt() *time.Time
- func (w *Webhook) MaxRetries() int
- func (w *Webhook) Name() string
- func (w *Webhook) RetryIntervalSeconds() int
- func (w *Webhook) SecretEncrypted() []byte
- func (w *Webhook) SetCreatedBy(id ID)
- func (w *Webhook) SetDescription(desc string)
- func (w *Webhook) SetEventTypes(types []string)
- func (w *Webhook) SetMaxRetries(n int)
- func (w *Webhook) SetName(name string)
- func (w *Webhook) SetRetryIntervalSeconds(n int)
- func (w *Webhook) SetSecret(secret []byte)
- func (w *Webhook) SetSeverityThreshold(s string)
- func (w *Webhook) SetURL(url string)
- func (w *Webhook) SeverityThreshold() string
- func (w *Webhook) Status() Status
- func (w *Webhook) Tags() []string
- func (w *Webhook) TenantID() ID
- func (w *Webhook) TotalFailed() int
- func (w *Webhook) TotalSent() int
- func (w *Webhook) URL() string
- func (w *Webhook) UpdatedAt() time.Time
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrWebhookNotFound = fmt.Errorf("%w: webhook not found", shared.ErrNotFound) ErrWebhookNameExists = fmt.Errorf("%w: webhook name already exists", shared.ErrAlreadyExists) )
Functions ¶
This section is empty.
Types ¶
type Delivery ¶
type Delivery struct {
ID ID
WebhookID ID
EventID *ID
EventType string
Payload map[string]any
Status DeliveryStatus
ResponseCode *int
ResponseBody string
ResponseHeaders map[string]any
Attempt int
NextRetryAt *time.Time
ErrorMessage string
CreatedAt time.Time
DeliveredAt *time.Time
DurationMs *int
}
Delivery represents a webhook delivery attempt.
type DeliveryFilter ¶
type DeliveryFilter struct {
WebhookID *ID
Status *DeliveryStatus
Page int
PerPage int
}
DeliveryFilter represents filtering options for listing deliveries.
type DeliveryListResult ¶
DeliveryListResult represents a paginated list of deliveries.
type DeliveryStatus ¶
type DeliveryStatus string
DeliveryStatus represents delivery status.
const ( DeliveryPending DeliveryStatus = "pending" DeliverySuccess DeliveryStatus = "success" DeliveryFailed DeliveryStatus = "failed" DeliveryRetrying DeliveryStatus = "retrying" )
type Filter ¶
type Filter struct {
TenantID *ID
Status *Status
EventType string
Search string
Page int
PerPage int
SortBy string
SortOrder string
}
Filter represents filtering options for listing webhooks.
type ListResult ¶
ListResult represents a paginated list of webhooks.
type Repository ¶
type Repository interface {
Create(ctx context.Context, w *Webhook) error
GetByID(ctx context.Context, id, tenantID ID) (*Webhook, error)
List(ctx context.Context, filter Filter) (ListResult, error)
Update(ctx context.Context, w *Webhook) error
Delete(ctx context.Context, id, tenantID ID) error
ListDeliveries(ctx context.Context, filter DeliveryFilter) (DeliveryListResult, error)
}
Repository defines the interface for webhook persistence.
type Webhook ¶
type Webhook struct {
// contains filtered or unexported fields
}
Webhook represents an outgoing webhook configuration.
func NewWebhook ¶
NewWebhook creates a new webhook entity.
func Reconstruct ¶
func Reconstruct( id, tenantID ID, name, description, url string, secretEncrypted []byte, eventTypes []string, severityThreshold string, assetGroupIDs, tags []string, status Status, maxRetries, retryIntervalSeconds int, totalSent, totalFailed int, lastSentAt *time.Time, lastError string, lastErrorAt *time.Time, createdBy *ID, createdAt, updatedAt time.Time, ) *Webhook
Reconstruct creates a Webhook from stored data.
func (*Webhook) AssetGroupIDs ¶
func (*Webhook) Description ¶
func (*Webhook) EventTypes ¶
func (*Webhook) LastErrorAt ¶
func (*Webhook) LastSentAt ¶
func (*Webhook) MaxRetries ¶
func (*Webhook) RetryIntervalSeconds ¶
func (*Webhook) SecretEncrypted ¶
func (*Webhook) SetCreatedBy ¶
func (*Webhook) SetDescription ¶
func (*Webhook) SetEventTypes ¶
func (*Webhook) SetMaxRetries ¶
func (*Webhook) SetRetryIntervalSeconds ¶
func (*Webhook) SetSeverityThreshold ¶
func (*Webhook) SeverityThreshold ¶
func (*Webhook) TotalFailed ¶
Click to show internal directories.
Click to hide internal directories.