Skip to content
Snippets Groups Projects
index.rst 3.56 KiB
Newer Older
Arkindex API Client
===================

:ref:`genindex` - :ref:`modindex` - :ref:`search`

Erwan Rouchet's avatar
Erwan Rouchet committed
``arkindex-client`` provides an API client and a command-line tool to interact
with Arkindex servers.
Erwan Rouchet's avatar
Erwan Rouchet committed
.. contents::
   :depth: 2
   :local:
   :backlinks: none
Erwan Rouchet's avatar
Erwan Rouchet committed
Setup
-----

Install the client using ``pip``::

   pip install arkindex-client

Command-line tool
-----------------

Erwan Rouchet's avatar
Erwan Rouchet committed
Once installed, a ``arkindex`` script should be in your PATH. Two commands are
currently available:
Erwan Rouchet's avatar
Erwan Rouchet committed
   Login to an Arkindex server with an email and a password, then save API
   tokens to a configuration file.
``arkindex upload``
   Upload and import files into an Arkindex server.

Main options
^^^^^^^^^^^^

Erwan Rouchet's avatar
Erwan Rouchet committed
These options are available for all ``arkindex`` subcommands and should be
applied before the subcommand name, like so::

   arkindex --no-verify-ssl login

``--profile [name]``
   Name of the configuration profile to use. Defaults to ``default``.
``--verify-ssl / --no-verify-ssl``
   Enable or disable SSL certificate checks (enabled by default).
   Useful when the Arkindex server uses self-signed certificates.

Login
^^^^^

Erwan Rouchet's avatar
Erwan Rouchet committed
To perform authenticated requests against the API, the client must obtain
a user's API token. The ``arkindex login`` commands allows to log in to an
Arkindex server, fetch the API token and save it to the configuration file.

``--host [name]``
   Host name of the Arkindex server. Defaults to ``arkindex.teklia.com``.
``--email``
Erwan Rouchet's avatar
Erwan Rouchet committed
   Email to use for logging in. If this setting is omitted, a prompt will be
   shown asking for the email.

The script will ask for your password, then login and save tokens.

Upload
^^^^^^

Erwan Rouchet's avatar
Erwan Rouchet committed
The ``upload`` subcommand allows to upload files and optionally start import
processes in batch::

   arkindex upload --mode images Himanis ./himanis/*.jpg

Erwan Rouchet's avatar
Erwan Rouchet committed
This example will try to find a corpus that contains ``Himanis`` in its name,
then upload all ``.jpg`` files from the ``himanis`` folder and start an import
process for each file automatically.
Erwan Rouchet's avatar
Erwan Rouchet committed
   arkindex upload
       [--mode pdf|images]
       [--start/--no-start]
       [--volume <name or ID>]
       [--verbose]
Erwan Rouchet's avatar
Erwan Rouchet committed
       [corpus]
       [files]

``corpus``
   UUID or part of the name of a corpus to upload files to.
Erwan Rouchet's avatar
Erwan Rouchet committed
   If a name is specified, corpus name matching is done in a case-insensitive
   manner. If there are multiple matching corpora for a name, the matching
   corpora names are printed and the script exits.
Erwan Rouchet's avatar
Erwan Rouchet committed
   Paths of all files to upload/import. Compatible shells may allow the use of
   wildcards (``*`` or ``**``) to specify multiple paths at once.
``--start / --no-start``
Erwan Rouchet's avatar
Erwan Rouchet committed
   Start (or do not start) an import process for each uploaded file.
   Enabled by default.
   With the ``--volume`` option, a single import process will be run with all
   files. Without this option, files are imported separately.
``--mode pdf / --mode images``
Erwan Rouchet's avatar
Erwan Rouchet committed
   Set the import process mode. Defaults to ``pdf``.
   Is ignored if ``--no-start`` is specified.
``--volume <name or ID>``
   UUID or part of the name of a volume to import to. When left unspecified,
   the Arkindex server will automatically create a volume for each import.
   Is ignored if ``--no-start`` is specified.
``--verbose``
   Print all import UUIDs when the upload is complete.

Package reference
-----------------

API client
^^^^^^^^^^

.. autoclass:: arkindex.client.ArkindexAPI
   :members:

Exceptions
^^^^^^^^^^

Erwan Rouchet's avatar
Erwan Rouchet committed
.. autoexception:: arkindex.client.ArkindexAPIError
   :members:

Helper classes
^^^^^^^^^^^^^^

.. autoclass:: arkindex.client.ResponsePaginator
   :members:

.. autoclass:: arkindex.conf.LocalConf
   :members: