Skip to content

Commit

Permalink
add touch to api and cli
Browse files Browse the repository at this point in the history
  • Loading branch information
brrttwrks committed Oct 15, 2024
1 parent a58be59 commit 82c457e
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
5 changes: 5 additions & 0 deletions alephclient/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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) -> None:
"""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}")
Expand Down
13 changes: 13 additions & 0 deletions alephclient/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
3 changes: 3 additions & 0 deletions alephclient/tests/test_api_collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 82c457e

Please sign in to comment.