model

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Jan 14, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidModel = errors.New("invalid model")

ErrInvalidModel is returned when a model is invalid.

Functions

This section is empty.

Types

type AdminCreateArgs

type AdminCreateArgs struct {
	APIKey                   uuid.UUID                `json:"apiKey"`
	Aud                      uuid.UUID                `json:"aud"`
	UUID                     uuid.UUID                `json:"uuid"`
	ServiceAccountCreateArgs ServiceAccountCreateArgs `json:"serviceAccountCreateArgs"`
}

AdminCreateArgs are the unvalidated arguments for creating an admin.

func (AdminCreateArgs) Validate

func (a AdminCreateArgs) Validate(config Validation) (ValidAdminCreateArgs, error)

Validate validates the admin create arguments.

type EmailLinkCreateArgs

type EmailLinkCreateArgs struct {
	ButtonText   string `json:"buttonText"`
	Greeting     string `json:"greeting"`
	LogoClickURL string `json:"logoClickURL"`
	LogoImageURL string `json:"logoImageURL"`
	ServiceName  string `json:"serviceName"`
	Subject      string `json:"subject"`
	SubTitle     string `json:"subTitle"`
	Title        string `json:"title"`
	ToEmail      string `json:"toEmail"`
	ToName       string `json:"toName"`
}

EmailLinkCreateArgs are the unvalidated arguments for creating an email link.

func (EmailLinkCreateArgs) Validate

Validate implements the Validatable interface.

type EmailLinkCreateRequest

type EmailLinkCreateRequest struct {
	EmailArgs EmailLinkCreateArgs `json:"emailArgs"`
	LinkArgs  LinkCreateArgs      `json:"linkArgs"`
}

EmailLinkCreateRequest is the unvalidated request to create an email link.

func (EmailLinkCreateRequest) Validate

Validate implements the Validatable interface.

type EmailLinkCreateResponse

type EmailLinkCreateResponse struct {
	EmailLinkCreateResults EmailLinkCreateResults `json:"emailLinkCreateResults"`
	RequestMetadata        RequestMetadata        `json:"requestMetadata"`
}

EmailLinkCreateResponse is the response to creating an email link.

type EmailLinkCreateResults

type EmailLinkCreateResults struct {
	LinkCreateResults LinkCreateResults `json:"linkCreateResults"`
}

EmailLinkCreateResults are the results of creating an email link.

type Error

type Error struct {
	Code            int             `json:"code"`
	Message         string          `json:"message"`
	RequestMetadata RequestMetadata `json:"requestMetadata"`
}

Error is the model for an error.

func NewError

func NewError(ctx context.Context, code int, message string) Error

NewError creates a new error.

type JWTCreateArgs

type JWTCreateArgs struct {
	JWTAlg             string `json:"jwtAlg"`
	JWTClaims          any    `json:"jwtClaims"`
	JWTLifespanSeconds int    `json:"jwtLifespanSeconds"`
}

JWTCreateArgs are the unvalidated arguments for creating a JWT.

func (JWTCreateArgs) Validate

func (j JWTCreateArgs) Validate(config Validation) (ValidJWTCreateArgs, error)

Validate implements the Validatable interface.

type JWTCreateRequest

type JWTCreateRequest struct {
	JWTCreateArgs JWTCreateArgs `json:"jwtCreateArgs"`
}

JWTCreateRequest is the unvalidated request to create a JWT.

func (JWTCreateRequest) Validate

Validate implements the Validatable interface.

type JWTCreateResponse

type JWTCreateResponse struct {
	JWTCreateResults JWTCreateResults `json:"jwtCreateResults"`
	RequestMetadata  RequestMetadata  `json:"requestMetadata"`
}

JWTCreateResponse is the response to creating a JWT.

type JWTCreateResults

type JWTCreateResults struct {
	JWT string `json:"jwt"`
}

JWTCreateResults are the results of creating a JWT.

type JWTValidateArgs

type JWTValidateArgs struct {
	JWT string `json:"jwt"`
}

JWTValidateArgs are the unvalidated arguments for validating a JWT.

func (JWTValidateArgs) Validate

Validate implements the Validatable interface.

type JWTValidateRequest

type JWTValidateRequest struct {
	JWTValidateArgs JWTValidateArgs `json:"jwtValidateArgs"`
}

JWTValidateRequest is the unvalidated request to validate a JWT.

func (JWTValidateRequest) Validate

Validate implements the Validatable interface.

type JWTValidateResponse

type JWTValidateResponse struct {
	JWTValidateResults JWTValidateResults `json:"jwtValidateResults"`
	RequestMetadata    RequestMetadata    `json:"requestMetadata"`
}

JWTValidateResponse is the response to validating a JWT.

type JWTValidateResults

type JWTValidateResults struct {
	JWTClaims json.RawMessage `json:"claims"`
}

JWTValidateResults are the results of validating a JWT.

type LinkCreateArgs

type LinkCreateArgs struct {
	JWTCreateArgs    JWTCreateArgs `json:"jwtCreateArgs"`
	LinkLifespan     int           `json:"linkLifespan"`
	RedirectQueryKey string        `json:"redirectQueryKey"`
	RedirectURL      string        `json:"redirectUrl"`
}

LinkCreateArgs are the unvalidated arguments for creating a link.

func (LinkCreateArgs) Validate

func (p LinkCreateArgs) Validate(config Validation) (ValidLinkCreateArgs, error)

Validate validates the link create arguments.

type LinkCreateRequest

type LinkCreateRequest struct {
	LinkArgs LinkCreateArgs `json:"linkArgs"`
}

LinkCreateRequest is the request to create a link.

func (LinkCreateRequest) Validate

Validate validates the link create request.

type LinkCreateResponse

type LinkCreateResponse struct {
	LinkCreateResults LinkCreateResults `json:"linkCreateResults"`
	RequestMetadata   RequestMetadata   `json:"requestMetadata"`
}

LinkCreateResponse is the response to creating a link.

type LinkCreateResults

type LinkCreateResults struct {
	MagicLink string `json:"magicLink"`
	Secret    string `json:"secret"`
}

LinkCreateResults are the results of creating a link.

type RequestMetadata

type RequestMetadata struct {
	UUID uuid.UUID `json:"uuid"`
}

RequestMetadata is the model for request metadata.

type ServiceAccount

type ServiceAccount struct {
	UUID   uuid.UUID `json:"uuid"`
	APIKey uuid.UUID `json:"apiKey"`
	Aud    uuid.UUID `json:"aud"`
	Admin  bool      `json:"admin"`
}

ServiceAccount is the model for a service account and its metadata.

type ServiceAccountCreateArgs

type ServiceAccountCreateArgs struct{}

ServiceAccountCreateArgs are the unvalidated arguments to create a service account.

func (ServiceAccountCreateArgs) Validate

Validate implements the Validatable interface.

type ServiceAccountCreateRequest

type ServiceAccountCreateRequest struct {
	CreateServiceAccountArgs ServiceAccountCreateArgs `json:"createServiceAccountArgs"`
}

ServiceAccountCreateRequest is the unvalidated request to create a service account.

func (ServiceAccountCreateRequest) Validate

Validate implements the Validatable interface.

type ServiceAccountCreateResponse

type ServiceAccountCreateResponse struct {
	CreateServiceAccountResults ServiceAccountCreateResults `json:"createServiceAccountResults"`
	RequestMetadata             RequestMetadata             `json:"requestMetadata"`
}

ServiceAccountCreateResponse is the response to creating a service account.

type ServiceAccountCreateResults

type ServiceAccountCreateResults struct {
	ServiceAccount ServiceAccount `json:"serviceAccount"`
}

ServiceAccountCreateResults are the results of creating a service account.

type ValidAdminCreateArgs

type ValidAdminCreateArgs struct {
	APIKey                        uuid.UUID
	Aud                           uuid.UUID
	UUID                          uuid.UUID
	ValidServiceAccountCreateArgs ValidServiceAccountCreateArgs
}

ValidAdminCreateArgs are the validated arguments for creating an admin.

type ValidEmailLinkCreateArgs

type ValidEmailLinkCreateArgs struct {
	ButtonText   string
	Greeting     string
	LogoClickURL string
	LogoImageURL string
	ServiceName  string
	Subject      string
	SubTitle     string
	Title        string
	ToEmail      *mail.Address
}

ValidEmailLinkCreateArgs are the validated arguments for creating an email link.

type ValidEmailLinkCreateRequest

type ValidEmailLinkCreateRequest struct {
	EmailArgs ValidEmailLinkCreateArgs
	LinkArgs  ValidLinkCreateArgs
}

ValidEmailLinkCreateRequest is the validated request to create an email link.

type ValidJWTCreateArgs

type ValidJWTCreateArgs struct {
	JWTAlg      string
	JWTClaims   json.RawMessage
	JWTLifespan time.Duration
}

ValidJWTCreateArgs are the validated arguments for creating a JWT.

type ValidJWTCreateRequest

type ValidJWTCreateRequest struct {
	JWTCreateArgs ValidJWTCreateArgs
}

ValidJWTCreateRequest is the validated request to create a JWT.

type ValidJWTValidateArgs

type ValidJWTValidateArgs struct {
	JWT string
}

ValidJWTValidateArgs are the validated arguments for validating a JWT.

type ValidJWTValidateRequest

type ValidJWTValidateRequest struct {
	JWTValidateArgs ValidJWTValidateArgs
}

ValidJWTValidateRequest is the validated request to validate a JWT.

type ValidLinkCreateArgs

type ValidLinkCreateArgs struct {
	LinkLifespan     time.Duration
	JWTCreateArgs    ValidJWTCreateArgs
	RedirectQueryKey string
	RedirectURL      *url.URL
}

ValidLinkCreateArgs are the validated arguments for creating a link.

type ValidLinkCreateRequest

type ValidLinkCreateRequest struct {
	LinkArgs ValidLinkCreateArgs
}

ValidLinkCreateRequest is the validated request to create a link.

type ValidServiceAccountCreateArgs

type ValidServiceAccountCreateArgs struct{}

ValidServiceAccountCreateArgs are the validated arguments to create a service account.

type ValidServiceAccountCreateRequest

type ValidServiceAccountCreateRequest struct {
	CreateServiceAccountArgs ValidServiceAccountCreateArgs
}

ValidServiceAccountCreateRequest is the validated request to create a service account.

type Validation

type Validation struct {
	LinkLifespanDefault *jt.JSONType[time.Duration] `json:"linkLifespanDefault"`
	LinkLifespanMax     *jt.JSONType[time.Duration] `json:"maxLinkLifespan"`
	JWTClaimsMaxBytes   uint                        `json:"maxJWTClaimsBytes"`
	JWTLifespanDefault  *jt.JSONType[time.Duration] `json:"jwtLifespanDefault"`
	JWTLifespanMax      *jt.JSONType[time.Duration] `json:"maxJWTLifespan"`
	ServiceNameMinUTF8  uint                        `json:"serviceNameMinUTF8"`
	ServiceNameMaxUTF8  uint                        `json:"serviceNameMaxUTF8"`
	URLMaxLength        uint                        `json:"urlMaxLength"`
}

Validation contains information on how to validate models.

func (Validation) DefaultsAndValidate

func (v Validation) DefaultsAndValidate() (Validation, error)

DefaultsAndValidate implements the jsontype.Config interface.

Jump to

Keyboard shortcuts

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