AAIService Named Query
Named-Query is one of the query types supported by AAI Service.
The template of the JSON request is:
named-query JSON template
{
"query-parameters": {
"named-query": {
"named-query-uuid": "<query-uuid>"
}
},
"instance-filters": {
"instance-filter": [
]
}
}
The instance-filter template is:
instance-filter template
{
"<resource-name>": {
"<resource-id>": "<id-value>"
}
}
Sample JSON named-query request
{
"query-parameters": {
"named-query": {
"named-query-uuid": "75d55786-200b-49fd-92d7-1393e755d693"
}
},
"instance-filters": {
"instance-filter": [
{
"service-instance": {
"service-instance-id": "service-instance-id-value"
}
}
]
}
}
Converting JSON request to DirectedGraph node
When creating the DG node, the developer needs to pass filter data to the request. Named query is identified by named query UUID. Each query requires instance-filters to be provided to execute.
To add a filter to the DG node, add an attribute to the SvcLogicContext.
The format of the attribute name is : <prefix> + instance-filters.instance-filter[<offset of the filter>] .<resource identifier>
After adding filter entry, you must specify size of filter array using following format of the attribute name: <prefix> + instance-filters.instance-filter_length
named-query call (sample)
<set>
<parameter name="namedQueryData.instance-filters.instance-filter[0].l3-network.network-role" value="$some-value"/>
<parameter name="namedQueryData.instance-filters.instance-filter_length" value="1"/>
</set>
<get-resource
plugin="org.openecomp.sdnc.sli.aai.AAIService"
resource="named-query"
key="named-query-uuid = '${named-query-uuid}' AND prefix = 'namedQueryData' "
local-only="false"
pfx="vnfProfile" />
Step-by-step guide
- Obtain named query uuid for the query you are working with, from the SE.
- Set parameters in the SvcLogicContext:
- namedQueryData.query-parameters.named-query.named-query-uuid - Note: uuid needs to be set in both key and in SvcLogicContext using this property name
Filters - filters are set using prefix: namedQueryData.instance-filters.instance-filter[n] followed by resource name + '.' + id
- namedQueryData.instance-filters.instance-filter_length - specifies number of filters
- data prefix value "namedQueryData" was chosen for this example and can be changed as long as it is also updated in the key string.
Please keep in mind that named-query API currently supports requests for "logical-link", "pnf", "l3-network" and "service-instance".
If your project requires support for other types in the filter, please contact Richard (rt0525) with the request information that needs to be supported by named-query.
Related articles
- Page: