httpclient

package
v1.0.15 Latest Latest
Warning

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

Go to latest
Published: Dec 17, 2025 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package httpclient provides a typed Go client for consuming the PostgreSQL management REST API.

Create a client with:

client, err := httpclient.New("http://localhost:8080/api/v1")
if err != nil {
    panic(err)
}

Then use the client to query resources:

roles, err := client.ListRoles(ctx)
databases, err := client.ListDatabases(ctx, httpclient.WithDatabase("mydb"))

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	*client.Client
}

func New

func New(url string, opts ...client.ClientOpt) (*Client, error)

New creates a new HTTP client for the PostgreSQL management API.

func (*Client) CreateDatabase

func (c *Client) CreateDatabase(ctx context.Context, database schema.DatabaseMeta) (*schema.Database, error)

func (*Client) CreateExtension

func (c *Client) CreateExtension(ctx context.Context, meta schema.ExtensionMeta, opts ...Opt) (*schema.Extension, error)

func (*Client) CreateReplicationSlot

func (c *Client) CreateReplicationSlot(ctx context.Context, meta schema.ReplicationSlotMeta) (*schema.ReplicationSlot, error)

func (*Client) CreateRole

func (c *Client) CreateRole(ctx context.Context, role schema.RoleMeta) (*schema.Role, error)

func (*Client) CreateSchema

func (c *Client) CreateSchema(ctx context.Context, database string, meta schema.SchemaMeta) (*schema.Schema, error)

CreateSchema creates a new schema in the specified database.

func (*Client) CreateTablespace

func (c *Client) CreateTablespace(ctx context.Context, meta schema.TablespaceMeta, location string) (*schema.Tablespace, error)

func (*Client) DeleteConnection

func (c *Client) DeleteConnection(ctx context.Context, pid uint64) error

func (*Client) DeleteDatabase

func (c *Client) DeleteDatabase(ctx context.Context, name string, opt ...Opt) error

func (*Client) DeleteExtension

func (c *Client) DeleteExtension(ctx context.Context, name string, opts ...Opt) error

func (*Client) DeleteReplicationSlot

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

func (*Client) DeleteRole

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

func (*Client) DeleteSchema

func (c *Client) DeleteSchema(ctx context.Context, database, namespace string, opt ...Opt) error

DeleteSchema deletes a schema by database and namespace name.

func (*Client) DeleteTablespace

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

func (*Client) GetConnection

func (c *Client) GetConnection(ctx context.Context, pid uint64) (*schema.Connection, error)

func (*Client) GetDatabase

func (c *Client) GetDatabase(ctx context.Context, name string) (*schema.Database, error)

func (*Client) GetExtension

func (c *Client) GetExtension(ctx context.Context, name string) (*schema.Extension, error)

func (*Client) GetObject

func (c *Client) GetObject(ctx context.Context, database, namespace, name string) (*schema.Object, error)

GetObject returns an object by database, namespace (schema), and name.

func (*Client) GetReplicationSlot

func (c *Client) GetReplicationSlot(ctx context.Context, name string) (*schema.ReplicationSlot, error)

func (*Client) GetRole

func (c *Client) GetRole(ctx context.Context, name string) (*schema.Role, error)

func (*Client) GetSchema

func (c *Client) GetSchema(ctx context.Context, database, namespace string) (*schema.Schema, error)

GetSchema returns a schema by database and namespace name.

func (*Client) GetSetting

func (c *Client) GetSetting(ctx context.Context, name string) (*schema.Setting, error)

func (*Client) GetTablespace

func (c *Client) GetTablespace(ctx context.Context, name string) (*schema.Tablespace, error)

func (*Client) ListConnections

func (c *Client) ListConnections(ctx context.Context, opts ...Opt) (*schema.ConnectionList, error)

func (*Client) ListDatabases

func (c *Client) ListDatabases(ctx context.Context, opts ...Opt) (*schema.DatabaseList, error)

func (*Client) ListExtensions

func (c *Client) ListExtensions(ctx context.Context, opts ...Opt) (*schema.ExtensionList, error)

func (*Client) ListObjects

func (c *Client) ListObjects(ctx context.Context, database, namespace string, opts ...Opt) (*schema.ObjectList, error)

ListObjects returns a list of objects. If database is non-empty, only objects from that database are returned. If namespace is also non-empty, objects are further filtered by schema.

func (*Client) ListReplicationSlots

func (c *Client) ListReplicationSlots(ctx context.Context, opts ...Opt) (*schema.ReplicationSlotList, error)

func (*Client) ListRoles

func (c *Client) ListRoles(ctx context.Context, opts ...Opt) (*schema.RoleList, error)

func (*Client) ListSchemas

func (c *Client) ListSchemas(ctx context.Context, database string, opts ...Opt) (*schema.SchemaList, error)

ListSchemas returns a list of schemas. If database is non-empty, only schemas from that database are returned.

func (*Client) ListSettingCategories

func (c *Client) ListSettingCategories(ctx context.Context) (*schema.SettingCategoryList, error)

func (*Client) ListSettings

func (c *Client) ListSettings(ctx context.Context, opts ...Opt) (*schema.SettingList, error)

func (*Client) ListStatements

func (c *Client) ListStatements(ctx context.Context, opts ...Opt) (*schema.StatementList, error)

ListStatements returns statement statistics from pg_stat_statements. Supports filtering by database, user, and ordering.

func (*Client) ListTablespaces

func (c *Client) ListTablespaces(ctx context.Context, opts ...Opt) (*schema.TablespaceList, error)

func (*Client) ResetStatements

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

ResetStatements resets all statement statistics.

func (*Client) UpdateDatabase

func (c *Client) UpdateDatabase(ctx context.Context, name string, meta schema.DatabaseMeta) (*schema.Database, error)

func (*Client) UpdateExtension

func (c *Client) UpdateExtension(ctx context.Context, name string, meta schema.ExtensionMeta) (*schema.Extension, error)

func (*Client) UpdateRole

func (c *Client) UpdateRole(ctx context.Context, name string, meta schema.RoleMeta) (*schema.Role, error)

func (*Client) UpdateSchema

func (c *Client) UpdateSchema(ctx context.Context, database, namespace string, meta schema.SchemaMeta) (*schema.Schema, error)

UpdateSchema updates a schema by database and namespace name.

func (*Client) UpdateSetting

func (c *Client) UpdateSetting(ctx context.Context, name string, meta schema.SettingMeta, opts ...Opt) (*schema.Setting, error)

func (*Client) UpdateTablespace

func (c *Client) UpdateTablespace(ctx context.Context, name string, meta schema.TablespaceMeta) (*schema.Tablespace, error)

type Opt

type Opt func(*opt) error

Opt is an option to set on the client request.

func OptCascade

func OptCascade(v bool) Opt

func OptDatabase

func OptDatabase(v string) Opt

func OptRole

func OptRole(v string) Opt

func OptSet

func OptSet(k, v string) Opt

func OptState

func OptState(v string) Opt

func WithCategory

func WithCategory(v *string) Opt

func WithDatabase

func WithDatabase(v *string) Opt

func WithForce

func WithForce(v bool) Opt

func WithInstalled

func WithInstalled(v *bool) Opt

func WithOffsetLimit

func WithOffsetLimit(offset uint64, limit *uint64) Opt

WithOffsetLimit sets offset and limit query parameters.

func WithOrderBy

func WithOrderBy(v string) Opt

func WithOrderDir

func WithOrderDir(v string) Opt

func WithReload

func WithReload(v bool) Opt

func WithRole

func WithRole(v *string) Opt

func WithSchema

func WithSchema(v *string) Opt

func WithSort

func WithSort(v string) Opt

func WithState

func WithState(v *string) Opt

func WithType

func WithType(v *string) Opt

Jump to

Keyboard shortcuts

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