model

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

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

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

Documentation

Index

Constants

View Source
const (
	// AccountStateStable is a account in a stable state and undergoing no changes.
	AccountStateStable = "stable"
	// AccountStateCreationRequested is a account in the process of being created.
	AccountStateCreationRequested = "creation-requested"
	// AccountStateCreationFailed is a account that failed creation.
	AccountStateCreationFailed = "creation-failed"
	// AccountStateProvisioningRequested is a account in the process of being provisioned.
	AccountStateProvisioningRequested = "provisioning-requested"
	// AccountStateRefreshMetadata is a account that will have metadata refreshed.
	AccountStateRefreshMetadata = "refresh-metadata"
	// AccountStateProvisioningFailed is a account that failed provisioning.
	AccountStateProvisioningFailed = "provisioning-failed"
	// AccountStateDeletionRequested is a account in the process of being deleted.
	AccountStateDeletionRequested = "deletion-requested"
	// AccountStateDeletionFailed is a account that failed deletion.
	AccountStateDeletionFailed = "deletion-failed"
	// AccountStateDeleted is a account that has been deleted
	AccountStateDeleted = "deleted"
)
View Source
const (
	// AllPerPage signals the store to return all results, avoid pagination of any kind.
	AllPerPage = -1

	// NoInstallationsLimit signals the store to return all multitenant database instances independently
	// of the number of installations using each instance.
	NoInstallationsLimit = -1
)
View Source
const (
	// TypeAccount is the string value that represents an account
	TypeAccount = "account"

	// TypeParentSubnet is the string value that represents a parent subnet
	TypeParentSubnet = "parent_subnet"
)
View Source
const (
	// ProviderAWS is the cloud provider AWS.
	ProviderAWS = "aws"
)

Variables

AllAccountRequestStates is a list of all states that a account can be put in via the API. Warning: When creating a new account state, it must be added to this list if an API endpoint should put the account in this state.

AllAccountStates is a list of all states a account can be in. Warning: When creating a new account state, it must be added to this list.

AllAccountStatesPendingWork is a list of all account states that the supervisor will attempt to transition towards stable on the next "tick". Warning: When creating a new account state, it must be added to this list if the cloud account supervisor should perform some action on its next work cycle.

View Source
var BuildHash string

BuildHash holds the git commit hash when we build the server

Functions

func CheckProvider

func CheckProvider(provider string) (string, error)

CheckProvider normalizes the given provider, returning an error if invalid.

func NewID

func NewID() string

NewID is a globally unique identifier. It is a [A-Z0-9] string 26 characters long. It is a UUID version 4 Guid that is zbased32 encoded with the padding stripped off.

Types

type AWSMetadata

type AWSMetadata struct {
	ServiceCatalogProductID string
	AWSAccountID            string
	AccountProductID        string
}

AWSMetadata is the provider metadata stored in a model.Account.

func NewAWSMetadata

func NewAWSMetadata(metadataBytes []byte) (*AWSMetadata, error)

NewAWSMetadata creates an instance of AWSMetadata given the raw provider metadata.

type Account

type Account struct {
	ID                  string
	State               string
	Provider            string
	ProviderMetadataAWS *AWSMetadata
	AccountMetadata     *AccountMetadata
	Provisioner         string
	CreateAt            int64
	DeleteAt            int64
	APISecurityLock     bool
	LockAcquiredBy      *string
	LockAcquiredAt      int64
}

Account represents an AWS account.

func AccountFromReader

func AccountFromReader(reader io.Reader) (*Account, error)

AccountFromReader decodes a json-encoded account from the given io.Reader.

func AccountsFromReader

func AccountsFromReader(reader io.Reader) ([]*Account, error)

AccountsFromReader decodes a json-encoded list of accounts from the given io.Reader.

func (*Account) Clone

func (a *Account) Clone() (*Account, error)

Clone returns a deep copy the account.

func (*Account) ValidTransitionState

func (c *Account) ValidTransitionState(newState string) bool

ValidTransitionState returns whether a account can be transitioned into the new state or not based on its current state.

type AccountCreation

type AccountCreation struct {
	SSOUserEmail          string
	SSOFirstName          string
	SSOLastName           string
	ManagedOU             string
	ControlTowerRole      string
	ControlTowerAccountID string
}

AccountCreation stores information neeeded for account creation.

type AccountFilter

type AccountFilter struct {
	Page           int
	PerPage        int
	IncludeDeleted bool
}

AccountFilter describes the parameters used to constrain a set of accounts.

type AccountMetadata

type AccountMetadata struct {
	Provision bool
	Subnet    string
}

AccountMetadata is the provider metadata stored in a model.Account.

func NewAccountMetadata

func NewAccountMetadata(metadataBytes []byte) (*AccountMetadata, error)

NewAccountMetadata creates an instance of AccountMetadata given the raw provider metadata.

type AccountProvision

type AccountProvision struct {
	StateBucket          string
	TransitGatewayID     string
	Environment          string
	TransitGatewayRoutes string
	TeleportCIDR         string
	CncCIDRs             string
	BindServerIPs        string
	ResourceShareID      string
	CoreAccountID        string
}

AccountProvision stores information neeeded for account provision.

type AccountStateReport

type AccountStateReport []StateReportEntry

AccountStateReport is a report of all account requests states.

func GetAccountRequestStateReport

func GetAccountRequestStateReport() AccountStateReport

GetAccountRequestStateReport returns a AccountStateReport based on the current model of account states.

type AddParentSubnetRequest

type AddParentSubnetRequest struct {
	CIDR       string `json:"cidr,omitempty"`
	SplitRange int    `json:"splitRange,omitempty"`
}

AddParentSubnetRequest specifies the parameters for a new parent subnet.

func NewAddParentSubnetRequestFromReader

func NewAddParentSubnetRequestFromReader(reader io.Reader) (*AddParentSubnetRequest, error)

NewAddParentSubnetRequestFromReader will create a AddParentSubnetRequest from an io.Reader with JSON data.

func (*AddParentSubnetRequest) SetDefaults

func (request *AddParentSubnetRequest) SetDefaults()

SetDefaults sets the default values for a parent subnet create request.

func (*AddParentSubnetRequest) Validate

func (request *AddParentSubnetRequest) Validate() error

Validate validates the values of a parent subnet create request.

type Client

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

Client is the programmatic interface to the genesis server API.

func NewClient

func NewClient(address string) *Client

NewClient creates a client to the genesis server at the given address.

func NewClientWithHeaders

func NewClientWithHeaders(address string, headers map[string]string) *Client

NewClientWithHeaders creates a client to the genesis server at the given address and uses the provided headers.

func (*Client) AddParentSubnet

func (c *Client) AddParentSubnet(request *AddParentSubnetRequest) (*ParentSubnet, error)

AddParentSubnet requests the addition of a parent subnet from the configured genesis server.

func (*Client) CreateAccount

func (c *Client) CreateAccount(request *CreateAccountRequest) (*Account, error)

CreateAccount requests the creation of an account from the configured genesis server.

func (*Client) CreateWebhook

func (c *Client) CreateWebhook(request *CreateWebhookRequest) (*Webhook, error)

CreateWebhook requests the creation of a webhook from the configured genesis server.

func (*Client) DeleteAccount

func (c *Client) DeleteAccount(accountID string) error

DeleteAccount deletes the given account and all resources contained therein.

func (*Client) DeleteWebhook

func (c *Client) DeleteWebhook(webhookID string) error

DeleteWebhook deletes the given webhook.

func (*Client) GetAccount

func (c *Client) GetAccount(accountID string) (*Account, error)

GetAccount fetches the specified account from the configured genesis server.

func (*Client) GetAccounts

func (c *Client) GetAccounts(request *GetAccountsRequest) ([]*Account, error)

GetAccounts fetches the list of accounts from the configured genesis server.

func (*Client) GetParentSubnet

func (c *Client) GetParentSubnet(subnet string) (*ParentSubnet, error)

GetParentSubnet fetches the specified parent subnet from the configured genesis server.

func (*Client) GetParentSubnets

func (c *Client) GetParentSubnets(request *GetParentSubnetsRequest) ([]*ParentSubnet, error)

GetParentSubnets fetches the list of parent subnets from the configured genesis server.

func (*Client) GetSubnet

func (c *Client) GetSubnet(subnet string) (*Subnet, error)

GetSubnet fetches the specified subnet from the configured genesis server.

func (*Client) GetSubnets

func (c *Client) GetSubnets(request *GetSubnetsRequest) ([]*Subnet, error)

GetSubnets fetches the list of subnets from the configured genesis server.

func (*Client) GetWebhook

func (c *Client) GetWebhook(webhookID string) (*Webhook, error)

GetWebhook fetches the webhook from the configured genesis server.

func (*Client) GetWebhooks

func (c *Client) GetWebhooks(request *GetWebhooksRequest) ([]*Webhook, error)

GetWebhooks fetches the list of webhooks from the configured genesis server.

func (*Client) LockAPIForAccount

func (c *Client) LockAPIForAccount(accountID string) error

LockAPIForAccount locks API changes for a given account.

func (*Client) ProvisionAccount

func (c *Client) ProvisionAccount(accountID string, request *ProvisionAccountRequest) (*Account, error)

ProvisionAccount provisions k8s operators and Helm charts on a account from the configured genesis server.

func (*Client) RetryCreateAccount

func (c *Client) RetryCreateAccount(accountID string) error

RetryCreateAccount retries the creation of an account from the configured genesis server.

func (*Client) UnlockAPIForAccount

func (c *Client) UnlockAPIForAccount(accountID string) error

UnlockAPIForAccount unlocks API changes for a given account.

type CreateAccountRequest

type CreateAccountRequest struct {
	Provider                string `json:"provider,omitempty"`
	ServiceCatalogProductID string `json:"serviceCatalogProductID,omitempty"`
	Provision               bool   `json:"provision,omitempty"`
	Subnet                  string `json:"subnet,omitempty"`
	APISecurityLock         bool   `json:"api-security-lock,omitempty"`
}

CreateAccountRequest specifies the parameters for a new account.

func NewCreateAccountRequestFromReader

func NewCreateAccountRequestFromReader(reader io.Reader) (*CreateAccountRequest, error)

NewCreateAccountRequestFromReader will create a CreateAccountRequest from an io.Reader with JSON data.

func (*CreateAccountRequest) SetDefaults

func (request *CreateAccountRequest) SetDefaults()

SetDefaults sets the default values for an account create request.

func (*CreateAccountRequest) Validate

func (request *CreateAccountRequest) Validate() error

Validate validates the values of an account create request.

type CreateWebhookRequest

type CreateWebhookRequest struct {
	OwnerID string
	URL     string
}

CreateWebhookRequest specifies the parameters for a new webhook.

func NewCreateWebhookRequestFromReader

func NewCreateWebhookRequestFromReader(reader io.Reader) (*CreateWebhookRequest, error)

NewCreateWebhookRequestFromReader will create a CreateWebhookRequest from an io.Reader with JSON data.

type GetAccountsRequest

type GetAccountsRequest struct {
	Page           int
	PerPage        int
	IncludeDeleted bool
}

GetAccountsRequest describes the parameters to request a list of accounts.

func (*GetAccountsRequest) ApplyToURL

func (request *GetAccountsRequest) ApplyToURL(u *url.URL)

ApplyToURL modifies the given url to include query string parameters for the request.

type GetParentSubnetsRequest

type GetParentSubnetsRequest struct {
	Page    int
	PerPage int
}

GetParentSubnetsRequest describes the parameters to request a list of parent subnets.

func (*GetParentSubnetsRequest) ApplyToURL

func (request *GetParentSubnetsRequest) ApplyToURL(u *url.URL)

ApplyToURL modifies the given url to include query string parameters for the request.

type GetSubnetsRequest

type GetSubnetsRequest struct {
	Page    int
	PerPage int
	Free    bool
}

GetSubnetsRequest describes the parameters to request a list of subnets.

func (*GetSubnetsRequest) ApplyToURL

func (request *GetSubnetsRequest) ApplyToURL(u *url.URL)

ApplyToURL modifies the given url to include query string parameters for the request.

type GetWebhooksRequest

type GetWebhooksRequest struct {
	OwnerID        string
	Page           int
	PerPage        int
	IncludeDeleted bool
}

GetWebhooksRequest describes the parameters to request a list of webhooks.

func (*GetWebhooksRequest) ApplyToURL

func (request *GetWebhooksRequest) ApplyToURL(u *url.URL)

ApplyToURL modifies the given url to include query string parameters for the request.

type ParentSubnet

type ParentSubnet struct {
	ID             string
	CIDR           string
	SplitRange     int
	CreateAt       int64
	LockAcquiredBy *string
	LockAcquiredAt int64
}

ParentSubnet represents a parent subnet range.

func ParentSubnetFromReader

func ParentSubnetFromReader(reader io.Reader) (*ParentSubnet, error)

ParentSubnetFromReader decodes a json-encoded parent subnet from the given io.Reader.

func ParentSubnetsFromReader

func ParentSubnetsFromReader(reader io.Reader) ([]*ParentSubnet, error)

ParentSubnetsFromReader decodes a json-encoded list of parent subnets from the given io.Reader.

func (*ParentSubnet) Clone

func (c *ParentSubnet) Clone() (*ParentSubnet, error)

Clone returns a deep copy of the parent subnet.

type ParentSubnetFilter

type ParentSubnetFilter struct {
	Page    int
	PerPage int
}

ParentSubnetFilter describes the parameters used to constrain a set of parent subnets.

type ProvisionAccountRequest

type ProvisionAccountRequest struct {
	Subnet string
}

ProvisionAccountRequest contains metadata related to changing the installed account state.

func NewProvisionAccountRequestFromReader

func NewProvisionAccountRequestFromReader(reader io.Reader) (*ProvisionAccountRequest, error)

NewProvisionAccountRequestFromReader will create an UpdateAccountRequest from an io.Reader with JSON data.

type StateList

type StateList []string

StateList is a list of states

func (*StateList) Count

func (sl *StateList) Count() int

Count provides the number of states in a StateList.

type StateReportEntry

type StateReportEntry struct {
	RequestedState string
	ValidStates    StateList
	InvalidStates  StateList
}

StateReportEntry is a report entry of a given request state.

type Subnet

type Subnet struct {
	ID             string
	CIDR           string
	AccountID      string
	ParentSubnet   string
	CreateAt       int64
	LockAcquiredBy *string
	LockAcquiredAt int64
}

Subnet represents a parent subnet range.

func SubnetFromReader

func SubnetFromReader(reader io.Reader) (*Subnet, error)

SubnetFromReader decodes a json-encoded subnet from the given io.Reader.

func SubnetsFromReader

func SubnetsFromReader(reader io.Reader) ([]*Subnet, error)

SubnetsFromReader decodes a json-encoded list of subnets from the given io.Reader.

func (*Subnet) Clone

func (c *Subnet) Clone() (*Subnet, error)

Clone returns a deep copy of the subnet.

type SubnetFilter

type SubnetFilter struct {
	Page    int
	PerPage int
	Free    bool
}

SubnetFilter describes the parameters used to constrain a set of subnets.

type Webhook

type Webhook struct {
	ID       string
	OwnerID  string
	URL      string
	CreateAt int64
	DeleteAt int64
}

Webhook represents a genesis webhook

func WebhookFromReader

func WebhookFromReader(reader io.Reader) (*Webhook, error)

WebhookFromReader decodes a json-encoded webhook from the given io.Reader.

func WebhooksFromReader

func WebhooksFromReader(reader io.Reader) ([]*Webhook, error)

WebhooksFromReader decodes a json-encoded list of webhooks from the given io.Reader.

func (*Webhook) IsDeleted

func (w *Webhook) IsDeleted() bool

IsDeleted returns whether the webhook was marked as deleted or not.

type WebhookFilter

type WebhookFilter struct {
	OwnerID        string
	Page           int
	PerPage        int
	IncludeDeleted bool
}

WebhookFilter describes the parameters used to constrain a set of webhooks.

type WebhookPayload

type WebhookPayload struct {
	Timestamp int64             `json:"timestamp"`
	ID        string            `json:"id"`
	Type      string            `json:"type"`
	NewState  string            `json:"new_state"`
	OldState  string            `json:"old_state"`
	ExtraData map[string]string `json:"extra_data,omitempty"`
}

WebhookPayload is the payload sent in every webhook.

func WebhookPayloadFromReader

func WebhookPayloadFromReader(reader io.Reader) (*WebhookPayload, error)

WebhookPayloadFromReader decodes a json-encoded webhook payload from the given io.Reader.

func (*WebhookPayload) ToJSON

func (p *WebhookPayload) ToJSON() (string, error)

ToJSON returns a JSON string representation of the webhook payload.

Jump to

Keyboard shortcuts

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