@@ -174,6 +174,12 @@ def _requests(self,
174
174
elif method .lower () == "delete" :
175
175
return requests .delete (url , auth = (self .username , self .password ), ** kwargs , ** self .request_options )
176
176
177
+ # _______________________________________________________________________________________________
178
+ #
179
+ # GEOSERVER AND SERVER SPECIFIC METHODS
180
+ # _______________________________________________________________________________________________
181
+ #
182
+
177
183
def get_manifest (self ):
178
184
"""
179
185
Returns the manifest of the GeoServer. The manifest is a JSON of all the loaded JARs on the GeoServer server.
@@ -272,6 +278,12 @@ def reset(self):
272
278
else :
273
279
raise GeoserverException (r .status_code , r .content )
274
280
281
+ # _______________________________________________________________________________________________
282
+ #
283
+ # WORKSPACES
284
+ # _______________________________________________________________________________________________
285
+ #
286
+
275
287
def get_default_workspace (self ):
276
288
"""
277
289
Returns the default workspace.
@@ -407,6 +419,12 @@ def delete_workspace(self, workspace: str):
407
419
else :
408
420
raise GeoserverException (r .status_code , r .content )
409
421
422
+ # _______________________________________________________________________________________________
423
+ #
424
+ # DATASTORES
425
+ # _______________________________________________________________________________________________
426
+ #
427
+
410
428
def get_datastore (self , store_name : str , workspace : Optional [str ] = None ):
411
429
"""
412
430
Return the data store in a given workspace. If workspace is not provided, it will take the default workspace.
@@ -463,6 +481,12 @@ def get_datastores(self, workspace: Optional[str] = None):
463
481
else :
464
482
raise GeoserverException (r .status_code , r .content )
465
483
484
+ # _______________________________________________________________________________________________
485
+ #
486
+ # COVERAGE STORES
487
+ # _______________________________________________________________________________________________
488
+ #
489
+
466
490
def get_coveragestore (
467
491
self , coveragestore_name : str , workspace : Optional [str ] = None
468
492
):
@@ -546,6 +570,10 @@ def create_coveragestore(
546
570
-------
547
571
dict
548
572
The response from the server.
573
+
574
+ Notes
575
+ -----
576
+ the path to the file and file_type indicating it is a geotiff, arcgrid or other raster type
549
577
"""
550
578
if path is None :
551
579
raise Exception ("You must provide the full path to the raster" )
@@ -607,6 +635,11 @@ def publish_time_dimension_to_coveragestore(
607
635
-------
608
636
dict
609
637
The response from the server.
638
+
639
+ Notes
640
+ -----
641
+ More about time support in geoserver WMS you can read here:
642
+ https://docs.geoserver.org/master/en/user/services/wms/time.html
610
643
"""
611
644
url = "{0}/rest/workspaces/{1}/coveragestores/{2}/coverages/{2}" .format (
612
645
self .service_url , workspace , store_name
@@ -640,6 +673,12 @@ def publish_time_dimension_to_coveragestore(
640
673
else :
641
674
raise GeoserverException (r .status_code , r .content )
642
675
676
+ # _______________________________________________________________________________________________
677
+ #
678
+ # LAYERS
679
+ # _______________________________________________________________________________________________
680
+ #
681
+
643
682
def get_layer (self , layer_name : str , workspace : Optional [str ] = None ):
644
683
"""
645
684
Returns the layer by layer name.
@@ -721,6 +760,12 @@ def delete_layer(self, layer_name: str, workspace: Optional[str] = None):
721
760
else :
722
761
raise GeoserverException (r .status_code , r .content )
723
762
763
+ # _______________________________________________________________________________________________
764
+ #
765
+ # LAYER GROUPS
766
+ # _______________________________________________________________________________________________
767
+ #
768
+
724
769
def get_layergroups (self , workspace : Optional [str ] = None ):
725
770
"""
726
771
Returns all the layer groups from GeoServer. If workspace is None, it will list all the layer groups from GeoServer.
@@ -734,6 +779,10 @@ def get_layergroups(self, workspace: Optional[str] = None):
734
779
-------
735
780
dict
736
781
The list of layer groups.
782
+
783
+ Notes
784
+ -----
785
+ If workspace is None, it will list all the layer groups from geoserver.
737
786
"""
738
787
url = "{}/rest/layergroups" .format (self .service_url )
739
788
@@ -814,6 +863,12 @@ def create_layergroup(
814
863
-------
815
864
str
816
865
The URL of the created layer group.
866
+
867
+ Notes
868
+ -----
869
+ title is a human readable text for the layergroup
870
+ abstract_text is a long text, like a brief info about the layergroup
871
+ workspace is Optional(Global Layergroups don't need workspace).A layergroup can exist without a workspace.
817
872
"""
818
873
assert isinstance (name , str ), "Name must be of type String:''"
819
874
assert isinstance (mode , str ), "Mode must be of type String:''"
@@ -1354,6 +1409,12 @@ def _layergroup_definition_from_layers_and_styles(
1354
1409
1355
1410
return data
1356
1411
1412
+ # _______________________________________________________________________________________________
1413
+ #
1414
+ # STYLES
1415
+ # _______________________________________________________________________________________________
1416
+ #
1417
+
1357
1418
def get_style (self , style_name , workspace : Optional [str ] = None ):
1358
1419
"""
1359
1420
Returns the style by style name.
@@ -1449,6 +1510,13 @@ def upload_style(
1449
1510
------
1450
1511
GeoserverException
1451
1512
If there is an issue uploading the style.
1513
+
1514
+ Notes
1515
+ -----
1516
+ The name of the style file will be, sld_name:workspace
1517
+ This function will create the style file in a specified workspace.
1518
+ `path` can either be the path to the SLD file itself, or a string containing valid XML to be used for the style
1519
+ Inputs: path to the sld_file or the contents of an SLD file itself, workspace,
1452
1520
"""
1453
1521
if name is None :
1454
1522
name = os .path .basename (path )
@@ -1541,6 +1609,12 @@ def create_coveragestyle(
1541
1609
------
1542
1610
GeoserverException
1543
1611
If there is an issue creating the style.
1612
+
1613
+ Notes
1614
+ -----
1615
+ The name of the style file will be, rasterName:workspace
1616
+ This function will dynamically create the style file for raster.
1617
+ Inputs: name of file, workspace, cmap_type (two options: values, range), ncolors: determines the number of class, min for minimum value of the raster, max for the max value of raster
1544
1618
"""
1545
1619
raster = raster_value (raster_path )
1546
1620
min_value = raster ["min" ]
@@ -1633,6 +1707,13 @@ def create_catagorized_featurestyle(
1633
1707
------
1634
1708
GeoserverException
1635
1709
If there is an issue creating the style.
1710
+
1711
+ Notes
1712
+ -----
1713
+
1714
+ The data type must be point, line or polygon
1715
+ Inputs: column_name (based on which column style should be generated), workspace,
1716
+ color_or_ramp (color should be provided in hex code or the color ramp name, geom_type(point, line, polygon), outline_color(hex_color))
1636
1717
"""
1637
1718
catagorize_xml (column_name , column_distinct_values , color_ramp , geom_type )
1638
1719
@@ -1702,6 +1783,11 @@ def create_outline_featurestyle(
1702
1783
------
1703
1784
GeoserverException
1704
1785
If there is an issue creating the style.
1786
+
1787
+ Notes
1788
+ -----
1789
+ The geometry type must be point, line or polygon
1790
+ Inputs: style_name (name of the style file in geoserver), workspace, color (style color)
1705
1791
"""
1706
1792
outline_only_xml (color , width , geom_type )
1707
1793
@@ -1777,6 +1863,12 @@ def create_classified_featurestyle(
1777
1863
------
1778
1864
GeoserverException
1779
1865
If there is an issue creating the style.
1866
+
1867
+ Notes
1868
+ -----
1869
+ The data type must be point, line or polygon
1870
+ Inputs: column_name (based on which column style should be generated), workspace,
1871
+ color_or_ramp (color should be provided in hex code or the color ramp name, geom_type(point, line, polygon), outline_color(hex_color))
1780
1872
"""
1781
1873
classified_xml (
1782
1874
style_name ,
@@ -1848,6 +1940,12 @@ def publish_style(
1848
1940
------
1849
1941
GeoserverException
1850
1942
If there is an issue publishing the style.
1943
+
1944
+ Notes
1945
+ -----
1946
+ The coverage store will be created automatically as the same name as the raster layer name.
1947
+ input parameters: the parameters connecting geoserver (user,password, url and workspace name),
1948
+ the path to the file and file_type indicating it is a geotiff, arcgrid or other raster type.
1851
1949
"""
1852
1950
headers = {"content-type" : "text/xml" }
1853
1951
url = "{}/rest/layers/{}:{}" .format (self .service_url , workspace , layer_name )
@@ -1903,6 +2001,12 @@ def delete_style(self, style_name: str, workspace: Optional[str] = None):
1903
2001
else :
1904
2002
raise GeoserverException (r .status_code , r .content )
1905
2003
2004
+ # _______________________________________________________________________________________________
2005
+ #
2006
+ # FEATURES AND DATASTORES
2007
+ # _______________________________________________________________________________________________
2008
+ #
2009
+
1906
2010
def create_featurestore (
1907
2011
self ,
1908
2012
store_name : str ,
@@ -2008,6 +2112,10 @@ def create_featurestore(
2008
2112
------
2009
2113
GeoserverException
2010
2114
If there is an issue creating/updating the feature store.
2115
+
2116
+ Notes
2117
+ -----
2118
+ After creating feature store, you need to publish it. See the layer publish guidline here: https://geoserver-rest.readthedocs.io/en/latest/how_to_use.html#creating-and-publishing-featurestores-and-featurestore-layers
2011
2119
"""
2012
2120
url = "{}/rest/workspaces/{}/datastores" .format (self .service_url , workspace )
2013
2121
@@ -2131,6 +2239,10 @@ def create_datastore(
2131
2239
------
2132
2240
GeoserverException
2133
2241
If there is an issue creating/updating the datastore.
2242
+
2243
+ Notes
2244
+ -----
2245
+ If you have PostGIS datastore, please use create_featurestore function
2134
2246
"""
2135
2247
if workspace is None :
2136
2248
workspace = "default"
@@ -2195,6 +2307,10 @@ def create_shp_datastore(
2195
2307
------
2196
2308
GeoserverException
2197
2309
If there is an issue creating the shapefile datastore.
2310
+
2311
+ Notes
2312
+ -----
2313
+ The layer name will be assigned according to the shp name
2198
2314
"""
2199
2315
if path is None :
2200
2316
raise Exception ("You must provide a full path to shapefile" )
@@ -2262,6 +2378,11 @@ def create_gpkg_datastore(
2262
2378
------
2263
2379
GeoserverException
2264
2380
If there is an issue creating the geopackage datastore.
2381
+
2382
+ Notes
2383
+ -----
2384
+ The layer name will be assigned according to the layer name in the geopackage.
2385
+ If the layer already exist it will be updated.
2265
2386
"""
2266
2387
if path is None :
2267
2388
raise Exception ("You must provide a full path to shapefile" )
@@ -2338,6 +2459,11 @@ def publish_featurestore(
2338
2459
------
2339
2460
GeoserverException
2340
2461
If there is an issue publishing the featurestore.
2462
+
2463
+ Notes
2464
+ -----
2465
+ Only user for postgis vector data
2466
+ input parameters: specify the name of the table in the postgis database to be published, specify the store,workspace name, and the Geoserver user name, password and URL
2341
2467
"""
2342
2468
if workspace is None :
2343
2469
workspace = "default"
@@ -2502,6 +2628,26 @@ def publish_featurestore_sqlview(
2502
2628
------
2503
2629
GeoserverException
2504
2630
If there is an issue publishing the SQL view.
2631
+
2632
+ Notes
2633
+ -----
2634
+ With regards to SQL view parameters, it is advised to read the relevant section from the geoserver docs:
2635
+ https://docs.geoserver.org/main/en/user/data/database/sqlview.html#parameterizing-sql-views
2636
+
2637
+ An integer-based parameter must have a default value
2638
+
2639
+ You should be VERY careful with the `regexp_validator`, as it can open you to SQL injection attacks. If you do
2640
+ not supply one for a parameter, it will use the geoserver default `^[\w\d\s]+$`.
2641
+
2642
+ The `parameters` iterable must contain dictionaries with this structure:
2643
+
2644
+ ```
2645
+ {
2646
+ "name": "<name of parameter (required)>"
2647
+ "rexegpValidator": "<string containing regex validator> (optional)"
2648
+ "defaultValue" : "<default value of parameter if not specified (required only for non-string parameters)>"
2649
+ }
2650
+ ```
2505
2651
"""
2506
2652
if workspace is None :
2507
2653
workspace = "default"
@@ -2759,6 +2905,12 @@ def delete_coveragestore(
2759
2905
else :
2760
2906
raise GeoserverException (r .status_code , r .content )
2761
2907
2908
+ # _______________________________________________________________________________________________
2909
+ #
2910
+ # USERS AND USERGROUPS
2911
+ # _______________________________________________________________________________________________
2912
+ #
2913
+
2762
2914
def get_all_users (self , service = None ) -> dict :
2763
2915
"""
2764
2916
Query all users in the provided user/group service, else default user/group service is queried.
0 commit comments