Manage policy input mappings
Create and delete CDM policy input mappings.
When to use this pattern
- You're wiring policies to configuration inputs as part of CDM automation
Required values
| Value | Description |
|---|---|
| Mapping parameters | Supplied through the request configuration |
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()
mappings := client.Cdm().Policies().Mappings()
// Step 2: Create a policy mapping (parameters go in the request configuration)
created, err := mappings.Post(ctx, nil)
if err != nil {
log.Fatalf("unable to create mapping: %v", err)
}
mapping, err := created.GetResult()
if err != nil {
log.Fatal(err)
}
fmt.Printf("created mapping: %+v\n", mapping)
// Step 3: Delete a mapping when it's no longer needed
if err := mappings.Delete(ctx, nil); err != nil {
log.Fatalf("unable to delete mapping: %v", err)
}
}
Tips
PostandDeletetake their parameters via the request configuration rather than a body.