subject

package
v1.0.0-beta.220 Latest Latest
Warning

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

Go to latest
Published: Aug 17, 2025 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Adapter

type Adapter interface {
	Create(ctx context.Context, input CreateInput) (Subject, error)
	Update(ctx context.Context, input UpdateInput) (Subject, error)
	GetByIdOrKey(ctx context.Context, namespace string, idOrKey string) (Subject, error)
	GetByKey(ctx context.Context, key models.NamespacedKey) (Subject, error)
	GetById(ctx context.Context, id models.NamespacedID) (Subject, error)
	List(ctx context.Context, namespace string, params ListParams) (pagination.PagedResponse[Subject], error)
	Delete(ctx context.Context, id models.NamespacedID) error

	entutils.TxCreator
}

type CreateInput

type CreateInput struct {
	Namespace        string
	Key              string
	DisplayName      *string
	StripeCustomerId *string
	Metadata         *map[string]interface{}
}

CreateInput is the input for creating a subject.

func (CreateInput) Validate

func (i CreateInput) Validate() error

type GetSubjectAdapterInput

type GetSubjectAdapterInput struct {
	Namespace string
	ID        string
	Key       string
}

func (GetSubjectAdapterInput) Validate

func (i GetSubjectAdapterInput) Validate() error

type ListParams

type ListParams struct {
	Keys   []string
	Search string
	Page   pagination.Page
	SortBy ListSortBy
}

type ListSortBy

type ListSortBy string
const (
	ListSortByKeyAsc          ListSortBy = "key_asc"
	ListSortByKeyDesc         ListSortBy = "key_desc"
	ListSortByDisplayNameAsc  ListSortBy = "display_name_asc"
	ListSortByDisplayNameDesc ListSortBy = "display_name_desc"
)

type OptionalNullable

type OptionalNullable[T any] struct {
	Value *T
	IsSet bool
}

FIXME: this pattern is unique to this adapter, and should not be reused anywhere else OptionalNullable is a helper to differentiate between a nil value and a value that is not set.

type Service

type Service interface {
	models.ServiceHooks[Subject]

	Create(ctx context.Context, input CreateInput) (Subject, error)
	Update(ctx context.Context, input UpdateInput) (Subject, error)

	GetByKey(ctx context.Context, key models.NamespacedKey) (Subject, error)
	GetById(ctx context.Context, id models.NamespacedID) (Subject, error)

	// GetByIdOrKey is a convenience method that gets a subject by ID or key (please use GetById or GetByKey instead if possible)
	GetByIdOrKey(ctx context.Context, orgId string, idOrKey string) (Subject, error)
	List(ctx context.Context, orgId string, params ListParams) (pagination.PagedResponse[Subject], error)
	Delete(ctx context.Context, id models.NamespacedID) error
}

type Subject

type Subject struct {
	Namespace   string
	Id          string
	Key         string
	DisplayName *string
	Metadata    map[string]interface{}
	// Use customer application entity instead
	StripeCustomerId *string
}

Subject represents a subject in the system.

func (Subject) Validate

func (s Subject) Validate() error

type SubjectKey

type SubjectKey struct {
	Key string `json:"key"`
}

SubjectKey is key only version of Subject Used in in entitlements events to reduce payload size

func (SubjectKey) Validate

func (s SubjectKey) Validate() error

type UpdateInput

type UpdateInput struct {
	ID               string
	Namespace        string
	DisplayName      OptionalNullable[string]
	StripeCustomerId OptionalNullable[string]
	Metadata         OptionalNullable[map[string]interface{}]
}

UpdateInput is the input for updating a subject.

func (UpdateInput) Validate

func (i UpdateInput) Validate() error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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