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, json_encoder=<class 'json.encoder.JSONEncoder'>)[source]

Bases: django.http.response.HttpResponse

openstack_dashboard.api.rest.utils.ajax(authenticated=True, data_required=False, json_encoder=<class 'json.encoder.JSONEncoder'>)[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.

openstack_dashboard.api.rest.utils.parse_filters_kwargs(request, client_keywords={})[source]

Extract REST filter parameters from the request GET args.

Client processes some keywords separately from filters and takes them as separate inputs. This will ignore those keys to avoid potential conflicts.

Previous topic

The openstack_dashboard.api.rest.keystone Module

Next topic

The openstack_dashboard.api.rest.neutron Module

Project Source

This Page