Documentation
¶
Index ¶
- Constants
- func NewSubscriber(directorClient DirectorGraphQLClient, provisioner TenantProvisioner) *subscriber
- func NewTenantFetcherHTTPHandler(fetcher TenantFetcher, config HandlerConfig) *handler
- func NewTenantProvisioner(directorClient DirectorGraphQLClient, tenantConverter TenantConverter, ...) *provisioner
- func NewTenantsHTTPHandler(subscriber TenantSubscriber, config HandlerConfig) *handler
- type Dependency
- type DirectorGraphQLClient
- type HandlerConfig
- type TenantConverter
- type TenantFetcher
- type TenantProviderConfig
- type TenantProvisioner
- type TenantSubscriber
- type TenantSubscriptionRequest
Constants ¶
const (
// InternalServerError message
InternalServerError = "Internal Server Error"
)
Variables ¶
This section is empty.
Functions ¶
func NewSubscriber ¶
func NewSubscriber(directorClient DirectorGraphQLClient, provisioner TenantProvisioner) *subscriber
NewSubscriber creates new subscriber
func NewTenantFetcherHTTPHandler ¶
func NewTenantFetcherHTTPHandler(fetcher TenantFetcher, config HandlerConfig) *handler
NewTenantFetcherHTTPHandler returns a new HTTP handler, responsible for creation of on-demand tenants.
func NewTenantProvisioner ¶
func NewTenantProvisioner(directorClient DirectorGraphQLClient, tenantConverter TenantConverter, tenantProvider string) *provisioner
NewTenantProvisioner returns a TenantProvisioner initialized with the provided TenantService, and tenant provider. All tenants, created by the provisioner, besides the Customer ones, will have the value of tenantProvider as a provider.
func NewTenantsHTTPHandler ¶
func NewTenantsHTTPHandler(subscriber TenantSubscriber, config HandlerConfig) *handler
NewTenantsHTTPHandler returns a new HTTP handler, responsible for creation and deletion of regional and non-regional tenants.
Types ¶
type Dependency ¶
type Dependency struct {
Xsappname string `json:"xsappname"`
}
Dependency contains the xsappname to be used in the dependencies callback
type DirectorGraphQLClient ¶
type DirectorGraphQLClient interface { WriteTenants(context.Context, []graphql.BusinessTenantMappingInput) error DeleteTenants(ctx context.Context, tenants []graphql.BusinessTenantMappingInput) error UpdateTenant(ctx context.Context, id string, tenant graphql.BusinessTenantMappingInput) error SubscribeTenant(ctx context.Context, providerID, subaccountID, providerSubaccountID, consumerTenantID, region, subscriptionProviderAppName, subscriptionPayload string) error UnsubscribeTenant(ctx context.Context, providerID, subaccountID, providerSubaccountID, consumerTenantID, region, subscriptionPayload string) error ExistsTenantByExternalID(ctx context.Context, tenantID string) (bool, error) }
DirectorGraphQLClient expects graphql implementation
type HandlerConfig ¶
type HandlerConfig struct { TenantWithParentOnDemandHandlerEndpoint string `envconfig:"APP_TENANT_WITH_PARENT_ON_DEMAND_HANDLER_ENDPOINT,default=/v1/fetch/{parentTenantId}/{tenantId}"` TenantWithoutParentOnDemandHandlerEndpoint string `envconfig:"APP_TENANT_WITHOUT_PARENT_ON_DEMAND_HANDLER_ENDPOINT,default=/v1/fetch/{tenantId}"` RegionalHandlerEndpoint string `envconfig:"APP_REGIONAL_HANDLER_ENDPOINT,default=/v1/regional/{region}/callback/{tenantId}"` DependenciesEndpoint string `envconfig:"APP_REGIONAL_DEPENDENCIES_ENDPOINT,default=/v1/regional/{region}/dependencies"` TenantPathParam string `envconfig:"APP_TENANT_PATH_PARAM,default=tenantId"` ParentTenantPathParam string `envconfig:"APP_PARENT_TENANT_PATH_PARAM,default=parentTenantId"` RegionPathParam string `envconfig:"APP_REGION_PATH_PARAM,default=region"` XsAppNamePathParam string `envconfig:"APP_TENANT_FETCHER_XSAPPNAME_PATH,default=xsappname"` OmitDependenciesCallbackParam string `envconfig:"APP_TENANT_FETCHER_OMIT_PARAM_NAME"` OmitDependenciesCallbackParamValue string `envconfig:"APP_TENANT_FETCHER_OMIT_PARAM_VALUE"` Database persistence.DatabaseConfig DirectorGraphQLEndpoint string `envconfig:"APP_DIRECTOR_GRAPHQL_ENDPOINT"` ClientTimeout time.Duration `envconfig:"default=60s"` HTTPClientSkipSslValidation bool `envconfig:"APP_HTTP_CLIENT_SKIP_SSL_VALIDATION,default=false"` TenantProviderConfig MetricsPushEndpoint string `envconfig:"optional,APP_METRICS_PUSH_ENDPOINT"` TenantDependenciesConfigPath string `envconfig:"APP_TENANT_REGION_DEPENDENCIES_CONFIG_PATH"` RegionToDependenciesConfig map[string][]Dependency `envconfig:"-"` }
HandlerConfig is the configuration required by the tenant handler. It includes configurable parameters for incoming requests, including different tenant IDs json properties, and path parameters.
type TenantConverter ¶
type TenantConverter interface { MultipleInputToGraphQLInput([]model.BusinessTenantMappingInput) []graphql.BusinessTenantMappingInput ToGraphQLInput(model.BusinessTenantMappingInput) graphql.BusinessTenantMappingInput }
TenantConverter expects tenant converter implementation
type TenantFetcher ¶
type TenantFetcher interface {
SynchronizeTenant(ctx context.Context, parentTenantID, tenantID string) error
}
TenantFetcher is used to fectch tenants for creation;
type TenantProviderConfig ¶
type TenantProviderConfig struct { TenantIDProperty string `envconfig:"APP_TENANT_PROVIDER_TENANT_ID_PROPERTY,default=tenantId"` SubaccountTenantIDProperty string `envconfig:"APP_TENANT_PROVIDER_SUBACCOUNT_TENANT_ID_PROPERTY,default=subaccountTenantId"` CustomerIDProperty string `envconfig:"APP_TENANT_PROVIDER_CUSTOMER_ID_PROPERTY,default=customerId"` SubdomainProperty string `envconfig:"APP_TENANT_PROVIDER_SUBDOMAIN_PROPERTY,default=subdomain"` LicenseTypeProperty string `envconfig:"APP_TENANT_PROVIDER_LICENSE_TYPE_PROPERTY,default=licenseType"` TenantProvider string `envconfig:"APP_TENANT_PROVIDER,default=external-provider"` SubscriptionProviderIDProperty string `envconfig:"APP_TENANT_PROVIDER_SUBSCRIPTION_PROVIDER_ID_PROPERTY,default=subscriptionProviderIdProperty"` ProviderSubaccountIDProperty string `envconfig:"APP_TENANT_PROVIDER_PROVIDER_SUBACCOUNT_ID_PROPERTY,default=providerSubaccountIdProperty"` ConsumerTenantIDProperty string `envconfig:"APP_TENANT_PROVIDER_CONSUMER_TENANT_ID_PROPERTY,default=consumerTenantIdProperty"` SubscriptionProviderAppNameProperty string `envconfig:"APP_TENANT_PROVIDER_SUBSCRIPTION_PROVIDER_APP_NAME_PROPERTY,default=subscriptionProviderAppNameProperty"` CostObjectIDProperty string `envconfig:"APP_TENANT_PROVIDER_COST_OBJECT_ID_PROPERTY,default=costObjectProperty"` }
TenantProviderConfig includes the configuration for tenant providers - the tenant ID json property names, the subdomain property name, and the tenant provider name.
type TenantProvisioner ¶
type TenantProvisioner interface {
ProvisionMissingTenants(ctx context.Context, request *TenantSubscriptionRequest) error
}
TenantProvisioner is used to create all related to the incoming request tenants, and build their hierarchy;
type TenantSubscriber ¶
type TenantSubscriber interface { Subscribe(ctx context.Context, tenantSubscriptionRequest *TenantSubscriptionRequest) error Unsubscribe(ctx context.Context, tenantSubscriptionRequest *TenantSubscriptionRequest) error }
TenantSubscriber is used to apply subscription changes for tenants;
type TenantSubscriptionRequest ¶
type TenantSubscriptionRequest struct { AccountTenantID string SubaccountTenantID string CustomerTenantID string CostObjectTenantID string Subdomain string Region string SubscriptionProviderID string SubscriptionLcenseType string ProviderSubaccountID string ConsumerTenantID string SubscriptionProviderAppName string SubscriptionPayload string }
TenantSubscriptionRequest represents the information provided during tenant provisioning request in Compass, which includes tenant IDs, subdomain, and region of the tenant. The tenant which triggered the provisioning request is only one, and one of the tenant IDs in the request is its external ID, where the other tenant IDs are external IDs from its parents hierarchy.
func (*TenantSubscriptionRequest) MainTenantID ¶
func (r *TenantSubscriptionRequest) MainTenantID() string
MainTenantID is used to determine the external tenant ID of the tenant for which the provisioning request was triggered.