REST APIs
Use this information to understand some sample Rest API requests and responses by using
curl
commands directly.
List all pack rules available in the system
curl --request GET \
--url http://<pack_service_host>:30048/v1/Default/storage/pack-rule
\
Output[
{
"lastUpdated": 1655889686311,
"dataSourceType": "3gppPmXml",
"dataSourceId": "3gppPmXml-json",
"owner": "System",
"versions": 3
},
{
"lastUpdated": 1655886760813,
"dataSourceType": "3gppPmXml",
"dataSourceId": "3gppPmXml-xlsx",
"owner": "System",
"versions": 2
}
]
All the pack rules are version controlled in the Pack Service.
Save new pack rule
curl --request POST \
--url http://<pack_service_host>:30048/v1/Default/storage/pack-rule \
--header 'Content-Type: application/json' \
--data '{
"lastUpdated": 0,
"owner": "System",
"description": "this is test 1",
"state": "draft",
"packRule": {
"dataSourceType": "3gppPmXml",
"dataSourceId": "3gppPmXml-json",
"metaJsonKey": "undefined",
"packs": [ ... ]
}
}'
Output{
"errors": [],
"warnings": [],
"infos": [
{
"code": 117440515,
"message": "Request completed successfully for /storage/pack-rule (2.4.1.0-50-fac28017-1049)"
},
{
"code": 117440542,
"message": "Pack rule updated (0)"
}
]
}
Save new pack rule from Excel
curl --request POST \
--url http://<pack_service_host>:30048/v1/Default/storage/pack-rule \
--header 'Content-Type: multipart/form-data; boundary=---011000010111000001101001' \
--form xlsx=@/home/<user>/Downloads/PackServiceRulesv3-3gppPmXml.xlsx
Output{
"errors": [],
"warnings": [],
"infos": [
{
"code": 117440515,
"message": "Request completed successfully for /storage/pack-rule (2.4.1.0-50-fac28017-1049)"
},
{
"code": 117440542,
"message": "Pack rule updated (0)"
}
]
}
Retrieve the latest pack rule
curl --request GET \
--url http://<pack_service_host>:30048/v1/Default/storage/pack-rule/3gppPmXml/3gppPmXml-xlsx
Output{
"lastUpdated": 1655886760813,
"owner": "System",
"description": "import from excel"m
"packRule": {
"dataSourceType": "3gppPmXml",
"dataSourceId": "3gppPmXml-xlsx",
"metaJsonKey": "undefined",
"packs": [ ... ]
}
}
Retrieve the N-1 pack rule
curl --request GET \
--url 'http://<pack_service_host>:30048/v1/Default/storage/pack-rule/3gppPmXml/3gppPmXml-xlsx?nBefore=1&owner=System'
Output{
"lastUpdated": 1655886579527,
"owner": "System",
"description": "import from excel"m
"packRule": {
"dataSourceType": "3gppPmXml",
"dataSourceId": "3gppPmXml-xlsx",
"metaJsonKey": "undefined",
"packs": [ ... ]
}
}
Retrieve pack rule content as Excel
curl --request GET \
--url http://<pack_service_host>:30048/v1/Default/storage/pack-rule/3gppPmXml/3gppPmXml-json \
--header 'Accept: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
Patch existing pack rule with additional Resource types
When you create a pack rule with one Resource type and when you want to add another Resource type later, you can patch the existing content with new content. New content gets appended to the existing content and the version of the pack gets updated. Currently, patch is applicable only if you want to add additional Resource types alone and not for other artifacts.
- Create a pack rule with the following
command:
curl --request POST \ --url http://<pack_service_host>:30048/v1/Default/storage/pack-rule \ --header 'Content-Type: application/json' \ --data '{ "lastUpdated": 0, "owner": "System", "packRule": { "dataSourceType": "3gppPmXml", "dataSourceId": "3gppPmXml-json", "metaJsonKey": "undefined", "packs": [ { "packId": "00000000-0000-0000-0000-000000000000", "validPackId": false, "domain": "Wireless", "model": { "metaVendor": "Huawei", "metaTechnology": "xml", "metaVersion": "v4", "metaDevice": "undefined", "metaRegion": "undefined", "metaNetwork": "undefined" }, "resourceTypes": [ { "resourceFilter": "[/measCollecFile/fileHeader/fileSender/@elementType='eNodeB']", "resourceType": "ENodeB", "metaResourceId": "/measCollecFile/measData/measInfo/measValue/@measObjLdn", "model": { "relate": { "parentType": "Region", "parentLookupProperty": "region" } }, "kpis": [ { "kpiFilter": "[zipContains(/measCollecFile/measData/measInfo/measTypes, /measCollecFile/measData/measInfo/measValue/measResults, '1593835645')]", "kpiName": "m1593835645", "metaKpiValue": "zipValue(/measCollecFile/measData/measInfo/measTypes, /measCollecFile/measData/measInfo/measValue/measResults, '1593835645')", "metaTimestamp": "toDate(/measCollecFile/fileHeader/measCollec/@beginTime, 'yyyy-MM-dd\\'T\\'HH:mm:ssX')", "metaInterval": "replaceRegex(/measCollecFile/measData/measInfo/granPeriod/@duration, '[A-Z]','')", "unit": "bytes", "aggregation": "avg" }, { "kpiFilter": "[zipContains(/measCollecFile/measData/measInfo/measTypes, /measCollecFile/measData/measInfo/measValue/measResults, '1593835646')]", "kpiName": "m1593835646", "metaKpiValue": "zipValue(/measCollecFile/measData/measInfo/measTypes, /measCollecFile/measData/measInfo/measValue/measResults, '1593835646')", "metaTimestamp": "toDate(/measCollecFile/fileHeader/measCollec/@beginTime, 'yyyy-MM-dd\\'T\\'HH:mm:ssX')", "metaInterval": "replaceRegex(/measCollecFile/measData/measInfo/granPeriod/@duration, '[A-Z]','')", "unit": "bytes", "aggregation": "avg" } ] } ] } ] }, "description": "this is test 1", "state": "draft" }'
- List the pack rule with the following
command:
Outputcurl --request GET \ --url http://<pack_service_host>:30048/v1/Default/storage/pack-rule
[ { "lastUpdated": 1655951895384, "dataSourceType": "3gppPmXml", "dataSourceId": "3gppPmXml-json", "owner": "System", "versions": 1 } ]
- Patch the pack rule with a new Resource type with the following
command:
curl --request PATCH \ --url http://<pack_service_host>:30048/v1/Default/storage/pack-rule/3gppPmXml/3gppPmXml-json \ --header 'Content-Type: application/json' \ --data '{ "dataSourceType": "3gppPmXml", "dataSourceId": "3gppPmXml-json", "metaJsonKey": "undefined", "packs": [ { "packId": "00000000-0000-0000-0000-000000000000", "validPackId": false, "domain": "Wireless", "model": { "metaVendor": "Huawei", "metaTechnology": "xml", "metaVersion": "v1", "metaDevice": "undefined", "metaRegion": "undefined", "metaNetwork": "undefined" }, "resourceTypes": [ { "resourceFilter": "[/measCollecFile/fileHeader/fileSender/@elementType='RNC']", "resourceType": "RNC", "metaResourceId": "/measCollecFile/measData/measInfo/measValue/@measObjLdn", "model": { "relate": { "parentType": "Region", "parentLookupProperty": "region" } }, "kpis": [ { "kpiFilter": "[zipContains(/measCollecFile/measData/measInfo/measTypes, /measCollecFile/measData/measInfo/measValue/measResults, '1593835645')]", "kpiName": "m1593835645", "metaKpiValue": "zipValue(/measCollecFile/measData/measInfo/measTypes, /measCollecFile/measData/measInfo/measValue/measResults, '1593835645')", "metaTimestamp": "toDate(/measCollecFile/fileHeader/measCollec/@beginTime, 'yyyy-MM-dd\\'T\\'HH:mm:ssX')", "metaInterval": "replaceRegex(/measCollecFile/measData/measInfo/granPeriod/@duration, '[A-Z]','')", "unit": "bytes", "aggregation": "avg" }, { "kpiFilter": "[zipContains(/measCollecFile/measData/measInfo/measTypes, /measCollecFile/measData/measInfo/measValue/measResults, '1593835646')]", "kpiName": "m1593835646", "metaKpiValue": "zipValue(/measCollecFile/measData/measInfo/measTypes, /measCollecFile/measData/measInfo/measValue/measResults, '1593835646')", "metaTimestamp": "toDate(/measCollecFile/fileHeader/measCollec/@beginTime, 'yyyy-MM-dd\\'T\\'HH:mm:ssX')", "metaInterval": "replaceRegex(/measCollecFile/measData/measInfo/granPeriod/@duration, '[A-Z]','')", "unit": "bytes", "aggregation": "avg" } ] } ] } ] }'
- List the pack rule with the following
command:
Outputcurl --request GET \ --url http://<pack_service_host>:30048/v1/Default/storage/pack-rule
[ { "lastUpdated": 1655951941330, "dataSourceType": "3gppPmXml", "dataSourceId": "3gppPmXml-json", "owner": "System", "versions": 2 } ]
- You can also verify that the new Resource type RNC is added with the following
command:
curl --request GET \ --url http://<pack_service_host>:30048/v1/Default/storage/pack-rule/3gppPmXml/3gppPmXml-json
Enrich the pack with Lookup
Lookup is needed
for data enrichment that is not directly available from incoming raw data. Raw data comes with
certain code that defines lookup against another lookup table to get the needed data. It can
identify region and market for incoming network element. It is based on parent code that needs to be
looked up against customer-provided lookup table to get appropriate region and market for reporting
purpose.
Note: The Record path expression
csvLookup
is validated against this lookup
to make sure the correct lookup table and value field are
available.curl --request POST \
--url http://<pack_service_host>:30048/v1/Default/storage/pack-lookup \
--header 'Content-Type: application/json' \
--data '{
"lastUpdated": 0,
"owner": "System",
"description": "inital",
"lookup": {
"dataSourceType": "3gppPmXml",
"dataSourceId": "3gppPmXml-json",
"lookupName": "location",
"valueFields": [
"region",
"market"
],
"records": [
{
"key": "id01",
"values": [
"Johor",
"South"
]
},
{
"key": "id02",
"values": [
"Kuala Lumpur",
"Central"
]
},
{
"key": "id03",
"values": [
"Penang",
"North"
]
}
]
}
}'
Output{
"errors": [],
"warnings": [],
"infos": [
{
"code": 117440515,
"message": "Request completed successfully for /storage/pack-lookup (2.4.1.0-129-f426f664-1206)"
},
{
"code": 117440549,
"message": "Pack lookup updated (1658120060064)"
}
]
}
View the Pack rule model APIs in Swagger editor
Follow these steps:
- Click the following files to view the Pack service APIs in Swagger Editor (https://editor.swagger.io/) that is in built into IBM Documentation: