Documentation ¶
Index ¶
- Constants
- type Client
- func (c *Client) APIReq(isStarterPlan bool, meth, path string, v interface{}) error
- func (c *Client) DoReq(req *http.Request, v interface{}) error
- func (c *Client) Get(isStarterPlan bool, path string, v interface{}) error
- func (c *Client) NewDB(id, plan string) DB
- func (c *Client) NewRequest(isStarterPlan bool, method, path string) (*http.Request, error)
- func (c *Client) Post(isStarterPlan bool, path string, v interface{}) error
- func (c *Client) Put(isStarterPlan bool, path string, v interface{}) error
- type DB
- type DBInfo
- type InfoEntry
- type InfoEntryList
- type WaitStatus
Constants ¶
const ( Version = "0.0.1" DefaultAPIPath = "/client/v11/databases" DefaultAPIURL = "https://postgres-api.heroku.com" + DefaultAPIPath DefaultStarterAPIURL = "https://postgres-starter-api.heroku.com" + DefaultAPIPath DefaultUserAgent = "heroku-postgres-go/" + Version + " (" + runtime.GOOS + "; " + runtime.GOARCH + ")" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct { // HTTP is the Client's internal http.Client, handling HTTP requests to the // Heroku Postgres API. HTTP *http.Client // The URL of the Heroku Postgres API to communicate with. Defaults to // DefaultAPIURL. URL string // The URL of the Heroku Postgres Starter API to communicate with. Defaults // to DefaultStarterAPIURL. StarterURL string // Username is the HTTP basic auth username for API calls made by this Client. Username string // Password is the HTTP basic auth password for API calls made by this Client. Password string // UserAgent to be provided in API requests. Set to DefaultUserAgent if not // specified. UserAgent string // Debug mode can be used to dump the full request and response to stdout. Debug bool // AdditionalHeaders are extra headers to add to each HTTP request sent by // this Client. AdditionalHeaders http.Header }
A Client is a Heroku Postgres API client. Its zero value is a usable client that uses default settings for the Heroku Postgres API. The Client has an internal HTTP client (HTTP) which defaults to http.DefaultClient.
As with all http.Clients, this Client's Transport has internal state (cached HTTP connections), so Clients should be reused instead of created as needed. Clients are safe for use by multiple goroutines.
func (*Client) APIReq ¶
Sends a Heroku Postgres API request and decodes the response into v. As described in DoReq(), the type of v determines how to handle the response body.
func (*Client) DoReq ¶
Submits an HTTP request, checks its response, and deserializes the response into v. The type of v determines how to handle the response body:
nil body is discarded io.Writer body is copied directly into v else body is decoded into v as json
func (*Client) NewRequest ¶
Generates an HTTP request for the Heroku Postgres API, but does not perform the request. The request's Accept header field will be set to:
Accept: application/json
The Request-Id header will be set to a random UUID. The User-Agent header will be set to the Client's UserAgent, or DefaultUserAgent if UserAgent is not set.
isStarterPlan should be set to true if the target database is a starter plan, and false otherwise (as defined in DB.IsStarterPlan() ). Method is the HTTP method of this request, and path is the HTTP path.
type DB ¶
func (*DB) IsStarterPlan ¶
Whether the DB is a starter plan and should communicate with the starter API. Plan names ending in "dev" or "basic" are currently handled by the starter API while all others are handled by the production API.
func (*DB) RotateCredentials ¶
func (*DB) WaitStatus ¶
func (d *DB) WaitStatus() (ws WaitStatus, err error)
type DBInfo ¶
type DBInfo struct { AvailableForIngress bool `json:"available_for_ingress"` CreatedAt string `json:"created_at"` CurrentTransaction string `json:"current_transaction"` DatabaseName string `json:"database_name"` DatabasePassword string `json:"database_password"` DatabaseUser string `json:"database_user"` Following string `json:"following"` Info InfoEntryList `json:"info"` IsInRecovery bool `json:"is_in_recovery?"` NumBytes int `json:"num_bytes"` NumConnections int `json:"num_connections"` NumConnectionsWaiting int `json:"num_connections_waiting"` NumTables int `json:"num_tables"` Plan string `json:"plan"` PostgresqlVersion string `json:"postgresql_version"` ResourceURL string `json:"resource_url"` ServicePort int `json:"service_port"` StatusUpdatedAt time.Time `json:"status_updated_at"` Standalone bool `json:"standalone?"` TargetTransaction string `json:"target_transaction"` }
func (*DBInfo) IsFollower ¶
type InfoEntryList ¶
type InfoEntryList []InfoEntry
func (*InfoEntryList) GetString ¶
func (iel *InfoEntryList) GetString(key string) (valstr string, resolve bool)
func (*InfoEntryList) Named ¶
func (iel *InfoEntryList) Named(name string) *InfoEntry
type WaitStatus ¶
type WaitStatus struct { }