Hi,
While working with the External Imports REST API for Assets I’m facing an unexpected issue when configuring the Assets Schema to “Pass all attributes to child object types”. It appears that such option is needed to have the parent object type show the aggregated count of all it’s child object type assets.
Having an schema configured as described above, I call the GET /schema-and-mapping
resource and the JSON I get has all the child object types with no attributes, and no indication that the child object types are inheriting from the parent. In order to do the objectTypeMapping it’s required to use the externalId value to tie the type and the mapping. Since there are no attributes in the child object type attributes I use the parent’s attribute externalId. However this results in an invalid mapping when submitting it by PUT /mapping
.
This is the JSON returned by GET /schema-and-mapping:
{
"schema": {
"objectSchema": {
"name": "PARROYO SCHEMA",
"description": "",
"objectTypes": [
{
"externalId": "cmdb::externalId/5e0758d8-c76e-4289-997f-ec5e61b2f71a",
"name": "Parent A",
"description": "",
"attributes": [
{
"externalId": "cmdb::externalId/775cec56-0096-4eea-b027-510fa58a003a",
"name": "Key",
"description": "",
"type": "text",
"label": false,
"minimumCardinality": 1,
"maximumCardinality": 1,
"unique": false
},
{
"externalId": "cmdb::externalId/8797464c-8039-4daa-a733-ea652176b194",
"name": "Attribute 1",
"description": "",
"type": "text",
"label": false,
"minimumCardinality": 0,
"maximumCardinality": 1,
"unique": false
},
{
"externalId": "cmdb::externalId/52318d67-9972-4c7a-b4a0-cd82e0ab3b47",
"name": "Name",
"description": "The name of the object",
"type": "text",
"label": true,
"minimumCardinality": 1,
"maximumCardinality": 1,
"unique": false
},
{
"externalId": "cmdb::externalId/62c18302-785c-4ac2-8acf-10e65d110b18",
"name": "Attribute 2",
"description": "",
"type": "text",
"label": false,
"minimumCardinality": 0,
"maximumCardinality": 1,
"unique": false
}
],
"children": [
{
"externalId": "cmdb::externalId/374036f5-774b-4c9a-8859-ed3e718f1768",
"name": "Child A1",
"description": ""
},
{
"externalId": "cmdb::externalId/3dfe439c-b707-4993-a96d-ba56666d8822",
"name": "Child A2",
"description": "",
"children": [
{
"externalId": "cmdb::externalId/4cfb7179-f021-4a66-be1b-acd664b374c0",
"name": "Child A21",
"description": ""
}
]
}
]
},
{
"externalId": "cmdb::externalId/cf4cf345-7490-4df2-af23-244c65f18fbe",
"name": "Parent B",
"description": "",
"attributes": [
{
"externalId": "cmdb::externalId/191c5649-8730-437c-a21d-bba01cc25431",
"name": "Attribute 4",
"description": "",
"type": "text",
"label": false,
"minimumCardinality": 0,
"maximumCardinality": 1,
"unique": false
},
{
"externalId": "cmdb::externalId/203de4db-36cb-483a-9125-223b8d542cfe",
"name": "Attribute 3",
"description": "",
"type": "text",
"label": false,
"minimumCardinality": 0,
"maximumCardinality": 1,
"unique": false
},
{
"externalId": "cmdb::externalId/7af86c46-3bf0-4dd7-b669-d18af13cb86f",
"name": "Name",
"description": "The name of the object",
"type": "text",
"label": true,
"minimumCardinality": 1,
"maximumCardinality": 1,
"unique": false
},
{
"externalId": "cmdb::externalId/c01c42be-4677-4757-ae24-4c3fbc1d6f2c",
"name": "Key",
"description": "",
"type": "text",
"label": false,
"minimumCardinality": 1,
"maximumCardinality": 1,
"unique": false
}
]
}
]
}
},
"mapping": { "objectTypeMappings": [] }
}
See the difference between Parent A
and Parent B
structures, no attributes for child object types on Parent A
. No flag to note children are inheriting attributes. How can I differentiate betwen object types that are inheriting and object types that do just don’t have attributes configured?
Using the parent’s attribute externalId’s I come up with this mapping:
"mapping": {
"objectTypeMappings": [
{
"objectTypeExternalId": "cmdb::externalId/374036f5-774b-4c9a-8859-ed3e718f1768",
"objectTypeName": "Child A1",
"selector": "childA1",
"description": "",
"unknownValues": "USE_DEFAULT",
"attributesMapping": [
{
"attributeExternalId": "cmdb::externalId/8797464c-8039-4daa-a733-ea652176b194",
"attributeName": "Attribute 1",
"attributeLocators": ["attribute1"],
"externalIdPart": false
},
{
"attributeExternalId": "cmdb::externalId/62c18302-785c-4ac2-8acf-10e65d110b18",
"attributeName": "Attribute 2",
"attributeLocators": ["attribute2"],
"externalIdPart": false
}
]
},
{
"objectTypeExternalId": "cmdb::externalId/3dfe439c-b707-4993-a96d-ba56666d8822",
"objectTypeName": "Child A2",
"selector": "childA2",
"description": "",
"unknownValues": "USE_DEFAULT",
"attributesMapping": [
{
"attributeExternalId": "cmdb::externalId/8797464c-8039-4daa-a733-ea652176b194",
"attributeName": "Attribute 1",
"attributeLocators": ["attribute1"],
"externalIdPart": false
},
{
"attributeExternalId": "cmdb::externalId/62c18302-785c-4ac2-8acf-10e65d110b18",
"attributeName": "Attribute 2",
"attributeLocators": ["attribute2"],
"externalIdPart": false
}
]
},
{
"objectTypeExternalId": "cmdb::externalId/4cfb7179-f021-4a66-be1b-acd664b374c0",
"objectTypeName": "Child A21",
"selector": "childA21",
"description": "",
"unknownValues": "USE_DEFAULT",
"attributesMapping": [
{
"attributeExternalId": "cmdb::externalId/8797464c-8039-4daa-a733-ea652176b194",
"attributeName": "Attribute 1",
"attributeLocators": ["attribute1"],
"externalIdPart": false
},
{
"attributeExternalId": "cmdb::externalId/62c18302-785c-4ac2-8acf-10e65d110b18",
"attributeName": "Attribute 2",
"attributeLocators": ["attribute2"],
"externalIdPart": false
}
]
}
]
}
}
And the PUT /mapping
result returns an error with this message:
{
"jsonValidationErrors": [],
"dataValidationErrors": [
{
"code": "MAPPING_INVALID_EXTERNAL_ID",
"location": "cmdb::externalId/8797464c-8039-4daa-a733-ea652176b194"
},
{
"code": "MAPPING_INVALID_EXTERNAL_ID",
"location": "cmdb::externalId/62c18302-785c-4ac2-8acf-10e65d110b18"
},
{
"code": "MAPPING_INVALID_EXTERNAL_ID",
"location": "cmdb::externalId/8797464c-8039-4daa-a733-ea652176b194"
},
{
"code": "MAPPING_INVALID_EXTERNAL_ID",
"location": "cmdb::externalId/62c18302-785c-4ac2-8acf-10e65d110b18"
},
{
"code": "MAPPING_INVALID_EXTERNAL_ID",
"location": "cmdb::externalId/8797464c-8039-4daa-a733-ea652176b194"
},
{
"code": "MAPPING_INVALID_EXTERNAL_ID",
"location": "cmdb::externalId/62c18302-785c-4ac2-8acf-10e65d110b18"
}
],
"status": "error"
}
Has anybody figured out the workaround for this?
Thank you for reading and for your comments