(Nodes)
Nodes management
- ListAcceptedNodes - List managed nodes
- CreateNodes - Create one or several new nodes
- ApplyPolicyAllNodes - Trigger an agent run on all nodes
- ListPendingNodes - List pending nodes
- ChangePendingNodeStatus - Update pending Node status
- GetNodesStatus - Get nodes acceptation status
- NodeDetails - Get information about a node
- UpdateNode - Update node settings and properties
- DeleteNode - Delete a node
- ApplyPolicy - Trigger an agent run
- NodeInheritedProperties - Get inherited node properties for a node
Get information about the nodes managed by the target server
package main
import(
rudder "github.com/infra-rdc/rudder-go"
"github.com/infra-rdc/rudder-go/models/components"
"github.com/infra-rdc/rudder-go/models/operations"
"context"
"log"
)
func main() {
s := rudder.New(
rudder.WithSecurity("<YOUR_API_KEY_HERE>"),
)
request := operations.ListAcceptedNodesRequest{
Include: rudder.String("minimal"),
Query: &components.NodeQuery{
Composition: components.CompositionAnd.ToPointer(),
Where: []components.Where{
components.Where{
ObjectType: rudder.String("node"),
Attribute: rudder.String("OS"),
Comparator: rudder.String("eq"),
Value: rudder.String("Linux"),
},
},
},
Where: []components.NodeWhere{
components.NodeWhere{
ObjectType: rudder.String("node"),
Attribute: rudder.String("OS"),
Comparator: rudder.String("eq"),
Value: rudder.String("Linux"),
},
},
Composition: components.NodeCompositionAnd.ToPointer(),
}
ctx := context.Background()
res, err := s.Nodes.ListAcceptedNodes(ctx, request)
if err != nil {
log.Fatal(err)
}
if res.Object != nil {
// handle response
}
}
Parameter | Type | Required | Description |
---|---|---|---|
ctx |
context.Context | ✔️ | The context to use for the request. |
request |
operations.ListAcceptedNodesRequest | ✔️ | The request object to use for the request. |
*operations.ListAcceptedNodesResponse, error
Error Object | Status Code | Content Type |
---|---|---|
sdkerrors.SDKError | 4xx-5xx | / |
Use the provided array of node information to create new nodes
package main
import(
rudder "github.com/infra-rdc/rudder-go"
"github.com/infra-rdc/rudder-go/models/components"
"context"
"log"
)
func main() {
s := rudder.New(
rudder.WithSecurity("<YOUR_API_KEY_HERE>"),
)
request := []components.NodeAdd{
components.NodeAdd{
ID: "378740d3-c4a9-4474-8485-478e7e52db52",
Hostname: "my.node.hostname.local",
Status: components.NodeAddStatusPending,
Os: components.Os{
Type: components.OsTypeFreebsd,
Name: components.NameKali,
Version: "9.5",
FullName: "Debian GNU/Linux 9 (stretch)",
},
PolicyServerID: rudder.String("root"),
Machine: &components.NodeAddMachine{
Type: components.NodeAddTypeVirtual,
Manufacturer: rudder.String("corp inc."),
SerialNumber: rudder.String("ece12459-2b90-49c9-ab1e-72e38f797421"),
},
AgentKey: &components.AgentKey{
Value: "-----BEGIN CERTIFICATE-----
MIIFqDCC[...]3tALNn
-----END CERTIFICATE-----",
},
Properties: []components.NodeAddProperties{
components.NodeAddProperties{
Name: "datacenter",
Value: "AMS2",
},
},
IPAddresses: []string{
"192.168.180.90",
},
Timezone: &components.Timezone{
Name: "CEST",
Offset: "+0200",
},
},
}
ctx := context.Background()
res, err := s.Nodes.CreateNodes(ctx, request)
if err != nil {
log.Fatal(err)
}
if res.Object != nil {
// handle response
}
}
Parameter | Type | Required | Description |
---|---|---|---|
ctx |
context.Context | ✔️ | The context to use for the request. |
request |
[]components.NodeAdd | ✔️ | The request object to use for the request. |
*operations.CreateNodesResponse, error
Error Object | Status Code | Content Type |
---|---|---|
sdkerrors.SDKError | 4xx-5xx | / |
This API allows to trigger an agent run on all nodes. Response contains a json stating if agent could be started on each node, but not if the run went fine and do not display any output from it. You can see the result of the run in Rudder web interface or in the each agent logs.
package main
import(
rudder "github.com/infra-rdc/rudder-go"
"context"
"log"
)
func main() {
s := rudder.New(
rudder.WithSecurity("<YOUR_API_KEY_HERE>"),
)
ctx := context.Background()
res, err := s.Nodes.ApplyPolicyAllNodes(ctx)
if err != nil {
log.Fatal(err)
}
if res.Object != nil {
// handle response
}
}
Parameter | Type | Required | Description |
---|---|---|---|
ctx |
context.Context | ✔️ | The context to use for the request. |
*operations.ApplyPolicyAllNodesResponse, error
Error Object | Status Code | Content Type |
---|---|---|
sdkerrors.SDKError | 4xx-5xx | / |
Get information about the nodes pending acceptation
package main
import(
rudder "github.com/infra-rdc/rudder-go"
"github.com/infra-rdc/rudder-go/models/components"
"github.com/infra-rdc/rudder-go/models/operations"
"context"
"log"
)
func main() {
s := rudder.New(
rudder.WithSecurity("<YOUR_API_KEY_HERE>"),
)
request := operations.ListPendingNodesRequest{
Include: rudder.String("minimal"),
Query: &components.NodeQuery{
Composition: components.CompositionAnd.ToPointer(),
Where: []components.Where{
components.Where{
ObjectType: rudder.String("node"),
Attribute: rudder.String("OS"),
Comparator: rudder.String("eq"),
Value: rudder.String("Linux"),
},
},
},
Where: []components.NodeWhere{
components.NodeWhere{
ObjectType: rudder.String("node"),
Attribute: rudder.String("OS"),
Comparator: rudder.String("eq"),
Value: rudder.String("Linux"),
},
},
Composition: components.NodeCompositionAnd.ToPointer(),
}
ctx := context.Background()
res, err := s.Nodes.ListPendingNodes(ctx, request)
if err != nil {
log.Fatal(err)
}
if res.Object != nil {
// handle response
}
}
Parameter | Type | Required | Description |
---|---|---|---|
ctx |
context.Context | ✔️ | The context to use for the request. |
request |
operations.ListPendingNodesRequest | ✔️ | The request object to use for the request. |
*operations.ListPendingNodesResponse, error
Error Object | Status Code | Content Type |
---|---|---|
sdkerrors.SDKError | 4xx-5xx | / |
Accept or refuse a pending node
package main
import(
rudder "github.com/infra-rdc/rudder-go"
"github.com/infra-rdc/rudder-go/models/operations"
"context"
"log"
)
func main() {
s := rudder.New(
rudder.WithSecurity("<YOUR_API_KEY_HERE>"),
)
var nodeID string = "9a1773c9-0889-40b6-be89-f6504443ac1b"
var requestBody *operations.ChangePendingNodeStatusRequestBody = &operations.ChangePendingNodeStatusRequestBody{
Status: operations.ChangePendingNodeStatusStatusAccepted.ToPointer(),
}
ctx := context.Background()
res, err := s.Nodes.ChangePendingNodeStatus(ctx, nodeID, requestBody)
if err != nil {
log.Fatal(err)
}
if res.Object != nil {
// handle response
}
}
Parameter | Type | Required | Description | Example |
---|---|---|---|---|
ctx |
context.Context | ✔️ | The context to use for the request. | |
nodeID |
string | ✔️ | Id of the target node | 9a1773c9-0889-40b6-be89-f6504443ac1b |
requestBody |
*operations.ChangePendingNodeStatusRequestBody | ➖ | N/A |
*operations.ChangePendingNodeStatusResponse, error
Error Object | Status Code | Content Type |
---|---|---|
sdkerrors.SDKError | 4xx-5xx | / |
Get acceptation status (pending, accepted, deleted, unknown) of a list of nodes
package main
import(
rudder "github.com/infra-rdc/rudder-go"
"context"
"log"
)
func main() {
s := rudder.New(
rudder.WithSecurity("<YOUR_API_KEY_HERE>"),
)
var ids string = "8403353b-42c4-46f5-a08d-bc77a1a0bad9,root"
ctx := context.Background()
res, err := s.Nodes.GetNodesStatus(ctx, ids)
if err != nil {
log.Fatal(err)
}
if res.Object != nil {
// handle response
}
}
Parameter | Type | Required | Description | Example |
---|---|---|---|---|
ctx |
context.Context | ✔️ | The context to use for the request. | |
ids |
string | ✔️ | Comma separated list of node Ids | 8403353b-42c4-46f5-a08d-bc77a1a0bad9,root |
*operations.GetNodesStatusResponse, error
Error Object | Status Code | Content Type |
---|---|---|
sdkerrors.SDKError | 4xx-5xx | / |
Get details about a given node
package main
import(
rudder "github.com/infra-rdc/rudder-go"
"context"
"log"
)
func main() {
s := rudder.New(
rudder.WithSecurity("<YOUR_API_KEY_HERE>"),
)
var nodeID string = "9a1773c9-0889-40b6-be89-f6504443ac1b"
var include *string = rudder.String("minimal")
ctx := context.Background()
res, err := s.Nodes.NodeDetails(ctx, nodeID, include)
if err != nil {
log.Fatal(err)
}
if res.Object != nil {
// handle response
}
}
Parameter | Type | Required | Description | Example |
---|---|---|---|---|
ctx |
context.Context | ✔️ | The context to use for the request. | |
nodeID |
string | ✔️ | Id of the target node | 9a1773c9-0889-40b6-be89-f6504443ac1b |
include |
*string | ➖ | Level of information to include from the node inventory. Some base levels are defined (minimal, default, full). You can add fields you want to a base level by adding them to the list, possible values are keys from json answer. If you don't provide a base level, they will be added to default level, so if you only want os details, use minimal,os as the value for this parameter.* minimal includes: id , hostname and status * default includes minimal plus architectureDescription , description , ipAddresses , lastRunDate , lastInventoryDate , machine , os , managementTechnology , policyServerId , properties (be careful! Only node own properties, if you also need inherited properties, look at the dedicated /nodes/{id}/inheritedProperties endpoint), policyMode , ram and timezone * full includes: default plus accounts , bios , controllers , environmentVariables , fileSystems , managementTechnologyDetails , memories , networkInterfaces , ports , processes , processors , slots , software , softwareUpdate , sound , storage , videos and virtualMachines |
minimal |
*operations.NodeDetailsResponse, error
Error Object | Status Code | Content Type |
---|---|---|
sdkerrors.SDKError | 4xx-5xx | / |
Update node settings and properties
package main
import(
rudder "github.com/infra-rdc/rudder-go"
"github.com/infra-rdc/rudder-go/models/components"
"context"
"log"
)
func main() {
s := rudder.New(
rudder.WithSecurity("<YOUR_API_KEY_HERE>"),
)
var nodeID string = "9a1773c9-0889-40b6-be89-f6504443ac1b"
var nodeSettings *components.NodeSettings = &components.NodeSettings{
Properties: []components.NodeSettingsProperties{
components.NodeSettingsProperties{
Name: "datacenter",
Value: "AMS2",
},
},
PolicyMode: components.NodeSettingsPolicyModeAudit.ToPointer(),
State: components.NodeSettingsStateEnabled.ToPointer(),
AgentKey: &components.AgentKey{
Value: "-----BEGIN CERTIFICATE-----
MIIFqDCC[...]3tALNn
-----END CERTIFICATE-----",
},
}
ctx := context.Background()
res, err := s.Nodes.UpdateNode(ctx, nodeID, nodeSettings)
if err != nil {
log.Fatal(err)
}
if res.Object != nil {
// handle response
}
}
Parameter | Type | Required | Description | Example |
---|---|---|---|---|
ctx |
context.Context | ✔️ | The context to use for the request. | |
nodeID |
string | ✔️ | Id of the target node | 9a1773c9-0889-40b6-be89-f6504443ac1b |
nodeSettings |
*components.NodeSettings | ➖ | N/A |
*operations.UpdateNodeResponse, error
Error Object | Status Code | Content Type |
---|---|---|
sdkerrors.SDKError | 4xx-5xx | / |
Remove a node from the Rudder server. It won't be managed anymore.
package main
import(
rudder "github.com/infra-rdc/rudder-go"
"github.com/infra-rdc/rudder-go/models/components"
"context"
"log"
)
func main() {
s := rudder.New(
rudder.WithSecurity("<YOUR_API_KEY_HERE>"),
)
var nodeID string = "9a1773c9-0889-40b6-be89-f6504443ac1b"
var mode *components.NodeDeleteMode = components.NodeDeleteModeMove.ToPointer()
ctx := context.Background()
res, err := s.Nodes.DeleteNode(ctx, nodeID, mode)
if err != nil {
log.Fatal(err)
}
if res.Object != nil {
// handle response
}
}
Parameter | Type | Required | Description | Example |
---|---|---|---|---|
ctx |
context.Context | ✔️ | The context to use for the request. | |
nodeID |
string | ✔️ | Id of the target node | 9a1773c9-0889-40b6-be89-f6504443ac1b |
mode |
*components.NodeDeleteMode | ➖ | Deletion mode to use, either move to trash ('move', default) or erase ('erase') | move |
*operations.DeleteNodeResponse, error
Error Object | Status Code | Content Type |
---|---|---|
sdkerrors.SDKError | 4xx-5xx | / |
This API allows to trigger an agent run on the target node. Response is a stream of the actual agent run on the node.
package main
import(
rudder "github.com/infra-rdc/rudder-go"
"context"
"log"
)
func main() {
s := rudder.New(
rudder.WithSecurity("<YOUR_API_KEY_HERE>"),
)
var nodeID string = "9a1773c9-0889-40b6-be89-f6504443ac1b"
ctx := context.Background()
res, err := s.Nodes.ApplyPolicy(ctx, nodeID)
if err != nil {
log.Fatal(err)
}
if res.AgentOutput != nil {
// handle response
}
}
Parameter | Type | Required | Description | Example |
---|---|---|---|---|
ctx |
context.Context | ✔️ | The context to use for the request. | |
nodeID |
string | ✔️ | Id of the target node | 9a1773c9-0889-40b6-be89-f6504443ac1b |
*operations.ApplyPolicyResponse, error
Error Object | Status Code | Content Type |
---|---|---|
sdkerrors.SDKError | 4xx-5xx | / |
This API returns all node properties for a node, including group inherited ones.
package main
import(
rudder "github.com/infra-rdc/rudder-go"
"context"
"log"
)
func main() {
s := rudder.New(
rudder.WithSecurity("<YOUR_API_KEY_HERE>"),
)
var nodeID string = "9a1773c9-0889-40b6-be89-f6504443ac1b"
ctx := context.Background()
res, err := s.Nodes.NodeInheritedProperties(ctx, nodeID)
if err != nil {
log.Fatal(err)
}
if res.Object != nil {
// handle response
}
}
Parameter | Type | Required | Description | Example |
---|---|---|---|---|
ctx |
context.Context | ✔️ | The context to use for the request. | |
nodeID |
string | ✔️ | Id of the target node | 9a1773c9-0889-40b6-be89-f6504443ac1b |
*operations.NodeInheritedPropertiesResponse, error
Error Object | Status Code | Content Type |
---|---|---|
sdkerrors.SDKError | 4xx-5xx | / |