webhook

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Jun 20, 2023 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Credential   = Noun("Credential")
	DID          = Noun("DID")
	Manifest     = Noun("Manifest")
	Schema       = Noun("SchemaID")
	Presentation = Noun("Presentation")
	Application  = Noun("Application")
	Submission   = Noun("Submission")
)

Supported Nouns

View Source
const (
	BatchCreate = Verb("BatchCreate")
	Create      = Verb("Create")
	Delete      = Verb("Delete")
)

Supported Verbs

Variables

This section is empty.

Functions

This section is empty.

Types

type CreateWebhookRequest

type CreateWebhookRequest struct {
	Noun Noun   `json:"noun" validate:"required"`
	Verb Verb   `json:"verb" validate:"required"`
	URL  string `json:"url" validate:"required"`
}

func (CreateWebhookRequest) IsValid

func (cwr CreateWebhookRequest) IsValid() bool

type CreateWebhookResponse

type CreateWebhookResponse struct {
	Webhook Webhook `json:"webhook"`
}

type DeleteWebhookRequest

type DeleteWebhookRequest struct {
	Noun Noun   `json:"noun" validate:"required"`
	Verb Verb   `json:"verb" validate:"required"`
	URL  string `json:"url" validate:"required"`
}

func (DeleteWebhookRequest) IsValid

func (cwr DeleteWebhookRequest) IsValid() bool

type GetSupportedNounsResponse

type GetSupportedNounsResponse struct {
	Nouns []Noun `json:"nouns,omitempty"`
}

type GetSupportedVerbsResponse

type GetSupportedVerbsResponse struct {
	Verbs []Verb `json:"verbs,omitempty"`
}

type GetWebhookRequest

type GetWebhookRequest struct {
	Noun Noun `json:"noun" validate:"required"`
	Verb Verb `json:"verb" validate:"required"`
}

type GetWebhookResponse

type GetWebhookResponse struct {
	Webhook Webhook `json:"webhook"`
}

type ListWebhooksResponse

type ListWebhooksResponse struct {
	Webhooks []Webhook `json:"webhooks,omitempty"`
}

type Noun

type Noun string

In the context of webhooks, it's common to use noun.verb notation to describe events, such as "credential.create" or "schema.delete".

func (Noun) IsValid

func (n Noun) IsValid() bool

type Payload

type Payload struct {
	Noun Noun            `json:"noun" validate:"required"`
	Verb Verb            `json:"verb" validate:"required"`
	URL  string          `json:"url" validate:"required"`
	Data json.RawMessage `json:"data,omitempty"`
}

type Service

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

func NewWebhookService

func NewWebhookService(config config.WebhookServiceConfig, s storage.ServiceStorage) (*Service, error)

func (Service) Config

func (s Service) Config() config.WebhookServiceConfig

func (Service) CreateWebhook

func (s Service) CreateWebhook(ctx context.Context, request CreateWebhookRequest) (*CreateWebhookResponse, error)

func (Service) DeleteWebhook

func (s Service) DeleteWebhook(ctx context.Context, request DeleteWebhookRequest) error

DeleteWebhook deletes a webhook from the storage by removing a given DIDWebID from the list of URLs associated with the webhook. If there are no URLs left in the list, the entire webhook is deleted from storage.

func (Service) GetSupportedNouns

func (s Service) GetSupportedNouns() GetSupportedNounsResponse

func (Service) GetSupportedVerbs

func (s Service) GetSupportedVerbs() GetSupportedVerbsResponse

func (Service) GetWebhook

func (s Service) GetWebhook(ctx context.Context, request GetWebhookRequest) (*GetWebhookResponse, error)

func (Service) ListWebhooks

func (s Service) ListWebhooks(ctx context.Context) (*ListWebhooksResponse, error)

ListWebhooks returns all webhooks in storage.

func (Service) PublishWebhook

func (s Service) PublishWebhook(c *gin.Context, noun Noun, verb Verb, payloadReader io.Reader)

TODO: consider returning an error to be handled by the gin middleware

func (Service) Status

func (s Service) Status() framework.Status

func (Service) Type

func (s Service) Type() framework.Type

type Storage

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

func NewWebhookStorage

func NewWebhookStorage(db storage.ServiceStorage) (*Storage, error)

func (*Storage) DeleteWebhook

func (whs *Storage) DeleteWebhook(ctx context.Context, noun, verb string) error

func (*Storage) GetWebhook

func (whs *Storage) GetWebhook(ctx context.Context, noun, verb string) (*Webhook, error)

func (*Storage) ListWebhooks

func (whs *Storage) ListWebhooks(ctx context.Context) ([]Webhook, error)

func (*Storage) StoreWebhook

func (whs *Storage) StoreWebhook(ctx context.Context, noun, verb string, webhook Webhook) error

type Verb

type Verb string

In the context of webhooks, it's common to use noun.verb notation to describe events, such as "credential.create" or "schema.delete".

type Webhook

type Webhook struct {
	Noun Noun     `json:"noun" validate:"required"`
	Verb Verb     `json:"verb" validate:"required"`
	URLS []string `json:"urls" validate:"required"`
}

func (Webhook) IsEmpty

func (wh Webhook) IsEmpty() bool

Jump to

Keyboard shortcuts

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