diff --git a/cwms/locations/physical_locations.py b/cwms/locations/physical_locations.py index 39ad66f0..d703dad6 100644 --- a/cwms/locations/physical_locations.py +++ b/cwms/locations/physical_locations.py @@ -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. @@ -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 ------- @@ -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: