The openstack_dashboard.api.rest.utils ModuleΒΆ

exception openstack_dashboard.api.rest.utils.AjaxError(http_status, msg)[source]

Bases: exceptions.Exception

class openstack_dashboard.api.rest.utils.CreatedResponse(location, data=None)[source]

Bases: django.http.response.HttpResponse

class openstack_dashboard.api.rest.utils.JSONResponse(data, status=200)[source]

Bases: django.http.response.HttpResponse

openstack_dashboard.api.rest.utils.ajax(authenticated=True, data_required=False)[source]

Provide a decorator to wrap a view method so that it may exist in an entirely AJAX environment:

  • data decoded from JSON as input and data coded as JSON as output
  • result status is coded in the HTTP status code; any non-2xx response data will be coded as a JSON string, otherwise the response type (always JSON) is specific to the method called.

if authenticated is true then we’ll make sure the current user is authenticated.

If data_required is true then we’ll assert that there is a JSON body present.

The wrapped view method should return either:

  • JSON serialisable data
  • an object of the django http.HttpResponse subclass (one of JSONResponse or CreatedResponse is suggested)
  • nothing

Methods returning nothing (or None explicitly) will result in a 204 “NO CONTENT” being returned to the caller.

Previous topic

The openstack_dashboard.api.heat Module

Next topic

The openstack_dashboard.api.rest.keystone Module

This Page