Documentation
¶
Overview ¶
Package db provides access to the `/cloud/db` API endpoint.
Index ¶
- type AddRequest
- type AddResponse
- type Client
- func (s *Client) Add(ctx context.Context, request AddRequest) (response AddResponse, err error)
- func (s *Client) Delete(ctx context.Context, request DeleteRequest) (response DeleteResponse, err error)
- func (s *Client) Get(ctx context.Context, request GetRequest) (response GetResponse, err error)
- func (s *Client) List(ctx context.Context, opt ListOptions) (response ListResponse, err error)
- func (s *Client) Update(ctx context.Context, request UpdateRequest) (response UpdateResponse, err error)
- type DeleteRequest
- type DeleteResponse
- type GetRequest
- type GetResponse
- type ListOptions
- type ListResponse
- type UpdateRequest
- type UpdateResponse
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AddRequest ¶
type AddRequest struct {
ServerName string `url:"server_name"`
MySQLHost string `url:"mysql_host"`
Database string `url:"database"`
Container string `url:"container"`
}
AddRequest adds/creates a new database on the given cloud server.
type AddResponse ¶
type AddResponse struct {
Return struct {
models.Job `json:"job"`
} `json:"return"`
models.APIResponse
}
AddResponse is the return for adding a cloud database.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is a Service to work with API Jobs.
func (*Client) Add ¶
func (s *Client) Add(ctx context.Context, request AddRequest) (response AddResponse, err error)
Add creates a new cloud database via /cloud/db/add.json.
Required fields:
- ServerName: the CCS to create the database on.
- MySQLHost: the **DB stack name** on the CCS — e.g. "mariadb1108", "mysql57", "postgres15". Despite the field name, this is NOT a DNS hostname; it's the docker-stack name resolvable inside the CCS's docker network. Discover what's available via cloud.stack.List on the CCS and match well-known prefixes (mariadb*/mysql*/postgres*).
- Database: the name of the new database (snake_case OK).
- Container: the name of an existing www-type container stack on the same CCS that "owns" this database (used by the Control Panel UI to associate the DB with its consumer).
**Container-level lock between consecutive Adds** (verified live, May 2026): two cloud.db.Add calls against the **same Container** in quick succession reject the second with:
"Unable to create database. There is already a job operating on the container."
even after the first call's scheduler job reports Completed. The container holds a brief follow-on lock past the Add's scheduler job. Insert ~30s of backoff between Adds against the same Container, OR pin each DB to a different Container, OR retry on the substring "already a job operating on the container."
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 deletes a cloud database.
func (*Client) Get ¶
func (s *Client) Get(ctx context.Context, request GetRequest) (response GetResponse, err error)
Get fetches a cloud db.
func (*Client) List ¶
func (s *Client) List(ctx context.Context, opt ListOptions) (response ListResponse, err error)
List returns a list of cloud databases, specific to the customer.
func (*Client) Update ¶
func (s *Client) Update(ctx context.Context, request UpdateRequest) (response UpdateResponse, err error)
Update updates the database's backup location.
type DeleteRequest ¶
type DeleteRequest struct {
ServerName string `url:"server_name"`
MySQLHost string `url:"mysql_host"`
Database string `url:"database"`
}
DeleteRequest a request to delete the database.
type DeleteResponse ¶
type DeleteResponse struct {
Return struct {
models.Job `json:"job"`
} `json:"return"`
models.APIResponse
}
DeleteResponse is the return from deleting.
type GetRequest ¶
type GetRequest struct {
ServerName string `json:"server_name"`
MySQLHost string `json:"mysql_host"`
Database string `json:"database"`
}
GetRequest is for getting a single database.
type GetResponse ¶
type GetResponse struct {
Database models.Database `json:"return"`
models.APIResponse
}
GetResponse is the return value from a get request.
type ListOptions ¶
type ListOptions struct {
ServerName string `url:"filters[server_name],omitempty"`
MySQLHost string `url:"filters[mysql_host],omitempty"`
Database string `url:"filters[db_name],omitempty"`
models.Filtering
}
ListOptions are options for filtering/listing databases.
type ListResponse ¶
type ListResponse struct {
Return struct {
Databases []models.Database `json:"data"`
models.Pagination
} `json:"return"`
models.APIResponse
}
ListResponse is the returned response from the List endpoint.
type UpdateRequest ¶
type UpdateRequest struct {
ServerName string `url:"server_name"`
MySQLHost string `url:"mysql_host"`
Database string `url:"database"`
Container string `url:"params[container]'"`
}
UpdateRequest is a request to the update endpoint, it only changes the backup container.
type UpdateResponse ¶
type UpdateResponse struct {
models.APIResponse
}
UpdateResponse is the response from updating a database.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package grant is used for interacting with the SiteHost `/cloud/db/grant` API endpoint.
|
Package grant is used for interacting with the SiteHost `/cloud/db/grant` API endpoint. |
|
Package user represents the SiteHost `/cloud/db/user` API endpoint.
|
Package user represents the SiteHost `/cloud/db/user` API endpoint. |