plan

package
v1.0.0-beta.208 Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2025 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PlanEventSubsystem   metadata.EventSubsystem = "plan"
	PlanCreateEventName  metadata.EventName      = "plan.created"
	PlanUpdateEventName  metadata.EventName      = "plan.updated"
	PlanDeleteEventName  metadata.EventName      = "plan.deleted"
	PlanPublishEventName metadata.EventName      = "plan.published"
	PlanArchiveEventName metadata.EventName      = "plan.archived"
)
View Source
const (
	OrderAsc  = sortx.OrderAsc
	OrderDesc = sortx.OrderDesc
)

Variables

This section is empty.

Functions

func AssertPlanCreateInputEqual

func AssertPlanCreateInputEqual(t *testing.T, i CreatePlanInput, p Plan)

func AssertPlanEqual

func AssertPlanEqual(t *testing.T, expected, actual Plan)

func AssertPlanPhaseEqual

func AssertPlanPhaseEqual[E interface{ productcatalog.Phase | Phase }](t *testing.T, in E, actual Phase)

func AssertPlanPhasesEqual

func AssertPlanPhasesEqual[E interface{ productcatalog.Phase | Phase }](t *testing.T, expected []E, actual []Phase)

func AssertPlanRateCardsEqual

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

func AssertPlanUpdateInputEqual

func AssertPlanUpdateInputEqual(t *testing.T, i UpdatePlanInput, p Plan)

func AssertRateCardEqual

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

func IsNotFound

func IsNotFound(err error) bool

Types

type ArchivePlanInput

type ArchivePlanInput struct {
	// NamespacedID
	models.NamespacedID

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

func (ArchivePlanInput) Validate

func (i ArchivePlanInput) Validate() error

type CreatePlanInput

type CreatePlanInput struct {
	models.NamespacedModel
	productcatalog.Plan
}

func (CreatePlanInput) Validate

func (i CreatePlanInput) Validate() error

type DeletePlanInput

type DeletePlanInput struct {
	models.NamespacedID
}

func (DeletePlanInput) Validate

func (i DeletePlanInput) Validate() error

type GetPlanInput

type GetPlanInput struct {
	models.NamespacedID

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

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

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

func (GetPlanInput) Validate

func (i GetPlanInput) Validate() error

type ListPlansInput

type ListPlansInput 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

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

	// Keys is the list of keys to filter by.
	Keys []string

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

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

	// Status filter
	Status []productcatalog.PlanStatus

	// Currencies is the list of currencies to filter by.
	Currencies []string
}

func (ListPlansInput) Validate

func (i ListPlansInput) Validate() error

type ListPlansStatusFilter

type ListPlansStatusFilter struct {
	// Active signals that the active plans should be returned.
	Active bool

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

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

type ManagedPhase

type ManagedPhase interface {
	ManagedFields() PhaseManagedFields
}

type ManagedRateCard

type ManagedRateCard interface {
	ManagedFields() RateCardManagedFields
}

type NextPlanInput

type NextPlanInput struct {
	// NamespacedID
	models.NamespacedID

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

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

func (NextPlanInput) Validate

func (i NextPlanInput) 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"
)

type Phase

type Phase struct {
	PhaseManagedFields
	productcatalog.Phase
}

func (Phase) AsProductCatalogPhase

func (p Phase) AsProductCatalogPhase() productcatalog.Phase

func (Phase) Equal

func (p Phase) Equal(v Phase) bool

func (Phase) Validate

func (p Phase) Validate() error

type PhaseManagedFields

type PhaseManagedFields struct {
	models.ManagedModel
	models.NamespacedID

	// PlanID
	PlanID string `json:"planId"`
}

func (PhaseManagedFields) Equal

func (PhaseManagedFields) Validate

func (m PhaseManagedFields) Validate() error

type Plan

type Plan struct {
	models.NamespacedID
	models.ManagedModel

	productcatalog.PlanMeta

	// Phases
	Phases []Phase `json:"phases"`
}

func (Plan) AsProductCatalogPlan

func (p Plan) AsProductCatalogPlan(at time.Time) (productcatalog.Plan, error)

func (Plan) MarshalJSON

func (p Plan) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler

func (*Plan) UnmarshalJSON

func (p *Plan) UnmarshalJSON(data []byte) error

UnmarshalJSON implements json.Unmarshaler

func (Plan) Validate

func (p Plan) Validate() error

type PlanArchiveEvent

type PlanArchiveEvent struct {
	Plan   *Plan   `json:"plan"`
	UserID *string `json:"userId,omitempty"`
}

PlanArchiveEvent is an event that is emitted when a plan is archived

func NewPlanArchiveEvent

func NewPlanArchiveEvent(ctx context.Context, plan *Plan) PlanArchiveEvent

NewPlanArchiveEvent creates a new plan archive event

func (PlanArchiveEvent) EventMetadata

func (e PlanArchiveEvent) EventMetadata() metadata.EventMetadata

func (PlanArchiveEvent) EventName

func (e PlanArchiveEvent) EventName() string

func (PlanArchiveEvent) Validate

func (e PlanArchiveEvent) Validate() error

type PlanCreateEvent

type PlanCreateEvent struct {
	Plan   *Plan   `json:"plan"`
	UserID *string `json:"userId,omitempty"`
}

PlanCreateEvent is an event that is emitted when a plan is created

func NewPlanCreateEvent

func NewPlanCreateEvent(ctx context.Context, plan *Plan) PlanCreateEvent

NewPlanCreateEvent creates a new plan create event

func (PlanCreateEvent) EventMetadata

func (e PlanCreateEvent) EventMetadata() metadata.EventMetadata

func (PlanCreateEvent) EventName

func (e PlanCreateEvent) EventName() string

func (PlanCreateEvent) Validate

func (e PlanCreateEvent) Validate() error

type PlanDeleteEvent

type PlanDeleteEvent struct {
	Plan   *Plan   `json:"plan"`
	UserID *string `json:"userId,omitempty"`
}

PlanDeleteEvent is an event that is emitted when a plan is deleted

func NewPlanDeleteEvent

func NewPlanDeleteEvent(ctx context.Context, plan *Plan) PlanDeleteEvent

NewPlanDeleteEvent creates a new plan delete event

func (PlanDeleteEvent) EventMetadata

func (e PlanDeleteEvent) EventMetadata() metadata.EventMetadata

func (PlanDeleteEvent) EventName

func (e PlanDeleteEvent) EventName() string

func (PlanDeleteEvent) Validate

func (e PlanDeleteEvent) Validate() error

type PlanPublishEvent

type PlanPublishEvent struct {
	Plan   *Plan   `json:"plan"`
	UserID *string `json:"userId,omitempty"`
}

PlanPublishEvent is an event that is emitted when a plan is published

func NewPlanPublishEvent

func NewPlanPublishEvent(ctx context.Context, plan *Plan) PlanPublishEvent

NewPlanPublishEvent creates a new plan publish event

func (PlanPublishEvent) EventMetadata

func (e PlanPublishEvent) EventMetadata() metadata.EventMetadata

func (PlanPublishEvent) EventName

func (e PlanPublishEvent) EventName() string

func (PlanPublishEvent) Validate

func (e PlanPublishEvent) Validate() error

type PlanUpdateEvent

type PlanUpdateEvent struct {
	Plan   *Plan   `json:"plan"`
	UserID *string `json:"userId,omitempty"`
}

PlanUpdateEvent is an event that is emitted when a plan is updated

func NewPlanUpdateEvent

func NewPlanUpdateEvent(ctx context.Context, plan *Plan) PlanUpdateEvent

NewPlanUpdateEvent creates a new plan update event

func (PlanUpdateEvent) EventMetadata

func (e PlanUpdateEvent) EventMetadata() metadata.EventMetadata

func (PlanUpdateEvent) EventName

func (e PlanUpdateEvent) EventName() string

func (PlanUpdateEvent) Validate

func (e PlanUpdateEvent) Validate() error

type PublishPlanInput

type PublishPlanInput struct {
	models.NamespacedID

	// EffectivePeriod
	productcatalog.EffectivePeriod
}

func (PublishPlanInput) Validate

func (i PublishPlanInput) 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

	// PhaseID
	PhaseID string `json:"phaseId"`
}

func (RateCardManagedFields) Equal

func (RateCardManagedFields) Validate

func (m RateCardManagedFields) Validate() error

type Repository

type Repository interface {
	entutils.TxCreator

	ListPlans(ctx context.Context, params ListPlansInput) (pagination.PagedResponse[Plan], error)
	CreatePlan(ctx context.Context, params CreatePlanInput) (*Plan, error)
	DeletePlan(ctx context.Context, params DeletePlanInput) error
	GetPlan(ctx context.Context, params GetPlanInput) (*Plan, error)
	UpdatePlan(ctx context.Context, params UpdatePlanInput) (*Plan, error)
}

type Service

type Service interface {
	ListPlans(ctx context.Context, params ListPlansInput) (pagination.PagedResponse[Plan], error)
	CreatePlan(ctx context.Context, params CreatePlanInput) (*Plan, error)
	DeletePlan(ctx context.Context, params DeletePlanInput) error
	GetPlan(ctx context.Context, params GetPlanInput) (*Plan, error)
	UpdatePlan(ctx context.Context, params UpdatePlanInput) (*Plan, error)
	PublishPlan(ctx context.Context, params PublishPlanInput) (*Plan, error)
	ArchivePlan(ctx context.Context, params ArchivePlanInput) (*Plan, error)
	NextPlan(ctx context.Context, params NextPlanInput) (*Plan, error)
}

type UpdatePlanInput

type UpdatePlanInput struct {
	models.NamespacedID

	// EffectivePeriod
	productcatalog.EffectivePeriod

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

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

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

	// Phases
	Phases *[]productcatalog.Phase `json:"phases"`

	// Alignment
	productcatalog.AlignmentUpdate
}

func (UpdatePlanInput) Equal

func (i UpdatePlanInput) Equal(p Plan) bool

func (UpdatePlanInput) Validate

func (i UpdatePlanInput) Validate() error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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