svix

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2023 License: MIT Imports: 12 Imported by: 0

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 NullableString

func NullableString(s string) *openapi.NullableString

func String

func String(s string) *string

Types

type AppPortalAccessIn

type AppPortalAccessIn openapi.AppPortalAccessIn

type AppPortalAccessOut

type AppPortalAccessOut openapi.AppPortalAccessOut

type Application

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

func (*Application) Create

func (a *Application) Create(applicationIn *ApplicationIn) (*ApplicationOut, error)

func (*Application) CreateWithOptions

func (a *Application) CreateWithOptions(applicationIn *ApplicationIn, options *PostOptions) (*ApplicationOut, error)

func (*Application) Delete

func (a *Application) Delete(appId string) error

func (*Application) Get

func (a *Application) Get(appId string) (*ApplicationOut, error)

func (*Application) GetOrCreate

func (a *Application) GetOrCreate(applicationIn *ApplicationIn) (*ApplicationOut, error)

func (*Application) GetOrCreateWithOptions

func (a *Application) GetOrCreateWithOptions(applicationIn *ApplicationIn, options *PostOptions) (*ApplicationOut, error)

func (*Application) List

func (*Application) Update

func (a *Application) Update(appId string, applicationIn *ApplicationIn) (*ApplicationOut, error)

type ApplicationIn

type ApplicationIn openapi.ApplicationIn

type ApplicationListOptions

type ApplicationListOptions struct {
	Iterator *string
	Limit    *int32
}

type ApplicationOut

type ApplicationOut openapi.ApplicationOut

type Authentication

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

func (*Authentication) AppPortalAccess

func (a *Authentication) AppPortalAccess(appId string, appPortalAccessIn *AppPortalAccessIn) (*AppPortalAccessOut, error)

func (*Authentication) AppPortalAccessWithOptions

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

func (*Authentication) DashboardAccess

func (a *Authentication) DashboardAccess(appId string) (*DashboardAccessOut, error)

func (*Authentication) DashboardAccessWithOptions

func (a *Authentication) DashboardAccessWithOptions(appId string, options *PostOptions) (*DashboardAccessOut, error)

func (*Authentication) Logout

func (a *Authentication) Logout() error

func (*Authentication) LogoutWithOptions

func (a *Authentication) LogoutWithOptions(options *PostOptions) error

type DashboardAccessOut

type DashboardAccessOut openapi.DashboardAccessOut

type Endpoint

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

func (*Endpoint) Create

func (e *Endpoint) Create(appId string, endpointIn *EndpointIn) (*EndpointOut, error)

func (*Endpoint) CreateWithOptions

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

func (*Endpoint) Delete

func (e *Endpoint) Delete(appId string, endpointId string) error

func (*Endpoint) Get

func (e *Endpoint) Get(appId string, endpointId string) (*EndpointOut, error)

func (*Endpoint) GetHeaders

func (e *Endpoint) GetHeaders(appId string, endpointId string) (*EndpointHeadersOut, error)

func (*Endpoint) GetSecret

func (e *Endpoint) GetSecret(appId string, endpointId string) (*EndpointSecretOut, error)

func (*Endpoint) GetStats

func (e *Endpoint) GetStats(appId string, endpointId string) (*EndpointStats, error)

func (*Endpoint) List

func (e *Endpoint) List(appId string, options *EndpointListOptions) (*ListResponseEndpointOut, error)

func (*Endpoint) PatchHeaders

func (e *Endpoint) PatchHeaders(appId string, endpointId string, endpointHeadersIn *EndpointHeadersPatchIn) error

func (*Endpoint) Recover

func (e *Endpoint) Recover(appId string, endpointId string, recoverIn *RecoverIn) error

func (*Endpoint) RecoverWithOptions

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

func (*Endpoint) ReplayMissing

func (e *Endpoint) ReplayMissing(appId string, endpointId string, replayIn *ReplayIn) error

func (*Endpoint) ReplayMissingWithOptions

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

func (*Endpoint) RotateSecret

func (e *Endpoint) RotateSecret(appId string, endpointId string, endpointSecretRotateIn *EndpointSecretRotateIn) error

func (*Endpoint) RotateSecretWithOptions

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

func (*Endpoint) TransformatioPartialUpdate

func (e *Endpoint) TransformatioPartialUpdate(appId string, endpointId string, transformation *EndpointTransformationIn) error

func (*Endpoint) TransformationGet

func (e *Endpoint) TransformationGet(appId string, endpointId string) (*EndpointTransformationOut, error)

func (*Endpoint) Update

func (e *Endpoint) Update(appId string, endpointId string, endpointUpdate *EndpointUpdate) (*EndpointOut, error)

func (*Endpoint) UpdateHeaders

func (e *Endpoint) UpdateHeaders(appId string, endpointId string, endpointHeadersIn *EndpointHeadersIn) error

type EndpointHeadersIn

type EndpointHeadersIn openapi.EndpointHeadersIn

type EndpointHeadersOut

type EndpointHeadersOut openapi.EndpointHeadersOut

type EndpointHeadersPatchIn

type EndpointHeadersPatchIn openapi.EndpointHeadersPatchIn

type EndpointIn

type EndpointIn openapi.EndpointIn

type EndpointListOptions

type EndpointListOptions struct {
	Iterator *string
	Limit    *int32
}

type EndpointOut

type EndpointOut openapi.EndpointOut

type EndpointSecretOut

type EndpointSecretOut openapi.EndpointSecretOut

type EndpointSecretRotateIn

type EndpointSecretRotateIn openapi.EndpointSecretRotateIn

type EndpointStats

type EndpointStats openapi.EndpointStats

type EndpointTransformationIn

type EndpointTransformationIn openapi.EndpointTransformationIn

type EndpointTransformationOut

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 EventType

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

func (*EventType) Create

func (e *EventType) Create(eventTypeIn *EventTypeIn) (*EventTypeOut, error)

func (*EventType) CreateWithOptions

func (e *EventType) CreateWithOptions(eventTypeIn *EventTypeIn, options *PostOptions) (*EventTypeOut, error)

func (*EventType) Delete

func (e *EventType) Delete(eventTypeName string) error

func (*EventType) Get

func (e *EventType) Get(eventTypeName string) (*EventTypeOut, error)

func (*EventType) List

func (*EventType) Update

func (e *EventType) Update(eventTypeName string, eventTypeUpdate *EventTypeUpdate) (*EventTypeOut, error)

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 EventTypeUpdate

type EventTypeUpdate openapi.EventTypeUpdate

type Integration

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

func (*Integration) Create

func (e *Integration) Create(appId string, endpointIn *IntegrationIn) (*IntegrationOut, error)

func (*Integration) CreateWithOptions

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

func (*Integration) Delete

func (e *Integration) Delete(appId string, integId string) error

func (*Integration) Get

func (e *Integration) Get(appId string, integId string) (*IntegrationOut, error)

func (*Integration) GetKey

func (e *Integration) GetKey(appId string, integId string) (*IntegrationKeyOut, error)

func (*Integration) List

func (*Integration) RotateKey

func (e *Integration) RotateKey(appId string, integId string) (*IntegrationKeyOut, error)

func (*Integration) RotateKeyWithOptions

func (e *Integration) RotateKeyWithOptions(appId string, integId string, options *PostOptions) (*IntegrationKeyOut, error)

func (*Integration) Update

func (e *Integration) Update(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 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(appId string, messageIn *MessageIn) (*MessageOut, error)

func (*Message) CreateWithOptions

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

func (*Message) ExpungeContent

func (m *Message) ExpungeContent(appId string, msgId string) error

func (*Message) Get

func (m *Message) Get(appId string, msgId string) (*MessageOut, error)

func (*Message) List

func (m *Message) List(appId string, options *MessageListOptions) (*ListResponseMessageOut, error)

type MessageAttempt

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

func (*MessageAttempt) ExpungeContent

func (m *MessageAttempt) ExpungeContent(appId string, msgId string, attemptId string) error

func (*MessageAttempt) Get

func (m *MessageAttempt) Get(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(appId string, msgId string, options *MessageAttemptListOptions) (*ListResponseMessageEndpointOut, error)

func (*MessageAttempt) ListAttemptedMessages

func (m *MessageAttempt) ListAttemptedMessages(appId string, endpointId string, options *MessageAttemptListOptions) (*ListResponseEndpointMessageOut, error)

func (*MessageAttempt) ListAttemptsForEndpoint

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

func (*MessageAttempt) ListByEndpoint

func (m *MessageAttempt) ListByEndpoint(appId string, endpointId string, options *MessageAttemptListOptions) (*ListResponseMessageAttemptOut, error)

func (*MessageAttempt) ListByMsg

func (*MessageAttempt) Resend

func (m *MessageAttempt) Resend(appId string, msgId string, endpointId string) error

func (*MessageAttempt) ResendWithOptions

func (m *MessageAttempt) ResendWithOptions(appId string, msgId string, endpointId string, options *PostOptions) error

type MessageAttemptListOptions

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

type MessageAttemptOut

type MessageAttemptOut openapi.MessageAttemptOut

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
}

type MessageOut

type MessageOut openapi.MessageOut

type MessageStatus

type MessageStatus openapi.MessageStatus

type PostOptions

type PostOptions struct {
	IdempotencyKey *string
}

type RecoverIn

type RecoverIn openapi.RecoverIn

type ReplayIn

type ReplayIn openapi.ReplayIn

type StatusCodeClass

type StatusCodeClass openapi.StatusCodeClass

type Svix

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

func New

func New(host, 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

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