diff --git a/alephclient/api.py b/alephclient/api.py index d5ad320..1029ec9 100644 --- a/alephclient/api.py +++ b/alephclient/api.py @@ -220,6 +220,11 @@ def flush_collection(self, collection_id: str, sync: bool = False): url = self._make_url(f"collections/{collection_id}", params=params) return self._request("DELETE", url) + def touch_collection(self, collection_id: str): + """Update the content update date of a collection by ID""" + url = self._make_url(f"collections/{collection_id}/touch") + return self._request("POST", url) + def get_entity(self, entity_id: str, publisher: bool = False) -> Dict: """Get a single entity by ID.""" url = self._make_url(f"entities/{entity_id}") diff --git a/alephclient/cli.py b/alephclient/cli.py index 96a09d9..3b058aa 100644 --- a/alephclient/cli.py +++ b/alephclient/cli.py @@ -213,6 +213,19 @@ def flush_collection(ctx, foreign_id, sync=False): raise click.ClickException(exc.message) +@cli.command("touch") +@click.option("-f", "--foreign-id", required=True, help="foreign_id of the collection") +@click.pass_context +def touch_collection(ctx, foreign_id): + """Update a collection's content update date.""" + api = ctx.obj["api"] + try: + collection_id = _get_id_from_foreign_key(api, foreign_id) + api.touch_collection(collection_id) + except AlephException as exc: + raise click.ClickException(exc.message) + + @cli.command("write-entity") @click.option("-i", "--infile", type=click.File("r"), default="-") @click.option("-f", "--foreign-id", required=True, help="foreign_id of the collection") diff --git a/alephclient/tests/test_api_collection.py b/alephclient/tests/test_api_collection.py index cc58596..66f6075 100644 --- a/alephclient/tests/test_api_collection.py +++ b/alephclient/tests/test_api_collection.py @@ -50,6 +50,9 @@ def test_delete_collection(self, mocker): def test_flush_collection(self, mocker): pass + def test_touch_collection(self, mocker): + pass + def test_get_collection_by_foreign_id(self, mocker): pass