svix

package
v1.21.0 Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2024 License: MIT Imports: 12 Imported by: 5

README

Svix - Webhooks as a service

Website | Documentation | Community Slack

Go library for interacting with the Svix API and verifying webhook signatures

GitHub tag PkgGoDev

Join our slack

Usage Documentation

You can find general usage documentation at https://docs.svix.com. For complete API documentation with code examples for each endpoint in all of our official client libraries head over to our API documentation site at https://api.svix.com.

Language Support

⚡️ Features ⚡️
Officially Supported
API Support
Signature Verification
Caveats None! 🚀

Development

First checkout the core README for details on how to generate our API bindings, then follow the steps below.

Requirements

  • go >= 1.16

Contributing

Before opening a PR be sure to format your code!

go fmt ./...

Running Tests

Simply run:

go test ./...

Publishing

Releases use go modules and are automatically published by tagging the release commit.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Int32

func Int32(i int32) *int32

func NullableInt32 added in v1.8.0

func NullableInt32(num *int32) *openapi.NullableInt32

func NullableString added in v0.64.1

func NullableString(s *string) *openapi.NullableString

func String

func String(s string) *string

Types

type AggregateEventTypesOut added in v1.14.0

type AggregateEventTypesOut = openapi.AggregateEventTypesOut

type AppPortalAccessIn added in v0.75.0

type AppPortalAccessIn = openapi.AppPortalAccessIn

type AppPortalAccessOut added in v0.75.0

type AppPortalAccessOut = openapi.AppPortalAccessOut

type AppUsageStatsIn added in v1.14.0

type AppUsageStatsIn = openapi.AppUsageStatsIn

type AppUsageStatsOut added in v1.14.0

type AppUsageStatsOut = openapi.AppUsageStatsOut

type Application

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

func (*Application) Create

func (a *Application) Create(ctx context.Context, applicationIn *ApplicationIn) (*ApplicationOut, error)

func (*Application) CreateWithOptions added in v0.51.0

func (a *Application) CreateWithOptions(ctx context.Context, applicationIn *ApplicationIn, options *PostOptions) (*ApplicationOut, error)

func (*Application) Delete

func (a *Application) Delete(ctx context.Context, appId string) error

func (*Application) Get

func (a *Application) Get(ctx context.Context, appId string) (*ApplicationOut, error)

func (*Application) GetOrCreate added in v0.52.0

func (a *Application) GetOrCreate(ctx context.Context, applicationIn *ApplicationIn) (*ApplicationOut, error)

func (*Application) GetOrCreateWithOptions added in v0.52.0

func (a *Application) GetOrCreateWithOptions(ctx context.Context, applicationIn *ApplicationIn, options *PostOptions) (*ApplicationOut, error)

func (*Application) List

func (*Application) Patch added in v1.6.0

func (a *Application) Patch(ctx context.Context, appId string, applicationPatch *ApplicationPatch) (*ApplicationOut, error)

func (*Application) Update

func (a *Application) Update(ctx context.Context, appId string, applicationIn *ApplicationIn) (*ApplicationOut, error)

type ApplicationIn

type ApplicationIn = openapi.ApplicationIn

type ApplicationListOptions

type ApplicationListOptions struct {
	Iterator *string
	Limit    *int32
	Order    *Ordering
}

type ApplicationOut

type ApplicationOut = openapi.ApplicationOut

type ApplicationPatch added in v1.6.0

type ApplicationPatch = openapi.ApplicationPatch

type Authentication

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

func (*Authentication) AppPortalAccess added in v0.75.0

func (a *Authentication) AppPortalAccess(ctx context.Context, appId string, appPortalAccessIn *AppPortalAccessIn) (*AppPortalAccessOut, error)

func (*Authentication) AppPortalAccessWithOptions added in v0.75.0

func (a *Authentication) AppPortalAccessWithOptions(ctx context.Context, appId string, appPortalAccessIn *AppPortalAccessIn, options *PostOptions) (*AppPortalAccessOut, error)

func (*Authentication) DashboardAccess

func (a *Authentication) DashboardAccess(ctx context.Context, appId string) (*DashboardAccessOut, error)

func (*Authentication) DashboardAccessWithOptions added in v0.51.0

func (a *Authentication) DashboardAccessWithOptions(ctx context.Context, appId string, options *PostOptions) (*DashboardAccessOut, error)

func (*Authentication) Logout

func (a *Authentication) Logout(ctx context.Context) error

func (*Authentication) LogoutWithOptions added in v0.51.0

func (a *Authentication) LogoutWithOptions(ctx context.Context, options *PostOptions) error

type BackgroundTask added in v1.4.12

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

func (*BackgroundTask) Get added in v1.4.12

func (a *BackgroundTask) Get(ctx context.Context, taskId string) (*BackgroundTaskOut, error)

func (*BackgroundTask) List added in v1.4.12

type BackgroundTaskListOptions added in v1.4.12

type BackgroundTaskListOptions struct {
	Iterator *string
	Limit    *int32
	Order    *Ordering
	Status   *openapi.BackgroundTaskStatus
	Task     *openapi.BackgroundTaskType
}

type BackgroundTaskOut added in v1.4.12

type BackgroundTaskOut = openapi.BackgroundTaskOut

type DashboardAccessOut

type DashboardAccessOut = openapi.DashboardAccessOut

type Endpoint

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

func (*Endpoint) Create

func (e *Endpoint) Create(ctx context.Context, appId string, endpointIn *EndpointIn) (*EndpointOut, error)

func (*Endpoint) CreateWithOptions added in v0.51.0

func (e *Endpoint) CreateWithOptions(ctx context.Context, appId string, endpointIn *EndpointIn, options *PostOptions) (*EndpointOut, error)

func (*Endpoint) Delete

func (e *Endpoint) Delete(ctx context.Context, appId string, endpointId string) error

func (*Endpoint) Get

func (e *Endpoint) Get(ctx context.Context, appId string, endpointId string) (*EndpointOut, error)

func (*Endpoint) GetHeaders

func (e *Endpoint) GetHeaders(ctx context.Context, appId string, endpointId string) (*EndpointHeadersOut, error)

func (*Endpoint) GetSecret

func (e *Endpoint) GetSecret(ctx context.Context, appId string, endpointId string) (*EndpointSecretOut, error)

func (*Endpoint) GetStats added in v0.66.0

func (e *Endpoint) GetStats(ctx context.Context, appId string, endpointId string) (*EndpointStats, error)

func (*Endpoint) GetStatsWithOptions added in v1.4.12

func (e *Endpoint) GetStatsWithOptions(ctx context.Context, appId string, endpointId string, options EndpointStatsOptions) (*EndpointStats, error)

func (*Endpoint) List

func (*Endpoint) Patch added in v1.6.0

func (e *Endpoint) Patch(ctx context.Context, appId string, endpointId string, endpointPatch *EndpointPatch) (*EndpointOut, error)

func (*Endpoint) PatchHeaders

func (e *Endpoint) PatchHeaders(ctx context.Context, appId string, endpointId string, endpointHeadersIn *EndpointHeadersPatchIn) error

func (*Endpoint) Recover

func (e *Endpoint) Recover(ctx context.Context, appId string, endpointId string, recoverIn *RecoverIn) error

func (*Endpoint) RecoverWithOptions added in v0.51.0

func (e *Endpoint) RecoverWithOptions(ctx context.Context, appId string, endpointId string, recoverIn *RecoverIn, options *PostOptions) error

func (*Endpoint) ReplayMissing added in v0.76.1

func (e *Endpoint) ReplayMissing(ctx context.Context, appId string, endpointId string, replayIn *ReplayIn) error

func (*Endpoint) ReplayMissingWithOptions added in v0.76.1

func (e *Endpoint) ReplayMissingWithOptions(
	ctx context.Context,
	appId string,
	endpointId string,
	replayIn *ReplayIn,
	options *PostOptions,
) error

func (*Endpoint) RotateSecret

func (e *Endpoint) RotateSecret(ctx context.Context, appId string, endpointId string, endpointSecretRotateIn *EndpointSecretRotateIn) error

func (*Endpoint) RotateSecretWithOptions added in v0.51.0

func (e *Endpoint) RotateSecretWithOptions(ctx context.Context, appId string, endpointId string, endpointSecretRotateIn *EndpointSecretRotateIn, options *PostOptions) error

func (*Endpoint) SendExample added in v0.83.0

func (e *Endpoint) SendExample(ctx context.Context, appId string, endpointId string, eventExampleIn *EventExampleIn) (*MessageOut, error)

func (*Endpoint) SendExampleWithOptions added in v0.83.0

func (e *Endpoint) SendExampleWithOptions(
	ctx context.Context,
	appId string,
	endpointId string,
	eventExampleIn *EventExampleIn,
	options *PostOptions,
) (*MessageOut, error)

func (*Endpoint) TransformationGet added in v0.76.0

func (e *Endpoint) TransformationGet(ctx context.Context, appId string, endpointId string) (*EndpointTransformationOut, error)

func (*Endpoint) TransformationPartialUpdate added in v1.14.0

func (e *Endpoint) TransformationPartialUpdate(ctx context.Context, appId string, endpointId string, transformation *EndpointTransformationIn) error

func (*Endpoint) Update

func (e *Endpoint) Update(ctx context.Context, appId string, endpointId string, endpointUpdate *EndpointUpdate) (*EndpointOut, error)

func (*Endpoint) UpdateHeaders

func (e *Endpoint) UpdateHeaders(ctx context.Context, appId string, endpointId string, endpointHeadersIn *EndpointHeadersIn) error

type EndpointHeadersIn

type EndpointHeadersIn = openapi.EndpointHeadersIn

type EndpointHeadersOut

type EndpointHeadersOut = openapi.EndpointHeadersOut

type EndpointHeadersPatchIn added in v0.57.1

type EndpointHeadersPatchIn = openapi.EndpointHeadersPatchIn

type EndpointIn

type EndpointIn = openapi.EndpointIn

type EndpointListOptions

type EndpointListOptions struct {
	Iterator *string
	Limit    *int32
	Order    *Ordering
}

type EndpointMessageOut added in v0.83.0

type EndpointMessageOut = openapi.EndpointMessageOut

type EndpointOut

type EndpointOut = openapi.EndpointOut

type EndpointPatch added in v1.6.0

type EndpointPatch = openapi.EndpointPatch

type EndpointSecretOut

type EndpointSecretOut = openapi.EndpointSecretOut

type EndpointSecretRotateIn

type EndpointSecretRotateIn = openapi.EndpointSecretRotateIn

type EndpointStats added in v0.66.0

type EndpointStats = openapi.EndpointStats

type EndpointStatsOptions added in v1.4.12

type EndpointStatsOptions struct {
	Since *time.Time
	Until *time.Time
}

type EndpointTransformationIn added in v0.76.0

type EndpointTransformationIn = openapi.EndpointTransformationIn

type EndpointTransformationOut added in v0.76.0

type EndpointTransformationOut = openapi.EndpointTransformationOut

type EndpointUpdate

type EndpointUpdate = openapi.EndpointUpdate

type Error

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

Error provides access to the body, status, and error on returned errors.

func (Error) Body

func (e Error) Body() []byte

Body returns the raw bytes of the response.

func (Error) Error

func (e Error) Error() string

Error returns non-empty string if there was an error.

func (Error) Status

func (e Error) Status() int

Status returns the HTTP status of the error.

type EventExampleIn added in v0.83.0

type EventExampleIn = openapi.EventExampleIn

type EventType

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

func (*EventType) Create

func (e *EventType) Create(ctx context.Context, eventTypeIn *EventTypeIn) (*EventTypeOut, error)

func (*EventType) CreateWithOptions added in v0.51.0

func (e *EventType) CreateWithOptions(ctx context.Context, eventTypeIn *EventTypeIn, options *PostOptions) (*EventTypeOut, error)

func (*EventType) Delete

func (e *EventType) Delete(ctx context.Context, eventTypeName string) error

func (*EventType) DeleteWithOptions added in v1.13.0

func (e *EventType) DeleteWithOptions(ctx context.Context, eventTypeName string, options *EventTypeDeleteOptions) error

func (*EventType) Get

func (e *EventType) Get(ctx context.Context, eventTypeName string) (*EventTypeOut, error)

func (*EventType) ImportOpenApi added in v1.11.0

func (e *EventType) ImportOpenApi(ctx context.Context, eventTypeImportOpenApiIn EventTypeImportOpenApiIn) (*EventTypeImportOpenApiOut, error)

func (*EventType) ImportOpenApiWithOptions added in v1.11.0

func (e *EventType) ImportOpenApiWithOptions(ctx context.Context, eventTypeImportOpenApiIn EventTypeImportOpenApiIn, options *PostOptions) (*EventTypeImportOpenApiOut, error)

func (*EventType) List

func (*EventType) Patch added in v1.6.0

func (e *EventType) Patch(ctx context.Context, eventTypeName string, eventTypePatch *EventTypePatch) (*EventTypeOut, error)

func (*EventType) Update

func (e *EventType) Update(ctx context.Context, eventTypeName string, eventTypeUpdate *EventTypeUpdate) (*EventTypeOut, error)

type EventTypeDeleteOptions added in v1.13.0

type EventTypeDeleteOptions struct {
	Expunge *bool
}

type EventTypeImportOpenApiIn added in v1.11.0

type EventTypeImportOpenApiIn = openapi.EventTypeImportOpenApiIn

type EventTypeImportOpenApiOut added in v1.11.0

type EventTypeImportOpenApiOut = openapi.EventTypeImportOpenApiOut

type EventTypeImportOpenApiOutData added in v1.11.0

type EventTypeImportOpenApiOutData = openapi.EventTypeImportOpenApiOutData

type EventTypeIn

type EventTypeIn = openapi.EventTypeIn

type EventTypeListOptions

type EventTypeListOptions struct {
	Iterator        *string
	Limit           *int32
	WithContent     *bool
	IncludeArchived *bool
}

type EventTypeOut

type EventTypeOut = openapi.EventTypeOut

type EventTypePatch added in v1.6.0

type EventTypePatch = openapi.EventTypePatch

type EventTypeUpdate

type EventTypeUpdate = openapi.EventTypeUpdate

type Integration

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

func (*Integration) Create

func (e *Integration) Create(ctx context.Context, appId string, endpointIn *IntegrationIn) (*IntegrationOut, error)

func (*Integration) CreateWithOptions added in v0.51.0

func (e *Integration) CreateWithOptions(ctx context.Context, appId string, endpointIn *IntegrationIn, options *PostOptions) (*IntegrationOut, error)

func (*Integration) Delete

func (e *Integration) Delete(ctx context.Context, appId string, integId string) error

func (*Integration) Get

func (e *Integration) Get(ctx context.Context, appId string, integId string) (*IntegrationOut, error)

func (*Integration) GetKey

func (e *Integration) GetKey(ctx context.Context, appId string, integId string) (*IntegrationKeyOut, error)

func (*Integration) List

func (*Integration) RotateKey

func (e *Integration) RotateKey(ctx context.Context, appId string, integId string) (*IntegrationKeyOut, error)

func (*Integration) RotateKeyWithOptions added in v0.51.0

func (e *Integration) RotateKeyWithOptions(ctx context.Context, appId string, integId string, options *PostOptions) (*IntegrationKeyOut, error)

func (*Integration) Update

func (e *Integration) Update(ctx context.Context, appId string, integId string, endpointUpdate *IntegrationUpdate) (*IntegrationOut, error)

type IntegrationIn

type IntegrationIn = openapi.IntegrationIn

type IntegrationKeyOut

type IntegrationKeyOut = openapi.IntegrationKeyOut

type IntegrationListOptions

type IntegrationListOptions struct {
	Iterator *string
	Limit    *int32
}

type IntegrationOut

type IntegrationOut = openapi.IntegrationOut

type IntegrationUpdate

type IntegrationUpdate = openapi.IntegrationUpdate

type ListResponseApplicationOut

type ListResponseApplicationOut = openapi.ListResponseApplicationOut

type ListResponseBackgroundTaskOut added in v1.4.12

type ListResponseBackgroundTaskOut = openapi.ListResponseBackgroundTaskOut

type ListResponseEndpointMessageOut

type ListResponseEndpointMessageOut = openapi.ListResponseEndpointMessageOut

type ListResponseEndpointOut

type ListResponseEndpointOut = openapi.ListResponseEndpointOut

type ListResponseEventTypeOut

type ListResponseEventTypeOut = openapi.ListResponseEventTypeOut

type ListResponseIntegrationOut

type ListResponseIntegrationOut = openapi.ListResponseIntegrationOut

type ListResponseMessageAttemptOut

type ListResponseMessageAttemptOut = openapi.ListResponseMessageAttemptOut

type ListResponseMessageEndpointOut

type ListResponseMessageEndpointOut = openapi.ListResponseMessageEndpointOut

type ListResponseMessageOut

type ListResponseMessageOut = openapi.ListResponseMessageOut

type Message

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

func (*Message) Create

func (m *Message) Create(ctx context.Context, appId string, messageIn *MessageIn) (*MessageOut, error)

func (*Message) CreateWithOptions added in v0.51.0

func (m *Message) CreateWithOptions(ctx context.Context, appId string, messageIn *MessageIn, options *PostOptions) (*MessageOut, error)

func (*Message) ExpungeContent added in v0.76.0

func (m *Message) ExpungeContent(ctx context.Context, appId string, msgId string) error

func (*Message) Get

func (m *Message) Get(ctx context.Context, appId string, msgId string) (*MessageOut, error)

func (*Message) List

func (m *Message) List(ctx context.Context, appId string, options *MessageListOptions) (*ListResponseMessageOut, error)

type MessageAttempt

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

func (*MessageAttempt) ExpungeContent added in v0.76.0

func (m *MessageAttempt) ExpungeContent(ctx context.Context, appId string, msgId string, attemptId string) error

func (*MessageAttempt) Get

func (m *MessageAttempt) Get(ctx context.Context, appId string, msgId string, attemptID string) (*MessageAttemptOut, error)

func (*MessageAttempt) List deprecated

Deprecated: use `ListByMsg` or `ListByEndpoint` instead

func (*MessageAttempt) ListAttemptedDestinations

func (m *MessageAttempt) ListAttemptedDestinations(ctx context.Context, appId string, msgId string, options *MessageAttemptListOptions) (*ListResponseMessageEndpointOut, error)

func (*MessageAttempt) ListAttemptedMessages

func (m *MessageAttempt) ListAttemptedMessages(ctx context.Context, appId string, endpointId string, options *MessageAttemptListOptions) (*ListResponseEndpointMessageOut, error)

func (*MessageAttempt) ListAttemptsForEndpoint

func (m *MessageAttempt) ListAttemptsForEndpoint(ctx context.Context, appId string, msgId string, endpointId string, options *MessageAttemptListOptions) (*ListResponseMessageAttemptEndpointOut, error)

func (*MessageAttempt) ListByEndpoint added in v0.48.0

func (m *MessageAttempt) ListByEndpoint(ctx context.Context, appId string, endpointId string, options *MessageAttemptListOptions) (*ListResponseMessageAttemptOut, error)

func (*MessageAttempt) ListByMsg added in v0.48.0

func (*MessageAttempt) Resend

func (m *MessageAttempt) Resend(ctx context.Context, appId string, msgId string, endpointId string) error

func (*MessageAttempt) ResendWithOptions added in v0.51.0

func (m *MessageAttempt) ResendWithOptions(ctx context.Context, appId string, msgId string, endpointId string, options *PostOptions) error

type MessageAttemptEndpointOut added in v0.83.0

type MessageAttemptEndpointOut = openapi.MessageAttemptEndpointOut

type MessageAttemptListOptions

type MessageAttemptListOptions struct {
	Iterator        *string
	Limit           *int32
	Status          *MessageStatus
	EventTypes      *[]string
	Before          *time.Time
	After           *time.Time
	StatusCodeClass *StatusCodeClass
	Channel         *string
	EndpointId      *string
	WithContent     *bool
}

type MessageAttemptOut

type MessageAttemptOut = openapi.MessageAttemptOut

type MessageEndpointOut added in v0.83.0

type MessageEndpointOut = openapi.MessageEndpointOut

type MessageIn

type MessageIn = openapi.MessageIn

type MessageListOptions

type MessageListOptions struct {
	Iterator   *string
	Limit      *int32
	EventTypes *[]string
	Before     *time.Time
	After      *time.Time
	Channel    *string
	Tag        *string
}

type MessageOut

type MessageOut = openapi.MessageOut

type MessageStatus

type MessageStatus = openapi.MessageStatus

type Ordering added in v0.78.0

type Ordering = openapi.Ordering

type PostOptions added in v0.51.0

type PostOptions struct {
	IdempotencyKey *string
}

type RecoverIn

type RecoverIn = openapi.RecoverIn

type ReplayIn added in v0.76.0

type ReplayIn = openapi.ReplayIn

type Statistics added in v1.14.0

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

func (*Statistics) AggregateAppStats added in v1.14.0

func (s *Statistics) AggregateAppStats(ctx context.Context, appUsageStatsIn *AppUsageStatsIn, options *PostOptions) (*AppUsageStatsOut, error)

func (*Statistics) AggregateEventTypes added in v1.14.0

func (s *Statistics) AggregateEventTypes(ctx context.Context) (*AggregateEventTypesOut, error)

type StatusCodeClass added in v0.50.0

type StatusCodeClass = openapi.StatusCodeClass

type Svix

type Svix struct {
	Authentication *Authentication
	Application    *Application
	Endpoint       *Endpoint
	EventType      *EventType
	Integration    *Integration
	Message        *Message
	MessageAttempt *MessageAttempt
	Statistics     *Statistics
}

func New

func New(token string, options *SvixOptions) *Svix

type SvixOptions

type SvixOptions struct {
	Debug bool

	// Overrides the base URL (protocol + hostname) used for all requests sent by this Svix client. (Useful for testing)
	ServerUrl  *url.URL
	HTTPClient *http.Client
}

type Webhook

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

func NewWebhook

func NewWebhook(secret string) (*Webhook, error)

func NewWebhookRaw added in v0.63.0

func NewWebhookRaw(secret []byte) (*Webhook, error)

func (*Webhook) Sign

func (wh *Webhook) Sign(msgId string, timestamp time.Time, payload []byte) (string, error)

func (*Webhook) Verify

func (wh *Webhook) Verify(payload []byte, headers http.Header) error

Verify validates the payload against the svix signature headers using the webhooks signing secret.

Returns an error if the body or headers are missing/unreadable or if the signature doesn't match.

func (*Webhook) VerifyIgnoringTimestamp

func (wh *Webhook) VerifyIgnoringTimestamp(payload []byte, headers http.Header) error

VerifyIgnoringTimestamp validates the payload against the svix signature headers using the webhooks signing secret.

Returns an error if the body or headers are missing/unreadable or if the signature doesn't match.

WARNING: This function does not check the signature's timestamp. We recommend using the `Verify` function instead.

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

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