Edit and validate CDM configuration
List configuration-data nodes and validate the configuration.
When to use this pattern
- You're programmatically editing configuration data nodes
- You want validation results before committing a changeset
Required values
| Value | Description |
|---|---|
| Changeset context | Editor operations run against your active changeset |
Example
package main
import (
"context"
"fmt"
"log"
servicenow "github.com/michaeldcanady/servicenow-sdk-go/v2"
"github.com/michaeldcanady/servicenow-sdk-go/v2/credentials"
)
func main() {
// Step 1: Authenticate and initialize the client
cred := credentials.NewBasicProvider("{username}", "{password}")
client, err := servicenow.NewServiceNowServiceClient(
servicenow.WithAuthenticationProvider(cred),
servicenow.WithInstance("{instance}"),
)
if err != nil {
log.Fatalf("failed to initialize client: %v", err)
}
ctx := context.Background()
editor := client.Cdm().Editor()
// Step 2: List configuration data nodes
nodes, err := editor.Nodes().Get(ctx, nil)
if err != nil {
log.Fatalf("unable to list nodes: %v", err)
}
fmt.Printf("nodes: %+v\n", nodes)
// Step 3: Validate the configuration data
validation, err := editor.Validation().Get(ctx, nil)
if err != nil {
log.Fatalf("validation failed: %v", err)
}
fmt.Printf("validation: %+v\n", validation)
}
Tips
Nodes().Post/Put/Deletemodify nodes; validate before you commit.