I want to import external data in Jira Assets. I am following the instructions available and the schema - https://api.atlassian.com/jsm/assets/imports/external/schema/versions/2021_09_15
I using static data for the imports during the development process to simplify troubleshooting. Mainly I have:
- The schema file
- A data file devices
- A data file manufacturers
I want to reference a manufacturer to the device attributes using the type "referenced_object". Apparently I dont use the correct syntax because I get a data validation error.
INFO 22:19:17.451 812d3ec2a80b4dec811065ced224a263 {
jsonValidationErrors: [],
dataValidationErrors: [
{
code: 'MISSING_REFERENCE_OBJECT_TYPE_EXTERNAL_ID',
location: 'Device.Manufacturer'
}
],
status: 'error'
}
I spent hours fiddling with the syntax, especially setting the "objectMappingIQL" string but was never able to make the import work.
My files look like this.
schema
{
"$schema": "https://api.atlassian.com/jsm/assets/imports/external/schema/versions/2021_09_15",
"schema": {
"objectSchema": {
"name": "dcim",
"description": "Assets imported from NetBox DCIM",
"objectTypes": [
{
"externalId": "object-type/device",
"name": "Device",
"description": "A device is a physical asset that is managed by NetBox DCIM",
"attributes": [
{
"externalId": "object-type-attribute/device-id",
"name": "id",
"description": "The unique identifier of the device",
"type": "integer",
"label": false,
"unique": true
},
{
"externalId": "object-type-attribute/device-name",
"name": "Device Name",
"description": "The name of the device",
"type": "text",
"label": true
},
{
"externalId": "object-type-attribute/device-url",
"name": "Netbox URL",
"description": "Source URL of the device in Netbox",
"type": "url",
"label": false
},
{
"externalId": "object-type-attribute/device-manufacturer",
"name": "Manufacturer",
"description": "The manufacturer of the device",
"type": "referenced_object",
"referenceObjectExternalId": "object-type/manufacturer",
"referenceObjectTypeName": "Manufacturer",
"label": false,
"selector": "name"
}
]
},
{
"externalId": "object-type/manufacturer",
"name": "Manufacturer",
"description": "A manufacturer is a company that produces devices",
"attributes": [
{
"externalId": "object-type-attribute/manufacturer-id",
"name": "id",
"description": "The unique identifier of the manufacturer",
"type": "integer",
"label": false,
"unique": true
},
{
"externalId": "object-type-attribute/manufacturer-name",
"name": "Manufacturer Name",
"description": "The name of the manufacturer",
"type": "text",
"label": true
},
{
"externalId": "object-type-attribute/manufacturer-url",
"name": "Netbox URL",
"description": "Source URL of the manufacturer in Netbox",
"type": "url",
"label": false
}
]
}
]
}
},
"mapping": {
"objectTypeMappings": [
{
"objectTypeExternalId": "object-type/device",
"objectTypeName": "Device",
"selector": "devices",
"description": "devices",
"attributesMapping": [
{
"attributeExternalId": "object-type-attribute/device-id",
"attributeName": "id",
"attributeLocators": [
"id"
],
"externalIdPart": false
},
{
"attributeExternalId": "object-type-attribute/device-name",
"attributeName": "name",
"attributeLocators": [
"name"
],
"externalIdPart": false
},
{
"attributeExternalId": "object-type-attribute/device-url",
"attributeName": "url",
"attributeLocators": [
"url"
],
"externalIdPart": true
},
{
"attributeExternalId": "object-type-attribute/device-manufacturer",
"attributeName": "manufacturer",
"referenceObjectTypeName": "Manufacturer",
"referenceObjectExternalId": "object-type/manufacturer",
"attributeLocators": [
"device_type.manufacturer.id"
],
"objectMappingIQL": "device_type.manufacturer.id = ${device_type.manufacturer.id}",
"externalIdPart": false
}
]
},
{
"objectTypeExternalId": "object-type/manufacturer",
"objectTypeName": "Manufacturer",
"selector": "manufacturers",
"description": "manufacturers",
"attributesMapping": [
{
"attributeExternalId": "object-type-attribute/manufacturer-id",
"attributeName": "id",
"attributeLocators": [
"id"
],
"externalIdPart": false
},
{
"attributeExternalId": "object-type-attribute/manufacturer-name",
"attributeName": "name",
"attributeLocators": [
"name"
],
"externalIdPart": false
},
{
"attributeExternalId": "object-type-attribute/manufacturer-url",
"attributeName": "url",
"attributeLocators": [
"url"
],
"externalIdPart": true
}
]
}
]
}
}
device data
"devices": [
{
"id": 88,
"url": "https://demo.netbox.dev/api/dcim/devices/88/",
"display": "PP:B117",
"name": "PP:B117",
"device_type": {
"id": 11,
"url": "https://demo.netbox.dev/api/dcim/device-types/11/",
"display": "48-Pair Fiber Panel",
"manufacturer": {
"id": 13,
"url": "https://demo.netbox.dev/api/dcim/manufacturers/13/",
"display": "Generic",
"name": "Generic",
"slug": "generic"
},
"model": "48-Pair Fiber Panel",
"slug": "48-pair-fiber-panel"
},
"role": {
"id": 6,
"url": "https://demo.netbox.dev/api/dcim/device-roles/6/",
"display": "Patch Panel",
"name": "Patch Panel",
"slug": "patch-panel"
},
"device_role": {
"id": 6,
"url": "https://demo.netbox.dev/api/dcim/device-roles/6/",
"display": "Patch Panel",
"name": "Patch Panel",
"slug": "patch-panel"
},
"tenant": {
"id": 13,
"url": "https://demo.netbox.dev/api/tenancy/tenants/13/",
"display": "NC State University",
"name": "NC State University",
"slug": "nc-state"
},
"platform": null,
"serial": "",
"asset_tag": null,
"site": {
"id": 21,
"url": "https://demo.netbox.dev/api/dcim/sites/21/",
"display": "MDF",
"name": "MDF",
"slug": "ncsu-065"
},
"location": null,
"rack": {
"id": 41,
"url": "https://demo.netbox.dev/api/dcim/racks/41/",
"display": "Plant 1",
"name": "Plant 1"
},
"position": 37.0,
"face": {
"value": "front",
"label": "Front"
},
"latitude": null,
"longitude": null,
"parent_device": null,
"status": {
"value": "active",
"label": "Active"
},
"airflow": null,
"primary_ip": null,
"primary_ip4": null,
"primary_ip6": null,
"oob_ip": null,
"cluster": null,
"virtual_chassis": null,
"vc_position": null,
"vc_priority": null,
"description": "",
"comments": "",
"config_template": null,
"config_context": {},
"local_context_data": null,
"tags": [],
"custom_fields": {},
"created": "2021-04-02T00:00:00Z",
"last_updated": "2021-04-02T17:17:28.425000Z",
"console_port_count": 0,
"console_server_port_count": 0,
"power_port_count": 0,
"power_outlet_count": 0,
"interface_count": 0,
"front_port_count": 48,
"rear_port_count": 1,
"device_bay_count": 0,
"module_bay_count": 0,
"inventory_item_count": 1
},
...
manufacturer data
"manufacturers": [
{
"id": 11,
"url": "https://demo.netbox.dev/api/dcim/manufacturers/11/",
"display": "APC",
"name": "APC",
"slug": "apc",
"description": "",
"tags": [],
"custom_fields": {},
"created": "2020-12-22T00:00:00Z",
"last_updated": "2020-12-22T02:25:37.151000Z",
"devicetype_count": 1,
"inventoryitem_count": 0,
"platform_count": 0
},
{
"id": 1,
"url": "https://demo.netbox.dev/api/dcim/manufacturers/1/",
"display": "Arista",
"name": "Arista",
"slug": "arista",
"description": "",
"tags": [],
"custom_fields": {},
"created": "2020-12-18T00:00:00Z",
"last_updated": "2020-12-18T03:17:05.204000Z",
"devicetype_count": 0,
"inventoryitem_count": 0,
"platform_count": 0
},
...