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 ¶
- type Client
- func (c *Client) CreateDatabase(ctx context.Context, database schema.DatabaseMeta) (*schema.Database, error)
- func (c *Client) CreateExtension(ctx context.Context, meta schema.ExtensionMeta, opts ...Opt) (*schema.Extension, error)
- func (c *Client) CreateReplicationSlot(ctx context.Context, meta schema.ReplicationSlotMeta) (*schema.ReplicationSlot, error)
- func (c *Client) CreateRole(ctx context.Context, role schema.RoleMeta) (*schema.Role, error)
- func (c *Client) CreateSchema(ctx context.Context, database string, meta schema.SchemaMeta) (*schema.Schema, error)
- func (c *Client) CreateTablespace(ctx context.Context, meta schema.TablespaceMeta, location string) (*schema.Tablespace, error)
- func (c *Client) DeleteConnection(ctx context.Context, pid uint64) error
- func (c *Client) DeleteDatabase(ctx context.Context, name string, opt ...Opt) error
- func (c *Client) DeleteExtension(ctx context.Context, name string, opts ...Opt) error
- func (c *Client) DeleteReplicationSlot(ctx context.Context, name string) error
- func (c *Client) DeleteRole(ctx context.Context, name string) error
- func (c *Client) DeleteSchema(ctx context.Context, database, namespace string, opt ...Opt) error
- func (c *Client) DeleteTablespace(ctx context.Context, name string) error
- func (c *Client) GetConnection(ctx context.Context, pid uint64) (*schema.Connection, error)
- func (c *Client) GetDatabase(ctx context.Context, name string) (*schema.Database, error)
- func (c *Client) GetExtension(ctx context.Context, name string) (*schema.Extension, error)
- func (c *Client) GetObject(ctx context.Context, database, namespace, name string) (*schema.Object, error)
- func (c *Client) GetReplicationSlot(ctx context.Context, name string) (*schema.ReplicationSlot, error)
- func (c *Client) GetRole(ctx context.Context, name string) (*schema.Role, error)
- func (c *Client) GetSchema(ctx context.Context, database, namespace string) (*schema.Schema, error)
- func (c *Client) GetSetting(ctx context.Context, name string) (*schema.Setting, error)
- func (c *Client) GetTablespace(ctx context.Context, name string) (*schema.Tablespace, error)
- func (c *Client) ListConnections(ctx context.Context, opts ...Opt) (*schema.ConnectionList, error)
- func (c *Client) ListDatabases(ctx context.Context, opts ...Opt) (*schema.DatabaseList, error)
- func (c *Client) ListExtensions(ctx context.Context, opts ...Opt) (*schema.ExtensionList, error)
- func (c *Client) ListObjects(ctx context.Context, database, namespace string, opts ...Opt) (*schema.ObjectList, error)
- func (c *Client) ListReplicationSlots(ctx context.Context, opts ...Opt) (*schema.ReplicationSlotList, error)
- func (c *Client) ListRoles(ctx context.Context, opts ...Opt) (*schema.RoleList, error)
- func (c *Client) ListSchemas(ctx context.Context, database string, opts ...Opt) (*schema.SchemaList, error)
- func (c *Client) ListSettingCategories(ctx context.Context) (*schema.SettingCategoryList, error)
- func (c *Client) ListSettings(ctx context.Context, opts ...Opt) (*schema.SettingList, error)
- func (c *Client) ListStatements(ctx context.Context, opts ...Opt) (*schema.StatementList, error)
- func (c *Client) ListTablespaces(ctx context.Context, opts ...Opt) (*schema.TablespaceList, error)
- func (c *Client) ResetStatements(ctx context.Context) error
- func (c *Client) UpdateDatabase(ctx context.Context, name string, meta schema.DatabaseMeta) (*schema.Database, error)
- func (c *Client) UpdateExtension(ctx context.Context, name string, meta schema.ExtensionMeta) (*schema.Extension, error)
- func (c *Client) UpdateRole(ctx context.Context, name string, meta schema.RoleMeta) (*schema.Role, error)
- func (c *Client) UpdateSchema(ctx context.Context, database, namespace string, meta schema.SchemaMeta) (*schema.Schema, error)
- func (c *Client) UpdateSetting(ctx context.Context, name string, meta schema.SettingMeta, opts ...Opt) (*schema.Setting, error)
- func (c *Client) UpdateTablespace(ctx context.Context, name string, meta schema.TablespaceMeta) (*schema.Tablespace, error)
- type Opt
- func OptCascade(v bool) Opt
- func OptDatabase(v string) Opt
- func OptRole(v string) Opt
- func OptSet(k, v string) Opt
- func OptState(v string) Opt
- func WithCategory(v *string) Opt
- func WithDatabase(v *string) Opt
- func WithForce(v bool) Opt
- func WithInstalled(v *bool) Opt
- func WithOffsetLimit(offset uint64, limit *uint64) Opt
- func WithOrderBy(v string) Opt
- func WithOrderDir(v string) Opt
- func WithReload(v bool) Opt
- func WithRole(v *string) Opt
- func WithSchema(v *string) Opt
- func WithSort(v string) Opt
- func WithState(v *string) Opt
- func WithType(v *string) Opt
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
func (*Client) CreateDatabase ¶
func (*Client) CreateExtension ¶
func (*Client) CreateReplicationSlot ¶
func (c *Client) CreateReplicationSlot(ctx context.Context, meta schema.ReplicationSlotMeta) (*schema.ReplicationSlot, error)
func (*Client) CreateRole ¶
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 (*Client) DeleteDatabase ¶
func (*Client) DeleteExtension ¶
func (*Client) DeleteReplicationSlot ¶
func (*Client) DeleteSchema ¶
DeleteSchema deletes a schema by database and namespace name.
func (*Client) DeleteTablespace ¶
func (*Client) GetConnection ¶
func (*Client) GetDatabase ¶
func (*Client) GetExtension ¶
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 (*Client) GetSetting ¶
func (*Client) GetTablespace ¶
func (*Client) ListConnections ¶
func (*Client) ListDatabases ¶
func (*Client) ListExtensions ¶
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 (*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 (*Client) ListSettings ¶
func (*Client) ListStatements ¶
ListStatements returns statement statistics from pg_stat_statements. Supports filtering by database, user, and ordering.
func (*Client) ListTablespaces ¶
func (*Client) ResetStatements ¶
ResetStatements resets all statement statistics.
func (*Client) UpdateDatabase ¶
func (*Client) UpdateExtension ¶
func (*Client) UpdateRole ¶
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 (*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 OptDatabase ¶
func WithCategory ¶
func WithDatabase ¶
func WithInstalled ¶
func WithOffsetLimit ¶
WithOffsetLimit sets offset and limit query parameters.