convoy_go

package module
v2.1.14 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2024 License: MIT Imports: 24 Imported by: 1

README

convoy-go
Go Reference

This is the Golang SDK for Convoy. It makes it easy to interact with the Convoy API. You can view the full API Reference here

Installation

$ go get github.com/frain-dev/convoy-go/v2

Usage

To begin you need to define a Client.

Configure your Client

Below are the several ways you can configure a client depending on your needs.

baseURL := "{host}/api/v1"

// Regular Client
c := convoy.New(baseURL, apiKey, projectID)

// Add a Custom HTTP Client
client := &http.Client{}
c := convoy.New(baseURL, apiKey, projectID,
    convoy.OptionHTTPClient(client))

// Add a SQS Client 
so := &convoy.SQSOptions{
    Client: sqs.New(),
    QueueUrl: "queue-url",
}
c := convoy.New(baseURL, apiKey, projectID,
    convoy.OptionSQSOptions(so))

// Add a Kafka Client 
ko := &convoy.KafkaOptions{
    Client: &kafka.Client{},
    Topic: "kafka-topic",
}
c := convoy.New(baseURL, apiKey, projectID,
    convoy.OptionKafkaOptions(ko))

Please see go reference for other options available to use to configure your client.

Creating Endpoints
body := &convoy.CreateEndpointRequest{
    Name: "endpoint-name",
    URL: "https://play.getconvoy.io/ingest/DQzxCcNKTB7SGqzm",
    Secret: "endpoint-secret",
    SupportEmail: "[email protected]"
}

endpoint, err := c.Endpoints.Create(ctx, body, nil)
if err != nil {
    return err
}

Store the Endpoint ID, so you can use it in subsequent requests for creating subscriptions or sending events.

Creating Subscriptions
body := &convoy.CreateSubscriptionRequest{
    Name: "endpoint-subscription",
    EndpointID: "endpoint-id",
    FilterConfig: &convoy.FilterConfiguration{
        EventTypes: []string{"*"},
    },
}

subscription, err := c.Subscriptions.Create(ctx, body)
if err != nil {
    return err 
}
Sending Events

You can send events to Convoy via HTTP or via any supported message broker. See here to see the list of supported brokers.

HTTP
// Send an event to a single endpoint.
body := &CreateEventRequest{
    EventType: "event.type",
    EndpointID: "endpoint-id",
    IdempotencyKey: "unique-event-id",
    Data: []byte(`{"version": "Convoy v24.0.0"}`),
}

event, err := c.Events.Create(ctx, body)
if err != nil {
    return err 
}

// Send event to multiple endpoints.
body := &CreateFanoutEventRequest{
    EventType: "event.type",
    OwnerID: "unique-user-id",
    IdempotencyKey: "unique-event-id",
    Data: []byte(`{"version": "Convoy v24.0.0"}`),
}

event, err := c.Events.FanoutEvent(ctx, body)
if err != nil {
    return err 
}

Note: The body struct used above is the same used for the message brokers below.

SQS
// Send event to a single endpoint.
err := c.SQS.WriteEvent(ctx, body)
if err != nil {
    return err 
}

// Send event to multiple endpoints.
err := c.SQS.WriteFanoutEvent(ctx, body)
if err != nil {
    return err 
}
Kafka

This library depends on kafka-go to configure Kafka Clients.

// Send event to a single endpoint.
err := c.Kafka.WriteEvent(ctx, body)
if err != nil {
    return err 
}


// Send event to multiple endpoints.
err := c.Kafka.WriteFanoutEvent(ctx, body) 
if err != nil {
    return err 
}
Verifying Webhooks

This client supports verifying simple and advanced webhook signatures.

webhook := NewWebhook(&convoy.ConfigOpts{
    SigHeader: "ZmBgy+E0i7x+yY9Ok92P3CZQkc+FEJgR5gYZ0bwSEhwLESnc/gGct57IQ==",
    Payload:   []byte(`{"firstname":"test","lastname":"test"}`),
    Secret:    "8IX9njirDG",
    Hash:      "SHA512",
    Encoding:  "base64",
})

err := webhook.Verify()
if err != nil {
    return err 
}
Version Compatibility Table

The following table identifies which version of the Convoy API is supported by this (and past) versions of this repo (convoy-go)

convoy-go Version Convoy API Version
v2.1.5 0001-01-01
v2.1.6 0001-01-01
v2.1.7 0001-01-01

Credits

License

The MIT License (MIT). Please see License File for more information.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotListDeliveryAttemptResponse = errors.New("invalid list delivery attempt response")
	ErrNotDeliveryAttemptResponse     = errors.New("invalid delivery attempt response")
)
View Source
var (
	ErrNotListEndpointResponse = errors.New("invalid list endpoint response")
	ErrNotEndpointResponse     = errors.New("invalid endpoint response")
)
View Source
var (
	ErrNotListEventResponse = errors.New("invalid list event response")
	ErrNotEventResponse     = errors.New("invalid event response")
)
View Source
var (
	ErrNotListEventDeliveryResponse = errors.New("invalid list event delivery response")
	ErrNotEventDeliveryResponse     = errors.New("invalid event delivery response")
)
View Source
var (
	ErrNotListProjectResponse = errors.New("invalid list project response")
	ErrNotProjectResponse     = errors.New("invalid project response")
)
View Source
var (
	ErrNotListSourceResponse = errors.New("invalid list source response")
	ErrNotSourceResponse     = errors.New("invalid source response")
)
View Source
var (
	ErrNotListSubscriptionResponse = errors.New("invalid list subscription response")
	ErrNotSubscriptionResponse     = errors.New("invalid subscription response")
)
View Source
var (
	ErrInvalidSignatureHeader = errors.New("webhook has no signature header")
	ErrInvalidHeader          = errors.New("webhook has invalid header")
	ErrInvalidEncoding        = errors.New("invalid encoding")
	ErrInvalidSignature       = errors.New("webhook has no valid signature")
	ErrInvalidHashAlgorithm   = errors.New("invalid hash algorithm")
	ErrTimestampExpired       = errors.New("timestamp has expired")
)
View Source
var (
	DefaultTolerance              = 300 * time.Second
	DefaultEncoding  EncodingType = HexEncoding
	DefaultHash                   = "SHA256"
	DefaultSigHeader              = "X-Convoy-Signature"
)

Functions

func NewLogger

func NewLogger(out io.Writer, lvl Level) *log.Logger

func OptionHTTPClient

func OptionHTTPClient(client *http.Client) func(c *Client)

func OptionKafkaOptions

func OptionKafkaOptions(ko *KafkaOptions) func(c *Client)

func OptionLogger

func OptionLogger(logger iLogger) func(c *Client)

func OptionSQSOptions

func OptionSQSOptions(so *SQSOptions) func(c *Client)

Types

type APIResponse

type APIResponse struct {
	Status  bool             `json:"status"`
	Message string           `json:"message"`
	Data    *json.RawMessage `json:"data,omitempty"`
}

type AlertConfiguration

type AlertConfiguration struct {
	Count     int    `json:"count"`
	Threshold string `json:"threshold"`
}

type ApiKey

type ApiKey struct {
	HeaderValue string `json:"header_value"`
	HeaderName  string `json:"header_name"`
}

type ApiKeyAuth

type ApiKeyAuth struct {
	HeaderValue string `json:"header_value"`
	HeaderName  string `json:"header_name"`
}

type BasicAuth

type BasicAuth struct {
	UserName string `json:"username"`
	Password string `json:"password"`
}

type BatchReplayOptions

type BatchReplayOptions struct {
	SourceID  string    `url:"sourceId"`
	StartDate time.Time `url:"startDate" layout:"2006-01-02T15:04:05"`
	EndDate   time.Time `url:"endDate" layout:"2006-01-02T15:04:05"`
}

type Client

type Client struct {
	Projects         *Project
	Endpoints        *Endpoint
	Events           *Event
	EventDeliveries  *EventDelivery
	DeliveryAttempts *DeliveryAttempt
	Sources          *Source
	Subscriptions    *Subscription
	PortalLinks      *PortalLink
	Kafka            *Kafka
	SQS              *SQS
	// contains filtered or unexported fields
}

func New

func New(baseURL, apiKey, projectID string, options ...Option) *Client

type CreateBroadcastEventRequest added in v2.1.10

type CreateBroadcastEventRequest struct {
	EventType      string            `json:"event_type"`
	CustomHeaders  map[string]string `json:"custom_headers"`
	IdempotencyKey string            `json:"idempotency_key"`
	Data           json.RawMessage   `json:"data"`
}

type CreateDynamicEventRequest

type CreateDynamicEventRequest struct {
	Endpoint     string `json:"endpoint"`
	Subscription string `json:"subscription"`
	Event        string `json:"event"`
}

type CreateEndpointRequest

type CreateEndpointRequest struct {
	Name               string `json:"name"`
	SupportEmail       string `json:"support_email"`
	OwnerID            string `json:"owner_id"`
	SlackWebhookUrl    string `json:"slack_webhook_url"`
	URL                string `json:"url"`
	Secret             string `json:"secret,omitempty"`
	Description        string `json:"description,omitempty"`
	AdvancedSignatures *bool  `json:"advanced_signatures"`
	IsDisabled         bool   `json:"is_disabled"`

	Authentication *EndpointAuth `json:"authentication"`

	HttpTimeout       string `json:"http_timeout,omitempty"`
	RateLimit         int    `json:"rate_limit,omitempty"`
	RateLimitDuration string `json:"rate_limit_duration,omitempty"`
}

type CreateEventRequest

type CreateEventRequest struct {
	EndpointID     string            `json:"endpoint_id"`
	EventType      string            `json:"event_type"`
	IdempotencyKey string            `json:"idempotency_key"`
	CustomHeaders  map[string]string `json:"custom_headers"`
	Data           json.RawMessage   `json:"data"`
}

type CreateFanoutEventRequest

type CreateFanoutEventRequest struct {
	OwnerID        string            `json:"owner_id"`
	EventType      string            `json:"event_type"`
	IdempotencyKey string            `json:"idempotency_key"`
	CustomHeaders  map[string]string `json:"custom_headers"`
	Data           json.RawMessage   `json:"data"`
}

type CreatePortalLinkRequest

type CreatePortalLinkRequest struct {
	Name              string   `json:"name"`
	Endpoints         []string `json:"endpoints"`
	OwnerID           string   `json:"owner_id"`
	CanManageEndpoint bool     `json:"can_manage_endpoint"`
}

type CreateProjectRequest

type CreateProjectRequest struct {
	Name              string         `json:"name"`
	Type              string         `json:"type"`
	LogoUrl           string         `json:"logo_url,omitempty"`
	RateLimit         int            `json:"rate_limit,omitempty"`
	RateLimitDuration string         `json:"rate_limit_duration,omitempty"`
	Project           *ProjectConfig `json:"config"`
}

type CreateSourceRequest

type CreateSourceRequest struct {
	Name       string         `json:"name"`
	Type       string         `json:"type"`
	Provider   string         `json:"provider"`
	IsDisabled bool           `json:"is_disabled"`
	Verifier   VerifierConfig `json:"verifier"`
}

type CreateSubscriptionRequest

type CreateSubscriptionRequest struct {
	Name       string `json:"name"`
	SourceID   string `json:"source_id"`
	EndpointID string `json:"endpoint_id"`

	AlertConfig  *AlertConfiguration  `json:"alert_config"`
	RetryConfig  *RetryConfiguration  `json:"retry_config"`
	FilterConfig *FilterConfiguration `json:"filter_config"`
}

type DeliveryAttempt

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

func (*DeliveryAttempt) All

func (*DeliveryAttempt) Find

func (d *DeliveryAttempt) Find(ctx context.Context, eventDeliveryID, deliveryAttemptID string, query *DeliveryAttemptQueryParam) (*DeliveryAttemptResponse, error)

type DeliveryAttemptQueryParam

type DeliveryAttemptQueryParam struct {
	GroupID string `url:"groupId"`
}

type DeliveryAttemptResponse

type DeliveryAttemptResponse struct {
	UID        string `json:"uid"`
	MsgID      string `json:"msg_id"`
	URL        string `json:"url"`
	Method     string `json:"method"`
	EndpointID string `json:"endpoint_id"`
	APIVersion string `json:"api_version"`

	IPAddress        string            `json:"ip_address,omitempty"`
	RequestHeader    map[string]string `json:"request_http_header,omitempty"`
	ResponseHeader   map[string]string `json:"response_http_header,omitempty"`
	HttpResponseCode string            `json:"http_status,omitempty"`
	ResponseData     string            `json:"response_data,omitempty"`
	Error            string            `json:"error,omitempty"`
	Status           bool              `json:"status,omitempty"`

	CreatedAt time.Time `json:"created_at,omitempty"`
	UpdatedAt time.Time `json:"updated_at,omitempty"`
	DeletedAt time.Time `json:"deleted_at,omitempty"`
}

type EncodingType

type EncodingType string
const (
	Base64Encoding EncodingType = "base64"
	HexEncoding    EncodingType = "hex"
)

type Endpoint

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

func (*Endpoint) All

func (*Endpoint) Create

func (*Endpoint) Delete

func (e *Endpoint) Delete(ctx context.Context, endpointID string, query *EndpointParams) error

func (*Endpoint) Find

func (e *Endpoint) Find(ctx context.Context, endpointID string, query *EndpointParams) (*EndpointResponse, error)

func (*Endpoint) Pause

func (e *Endpoint) Pause(ctx context.Context, Id string) (*EndpointResponse, error)

func (Endpoint) RollSecret

func (e Endpoint) RollSecret(ctx context.Context, Id string, body *RollSecretRequest) error

func (*Endpoint) Update

func (e *Endpoint) Update(ctx context.Context, endpointID string, body *CreateEndpointRequest, query *EndpointParams) (*EndpointResponse, error)

type EndpointAuth

type EndpointAuth struct {
	Type   string      `json:"type"`
	ApiKey *ApiKeyAuth `json:"api_key"`
}

type EndpointParams

type EndpointParams struct {
	ListParams
	Query   string `url:"query"`
	OwnerID string `url:"ownerId"`
}

type EndpointResponse

type EndpointResponse struct {
	UID         string `json:"uid"`
	GroupID     string `json:"group_id"`
	OwnerID     string `json:"owner_id"`
	TargetUrl   string `json:"target_url"`
	Title       string `json:"title"`
	Description string `json:"description"`

	Status             string   `json:"status"`
	Secrets            []Secret `json:"secrets"`
	AdvancedSignatures bool     `json:"advanced_signatures"`
	SlackWebhookUrl    string   `json:"slack_webhook_url"`
	SupportEmail       string   `json:"support_email"`
	IsDisabled         bool     `json:"is_disabled"`

	HttpTimeout       string `json:"http_timeout"`
	RateLimit         int    `json:"rate_limit"`
	RateLimitDuration string `json:"rate_limit_duration"`

	Authentication *EndpointAuth `json:"authentication"`
	Events         int64         `json:"events"`

	CreatedAt time.Time `json:"created_at"`
	UpdatedAt time.Time `json:"updated_at"`
}

type Event

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

func (*Event) All

func (e *Event) All(ctx context.Context, query *EventParams) (*ListEventResponse, error)

func (*Event) BatchReplay

func (e *Event) BatchReplay(ctx context.Context, query *BatchReplayOptions) error

func (*Event) BroadcastEvent added in v2.1.10

func (e *Event) BroadcastEvent(ctx context.Context, body *CreateBroadcastEventRequest) error

func (*Event) Create

func (e *Event) Create(ctx context.Context, body *CreateEventRequest) error

func (*Event) FanoutEvent

func (e *Event) FanoutEvent(ctx context.Context, body *CreateFanoutEventRequest) error

func (*Event) Find

func (e *Event) Find(ctx context.Context, eventID string) (*EventResponse, error)

func (*Event) Replay

func (e *Event) Replay(ctx context.Context, eventID string) error

type EventDelivery

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

func (*EventDelivery) All

func (*EventDelivery) BatchResend

func (e *EventDelivery) BatchResend(ctx context.Context, query *EventDeliveryParams) error

func (*EventDelivery) Find

func (e *EventDelivery) Find(ctx context.Context, eventDeliveryID string, query *EventDeliveryParams) (*EventDeliveryResponse, error)

func (*EventDelivery) Resend

func (e *EventDelivery) Resend(ctx context.Context, eventDeliveryID string, query *EventDeliveryParams) (*EventDeliveryResponse, error)

type EventDeliveryParams

type EventDeliveryParams struct {
	ListParams
	EventType      string    `url:"eventType"`
	EventID        string    `url:"eventId"`
	Status         []string  `url:"status"`
	EndpointID     []string  `url:"endpointId"`
	SubscriptionID string    `url:"subscriptionId"`
	StartDate      time.Time `url:"startDate" layout:"2006-01-02T15:04:05"`
	EndDate        time.Time `url:"endDate" layout:"2006-01-02T15:04:05"`
}

type EventDeliveryResponse

type EventDeliveryResponse struct {
	UID           string        `json:"uid"`
	EventMetadata EventMetadata `json:"event_metadata"`
	Metadata      Metadata      `json:"metadata"`
	Description   string        `json:"description,omitempty"`
	Status        string        `json:"status"`

	CreatedAt time.Time `json:"created_at"`
	UpdatedAt time.Time `json:"updated_at"`
}

type EventMetadata

type EventMetadata struct {
	UID  string `json:"uid"`
	Name string `json:"name"`
}

type EventParams

type EventParams struct {
	ListParams
	Query          string    `url:"query"`
	IdempotencyKey string    `url:"idempotencyKey"`
	SourceID       string    `url:"sourceId"`
	EndpointID     []string  `url:"endpointId"`
	StartDate      time.Time `url:"startDate" layout:"2006-01-02T15:04:05"`
	EndDate        time.Time `url:"endDate" layout:"2006-01-02T15:04:05"`
}

type EventResponse

type EventResponse struct {
	UID              string          `json:"uid"`
	EventType        string          `json:"event_type"`
	MatchedEndpoints int             `json:"matched_endpoints"`
	ProviderID       string          `json:"provider_id"`
	Data             json.RawMessage `json:"data"`

	CreatedAt time.Time `json:"created_at"`
	UpdatedAt time.Time `json:"updated_at"`
}

type Filter added in v2.1.8

type Filter struct {
	Body    map[string]interface{} `json:"body"`
	Headers map[string]interface{} `json:"headers"`
}

type FilterConfiguration

type FilterConfiguration struct {
	EventTypes []string `json:"event_types" bson:"event_types,omitempty"`
	Filter     Filter   `json:"filter" bson:"filter,omitempty"`
}

type HMac

type HMac struct {
	Header   string `json:"header"`
	Hash     string `json:"hash"`
	Secret   string `json:"secret"`
	Encoding string `json:"encoding"`
}

type Kafka

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

func (*Kafka) WriteBroadcastEvent added in v2.1.14

func (k *Kafka) WriteBroadcastEvent(ctx context.Context, body *CreateBroadcastEventRequest) error

func (*Kafka) WriteEvent

func (k *Kafka) WriteEvent(ctx context.Context, body *CreateEventRequest) error

func (*Kafka) WriteFanoutEvent

func (k *Kafka) WriteFanoutEvent(ctx context.Context, body *CreateFanoutEventRequest) error

type KafkaOptions

type KafkaOptions struct {
	Client *kafka.Client
	Topic  string
}

type Level

type Level int32

Level represents a log level.

const (
	// FatalLevel is used for undesired and unexpected events that
	// the program cannot recover from.
	FatalLevel Level = iota

	// ErrorLevel is used for undesired and unexpected events that
	// the program can recover from.
	ErrorLevel

	// WarnLevel is used for undesired but relatively expected events,
	// which may indicate a problem.
	WarnLevel

	// InfoLevel is used for general informational log messages.
	InfoLevel

	// DebugLevel is the lowest level of logging.
	// Debug logs are intended for debugging and development purposes.
	DebugLevel
)

type ListDeliveryAttemptResponse

type ListDeliveryAttemptResponse []DeliveryAttemptResponse

type ListEndpointResponse

type ListEndpointResponse struct {
	Content    []EndpointResponse `json:"content"`
	Pagination Pagination         `json:"pagination"`
}

type ListEventDeliveryResponse

type ListEventDeliveryResponse struct {
	Content    []EventDeliveryResponse `json:"content"`
	Pagination Pagination              `json:"pagination"`
}

type ListEventResponse

type ListEventResponse struct {
	Content    []EventResponse `json:"content"`
	Pagination Pagination      `json:"pagination"`
}

type ListParams

type ListParams struct {
	PerPage        int    `url:"perPage,omitempty"`
	PrevPageCursor string `url:"prev_page_cursor"`
	NextPageCursor string `url:"next_page_cursor"`
}

ListParams is used in requests for filtering lists

type ListPortalLinkResponse

type ListPortalLinkResponse struct {
	Content    []PortalLinkResponse `json:"content"`
	Pagination Pagination           `json:"pagination"`
}

type ListProjectResponse

type ListProjectResponse []ProjectResponse

type ListSourceResponse

type ListSourceResponse struct {
	Content    []SourceResponse `json:"content"`
	Pagination Pagination       `json:"pagination"`
}

type ListSubscriptionResponse

type ListSubscriptionResponse struct {
	Content    []SubscriptionResponse `json:"content"`
	Pagination Pagination             `json:"pagination"`
}

type Metadata

type Metadata struct {
	// Data to be sent to endpoint.
	Data     json.RawMessage `json:"data"`
	Strategy string          `json:"strategy"`
	// NextSendTime denotes the next time a Event will be published in
	// case it failed the first time
	NextSendTime time.Time `json:"next_send_time"`

	// NumTrials: number of times we have tried to deliver this Event to
	// an application
	NumTrials uint64 `json:"num_trials"`

	IntervalSeconds uint64 `json:"interval_seconds"`

	RetryLimit uint64 `json:"retry_limit"`
}

type Option

type Option func(*Client)

type Pagination

type Pagination struct {
	PerPage        int    `json:"per_page"`
	HasNextPage    bool   `json:"has_next_page"`
	HasPrevPage    bool   `json:"has_prev_page"`
	PrevPageCursor string `json:"prev_page_cursor"`
	NextPageCursor string `json:"next_page_cursor"`
}

Pagination type used in responses.

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

func (*PortalLink) All

func (*PortalLink) Create

func (*PortalLink) Find

func (p *PortalLink) Find(ctx context.Context, portalLinkID string) (*PortalLinkResponse, error)

func (*PortalLink) Revoke

func (p *PortalLink) Revoke(ctx context.Context, portalLinkID string) error

func (*PortalLink) Update

func (p *PortalLink) Update(ctx context.Context, portalLinkID string, body *UpdatePortalLinkRequest) (*PortalLinkResponse, error)

type PortalLinkResponse

type PortalLinkResponse struct {
	UID               string             `json:"uid"`
	Name              string             `json:"name"`
	ProjectID         string             `json:"project_id"`
	OwnerID           string             `json:"owner_id"`
	Endpoints         []string           `json:"endpoints"`
	EndpointCount     int                `json:"endpoint_count"`
	CanManageEndpoint bool               `json:"can_manage_endpoint"`
	Token             string             `json:"token"`
	EndpointsMetadata []EndpointResponse `json:"endpoints_metadata"`
	URL               string             `json:"url"`

	CreatedAt time.Time
	UpdatedAt time.Time
	DeletedAt time.Time
}

type Project

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

func (*Project) Delete

func (p *Project) Delete(ctx context.Context, projectID string) error

func (*Project) Find

func (p *Project) Find(ctx context.Context, projectID string) (*ProjectResponse, error)

func (*Project) Update

func (p *Project) Update(ctx context.Context, projectID string, body *CreateProjectRequest) (*ProjectResponse, error)

type ProjectConfig

type ProjectConfig struct {
	RateLimit                *RateLimitConfiguration       `json:"ratelimit"`
	Strategy                 *StrategyConfiguration        `json:"strategy"`
	Signature                *SignatureConfiguration       `json:"signature"`
	RetentionPolicy          *RetentionPolicyConfiguration `json:"retention_policy"`
	DisableEndpoint          bool                          `json:"disable_endpoint"`
	ReplayAttacks            bool                          `json:"replay_attacks"`
	IsRetentionPolicyEnabled bool                          `json:"is_retention_policy_enabled"`
}

type ProjectMetadata

type ProjectMetadata struct {
	RetainedEvents int `json:"retained_events"`
}

type ProjectResponse

type ProjectResponse struct {
	UID            string         `json:"uid"`
	Name           string         `json:"name"`
	LogoUrl        string         `json:"logo_url"`
	OrganisationID string         `json:"organisation_id"`
	Type           string         `json:"type"`
	Config         *ProjectConfig `json:"config"`
	Statistics     struct {
		MessageSent int `json:"messages_sent"`
		TotalApps   int `json:"total_apps"`
	} `json:"statistics"`
	RateLimit         int              `json:"rate_limit"`
	RateLimitDuration string           `json:"rate_limit_duration"`
	Metadata          *ProjectMetadata `json:"metadata"`

	CreatedAt time.Time `json:"created_at,omitempty"`
	UpdatedAt time.Time `json:"updated_at,omitempty"`
}

type ProviderConfig

type ProviderConfig struct {
	Twitter *TwitterProviderConfig `json:"twitter" bson:"twitter"`
}

type RateLimitConfiguration

type RateLimitConfiguration struct {
	Count    int    `json:"count"`
	Duration uint64 `json:"duration"`
}

type RetentionPolicyConfiguration

type RetentionPolicyConfiguration struct {
	Policy string `json:"policy"`
}

type RetryConfiguration

type RetryConfiguration struct {
	Type       string `json:"type"`
	Duration   string `json:"duration"`
	RetryCount int    `json:"retry_count"`
}

type RollSecretRequest

type RollSecretRequest struct {
	Expiration int    `json:"expiration"`
	Secret     string `json:"secret"`
}

type SQS

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

func (*SQS) WriteBroadcastEvent added in v2.1.14

func (s *SQS) WriteBroadcastEvent(ctx context.Context, body *CreateBroadcastEventRequest) error

func (*SQS) WriteEvent

func (s *SQS) WriteEvent(ctx context.Context, body *CreateEventRequest) error

func (*SQS) WriteFanoutEvent

func (s *SQS) WriteFanoutEvent(ctx context.Context, body *CreateFanoutEventRequest) error

type SQSOptions

type SQSOptions struct {
	Client   *sqs.Client
	QueueUrl string
}

type Secret

type Secret struct {
	UID   string `json:"uid" bson:"uid"`
	Value string `json:"value" bson:"value"`

	ExpiresAt time.Time `json:"expires_at,omitempty"`
}

type SignatureConfiguration

type SignatureConfiguration struct {
	Header string `json:"header"`
	Hash   string `json:"hash"`
}

type Source

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

func (*Source) All

func (s *Source) All(ctx context.Context, query *SourceParams) (*ListSourceResponse, error)

func (*Source) Create

func (s *Source) Create(ctx context.Context, body *CreateSourceRequest) (*SourceResponse, error)

func (*Source) Delete

func (s *Source) Delete(ctx context.Context, sourceId string) error

func (*Source) Find

func (s *Source) Find(ctx context.Context, sourceId string) (*SourceResponse, error)

func (*Source) Update

func (s *Source) Update(ctx context.Context, sourceId string, body *CreateSourceRequest) (*SourceResponse, error)

type SourceParams

type SourceParams struct {
	ListParams
	Type string `url:"type"`
}

type SourceResponse

type SourceResponse struct {
	UID            string          `json:"uid"`
	GroupID        string          `json:"group_id"`
	MaskID         string          `json:"mask_id"`
	Name           string          `json:"name"`
	Type           string          `json:"type"`
	Provider       string          `json:"provider"`
	IsDisabled     bool            `json:"is_disabled"`
	Verifier       *VerifierConfig `json:"verifier"`
	ProviderConfig *ProviderConfig `json:"provider_config"`
	ForwardHeaders []string        `json:"forward_headers"`

	CreatedAt time.Time `json:"created_at,omitempty"`
	UpdatedAt time.Time `json:"updated_at,omitempty"`
}

type StrategyConfiguration

type StrategyConfiguration struct {
	Type       string `json:"type"`
	Duration   uint64 `json:"duration"`
	RetryCount uint64 `json:"retry_count"`
}

type Subscription

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

func (*Subscription) All

func (*Subscription) Create

func (*Subscription) Delete

func (s *Subscription) Delete(ctx context.Context, subscriptionId string) error

func (*Subscription) Find

func (s *Subscription) Find(ctx context.Context, subscriptionId string) (*SubscriptionResponse, error)

func (*Subscription) Update

func (s *Subscription) Update(ctx context.Context, subscriptionId string, body *CreateSubscriptionRequest) (*SubscriptionResponse, error)

type SubscriptionParams

type SubscriptionParams struct {
	ListParams
	EndpointID []string `url:"endpointId"`
}

type SubscriptionResponse

type SubscriptionResponse struct {
	UID    string `json:"uid"`
	Name   string `json:"name"`
	Type   string `json:"type"`
	Status string `json:"status"`

	Source *SourceResponse `json:"source_metadata,omitempty"`

	// subscription config
	AlertConfig  *AlertConfiguration  `json:"alert_config,omitempty"`
	RetryConfig  *RetryConfiguration  `json:"retry_config,omitempty"`
	FilterConfig *FilterConfiguration `json:"filter_config,omitempty"`

	CreatedAt time.Time `json:"created_at,omitempty"`
	UpdatedAt time.Time `json:"updated_at,omitempty"`
}

type TwitterProviderConfig

type TwitterProviderConfig struct {
	CrcVerifiedAt time.Time `json:"crc_verified_at"`
}

type UpdatePortalLinkRequest

type UpdatePortalLinkRequest struct {
	Name              string   `json:"name"`
	Endpoints         []string `json:"endpoints"`
	OwnerID           string   `json:"owner_id"`
	CanManageEndpoint bool     `json:"can_manage_endpoint"`
}

type VerifierConfig

type VerifierConfig struct {
	Type      string     `json:"type,omitempty"`
	HMac      *HMac      `json:"hmac"`
	BasicAuth *BasicAuth `json:"basic_auth"`
	ApiKey    *ApiKey    `json:"api_key"`
}

type Webhook

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

func NewWebhook

func NewWebhook(opts *WebhookOpts) *Webhook

func (*Webhook) VerifyPayload added in v2.1.3

func (w *Webhook) VerifyPayload(b []byte, header string) error

func (*Webhook) VerifyRequest added in v2.1.3

func (w *Webhook) VerifyRequest(r *http.Request) error

type WebhookOpts added in v2.1.3

type WebhookOpts struct {
	SigHeader string
	Secret    string
	Encoding  EncodingType
	Hash      string
	Tolerance time.Duration
}

Directories

Path Synopsis
sqs

Jump to

Keyboard shortcuts

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