mirror of
https://github.com/moby/moby.git
synced 2026-01-11 10:41:43 +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>
27 lines
524 B
Go
27 lines
524 B
Go
package client
|
|
|
|
import (
|
|
"context"
|
|
"encoding/json"
|
|
"net/url"
|
|
|
|
"github.com/moby/moby/api/types/swarm"
|
|
)
|
|
|
|
// TaskList returns the list of tasks.
|
|
func (cli *Client) TaskList(ctx context.Context, options TaskListOptions) ([]swarm.Task, error) {
|
|
query := url.Values{}
|
|
|
|
options.Filters.updateURLValues(query)
|
|
|
|
resp, err := cli.get(ctx, "/tasks", query, nil)
|
|
defer ensureReaderClosed(resp)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
var tasks []swarm.Task
|
|
err = json.NewDecoder(resp.Body).Decode(&tasks)
|
|
return tasks, err
|
|
}
|