Skip to content

Commit e7a6ef5

Browse files
committed
Add human property to Task List API
See #769
1 parent e710345 commit e7a6ef5

File tree

2 files changed

+11
-9
lines changed

2 files changed

+11
-9
lines changed

tasks_list.go

+10
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ type TasksListService struct {
2424
taskId []string
2525
actions []string
2626
detailed *bool
27+
human *bool
2728
nodeId []string
2829
parentNode string
2930
parentTaskId *string
@@ -56,6 +57,12 @@ func (s *TasksListService) Detailed(detailed bool) *TasksListService {
5657
return s
5758
}
5859

60+
// Human indicates whether to return time and byte values in human-readable format.
61+
func (s *TasksListService) Human(human bool) *TasksListService {
62+
s.human = &human
63+
return s
64+
}
65+
5966
// NodeId is a list of node IDs or names to limit the returned information;
6067
// use `_local` to return information from the node you're connecting to,
6168
// leave empty to get information from all nodes.
@@ -123,6 +130,9 @@ func (s *TasksListService) buildURL() (string, url.Values, error) {
123130
if s.detailed != nil {
124131
params.Set("detailed", fmt.Sprintf("%v", *s.detailed))
125132
}
133+
if s.human != nil {
134+
params.Set("human", fmt.Sprintf("%v", *s.human))
135+
}
126136
if len(s.nodeId) > 0 {
127137
params.Set("node_id", strings.Join(s.nodeId, ","))
128138
}

tasks_list_test.go

+1-9
Original file line numberDiff line numberDiff line change
@@ -44,15 +44,7 @@ func TestTasksListBuildURL(t *testing.T) {
4444

4545
func TestTasksList(t *testing.T) {
4646
client := setupTestClientAndCreateIndexAndAddDocs(t) //, SetTraceLog(log.New(os.Stdout, "", 0)))
47-
esversion, err := client.ElasticsearchVersion(DefaultURL)
48-
if err != nil {
49-
t.Fatal(err)
50-
}
51-
if esversion < "2.3.0" {
52-
t.Skipf("Elasticsearch %v does not support Tasks Management API yet", esversion)
53-
}
54-
55-
res, err := client.TasksList().Pretty(true).Do(context.TODO())
47+
res, err := client.TasksList().Pretty(true).Human(true).Do(context.TODO())
5648
if err != nil {
5749
t.Fatal(err)
5850
}

0 commit comments

Comments
 (0)