summaryrefslogtreecommitdiffstats
path: root/vendor/gopkg.in/olivere/elastic.v5/tasks_list.go
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/gopkg.in/olivere/elastic.v5/tasks_list.go')
-rw-r--r--vendor/gopkg.in/olivere/elastic.v5/tasks_list.go56
1 files changed, 33 insertions, 23 deletions
diff --git a/vendor/gopkg.in/olivere/elastic.v5/tasks_list.go b/vendor/gopkg.in/olivere/elastic.v5/tasks_list.go
index d68bc21fb..54299d961 100644
--- a/vendor/gopkg.in/olivere/elastic.v5/tasks_list.go
+++ b/vendor/gopkg.in/olivere/elastic.v5/tasks_list.go
@@ -10,38 +10,36 @@ import (
"net/url"
"strings"
- "gopkg.in/olivere/elastic.v5/uritemplates"
+ "github.com/olivere/elastic/uritemplates"
)
// TasksListService retrieves the list of currently executing tasks
// on one ore more nodes in the cluster. It is part of the Task Management API
-// documented at http://www.elastic.co/guide/en/elasticsearch/reference/5.2/tasks-list.html.
+// documented at https://www.elastic.co/guide/en/elasticsearch/reference/6.0/tasks.html.
//
// It is supported as of Elasticsearch 2.3.0.
type TasksListService struct {
client *Client
pretty bool
- taskId []int64
+ taskId []string
actions []string
detailed *bool
nodeId []string
parentNode string
- parentTask *int64
+ parentTaskId *string
waitForCompletion *bool
+ groupBy string
}
// NewTasksListService creates a new TasksListService.
func NewTasksListService(client *Client) *TasksListService {
return &TasksListService{
- client: client,
- taskId: make([]int64, 0),
- actions: make([]string, 0),
- nodeId: make([]string, 0),
+ client: client,
}
}
// TaskId indicates to returns the task(s) with specified id(s).
-func (s *TasksListService) TaskId(taskId ...int64) *TasksListService {
+func (s *TasksListService) TaskId(taskId ...string) *TasksListService {
s.taskId = append(s.taskId, taskId...)
return s
}
@@ -72,9 +70,9 @@ func (s *TasksListService) ParentNode(parentNode string) *TasksListService {
return s
}
-// ParentTask returns tasks with specified parent task id. Set to -1 to return all.
-func (s *TasksListService) ParentTask(parentTask int64) *TasksListService {
- s.parentTask = &parentTask
+// ParentTaskId returns tasks with specified parent task id (node_id:task_number). Set to -1 to return all.
+func (s *TasksListService) ParentTaskId(parentTaskId string) *TasksListService {
+ s.parentTaskId = &parentTaskId
return s
}
@@ -85,6 +83,13 @@ func (s *TasksListService) WaitForCompletion(waitForCompletion bool) *TasksListS
return s
}
+// GroupBy groups tasks by nodes or parent/child relationships.
+// As of now, it can either be "nodes" (default) or "parents".
+func (s *TasksListService) GroupBy(groupBy string) *TasksListService {
+ s.groupBy = groupBy
+ return s
+}
+
// Pretty indicates that the JSON response be indented and human readable.
func (s *TasksListService) Pretty(pretty bool) *TasksListService {
s.pretty = pretty
@@ -97,12 +102,8 @@ func (s *TasksListService) buildURL() (string, url.Values, error) {
var err error
var path string
if len(s.taskId) > 0 {
- var tasks []string
- for _, taskId := range s.taskId {
- tasks = append(tasks, fmt.Sprintf("%d", taskId))
- }
path, err = uritemplates.Expand("/_tasks/{task_id}", map[string]string{
- "task_id": strings.Join(tasks, ","),
+ "task_id": strings.Join(s.taskId, ","),
})
} else {
path = "/_tasks"
@@ -114,7 +115,7 @@ func (s *TasksListService) buildURL() (string, url.Values, error) {
// Add query string parameters
params := url.Values{}
if s.pretty {
- params.Set("pretty", "1")
+ params.Set("pretty", "true")
}
if len(s.actions) > 0 {
params.Set("actions", strings.Join(s.actions, ","))
@@ -128,12 +129,15 @@ func (s *TasksListService) buildURL() (string, url.Values, error) {
if s.parentNode != "" {
params.Set("parent_node", s.parentNode)
}
- if s.parentTask != nil {
- params.Set("parent_task", fmt.Sprintf("%v", *s.parentTask))
+ if s.parentTaskId != nil {
+ params.Set("parent_task_id", *s.parentTaskId)
}
if s.waitForCompletion != nil {
params.Set("wait_for_completion", fmt.Sprintf("%v", *s.waitForCompletion))
}
+ if s.groupBy != "" {
+ params.Set("group_by", s.groupBy)
+ }
return path, params, nil
}
@@ -156,7 +160,11 @@ func (s *TasksListService) Do(ctx context.Context) (*TasksListResponse, error) {
}
// Get HTTP response
- res, err := s.client.PerformRequest(ctx, "GET", path, params, nil)
+ res, err := s.client.PerformRequest(ctx, PerformRequestOptions{
+ Method: "GET",
+ Path: path,
+ Params: params,
+ })
if err != nil {
return nil, err
}
@@ -178,7 +186,7 @@ type TasksListResponse struct {
}
type TaskOperationFailure struct {
- TaskId int64 `json:"task_id"`
+ TaskId int64 `json:"task_id"` // this is a long in the Java source
NodeId string `json:"node_id"`
Status string `json:"status"`
Reason *ErrorDetails `json:"reason"`
@@ -194,14 +202,16 @@ type DiscoveryNode struct {
TransportAddress string `json:"transport_address"`
Host string `json:"host"`
IP string `json:"ip"`
+ Roles []string `json:"roles"` // "master", "data", or "ingest"
Attributes map[string]interface{} `json:"attributes"`
// Tasks returns the tasks by its id (as a string).
Tasks map[string]*TaskInfo `json:"tasks"`
}
+// TaskInfo represents information about a currently running task.
type TaskInfo struct {
Node string `json:"node"`
- Id int64 `json:"id"` // the task id
+ Id int64 `json:"id"` // the task id (yes, this is a long in the Java source)
Type string `json:"type"`
Action string `json:"action"`
Status interface{} `json:"status"` // has separate implementations of Task.Status in Java for reindexing, replication, and "RawTaskStatus"