File: json.rst

package info (click to toggle)
python-django-waffle 4.2.0-1
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 684 kB
  • sloc: python: 3,266; makefile: 139; sh: 39; javascript: 34
file content (62 lines) | stat: -rw-r--r-- 1,838 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
.. _usage-json:

=====================
Waffle Status as JSON
=====================

Although :doc:`WaffleJS<javascript>` returns the status of all
:ref:`flags <types-flag>`, :ref:`switches <types-switch>`, and
:ref:`samples <types-sample>`, it does so by exposing a Javascript
object, rather than returning the data in a directly consumable format.

In cases where a directly consumable format is preferable,
Waffle also exposes this data as JSON via the ``waffle_status`` view.


Using the view
--------------

Using the ``waffle_status`` view requires adding Waffle to your URL
configuration. For example, in your ``ROOT_URLCONF``::

    urlpatterns = patterns('',
        (r'^', include('waffle.urls')),
    )

This adds a route called ``waffle_status``, which will return the current
status of each flag, switch, and sample as JSON, with the following structure:

.. code-block:: json

    {
        "flags": {
            "flag_active": {
                "is_active": true,
                "last_modified": "2020-01-01T12:00:00.000"
            },
            "flag_inactive": {
                "is_active": false,
                "last_modified": "2020-01-01T12:00:00.000"
            }
        },
        "switches": {
            "switch_active": {
                "is_active": true,
                "last_modified": "2020-01-01T12:00:00.000"
            },
            "switch_inactive": {
                "is_active": false,
                "last_modified": "2020-01-01T12:00:00.000"
            }
        },
        "samples": {
            "sample_active": {
                "is_active": true,
                "last_modified": "2020-01-01T12:00:00.000"
            },
            "sample_inactive": {
                "is_active": false,
                "last_modified": "2020-01-01T12:00:00.000"
            }
        }
    }