v1

package
v0.4.49 Latest Latest
Warning

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

Go to latest
Published: May 7, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewContextWithClient

func NewContextWithClient(ctx context.Context, c ClientV1) context.Context

NewContext derives a Context that carries c from ctx.

Types

type Client

type Client struct {
	*uiex.Client
}

func NewClientWithOptions

func NewClientWithOptions(ctx context.Context, opts uiex.NewClientOpts) (*Client, error)

func (*Client) BaseURL

func (c *Client) BaseURL() *url.URL

func (*Client) CreateAttachment

func (c *Client) CreateAttachment(ctx context.Context, clusterId string, input CreateAttachmentInput) (CreateAttachmentResponse, error)

CreateAttachment creates a ManagedServiceAttachment record linking an app to a managed Postgres cluster

func (*Client) CreateCluster

func (c *Client) CreateCluster(ctx context.Context, input CreateClusterInput) (CreateClusterResponse, error)

func (*Client) CreateDatabase

func (c *Client) CreateDatabase(ctx context.Context, id string, input CreateDatabaseInput) (CreateDatabaseResponse, error)

func (*Client) CreateManagedClusterBackup

func (c *Client) CreateManagedClusterBackup(ctx context.Context, clusterID string, input CreateManagedClusterBackupInput) (CreateManagedClusterBackupResponse, error)

CreateManagedClusterBackup creates a new backup for a managed Postgres cluster

func (*Client) CreateUser

func (c *Client) CreateUser(ctx context.Context, id string, input CreateUserInput) (CreateUserResponse, error)

func (*Client) CreateUserWithRole

func (c *Client) CreateUserWithRole(ctx context.Context, id string, input CreateUserWithRoleInput) (CreateUserWithRoleResponse, error)

func (*Client) DeleteAttachment

func (c *Client) DeleteAttachment(ctx context.Context, clusterId string, appName string) (DeleteAttachmentResponse, error)

DeleteAttachment removes a ManagedServiceAttachment record linking an app to a managed Postgres cluster

func (*Client) DeleteUser

func (c *Client) DeleteUser(ctx context.Context, id string, username string) error

func (*Client) DestroyCluster

func (c *Client) DestroyCluster(ctx context.Context, orgSlug string, id string) error

DestroyCluster permanently destroys a managed Postgres cluster

func (*Client) GetManagedCluster

func (c *Client) GetManagedCluster(ctx context.Context, orgSlug string, id string) (GetManagedClusterResponse, error)

func (*Client) GetManagedClusterById

func (c *Client) GetManagedClusterById(ctx context.Context, id string) (GetManagedClusterResponse, error)

func (*Client) GetUserCredentials

func (c *Client) GetUserCredentials(ctx context.Context, id string, username string) (GetUserCredentialsResponse, error)

func (*Client) HTTPClient

func (c *Client) HTTPClient() *http.Client

func (*Client) ListDatabases

func (c *Client) ListDatabases(ctx context.Context, id string) (ListDatabasesResponse, error)

func (*Client) ListMPGRegions

func (c *Client) ListMPGRegions(ctx context.Context, orgSlug string) (ListMPGRegionsResponse, error)

ListMPGRegions returns the list of regions available for Managed Postgres TODO: Implement the actual API endpoint on the backend

func (*Client) ListManagedClusterBackups

func (c *Client) ListManagedClusterBackups(ctx context.Context, clusterID string) (ListManagedClusterBackupsResponse, error)

ListManagedClusterBackups returns the list of backups for a managed Postgres cluster

func (*Client) ListManagedClusters

func (c *Client) ListManagedClusters(ctx context.Context, orgSlug string, deleted bool) (ListManagedClustersResponse, error)

func (*Client) ListUsers

func (c *Client) ListUsers(ctx context.Context, id string) (ListUsersResponse, error)

func (*Client) RestoreManagedClusterBackup

func (c *Client) RestoreManagedClusterBackup(ctx context.Context, clusterID string, input RestoreManagedClusterBackupInput) (RestoreManagedClusterBackupResponse, error)

RestoreManagedClusterBackup restores a managed Postgres cluster from a backup

func (*Client) UpdateUserRole

func (c *Client) UpdateUserRole(ctx context.Context, id string, username string, input UpdateUserRoleInput) (UpdateUserRoleResponse, error)

type ClientV1

type ClientV1 interface {
	// List clusters. NOTE: Odd but the v1 client endpoint returns both v1 and v2 clusters,
	// they are just identified with the `Version` field being 1 or 2.
	ListManagedClusters(ctx context.Context, orgSlug string, deleted bool) (ListManagedClustersResponse, error)
	GetManagedCluster(ctx context.Context, orgSlug string, id string) (GetManagedClusterResponse, error)
	GetManagedClusterById(ctx context.Context, id string) (GetManagedClusterResponse, error)
	ListMPGRegions(ctx context.Context, orgSlug string) (ListMPGRegionsResponse, error)
	CreateUser(ctx context.Context, id string, input CreateUserInput) (CreateUserResponse, error)
	CreateUserWithRole(ctx context.Context, id string, input CreateUserWithRoleInput) (CreateUserWithRoleResponse, error)
	UpdateUserRole(ctx context.Context, id string, username string, input UpdateUserRoleInput) (UpdateUserRoleResponse, error)
	DeleteUser(ctx context.Context, id string, username string) error
	GetUserCredentials(ctx context.Context, id string, username string) (GetUserCredentialsResponse, error)
	ListUsers(ctx context.Context, id string) (ListUsersResponse, error)
	ListDatabases(ctx context.Context, id string) (ListDatabasesResponse, error)
	CreateDatabase(ctx context.Context, id string, input CreateDatabaseInput) (CreateDatabaseResponse, error)
	CreateCluster(ctx context.Context, input CreateClusterInput) (CreateClusterResponse, error)
	DestroyCluster(ctx context.Context, orgSlug string, id string) error
	ListManagedClusterBackups(ctx context.Context, clusterID string) (ListManagedClusterBackupsResponse, error)
	CreateManagedClusterBackup(ctx context.Context, clusterID string, input CreateManagedClusterBackupInput) (CreateManagedClusterBackupResponse, error)
	RestoreManagedClusterBackup(ctx context.Context, clusterID string, input RestoreManagedClusterBackupInput) (RestoreManagedClusterBackupResponse, error)
	CreateAttachment(ctx context.Context, clusterId string, input CreateAttachmentInput) (CreateAttachmentResponse, error)
	DeleteAttachment(ctx context.Context, clusterId string, appName string) (DeleteAttachmentResponse, error)
}

func ClientFromContext

func ClientFromContext(ctx context.Context) ClientV1

ClientFromContext returns the ClientV1 ctx carries.

type CreateAttachmentInput

type CreateAttachmentInput struct {
	AppName string `json:"app_name"`
}

type CreateAttachmentResponse

type CreateAttachmentResponse struct {
	Data struct {
		Id               int64  `json:"id"`
		AppId            int64  `json:"app_id"`
		ManagedServiceId int64  `json:"managed_service_id"`
		AttachedAt       string `json:"attached_at"`
	} `json:"data"`
}

type CreateClusterInput

type CreateClusterInput struct {
	Name           string `json:"name"`
	Region         string `json:"region"`
	Plan           string `json:"plan"`
	OrgSlug        string `json:"org_slug"`
	Disk           int    `json:"disk"`
	PostGISEnabled bool   `json:"postgis_enabled"`
	PGMajorVersion string `json:"pg_major_version"`
}

type CreateClusterResponse

type CreateClusterResponse struct {
	Ok     bool                `json:"ok"`
	Errors uiex.DetailedErrors `json:"errors"`
	Data   struct {
		Id             string                          `json:"id"`
		Name           string                          `json:"name"`
		Status         *string                         `json:"status"`
		Plan           string                          `json:"plan"`
		Environment    *string                         `json:"environment"`
		Region         string                          `json:"region"`
		Organization   fly.Organization                `json:"organization"`
		Replicas       int                             `json:"replicas"`
		Disk           int                             `json:"disk"`
		IpAssignments  mpg.ManagedClusterIpAssignments `json:"ip_assignments"`
		PostGISEnabled bool                            `json:"postgis_enabled"`
	} `json:"data"`
}

type CreateDatabaseInput

type CreateDatabaseInput struct {
	Name string `json:"name"`
}

type CreateDatabaseResponse

type CreateDatabaseResponse struct {
	Data Database `json:"data"`
}

type CreateManagedClusterBackupInput

type CreateManagedClusterBackupInput struct {
	Type string `json:"type"`
}

type CreateManagedClusterBackupResponse

type CreateManagedClusterBackupResponse struct {
	Data ManagedClusterBackup `json:"data"`
}

type CreateUserInput

type CreateUserInput struct {
	DbName   string `json:"db_name"`
	UserName string `json:"user_name"`
}

type CreateUserResponse

type CreateUserResponse struct {
	ConnectionUri string              `json:"connection_uri"`
	Ok            bool                `json:"ok"`
	Errors        uiex.DetailedErrors `json:"errors"`
}

type CreateUserWithRoleInput

type CreateUserWithRoleInput struct {
	UserName string `json:"user_name"`
	Role     string `json:"role"` // 'schema_admin' | 'writer' | 'reader'
}

type CreateUserWithRoleResponse

type CreateUserWithRoleResponse struct {
	Data User `json:"data"`
}

type Database

type Database struct {
	Name string `json:"name"`
}

type DeleteAttachmentResponse

type DeleteAttachmentResponse struct {
	Data struct {
		Message string `json:"message"`
	} `json:"data"`
}

type GetManagedClusterCredentialsResponse

type GetManagedClusterCredentialsResponse struct {
	Status        string `json:"status"`
	User          string `json:"user"`
	Password      string `json:"password"`
	DBName        string `json:"dbname"`
	ConnectionUri string `json:"pgbouncer_uri"`
}

type GetManagedClusterResponse

type GetManagedClusterResponse struct {
	Data        ManagedCluster                       `json:"data"`
	Credentials GetManagedClusterCredentialsResponse `json:"credentials"`
}

type GetUserCredentialsResponse

type GetUserCredentialsResponse struct {
	Data struct {
		User     string `json:"user"`
		Password string `json:"password"`
	} `json:"data"`
}

type ListDatabasesResponse

type ListDatabasesResponse struct {
	Data []Database `json:"data"`
}

type ListMPGRegionsResponse

type ListMPGRegionsResponse struct {
	Data []MPGRegion `json:"data"`
}

type ListManagedClusterBackupsResponse

type ListManagedClusterBackupsResponse struct {
	Data []ManagedClusterBackup `json:"data"`
}

type ListManagedClustersResponse

type ListManagedClustersResponse struct {
	Data []ManagedCluster `json:"data"`
}

type ListUsersResponse

type ListUsersResponse struct {
	Data []User `json:"data"`
}

type MPGRegion

type MPGRegion struct {
	Code      string `json:"code"`      // e.g., "fra"
	Available bool   `json:"available"` // Whether this region supports MPG
}

type ManagedCluster

type ManagedCluster struct {
	Id            string                          `json:"id"`
	ClusterId     string                          `json:"mpgd_cluster_id"`
	Version       int                             `json:"version"`
	Name          string                          `json:"name"`
	Region        string                          `json:"region"`
	Status        string                          `json:"status"`
	Plan          string                          `json:"plan"`
	Disk          int                             `json:"disk"`
	Replicas      int                             `json:"replicas"`
	Organization  fly.Organization                `json:"organization"`
	IpAssignments mpg.ManagedClusterIpAssignments `json:"ip_assignments"`
	AttachedApps  []mpg.AttachedApp               `json:"attached_apps"`
}

type ManagedClusterBackup

type ManagedClusterBackup struct {
	Id     string `json:"id"`
	Status string `json:"status"`
	Type   string `json:"type"`
	Start  string `json:"start"`
	Stop   string `json:"stop"`
}

type RestoreManagedClusterBackupInput

type RestoreManagedClusterBackupInput struct {
	BackupId string `json:"backup_id"`
}

type RestoreManagedClusterBackupResponse

type RestoreManagedClusterBackupResponse struct {
	Data ManagedCluster `json:"data"`
}

type UpdateUserRoleInput

type UpdateUserRoleInput struct {
	Role string `json:"role"` // 'schema_admin' | 'writer' | 'reader'
}

type UpdateUserRoleResponse

type UpdateUserRoleResponse struct {
	Data User `json:"data"`
}

type User

type User struct {
	Name string `json:"name"`
	Role string `json:"role"`
}

Jump to

Keyboard shortcuts

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