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: openstack_dashboard.api.rest.utils._RestResponse

class openstack_dashboard.api.rest.utils.JSONResponse(data, status=200, json_encoder=<class 'json.encoder.JSONEncoder'>)[source]

Bases: openstack_dashboard.api.rest.utils._RestResponse

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=None)[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.

openstack_dashboard.api.rest.utils.post2data(func)[source]

The sole purpose of this decorator is to restore original form values along with their types stored on client-side under key $$originalJSON. This in turn prevents the loss of field types when they are passed with header ‘Content-Type: multipart/form-data’, which is needed to pass a binary blob as a part of POST request.

Previous topic

The openstack_dashboard.api.rest.swift Module

Next topic

The openstack_dashboard.api.rest.glance Module

Project Source

This Page