Hi Dojo,
I'm trying to create DomInstance with optional and multiple sections of particular section definition and got error about InvalidSections and DomInstanceDoesNotContainRequiredModuleSections.
It is allowed in DomDefinition
my code:
var myInstance = new DomInstance() {DomDefinitionId = serviceDomDef.ID, StatusId = "draft"};
var serviceSecDef = domHelper.SectionDefinitions.Read(SectionDefinitionExposers.Name.Equal("section_service")).FirstOrDefault();
var inputSecDef = domHelper.SectionDefinitions.Read(SectionDefinitionExposers.Name.Equal("section_input")).FirstOrDefault();
var outputSecDef = domHelper.SectionDefinitions.Read(SectionDefinitionExposers.Name.Equal("section_output")).FirstOrDefault();var mySection = new Section(serviceSecDef);
mySection.AddOrUpdateValue(serviceSecDef.GetAllFieldDescriptors().FirstOrDefault(fd => fd.Name == "ServiceName"), "TestName");
myInstance.Sections.Add(mySection);/////////////////// INPUT SECTION ////////////////////////
mySection = new Section(inputSecDef);
mySection.AddOrUpdateValue(inputSecDef.GetAllFieldDescriptors().FirstOrDefault(fd => fd.Name == "InDstIP"), "1.2.3.4");
myInstance.Sections.Add(mySection);/////////////////// SECOND INPUT SECTION ////////////////////////
mySection = new Section(inputSecDef);
mySection.AddOrUpdateValue(inputSecDef.GetAllFieldDescriptors().FirstOrDefault(fd => fd.Name == "InDstIP"), "5.6.7.8");
myInstance.Sections.Add(mySection);/////////////////// OUTPUT SECTION ////////////////////////
mySection = new Section(outputSecDef);
mySection.AddOrUpdateValue(outputSecDef.GetAllFieldDescriptors().FirstOrDefault(fd => fd.Name == "OutDstIP"), "4.3.2.1");
myInstance.Sections.Add(mySection);domHelper.DomInstances.Create(myInstance);
I got error:
Error Creating Instance: Exception of type 'Skyline.DataMiner.Net.ManagerStore.CrudFailedException' was thrown.
Error reason: DomInstanceDoesNotContainRequiredModuleSections
TraceData: (amount = 1)
- ErrorData: (amount = 1)
- ErrorReason: DomInstanceDoesNotContainRequiredModuleSections, DomInstance: DomInstance[3ced7b30-9083-472d-944d-d8d6b271ea69], DomInstanceName: , InvalidSections: SectionDefinitionID[48bdaef5-d26f-4a09-92a2-49f0f72ae910],
My DomDefinition looks like:
{
"Id": {
"Id": "af30687a-a6c6-4c51-b83a-9055074b1071",
"ModuleId": "headend_test"
},
"SectionDefinitionLinks": [
{
"SectionDefinitionID": {
"Id": "8fa03266-483d-4b9c-a3dc-f0ac5112c159",
"ModuleId": "headend_test"
},
"IsSoftDeleted": false,
"IsOptional": false,
"AllowMultipleSections": false
},
{
"SectionDefinitionID": {
"Id": "48bdaef5-d26f-4a09-92a2-49f0f72ae910",
"ModuleId": "headend_test"
},
"IsSoftDeleted": false,
"IsOptional": true,
"AllowMultipleSections": true
},
{
"SectionDefinitionID": {
"Id": "83f7c76a-c9ae-4474-8b92-3d271a4f5ada",
"ModuleId": "headend_test"
},
"IsSoftDeleted": false,
"IsOptional": true,
"AllowMultipleSections": true
}
],
"Name": "Service",
"VisualStructure": {
"SectionDefinitionInfos": [
],
"IsHidden": false
},
"BehaviorDefinitionId": null,
"ModuleSettingsOverrides": {
"NameDefinition": null
},
"SyncLastModified": "2024-10-24T11:26:45.2650291Z",
"LastModifiedBy": "Administrator",
"CreatedAt": "2024-09-27T12:34:41.5468175Z",
"CreatedBy": "Jan Palansky"
}
It works for singular sections. I also tried create instance without input and output section (which are optional) and also got simillar error.
Can you please help me?