-
Notifications
You must be signed in to change notification settings - Fork 3
/
get_connector_status.go
45 lines (38 loc) · 1.03 KB
/
get_connector_status.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package connect
import (
"context"
)
type ConnectorStateInfo struct {
Name string `json:"name"`
Connector ConnectorState `json:"connector"`
Tasks []TaskState `json:"tasks"`
Type string `json:"type"`
}
type ConnectorState struct {
State string `json:"state"`
WorkerID string `json:"worker_id"`
Trace string `json:"trace,omitempty"`
}
type TaskState struct {
ID int `json:"id"`
State string `json:"state"`
WorkerID string `json:"worker_id"`
Trace string `json:"trace"`
}
func (c *Client) GetConnectorStatus(ctx context.Context, connectorName string) (ConnectorStateInfo, error) {
var stateInfo ConnectorStateInfo
response, err := c.client.NewRequest().
SetContext(ctx).
SetResult(&stateInfo).
SetError(ApiError{}).
SetPathParam("connector", connectorName).
Get("/connectors/{connector}/status")
if err != nil {
return ConnectorStateInfo{}, err
}
err = getErrorFromResponse(response)
if err != nil {
return ConnectorStateInfo{}, err
}
return stateInfo, nil
}