gocherwell is a go-Module for communication with the REST-API of Cherwell.
var user = "TESTUSER"
var password = "p4$$w0rd"
var clientID = "0000-1111-2222-3333-4444"
var baseURI = "https://example.com/CherwellAPI/"
var auth_mode = "Internal"
var grant_type = "password"
cl := gocherwell.NewClient(
user,
password,
clientID,
baseURI,
auth_mode,
grant_type,
).Login()
Example returns the BusinessObject with the DisplayName Configuration Item
bo := cl.GetBusinessObjectByDisplayName("Configuration Item")
Example returns the BusinessObject with the BusObID 012345678910abcdefghijklmnop
bo := cl.GetBusinessObjectByBusObID("012345678910abcdefghijklmnop")
Example returns the BusinessObjectRecord of the Configuration Item with the PublicID NOTEBOOK001
rec := bo.GetBusinessObjectRecordByPublicID(cl, "NOTEBOOK001")
Example returns the BusinessObjectRecord of the Configuration Item with the RecID abcdefghijklmnop012345678910
rec := bo.GetBusinessObjectRecordByRecID(cl, "abcdefghijklmnop012345678910")
Example returns the first Hit of BusinessObjectRecords with the AssetName NOTEBOOK001 of Type Notebook with the Status Active
rec := bo.SearchObjectRecord(cl, []string{
"AssetName", "EQ", "NOTEBOOK001",
},
[]string{
"Type","EQ","Notebook",
},
[]string{
"Status","EQ","Active"
},
)
Example returns all BusinessObjectRecords of Type Notebook with the Status Active
records := bo.SearchObjectRecord(cl, []string{
[]string{
"Type","EQ","Notebook",
},
[]string{
"Status","EQ","Active"
},
)
This method of BusinessObject takes all given Fields and creates a BusinessObjectRecord with them
rec := bo.NewBusinessObjectRecord(cl, []gocherwell.Field{
gocherwell.Field{
DisplayName: "AssetName",
Value: "NOTEBOOK001",
},
gocherwell.Field{
DisplayName: "AssetType",
Value: "Notebook",
},
gocherwell.Field{
DisplayName: "Status",
Value: "Active",
},
})
This method of BusinessObjectRecord goes over all .FieldValues and commits the changed fields to .Fields and sets Dirty to True
resp := rec.SaveBusinessObjectRecord(cl)
This method of BusinessObjectRecord deletes the executing BusinessObjectRecord
resp := rec.DeleteBusinessObjectRecord(cl)
This method of BusinessObjectRecord links the executing and the given BusinessObjectRecord
The following Example links the Configuration Item NOTEBOOK001 to the *Note with the PublicID NOTE-1234
child := cl.GetBusinessObject("Note").GetBusinessObjectRecordByPublicID("NOTE-1234")
resp := rec.LinkBusinessObjectRecord(cl, child, "Configuration Item Links Note")
This method of BusinessObjectRecord unlinks the executing and the given BusinessObjectRecord
The following Example unlinks the Configuration Item NOTEBOOK001 to the *Note with the PublicID NOTE-1234
child := cl.GetBusinessObject("Note").GetBusinessObjectRecordByPublicID("NOTE-1234")
resp := rec.UninkBusinessObjectRecord(cl, child, "Configuration Item Links Note")