clients

package
v0.7.1 Latest Latest
Warning

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

Go to latest
Published: May 1, 2024 License: MPL-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConstructAppPassword

func ConstructAppPassword(clientID, secret string) string

Helper function to construct app password from clientId and secret.

func FronteggRequest added in v0.6.6

func FronteggRequest(ctx context.Context, client *FronteggClient, method, url string, body []byte) (*http.Response, error)

Helper function to perform HTTP requests

func HandleApiError added in v0.6.6

func HandleApiError(resp *http.Response) error

Helper function to handle API errors

func SplitHostPort

func SplitHostPort(hostPortStr string) (host string, port int, err error)

Types

type AppPassword

type AppPassword struct {
	ClientID    string    `json:"clientId"`
	Secret      string    `json:"secret"`
	Description string    `json:"description"`
	Owner       string    `json:"owner"`
	CreatedAt   time.Time `json:"created_at"`
}

type CloudAPIClient

type CloudAPIClient struct {
	HTTPClient     *http.Client
	FronteggClient *FronteggClient
	Endpoint       string
	BaseEndpoint   string
}

CloudAPIClient is a client for interacting with the Materialize Cloud API

func NewCloudAPIClient

func NewCloudAPIClient(fronteggClient *FronteggClient, cloudAPIEndpoint, baseEndpoint string) *CloudAPIClient

NewCloudAPIClient creates a new Cloud API client

func (*CloudAPIClient) EnableRegion added in v0.6.10

func (c *CloudAPIClient) EnableRegion(ctx context.Context, provider CloudProvider) (*CloudRegion, error)

EnableRegion sends a PATCH request to enable a cloud region

func (*CloudAPIClient) GetHost

func (c *CloudAPIClient) GetHost(ctx context.Context, regionID string) (string, error)

GetHost retrieves the SQL address for a specified region

func (*CloudAPIClient) GetRegionDetails

func (c *CloudAPIClient) GetRegionDetails(ctx context.Context, provider CloudProvider) (*CloudRegion, error)

GetRegionDetails fetches the details for a given region

func (*CloudAPIClient) ListCloudProviders

func (c *CloudAPIClient) ListCloudProviders(ctx context.Context) ([]CloudProvider, error)

ListCloudProviders fetches the list of cloud providers and their regions

type CloudProvider

type CloudProvider struct {
	ID            string `json:"id"`
	Name          string `json:"name"`
	Url           string `json:"url"`
	CloudProvider string `json:"cloudProvider"`
}

CloudProvider contains the information about a cloud provider and its region

type CloudProviderResponse

type CloudProviderResponse struct {
	Data       []CloudProvider `json:"data"`
	NextCursor string          `json:"nextCursor,omitempty"`
}

CloudProviderResponse represents the response for listing cloud providers

type CloudRegion

type CloudRegion struct {
	RegionInfo *RegionInfo `json:"regionInfo"`
}

Region holds the connection details for an active region

type DBClient

type DBClient struct {
	*sqlx.DB
}

func NewDBClient

func NewDBClient(host, user, password string, port int, database, application_name_suffix, version, sslmode string) (*DBClient, diag.Diagnostics)

func (*DBClient) SQLX

func (c *DBClient) SQLX() *sqlx.DB

type FronteggClient

type FronteggClient struct {
	HTTPClient  *http.Client
	Token       string
	Email       string
	Endpoint    string
	TokenExpiry time.Time
	Password    string
}

FronteggClient struct to encapsulate the http.Client with additional properties

func NewFronteggClient

func NewFronteggClient(ctx context.Context, password, endpoint string) (*FronteggClient, error)

NewFronteggClient function for initializing a new Frontegg client with an auth token

func (*FronteggClient) GetEmail

func (c *FronteggClient) GetEmail() string

Get the email from the FronteggClient

func (*FronteggClient) GetEndpoint

func (c *FronteggClient) GetEndpoint() string

Get the endpoint from the FronteggClient

func (*FronteggClient) GetPassword

func (c *FronteggClient) GetPassword() string

Get the password from the FronteggClient

func (*FronteggClient) GetToken

func (c *FronteggClient) GetToken() string

Get the token from the FronteggClient

func (*FronteggClient) GetTokenExpiry

func (c *FronteggClient) GetTokenExpiry() time.Time

Get the token expiry from the FronteggClient

func (*FronteggClient) NeedsTokenRefresh

func (c *FronteggClient) NeedsTokenRefresh() error

func (*FronteggClient) RefreshToken

func (c *FronteggClient) RefreshToken() error

type Region

type Region string
const (
	AwsUsEast1 Region = "aws/us-east-1"
	AwsUsWest2 Region = "aws/us-west-2"
	AwsEuWest1 Region = "aws/eu-west-1"
)

type RegionInfo

type RegionInfo struct {
	SqlAddress  string `json:"sqlAddress"`
	HttpAddress string `json:"httpAddress"`
	Resolvable  bool   `json:"resolvable"`
	EnabledAt   string `json:"enabledAt"`
}

RegionInfo holds the detailed information about a region from the Cloud API

type Role

type Role struct {
	ID            string    `json:"id"`
	VendorID      string    `json:"vendorId"`
	TenantID      *string   `json:"tenantId,omitempty"`
	Key           string    `json:"key"`
	Name          string    `json:"name"`
	Description   string    `json:"description"`
	IsDefault     bool      `json:"isDefault"`
	FirstUserRole bool      `json:"firstUserRole"`
	CreatedAt     time.Time `json:"createdAt"`
	UpdatedAt     time.Time `json:"updatedAt"`
	Permissions   []string  `json:"permissions"`
	Level         int       `json:"level"`
}

Role represents the Frontegg role structure.

Jump to

Keyboard shortcuts

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