developer.rst 2.39 KB
Newer Older
1 2 3 4 5 6
.. _xivo-confd-developer:

Developer's Guide (xivo-confd)

7 8 9 10 11 12 13 14 15 16 17 18 19
xivo-confd resources are organised through a plugin mechanism. There are 2 main plugin categories:

Resource plugins
    A plugin that manages a resource (e.g. users, extensions, voicemails, etc). A resource plugin
    exposes the 4 basic CRUD operations (Create, Read, Update, Delete) in order to operate on a
    resource in a RESTful manner.

Association plugins
    A plugin for associating or dissociating 2 resources (e.g a user and a line). An association
    plugin exposes an HTTP action for associating (either ``POST`` or ``PUT``) and another for
    dissociating (``DELETE``)

The following diagram outlines the most important parts of a plugin:
20 21 22 23 24 25

.. figure:: images/xivo-confd-plugin-architecture.png

   Plugin architecture of xivo-confd

26 27
    Class that receives and handles HTTP requests. Resources use `flask-restful
    <>`_ for handling requests.
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44

    There are 2 kinds of resources: `ListResource` for root URLs and `ItemResource` for URLs that
    have an ID. `ListResource` will handle creating a resource (``POST``) and searching through a
    list of available resources (``GET``).  `ItemResource` handles fetching a single item (``GET``),
    updating (``PUT``) and deleting (``DELETE``).

    Class that handles business logic for a resource, such as what to do in order to get, create,
    update, or delete a resource. `Service` classes do not manipulate data directly.  Instead, they
    coordinate what to do via other objects.

    There are 2 kinds of services: `CRUDService` for basic CRUD operations in `Resource
    plugins`, and `AssociationService` for association/dissociation operations in `Association

45 46
    Data Access Object. Knows how to get data and how to manipulate it, such as SQL queries, files,
47 48 49 50 51 52 53 54 55 56

    Sends events after an operation has completed. An event will be sent in a messaging queue for
    each CRUD operation. Certain resources also need to send events to other daemons in order to
    reload some configuration data. (i.e. asterisk needs to reload the dialplan when an extension is

    Makes sure that a resource's data does not contain any errors before doing something with it.
    A `Validator` can be used for validating input data or business rules.