Changeset View
Changeset View
Standalone View
Standalone View
swh/web/api/views/vault.py
Show First 20 Lines • Show All 78 Lines • ▼ Show 20 Lines | .. http:post:: /api/1/vault/flat/(swhid)/ | ||||
through a GET request. | through a GET request. | ||||
Once the cooking task has been executed, the resulting archive can | Once the cooking task has been executed, the resulting archive can | ||||
be downloaded using the dedicated endpoint | be downloaded using the dedicated endpoint | ||||
:http:get:`/api/1/vault/flat/(swhid)/raw/`. | :http:get:`/api/1/vault/flat/(swhid)/raw/`. | ||||
Then to extract the cooked directory in the current one, use:: | Then to extract the cooked directory in the current one, use:: | ||||
$ tar xvf path/to/swh:1:*.tar.gz | $ tar xvf path/to/swh_1_*.tar.gz | ||||
:param string swhid: the object's SWHID | :param string swhid: the object's SWHID | ||||
:query string email: e-mail to notify when the archive is ready | :query string email: e-mail to notify when the archive is ready | ||||
{common_headers} | {common_headers} | ||||
:>json string fetch_url: the url from which to download the archive | :>json string fetch_url: the url from which to download the archive | ||||
▲ Show 20 Lines • Show All 88 Lines • ▼ Show 20 Lines | res = api_lookup( | ||||
archive.vault_fetch, | archive.vault_fetch, | ||||
"flat", | "flat", | ||||
CoreSWHID.from_string(swhid), | CoreSWHID.from_string(swhid), | ||||
notfound_msg=f"Cooked archive for {swhid} not found.", | notfound_msg=f"Cooked archive for {swhid} not found.", | ||||
request=request, | request=request, | ||||
) | ) | ||||
fname = "{}.tar.gz".format(swhid) | fname = "{}.tar.gz".format(swhid) | ||||
response = HttpResponse(res, content_type="application/gzip") | response = HttpResponse(res, content_type="application/gzip") | ||||
response["Content-disposition"] = "attachment; filename={}".format(fname) | response["Content-disposition"] = "attachment; filename={}".format( | ||||
fname.replace(":", "_") | |||||
) | |||||
return response | return response | ||||
@api_route( | @api_route( | ||||
r"/vault/directory/(?P<dir_id>[0-9a-f]+)/raw/", | r"/vault/directory/(?P<dir_id>[0-9a-f]+)/raw/", | ||||
"api-1-vault-fetch-directory", | "api-1-vault-fetch-directory", | ||||
checksum_args=["dir_id"], | checksum_args=["dir_id"], | ||||
) | ) | ||||
Show All 40 Lines | .. http:post:: /api/1/vault/gitfast/(swhid)/ | ||||
Once the cooking task has been executed, the resulting gitfast archive | Once the cooking task has been executed, the resulting gitfast archive | ||||
can be downloaded using the dedicated endpoint | can be downloaded using the dedicated endpoint | ||||
:http:get:`/api/1/vault/gitfast/(swhid)/raw/`. | :http:get:`/api/1/vault/gitfast/(swhid)/raw/`. | ||||
Then to import the revision in the current directory, use:: | Then to import the revision in the current directory, use:: | ||||
$ git init | $ git init | ||||
$ zcat path/to/swh:1:rev:*.gitfast.gz | git fast-import | $ zcat path/to/swh_1_rev_*.gitfast.gz | git fast-import | ||||
$ git checkout HEAD | $ git checkout HEAD | ||||
:param string swhid: the revision's permanent identifiers | :param string swhid: the revision's permanent identifiers | ||||
:query string email: e-mail to notify when the gitfast archive is ready | :query string email: e-mail to notify when the gitfast archive is ready | ||||
{common_headers} | {common_headers} | ||||
▲ Show 20 Lines • Show All 88 Lines • ▼ Show 20 Lines | res = api_lookup( | ||||
archive.vault_fetch, | archive.vault_fetch, | ||||
"gitfast", | "gitfast", | ||||
CoreSWHID.from_string(swhid), | CoreSWHID.from_string(swhid), | ||||
notfound_msg="Cooked archive for {} not found.".format(swhid), | notfound_msg="Cooked archive for {} not found.".format(swhid), | ||||
request=request, | request=request, | ||||
) | ) | ||||
fname = "{}.gitfast.gz".format(swhid) | fname = "{}.gitfast.gz".format(swhid) | ||||
response = HttpResponse(res, content_type="application/gzip") | response = HttpResponse(res, content_type="application/gzip") | ||||
response["Content-disposition"] = "attachment; filename={}".format(fname) | response["Content-disposition"] = "attachment; filename={}".format( | ||||
fname.replace(":", "_") | |||||
) | |||||
return response | return response | ||||
@api_route( | @api_route( | ||||
r"/vault/revision/(?P<rev_id>[0-9a-f]+)/gitfast/raw/", | r"/vault/revision/(?P<rev_id>[0-9a-f]+)/gitfast/raw/", | ||||
"api-1-vault-fetch-revision_gitfast", | "api-1-vault-fetch-revision_gitfast", | ||||
checksum_args=["rev_id"], | checksum_args=["rev_id"], | ||||
) | ) | ||||
Show All 36 Lines | .. http:post:: /api/1/vault/git-bare/(swhid)/ | ||||
through a GET request. | through a GET request. | ||||
Once the cooking task has been executed, the resulting git-bare archive | Once the cooking task has been executed, the resulting git-bare archive | ||||
can be downloaded using the dedicated endpoint | can be downloaded using the dedicated endpoint | ||||
:http:get:`/api/1/vault/git-bare/(swhid)/raw/`. | :http:get:`/api/1/vault/git-bare/(swhid)/raw/`. | ||||
Then to import the revision in the current directory, use:: | Then to import the revision in the current directory, use:: | ||||
$ tar -xf path/to/swh:1:rev:*.git.tar | $ tar -xf path/to/swh_1_rev_*.git.tar | ||||
$ git clone swh:1:rev:*.git new_repository | $ git clone swh:1:rev:*.git new_repository | ||||
(replace ``swh:1:rev:*`` with the SWHID of the requested revision) | (replace ``swh:1:rev:*`` with the SWHID of the requested revision) | ||||
This will create a directory called ``new_repository``, which is a git | This will create a directory called ``new_repository``, which is a git | ||||
repository containing the requested objects. | repository containing the requested objects. | ||||
:param string swhid: the revision's permanent identifier | :param string swhid: the revision's permanent identifier | ||||
▲ Show 20 Lines • Show All 65 Lines • ▼ Show 20 Lines | res = api_lookup( | ||||
archive.vault_fetch, | archive.vault_fetch, | ||||
"git_bare", | "git_bare", | ||||
CoreSWHID.from_string(swhid), | CoreSWHID.from_string(swhid), | ||||
notfound_msg="Cooked archive for {} not found.".format(swhid), | notfound_msg="Cooked archive for {} not found.".format(swhid), | ||||
request=request, | request=request, | ||||
) | ) | ||||
fname = "{}.git.tar".format(swhid) | fname = "{}.git.tar".format(swhid) | ||||
response = HttpResponse(res, content_type="application/gzip") | response = HttpResponse(res, content_type="application/gzip") | ||||
response["Content-disposition"] = "attachment; filename={}".format(fname) | response["Content-disposition"] = "attachment; filename={}".format( | ||||
fname.replace(":", "_") | |||||
) | |||||
return response | return response |