user

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Jul 23, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package user represents the SiteHost `/cloud/db/user` API endpoint.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AddRequest

type AddRequest struct {
	ServerName string   `json:"server_name"`
	MySQLHost  string   `json:"mysql_host"`
	Username   string   `json:"username"`
	Password   string   `json:"password"`
	Database   string   `json:"database"`
	Grants     []string `json:"grants"`
}

AddRequest represents a request to add a database user, with an initial set of grants.

type AddResponse

type AddResponse struct {
	Return struct {
		models.Job `json:"job"`
	} `json:"return"`
	models.APIResponse
}

AddResponse adds a new database user.

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client is a Service to work with API Jobs.

func New

func New(c *api.Client) *Client

New is an initialisation function.

func (*Client) Add

func (s *Client) Add(ctx context.Context, request AddRequest) (response AddResponse, err error)

Add creates a new database user via /cloud/db/user/add.json.

**Username format gotcha** (verified live, May 2026): the API rejects names containing underscores or longer than ~16 chars with "Please specify a valid username." The exact rule isn't documented; the safe shape mirrors the cc<hex> stack-name pattern — alphanumeric, no separators, ≤16 chars.

Examples that work: "g0a1b2c3d4e", "ccdeadbeef" (matches stack name). Examples that fail: "goshu_mariadb_8abd1e", "my_db_user".

Grants takes the lowercased privilege names — typical app grant set is "select", "insert", "update", "delete", "create", "drop", "index", "alter", "create temporary tables", "lock tables", "create view", "show view".

See examples/cloud-db-compare for the working pattern.

func (*Client) Delete

func (s *Client) Delete(ctx context.Context, request DeleteRequest) (response DeleteResponse, err error)

Delete removes the specified cloud database user.

func (*Client) Get

func (s *Client) Get(ctx context.Context, request GetRequest) (response GetResponse, err error)

Get fetches a cloud db user.

func (*Client) List

func (s *Client) List(ctx context.Context, opt ListOptions) (response ListResponse, err error)

List returns a list of cloud database users. It can be filtered by server, host, username.

func (*Client) Update

func (s *Client) Update(ctx context.Context, request UpdateRequest) (response UpdateResponse, err error)

Update sets the password for the specified cloud database user.

type DeleteRequest

type DeleteRequest struct {
	MySQLHost  string `json:"mysql_host"`
	ServerName string `json:"server_name"`
	Username   string `json:"username"`
}

DeleteRequest represents a request to delete a database user.

type DeleteResponse

type DeleteResponse struct {
	Return struct {
		models.Job `json:"job"`
	} `json:"return"`
	models.APIResponse
}

DeleteResponse deletes the specified database user.

type GetRequest

type GetRequest struct {
	MySQLHost  string `json:"mysql_host"`
	ServerName string `json:"server_name"`
	Username   string `json:"username"`
}

GetRequest represents a request to get the specified database user on the given server/host.

type GetResponse

type GetResponse struct {
	User models.DatabaseUser `json:"return"`
	models.APIResponse
}

GetResponse gets the specified database user.

type ListOptions

type ListOptions struct {
	ServerName string `url:"filters[server_name],omitempty"`
	Username   string `url:"filters[username],omitempty"`
	MySQLHost  string `url:"filters[mysql_host],omitempty"`
	models.Filtering
}

ListOptions are options for filtering/listing databases.

type ListResponse

type ListResponse struct {
	Return struct {
		Users []models.DatabaseUser `json:"data"`
		models.Pagination
	} `json:"return"`
	models.APIResponse
}

ListResponse is the returned response from the List endpoint.

type UpdateRequest

type UpdateRequest struct {
	ServerName string `json:"server_name"`
	MySQLHost  string `json:"mysql_host"`
	Username   string `json:"username"`
	Password   string `json:"password"`
}

UpdateRequest represents a request to update a database user. It sets the password.

type UpdateResponse

type UpdateResponse struct {
	Return struct {
		models.Job `json:"job"`
	} `json:"return"`
	models.APIResponse
}

UpdateResponse updates the specified database user.

Jump to

Keyboard shortcuts

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