Skip to main content

Introduction

Django 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.

Installation

To install from pypi just run pip install djira.

To install de development version clone the git repo:

git clone https://github.com/patxoca/djira.git

From a virtualenv (recommended), install the package in development mode:

cd djira
python setup.py develop

Configuration

Add djira to INSTALLED_APPS in 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 to http://localhost:8000/__djira__/__ping__/, this should display a pong response.

Calling an endpoint

As seen in the previous section, calling an endpoint is just a matter of executing a GET request on some URL.

Warning: djira provides a read-only API so it only accepts GET and HEAD requests.

In order to improve readability the output from the following examples has been prettyfied. Depending on the plugins you have enabled the output may be different.

$ curl http://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:

$ curl http://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:

$ curl http://localhost:8000/__djira__/get_model_info/?model_id=FooBarModel
{
  "name": [
    "FooBarModel"
  ],
  "verbose_name": "Some descriptive text",
  "fields": [
    {
      "name": "my_field",
      "type": "int"
    }
  ]
}

Available endpoints

Only the __list__, __ping__ and __version__ endpoints are guaranteed to be available, the remaining endpoints (including those provided by djira itself) are implemented as plugins and can be replaced or removed on a per project basis.

Plugins

I want djira to be easily extensible so you can add your own endpoints to the API without getting a headache.

djira uses pluggy in order to manage the plugins.

Writing plugins

Take a look at the hookspec.py module to see what the current specification of the plugin API is.

Take a look at the demo.py module for an example.

Take a look at the pluggy docs for extra details.

Warning: endpoints with dunder names are reserved for internal usage.

Loading plugins

In order to discover and load plugins djira implements two plugin loaders:

  • entry_points: loads all plugins declared in a djira entry point. Load order is undefined. This is the default loader.

  • django_config: loads all plugins listed in the enabled_plugins configuracion 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 in settings.py:

DJIRA = {
    "plugin_loader": "djira.plugin_loader.django_config",
    "enabled_plugins": ["djira.demo"],
}

This example enables the djira.demo plugin.

Metadata

Release files for djira 0.2.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for djira 0.2.1
File Size Uploaded Provenance Actions
djira-0.2.1.tar.gz 33.6 kB Without provenance Details for djira-0.2.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for djira 0.2.1
File Interpreter ABI Platform Actions
djira-0.2.1-py3-none-any.whl Python 3 none any Details for djira-0.2.1-py3-none-any.whl

Total release size: 55.9 kB

Release files / djira-0.2.1.tar.gz

Download URL djira-0.2.1.tar.gz
Size 33.6 kB
Tags Source
SHA-256 checksum
How to use checksums
9f591cf2d3921af8850eb6f99fd9466a71c3d85de99bf1d3b33058a170f5af0c
BLAKE2b-256 checksum
How to use checksums
581e3460b55ffb484b5eec953b56945ea980e0f0ce6868dea8bc0ea441b9113c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.2.0 requests-toolbelt/0.8.0 tqdm/4.25.0 CPython/3.6.4

Release files / djira-0.2.1-py3-none-any.whl

Download URL djira-0.2.1-py3-none-any.whl
Size 22.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8266d76de8fbbc9239a6b7906bd60a2b984bce4db922238d86da866baa9ed4f9
BLAKE2b-256 checksum
How to use checksums
63cc81e481c3d9f92928566d2b56b8c326f4fb88b62d736f593c9b348312c28a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.2.0 requests-toolbelt/0.8.0 tqdm/4.25.0 CPython/3.6.4

Security for djira 0.2.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.2.1 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page