Assign sites and sources using JSON
Sites and sources are granted to users respectively by opUser.Sites and opUser.Sources identifiers.
Sites/sources from JSON path
You can grant sites/sources by providing a JSON path starting at the root of the users definition.
Template
{
"OpUser": {
"RootPath": "myUsers[*]",
"Items": [
...
{
"OpIdentifier": "opUser.Sites",
"Path": "sitesForUser[*].SiteBusinessKey"
},
{
"OpIdentifier": "opUser.Sources",
"Path": "sourcesForUser[*].SourceSerialNumber"
}
]
}
}
Data
{
"myUsers": [
{
...
"sitesForUser": [
{
"SiteBusinessKey": "Store_Deurne"
},
{
"SiteBusinessKey": "Store_Charleroi"
}
],
"sourcesForUser": []
},
{
...
"sitesForUser": [
{
"SiteBusinessKey": "Store_Brussels"
}
],
"sourcesForUser": [
{
"SourceSerialNumber": "SN0001"
},
{
"SourceSerialNumber": "SN0002"
},
{
"SourceSerialNumber": "SN0003"
}
]
}
]
}
The Path expression is applied to all child elements under 'myUser'. All values found under myUser.sitesForUser.SiteBusinessKey will the be considered as the business keys of the sites to grant to the user. The same behaviour applies to sources.
See Json path sample.
Sites/sources from custom query
You can grant sites/sources by providing a custom query, which follows the same syntax as the one you can use in DataHub.
Template
{
"OpUser": {
"RootPath": "myUsers[*]",
"Items": [
...
{
"OpIdentifier": "opUser.Sites",
"Path": "SiteQuery",
"Transform": {
"Operation": "query"
}
},
{
"OpIdentifier": "opUser.Sources",
"Path": "SourceQuery",
"Transform": {
"Operation": "query"
}
}
]
}
}
Data
{
"myUsers": [
{
...
"SiteQuery": "Name = 'Store_Deurne' OR City = 'Charleroi'"
},
{
...
"SourceQuery": "SerialNumber like SN000 AND 'Master Data'.'Technical Identifiers'.BusinessKey != SN0001"
}
]
}
Important
When you use custom query for sites or sources, both must be defined by custom query, you can't mix e.g. custom query for sites and path for sources.
Sources depend on sites query, according to the following matrix:
Site query | Source query | Result |
---|---|---|
Specified | Specified | User has access to sources belonging to the sites filtered by the sites query and again filtered by the sources query |
Specified | Not specified | User has access to all sources belonging to the sites filtered by the sites query |
Not specified | Specified | User has access to sources belonging to the account filtered by the sources query but no access to any site |
Not specified | Not specified | User does not have access to any site or source |
See Custom query (Json) sample.
Sites/sources from discrete list
You can grant sites/sources by providing a discrete list of site/source business keys. Remember that the business keys are specified by opKey identifier under opSite element and by opKey identifier under opSource identifiers in the template.
Template
{
"OpUser": {
"RootPath": "myUsers[*]",
"Items": [
...
{
"OpIdentifier": "opUser.Sites",
"Path": "SiteList",
"Transform": {
"Operation": "list"
}
},
{
"OpIdentifier": "opUser.Sources",
"Path": "SourceList",
"Transform": {
"Operation": "list",
"Value" : "|"
}
}
]
}
}
Data
{
"myUsers": [
{
...
"SiteList": "Store_Deurne,Store_Charleroi"
},
{
...
"SourceList": "SN0001|SN0002|SN0003"
}
]
}
The list of business keys is expressed as string separated by a separator, which is ',' by default. You can overwrite the default separator by providing the separator character as a value of the transform operation.
See Sites/sources list (Json) sample.
Important
When you use list for sites or sources, both must be defined by list, you can't mix e.g. custom query for sites and list for sources.
Contrary to using custom query to grant sites/sources, the list of sites and sources are not dependent, according to the following table:
Site query | Source query | Result |
---|---|---|
Specified | Specified | User has access to specified sites list and to to specified sources list, wether the sources belong to the sites or not |
Specified | Not specified | User has access to specified sites list but has no source access |
Not specified | Specified | User has access to specified sources list but has no site access |
Not specified | Not specified | User does not have access to any site or source |