rest_reference.rst 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113
  1. .. _importer_rest_reference:
  2. REST API
  3. ========
  4. Importer concepts
  5. -----------------
  6. The importer REST api is built around a tree of objects representing a single import, structured as follows:
  7. * import
  8. * target workspace
  9. * data
  10. * task (one or more)
  11. * data
  12. * layer
  13. * transformation (one or more)
  14. An **import** refers to the top level object and is a "session" like entity the state of the entire import. It maintains information relevant to the import as a whole such as user information, timestamps
  15. along with optional information that is uniform along all tasks, such as a target workspace, the shared input data (e.g., a directory, a database).
  16. An import is made of any number of task objects.
  17. A **data** is the description of the source data of a import (overall) or a task. In case the import has a global data definition, this normally refers to an aggregate
  18. store such as a directory or a database, and the data associated to the tasks refers to a single element inside such aggregation, such as a single file or table.
  19. A **task** represents a unit of work to the importer needed to register one new layer, or alter an existing one, and contains the following information:
  20. * The data being imported
  21. * The target store that is the destination of the import
  22. * The target layer
  23. * The data of a task, referred to as its source, is the data to be processed as part of the task.
  24. * The transformations that we need to apply to the data before it gets imported
  25. This data comes in a variety of forms including:
  26. * A spatial file (Shapefile, GeoTiff, KML, etc...)
  27. * A directory of spatial files
  28. * A table in a spatial database
  29. * A remote location that the server will download data from
  30. A task is classified as either "direct" or "indirect". A *direct task* is one in which the data being imported requires no transformation to be imported.
  31. It is imported directly. An example of such a task is one that involves simply importing an existing Shapefile as is.
  32. An *indirect task* is one that does require a **transformation** to the original import data. An example of an indirect task is one that involves importing a Shapefile into an existing PostGIS database.
  33. Another example of indirect task might involve taking a CSV file as an input, turning a x and y column into a Point, remapping a string column into a timestamp, and finally import the result into a PostGIS.
  34. REST API Reference
  35. ------------------
  36. All the imports
  37. ^^^^^^^^^^^^^^^
  38. /imports
  39. """"""""
  40. .. list-table::
  41. :header-rows: 1
  42. * - Method
  43. - Action
  44. - Status Code/Headers
  45. - Input
  46. - Output
  47. - Parameters
  48. * - GET
  49. - Retrieve all imports
  50. - 200
  51. - n/a
  52. - Import Collection
  53. - n/a
  54. * - POST
  55. - Create a new import
  56. - 201 with Location header
  57. - n/a
  58. - Imports
  59. - async=false/true,execute=false/true
  60. Retrieving the list of all imports
  61. """"""""""""""""""""""""""""""""""
  62. .. code-block:: text
  63. GET /imports
  64. results in::
  65. Status: 200 OK
  66. Content-Type: application/json
  67. {
  68. "imports": [{
  69. "id": 0,
  70. "state": "COMPLETE",
  71. "href": "http://localhost:8080/geoserver/rest/imports/0"
  72. }, {
  73. "id": 1,
  74. "state": "PENDING",
  75. "href": "http://localhost:8080/geoserver/rest/imports/1"
  76. }]
  77. }
  78. Creating a new import
  79. """""""""""""""""""""
  80. Posting to the /imports path a import json object creates a new import session::
  81. Content-Type: application/json
  82. {
  83. "import": {
  84. "targetWorkspace": {
  85. "workspace": {
  86. "name": "scratch"
  87. }
  88. },
  89. "targetStore": {
  90. "dataStore": {
  91. "name": "shapes"
  92. }
  93. },
  94. "data": {
  95. "type": "file",
  96. "file": "/data/spearfish/archsites.shp"
  97. }
  98. }
  99. }
  100. The parameters are:
  101. .. list-table::
  102. :widths: 10 10 60
  103. :header-rows: 1
  104. * - Name
  105. - Optional
  106. - Description
  107. * - targetWorkspace
  108. - Y
  109. - The target workspace to import to
  110. * - targetStore
  111. - Y
  112. - The target store to import to
  113. * - data
  114. - Y
  115. - The data to be imported
  116. The mere creation does not start the import, but it may automatically populate its tasks depending on the target.
  117. For example, by referring a directory of shapefiles to be importer, the creation will automatically fill in a task to import each of the shapefiles as a new layer.
  118. The response to the above POST request will be::
  119. Status: 201 Created
  120. Location: http://localhost:8080/geoserver/rest/imports/2
  121. Content-Type: application/json
  122. {
  123. "import": {
  124. "id": 2,
  125. "href": "http://localhost:8080/geoserver/rest/imports/2",
  126. "state": "READY",
  127. "targetWorkspace": {
  128. "workspace": {
  129. "name": "scratch"
  130. }
  131. },
  132. "targetStore": {
  133. "dataStore": {
  134. "name": "shapes",
  135. "type": "PostGIS"
  136. }
  137. },
  138. "data": {
  139. "type": "file",
  140. "format": "Shapefile",
  141. "href": "http://localhost:8080/geoserver/rest/imports/2/data",
  142. "file": "archsites.shp"
  143. },
  144. "tasks": [
  145. {
  146. "id": 0,
  147. "href": "http://localhost:8080/geoserver/rest/imports/2/tasks/0",
  148. "state": "READY"
  149. }
  150. ]
  151. }
  152. }
  153. The operation of populating the tasks can require time, especially if done against a large set of
  154. files, or against a "remote" data (more on this later), in this case the POST request can include ``?async=true``
  155. at the end of the URL to make the importer run it asynchronously.
  156. In this case the import will be created in INIT state and will remain in such state until all
  157. the data transfer and task creation operations are completed. In case of failure to fetch data
  158. the import will immediately stop, the state will switch to the ``INIT_ERROR`` state,
  159. and a error message will appear in the import context "message" field.
  160. Adding the "execute=true" parameter to the context creation will also make the import start immediately,
  161. assuming tasks can be created during the init phase. Combining both execute and async, "?async=true&execute=true"
  162. will make the importer start an asynchronous initialization and execution.
  163. The import can also have a list of default transformations, that will be applied to tasks
  164. as they get created, either out of the initial data, or by upload. Here is an example of a
  165. import context creation with a default transformation::
  166. {
  167. "import": {
  168. "targetWorkspace": {
  169. "workspace": {
  170. "name": "topp"
  171. }
  172. },
  173. "data": {
  174. "type": "file",
  175. "file": "/tmp/locations.csv"
  176. },
  177. "targetStore": {
  178. "dataStore": {
  179. "name": "h2"
  180. }
  181. },
  182. "transforms": [
  183. {
  184. "type": "AttributesToPointGeometryTransform",
  185. "latField": "LAT",
  186. "lngField": "LON"
  187. }
  188. ]
  189. }
  190. }
  191. To get more information about transformations see the :ref:`transformations`.
  192. Import object
  193. ^^^^^^^^^^^^^
  194. /imports/<importId>
  195. """""""""""""""""""
  196. .. list-table::
  197. :header-rows: 1
  198. * - Method
  199. - Action
  200. - Status Code/Headers
  201. - Input
  202. - Output
  203. - Parameters
  204. * - GET
  205. - Retrieve import with id <importId>
  206. - 200
  207. - n/a
  208. - Imports
  209. - n/a
  210. * - POST
  211. - Execute import with id <importId>
  212. - 204
  213. - n/a
  214. - n/a
  215. - async=true/false
  216. * - PUT
  217. - Create import with proposed id <importId>. If the proposed id is
  218. ahead of the current (next) id, the current id will be advanced. If the
  219. proposed id is less than or equal to the current id, the current will be
  220. used. This allows an external system to dictate the id management.
  221. - 201 with Location header
  222. - n/a
  223. - Imports
  224. - n/a
  225. * - DELETE
  226. - Remove import with id <importId>
  227. - 200
  228. - n/a
  229. - n/a
  230. - n/a
  231. The representation of a import is the same as the one contained in the import creation response.
  232. The execution of a import can be a long task, as such, it's possible to add ``async=true`` to the
  233. request to make it run in an asynchronous fashion, the client will have to poll the import representation
  234. and check when it reaches either the "COMPLETE" or "COMPLETE_ERROR" state.
  235. Data
  236. ^^^^
  237. A import can have a "data" representing the source of the data to be imported. The data can
  238. be of different types, in particular, "file", "directory", "mosaic", "database" and "remote".
  239. During the import initialization the importer will scan the contents of said resource, and
  240. generate import tasks for each data found in it.
  241. Most data types are discussed in the task section, the only type that's specific to the whole
  242. import context is the "remote" one, that is used to ask the importer to fetch the data from
  243. a remote location autonomusly, without asking the client to perform an upload.
  244. The representation of a remote resource looks as follows::
  245. "data": {
  246. "type": "remote",
  247. "location": "ftp://fthost/path/to/importFile.zip",
  248. "username": "user",
  249. "password": "secret",
  250. "domain" : "mydomain"
  251. }
  252. The location can be `any URI supported by Commons VFS <http://commons.apache.org/proper/commons-vfs/filesystems.html>`_,
  253. including HTTP and FTP servers. The ``username``, ``password`` and ``domain`` elements are all optional,
  254. and required only if the remote server demands an authentication of sorts.
  255. In case the referred file is compressed, it will be unpacked as the download completes, and the
  256. tasks will be created over the result of unpacking.
  257. Tasks
  258. ^^^^^
  259. /imports/<importId>/tasks
  260. """""""""""""""""""""""""
  261. .. list-table::
  262. :header-rows: 1
  263. * - Method
  264. - Action
  265. - Status Code/Headers
  266. - Input
  267. - Output
  268. * - GET
  269. - Retrieve all tasks for import with id <importId>
  270. - 200
  271. - n/a
  272. - Task Collection
  273. * - POST
  274. - Create a new task
  275. - 201 with Location header
  276. - :ref:`Multipart form data <file_upload>`
  277. - Tasks
  278. .. _file_upload:
  279. Getting the list of tasks
  280. """""""""""""""""""""""""
  281. .. code-block:: text
  282. GET /imports/0/tasks
  283. Results in::
  284. Status: 200 OK
  285. Content-Type: application/json
  286. {
  287. "tasks": [
  288. {
  289. "id": 0,
  290. "href": "http://localhost:8080/geoserver/rest/imports/2/tasks/0",
  291. "state": "READY"
  292. }
  293. ]
  294. }
  295. Creating a new task as a file upload
  296. """"""""""""""""""""""""""""""""""""
  297. A new task can be created by issuing a POST to ``imports/<importId>/tasks`` as a "Content-type: multipart/form-data" multipart encoded data as defined by `RFC 2388 <https://www.ietf.org/rfc/rfc2388.txt>`_.
  298. One or more file can be uploaded this way, and a task will be created for importing them. In case the file being uploaded is a zip file, it will be unzipped on the server side and treated as a directory of files.
  299. The response to the upload will be the creation of a new task, for example::
  300. Status: 201 Created
  301. Location: http://localhost:8080/geoserver/rest/imports/1/tasks/1
  302. Content-type: application/json
  303. {
  304. "task": {
  305. "id": 1,
  306. "href": "http://localhost:8080/geoserver/rest/imports/2/tasks/1",
  307. "state": "READY",
  308. "updateMode": "CREATE",
  309. "data": {
  310. "type": "file",
  311. "format": "Shapefile",
  312. "href": "http://localhost:8080/geoserver/rest/imports/2/tasks/1/data",
  313. "file": "bugsites.shp"
  314. },
  315. "target": {
  316. "href": "http://localhost:8080/geoserver/rest/imports/2/tasks/1/target",
  317. "dataStore": {
  318. "name": "shapes",
  319. "type": "PostGIS"
  320. }
  321. },
  322. "progress": "http://localhost:8080/geoserver/rest/imports/2/tasks/1/progress",
  323. "layer": {
  324. "name": "bugsites",
  325. "href": "http://localhost:8080/geoserver/rest/imports/2/tasks/1/layer"
  326. },
  327. "transformChain": {
  328. "type": "vector",
  329. "transforms": []
  330. }
  331. }
  332. }
  333. Creating a new task from form upload
  334. """"""""""""""""""""""""""""""""""""
  335. This creation mode assumes the POST to ``imports/<importId>/tasks`` of form url encoded data containing a ``url`` parameter::
  336. Content-type: application/x-www-form-urlencoded
  337. url=file:///data/spearfish/
  338. The creation response will be the same as the multipart upload.
  339. Single task resource
  340. ^^^^^^^^^^^^^^^^^^^^
  341. /imports/<importId>/tasks/<taskId>
  342. """"""""""""""""""""""""""""""""""
  343. .. list-table::
  344. :header-rows: 1
  345. * - Method
  346. - Action
  347. - Status Code/Headers
  348. - Input
  349. - Output
  350. * - GET
  351. - Retrieve task with id <taskId> within import with id <importId>
  352. - 200
  353. - n/a
  354. - Task
  355. * - PUT
  356. - Modify task with id <taskId> within import with id <importId>
  357. - 200
  358. - Task
  359. - Task
  360. * - DELETE
  361. - Remove task with id <taskId> within import with id <importId>
  362. - 200
  363. - n/a
  364. - n/a
  365. The representation of a task resource is the same one reported in the task creation response.
  366. Updating a task
  367. """""""""""""""
  368. A PUT request over an existing task can be used to update its representation. The representation can be partial, and just contains
  369. the elements that need to be updated.
  370. The updateMode of a task may have different values.
  371. .. list-table::
  372. :header-rows: 1
  373. * - UpdateMode
  374. - Description
  375. * - CREATE
  376. - This is the default starting updateMode of a task, that is: create the target resource if missing.
  377. * - REPLACE
  378. - For vector stores: delete the existing features in the target layer and replace them with those from the task source. For raster stores: replace the underlying data. When dealing with StructuredGridCoverage reader (e.g. ImageMosaic) the new file will be harvested (replacing the old one). For single raster coverages (e.g. GeoTIFF) the name of the file should be the same so that the coverageStore layer will preserve the original name (the old file will be deleted).
  379. * - APPEND
  380. - Add the features from the task source into an existing layer.
  381. The following PUT request updates a task from "CREATE" to "APPEND" mode::
  382. Content-Type: application/json
  383. {
  384. "task": {
  385. "updateMode": "APPEND"
  386. }
  387. }
  388. Directory files representation
  389. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  390. The following operations are specific to data objects of type ``directory``.
  391. /imports/<importId>/tasks/<taskId>/data/files
  392. """""""""""""""""""""""""""""""""""""""""""""
  393. .. list-table::
  394. :header-rows: 1
  395. * - Method
  396. - Action
  397. - Status Code/Headers
  398. - Input
  399. - Output
  400. * - GET
  401. - Retrieve the list of files for a task with id <taskId> within import with id <importId>
  402. - 200
  403. - n/a
  404. - Task
  405. The response to a GET request will be::
  406. Status: 200 OK
  407. Content-Type: application/json
  408. {
  409. files: [
  410. {
  411. file: "tasmania_cities.shp",
  412. href: "http://localhost:8080/geoserver/rest/imports/0/tasks/0/data/files/tasmania_cities.shp"
  413. },
  414. {
  415. file: "tasmania_roads.shp",
  416. href: "http://localhost:8080/geoserver/rest/imports/0/tasks/0/data/files/tasmania_roads.shp"
  417. },
  418. {
  419. file: "tasmania_state_boundaries.shp",
  420. href: "http://localhost:8080/geoserver/rest/imports/0/tasks/0/data/files/tasmania_state_boundaries.shp"
  421. },
  422. {
  423. file: "tasmania_water_bodies.shp",
  424. href: "http://localhost:8080/geoserver/rest/imports/0/tasks/0/data/files/tasmania_water_bodies.shp"
  425. }
  426. ]
  427. }
  428. /imports/<importId>/tasks/<taskId>/data/files/<fileId>
  429. """"""""""""""""""""""""""""""""""""""""""""""""""""""
  430. .. list-table::
  431. :header-rows: 1
  432. * - Method
  433. - Action
  434. - Status Code/Headers
  435. - Input
  436. - Output
  437. * - GET
  438. - Retrieve the file with id <fileId> from the data of a task with id <taskId> within import with id <importId>
  439. - 200
  440. - n/a
  441. - Task
  442. * - DELETE
  443. - Remove a specific file from the task with id <taskId> within import with id <importId>
  444. - 200
  445. - n/a
  446. - n/a
  447. Following the links we'll get to the representation of a single file, notice how in this case a main file can be associate to sidecar files::
  448. Status: 200 OK
  449. Content-Type: application/json
  450. {
  451. type: "file",
  452. format: "Shapefile",
  453. location: "C:\devel\gs_data\release\data\taz_shapes",
  454. file: "tasmania_cities.shp",
  455. href: "http://localhost:8080/geoserver/rest/imports/0/tasks/0/data/files/tasmania_cities.shp",
  456. prj: "tasmania_cities.prj",
  457. other: [
  458. "tasmania_cities.dbf",
  459. "tasmania_cities.shx"
  460. ]
  461. }
  462. Mosaic extensions
  463. """""""""""""""""
  464. In case the input data is of ``mosaic`` type, we have all the attributes typical of a directory, plus support
  465. for directly specifying the timestamp of a particular granule.
  466. In order to specify the timestamp a PUT request can be issued against the granule::
  467. Content-Type: application/json
  468. {
  469. "timestamp": "2004-01-01T00:00:00.000+0000"
  470. }
  471. and the response will be::
  472. Status: 200 OK
  473. Content-Type: application/json
  474. {
  475. "type": "file",
  476. "format": "GeoTIFF",
  477. "href": "http://localhost:8080/geoserver/rest/imports/0/tasks/0/data/files/bm_200401.tif",
  478. "location": "/data/bluemarble/mosaic",
  479. "file": "bm_200401.tiff",
  480. "prj": null,
  481. "other": [],
  482. "timestamp": "2004-01-01T00:00:00.000+0000"
  483. }
  484. Database data
  485. ^^^^^^^^^^^^^
  486. The following operations are specific to data objects of type ``database``. At the time or writing, the REST API does not allow
  487. the creation of a database data source, but it can provide a read only description of one that has been created using the GUI.
  488. /imports/<importId>/tasks/<taskId>/data
  489. """""""""""""""""""""""""""""""""""""""
  490. .. list-table::
  491. :header-rows: 1
  492. * - Method
  493. - Action
  494. - Status Code/Headers
  495. - Input
  496. - Output
  497. * - GET
  498. - Retrieve the database connection parameters for a task with id <taskId> within import with id <importId>
  499. - 200
  500. - n/a
  501. - List of database connection parameters and available tables
  502. Performing a GET on a database type data will result in the following response::
  503. {
  504. type: "database",
  505. format: "PostGIS",
  506. href: "http://localhost:8080/geoserver/rest/imports/0/data",
  507. parameters: {
  508. schema: "public",
  509. fetch size: 1000,
  510. validate connections: true,
  511. Connection timeout: 20,
  512. Primary key metadata table: null,
  513. preparedStatements: true,
  514. database: "gttest",
  515. port: 5432,
  516. passwd: "cite",
  517. min connections: 1,
  518. dbtype: "postgis",
  519. host: "localhost",
  520. Loose bbox: true,
  521. max connections: 10,
  522. user: "cite"
  523. },
  524. tables: [
  525. "geoline",
  526. "geopoint",
  527. "lakes",
  528. "line3d",
  529. ]
  530. }
  531. Database table
  532. ^^^^^^^^^^^^^^^
  533. The following operations are specific to data objects of type ``table``. At the time or writing, the REST API does not allow
  534. the creation of a database data source, but it can provide a read only description of one that has been created using the GUI.
  535. A table description is normally linked to task, and refers to a database data linked to the overall import.
  536. /imports/<importId>/tasks/<taskId>/data
  537. """""""""""""""""""""""""""""""""""""""
  538. .. list-table::
  539. :header-rows: 1
  540. * - Method
  541. - Action
  542. - Status Code/Headers
  543. - Input
  544. - Output
  545. * - GET
  546. - Retrieve the table description for a task with id <taskId> within import with id <importId>
  547. - 200
  548. - n/a
  549. - A table representation
  550. Performing a GET on a database type data will result in the following response::
  551. {
  552. type: "table",
  553. name: "abc",
  554. format: "PostGIS",
  555. href: "http://localhost:8080/geoserver/rest/imports/0/tasks/0/data"
  556. }
  557. Task target layer
  558. ^^^^^^^^^^^^^^^^^^^
  559. /imports/<importId>/tasks/<taskId>/layer
  560. """"""""""""""""""""""""""""""""""""""""
  561. The layer defines how the target layer will be created
  562. .. list-table::
  563. :header-rows: 1
  564. * - Method
  565. - Action
  566. - Status Code/Headers
  567. - Input
  568. - Output
  569. * - GET
  570. - Retrieve the layer of a task with id <taskId> within import with id <importId>
  571. - 200
  572. - n/a
  573. - A layer JSON representation
  574. * - PUT
  575. - Modify the target layer for a task with id <taskId> within import with id <importId>
  576. - 200
  577. - Task
  578. - Task
  579. Requesting the task layer will result in the following::
  580. Status: 200 OK
  581. Content-Type: application/json
  582. {
  583. layer: {
  584. name: "tasmania_cities",
  585. href: "http://localhost:8080/geoserver/rest/imports/0/tasks/0/layer",
  586. title: "tasmania_cities",
  587. originalName: "tasmania_cities",
  588. nativeName: "tasmania_cities",
  589. srs: "EPSG:4326",
  590. bbox: {
  591. minx: 147.2909004483,
  592. miny: -42.85110181689001,
  593. maxx: 147.2911004483,
  594. maxy: -42.85090181689,
  595. crs: "GEOGCS["WGS 84", DATUM["World Geodetic System 1984", SPHEROID["WGS 84", 6378137.0, 298.257223563, AUTHORITY["EPSG","7030"]], AUTHORITY["EPSG","6326"]], PRIMEM["Greenwich", 0.0, AUTHORITY["EPSG","8901"]], UNIT["degree", 0.017453292519943295], AXIS["Geodetic longitude", EAST], AXIS["Geodetic latitude", NORTH], AUTHORITY["EPSG","4326"]]"
  596. },
  597. attributes: [
  598. {
  599. name: "the_geom",
  600. binding: "org.locationtech.jts.geom.MultiPoint"
  601. },
  602. {
  603. name: "CITY_NAME",
  604. binding: "java.lang.String"
  605. },
  606. {
  607. name: "ADMIN_NAME",
  608. binding: "java.lang.String"
  609. },
  610. {
  611. name: "CNTRY_NAME",
  612. binding: "java.lang.String"
  613. },
  614. {
  615. name: "STATUS",
  616. binding: "java.lang.String"
  617. },
  618. {
  619. name: "POP_CLASS",
  620. binding: "java.lang.String"
  621. }
  622. ],
  623. style: {
  624. name: "cite_tasmania_cities",
  625. href: "http://localhost:8080/geoserver/rest/imports/0/tasks/0/layer/style"
  626. }
  627. }
  628. }
  629. All the above attributes can be updated using a PUT request. Even if the above representation is similar to the REST config API, it should not
  630. be confused with it, as it does not support all the same properties, in particular the supported properties are all the ones listed above.
  631. Task transformations
  632. ^^^^^^^^^^^^^^^^^^^^
  633. /imports/<importId>/tasks/<taskId>/transforms
  634. """""""""""""""""""""""""""""""""""""""""""""
  635. .. list-table::
  636. :header-rows: 1
  637. * - Method
  638. - Action
  639. - Status Code/Headers
  640. - Input
  641. - Output
  642. * - GET
  643. - Retrieve the list of transformations of a task with id <taskId> within import with id <importId>
  644. - 200
  645. - n/a
  646. - A list of transfromations in JSON format
  647. * - POST
  648. - Create a new transformation and append it inside a task with id <taskId> within import with id <importId>
  649. - 201
  650. - A JSON transformation representation
  651. - The transform location
  652. Retrieving the transformation list
  653. """"""""""""""""""""""""""""""""""
  654. A GET request for the list of transformations will result in the following response::
  655. Status: 200 OK
  656. Content-Type: application/json
  657. {
  658. "transforms": [
  659. {
  660. "type": "ReprojectTransform",
  661. "href": "http://localhost:8080/geoserver/rest/imports/0/tasks/1/transforms/0",
  662. "source": null,
  663. "target": "EPSG:4326"
  664. },
  665. {
  666. "type": "DateFormatTransform",
  667. "href": "http://localhost:8080/geoserver/rest/imports/0/tasks/1/transforms/1",
  668. "field": "date",
  669. "format": "yyyyMMdd"
  670. }
  671. ]
  672. }
  673. Appending a new transformation
  674. """"""""""""""""""""""""""""""
  675. Creating a new transformation requires posting a JSON document with a ``type`` property identifying the class of the
  676. transformation, plus any extra attribute required by the transformation itself (this is transformation specific, each one will use a different set of attributes).
  677. The following POST request creates an attribute type remapping::
  678. Content-Type: application/json
  679. {
  680. "type": "AttributeRemapTransform",
  681. "field": "cat",
  682. "target": "java.lang.Integer"
  683. }
  684. The response will be::
  685. Status: 201 OK
  686. Location: http://localhost:8080/geoserver/rest/imports/0/tasks/1/transform/2
  687. /imports/<importId>/tasks/<taskId>/transforms/<transformId>
  688. """""""""""""""""""""""""""""""""""""""""""""""""""""""""""
  689. .. list-table::
  690. :header-rows: 1
  691. * - Method
  692. - Action
  693. - Status Code/Headers
  694. - Input
  695. - Output
  696. * - GET
  697. - Retrieve a transformation identified by <transformId> inside a task with id <taskId> within import with id <importId>
  698. - 200
  699. - n/a
  700. - A single transformation in JSON format
  701. * - PUT
  702. - Modifies the definition of a transformation identified by <transformId> inside a task with id <taskId> within import with id <importId>
  703. - 200
  704. - A JSON transformation representation (eventually just the portion of it that needs to be modified)
  705. - The full transformation representation
  706. * - DELETE
  707. - Removes the transformation identified by <transformId> inside a task with id <taskId> within import with id <importId>
  708. - 200
  709. - A JSON transformation representation (eventually just the portion of it that needs to be modified)
  710. - The full transformation representation
  711. Retrieve a single transformation
  712. """"""""""""""""""""""""""""""""
  713. Requesting a single transformation by identifier will result in the following response::
  714. Status: 200 OK
  715. Content-Type: application/json
  716. {
  717. "type": "ReprojectTransform",
  718. "href": "http://localhost:8080/geoserver/rest/imports/0/tasks/1/transforms/0",
  719. "source": null,
  720. "target": "EPSG:4326"
  721. }
  722. Modify an existing transformation
  723. """""""""""""""""""""""""""""""""
  724. Assuming we have a reprojection transformation, and that we need to change the target SRS type, the following PUT request will do the job::
  725. Content-Type: application/json
  726. {
  727. "type": "ReprojectTransform",
  728. "target": "EPSG:3005"
  729. }
  730. The response will be::
  731. Status: 200 OK
  732. Content-Type: application/json
  733. {
  734. "type": "ReprojectTransform",
  735. "href": "http://localhost:8080/geoserver/rest/imports/0/tasks/1/transform/0",
  736. "source": null,
  737. "target": "EPSG:3005"
  738. }
  739. .. _transformations:
  740. Transformation reference
  741. ^^^^^^^^^^^^^^^^^^^^^^^^
  742. AttributeRemapTransform
  743. """""""""""""""""""""""
  744. Remaps a certain field to a given target data type
  745. .. list-table::
  746. :header-rows: 1
  747. * - Parameter
  748. - Optional
  749. - Description
  750. * - field
  751. - N
  752. - The name of the field to be remapped
  753. * - target
  754. - N
  755. - The "target" field type, as a fully qualified Java class name
  756. AttributeComputeTransform
  757. """""""""""""""""""""""""
  758. Computes a new field based on an expression that can use the other field values
  759. .. list-table::
  760. :header-rows: 1
  761. * - Parameter
  762. - Optional
  763. - Description
  764. * - field
  765. - N
  766. - The name of the field to be computed
  767. * - fieldType
  768. - N
  769. - The field type, as a fully qualified Java class name (e.g., ``java.lang.String``, ``java.lang.Integer``, ``java.util.Date`` and so on)
  770. * - cql
  771. - N
  772. - The (E)CQL expression used to compute the new field (can be a constant value, e.g. ``'My String'``)
  773. AttributesToPointGeometryTransform
  774. """"""""""""""""""""""""""""""""""
  775. Transforms two numeric fields ``latField`` and ``lngField`` into a point geometry representation with ``pointFieldName`` setting name of the point ``POINT(lngField,latField)``, the source fields will be removed if ``preserveGeometry`` is false.
  776. .. list-table::
  777. :header-rows: 1
  778. * - Parameter
  779. - Optional
  780. - Description
  781. * - latField
  782. - N
  783. - The "latitude" field
  784. * - lngField
  785. - N
  786. - The "longitude" field
  787. * - pointFieldName
  788. - Y
  789. - The name of the point
  790. * - preserveGeometry
  791. - Y
  792. - Setting this flag will prevent source fields from removal (false by default)
  793. CreateIndexTransform
  794. """"""""""""""""""""
  795. For database targets only, creates an index on a given column after importing the data into the database
  796. .. list-table::
  797. :header-rows: 1
  798. * - Parameter
  799. - Optional
  800. - Description
  801. * - field
  802. - N
  803. - The field to be indexed
  804. DateFormatTransform
  805. """""""""""""""""""
  806. Parses a string representation of a date into a Date/Timestamp object
  807. .. list-table::
  808. :header-rows: 1
  809. * - Parameter
  810. - Optional
  811. - Description
  812. * - field
  813. - N
  814. - The field to be parsed
  815. * - format
  816. - Y
  817. - A date parsing pattern, setup using the Java `SimpleDateFormat syntax <http://docs.oracle.com/javase/7/docs/api/java/text/SimpleDateFormat.html>`_. In case it's missing, a number of built-in formats will be tried instead (short and full ISO date formats, dates without any separators).
  818. * - enddate
  819. - Y
  820. - The field used as end date for the time dimension.
  821. * - presentation
  822. - Y
  823. - The time dimension presentation type; one of {LIST; DISCRETE_INTERVAL; CONTINUOUS_INTERVAL}
  824. IntegerFieldToDateTransform
  825. """""""""""""""""""""""""""
  826. Takes a integer field and transforms it to a date, interpreting the intereger field as a date
  827. .. list-table::
  828. :header-rows: 1
  829. * - Parameter
  830. - Optional
  831. - Description
  832. * - field
  833. - N
  834. - The field containing the year information
  835. ReprojectTransform
  836. """"""""""""""""""
  837. Reprojects a vector layer from a source CRS to a target CRS
  838. .. list-table::
  839. :header-rows: 1
  840. * - Parameter
  841. - Optional
  842. - Description
  843. * - source
  844. - Y
  845. - Identifier of the source coordinate reference system (the native one will be used if missing)
  846. * - target
  847. - N
  848. - Identifier of the target coordinate reference system
  849. GdalTranslateTransform
  850. """"""""""""""""""""""
  851. Applies ``gdal_translate`` to a single file raster input. Requires ``gdal_translate`` to be inside the PATH used by the web container running GeoServer.
  852. .. list-table::
  853. :header-rows: 1
  854. * - Parameter
  855. - Optional
  856. - Description
  857. * - options
  858. - N
  859. - Array of options that will be passed to ``gdal_translate`` (beside the input and output names, which are internally managed)
  860. GdalWarpTransform
  861. """""""""""""""""
  862. Applies ``gdalwarp`` to a single file raster input. Requires ``gdalwarp`` to be inside the PATH used by the web container running GeoServer.
  863. .. list-table::
  864. :header-rows: 1
  865. * - Parameter
  866. - Optional
  867. - Description
  868. * - options
  869. - N
  870. - Array of options that will be passed to ``gdalwarp`` (beside the input and output names, which are internally managed)
  871. GdalAddoTransform
  872. """""""""""""""""
  873. Applies ``gdaladdo`` to a single file raster input. Requires ``gdaladdo`` to be inside the PATH used by the web container running GeoServer.
  874. .. list-table::
  875. :header-rows: 1
  876. * - Parameter
  877. - Optional
  878. - Description
  879. * - options
  880. - N
  881. - Array of options that will be passed to ``gdaladdo`` (beside the input file name, which is internally managed)
  882. * - levels
  883. - N
  884. - Array of integers with the overview levels that will be passed to ``gdaladdo``
  885. PostScriptTransform
  886. """""""""""""""""""
  887. Runs the specified script after the data is imported. The script must be located in ``$GEOSERVER_DATA_DIR/importer/scripts``.
  888. The script can be any executable file.
  889. At the time of writing, there is no way to pass information about the data just imported to the script (TBD).
  890. .. list-table::
  891. :header-rows: 1
  892. * - Parameter
  893. - Optional
  894. - Description
  895. * - name
  896. - N
  897. - Name of the script to be invoked
  898. * - options
  899. - Y
  900. - Array of options that will be passed to the script