Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions cwms/locations/physical_locations.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ def delete_location(
return api.delete(endpoint, params=params)


def store_location(data: JSON) -> None:
def store_location(data: JSON, fail_if_exists: bool = True) -> None:
"""
This method is used to store and update location's data through CWMS Data API.

Expand All @@ -137,6 +137,10 @@ def store_location(data: JSON) -> None:
data : dict
A dictionary representing the JSON data to be stored.
If the `data` value is None, a `ValueError` will be raised.
fail_if_exists : bool, optional
A boolean value indicating whether to fail if the outlet already exists.
Default is True.


Returns
-------
Expand All @@ -148,8 +152,8 @@ def store_location(data: JSON) -> None:
raise ValueError("Storing location requires a JSON data dictionary")

endpoint = "locations"

return api.post(endpoint, data)
params = {"fail-if-exists": fail_if_exists}
return api.post(endpoint, data, params=params)


def update_location(location_id: str, data: JSON) -> None:
Expand Down