formationtemplate

package
v0.0.0-...-a423d60 Latest Latest
Warning

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

Go to latest
Published: Jul 4, 2024 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (

	// Now is a function variable that returns the current time. It is used, so we could mock it in the tests.
	Now = time.Now
)

Functions

func NewConverter

func NewConverter(webhook WebhookConverter) *converter

NewConverter creates a new instance of gqlConverter

func NewRepository

func NewRepository(conv EntityConverter) *repository

NewRepository creates a new FormationTemplate repository

func NewService

func NewService(repo FormationTemplateRepository, uidSvc UIDService, converter FormationTemplateConverter, tenantSvc TenantService, webhookRepo WebhookRepository, webhookService WebhookService, labelService labelService) *service

NewService creates a FormationTemplate service

Types

type Entity

type Entity struct {
	ID                     string         `db:"id"`
	Name                   string         `db:"name"`
	ApplicationTypes       string         `db:"application_types"`
	RuntimeTypes           sql.NullString `db:"runtime_types"`
	RuntimeTypeDisplayName sql.NullString `db:"runtime_type_display_name"`
	RuntimeArtifactKind    sql.NullString `db:"runtime_artifact_kind"`
	LeadingProductIDs      sql.NullString `db:"leading_product_ids"`
	TenantID               sql.NullString `db:"tenant_id"`
	SupportsReset          bool           `db:"supports_reset"`
	DiscoveryConsumers     sql.NullString `db:"discovery_consumers"`
	CreatedAt              time.Time      `db:"created_at"`
	UpdatedAt              *time.Time     `db:"updated_at"`
}

Entity represents the formation template entity

type EntityCollection

type EntityCollection []*Entity

EntityCollection is a collection of formation template entities.

func (EntityCollection) Len

func (s EntityCollection) Len() int

Len returns the number of entities in the collection.

type EntityConverter

type EntityConverter interface {
	ToEntity(in *model.FormationTemplate) (*Entity, error)
	FromEntity(entity *Entity) (*model.FormationTemplate, error)
}

EntityConverter converts between the internal model and entity

type FormationConstraintConverter

type FormationConstraintConverter interface {
	MultipleToGraphQL(in []*model.FormationConstraint) []*graphql.FormationConstraint
}

FormationConstraintConverter represents the FormationConstraint converter

type FormationConstraintService

type FormationConstraintService interface {
	ListByFormationTemplateIDs(ctx context.Context, formationTemplateIDs []string) ([][]*model.FormationConstraint, error)
}

FormationConstraintService represents the FormationConstraint service layer

type FormationTemplateConverter

type FormationTemplateConverter interface {
	FromRegisterInputGraphQL(in *graphql.FormationTemplateRegisterInput) (*model.FormationTemplateRegisterInput, error)
	FromUpdateInputGraphQL(in *graphql.FormationTemplateUpdateInput) (*model.FormationTemplateUpdateInput, error)
	ToGraphQL(in *model.FormationTemplate) (*graphql.FormationTemplate, error)
	MultipleToGraphQL(in []*model.FormationTemplate) ([]*graphql.FormationTemplate, error)
	FromModelRegisterInputToModel(in *model.FormationTemplateRegisterInput, id string, tenantID string) *model.FormationTemplate
	FromModelUpdateInputToModel(in *model.FormationTemplateUpdateInput, id string, tenantID string) *model.FormationTemplate
}

FormationTemplateConverter converts between the graphql and model

type FormationTemplateRepository

type FormationTemplateRepository interface {
	Create(ctx context.Context, item *model.FormationTemplate) error
	Get(ctx context.Context, id string) (*model.FormationTemplate, error)
	List(ctx context.Context, filters []*labelfilter.LabelFilter, name *string, tenantID string, pageSize int, cursor string) (*model.FormationTemplatePage, error)
	Update(ctx context.Context, model *model.FormationTemplate) error
	Delete(ctx context.Context, id, tenantID string) error
	ExistsGlobal(ctx context.Context, id string) (bool, error)
}

FormationTemplateRepository represents the FormationTemplate repository layer

type FormationTemplateService

type FormationTemplateService interface {
	Create(ctx context.Context, in *model.FormationTemplateRegisterInput) (string, error)
	Get(ctx context.Context, id string) (*model.FormationTemplate, error)
	List(ctx context.Context, filters []*labelfilter.LabelFilter, name *string, pageSize int, cursor string) (*model.FormationTemplatePage, error)
	Update(ctx context.Context, id string, in *model.FormationTemplateUpdateInput) error
	Delete(ctx context.Context, id string) error
	ListWebhooksForFormationTemplate(ctx context.Context, formationTemplateID string) ([]*model.Webhook, error)
	SetLabel(ctx context.Context, label *model.LabelInput) error
	GetLabel(ctx context.Context, formationTemplateID string, key string) (*model.Label, error)
	DeleteLabel(ctx context.Context, formationTemplateID string, key string) error
	ListLabels(ctx context.Context, formationTemplateID string) (map[string]*model.Label, error)
}

FormationTemplateService represents the FormationTemplate service layer

type Resolver

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

Resolver is the FormationTemplate resolver

func NewResolver

func NewResolver(transact persistence.Transactioner, converter FormationTemplateConverter, formationTemplateSvc FormationTemplateService, webhookConverter WebhookConverter, formationConstraintSvc FormationConstraintService, formationConstraintConverter FormationConstraintConverter) *Resolver

NewResolver creates FormationTemplate resolver

func (*Resolver) CreateFormationTemplate

CreateFormationTemplate creates a FormationTemplate using `in`

func (*Resolver) DeleteFormationTemplate

func (r *Resolver) DeleteFormationTemplate(ctx context.Context, id string) (*graphql.FormationTemplate, error)

DeleteFormationTemplate deletes the FormationTemplate matching ID `id`

func (*Resolver) DeleteFormationTemplateLabel

func (r *Resolver) DeleteFormationTemplateLabel(ctx context.Context, formationTemplateID, key string) (*graphql.Label, error)

DeleteFormationTemplateLabel deletes a formation template label with the specified label key and formation template ID

func (*Resolver) FormationConstraint

func (r *Resolver) FormationConstraint(ctx context.Context, obj *graphql.FormationTemplate) ([]*graphql.FormationConstraint, error)

FormationConstraint retrieves a FormationConstraint for the specified FormationTemplate

func (*Resolver) FormationConstraintsDataLoader

func (r *Resolver) FormationConstraintsDataLoader(keys []dataloader.ParamFormationConstraint) ([][]*graphql.FormationConstraint, []error)

FormationConstraintsDataLoader retrieves Formation Constraints for each FormationTemplate ID in the keys

func (*Resolver) FormationTemplate

func (r *Resolver) FormationTemplate(ctx context.Context, id string) (*graphql.FormationTemplate, error)

FormationTemplate queries the FormationTemplate matching ID `id`

func (*Resolver) FormationTemplates

func (r *Resolver) FormationTemplates(ctx context.Context, filters []*graphql.LabelFilter, first *int, after *graphql.PageCursor) (*graphql.FormationTemplatePage, error)

FormationTemplates pagination lists all FormationTemplates based on `first` and `after`

func (*Resolver) FormationTemplatesByName

func (r *Resolver) FormationTemplatesByName(ctx context.Context, name *string, first *int, after *graphql.PageCursor) (*graphql.FormationTemplatePage, error)

FormationTemplatesByName pagination lists all FormationTemplates filtered by name and based on `first` and `after`

func (*Resolver) Labels

func (r *Resolver) Labels(ctx context.Context, obj *graphql.FormationTemplate, key *string) (graphql.Labels, error)

Labels retrieve all labels for formation template

func (*Resolver) SetFormationTemplateLabel

func (r *Resolver) SetFormationTemplateLabel(ctx context.Context, formationTemplateID string, lblInput graphql.LabelInput) (*graphql.Label, error)

SetFormationTemplateLabel add the provided label key and value to a formation template with the specified ID. If the label does not exist, it will be created. In case the label is already present, it will be updated with the provided value.

func (*Resolver) UpdateFormationTemplate

UpdateFormationTemplate updates the FormationTemplate matching ID `id` using `in`

func (*Resolver) Webhooks

func (r *Resolver) Webhooks(ctx context.Context, obj *graphql.FormationTemplate) ([]*graphql.Webhook, error)

Webhooks queries all webhooks related to the 'obj' Formation Template

type TenantService

type TenantService interface {
	ExtractTenantIDForTenantScopedFormationTemplates(ctx context.Context) (string, error)
}

TenantService is responsible for service-layer tenant operations

type UIDService

type UIDService interface {
	Generate() string
}

UIDService generates UUIDs for new entities

type WebhookConverter

type WebhookConverter interface {
	MultipleToGraphQL(in []*model.Webhook) ([]*graphql.Webhook, error)
	MultipleInputFromGraphQL(in []*graphql.WebhookInput) ([]*model.WebhookInput, error)
}

WebhookConverter converts between the graphql and model

type WebhookRepository

type WebhookRepository interface {
	CreateMany(ctx context.Context, tenant string, items []*model.Webhook) error
}

WebhookRepository is responsible for repo-layer Webhook operations

type WebhookService

type WebhookService interface {
	ListForFormationTemplate(ctx context.Context, tenant, formationTemplateID string) ([]*model.Webhook, error)
}

WebhookService represents the Webhook service layer

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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