network_inspect.go 705 B

12345678910111213141516171819202122232425
  1. package client
  2. import (
  3. "encoding/json"
  4. "net/http"
  5. "github.com/docker/engine-api/types"
  6. "golang.org/x/net/context"
  7. )
  8. // NetworkInspect returns the information for a specific network configured in the docker host.
  9. func (cli *Client) NetworkInspect(ctx context.Context, networkID string) (types.NetworkResource, error) {
  10. var networkResource types.NetworkResource
  11. resp, err := cli.get(ctx, "/networks/"+networkID, nil, nil)
  12. if err != nil {
  13. if resp.statusCode == http.StatusNotFound {
  14. return networkResource, networkNotFoundError{networkID}
  15. }
  16. return networkResource, err
  17. }
  18. err = json.NewDecoder(resp.body).Decode(&networkResource)
  19. ensureReaderClosed(resp)
  20. return networkResource, err
  21. }