tenant

package
v0.0.0-...-0a771b7 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const ContextKey contextKey = "TenantCtxKey"

ContextKey missing godoc

Variables

This section is empty.

Functions

func LoadFromContext

func LoadFromContext(ctx context.Context) (string, error)

LoadFromContext retrieves the tenantID from the provided context or returns error if missing

func SaveToContext

func SaveToContext(ctx context.Context, tenantID string) context.Context

SaveToContext saves the provided tenantID into the respective context

func TrimCustomerIDLeadingZeros

func TrimCustomerIDLeadingZeros(id string) string

TrimCustomerIDLeadingZeros trims the leading zeros of customer IDs. Some IDs might have those zeros but we need to unify all IDs because other external services expect the values without the zeros. If the id argument is a valid GUID, then no trimming is performed

func TypeToStr

func TypeToStr(value Type) string

TypeToStr returns the string value of the provided tenant Type.

Types

type Entity

type Entity struct {
	ID             string `db:"id"`
	Name           string `db:"external_name"`
	ExternalTenant string `db:"external_tenant"`
	Type           Type   `db:"type"`
	ProviderName   string `db:"provider_name"`
	Initialized    *bool  `db:"initialized"` // computed value
	Status         Status `db:"status"`
}

Entity represents a Compass tenant.

func (Entity) WithStatus

func (e Entity) WithStatus(status Status) Entity

WithStatus sets the provided status to the entity.

type EntityCollection

type EntityCollection []Entity

EntityCollection is a wrapper type for slice of entities.

func (EntityCollection) Len

func (a EntityCollection) Len() int

Len returns the current number of entities in the collection.

type EntityWithAppID

type EntityWithAppID struct {
	*Entity
	AppID string `db:"app_id"`
}

EntityWithAppID represents a Compass tenant with application id.

type EntityWithAppIDCollection

type EntityWithAppIDCollection []EntityWithAppID

EntityWithAppIDCollection represents a slice of EntityWithAppID objects

func (EntityWithAppIDCollection) Len

Len returns the current number of entities in the collection.

type Status

type Status string

Status is used to determine if a tenant is currently being used or not.

const (
	// Active status represents tenants, which are currently active and their resources can be operated.
	Active Status = "Active"
	// Inactive status represents tenants, whose resources cannot be operated.
	Inactive Status = "Inactive"
)

type Type

type Type string

Type missing godoc

const (
	// Unknown tenant type is used when the tenant type cannot be determined when the tenant's being created.
	Unknown Type = "unknown"
	// Customer tenants can be parents of account tenants.
	Customer Type = "customer"
	// Account tenant type may have a parent with type Customer.
	Account Type = "account"
	// Subaccount tenants must have a parent of type Account.
	Subaccount Type = "subaccount"
	// Organization tenants can be parents of Folder or ResourceGroup tenants.
	Organization Type = "organization"
	// Folder tenants must have a parent of type Organization.
	Folder Type = "folder"
	// ResourceGroup tenants must have a parent of type Folder or Organization.
	ResourceGroup Type = "resource-group"
	// CostObject tenants can be parents of Folder or Account.
	CostObject Type = "cost-object"
)

func StrToType

func StrToType(value string) Type

StrToType returns the tenant Type value of the provided string or "Unknown" if there's no type matching the string.

Jump to

Keyboard shortcuts

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