Documentation
¶
Overview ¶
License, machine, license-user/license-entitlement and license-file documents (the reference's LicenseSerializer, MachineSerializer, LicenseUserSerializer, LicenseEntitlementSerializer and LicenseFileSerializer).
The checkout payload: the JSON:API dataset embedded in a license or machine file certificate ({data, included, meta}).
Package render projects domain values onto the generated oas wire types. It is shared by the HTTP handlers and the future webhook publisher: one renderer, one wire truth.
Package render holds the domain→ogen conversions: every resource document the API (and later the webhook publisher) writes on the wire, in exactly the reference's serializer shape.
Webhook rendering: the endpoint and event resources, and the webhook payload documents the publisher embeds in the outbox rows.
Index ¶
- Variables
- func Base64Std(s string) string
- func CheckoutPayload(accountID uuid.UUID, checkout licenses.Checkout, now time.Time) ([]byte, error)
- func Component(accountID uuid.UUID, c domain.MachineComponent) oas.ComponentResource
- func EntitlementResource(accountID uuid.UUID, e domain.Entitlement) oas.EntitlementResource
- func Group(group domain.Group) oas.GroupResource
- func GroupIdentifier(group uuid.NullUUID) oas.NilResourceIdentifier
- func GroupOwner(owner domain.GroupOwner) oas.GroupOwnerResource
- func KeyResource(accountID uuid.UUID, k domain.Key) oas.KeyResource
- func License(accountID uuid.UUID, l domain.License, now time.Time, rawKey *string) oas.LicenseResource
- func LicenseEntitlement(accountID uuid.UUID, join domain.LicenseEntitlement) oas.LicenseEntitlementResource
- func LicenseFile(accountID uuid.UUID, fileID uuid.UUID, certificate, algorithm string, ...) oas.LicenseFileResource
- func LicenseUser(accountID uuid.UUID, join domain.LicenseUser) oas.LicenseUserResource
- func LicenseValidation(accountID uuid.UUID, event domain.LicenseValidationEvent) oas.LicenseValidateDocument
- func LicenseValidationMeta(event domain.LicenseValidationEvent) oas.LicenseValidateMeta
- func Links(doc *paging.Doc) oas.OptListLinks
- func Machine(accountID uuid.UUID, m domain.Machine) oas.MachineResource
- func MachineCheckoutPayload(accountID uuid.UUID, checkout machines.Checkout, now time.Time) ([]byte, error)
- func MachineFile(accountID, fileID uuid.UUID, certificate, algorithm string, includes []string, ...) oas.MachineFileResource
- func Metadata(stored map[string]any) oas.Metadata
- func NilInt(v *int) oas.NilInt
- func NilPtrString(s *string) oas.NilString
- func NilString(s string) oas.NilString
- func OptNilString(s string) oas.OptNilString
- func PayloadDocument(accountID uuid.UUID, resource any) (any, error)
- func PolicyEntitlementResource(accountID uuid.UUID, join domain.PolicyEntitlement) oas.PolicyEntitlementResource
- func PolicyResource(accountID uuid.UUID, p domain.Policy) oas.PolicyResource
- func Process(accountID uuid.UUID, p domain.MachineProcess) oas.ProcessResource
- func ProductResource(accountID uuid.UUID, p domain.Product) oas.ProductResource
- func ProductStub(accountID, id uuid.UUID) oas.UserProductResource
- func SecondFactor(accountID uuid.UUID, factor domain.SecondFactor, email string) oas.SecondFactorResource
- func Timestamp(t time.Time) oas.Timestamp
- func Token(accountID uuid.UUID, token domain.Token, role domain.Role, raw string) oas.TokenResource
- func User(accountID uuid.UUID, user domain.User, status string) oas.UserResource
- func WebhookEndpoint(accountID uuid.UUID, e domain.WebhookEndpoint) oas.WebhookEndpointResource
- func WebhookEvent(accountID uuid.UUID, e domain.WebhookEvent) oas.WebhookEventResource
Constants ¶
This section is empty.
Variables ¶
var ErrUnsupportedPayload = errors.New("render: webhook payload: unsupported resource")
ErrUnsupportedPayload marks a resource the renderer cannot turn into a webhook payload.
Functions ¶
func CheckoutPayload ¶
func CheckoutPayload( accountID uuid.UUID, checkout licenses.Checkout, now time.Time, ) ([]byte, error)
CheckoutPayload renders the license-file dataset of a checkout. It encodes through the generated jx encoders (encoding/json would marshal the optional relationship wrappers' zero values).
func Component ¶ added in v0.0.5
func Component(accountID uuid.UUID, c domain.MachineComponent) oas.ComponentResource
Component renders a machine component document.
func EntitlementResource ¶
func EntitlementResource(accountID uuid.UUID, e domain.Entitlement) oas.EntitlementResource
EntitlementResource renders an entitlement exactly as the reference's EntitlementSerializer does.
func Group ¶
func Group(group domain.Group) oas.GroupResource
Group renders a group exactly as the reference's GroupSerializer does.
func GroupIdentifier ¶
func GroupIdentifier(group uuid.NullUUID) oas.NilResourceIdentifier
GroupIdentifier renders a group linkage (null when none).
func GroupOwner ¶
func GroupOwner(owner domain.GroupOwner) oas.GroupOwnerResource
GroupOwner renders the group-owners join resource.
func KeyResource ¶
KeyResource renders a key exactly as the reference's KeySerializer does: the product linkage rides through the key's policy.
func License ¶
func License(accountID uuid.UUID, l domain.License, now time.Time, rawKey *string) oas.LicenseResource
License renders a license exactly as the reference's LicenseSerializer does. RawKey carries the one-time plaintext of a legacy-encrypted key (the create response); later reads omit key.
func LicenseEntitlement ¶
func LicenseEntitlement(accountID uuid.UUID, join domain.LicenseEntitlement) oas.LicenseEntitlementResource
LicenseEntitlement renders a license-entitlement join document.
func LicenseFile ¶
func LicenseFile(accountID uuid.UUID, fileID uuid.UUID, certificate, algorithm string, includes []string, ttl *int32, issued time.Time, expiry *time.Time, licenseID uuid.UUID, ) oas.LicenseFileResource
LicenseFile renders the license-file document of a checkout.
func LicenseUser ¶
func LicenseUser(accountID uuid.UUID, join domain.LicenseUser) oas.LicenseUserResource
LicenseUser renders a license-user join document.
func LicenseValidation ¶
func LicenseValidation(accountID uuid.UUID, event domain.LicenseValidationEvent) oas.LicenseValidateDocument
LicenseValidation renders the event's complete JSON:API document.
func LicenseValidationMeta ¶
func LicenseValidationMeta(event domain.LicenseValidationEvent) oas.LicenseValidateMeta
LicenseValidationMeta is shared by API responses and validation webhooks.
func Links ¶
func Links(doc *paging.Doc) oas.OptListLinks
Links builds the collection links document (nil Doc answers no links at all).
func Machine ¶
Machine renders a machine document (the machines reached through a license's relationship).
func MachineCheckoutPayload ¶ added in v0.0.5
func MachineCheckoutPayload(accountID uuid.UUID, checkout machines.Checkout, now time.Time) ([]byte, error)
MachineCheckoutPayload renders the machine-file dataset: the machine, its requested includes (the license's own included as license.*).
func MachineFile ¶ added in v0.0.5
func MachineFile(accountID, fileID uuid.UUID, certificate, algorithm string, includes []string, ttl *int32, issued time.Time, expiry *time.Time, licenseID, machineID uuid.UUID, ) oas.MachineFileResource
MachineFile renders a machine-file document (the license file's attributes, plus the machine relationship).
func NilPtrString ¶
NilPtrString renders an optional string.
func OptNilString ¶
func OptNilString(s string) oas.OptNilString
OptNilString renders the raw token secret: present on creation, explicitly null otherwise.
func PayloadDocument ¶
PayloadDocument renders the resource document a webhook payload carries: the same JSON:API renderer the API responses use. The types that need extra inputs (the user's status, the second factor's email) are resolved by the caller before this; an unknown type is an error, never a wrong payload.
func PolicyEntitlementResource ¶
func PolicyEntitlementResource(accountID uuid.UUID, join domain.PolicyEntitlement) oas.PolicyEntitlementResource
PolicyEntitlementResource renders one policy_entitlements join row exactly as the attach route's PolicyEntitlementSerializer does: the links object carries related (the policy-side relationship URL), not self.
func PolicyResource ¶
PolicyResource renders a policy exactly as the reference's PolicySerializer does.
func Process ¶ added in v0.0.5
func Process(accountID uuid.UUID, p domain.MachineProcess) oas.ProcessResource
Process renders a machine process document.
func ProductResource ¶
ProductResource renders a product exactly as the reference's ProductSerializer does.
func ProductStub ¶
func ProductStub(accountID, id uuid.UUID) oas.UserProductResource
ProductStub renders the minimal product document of the user/group relationship indexes (the full serializer belongs to the products group).
func SecondFactor ¶
func SecondFactor(accountID uuid.UUID, factor domain.SecondFactor, email string) oas.SecondFactorResource
SecondFactor renders a second factor; the secret and provisioning uri only while the factor is disabled.
func Token ¶
Token renders a token as the reference's TokenSerializer does: raw (the secret) only on creation/regeneration, the activation counters only on activation tokens. role is the bearer's live role.
func User ¶
User renders a user as the reference's UserSerializer does (status precomputed by the scenario).
func WebhookEndpoint ¶
func WebhookEndpoint(accountID uuid.UUID, e domain.WebhookEndpoint) oas.WebhookEndpointResource
WebhookEndpoint renders an endpoint exactly as the reference's WebhookEndpointSerializer does (the product relationship's linkage always present, null when account-scoped).
func WebhookEvent ¶
func WebhookEvent(accountID uuid.UUID, e domain.WebhookEvent) oas.WebhookEventResource
WebhookEvent renders an event exactly as the reference's WebhookEventSerializer does (the payload as the JSON string of the resource document; the idempotency token in resource-level meta).
Types ¶
This section is empty.