批处理REST API¶
批处理操作允许同时对规则和管理规则运行多个INSERT、UPDATE和DELETE。所有操作都在单个事务中执行:这意味着要么所有操作都成功,要么所有操作都被回滚。
安全性¶
只有具有该角色的用户才能访问Geofence REST API ROLE_ADMIN
。
输入/输出¶
数据对象传输¶
数据对象的传输同时支持XML和JSON。缺省值为XML。或者,可以通过设置 Content-Type
和 Accept
将http标头发送到 application/json
在您的请求中。
A Batch
数据对象传输必须声明 operations
。每项操作都需要声明:
这个
service
名字 (rules
对于规则操作或adminrules
用于AdminRule操作)。这个
type
手术的时间 (insert
,update
,delete
)。这个
id
对象的情况下对其执行操作的实体的update
或delete
类型。这个
Rule
或AdminRule
数据对象在以下情况下的传输insert
或update
手术。
对XML::中的批处理进行编码
<Batch>
<operations service="rules" id="2" type="update">
<Rule id="2">
<access>ALLOW</access>
<layer>layer</layer>
<priority>5</priority>
<request>GETMAP</request>
<roleName>ROLE_AUTHENTICATED</roleName>
<service>WMS</service>
<workspace>ws</workspace>
</Rule>
</operations>
<operations service="rules" id="5" type="delete" />
<operations service="adminrules" type="insert">
<RuleAdmin>
<priority>2</priority>
<roleName>ROLE_USER</roleName>
<workspace>ws</workspace>
<access>ADMIN</access>
</RuleAdmin>
</operations>
</Batch>
JSON::中批处理的编码
{
"Batch":{
"operations":[
{
"@service":"adminrules",
"@type":"update",
"@id":"3",
"Rule":{
"access":"ALLOW",
"layer":"layer",
"priority":5,
"request":"GETMAP",
"service":"WMS",
"roleName":"ROLE_AUTHENTICATED",
"workspace":"ws"
}
},
{
"@service":"rules",
"@type":"delete",
"@id":5
},
{
"@service":"adminrules",
"@type":"insert",
"AdminRule":{
"priority":2,
"roleName":"ROLE_USER",
"workspace":"ws",
"access":"ADMIN"
}
}
]
}
}
请求¶
/rest/geofence/batch/exec
¶
发出一个批处理操作,执行所有声明的操作。
方法 |
行动 |
响应码 |
响应 |
---|---|---|---|
POST |
执行批处理 |
200 |
OK |
400 |
BadRequest:请求正文格式错误,添加的规则重复 |
||
404 |
NotFound:未找到规则 |
||
500 |
InternalServerError:意外错误 |
Previous: 管理规则REST API
Next: 使用内部GeoFence服务器(教程)