1
0
mirror of https://github.com/peeringdb/peeringdb.git synced 2024-05-11 05:55:09 +00:00
Files
peeringdb-peeringdb/docs/dev/modules/rest.py.md
Matt Griswold 505760aa8d Support 202203 (#1144)
* Do not show objects in status "pending" on the UI #784

* Fix peeringdb.js bug introduced in #784

* 500 Error during login for 2FA enabled accounts with unverified email address #996

* Django-Admin: adding a network with existing asn fails with internal error #1035

* Some command-line-tool executions are not logged #1119

* Ops: API throttling of repeated requests #1126

* Ops: response header X-Auth-ID to augment logging #1120

* Allow rate-limiting of melissa enabled api functionality. #1124

* State / Province normalization #1079

* Log melissa requests #1122

* remove debug messages

* bump django-handleref to 1.0.2

* Need consolidated app logs #845

* pin django peeringdb to 2.13 and relock poetry

* pin django-restframework-apikey to 2.1.0

* linting

* migrations

* docs regenerate

* docs

* linting

Co-authored-by: David Poarch <dpoarch@20c.com>
Co-authored-by: Stefan Pratter <stefan@20c.com>
2022-04-12 15:39:19 -05:00

6.8 KiB

Generated from rest.py on 2022-04-12 16:41:02.631987

peeringdb_server.rest

REST API view definitions.

REST API path routing.

REST API permission checking (facilitated through django-grainy).

REST API error handling.

REST API list filtering logic.

peeringdb-py client compatibility checking.

The peeringdb REST API is implemented through django-rest-framework.

Functions


model_view_set

def model_view_set(model, methods=None, mixins=None)

Shortcut for peeringdb models to generate viewset and register in the API urls.


Classes


ASSetViewSet

ASSetViewSet(peeringdb_server.rest.ReadOnlyMixin, rest_framework.viewsets.ModelViewSet)

AS-SET endpoint.

List all as sets mapped by asn.

Methods

get_queryset

def get_queryset(self)

Get the list of items for this view. This must be an iterable, and may be a queryset. Defaults to using self.queryset.

This method should always be used rather than accessing self.queryset directly, as self.queryset gets evaluated only once, and those results are cached for all subsequent requests.

You may want to override this if you need to provide different querysets depending on the incoming request.

(Eg. return a list of items that is specific to the user)


DataException

DataException(builtins.ValueError)

Inappropriate argument value (of correct type).

DataMissingException

DataMissingException(peeringdb_server.rest.DataException)

"" Raised when the json data sent with a POST, PUT or PATCH request is missing.

Methods

_init_

def __init__(self, method)

Initialize self. See help(type(self)) for accurate signature.


DataParseException

DataParseException(peeringdb_server.rest.DataException)

Raised when the json data sent with a POST, PUT or PATCH request could not be parsed.

Methods

_init_

def __init__(self, method, exc)

Initialize self. See help(type(self)) for accurate signature.


FacilityViewSet

FacilityViewSet(peeringdb_server.rest.ModelViewSet)

Generic ModelViewSet Base Class. This should probably be moved to a common lib ?

IXLanPrefixViewSet

IXLanPrefixViewSet(peeringdb_server.rest.ModelViewSet)

Generic ModelViewSet Base Class. This should probably be moved to a common lib ?

IXLanViewSet

IXLanViewSet(peeringdb_server.rest.ModelViewSet)

Generic ModelViewSet Base Class. This should probably be moved to a common lib ?

InternetExchangeFacilityViewSet

InternetExchangeFacilityViewSet(peeringdb_server.rest.ModelViewSet)

Generic ModelViewSet Base Class. This should probably be moved to a common lib ?

InternetExchangeMixin

InternetExchangeMixin(builtins.object)

Custom API endpoints for the internet exchange object, exposed to api/ix/{id}/{action}

Methods

request_ixf_import

def request_ixf_import(self, request, *args, **kwargs)

Allows managers of an ix to request an ix-f import. (#779)


InternetExchangeViewSet

InternetExchangeViewSet(peeringdb_server.rest.InternetExchangeMixin, peeringdb_server.rest.ModelViewSet)

Custom API endpoints for the internet exchange object, exposed to api/ix/{id}/{action}

ModelViewSet

ModelViewSet(rest_framework.viewsets.ModelViewSet)

Generic ModelViewSet Base Class. This should probably be moved to a common lib ?

Methods

get_queryset

def get_queryset(self)

Prepare the queryset.


partial_update

def partial_update(self, request, *args, **kwargs)

PATCH (partial update) is currently disabled.


require_data

def require_data(self, request)

Test that the request contains data in its body that can be parsed to the required format (json) and is not empty.

Will raise DataParseException error if request payload could not be parsed.

Will raise DataMissingException error if request payload is missing or was parsed to an empty object.


NetworkContactViewSet

NetworkContactViewSet(peeringdb_server.rest.ModelViewSet)

Generic ModelViewSet Base Class. This should probably be moved to a common lib ?

NetworkFacilityViewSet

NetworkFacilityViewSet(peeringdb_server.rest.ModelViewSet)

Generic ModelViewSet Base Class. This should probably be moved to a common lib ?

NetworkIXLanViewSet

NetworkIXLanViewSet(peeringdb_server.rest.ModelViewSet)

Generic ModelViewSet Base Class. This should probably be moved to a common lib ?

NetworkViewSet

NetworkViewSet(peeringdb_server.rest.ModelViewSet)

Generic ModelViewSet Base Class. This should probably be moved to a common lib ?

OrganizationViewSet

OrganizationViewSet(peeringdb_server.rest.ModelViewSet)

Generic ModelViewSet Base Class. This should probably be moved to a common lib ?

RestRouter

RestRouter(rest_framework.routers.DefaultRouter)

The default router extends the SimpleRouter, but also adds in a default API root view, and adds format suffix patterns to the URLs.

Methods

_init_

def __init__(self, trailing_slash=False)

Initialize self. See help(type(self)) for accurate signature.


client_check

client_check(builtins.object)

Decorator that can be attached to rest viewset responses and will generate an error response if the requesting peeringdb client is running a client or backend version that is incompatible with the server.

Compatibilty is controlled via facsimile during deploy and can be configured in env.misc.api.compat

Methods

_call_

def __call__(self, fn)

Call self as a function.


_init_

def __init__(self)

Initialize self. See help(type(self)) for accurate signature.


backend_max_version

def backend_max_version(self, backend)

Return the max supported version for the specified backend.


backend_min_version

def backend_min_version(self, backend)

Return the min supported version for the specified backend.


client_info

def client_info(self, request)

Parse the useragent in the request and return client version info if possible.

Any connecting client that is NOT the peeringdb client will currently return an empty dict and not compatibility checking will be done.


compat_check

def compat_check(self, request)

Check if the connecting client is compatible with the API.

This is currently only sensible when the request is made through the official peeringdb-py client, any other client will be passed through without checks.

On incompatibility a ValueError is raised.


version_pad

def version_pad(self, version)

Take a semantic version tuple and zero pad to dev version.


version_string

def version_string(self, version)

Take a semantic version tuple and turn into a "." delimited string.


version_tuple

def version_tuple(self, str_version)

Take a semantic version string and turn into a tuple.