subscription

package
v0.0.0-...-6d13c91 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2024 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// SubdomainLabelKey is the key of the tenant label for subdomain.
	SubdomainLabelKey = "subdomain"
	// RegionPrefix a prefix to be trimmed from the region placeholder value when creating an app from template
	RegionPrefix = "cf-"
	// SubscriptionsLabelKey is the key of the subscriptions label, that stores the ids of created instances.
	SubscriptionsLabelKey = "subscriptions"
	// PreviousSubscriptionID represents a previous subscription id. This is needed, because before introducing this change there might be subscriptions which we don't know that they existed.
	PreviousSubscriptionID = "00000000-0000-0000-0000-000000000000"
)

Variables

This section is empty.

Functions

func NewService

func NewService(runtimeSvc RuntimeService, runtimeCtxSvc RuntimeCtxService, tenantSvc TenantService, labelSvc LabelService, appTemplateSvc ApplicationTemplateService, appConv ApplicationConverter, appTemplateConv ApplicationTemplateConverter, appSvc ApplicationService, uidService uidService, systemFieldDiscoveryEngine SystemFieldDiscoveryEngine,
	globalSubaccountIDLabelKey, subscriptionLabelKey, runtimeTypeLabelKey, subscriptionProviderLabelKey string) *service

NewService returns a new object responsible for service-layer Subscription operations.

Types

type ApplicationConverter

type ApplicationConverter interface {
	ToGraphQL(in *model.Application) *graphql.Application
	CreateRegisterInputJSONToGQL(in string) (graphql.ApplicationRegisterInput, error)
	CreateInputFromGraphQL(ctx context.Context, in graphql.ApplicationRegisterInput) (model.ApplicationRegisterInput, error)
}

ApplicationConverter is converting graphql and model Applications

type ApplicationService

type ApplicationService interface {
	CreateFromTemplate(ctx context.Context, in model.ApplicationRegisterInput, appTemplateID *string, systemFieldDiscoveryLabelIsTrue bool) (string, error)
	ListAll(ctx context.Context) ([]*model.Application, error)
	Delete(ctx context.Context, id string) error
}

ApplicationService is responsible for Application operations

type ApplicationTemplateConverter

type ApplicationTemplateConverter interface {
	ApplicationFromTemplateInputFromGraphQL(appTemplate *model.ApplicationTemplate, in graphql.ApplicationFromTemplateInput) (model.ApplicationFromTemplateInput, error)
}

ApplicationTemplateConverter missing godoc

type ApplicationTemplateService

type ApplicationTemplateService interface {
	Exists(ctx context.Context, id string) (bool, error)
	GetByFilters(ctx context.Context, filter []*labelfilter.LabelFilter) (*model.ApplicationTemplate, error)
	PrepareApplicationCreateInputJSON(appTemplate *model.ApplicationTemplate, values model.ApplicationFromTemplateInputValues) (string, error)
	GetLabel(ctx context.Context, appTemplateID string, key string) (*model.Label, error)
}

ApplicationTemplateService is responsible for Application Template operations

type Config

type Config struct {
	ProviderLabelKey           string `envconfig:"APP_SUBSCRIPTION_PROVIDER_LABEL_KEY,default=subscriptionProviderId"`
	GlobalSubaccountIDLabelKey string `envconfig:"APP_GLOBAL_SUBACCOUNT_ID_LABEL_KEY,default=global_subaccount_id"`
	SubscriptionLabelKey       string `envconfig:"APP_SUBSCRIPTION_LABEL_KEY,default=subscription"`
	RuntimeTypeLabelKey        string `envconfig:"APP_RUNTIME_TYPE_LABEL_KEY,default=runtimeType"`
}

Config is configuration for the tenant subscription flow

type DependentServiceInstanceInfo

type DependentServiceInstanceInfo struct {
	AppID                string `json:"appId"`
	AppName              string `json:"appName"`
	ProviderSubaccountID string `json:"providerSubaccountId"`
}

DependentServiceInstanceInfo represents the dependent service instance info object in a subscription payload.

type DependentServiceInstancesInfo

type DependentServiceInstancesInfo struct {
	Instances []DependentServiceInstanceInfo `json:"dependentServiceInstancesInfo"`
}

DependentServiceInstancesInfo represents collection of all dependent service instance info objects in a subscription payload.

type LabelService

type LabelService interface {
	GetLabel(ctx context.Context, tenant string, labelInput *model.LabelInput) (*model.Label, error)
	CreateLabel(ctx context.Context, tenant, id string, labelInput *model.LabelInput) error
	UpdateLabel(ctx context.Context, tenant, id string, labelInput *model.LabelInput) error
	UpsertLabel(ctx context.Context, tenant string, labelInput *model.LabelInput) error
	GetByKey(ctx context.Context, tenant string, objectType model.LabelableObject, objectID, key string) (*model.Label, error)
}

LabelService is responsible updating already existing labels, and their label definitions.

type Resolver

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

Resolver is an object responsible for resolver-layer Subscription operations.

func NewResolver

func NewResolver(transact persistence.Transactioner, subscriptionSvc SubscriptionService, ordAggregatorClientConfig apiclient.OrdAggregatorClientConfig) *Resolver

NewResolver returns a new object responsible for resolver-layer Subscription operations.

func (*Resolver) SubscribeTenant

func (r *Resolver) SubscribeTenant(ctx context.Context, providerID, subaccountTenantID, providerSubaccountID, consumerTenantID, region, subscriptionAppName string, subscriptionPayload string) (bool, error)

SubscribeTenant subscribes tenant to runtime or application template labeled with `providerID` and `region`

func (*Resolver) UnsubscribeTenant

func (r *Resolver) UnsubscribeTenant(ctx context.Context, providerID, subaccountTenantID, providerSubaccountID, consumerTenantID, region, subscriptionPayload string) (bool, error)

UnsubscribeTenant unsubscribes tenant from runtime or application template labeled with `providerID` and `region`

type RuntimeCtxService

type RuntimeCtxService interface {
	Create(ctx context.Context, in model.RuntimeContextInput) (string, error)
	Delete(ctx context.Context, id string) error
	ListByFilter(ctx context.Context, runtimeID string, filter []*labelfilter.LabelFilter, pageSize int, cursor string) (*model.RuntimeContextPage, error)
}

RuntimeCtxService provide functionality to interact with the runtime contexts(create, list, delete).

type RuntimeService

type RuntimeService interface {
	GetByFiltersGlobal(ctx context.Context, filters []*labelfilter.LabelFilter) (*model.Runtime, error)
	GetByFilters(ctx context.Context, filters []*labelfilter.LabelFilter) (*model.Runtime, error)
}

RuntimeService is responsible for Runtime operations

type SubscriptionService

type SubscriptionService interface {
	SubscribeTenantToRuntime(ctx context.Context, providerID, subaccountTenantID, providerSubaccountID, consumerTenantID, region, subscriptionAppName, subscriptionID string) (bool, error)
	UnsubscribeTenantFromRuntime(ctx context.Context, providerID, subaccountTenantID, providerSubaccountID, consumerTenantID, region, subscriptionID string) (bool, error)
	SubscribeTenantToApplication(ctx context.Context, providerID, subaccountTenantID, consumerTenantID, providerSubaccountID, region, subscribedAppName, subscriptionID string, subscriptionPayload string) (bool, string, string, error)
	UnsubscribeTenantFromApplication(ctx context.Context, providerID, subaccountTenantID, providerSubaccountID, consumerTenantID, region, subscriptionID string) (bool, error)
	DetermineSubscriptionFlow(ctx context.Context, providerID, region string) (resource.Type, error)
}

SubscriptionService responsible for service-layer Subscription operations

type SystemFieldDiscoveryEngine

type SystemFieldDiscoveryEngine interface {
	EnrichApplicationWebhookIfNeeded(ctx context.Context, appCreateInputModel model.ApplicationRegisterInput, systemFieldDiscovery bool, region, subaccountID, appTemplateName, appName string) ([]*model.WebhookInput, bool)
	CreateLabelForApplicationWebhook(ctx context.Context, appID string) error
}

SystemFieldDiscoveryEngine is responsible for system field discovery operations

type TenantService

type TenantService interface {
	GetLowestOwnerForResource(ctx context.Context, resourceType resource.Type, objectID string) (string, error)
	GetInternalTenant(ctx context.Context, externalTenant string) (string, error)
}

TenantService provides functionality for retrieving, and creating tenants.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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