This repository has been archived by the owner on Oct 20, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 33
/
flowfiles.go
57 lines (49 loc) · 1.99 KB
/
flowfiles.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
46
47
48
49
50
51
52
53
54
55
56
57
package nificlient
import (
nigoapi "github.com/erdrix/nigoapi/pkg/nifi"
)
func (n *nifiClient) GetDropRequest(connectionId, id string) (*nigoapi.DropRequestEntity, error) {
// Get nigoapi client, favoring the one associated to the coordinator node.
client, context := n.privilegeCoordinatorClient()
if client == nil {
log.Error(ErrNoNodeClientsAvailable, "Error during creating node client")
return nil, ErrNoNodeClientsAvailable
}
// Request on Nifi Rest API to get the drop request information
dropRequest, rsp, body, err := client.FlowfileQueuesApi.GetDropRequest(context, connectionId, id)
if err := errorGetOperation(rsp, body, err); err != nil {
return nil, err
}
return &dropRequest, nil
}
func (n *nifiClient) CreateDropRequest(connectionId string) (*nigoapi.DropRequestEntity, error) {
// Get nigoapi client, favoring the one associated to the coordinator node.
client, context := n.privilegeCoordinatorClient()
if client == nil {
log.Error(ErrNoNodeClientsAvailable, "Error during creating node client")
return nil, ErrNoNodeClientsAvailable
}
// Request on Nifi Rest API to create the drop Request
entity, rsp, body, err := client.FlowfileQueuesApi.CreateDropRequest(context, connectionId)
if err := errorCreateOperation(rsp, body, err); err != nil {
return nil, err
}
return &entity, nil
}
// TODO : when last supported will be NiFi 1.12.X
//func (n *nifiClient) CreateDropRequest(pgId string)(*nigoapi.ProcessGroupEntity, error) {
// // Get nigoapi client, favoring the one associated to the coordinator node.
// client, context := n.privilegeCoordinatorClient()
// if client == nil {
// log.Error(ErrNoNodeClientsAvailable, "Error during creating node client")
// return nil, ErrNoNodeClientsAvailable
// }
//
// // Request on Nifi Rest API to create the registry client
// entity, rsp, err := client.ProcessGroupsApi.CreateEmptyAllConnectionsRequest(context, pgId)
// if err := errorCreateOperation(rsp, err); err != nil {
// return nil, err
// }
//
// return &entity, nil
//}