addon

package
v1.0.0-beta.231 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2026 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AddonEventSubsystem   metadata.EventSubsystem = "addon"
	AddonCreateEventName  metadata.EventName      = "addon.created"
	AddonUpdateEventName  metadata.EventName      = "addon.updated"
	AddonDeleteEventName  metadata.EventName      = "addon.deleted"
	AddonPublishEventName metadata.EventName      = "addon.published"
	AddonArchiveEventName metadata.EventName      = "addon.archived"
)
View Source
const (
	OrderAsc  = sortx.OrderAsc
	OrderDesc = sortx.OrderDesc
)

Variables

This section is empty.

Functions

func AssertAddonCreateInputEqual

func AssertAddonCreateInputEqual(t *testing.T, i CreateAddonInput, a Addon)

func AssertAddonEqual

func AssertAddonEqual(t *testing.T, expected, actual Addon)

func AssertAddonRateCardsEqual

func AssertAddonRateCardsEqual(t *testing.T, r1, r2 productcatalog.RateCards)

func AssertAddonUpdateInputEqual

func AssertAddonUpdateInputEqual(t *testing.T, i UpdateAddonInput, a Addon)

func AssertRateCardEqual

func AssertRateCardEqual(t *testing.T, r1, r2 productcatalog.RateCard)

func HasAddonStatus

func HasAddonStatus(statuses ...productcatalog.AddonStatus) models.ValidatorFunc[Addon]

func IsAddonDeleted

func IsAddonDeleted(at time.Time) models.ValidatorFunc[Addon]

func IsNotFound

func IsNotFound(err error) bool

Types

type Addon

type Addon struct {
	models.NamespacedID
	models.ManagedModel

	productcatalog.AddonMeta

	// RateCards
	RateCards RateCards `json:"rateCards"`

	// Plans contains the list of Plans assigned to this Addon. It is only provided if the Addon was fetched
	// with Plans being expanded.
	Plans *[]Plan `json:"plans,omitempty"`
}

func (Addon) AsProductCatalogAddon

func (a Addon) AsProductCatalogAddon() productcatalog.Addon

func (Addon) Validate

func (a Addon) Validate() error

func (Addon) ValidateWith

func (a Addon) ValidateWith(validators ...models.ValidatorFunc[Addon]) error

type AddonArchiveEvent

type AddonArchiveEvent struct {
	Addon  *Addon  `json:"addon"`
	UserID *string `json:"userId,omitempty"`
}

AddonArchiveEvent is an event that is emitted when an Addon is archived

func NewAddonArchiveEvent

func NewAddonArchiveEvent(ctx context.Context, Addon *Addon) AddonArchiveEvent

NewAddonArchiveEvent creates a new Addon archive event

func (AddonArchiveEvent) EventMetadata

func (e AddonArchiveEvent) EventMetadata() metadata.EventMetadata

func (AddonArchiveEvent) EventName

func (e AddonArchiveEvent) EventName() string

func (AddonArchiveEvent) Validate

func (e AddonArchiveEvent) Validate() error

type AddonCreateEvent

type AddonCreateEvent struct {
	Addon  *Addon  `json:"addon"`
	UserID *string `json:"userId,omitempty"`
}

AddonCreateEvent is an event that is emitted when an Addon is created

func NewAddonCreateEvent

func NewAddonCreateEvent(ctx context.Context, addon *Addon) AddonCreateEvent

NewAddonCreateEvent creates a new Addon create event

func (AddonCreateEvent) EventMetadata

func (e AddonCreateEvent) EventMetadata() metadata.EventMetadata

func (AddonCreateEvent) EventName

func (e AddonCreateEvent) EventName() string

func (AddonCreateEvent) Validate

func (e AddonCreateEvent) Validate() error

type AddonDeleteEvent

type AddonDeleteEvent struct {
	Addon  *Addon  `json:"addon"`
	UserID *string `json:"userId,omitempty"`
}

AddonDeleteEvent is an event that is emitted when an Addon is deleted

func NewAddonDeleteEvent

func NewAddonDeleteEvent(ctx context.Context, addon *Addon) AddonDeleteEvent

NewAddonDeleteEvent creates a new Addon delete event

func (AddonDeleteEvent) EventMetadata

func (e AddonDeleteEvent) EventMetadata() metadata.EventMetadata

func (AddonDeleteEvent) EventName

func (e AddonDeleteEvent) EventName() string

func (AddonDeleteEvent) Validate

func (e AddonDeleteEvent) Validate() error

type AddonPublishEvent

type AddonPublishEvent struct {
	Addon  *Addon  `json:"addon"`
	UserID *string `json:"userId,omitempty"`
}

AddonPublishEvent is an event that is emitted when an Addon is published

func NewAddonPublishEvent

func NewAddonPublishEvent(ctx context.Context, Addon *Addon) AddonPublishEvent

NewAddonPublishEvent creates a new Addon publish event

func (AddonPublishEvent) EventMetadata

func (e AddonPublishEvent) EventMetadata() metadata.EventMetadata

func (AddonPublishEvent) EventName

func (e AddonPublishEvent) EventName() string

func (AddonPublishEvent) Validate

func (e AddonPublishEvent) Validate() error

type AddonUpdateEvent

type AddonUpdateEvent struct {
	Addon  *Addon  `json:"addon"`
	UserID *string `json:"userId,omitempty"`
}

AddonUpdateEvent is an event that is emitted when an Addon is updated

func NewAddonUpdateEvent

func NewAddonUpdateEvent(ctx context.Context, addon *Addon) AddonUpdateEvent

NewAddonUpdateEvent creates a new Addon update event

func (AddonUpdateEvent) EventMetadata

func (e AddonUpdateEvent) EventMetadata() metadata.EventMetadata

func (AddonUpdateEvent) EventName

func (e AddonUpdateEvent) EventName() string

func (AddonUpdateEvent) Validate

func (e AddonUpdateEvent) Validate() error

type ArchiveAddonInput

type ArchiveAddonInput struct {
	// NamespacedID
	models.NamespacedID

	// EffectiveFrom defines the time from the Addon is going to be unpublished.
	EffectiveTo time.Time `json:"effectiveTo,omitempty"`

	// RejectUnitConfig rejects the operation when the target add-on carries a unit_config
	// conversion. The v1 API cannot represent it, so v1 handlers set this; v3 leaves it false.
	RejectUnitConfig bool
}

func (ArchiveAddonInput) Validate

func (i ArchiveAddonInput) Validate() error

type CreateAddonInput

type CreateAddonInput struct {
	models.NamespacedModel
	productcatalog.Addon
	// contains filtered or unexported fields
}

func (CreateAddonInput) Validate

func (i CreateAddonInput) Validate() error

type DeleteAddonInput

type DeleteAddonInput struct {
	models.NamespacedID
}

func (DeleteAddonInput) Validate

func (i DeleteAddonInput) Validate() error

type ExpandFields

type ExpandFields struct {
	PlanAddons bool `json:"plans,omitempty"`
}

type GetAddonInput

type GetAddonInput struct {
	models.NamespacedID

	// Key is the unique key for Addon.
	Key string `json:"key,omitempty"`

	// Version is the version of the Addon.
	// If not set the latest version is assumed.
	Version int `json:"version,omitempty"`

	// IncludeLatest defines whether return the latest version regardless of its AddonStatus or with ActiveStatus only if
	// Version is not set.
	IncludeLatest bool `json:"includeLatest,omitempty"`

	Expand ExpandFields `json:"expand,omitempty"`
}

func (GetAddonInput) Validate

func (i GetAddonInput) Validate() error

type ListAddonsInput

type ListAddonsInput struct {
	// Page is the pagination parameters.
	// TODO: make it optional.
	pagination.Page

	// OrderBy is the field to order by.
	OrderBy OrderBy

	// Order is the order direction.
	Order sortx.Order

	// Namespaces is the list of namespaces to filter by.
	Namespaces []string

	// KeyVersions is the map of keys to versions to filter by.
	KeyVersions map[string][]int

	// IncludeDeleted defines whether to include deleted Addons.
	IncludeDeleted bool

	// Status filter
	Status []productcatalog.AddonStatus

	// Filters
	ID       *filter.FilterULID
	Key      *filter.FilterString
	Name     *filter.FilterString
	Currency *filter.FilterString

	// ExcludeUnitConfig omits add-ons carrying a unit_config conversion on any of their rate cards.
	ExcludeUnitConfig bool
}

func (ListAddonsInput) Validate

func (i ListAddonsInput) Validate() error

type ListAddonsStatusFilter

type ListAddonsStatusFilter struct {
	// Active signals that the active Addons should be returned.
	Active bool

	// Draft signals that the draft Addons should be returned.
	Draft bool

	// Archived signals that the archived Addons should be returned.
	Archived bool
}

type ManagedRateCard

type ManagedRateCard interface {
	ManagedFields() RateCardManagedFields
}

type NextAddonInput

type NextAddonInput struct {
	// NamespacedID
	models.NamespacedID

	// Key is the unique key for Addon.
	Key string `json:"key,omitempty"`

	// Version is the version of the Addon.
	// If not set the latest version is assumed.
	Version int `json:"version,omitempty"`
}

func (NextAddonInput) Validate

func (i NextAddonInput) Validate() error

type NotFoundError

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

func NewNotFoundError

func NewNotFoundError(e NotFoundErrorParams) *NotFoundError

func (*NotFoundError) Error

func (e *NotFoundError) Error() string

func (*NotFoundError) Unwrap

func (e *NotFoundError) Unwrap() error

type NotFoundErrorParams

type NotFoundErrorParams struct {
	Namespace string
	ID        string
	Key       string
	Version   int
}

type OrderBy

type OrderBy string
const (
	OrderByID        OrderBy = "id"
	OrderByKey       OrderBy = "key"
	OrderByVersion   OrderBy = "version"
	OrderByCreatedAt OrderBy = "created_at"
	OrderByUpdatedAt OrderBy = "updated_at"
	OrderByName      OrderBy = "name"
)

func (OrderBy) Validate

func (f OrderBy) Validate() error

func (OrderBy) Values

func (f OrderBy) Values() []OrderBy

type Plan

Plan stores the Addon specific representation of planaddon.PlanAddon.

func (Plan) Validate

func (p Plan) Validate() error

type PublishAddonInput

type PublishAddonInput struct {
	models.NamespacedID

	// AddonEffectivePeriod
	productcatalog.EffectivePeriod

	// RejectUnitConfig rejects the operation when the target add-on carries a unit_config
	// conversion. The v1 API cannot represent it, so v1 handlers set this; v3 leaves it false.
	RejectUnitConfig bool
}

func (PublishAddonInput) Validate

func (i PublishAddonInput) Validate() error

type RateCard

type RateCard struct {
	productcatalog.RateCard
	RateCardManagedFields
}

func (*RateCard) Equal

func (r *RateCard) Equal(v productcatalog.RateCard) bool

func (*RateCard) ManagedFields

func (r *RateCard) ManagedFields() RateCardManagedFields

func (*RateCard) MarshalJSON

func (r *RateCard) MarshalJSON() ([]byte, error)

func (*RateCard) UnmarshalJSON

func (r *RateCard) UnmarshalJSON(b []byte) error

func (*RateCard) Validate

func (r *RateCard) Validate() error

type RateCardManagedFields

type RateCardManagedFields struct {
	models.ManagedModel
	models.NamespacedID

	// AddonID defines the Addon the RateCard assigned to.
	AddonID string `json:"addonId"`
}

func (RateCardManagedFields) Equal

func (RateCardManagedFields) Validate

func (m RateCardManagedFields) Validate() error

type RateCards

type RateCards []RateCard

func (RateCards) AsProductCatalogRateCards

func (c RateCards) AsProductCatalogRateCards() productcatalog.RateCards

func (RateCards) At

func (c RateCards) At(idx int) RateCard

func (RateCards) Equal

func (c RateCards) Equal(v RateCards) bool

func (RateCards) SingleBillingCadence

func (c RateCards) SingleBillingCadence() bool

func (RateCards) Validate

func (c RateCards) Validate() error

type Repository

type Repository interface {
	entutils.TxCreator

	ListAddons(ctx context.Context, params ListAddonsInput) (pagination.Result[Addon], error)
	CreateAddon(ctx context.Context, params CreateAddonInput) (*Addon, error)
	DeleteAddon(ctx context.Context, params DeleteAddonInput) error
	GetAddon(ctx context.Context, params GetAddonInput) (*Addon, error)
	UpdateAddon(ctx context.Context, params UpdateAddonInput) (*Addon, error)
}

type Service

type Service interface {
	ListAddons(ctx context.Context, params ListAddonsInput) (pagination.Result[Addon], error)
	CreateAddon(ctx context.Context, params CreateAddonInput) (*Addon, error)
	DeleteAddon(ctx context.Context, params DeleteAddonInput) error
	GetAddon(ctx context.Context, params GetAddonInput) (*Addon, error)
	UpdateAddon(ctx context.Context, params UpdateAddonInput) (*Addon, error)
	PublishAddon(ctx context.Context, params PublishAddonInput) (*Addon, error)
	ArchiveAddon(ctx context.Context, params ArchiveAddonInput) (*Addon, error)
	NextAddon(ctx context.Context, params NextAddonInput) (*Addon, error)
}

type UpdateAddonInput

type UpdateAddonInput struct {
	models.NamespacedID

	// EffectivePeriod
	productcatalog.EffectivePeriod

	// Name
	Name *string `json:"name"`

	// Description
	Description *string `json:"description,omitempty"`

	// Metadata
	Metadata *models.Metadata `json:"metadata,omitempty"`

	// Metadata
	Annotations *models.Annotations `json:"annotations,omitempty"`

	// InstanceType
	InstanceType *productcatalog.AddonInstanceType `json:"instanceType,omitempty"`

	// RateCards
	RateCards *productcatalog.RateCards `json:"rateCards,omitempty"`

	// RejectUnitConfig makes mutation validation reject an add-on that carries a unit_config
	// conversion on any rate card. The v1 API cannot represent unit_config, and v1 update
	// rewrites rate cards from a body that has no such field, so proceeding would silently
	// drop the conversion. v1 handlers set this; v3 leaves it false.
	RejectUnitConfig bool
	// contains filtered or unexported fields
}

func (UpdateAddonInput) Equal

func (i UpdateAddonInput) Equal(p Addon) bool

func (UpdateAddonInput) Validate

func (i UpdateAddonInput) Validate() error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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