10 "github.com/docker/docker/api/types"
11 "golang.org/x/net/context"
14 // NetworkInspect returns the information for a specific network configured in the docker host.
15 func (cli *Client) NetworkInspect(ctx context.Context, networkID string, options types.NetworkInspectOptions) (types.NetworkResource, error) {
16 networkResource, _, err := cli.NetworkInspectWithRaw(ctx, networkID, options)
17 return networkResource, err
20 // NetworkInspectWithRaw returns the information for a specific network configured in the docker host and its raw representation.
21 func (cli *Client) NetworkInspectWithRaw(ctx context.Context, networkID string, options types.NetworkInspectOptions) (types.NetworkResource, []byte, error) {
23 networkResource types.NetworkResource
29 query.Set("verbose", "true")
31 if options.Scope != "" {
32 query.Set("scope", options.Scope)
34 resp, err = cli.get(ctx, "/networks/"+networkID, query, nil)
36 if resp.statusCode == http.StatusNotFound {
37 return networkResource, nil, networkNotFoundError{networkID}
39 return networkResource, nil, err
41 defer ensureReaderClosed(resp)
43 body, err := ioutil.ReadAll(resp.body)
45 return networkResource, nil, err
47 rdr := bytes.NewReader(body)
48 err = json.NewDecoder(rdr).Decode(&networkResource)
49 return networkResource, body, err