clients

package
v0.11.7 Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2026 License: MPL-2.0 Imports: 18 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.8.9

func HandleAPIError(resp *http.Response) error

HandleAPIError processes an HTTP response and returns a FronteggAPIError if applicable

func HandleApiError added in v0.6.6

func HandleApiError(resp *http.Response) error

Helper function to handle API errors

func IsNotFoundError added in v0.8.9

func IsNotFoundError(err error) bool

IsNotFoundError checks if the error is a 404 Not Found error

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
	Endpoint     string
	BaseEndpoint string
}

CloudAPIClient is a client for interacting with the Materialize Cloud API

func NewCloudAPIClient

func NewCloudAPIClient(tokens TokenSource, cloudAPIEndpoint, baseEndpoint string) *CloudAPIClient

NewCloudAPIClient creates a new Cloud API client that authorizes its requests from the given token source.

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, version, sslmode string, options map[string]string) (*DBClient, diag.Diagnostics)

func (*DBClient) SQLX

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

type FronteggAPIError added in v0.8.9

type FronteggAPIError struct {
	StatusCode int
	Message    string
}

FronteggAPIError represents a standardized error structure for Frontegg API calls

func NewFronteggAPIError added in v0.8.9

func NewFronteggAPIError(resp *http.Response, message string) *FronteggAPIError

NewFronteggAPIError creates a new FronteggAPIError instance

func (*FronteggAPIError) Error added in v0.8.9

func (e *FronteggAPIError) Error() string

type FronteggClient

type FronteggClient struct {
	HTTPClient *http.Client
	Endpoint   string
	// Email identifies the authenticated principal and is also used as the
	// database user. It is derived from the credentials, so it never changes for
	// the lifetime of the client.
	Email string
	// contains filtered or unexported fields
}

FronteggClient talks to the Frontegg admin API and doubles as the TokenSource for every other authorized client.

HTTPClient, Endpoint and Email are fixed once the client is built. The token state behind them is mutable and guarded by mu.

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) Token

func (c *FronteggClient) Token(ctx context.Context) (string, error)

Token implements TokenSource. It returns the cached token while it is still good and otherwise fetches a new one. The lock is deliberately held across the fetch so that concurrent callers arriving on an expired token produce a single request instead of one each.

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.

type TokenSource added in v0.11.7

type TokenSource interface {
	Token(ctx context.Context) (string, error)
}

TokenSource supplies a currently valid bearer token, refreshing it when it has expired. Implementations must be safe for concurrent use: Terraform runs resource operations in parallel.

Jump to

Keyboard shortcuts

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