client_deprecated.go 1.2 KB

123456789101112131415161718192021222324252627
  1. package client
  2. import "net/http"
  3. // NewClient initializes a new API client for the given host and API version.
  4. // It uses the given http client as transport.
  5. // It also initializes the custom http headers to add to each request.
  6. //
  7. // It won't send any version information if the version number is empty. It is
  8. // highly recommended that you set a version or your client may break if the
  9. // server is upgraded.
  10. //
  11. // Deprecated: use [NewClientWithOpts] passing the [WithHost], [WithVersion],
  12. // [WithHTTPClient] and [WithHTTPHeaders] options. We recommend enabling API
  13. // version negotiation by passing the [WithAPIVersionNegotiation] option instead
  14. // of WithVersion.
  15. func NewClient(host string, version string, client *http.Client, httpHeaders map[string]string) (*Client, error) {
  16. return NewClientWithOpts(WithHost(host), WithVersion(version), WithHTTPClient(client), WithHTTPHeaders(httpHeaders))
  17. }
  18. // NewEnvClient initializes a new API client based on environment variables.
  19. // See FromEnv for a list of support environment variables.
  20. //
  21. // Deprecated: use [NewClientWithOpts] passing the [FromEnv] option.
  22. func NewEnvClient() (*Client, error) {
  23. return NewClientWithOpts(FromEnv)
  24. }