Page MenuHomeSoftware Heritage

client: Open last_visit method to retrieve last visit of an origin
ClosedPublic

Authored by ardumont on Wed, Sep 8, 1:05 PM.

Details

Summary

This would allow to script retrieve the last swhid of an object [1] by composing
multiple calls from the client [2]

[1] T3192#69844

[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 T3192

Test Plan

tox

Diff Detail

Repository
rDWCLI Web client
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

Build is green

Patch application report for D6211 (id=22480)

Rebasing onto d1f064f196...

Current branch diff-target is up to date.
Changes applied before test
commit 3806eaba8430a2e9886985063f14382b42b5d882
Author: Antoine R. Dumont (@ardumont) <ardumont@softwareheritage.org>
Date:   Wed Sep 8 12:34:11 2021 +0200

    client: Open last_visit method to retrieve last visit of an origin
    
    Related to T3192

See https://jenkins.softwareheritage.org/job/DWCLI/job/tests-on-diff/51/ for more details.

Complete the test (i had forgotten to)

Build is green

Patch application report for D6211 (id=22481)

Rebasing onto d1f064f196...

Current branch diff-target is up to date.
Changes applied before test
commit 32b05c4581ea4beb8866cdb327ece58e723771cb
Author: Antoine R. Dumont (@ardumont) <ardumont@softwareheritage.org>
Date:   Wed Sep 8 12:34:11 2021 +0200

    client: Open last_visit method to retrieve last visit of an origin
    
    Related to T3192

See https://jenkins.softwareheritage.org/job/DWCLI/job/tests-on-diff/52/ for more details.

anlambert added a subscriber: anlambert.

Looks good to me.

This revision is now accepted and ready to land.Wed, Sep 8, 1:28 PM