-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAddNewWaterSystem.py
More file actions
47 lines (40 loc) · 1.4 KB
/
AddNewWaterSystem.py
File metadata and controls
47 lines (40 loc) · 1.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# This script adds a new water system to your primacy agency
# request library to interact with the server/api
# json to make the resulting json into a redable format
import requests
import json
# url for inventory api
inventoryApi = "https://inventory.dwsfties-uat-api.epa.gov"
# copy and paste the access_token from your profile-> copy access token in UAT
access_token = "<your_access_token>"
headerForApi = {
"Authorization": f"Bearer {access_token}",
"Content-Type": "application/json"
}
# Note: you can change all the values to the right of : in newWaterSystem
newWaterSystem = {
"waterSystemId": "X19852075",
"name": "myNewWaterSystem",
"wsOwnerTypeCode": "L",
"wsStatusCode": "A",
"waterSystemStatusDt": "2025-04-16",
"seasonalInd": "N",
"dwpWaterSystemAnnualOperatingPeriods": [],
"waterSystemServiceConnections": [],
"measureRequests": [],
"wsIndicatorRequests": [],
"relatedPOCRequests": [],
"flowRateRequests": [],
"waterSystemCertRequests": [],
"geographicAreas": [],
"serviceAreas": [],
"wholeSalerInd": "Y",
"wsServiceLineRequests": []
}
# Send the newWaterSystem
apiCall = requests.post(f"{inventoryApi}/inventory/water-system", json=newWaterSystem, headers=headerForApi)
# code of 200 means successfully added the newWaterSystem
if apiCall.status_code != 200:
print("Api call failed with the token: ", apiCall.status_code, apiCall.text)
else:
print("success")