gnunet-handbook

The GNUnet Handbook
Log | Files | Refs

commit 8f6f148595f2fa25709cfac840e3a02644c35034
parent 5fc07133c8d3ead0cdc82ff1f92c7f6b5ae04fc2
Author: Martin Schanzenbach <schanzen@gnunet.org>
Date:   Thu,  6 Oct 2022 14:14:08 +0900

improve REST organization

Diffstat:
Mdevelopers/rest/config.rst | 4++--
Adevelopers/rest/configuration.rst | 39+++++++++++++++++++++++++++++++++++++++
Adevelopers/rest/conventions.rst | 20++++++++++++++++++++
Mdevelopers/rest/gns.rst | 16++--------------
Mdevelopers/rest/identity.rst | 4++--
Mdevelopers/rest/index.rst | 74++++----------------------------------------------------------------------
Mdevelopers/rest/namestore.rst | 12+++++-------
Mdevelopers/rest/peerinfo.rst | 4++--
8 files changed, 76 insertions(+), 97 deletions(-)

diff --git a/developers/rest/config.rst b/developers/rest/config.rst @@ -1,5 +1,5 @@ -Config API Service -================== +Config +====== Definition ~~~~~~~~~~ diff --git a/developers/rest/configuration.rst b/developers/rest/configuration.rst @@ -0,0 +1,39 @@ +Configuration +============= + +In order to start the REST service, execute: + +:: + + $ gnunet-arm -i rest + +The REST service will listen by default on port 7776. +The service is run by each user so you may have to modify the port accordingly: + +:: + + $ gnunet-config -s rest -o HTTP_PORT -V 7788 + +Note that you may need to authenticate agains the API using HTTP basic authentication. +The REST service autogenerates a password upon first launch. +You can get your user-specific authentication secret by executing: + +:: + + $ SECRET=$(gnunet-config -f -s rest -o BASIC_AUTH_SECRET_FILE) + +To access the REST API, you can use any HTTP client such as a browser or cURL: + +:: + + $ curl localhost:7776/identity -u<$USER>:<$SECRET> + +You may disable the authentication if you want to by executing: + +:: + + $ gnunet-config -s rest -o BASIC_AUTH_ENABLED -V NO + +However, disabling authentication is not recommended. + + diff --git a/developers/rest/conventions.rst b/developers/rest/conventions.rst @@ -0,0 +1,20 @@ +Conventions +=========== + +The GNUnet Web API is based in REST principles. Data resources are accessed via HTTP requests to an API endpoint. Where possible, the Web API uses the following HTTP methods for each action: + ++----------+-----------------------------+ +|**Method**|**Action** | ++==========+=============================+ +|GET |Retrieve object(s) | ++----------+-----------------------------+ +|POST |Create new object(s) | ++----------+-----------------------------+ +|PUT |Edit existing object(s) | ++----------+-----------------------------+ +|DELETE |Delete existing object(s) | ++----------+-----------------------------+ +|OPTIONS |Get allowed headers | ++----------+-----------------------------+ + + diff --git a/developers/rest/gns.rst b/developers/rest/gns.rst @@ -1,16 +1,5 @@ -.. _ref-type: - -GNS API Service -=============== - -Definition -~~~~~~~~~~ - -Variables in single quotes ``'...'`` can or must be changed according to your specific case. - -``lookup`` is the combination of the ``record_name`` of a :ref:`ref-gnsrecord` and the ``name`` of the zone (or identity): ``record_name.name`` - -``type`` is the record_type of a :ref:`ref-gnsrecord`. +GNS +=== Error Response -------------- @@ -35,7 +24,6 @@ GET Request For this request ``record_type`` is optional. If missing or called with an invalid record_type, it will automatically be set to ANY. -The success response is a :ref:`ref-gnsrecord` without its record_name. +--------------------+----------------------------------------------------------------------------------------------------------------------------+ |**Title** |Return all records for given name | diff --git a/developers/rest/identity.rst b/developers/rest/identity.rst @@ -1,5 +1,5 @@ -Identity API Service -==================== +Identity +======== Definition ~~~~~~~~~~ diff --git a/developers/rest/index.rst b/developers/rest/index.rst @@ -1,70 +1,10 @@ +******** REST API -======== - -Configuration -~~~~~~~~~~~~~ - -In order to start the REST service, execute: - -:: - - $ gnunet-arm -i rest - -The REST service will listen by default on port 7776. -The service is run by each user so you may have to modify the port accordingly: - -:: - - $ gnunet-config -s rest -o HTTP_PORT -V 7788 - -Note that you may need to authenticate agains the API using HTTP basic authentication. -The REST service autogenerates a password upon first launch. -You can get your user-specific authentication secret by executing: - -:: - - $ SECRET=$(gnunet-config -f -s rest -o BASIC_AUTH_SECRET_FILE) - -To access the REST API, you can use any HTTP client such as a browser or cURL: - -:: - - $ curl localhost:7776/identity -u<$USER>:<$SECRET> - -You may disable the authentication if you want to by executing: - -:: - - $ gnunet-config -s rest -o BASIC_AUTH_ENABLED -V NO - -However, disabling authentication is not recommended. - -Conventions -~~~~~~~~~~~ - -The GNUnet Web API is based in REST principles. Data resources are accessed via HTTP requests to an API endpoint. Where possible, the Web API uses the following HTTP methods for each action: - -+----------+-----------------------------+ -|**Method**|**Action** | -+==========+=============================+ -|GET |Retrieve object(s) | -+----------+-----------------------------+ -|POST |Create new object(s) | -+----------+-----------------------------+ -|PUT |Edit existing object(s) | -+----------+-----------------------------+ -|DELETE |Delete existing object(s) | -+----------+-----------------------------+ -|OPTIONS |Get allowed headers | -+----------+-----------------------------+ - -Services -~~~~~~~~ +******** .. toctree:: - :maxdepth: 3 - :caption: Contents: - + configuration + conventions identity namestore gns @@ -72,9 +12,3 @@ Services config - -====== -Search -====== - -* :ref:`search` diff --git a/developers/rest/namestore.rst b/developers/rest/namestore.rst @@ -1,10 +1,8 @@ -Namestore API Service -===================== - -.. _ref-gnsrecord: +Namestore +========= Record Set ----------- +^^^^^^^^^^ Namestore entries are GNS record sets. A record set consists of a ``record_name`` and a ``data`` field. @@ -46,7 +44,7 @@ Namestore entries are GNS record sets. A record set consists of a ``record_name` } Error Response --------------- +^^^^^^^^^^^^^^ All error responses are sent with a `NamestoreError` body. @@ -60,7 +58,7 @@ All error responses are sent with a `NamestoreError` body. } Requests --------- +^^^^^^^^ .. http:get:: /namestore/$ZNAME diff --git a/developers/rest/peerinfo.rst b/developers/rest/peerinfo.rst @@ -1,5 +1,5 @@ -Peerinfo API Service -==================== +Peerinfo +======== Definition ~~~~~~~~~~