github.com/Prakhar-Agarwal-byte/moby@v0.0.0-20231027092010-a14e3e8ab87e/client/client_deprecated.go (about)

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