diff --git a/ecoscope/io/earthranger.py b/ecoscope/io/earthranger.py index e282ccdb..79d70801 100644 --- a/ecoscope/io/earthranger.py +++ b/ecoscope/io/earthranger.py @@ -19,9 +19,9 @@ dataframe_to_dict, filter_bad_geojson, format_iso_time, + pack_columns, to_gdf, to_hex, - pack_columns, ) @@ -1040,6 +1040,36 @@ def post_source( response = self._post("sources", payload=payload) return pd.DataFrame([response]) + def post_sourceproviders( + self, + provider_key: str, + display_name: str, + additional: typing.Dict = {}, + **kwargs, + ) -> pd.DataFrame: + """ + Parameters + ---------- + provider_key + display_name + + Returns + ------- + pd.DataFrame + """ + + payload = { + "provider_key": provider_key, + "display_name": display_name, + "additional": additional, + } + + if kwargs: + payload.update(kwargs) + + response = self._post("sourceproviders", payload=payload) + return pd.DataFrame([response]) + def post_subject( self, subject_name: str, diff --git a/tests/test_earthranger_io.py b/tests/test_earthranger_io.py index cc519d4c..34e59824 100644 --- a/tests/test_earthranger_io.py +++ b/tests/test_earthranger_io.py @@ -6,11 +6,10 @@ import pandas as pd import pytest import pytz +from erclient import ERClientException from shapely.geometry import Point import ecoscope -from erclient import ERClientException - from ecoscope.io.earthranger import EarthRangerIO from ecoscope.io.earthranger_utils import TIME_COLS @@ -205,6 +204,13 @@ def test_get_patrol_events_empty(patrols_mock, er_io): assert events.empty +def test_post_sourceproviders(er_io): + response = er_io.post_sourceproviders(provider_key="test_provider_key", display_name="Test Provider Key") + assert "id" in response + assert "provider_key" in response + assert "display_name" in response + + def test_post_observations(er_io): observations = gpd.GeoDataFrame.from_dict( [