seed

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Jun 18, 2024 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Overview

Package seed is used to generate test data for a demo or seeded environment.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrDatumAPITokenMissing is returned when the Datum API token is missing
	ErrAPITokenMissing = fmt.Errorf("token is required but not provided")

	// ErrColumnNotFound is returned when a column is not found in the CSV file
	ErrColumnNotFound = fmt.Errorf("column not found in CSV file")
)

Functions

This section is empty.

Types

type Client

type Client struct {
	*datumclient.DatumClient
	// contains filtered or unexported fields
}

Config represents provides the datum client and configuration for the seed client

func NewDefaultClient

func NewDefaultClient() (*Client, error)

NewDefaultClient creates a new datum client using the default configuration variables

func (*Client) AuthorizeOrganizationOnPAT

func (c *Client) AuthorizeOrganizationOnPAT(ctx context.Context, orgID, patID string) error

AuthorizeOrganizationOnPAT authorizes the organization id on the personal access token id

func (*Client) GenerateSeedAPIToken

func (c *Client) GenerateSeedAPIToken(ctx context.Context, orgID string) error

GenerateSeedAPIToken generates an API token for the organization id to use for seeding and authenticates the client with the token for future requests

func (*Client) LoadGroups

func (c *Client) LoadGroups(ctx context.Context) error

LoadGroups loads the groups from the groups.csv file

func (*Client) LoadInvites

func (c *Client) LoadInvites(ctx context.Context) error

LoadInvites loads the invites from the invites.csv file

func (*Client) LoadOrganizations

func (c *Client) LoadOrganizations(ctx context.Context) (string, error)

LoadOrganizations loads the organizations from the organizations.csv file

func (*Client) LoadSubscribers

func (c *Client) LoadSubscribers(ctx context.Context) error

LoadSubscribers loads the subscribers from the subscribers.csv file

func (*Client) RegisterUsers

func (c *Client) RegisterUsers(ctx context.Context) error

RegisterUsers registers the users from the users.csv file

type Config

type Config struct {
	// Directory is the directory to save generated data
	Directory string `json:"directory" koanf:"directory" default:"demodata"`
	// DatumHost is the host of the datum server
	DatumHost string `json:"datumHost" koanf:"datum" default:"http://localhost:17608"`
	// Token is the token to use for the datum client
	Token string `json:"token" koanf:"token" default:""`
	// NumOrganizations is the number of organizations to generate
	NumOrganizations int `json:"numOrganizations" koanf:"numOrganizations" default:"1"`
	// NumUsers is the number of users to generate
	NumUsers int `json:"NumUsers" koanf:"NumUsers" default:"10"`
	// NumGroups is the number of groups to generate
	NumGroups int `json:"NumGroups" koanf:"NumGroups" default:"10"`
	// NumInvites is the number of invites to generate
	NumInvites int `json:"NumInvites" koanf:"NumInvites" default:"5"`
	// NumSubscribers is the number of subscribers to generate
	NumSubscribers int `json:"NumSubscribers" koanf:"NumSubscribers" default:"30"`
}

Config is the configuration for the seed package

func NewDefaultConfig

func NewDefaultConfig() (*Config, error)

NewDefaultConfig returns a new Config with default values

func (*Config) GenerateData

func (c *Config) GenerateData() error

func (*Config) NewClient

func (c *Config) NewClient() (*Client, error)

NewClient creates a new datum client using the provided configuration variables

Jump to

Keyboard shortcuts

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