编写REST API脚本¶
与geoserver中的其他模块一样,您可以使用RESTful接口添加、更新、读取和删除脚本。
警告
在更改geoserver默认管理密码之前,脚本RESTAPI将无法工作。
WPS脚本¶
/scripts/wps[.<format>]¶
方法 |
行动 |
状态代码 |
格式 |
默认格式 |
|---|---|---|---|---|
GET |
列出所有脚本 |
200 |
HTML、XML、JSON |
HTML |
列出WPS脚本¶
curl-u用户名:password-xget-h“accept:text/xml”http://localhost:8080/geoserver/rest/scripts/wps
/scripts/wps/<script.ext>¶
方法 |
行动 |
状态代码 |
格式 |
默认格式 |
|---|---|---|---|---|
GET |
获取脚本的内容 |
200 |
文本 |
文本 |
PUT |
添加新脚本 |
200 |
文本 |
文本 |
PUT |
更新现有脚本 |
200 |
文本 |
文本 |
DELETE |
删除现有脚本 |
200 |
获取WPS脚本¶
curl-u用户名:password-xget-h“accept:text/xml”http://localhost:8080/geoserver/rest/scripts/wps/buffer.groovy
添加WPS脚本¶
curl-u用户名:password-xput-h“content-type:text/plain”-data binary@buffer.groovy http://localhost:8080/geoserver/rest/scripts/wps/buffer.groovy
更新WPS脚本¶
curl-u用户名:password-xput-h“content-type:text/plain”-data binary@buffer.groovy http://localhost:8080/geoserver/rest/scripts/wps/buffer.groovy
删除WPS脚本¶
curl-u用户名:password-xdelete http://localhost:8080/geoserver/rest/scripts/wps/buffer.groovy
筛选函数脚本¶
/scripts/function[.<format>]¶
方法 |
行动 |
状态代码 |
格式 |
默认格式 |
|---|---|---|---|---|
GET |
列出所有脚本 |
200 |
HTML、XML、JSON |
HTML |
列出函数脚本¶
curl-u用户名:password-xget-h“accept:text/xml”http://localhost:8080/geoserver/rest/scripts/function
/scripts/function/<script.ext>¶
方法 |
行动 |
状态代码 |
格式 |
默认格式 |
|---|---|---|---|---|
GET |
获取脚本的内容 |
200 |
文本 |
文本 |
PUT |
添加新脚本 |
200 |
文本 |
文本 |
PUT |
更新现有脚本 |
200 |
文本 |
文本 |
DELETE |
删除现有脚本 |
200 |
获取函数脚本¶
curl-u用户名:password-xget-h“accept:text/xml”http://localhost:8080/geoserver/rest/scripts/function/bufferedcentroid.groovy
添加函数脚本¶
curl-u用户名:password-xput-h“content-type:text/plain”-data binary@bufferedcentroid.groovy http://localhost:8080/geoserver/rest/scripts/function/bufferedcentroid.groovy
更新函数脚本¶
curl-u用户名:password-xput-h“content-type:text/plain”-data binary@bufferedcentroid.groovy http://localhost:8080/geoserver/rest/scripts/function/bufferedcentroid.groovy
删除函数脚本¶
curl-u用户名:password-xdelete http://localhost:8080/geoserver/rest/scripts/function/bufferedcentroid.groovy
WFS事务脚本¶
/scripts/wfs/tx[.<format>]¶
方法 |
行动 |
状态代码 |
格式 |
默认格式 |
|---|---|---|---|---|
GET |
列出所有脚本 |
200 |
HTML、XML、JSON |
HTML |
列出WFSTX脚本¶
curl-u用户名:password-xget-h“accept:text/json”http://localhost:8080/geoserver/rest/scripts/wfs/tx
/scripts/wfs/tx/<script.ext>¶
方法 |
行动 |
状态代码 |
格式 |
默认格式 |
|---|---|---|---|---|
GET |
获取脚本的内容 |
200 |
文本 |
文本 |
PUT |
添加新脚本 |
200 |
文本 |
文本 |
PUT |
更新现有脚本 |
200 |
文本 |
文本 |
DELETE |
删除现有脚本 |
200 |
获取wfstx脚本¶
curl-u用户名:password-xget-h“accept:text/xml”http://localhost:8080/geoserver/rest/scripts/wfs/tx/check.groovy
添加WFSTX脚本¶
curl-u用户名:password-xput-h“content-type:text/plain”-data binary@check.groovy http://localhost:8080/geoserver/rest/scripts/wfs/tx/check.groovy
更新wfstx脚本¶
curl-u用户名:password-xput-h“content-type:text/plain”-data binary@check.groovy http://localhost:8080/geoserver/rest/scripts/wfs/tx/check.groovy
删除WFSTX脚本¶
curl-u用户名:password-xdelete http://localhost:8080/geoserver/rest/scripts/wfs/tx/check.groovy
应用程序脚本¶
/scripts/apps/[.<format>]¶
方法 |
行动 |
状态代码 |
格式 |
默认格式 |
|---|---|---|---|---|
GET |
列出所有脚本 |
200 |
HTML、XML、JSON |
HTML |
列表应用程序¶
curl-u用户名:password-xget-h“accept:text/xml”http://localhost:8080/geoserver/rest/scripts/apps
/scripts/apps/<name>/main.<ext>¶
方法 |
行动 |
状态代码 |
格式 |
默认格式 |
|---|---|---|---|---|
GET |
获取脚本的内容 |
200 |
文本 |
文本 |
PUT |
添加新脚本 |
200 |
文本 |
文本 |
PUT |
更新现有脚本 |
200 |
文本 |
文本 |
DELETE |
删除现有脚本 |
200 |
获取应用程序¶
curl-u用户名:password-xget-h“accept:text/xml”http://localhost:8080/geoserver/rest/scripts/apps/buffer/main.groovy
添加应用程序脚本¶
curl-u用户名:password-xput-h“content-type:text/plain”-data binary@app_buffer.groovy http://localhost:8080/geoserver/rest/scripts/apps/buffer/main.groovy
更新应用程序脚本¶
curl-u用户名:password-xput-h“content-type:text/plain”-data binary@app_buffer.groovy http://localhost:8080/geoserver/rest/scripts/apps/buffer/main.groovy
删除添加脚本¶
curl-u用户名:password-xdelete http://localhost:8080/geoserver/rest/scripts/apps/buffer/main.groovy
编写会话脚本¶
/scripts/sessions[.<format>]¶
方法 |
行动 |
状态代码 |
格式 |
默认格式 |
|---|---|---|---|---|
GET |
列出所有脚本 |
200 |
JSON |
JSON |
列出脚本会话¶
curl-u用户名:password-xget-h“accept:text/json”http://localhost:8080/geoserver/rest/sessions
/scripts/sessions/<language>/<id>¶
方法 |
行动 |
状态代码 |
格式 |
默认格式 |
|---|---|---|---|---|
GET |
获取脚本会话 |
200 |
JSON |
JSON |
POST |
创建脚本会话 |
200 |
TEXT |
文本 |
PUT |
运行脚本 |
200 |
文本 |
文本 |
获取脚本会话¶
curl-u用户名:password-xget-h“accept:text/json”http://localhost:8080/geoserver/rest/sessions/groovy/0
创建脚本会话¶
curl-u用户名:password-xpost http://localhost:8080/geoserver/rest/sessions/groovy
在会话中运行脚本¶
curl-u用户名:password-xput--data binary@script.groovy http://localhost:8080/geoserver/rest/sessions/groovy/0