Changeset View
Changeset View
Standalone View
Standalone View
swh/web/api/views/content.py
Show All 36 Lines | .. http:get:: /api/1/content/[(hash_type):](hash)/filetype/ | ||||
getting information about the content | getting information about the content | ||||
:>json string encoding: the detected content encoding | :>json string encoding: the detected content encoding | ||||
:>json string id: the **sha1** identifier of the content | :>json string id: the **sha1** identifier of the content | ||||
:>json string mimetype: the detected MIME type of the content | :>json string mimetype: the detected MIME type of the content | ||||
:>json object tool: information about the tool used to detect the content filetype | :>json object tool: information about the tool used to detect the content filetype | ||||
{common_headers} | {common_headers} | ||||
**Allowed HTTP Methods:** :http:method:`get`, :http:method:`head`, :http:method:`options` | |||||
:statuscode 200: no error | :statuscode 200: no error | ||||
:statuscode 400: an invalid **hash_type** or **hash** has been provided | :statuscode 400: an invalid **hash_type** or **hash** has been provided | ||||
:statuscode 404: requested content can not be found in the archive | :statuscode 404: requested content can not be found in the archive | ||||
**Example:** | **Example:** | ||||
.. parsed-literal:: | .. parsed-literal:: | ||||
Show All 28 Lines | .. http:get:: /api/1/content/[(hash_type):](hash)/language/ | ||||
:>json object content_url: link to :http:get:`/api/1/content/[(hash_type):](hash)/` for | :>json object content_url: link to :http:get:`/api/1/content/[(hash_type):](hash)/` for | ||||
getting information about the content | getting information about the content | ||||
:>json string id: the **sha1** identifier of the content | :>json string id: the **sha1** identifier of the content | ||||
:>json string lang: the detected programming language if any | :>json string lang: the detected programming language if any | ||||
:>json object tool: information about the tool used to detect the programming language | :>json object tool: information about the tool used to detect the programming language | ||||
{common_headers} | {common_headers} | ||||
**Allowed HTTP Methods:** :http:method:`get`, :http:method:`head`, :http:method:`options` | |||||
:statuscode 200: no error | :statuscode 200: no error | ||||
:statuscode 400: an invalid **hash_type** or **hash** has been provided | :statuscode 400: an invalid **hash_type** or **hash** has been provided | ||||
:statuscode 404: requested content can not be found in the archive | :statuscode 404: requested content can not be found in the archive | ||||
**Example:** | **Example:** | ||||
.. parsed-literal:: | .. parsed-literal:: | ||||
Show All 26 Lines | .. http:get:: /api/1/content/[(hash_type):](hash)/license/ | ||||
:>json object content_url: link to :http:get:`/api/1/content/[(hash_type):](hash)/` for | :>json object content_url: link to :http:get:`/api/1/content/[(hash_type):](hash)/` for | ||||
getting information about the content | getting information about the content | ||||
:>json string id: the **sha1** identifier of the content | :>json string id: the **sha1** identifier of the content | ||||
:>json array licenses: array of strings containing the detected license names if any | :>json array licenses: array of strings containing the detected license names if any | ||||
:>json object tool: information about the tool used to detect the license | :>json object tool: information about the tool used to detect the license | ||||
{common_headers} | {common_headers} | ||||
**Allowed HTTP Methods:** :http:method:`get`, :http:method:`head`, :http:method:`options` | |||||
:statuscode 200: no error | :statuscode 200: no error | ||||
:statuscode 400: an invalid **hash_type** or **hash** has been provided | :statuscode 400: an invalid **hash_type** or **hash** has been provided | ||||
:statuscode 404: requested content can not be found in the archive | :statuscode 404: requested content can not be found in the archive | ||||
**Example:** | **Example:** | ||||
.. parsed-literal:: | .. parsed-literal:: | ||||
Show All 35 Lines | .. http:get:: /api/1/content/[(hash_type):](hash)/raw/ | ||||
or ``blake2s256``. If that parameter is not provided, it is assumed that the | or ``blake2s256``. If that parameter is not provided, it is assumed that the | ||||
hashing algorithm used is ``sha1``. | hashing algorithm used is ``sha1``. | ||||
:param string hash: hexadecimal representation of the checksum value computed with | :param string hash: hexadecimal representation of the checksum value computed with | ||||
the specified hashing algorithm. | the specified hashing algorithm. | ||||
:query string filename: if provided, the downloaded content will get that filename | :query string filename: if provided, the downloaded content will get that filename | ||||
:resheader Content-Type: application/octet-stream | :resheader Content-Type: application/octet-stream | ||||
**Allowed HTTP Methods:** :http:method:`get`, :http:method:`head`, :http:method:`options` | |||||
:statuscode 200: no error | :statuscode 200: no error | ||||
:statuscode 400: an invalid **hash_type** or **hash** has been provided | :statuscode 400: an invalid **hash_type** or **hash** has been provided | ||||
:statuscode 404: requested content can not be found in the archive | :statuscode 404: requested content can not be found in the archive | ||||
**Example:** | **Example:** | ||||
.. parsed-literal:: | .. parsed-literal:: | ||||
▲ Show 20 Lines • Show All 76 Lines • ▼ Show 20 Lines | .. http:get:: /api/1/content/known/(sha1)[,(sha1), ...,(sha1)]/ | ||||
by ','. | by ','. | ||||
{common_headers} | {common_headers} | ||||
:>json array search_res: array holding the search result for each provided **sha1** | :>json array search_res: array holding the search result for each provided **sha1** | ||||
:>json object search_stats: some statistics regarding the number of **sha1** provided | :>json object search_stats: some statistics regarding the number of **sha1** provided | ||||
and the percentage of those found in the archive | and the percentage of those found in the archive | ||||
**Allowed HTTP Methods:** :http:method:`get`, :http:method:`head`, :http:method:`options` | |||||
:statuscode 200: no error | :statuscode 200: no error | ||||
:statuscode 400: an invalid **sha1** has been provided | :statuscode 400: an invalid **sha1** has been provided | ||||
**Example:** | **Example:** | ||||
.. parsed-literal:: | .. parsed-literal:: | ||||
:swh_web_api:`content/known/dc2830a9e72f23c1dfebef4413003221baa5fb62,0c3f19cb47ebfbe643fb19fa94c874d18fa62d12/` | :swh_web_api:`content/known/dc2830a9e72f23c1dfebef4413003221baa5fb62,0c3f19cb47ebfbe643fb19fa94c874d18fa62d12/` | ||||
▲ Show 20 Lines • Show All 68 Lines • ▼ Show 20 Lines | .. http:get:: /api/1/content/[(hash_type):](hash)/ | ||||
:>json string filetype_url: link to :http:get:`/api/1/content/[(hash_type):](hash)/filetype/` | :>json string filetype_url: link to :http:get:`/api/1/content/[(hash_type):](hash)/filetype/` | ||||
for getting information about the content MIME type | for getting information about the content MIME type | ||||
:>json string language_url: link to :http:get:`/api/1/content/[(hash_type):](hash)/language/` | :>json string language_url: link to :http:get:`/api/1/content/[(hash_type):](hash)/language/` | ||||
for getting information about the programming language used in the content | for getting information about the programming language used in the content | ||||
:>json number length: length of the content in bytes | :>json number length: length of the content in bytes | ||||
:>json string license_url: link to :http:get:`/api/1/content/[(hash_type):](hash)/license/` | :>json string license_url: link to :http:get:`/api/1/content/[(hash_type):](hash)/license/` | ||||
for getting information about the license of the content | for getting information about the license of the content | ||||
**Allowed HTTP Methods:** :http:method:`get`, :http:method:`head`, :http:method:`options` | |||||
:statuscode 200: no error | :statuscode 200: no error | ||||
:statuscode 400: an invalid **hash_type** or **hash** has been provided | :statuscode 400: an invalid **hash_type** or **hash** has been provided | ||||
:statuscode 404: requested content can not be found in the archive | :statuscode 404: requested content can not be found in the archive | ||||
**Example:** | **Example:** | ||||
.. parsed-literal:: | .. parsed-literal:: | ||||
curl -i :swh_web_api:`content/sha1_git:fe95a46679d128ff167b7c55df5d02356c5a1ae1/` | curl -i :swh_web_api:`content/sha1_git:fe95a46679d128ff167b7c55df5d02356c5a1ae1/` | ||||
""" # noqa | """ # noqa | ||||
return api_lookup( | return api_lookup( | ||||
service.lookup_content, q, | service.lookup_content, q, | ||||
notfound_msg='Content with {} not found.'.format(q), | notfound_msg='Content with {} not found.'.format(q), | ||||
enrich_fn=functools.partial(utils.enrich_content, query_string=q), | enrich_fn=functools.partial(utils.enrich_content, query_string=q), | ||||
request=request) | request=request) |