mirror of
https://github.com/moby/moby.git
synced 2026-01-11 18:51:37 +00:00
Add a new type to use for building filter predicates for API requests, replacing "./api/types/filters".Args in the client. Remove the now unused api/types/filters package. Signed-off-by: Cory Snider <csnider@mirantis.com>
24 lines
624 B
Go
24 lines
624 B
Go
package client
|
|
|
|
import (
|
|
"context"
|
|
"encoding/json"
|
|
"net/url"
|
|
|
|
"github.com/moby/moby/api/types/network"
|
|
)
|
|
|
|
// NetworkList returns the list of networks configured in the docker host.
|
|
func (cli *Client) NetworkList(ctx context.Context, options NetworkListOptions) ([]network.Summary, error) {
|
|
query := url.Values{}
|
|
options.Filters.updateURLValues(query)
|
|
var networkResources []network.Summary
|
|
resp, err := cli.get(ctx, "/networks", query, nil)
|
|
defer ensureReaderClosed(resp)
|
|
if err != nil {
|
|
return networkResources, err
|
|
}
|
|
err = json.NewDecoder(resp.Body).Decode(&networkResources)
|
|
return networkResources, err
|
|
}
|