web

package
v3.31.1 Latest Latest
Warning

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

Go to latest
Published: Aug 1, 2024 License: Apache-2.0 Imports: 38 Imported by: 0

Documentation

Overview

Package web implements the webhooks integration.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewCachedHealthStatusRegistry added in v3.16.2

func NewCachedHealthStatusRegistry(registry sink.HealthStatusRegistry) sink.HealthStatusRegistry

NewCachedHealthStatusRegistry constructs a HealthStatusRegistry which allows the Get response to be cached.

func NewHealthStatusRegistry added in v3.16.2

func NewHealthStatusRegistry(registry WebhookRegistry) sink.HealthStatusRegistry

NewHealthStatusRegistry constructs a HealthStatusRegistry on top of the provided WebhookRegistry.

func NewRequest added in v3.30.1

func NewRequest(
	ctx context.Context, downlinks DownlinksConfig, msg *ttnpb.ApplicationUp, hook *ttnpb.ApplicationWebhook,
) (*http.Request, error)

NewRequest returns an HTTP request. This method returns nil, nil if the hook is not configured for the message.

func NewWebhookRegistryRPC

func NewWebhookRegistryRPC(webhooks WebhookRegistry, templates TemplateStore) ttnpb.ApplicationWebhookRegistryServer

NewWebhookRegistryRPC returns a new webhook registry gRPC server.

Types

type DownlinksConfig

type DownlinksConfig struct {
	PublicAddress    string `name:"public-address" description:"Public address of the HTTP webhooks frontend"`
	PublicTLSAddress string `name:"public-tls-address" description:"Public address of the HTTPS webhooks frontend"`
}

DownlinksConfig defines the configuration for the webhook downlink queue operations. For public addresses, the TLS version is preferred when present.

func (DownlinksConfig) Domain added in v3.30.1

func (c DownlinksConfig) Domain(_ context.Context) string

Domain returns the domain of the public address.

func (DownlinksConfig) URL added in v3.30.1

URL returns the URL for the downlink operation.

type Format

type Format struct {
	formatters.Formatter
	Name        string
	ContentType string
}

Format is a format to use for web-based frontends.

type RegistryCleaner added in v3.15.2

type RegistryCleaner struct {
	WebRegistry WebhookRegistry
	LocalSet    map[string]struct{}
}

RegistryCleaner is a service responsible for cleanup of the webhook registry.

func (*RegistryCleaner) CleanData added in v3.15.2

func (cleaner *RegistryCleaner) CleanData(ctx context.Context, isSet map[string]struct{}) error

CleanData cleans registry application data.

func (*RegistryCleaner) DeleteApplicationData added in v3.15.2

func (cleaner *RegistryCleaner) DeleteApplicationData(ctx context.Context, applicationList []string) error

DeleteApplicationData deletes registry application data of all applications in the application list.

func (*RegistryCleaner) RangeToLocalSet added in v3.15.2

func (cleaner *RegistryCleaner) RangeToLocalSet(ctx context.Context) error

RangeToLocalSet returns a set of applications that have data in the registry.

type TemplateStore

type TemplateStore interface {
	// GetTemplate returns the template with the given identifiers.
	GetTemplate(ctx context.Context, req *ttnpb.GetApplicationWebhookTemplateRequest) (*ttnpb.ApplicationWebhookTemplate, error)
	// ListTemplates returns the available templates.
	ListTemplates(ctx context.Context, req *ttnpb.ListApplicationWebhookTemplatesRequest) (*ttnpb.ApplicationWebhookTemplates, error)
}

TemplateStore contains the webhook templates.

type TemplatesConfig

type TemplatesConfig struct {
	Static      map[string][]byte `name:"-"`
	Directory   string            `name:"directory" description:"Retrieve the webhook templates from the filesystem"`
	URL         string            `name:"url" description:"Retrieve the webhook templates from a web server"`
	LogoBaseURL string            `name:"logo-base-url" description:"The base URL for the logo storage"`
}

TemplatesConfig defines the configuration for the webhook templates registry.

func (TemplatesConfig) NewTemplateStore

func (c TemplatesConfig) NewTemplateStore(ctx context.Context, httpClientProvider httpclient.Provider) (TemplateStore, error)

NewTemplateStore returns a TemplateStore based on the configuration.

type WebhookRegistry

type WebhookRegistry interface {
	// Get returns the webhook by its identifiers.
	Get(ctx context.Context, ids *ttnpb.ApplicationWebhookIdentifiers, paths []string) (*ttnpb.ApplicationWebhook, error)
	// List returns all webhooks of the application.
	List(ctx context.Context, ids *ttnpb.ApplicationIdentifiers, paths []string) ([]*ttnpb.ApplicationWebhook, error)
	// Set creates, updates or deletes the webhook by its identifiers.
	Set(ctx context.Context, ids *ttnpb.ApplicationWebhookIdentifiers, paths []string, f func(*ttnpb.ApplicationWebhook) (*ttnpb.ApplicationWebhook, []string, error)) (*ttnpb.ApplicationWebhook, error)
	// Range ranges over the webhooks and calls the callback function, until false is returned.
	Range(ctx context.Context, paths []string, f func(context.Context, *ttnpb.ApplicationIdentifiers, *ttnpb.ApplicationWebhook) bool) error
}

WebhookRegistry is a store for webhooks.

type Webhooks

type Webhooks interface {
	ttnweb.Registerer
	Registry() WebhookRegistry
}

Webhooks is an interface for registering incoming webhooks for downlink and creating a subscription to outgoing webhooks for upstream data.

func NewWebhooks

func NewWebhooks(
	ctx context.Context,
	server io.Server,
	registry WebhookRegistry,
	target sink.Sink,
	downlinks DownlinksConfig,
) (Webhooks, error)

NewWebhooks returns a new Webhooks.

Directories

Path Synopsis
Package internal contains internal webhook utilities.
Package internal contains internal webhook utilities.
Package sink provides an interface for processing HTTP requests.
Package sink provides an interface for processing HTTP requests.
mock
Package mock provides a mock sink for testing.
Package mock provides a mock sink for testing.

Jump to

Keyboard shortcuts

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