Package: djira
IntroductionDjango app that exposes some internals through a REST API. Intended
for development tools comsumption.The first objective is writing an emacs plugin that helps developing
django apps.InstallationTo install frompypijust runpip install djira.To install de development version clone the git repo:gitclonehttps://github.com/patxoca/djira.gitFrom a virtualenv (recommended), install the package in development
mode:cddjirapythonsetup.pydevelopConfigurationAdddjiratoINSTALLED_APPSin your project’s config and
include djira URLs in your root url definition:urlpatterns=[...url(r"^__djira__/",include("djira.urls")),...]In order to test the installation start the development server and
point a browser tohttp://localhost:8000/__djira__/__ping__/, this
should display apongresponse.Calling an endpointAs seen in the previous section, calling an endpoint is just a matter
of executing aGETrequest on some URL.Warning:djiraprovides a read-only API so it only acceptsGETandHEADrequests.In order to improve readability the output from the following examples
has beenprettyfied. Depending on the plugins you have enabled the
output may be different.$curlhttp://localhost:8000/__djira__/__ping__/"pong"If you get no output make sure you have included the trailing slash in
the URL.The API can be queried to get details about the endpoints. The__list__endpoint returns info about the registered endpoints:$curlhttp://localhost:8000/__djira__/__list__/[{"name":"__list__","description":"List available endpoints.","parameters":{}},{"name":"__ping__","description":"Test service availability.","parameters":{}},{"name":"__version__","description":"Get djira API version.","parameters":{}},{"name":"get_model_info","description":"Return a dict with info about the given model.","parameters":{"description":"","type":"schema","extra":{"model_id":{"description":"Model name.","type":"string","required":true}}}},{"name":"get_models_names","description":"Return a list with the models names.","parameters":{}}]If the endpoint is omitted it is assumed to be__list__.Arguments are passed in the query string:$curlhttp://localhost:8000/__djira__/get_model_info/?model_id=FooBarModel{"name":["FooBarModel"],"verbose_name":"Some descriptive text","fields":[{"name":"my_field","type":"int"}]}Available endpointsOnly the__list__,__ping__and__version__endpoints are
guaranteed to be available, the remaining endpoints (including those
provided bydjiraitself) are implemented as plugins and can be
replaced or removed on a per project basis.PluginsI wantdjirato be easily extensible so you can add your own
endpoints to the API without getting a headache.djirausespluggyin order to manage the plugins.Writing pluginsTake a look at thehookspec.pymodule to see what the current
specification of the plugin API is.Take a look at thedemo.pymodule for an example.Take a look at thepluggy docsfor extra details.Warning: endpoints withdundernames are reserved for internal
usage.Loading pluginsIn order to discover and load pluginsdjiraimplements two plugin
loaders:entry_points: loadsallplugins declared in adjiraentry
point.
Load order is undefined. This is the default loader.django_config: loads all plugins listed in theenabled_pluginsconfiguracion option. This loader gives finer
control on what plugins are loaded on what order at the expense
of increased verbosity.The plugin loader is configured insettings.py:DJIRA={"plugin_loader":"djira.plugin_loader.django_config","enabled_plugins":["djira.demo"],}This example enables thedjira.demoplugin.