client: Open last_visit method to retrieve last visit of an origin
This would allow to script retrieve the last swhid of an object [1] by composing multiple calls from the client [2]
-
[2]
from swh.web.client.client import WebAPIClient
client = WebAPIClient()
url = "https://doi.org/10.5201/ipol.2018.236"
visit = client.last_visit(url)
# if visit...
snapshot = next(client.snapshot(visit["snapshot"]))
# if snapshot ...
revision = client.revision(snapshot['HEAD']['target'])
# ensure target_type == 'revision'
# if revision
In [17]: str(revision['directory'])
Out[17]: 'swh:1:dir:d85591aeefea2c1c58142e34683fd1923b19c895'
Related to swh-deposit#3192 (closed)
Test Plan
tox
Migrated from D6211 (view on Phabricator)