2019-01-21 14:01:48 +00:00
|
|
|
package client
|
|
|
|
|
|
|
|
import "net/http"
|
|
|
|
|
|
|
|
// NewClient initializes a new API client for the given host and API version.
|
|
|
|
// It uses the given http client as transport.
|
|
|
|
// It also initializes the custom http headers to add to each request.
|
|
|
|
//
|
|
|
|
// It won't send any version information if the version number is empty. It is
|
|
|
|
// highly recommended that you set a version or your client may break if the
|
|
|
|
// server is upgraded.
|
2023-03-31 20:15:01 +00:00
|
|
|
//
|
|
|
|
// Deprecated: use [NewClientWithOpts] passing the [WithHost], [WithVersion],
|
|
|
|
// [WithHTTPClient] and [WithHTTPHeaders] options. We recommend enabling API
|
|
|
|
// version negotiation by passing the [WithAPIVersionNegotiation] option instead
|
|
|
|
// of WithVersion.
|
2019-01-21 14:01:48 +00:00
|
|
|
func NewClient(host string, version string, client *http.Client, httpHeaders map[string]string) (*Client, error) {
|
|
|
|
return NewClientWithOpts(WithHost(host), WithVersion(version), WithHTTPClient(client), WithHTTPHeaders(httpHeaders))
|
|
|
|
}
|
|
|
|
|
|
|
|
// NewEnvClient initializes a new API client based on environment variables.
|
|
|
|
// See FromEnv for a list of support environment variables.
|
|
|
|
//
|
2023-03-31 20:15:01 +00:00
|
|
|
// Deprecated: use [NewClientWithOpts] passing the [FromEnv] option.
|
2019-01-21 14:01:48 +00:00
|
|
|
func NewEnvClient() (*Client, error) {
|
|
|
|
return NewClientWithOpts(FromEnv)
|
|
|
|
}
|