styles.rst 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258
  1. .. _rest_api_styles:
  2. Styles
  3. ======
  4. A ``style`` describes how a resource (feature type or coverage) should be symbolized or rendered by the Web Map Service. In GeoServer styles are specified with :ref:`SLD <styling>`.
  5. ``/styles[.<format>]``
  6. ----------------------
  7. Controls all styles.
  8. .. list-table::
  9. :header-rows: 1
  10. * - Method
  11. - Action
  12. - Status code
  13. - Formats
  14. - Default Format
  15. - Parameters
  16. * - GET
  17. - Return all styles
  18. - 200
  19. - HTML, XML, JSON
  20. - HTML
  21. -
  22. * - POST
  23. - Create a new style
  24. - 201 with ``Location`` header
  25. - SLD, XML, JSON, ZIP
  26. :ref:`See note below <rest_api_styles_post_put>`
  27. -
  28. - :ref:`name <rest_api_styles_name>` :ref:`raw <rest_api_styles_raw>`
  29. * - PUT
  30. -
  31. - 405
  32. -
  33. -
  34. -
  35. * - DELETE
  36. -
  37. - 405
  38. -
  39. -
  40. -
  41. .. _rest_api_styles_post_put:
  42. Styles POST and PUT
  43. ~~~~~~~~~~~~~~~~~~~
  44. When executing a POST or PUT request with an SLD style, the ``Content-type`` header should be set to the mime type identifying the style format. Style formats
  45. supported out of the box include:
  46. * SLD 1.0 with a mime type of ``application/vnd.ogc.sld+xml``
  47. * SLD 1.1 / SE 1.1 with a mime type of ``application/vnd.ogc.se+xml``
  48. * SLD package (zip file containing sld and image files used in the style) with a mime type of application/zip
  49. Other extensions (such as :ref:`css <css>`) add support for
  50. additional formats.
  51. Parameters
  52. ~~~~~~~~~~
  53. .. _rest_api_styles_name:
  54. ``name``
  55. ^^^^^^^^
  56. The ``name`` parameter specifies the name to be given to the style. This option is most useful when executing a POST request with a style in SLD format, and an appropriate name can be not be inferred from the SLD itself.
  57. .. _rest_api_styles_raw:
  58. ``raw``
  59. ^^^^^^^
  60. The ``raw`` parameter specifies whether to forgo parsing and encoding of the
  61. uploaded style content. When set to "true" the style payload will be streamed
  62. directly to GeoServer configuration. Use this setting if the content and
  63. formatting of the style is to be preserved exactly. Use this setting with care
  64. as it may result in an invalid and unusable style. The default is "false".
  65. ``/styles/<s>[.<format>]``
  66. --------------------------
  67. Controls a given style.
  68. .. list-table::
  69. :header-rows: 1
  70. * - Method
  71. - Action
  72. - Status code
  73. - Formats
  74. - Default Format
  75. - Parameters
  76. * - GET
  77. - Return style ``s``
  78. - 200
  79. - SLD, HTML, XML, JSON
  80. - HTML
  81. - :ref:`quietOnNotFound <rest_api_styles_quietOnNotFound>` :ref:`pretty <rest_api_styles_pretty>`
  82. * - POST
  83. -
  84. - 405
  85. -
  86. -
  87. -
  88. * - PUT
  89. - Modify style ``s``
  90. - 200
  91. - SLD, XML, JSON, ZIP :ref:`See note above <rest_api_styles_post_put>`
  92. -
  93. - :ref:`raw <rest_api_styles_raw>`
  94. * - DELETE
  95. - Delete style ``s``
  96. - 200
  97. -
  98. - :ref:`purge <rest_api_styles_purge>`
  99. - :ref:`recurse <rest_api_styles_recurse>`
  100. Exceptions
  101. ~~~~~~~~~~
  102. .. list-table::
  103. :header-rows: 1
  104. * - Exception
  105. - Status code
  106. * - GET for a style that does not exist
  107. - 404
  108. * - PUT that changes name of style
  109. - 403
  110. * - DELETE against style which is referenced by existing layers
  111. - 403
  112. Parameters
  113. ~~~~~~~~~~
  114. .. _rest_api_styles_purge:
  115. ``purge``
  116. ^^^^^^^^^
  117. The ``purge`` parameter specifies whether the underlying SLD file for the style should be deleted on disk. Allowable values for this parameter are "true" or "false". When set to "true" the underlying file will be deleted.
  118. .. _rest_api_styles_recurse:
  119. ``recurse``
  120. ^^^^^^^^^^^
  121. The ``recurse`` parameter removes references to the specified style in existing layers. Allowed values for this parameter are "true" or "false". The default value is "false".
  122. .. _rest_api_styles_quietOnNotFound:
  123. ``quietOnNotFound``
  124. ^^^^^^^^^^^^^^^^^^^^
  125. The ``quietOnNotFound`` parameter avoids to log an Exception when the style is not present. Note that 404 status code will be returned anyway.
  126. .. _rest_api_styles_pretty:
  127. ``pretty``
  128. ^^^^^^^^^^
  129. The ``pretty`` parameter returns the style in a human-readable format, with proper blank-space and indentation. This parameter has no effect if you request a style in its native format - in this case the API returns the exact content of the underlying file. The HTML, XML, and JSON formats do not support this parameter.
  130. ``/workspaces/<ws>/styles[.<format>]``
  131. --------------------------------------
  132. Controls all styles in a given workspace.
  133. .. list-table::
  134. :header-rows: 1
  135. * - Method
  136. - Action
  137. - Status code
  138. - Formats
  139. - Default Format
  140. - Parameters
  141. * - GET
  142. - Return all styles within workspace ``ws``
  143. - 200
  144. - HTML, XML, JSON
  145. - HTML
  146. -
  147. * - POST
  148. - Create a new style within workspace ``ws``
  149. - 201 with ``Location`` header
  150. - SLD, XML, JSON, ZIP :ref:`See note above <rest_api_styles_post_put>`
  151. -
  152. - :ref:`name <rest_api_styles_name>` :ref:`raw <rest_api_styles_raw>`
  153. * - PUT
  154. -
  155. - 405
  156. -
  157. -
  158. -
  159. * - DELETE
  160. -
  161. - 405
  162. -
  163. -
  164. - :ref:`purge <rest_api_styles_purge>`
  165. ``/workspaces/<ws>/styles/<s>[.<format>]``
  166. ------------------------------------------
  167. Controls a particular style in a given workspace.
  168. .. list-table::
  169. :header-rows: 1
  170. * - Method
  171. - Action
  172. - Status code
  173. - Formats
  174. - Default Format
  175. - Parameters
  176. * - GET
  177. - Return style ``s`` within workspace ``ws``
  178. - 200
  179. - SLD, HTML, XML, JSON
  180. - HTML
  181. - :ref:`quietOnNotFound <rest_api_styles_quietOnNotFound>`
  182. * - POST
  183. -
  184. - 405
  185. -
  186. -
  187. -
  188. * - PUT
  189. - Modify style ``s`` within workspace ``ws``
  190. - 200
  191. - SLD, XML, JSON, ZIP
  192. :ref:`See note above <rest_api_styles_post_put>`
  193. -
  194. - :ref:`raw <rest_api_styles_raw>`
  195. * - DELETE
  196. - Delete style ``s`` within workspace ``ws``
  197. - 200
  198. -
  199. -
  200. -
  201. Exceptions
  202. ~~~~~~~~~~
  203. .. list-table::
  204. :header-rows: 1
  205. * - Exception
  206. - Status code
  207. * - GET for a style that does not exist for that workspace
  208. - 404