1package client // import "github.com/docker/docker/client"
2
3import (
4	"bytes"
5	"context"
6	"encoding/json"
7	"io/ioutil"
8
9	"github.com/docker/docker/api/types/swarm"
10)
11
12// NodeInspectWithRaw returns the node information.
13func (cli *Client) NodeInspectWithRaw(ctx context.Context, nodeID string) (swarm.Node, []byte, error) {
14	if nodeID == "" {
15		return swarm.Node{}, nil, objectNotFoundError{object: "node", id: nodeID}
16	}
17	serverResp, err := cli.get(ctx, "/nodes/"+nodeID, nil, nil)
18	defer ensureReaderClosed(serverResp)
19	if err != nil {
20		return swarm.Node{}, nil, wrapResponseError(err, serverResp, "node", nodeID)
21	}
22
23	body, err := ioutil.ReadAll(serverResp.body)
24	if err != nil {
25		return swarm.Node{}, nil, err
26	}
27
28	var response swarm.Node
29	rdr := bytes.NewReader(body)
30	err = json.NewDecoder(rdr).Decode(&response)
31	return response, body, err
32}
33