Skip to content

Commit

Permalink
Add NCM profile example in Go
Browse files Browse the repository at this point in the history
  • Loading branch information
AnaCr committed Oct 28, 2019
1 parent 2f59ccb commit 57c32d8
Showing 1 changed file with 48 additions and 0 deletions.
48 changes: 48 additions & 0 deletions Samples/Go/NCMProfile/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package main

import (
"encoding/json"
"log"

"github.com/mrxinu/gosolar"
)

// Node struct holds query results
type Node struct {
URI string `json:"uri"`
}

func main() {
// SolarWinds connection details
hostname := "localhost"
username := "admin"
password := ""

// connect to SolarWinds
client := gosolar.NewClient(hostname, username, password, true)

// query for node uri
query := `SELECT Uri
FROM Cirrus.Nodes
WHERE AgentIP = '192.0.2.0'`

res, err := client.Query(query, nil)
if err != nil {
log.Fatal(err)
}

var nodes []*Node
if err := json.Unmarshal(res, &nodes); err != nil {
log.Fatal(err)
}

// properties
req := map[string]interface{}{
"ConnectionProfile": 1,
}

_, err = client.Update(nodes[0].URI, req)
if err != nil {
log.Fatal(err)
}
}

0 comments on commit 57c32d8

Please sign in to comment.