api

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: May 19, 2025 License: Apache-2.0 Imports: 38 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (

	// Role values
	RoleAdmin  = "admin"
	RoleTenant = "tenant"
)

Variables

View Source
var (
	ErrMissingAuthHeader  = errors.New("missing authorization header")
	ErrInvalidBearerToken = errors.New("invalid bearer token format")
	ErrTenantIDNotFound   = errors.New("tenantID not found in context")
)
View Source
var (
	ErrDestinationDisabled = errors.New("destination is disabled")
)
View Source
var (
	ErrInvalidToken = errors.New("invalid token")
)
View Source
var JWT = jsonwebtoken{}

Functions

func APIKeyAuthMiddleware

func APIKeyAuthMiddleware(apiKey string) gin.HandlerFunc

func APIKeyOrTenantJWTAuthMiddleware

func APIKeyOrTenantJWTAuthMiddleware(apiKey string, jwtKey string) gin.HandlerFunc

func AbortWithError

func AbortWithError(c *gin.Context, code int, err error)

func AbortWithValidationError

func AbortWithValidationError(c *gin.Context, err error)

func ErrorHandlerMiddleware

func ErrorHandlerMiddleware() gin.HandlerFunc

func GetRequestLatency

func GetRequestLatency(c *gin.Context) time.Duration

GetRequestLatency returns the request latency from the context

func LatencyMiddleware

func LatencyMiddleware() gin.HandlerFunc

func LoggerMiddleware

func LoggerMiddleware(logger *logging.Logger) gin.HandlerFunc

func MetricsMiddleware

func MetricsMiddleware() gin.HandlerFunc

func NewRouter

func NewRouter(
	cfg RouterConfig,
	logger *logging.Logger,
	redisClient *redis.Client,
	deliveryMQ *deliverymq.DeliveryMQ,
	entityStore models.EntityStore,
	logStore logstore.LogStore,
	publishmqEventHandler publishmq.EventHandler,
	telemetry telemetry.Telemetry,
) http.Handler

func RequireTenantMiddleware

func RequireTenantMiddleware(entityStore models.EntityStore) gin.HandlerFunc

func SetTenantIDMiddleware

func SetTenantIDMiddleware() gin.HandlerFunc

func TenantJWTAuthMiddleware

func TenantJWTAuthMiddleware(apiKey string, jwtKey string) gin.HandlerFunc

Types

type APIService

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

func NewService

func NewService(ctx context.Context, wg *sync.WaitGroup, cfg *config.Config, logger *logging.Logger, telemetry telemetry.Telemetry) (*APIService, error)

func (*APIService) Run

func (s *APIService) Run(ctx context.Context) error

func (*APIService) Shutdown

func (s *APIService) Shutdown(ctx context.Context)

type AuthScope

type AuthScope string
const (
	AuthScopeAdmin         AuthScope = "admin"
	AuthScopeTenant        AuthScope = "tenant"
	AuthScopeAdminOrTenant AuthScope = "admin_or_tenant"
)

type CreateDestinationRequest

type CreateDestinationRequest struct {
	ID          string             `json:"id" binding:"-"`
	Type        string             `json:"type" binding:"required"`
	Topics      models.Topics      `json:"topics" binding:"required"`
	Config      models.Config      `json:"config" binding:"-"`
	Credentials models.Credentials `json:"credentials" binding:"-"`
}

func (*CreateDestinationRequest) ToDestination

func (r *CreateDestinationRequest) ToDestination(tenantID string) models.Destination

type DeliveryResponse

type DeliveryResponse struct {
	ID           string                 `json:"id"`
	DeliveredAt  string                 `json:"delivered_at"`
	Status       string                 `json:"status"`
	Code         string                 `json:"code"`
	ResponseData map[string]interface{} `json:"response_data"`
}

type DestinationHandlers

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

func NewDestinationHandlers

func NewDestinationHandlers(logger *logging.Logger, telemetry telemetry.Telemetry, entityStore models.EntityStore, topics []string, registry destregistry.Registry) *DestinationHandlers

func (*DestinationHandlers) Create

func (h *DestinationHandlers) Create(c *gin.Context)

func (*DestinationHandlers) Delete

func (h *DestinationHandlers) Delete(c *gin.Context)

func (*DestinationHandlers) Disable

func (h *DestinationHandlers) Disable(c *gin.Context)

func (*DestinationHandlers) Enable

func (h *DestinationHandlers) Enable(c *gin.Context)

func (*DestinationHandlers) List

func (h *DestinationHandlers) List(c *gin.Context)

func (*DestinationHandlers) ListProviderMetadata

func (h *DestinationHandlers) ListProviderMetadata(c *gin.Context)

func (*DestinationHandlers) Retrieve

func (h *DestinationHandlers) Retrieve(c *gin.Context)

func (*DestinationHandlers) RetrieveProviderMetadata

func (h *DestinationHandlers) RetrieveProviderMetadata(c *gin.Context)

func (*DestinationHandlers) Update

func (h *DestinationHandlers) Update(c *gin.Context)

type ErrorResponse

type ErrorResponse struct {
	Err     error       `json:"-"`
	Code    int         `json:"-"`
	Message string      `json:"message"`
	Data    interface{} `json:"data,omitempty"`
}

func NewErrBadRequest

func NewErrBadRequest(err error) ErrorResponse

func NewErrInternalServer

func NewErrInternalServer(err error) ErrorResponse

func NewErrNotFound

func NewErrNotFound(resource string) ErrorResponse

func (ErrorResponse) Error

func (e ErrorResponse) Error() string

func (*ErrorResponse) Parse

func (e *ErrorResponse) Parse(err error)

type LogHandlers

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

func NewLogHandlers

func NewLogHandlers(
	logger *logging.Logger,
	logStore logstore.LogStore,
) *LogHandlers

func (*LogHandlers) ListDeliveryByEvent

func (h *LogHandlers) ListDeliveryByEvent(c *gin.Context)

func (*LogHandlers) ListEvent

func (h *LogHandlers) ListEvent(c *gin.Context)

func (*LogHandlers) ListEventByDestination

func (h *LogHandlers) ListEventByDestination(c *gin.Context)

func (*LogHandlers) RetrieveEvent

func (h *LogHandlers) RetrieveEvent(c *gin.Context)

func (*LogHandlers) RetrieveEventByDestination

func (h *LogHandlers) RetrieveEventByDestination(c *gin.Context)

type PublishHandlers

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

func NewPublishHandlers

func NewPublishHandlers(
	logger *logging.Logger,
	eventHandler publishmq.EventHandler,
) *PublishHandlers

func (*PublishHandlers) Ingest

func (h *PublishHandlers) Ingest(c *gin.Context)

type PublishedEvent

type PublishedEvent struct {
	ID               string                 `json:"id"`
	TenantID         string                 `json:"tenant_id" binding:"required"`
	DestinationID    string                 `json:"destination_id"`
	Topic            string                 `json:"topic"`
	EligibleForRetry *bool                  `json:"eligible_for_retry"`
	Time             time.Time              `json:"time"`
	Metadata         map[string]string      `json:"metadata"`
	Data             map[string]interface{} `json:"data"`
}

type RetryHandlers

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

func NewRetryHandlers

func NewRetryHandlers(logger *logging.Logger, entityStore models.EntityStore, logStore logstore.LogStore, deliveryMQ *deliverymq.DeliveryMQ) *RetryHandlers

func (*RetryHandlers) Retry

func (h *RetryHandlers) Retry(c *gin.Context)

type RouteDefinition

type RouteDefinition struct {
	Method             string
	Path               string
	Handler            gin.HandlerFunc
	AuthScope          AuthScope
	Mode               RouteMode
	AllowTenantFromJWT bool // Allow tenant ID to be sourced from JWT token instead of URL param
	Middlewares        []gin.HandlerFunc
}

type RouteMode

type RouteMode string
const (
	RouteModeAlways RouteMode = "always" // Register route regardless of mode
	RouteModePortal RouteMode = "portal" // Only register when portal is enabled (both apiKey and jwtSecret set)
)

type RouterConfig

type RouterConfig struct {
	ServiceName  string
	APIKey       string
	JWTSecret    string
	Topics       []string
	Registry     destregistry.Registry
	PortalConfig portal.PortalConfig
	GinMode      string
}

type TenantHandlers

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

func NewTenantHandlers

func NewTenantHandlers(
	logger *logging.Logger,
	telemetry telemetry.Telemetry,
	jwtSecret string,
	entityStore models.EntityStore,
) *TenantHandlers

func (*TenantHandlers) Delete

func (h *TenantHandlers) Delete(c *gin.Context)

func (*TenantHandlers) Retrieve

func (h *TenantHandlers) Retrieve(c *gin.Context)

func (*TenantHandlers) RetrievePortal

func (h *TenantHandlers) RetrievePortal(c *gin.Context)

func (*TenantHandlers) RetrieveToken

func (h *TenantHandlers) RetrieveToken(c *gin.Context)

func (*TenantHandlers) Upsert

func (h *TenantHandlers) Upsert(c *gin.Context)

type TopicHandlers

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

func NewTopicHandlers

func NewTopicHandlers(logger *logging.Logger, topics []string) *TopicHandlers

func (*TopicHandlers) List

func (h *TopicHandlers) List(c *gin.Context)

type UpdateDestinationRequest

type UpdateDestinationRequest struct {
	Type        string             `json:"type" binding:"-"`
	Topics      models.Topics      `json:"topics" binding:"-"`
	Config      models.Config      `json:"config" binding:"-"`
	Credentials models.Credentials `json:"credentials" binding:"-"`
}

Jump to

Keyboard shortcuts

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