@@ -1555,12 +1555,7 @@ def upload_style(
1555
1555
1556
1556
r = self ._requests (method = "post" , url = url , data = style_xml , headers = headers )
1557
1557
if r .status_code == 201 :
1558
- r_sld = requests .put (
1559
- url + "/" + name ,
1560
- data = xml ,
1561
- auth = (self .username , self .password ),
1562
- headers = header_sld ,
1563
- )
1558
+ r_sld = self ._requests (method = "put" , url = url + "/" + name , data = xml , headers = header_sld )
1564
1559
1565
1560
if r_sld .status_code == 200 :
1566
1561
return r_sld .status_code
@@ -1656,12 +1651,8 @@ def create_coveragestyle(
1656
1651
)
1657
1652
if r .status_code == 201 :
1658
1653
with open ("style.sld" , "rb" ) as f :
1659
- r_sld = requests .put (
1660
- url + "/" + style_name ,
1661
- data = f .read (),
1662
- auth = (self .username , self .password ),
1663
- headers = header_sld ,
1664
- )
1654
+ r_sld = self ._requests (method = "put" , url = url + "/" + style_name , data = f .read (), headers = header_sld )
1655
+
1665
1656
os .remove ("style.sld" )
1666
1657
if r_sld .status_code == 200 :
1667
1658
return r_sld .status_code
@@ -2268,9 +2259,7 @@ def create_datastore(
2268
2259
2269
2260
else :
2270
2261
url = "{}/rest/workspaces/{}/datastores" .format (self .service_url , workspace )
2271
- r = requests .post (
2272
- url , data , auth = (self .username , self .password ), headers = headers
2273
- )
2262
+ r = self ._requests (method = "post" , url = url , data = data , headers = headers )
2274
2263
2275
2264
if r .status_code in [200 , 201 ]:
2276
2265
return "Data store created/updated successfully"
@@ -2337,12 +2326,7 @@ def create_shp_datastore(
2337
2326
)
2338
2327
2339
2328
with open (path , "rb" ) as f :
2340
- r = requests .put (
2341
- url ,
2342
- data = f .read (),
2343
- auth = (self .username , self .password ),
2344
- headers = headers ,
2345
- )
2329
+ r = self ._requests ("put" , url , data = f .read (), headers = headers )
2346
2330
if r .status_code in [200 , 201 , 202 ]:
2347
2331
return "The shapefile datastore created successfully!"
2348
2332
else :
@@ -2406,12 +2390,8 @@ def create_gpkg_datastore(
2406
2390
)
2407
2391
2408
2392
with open (path , "rb" ) as f :
2409
- r = requests .put (
2410
- url ,
2411
- data = f .read (),
2412
- auth = (self .username , self .password ),
2413
- headers = headers ,
2414
- )
2393
+ r = self ._requests ("put" , url , data = f .read (), headers = headers )
2394
+
2415
2395
if r .status_code in [200 , 201 , 202 ]:
2416
2396
return "The geopackage datastore created successfully!"
2417
2397
else :
@@ -2493,12 +2473,8 @@ def publish_featurestore(
2493
2473
</featureType>"""
2494
2474
headers = {"content-type" : "text/xml" }
2495
2475
2496
- r = requests .post (
2497
- url ,
2498
- data = layer_xml ,
2499
- auth = (self .username , self .password ),
2500
- headers = headers ,
2501
- )
2476
+ r = self ._requests ("post" , url , data = layer_xml , headers = headers )
2477
+
2502
2478
if r .status_code == 201 :
2503
2479
return r .status_code
2504
2480
else :
@@ -2572,12 +2548,8 @@ def edit_featuretype(
2572
2548
</featureType>"""
2573
2549
headers = {"content-type" : "text/xml" }
2574
2550
2575
- r = requests .put (
2576
- url ,
2577
- data = layer_xml ,
2578
- auth = (self .username , self .password ),
2579
- headers = headers ,
2580
- )
2551
+ r = self ._requests ("put" , url , data = layer_xml , headers = headers )
2552
+
2581
2553
if r .status_code == 200 :
2582
2554
return r .status_code
2583
2555
else :
@@ -2716,12 +2688,7 @@ def publish_featurestore_sqlview(
2716
2688
headers = {"content-type" : "text/xml" }
2717
2689
2718
2690
# request
2719
- r = requests .post (
2720
- url ,
2721
- data = layer_xml ,
2722
- auth = (self .username , self .password ),
2723
- headers = headers ,
2724
- )
2691
+ r = self .requests ("post" , url , data = layer_xml , headers = headers )
2725
2692
2726
2693
if r .status_code == 201 :
2727
2694
return r .status_code
@@ -2981,9 +2948,7 @@ def create_user(
2981
2948
username , password , str (enabled ).lower ()
2982
2949
)
2983
2950
headers = {"content-type" : "text/xml" , "accept" : "application/json" }
2984
- r = requests .post (
2985
- url , data , auth = (self .username , self .password ), headers = headers
2986
- )
2951
+ r = self ._requests ("post" , url , data = data , headers = headers )
2987
2952
2988
2953
if r .status_code == 201 :
2989
2954
return "User created successfully"
@@ -3036,9 +3001,7 @@ def modify_user(
3036
3001
data = unparse ({"user" : modifications })
3037
3002
print (url , data )
3038
3003
headers = {"content-type" : "text/xml" , "accept" : "application/json" }
3039
- r = requests .post (
3040
- url , data , auth = (self .username , self .password ), headers = headers
3041
- )
3004
+ r = self ._requests .post ("post" , url , data = data , headers = headers )
3042
3005
3043
3006
if r .status_code == 200 :
3044
3007
return "User modified successfully"
0 commit comments