webhooks

package
v0.1.0-rc.3 Latest Latest
Warning

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

Go to latest
Published: Aug 16, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var PlatformEventVersions = map[string]string{
	"organization.created": "1.0", "organization.retired": "1.0", "organization.restored": "1.0",
	"application.created": "1.0", "application.retired": "1.0", "application.restored": "1.0",
	"authorization.permission_grant.created": "1.0", "authorization.permission_grant.revoked": "1.0",
	"control_user.identity_linked": "1.0", "control_user.identity_unlinked": "1.0",
	"control_user.invitation_created": "1.0", "control_user.invitation_resent": "1.0",
	"control_user.invitation_revoked": "1.0", "control_user.invitation_accepted": "1.0",
	"control_auth.policy_updated": "1.0", "control_auth.provider_login_enabled": "1.0", "control_auth.provider_login_disabled": "1.0",
	"delegation.created": "1.0", "delegation.exchanged": "1.0", "delegation.revoked": "1.0",
	"entitlement.granted": "1.0", "local_entitlement_request.created": "1.0", "local_entitlement_request.approved": "1.0",
	"oauth.consent_revoked": "1.0", "platform93.webhook.test": "1.0", "user.created": "1.0",
	"storage.object.upload_requested": "1.0", "storage.object.ready": "1.0", "storage.object.deleted": "1.0",
	"storage.provider.verified": "1.0", "storage.provider.disabled": "1.0",
	"user.email_verified": "1.0", "user.email_unverified": "1.0", "user.organization_verified": "1.0",
	"user.organization_unverified": "1.0", "user.email_changed": "1.0", "user.password_reset": "1.0",
	"user.pending_deletion": "1.0", "user.anonymized": "1.0", "user.deleted": "1.0",
	"user.suspended": "1.0", "user.restored": "1.0", "workspace.invitation_created": "1.0",
	"workspace.invitation_accepted": "1.0", "workspace.owner_transferred": "1.0",
	"application_invitation.created": "1.0", "application_invitation.resent": "1.0", "application_invitation.revoked": "1.0",
	"application_invitation.accepted": "1.0", "application_invitation.expired": "1.0", "user.updated": "1.0",
	"workspace.created": "1.0", "workspace.updated": "1.0", "workspace.archived": "1.0", "workspace.member_added": "1.0",
	"workspace.member_updated": "1.0", "workspace.member_removed": "1.0", "entitlement.adjusted": "1.0",
	"entitlement.revoked": "1.0", "entitlement.restored": "1.0", "entitlement.expired": "1.0", "entitlement.effective_changed": "1.0",
	"billing.subscription.updated": "1.0", "billing.invoice.updated": "1.0", "billing.payment.updated": "1.0",
	"billing.refund.updated": "1.0", "billing.dispute.updated": "1.0",
}

Functions

func DecodeData

func DecodeData[T any](event Event) (T, error)

func Dispatch

func Dispatch(ctx context.Context, event Event, handlers map[string]Handler, custom Handler) (bool, error)

Dispatch routes a known Platform93 event by exact type and sends custom events to the optional fallback. It rejects unsupported major contract versions.

func Verify

func Verify(body []byte, header, secret string, now time.Time, tolerance time.Duration) error

Types

type ApplicationLifecycleData

type ApplicationLifecycleData struct {
	OrganizationID string `json:"organization_id"`
	Reason         string `json:"reason"`
}

type BillingLifecycleData

type BillingLifecycleData struct {
	SubscriptionID    string  `json:"subscription_id,omitempty"`
	InvoiceID         string  `json:"invoice_id,omitempty"`
	PaymentID         string  `json:"payment_id,omitempty"`
	RefundID          string  `json:"refund_id,omitempty"`
	DisputeID         string  `json:"dispute_id,omitempty"`
	Status            string  `json:"status"`
	SubjectType       string  `json:"subject_type,omitempty"`
	SubjectID         string  `json:"subject_id,omitempty"`
	ExternalReference *string `json:"external_reference"`
}

type ControlInvitationData

type ControlInvitationData struct {
	InvitationID     string  `json:"invitation_id"`
	OrganizationID   *string `json:"organization_id,omitempty"`
	ControlUserID    *string `json:"control_user_id,omitempty"`
	Role             string  `json:"role"`
	OnboardingMethod string  `json:"onboarding_method"`
	Status           string  `json:"status"`
}

type ControlUserIdentityData

type ControlUserIdentityData struct {
	ControlUserID string `json:"control_user_id"`
	Provider      string `json:"provider"`
}

type DelegationCreatedData

type DelegationCreatedData struct {
	DelegationID string    `json:"delegation_id"`
	UserID       string    `json:"user_id"`
	WorkspaceID  *string   `json:"workspace_id"`
	Permissions  []string  `json:"permissions"`
	Reason       string    `json:"reason"`
	ExpiresAt    time.Time `json:"expires_at"`
}

type DelegationExchangedData

type DelegationExchangedData struct {
	DelegationID string `json:"delegation_id"`
	UserID       string `json:"user_id"`
}

type DelegationRevokedData

type DelegationRevokedData struct {
	DelegationID string `json:"delegation_id"`
}

type EntitlementGrantedData

type EntitlementGrantedData struct {
	GrantID     string `json:"grant_id"`
	SubjectType string `json:"subject_type"`
	SubjectID   string `json:"subject_id"`
	Reason      string `json:"reason"`
}

type EntitlementLifecycleData

type EntitlementLifecycleData struct {
	GrantID           string  `json:"grant_id"`
	Status            string  `json:"status,omitempty"`
	SubjectType       string  `json:"subject_type,omitempty"`
	SubjectID         string  `json:"subject_id,omitempty"`
	ExternalReference *string `json:"external_reference,omitempty"`
	ExpiresAt         *string `json:"expires_at,omitempty"`
	Reason            string  `json:"reason,omitempty"`
}

type Event

type Event struct {
	SpecVersion    string          `json:"specversion"`
	ID             string          `json:"id"`
	Source         string          `json:"source"`
	Type           string          `json:"type"`
	ContractSource string          `json:"contract_source"`
	Time           time.Time       `json:"time"`
	ApplicationID  string          `json:"application_id"`
	SchemaVersion  string          `json:"schema_version"`
	Subject        *string         `json:"subject"`
	Actor          json.RawMessage `json:"actor"`
	CorrelationID  *string         `json:"correlation_id"`
	CausationID    *string         `json:"causation_id"`
	Data           json.RawMessage `json:"data"`
}

func VerifyAndDecode

func VerifyAndDecode(body []byte, header, secret string, now time.Time, tolerance time.Duration) (Event, error)

func (Event) IsCustom

func (e Event) IsCustom() bool

func (Event) IsPlatform

func (e Event) IsPlatform() bool

func (Event) SupportsKnownVersion

func (e Event) SupportsKnownVersion() bool

type Handler

type Handler func(context.Context, Event) error

type InvitationLifecycleData

type InvitationLifecycleData struct {
	InvitationID string  `json:"invitation_id"`
	Status       string  `json:"status"`
	WorkspaceID  *string `json:"workspace_id,omitempty"`
	UserID       *string `json:"user_id,omitempty"`
	ExpiresAt    *string `json:"expires_at,omitempty"`
}

type LocalEntitlementRequestApprovedData

type LocalEntitlementRequestApprovedData struct {
	RequestID string `json:"request_id"`
	GrantID   string `json:"grant_id"`
}

type LocalEntitlementRequestCreatedData

type LocalEntitlementRequestCreatedData struct {
	RequestID   string `json:"request_id"`
	SubjectType string `json:"subject_type"`
	SubjectID   string `json:"subject_id"`
	PriceID     string `json:"price_id"`
}

type NamedData

type NamedData struct {
	Name string `json:"name"`
	Slug string `json:"slug"`
}

type OAuthConsentRevokedData

type OAuthConsentRevokedData struct {
	UserID    string `json:"user_id"`
	ClientID  string `json:"client_id"`
	ClientKey string `json:"client_key"`
}

type OrganizationRestoredData

type OrganizationRestoredData struct {
	DescendantsRestored bool `json:"descendants_restored"`
}

type OrganizationRetiredData

type OrganizationRetiredData struct {
	ApplicationCount int `json:"application_count"`
}

type PermissionGrantLifecycleData

type PermissionGrantLifecycleData struct {
	GrantID        string  `json:"grant_id"`
	SubjectType    string  `json:"subject_type"`
	SubjectID      string  `json:"subject_id"`
	WorkspaceID    *string `json:"workspace_id"`
	Permission     string  `json:"permission"`
	CanonicalScope string  `json:"canonical_scope"`
}

type StorageObjectData

type StorageObjectData struct {
	ObjectID   string `json:"object_id"`
	OwnerType  string `json:"owner_type"`
	Visibility string `json:"visibility"`
	SizeBytes  int64  `json:"size_bytes"`
}

type StorageProviderData

type StorageProviderData struct {
	ProviderID     string `json:"provider_id"`
	Scope          string `json:"scope"`
	PublicEnabled  bool   `json:"public_enabled"`
	PrivateEnabled bool   `json:"private_enabled"`
}

type UserCreatedData

type UserCreatedData struct {
	UserID        string `json:"user_id"`
	EmailVerified bool   `json:"email_verified"`
	IsOrgVerified bool   `json:"is_org_verified"`
}

type UserIDData

type UserIDData struct {
	UserID string `json:"user_id"`
}

type UserStateData

type UserStateData struct {
	UserID string `json:"user_id"`
	Reason string `json:"reason"`
}

type UserVerificationData

type UserVerificationData struct {
	UserID   string `json:"user_id"`
	Verified bool   `json:"verified"`
	Reason   string `json:"reason"`
}

type WebhookTestData

type WebhookTestData struct {
	WebhookEndpointID string `json:"webhook_endpoint_id"`
	Test              bool   `json:"test"`
}

type WorkspaceInvitationAcceptedData

type WorkspaceInvitationAcceptedData struct {
	InvitationID string `json:"invitation_id"`
	WorkspaceID  string `json:"workspace_id"`
	UserID       string `json:"user_id"`
}

type WorkspaceInvitationCreatedData

type WorkspaceInvitationCreatedData struct {
	InvitationID string   `json:"invitation_id"`
	WorkspaceID  string   `json:"workspace_id"`
	RoleKeys     []string `json:"role_keys"`
}

type WorkspaceOwnerTransferredData

type WorkspaceOwnerTransferredData struct {
	WorkspaceID              string `json:"workspace_id"`
	PreviousOwnerUserID      string `json:"previous_owner_user_id"`
	NewOwnerUserID           string `json:"new_owner_user_id"`
	PreviousOwnerDisposition string `json:"previous_owner_disposition"`
}

Jump to

Keyboard shortcuts

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