1
0
mirror of https://github.com/peeringdb/peeringdb.git synced 2024-05-11 05:55:09 +00:00

Docs 202109 (#1067)

* module docstrings

* db schema graph

* dev docs first pass

* dev docs pass 2

* add generated notification to top of generated docs files

* linting

* regen docs

Co-authored-by: Stefan Pratter <stefan@20c.com>
Co-authored-by: Sunshine Buchholz <sunshine@20c.com>
This commit is contained in:
Matt Griswold
2021-10-15 03:25:38 -05:00
committed by GitHub
parent 48a3a899f6
commit c21130eed9
133 changed files with 9962 additions and 986 deletions

1430
docs/dev/modules/admin.py.md Normal file
View File

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,115 @@
Generated from admin_commandline_tools.py on 2021-10-15 07:56:57.376975
# peeringdb_server.admin_commandline_tools
Defines CLI wrappers for django commands that should
be executable through the django-admin interface.
Extend the CommandLineToolWrapper class and call the
register_tool decorator to add support for a new django
command to exposed in this manner.
# Functions
---
## get_tool
`def get_tool(tool_id, form)`
Arguments:
tool_id (str): tool_id as it exists in COMMANDLINE_TOOLS
form (django.forms.Form): form instance
Returns:
CommandLineToolWrapper instance
---
## get_tool_from_data
`def get_tool_from_data(data)`
Arguments:
data (dict): dict containing form data, at the very least
needs to have a "tool" key containing the tool_id
Returns:
CommandLineToolWrapper instance
---
# Classes
---
## ToolIXFIXPMemberImport
```
ToolIXFIXPMemberImport(peeringdb_server.admin_commandline_tools.CommandLineToolWrapper)
```
Allows resets for various parts of the ix-f member data import protocol.
And import ix-f member data for a single Ixlan at a time.
### Instanced Attributes
These attributes / properties will be available on instances of the class
- description (`@property`): None
## ToolMergeFacilities
```
ToolMergeFacilities(peeringdb_server.admin_commandline_tools.CommandLineToolWrapper)
```
This tool runs the pdb_fac_merge command to
merge two facilities.
### Instanced Attributes
These attributes / properties will be available on instances of the class
- description (`@property`): Provide a human readable description of the command that was run.
## ToolMergeFacilitiesUndo
```
ToolMergeFacilitiesUndo(peeringdb_server.admin_commandline_tools.CommandLineToolWrapper)
```
This tool runs the pdb_fac_merge_undo command to
undo a facility merge.
### Instanced Attributes
These attributes / properties will be available on instances of the class
- description (`@property`): Provide a human readable description of the command that was run.
## ToolRenumberLans
```
ToolRenumberLans(peeringdb_server.admin_commandline_tools.CommandLineToolWrapper)
```
This tools runs the pdb_renumber_lans command to
Renumber IP Spaces in an Exchange.
### Instanced Attributes
These attributes / properties will be available on instances of the class
- description (`@property`): Provide a human readable description of the command that was run.
## ToolUndelete
```
ToolUndelete(peeringdb_server.admin_commandline_tools.CommandLineToolWrapper)
```
Allows restoration of an object object and it's child objects.
### Instanced Attributes
These attributes / properties will be available on instances of the class
- description (`@property`): None

View File

@@ -0,0 +1,67 @@
Generated from api_cache.py on 2021-10-15 07:56:57.376975
# peeringdb_server.api_cache
Handle loading of api-cache data.
# Classes
---
## APICacheLoader
```
APICacheLoader(builtins.object)
```
Checks if an API GET request qualifies for a cache load
and if it does allows you to provide the cached result.
### Methods
#### \__init__
`def __init__(self, viewset, qset, filters)`
Initialize self. See help(type(self)) for accurate signature.
---
#### filter_fields
`def filter_fields(self, row)`
Remove any unwanted fields from the resultset
according to the `fields` filter specified in the request.
---
#### load
`def load(self)`
Load the cached response according to tag and depth.
---
#### qualifies
`def qualifies(self)`
Check if request qualifies for a cache load.
---
## CacheRedirect
```
CacheRedirect(builtins.Exception)
```
Raise this error to redirect to cache response during viewset.get_queryset
or viewset.list()
Argument should be an APICacheLoader instance.
### Methods
#### \__init__
`def __init__(self, loader)`
Initialize self. See help(type(self)) for accurate signature.
---

View File

@@ -0,0 +1,38 @@
Generated from api_key_views.py on 2021-10-15 07:56:57.376975
# peeringdb_server.api_key_views
Views for organization api key management.
# Functions
---
## add_user_key
`def add_user_key(request, **kwargs)`
Create a new User API key.
Requires a name and a readonly boolean.
---
## load_all_key_permissions
`def load_all_key_permissions(org)`
Returns dict of all users with all their permissions for
the given org.
---
## remove_user_key
`def remove_user_key(request, **kwargs)`
Revoke user api key.
---
## save_key_permissions
`def save_key_permissions(org, key, perms)`
Save key permissions for the specified org and key.
Perms should be a dict of permissioning ids and permission levels.
---

View File

@@ -0,0 +1,124 @@
Generated from api_schema.py on 2021-10-15 07:56:57.376975
# peeringdb_server.api_schema
Augment REST API schema to use for open-api schema generation.
open-api schema generation leans heavily on automatic generation
implemented through the django-rest-framework.
Specify custom fields to be added to the generated open-api schema.
# Classes
---
## BaseSchema
```
BaseSchema(rest_framework.schemas.openapi.AutoSchema)
```
Augments the openapi schema generation for
the peeringdb API docs.
### Methods
#### _get_operation_id
`def _get_operation_id(self, path, method)`
Override this so operation ids become "{op} {reftag}"
---
#### augment_create_ix
`def augment_create_ix(self, serializer, model, op_dict)`
Augment openapi schema for create ix operation.
---
#### augment_create_operation
`def augment_create_operation(self, op_dict, op_args)`
Augment openapi schema for object creation.
---
#### augment_delete_operation
`def augment_delete_operation(self, op_dict, op_args)`
Augment openapi schema for delete operation.
---
#### augment_list_filters
`def augment_list_filters(self, model, serializer, parameters)`
Further augment openapi schema for object listing by filling
the query parameter list with all the possible query filters
for the object.
---
#### augment_list_operation
`def augment_list_operation(self, op_dict, op_args)`
Augment openapi schema for object listings.
---
#### augment_retrieve_operation
`def augment_retrieve_operation(self, op_dict, op_args)`
Augment openapi schema for single object retrieval.
---
#### augment_update_fac
`def augment_update_fac(self, serializer, model, op_dict)`
Augment openapi schema for update fac operation.
---
#### augment_update_ix
`def augment_update_ix(self, serializer, model, op_dict)`
Augment openapi schema for update ix operation.
---
#### augment_update_net
`def augment_update_net(self, serializer, model, op_dict)`
Augment openapi schema for update net operation.
---
#### augment_update_operation
`def augment_update_operation(self, op_dict, op_args)`
Augment openapi schema for update operation.
---
#### get_classes
`def get_classes(self, *op_args)`
Try to relate a serializer and model class to the openapi operation.
Returns:
- tuple(serializers.Serializer, models.Model)
---
#### get_operation
`def get_operation(self, *args, **kwargs)`
Override this so we can augment the operation dict
for an openapi schema operation.
---
#### get_operation_type
`def get_operation_type(self, *args)`
Determine if this is a list retrieval operation.
---
#### request_body_schema
`def request_body_schema(self, op_dict, content=application/json)`
Helper function that return the request body schema
for the specified content type.
---

View File

@@ -0,0 +1,26 @@
Generated from apps.py on 2021-10-15 07:56:57.376975
# peeringdb_server.apps
Django apps configuration.
# Classes
---
## PeeringDBServerAppConfig
```
PeeringDBServerAppConfig(django.apps.config.AppConfig)
```
Class representing a Django application and its configuration.
### Methods
#### ready
`def ready(self)`
Override this method in subclasses to run code when Django starts.
---

View File

@@ -0,0 +1,291 @@
Generated from autocomplete_views.py on 2021-10-15 07:56:57.136306
# peeringdb_server.autocomplete_views
Autocomplete views.
Handle most autocomplete functionality found in peeringdb.
Note: Quick search behavior is specified in search.py
# Classes
---
## AutocompleteHTMLResponse
```
AutocompleteHTMLResponse(dal_select2.views.Select2QuerySetView)
```
List options for a Select2 widget.
### Methods
#### render_to_response
`def render_to_response(self, context)`
Return a JSON response in Select2 format.
---
## CommandLineToolHistoryAutocomplete
```
CommandLineToolHistoryAutocomplete(dal_select2.views.Select2QuerySetView)
```
Autocomplete for command line tools that were run via the admin ui.
### Methods
#### get_queryset
`def get_queryset(self)`
Filter the queryset with GET['q'].
---
#### get_result_label
`def get_result_label(self, item)`
Return the label of a result.
---
## DeletedVersionAutocomplete
```
DeletedVersionAutocomplete(dal_select2.views.Select2QuerySetView)
```
Autocomplete that will show reversion versions where an object
was set to deleted.
### Methods
#### get_queryset
`def get_queryset(self)`
Filter the queryset with GET['q'].
---
#### get_result_label
`def get_result_label(self, item)`
Return the label of a result.
---
## ExchangeAutocomplete
```
ExchangeAutocomplete(peeringdb_server.autocomplete_views.AutocompleteHTMLResponse)
```
List options for a Select2 widget.
### Methods
#### get_queryset
`def get_queryset(self)`
Filter the queryset with GET['q'].
---
#### get_result_label
`def get_result_label(self, item)`
Return the label of a result.
---
## ExchangeAutocompleteJSON
```
ExchangeAutocompleteJSON(dal_select2.views.Select2QuerySetView)
```
List options for a Select2 widget.
### Methods
#### get_queryset
`def get_queryset(self)`
Filter the queryset with GET['q'].
---
## FacilityAutocomplete
```
FacilityAutocomplete(peeringdb_server.autocomplete_views.AutocompleteHTMLResponse)
```
List options for a Select2 widget.
### Methods
#### get_queryset
`def get_queryset(self)`
Filter the queryset with GET['q'].
---
#### get_result_label
`def get_result_label(self, item)`
Return the label of a result.
---
## FacilityAutocompleteForExchange
```
FacilityAutocompleteForExchange(peeringdb_server.autocomplete_views.FacilityAutocomplete)
```
List options for a Select2 widget.
### Methods
#### get_queryset
`def get_queryset(self)`
Filter the queryset with GET['q'].
---
## FacilityAutocompleteForNetwork
```
FacilityAutocompleteForNetwork(peeringdb_server.autocomplete_views.FacilityAutocomplete)
```
List options for a Select2 widget.
### Methods
#### get_queryset
`def get_queryset(self)`
Filter the queryset with GET['q'].
---
## FacilityAutocompleteJSON
```
FacilityAutocompleteJSON(dal_select2.views.Select2QuerySetView)
```
List options for a Select2 widget.
### Methods
#### get_queryset
`def get_queryset(self)`
Filter the queryset with GET['q'].
---
## GrappelliHandlerefAutocomplete
```
GrappelliHandlerefAutocomplete(grappelli.views.related.AutocompleteLookup)
```
Make sure that the auto-complete fields managed
by grappelli in django admin exclude soft-deleted
objects.
## IXLanAutocomplete
```
IXLanAutocomplete(peeringdb_server.autocomplete_views.AutocompleteHTMLResponse)
```
List options for a Select2 widget.
### Methods
#### get_queryset
`def get_queryset(self)`
Filter the queryset with GET['q'].
---
#### get_result_label
`def get_result_label(self, item)`
Return the label of a result.
---
## NetworkAutocomplete
```
NetworkAutocomplete(peeringdb_server.autocomplete_views.AutocompleteHTMLResponse)
```
List options for a Select2 widget.
### Methods
#### get_queryset
`def get_queryset(self)`
Filter the queryset with GET['q'].
---
#### get_result_label
`def get_result_label(self, item)`
Return the label of a result.
---
## OrganizationAutocomplete
```
OrganizationAutocomplete(peeringdb_server.autocomplete_views.AutocompleteHTMLResponse)
```
List options for a Select2 widget.
### Methods
#### get_queryset
`def get_queryset(self)`
Filter the queryset with GET['q'].
---
#### get_result_label
`def get_result_label(self, item)`
Return the label of a result.
---
## ToolHistory
```
ToolHistory(peeringdb_server.autocomplete_views.CommandLineToolHistoryAutocomplete)
```
Autocomplete for command line tools that were run via the admin ui.

View File

@@ -0,0 +1,18 @@
Generated from context.py on 2021-10-15 07:56:57.376975
# peeringdb_server.context
Define custom context managers.
# Functions
---
## current_request
`def current_request(request=None)`
Will yield the current request, if there is one.
To se the current request for the context pass it to
the request parameter.
---

View File

@@ -0,0 +1,59 @@
Generated from data_views.py on 2021-10-15 07:56:57.376975
# peeringdb_server.data_views
This holds JSON views for various data sets.
These are needed for filling form-selects for editable
mode in UX.
# Functions
---
## asns
`def asns(request)`
Return a JSON response with a list of asns that the user's
organizations own to use for selecting asn in netixlan
creation.
---
## countries
`def countries(request)`
Return all valid countries and their country codes.
---
## countries_w_blank
`def countries_w_blank(request)`
Return all valid countries and their country codes with a blank field.
---
## facilities
`def facilities(request)`
Return all valid facilities with id and name.
---
## my_organizations
`def my_organizations(request)`
Return a JSON response with a list of organization names and ids
that the requesting user is a member of.
---
## organizations
`def organizations(request)`
Return a JSON response with a list of organization names and ids.
This is currently only used by the org-merge-tool which is only
available to site administrators.
---
## sponsorships
`def sponsorships(request)`
Return all sponsorships.
---

View File

@@ -0,0 +1,30 @@
Generated from db_router.py on 2021-10-15 07:56:57.136306
# peeringdb_server.db_router
Custom django database routers.
Split read and write database connections if needed.
# Classes
---
## DatabaseRouter
```
DatabaseRouter(builtins.object)
```
A very basic database router that routes to a different
read and write db.
## TestRouter
```
TestRouter(peeringdb_server.db_router.DatabaseRouter)
```
A very basic database router that routes to a different
read and write db.

View File

@@ -0,0 +1,120 @@
Generated from deskpro.py on 2021-10-15 07:56:57.376975
# peeringdb_server.deskpro
DeskPro API Client used to post and retrieve support ticket information
from the deskpro API.
# Functions
---
## ticket_queue
`def ticket_queue(subject, body, user)`
Queue a deskpro ticket for creation.
---
## ticket_queue_asnauto_affil
`def ticket_queue_asnauto_affil(user, org, net, rir_data)`
Queue deskro ticket creation for asn automation action: affil.
---
## ticket_queue_asnauto_create
`def ticket_queue_asnauto_create(user, org, net, rir_data, asn, org_created=False, net_created=False)`
Queue deskro ticket creation for asn automation action: create.
---
## ticket_queue_asnauto_skipvq
`def ticket_queue_asnauto_skipvq(request, org, net, rir_data)`
Queue deskro ticket creation for asn automation action: skip vq.
---
## ticket_queue_deletion_prevented
`def ticket_queue_deletion_prevented(request, instance)`
Queue deskpro ticket to notify the prevented
deletion of an object #696.
---
## ticket_queue_email_only
`def ticket_queue_email_only(subject, body, email)`
Queue a deskpro ticket for creation.
---
# Classes
---
## APIError
```
APIError(builtins.OSError)
```
Base class for I/O related errors.
### Methods
#### \__init__
`def __init__(self, msg, data)`
Initialize self. See help(type(self)) for accurate signature.
---
## FailingMockAPIClient
```
FailingMockAPIClient(peeringdb_server.deskpro.MockAPIClient)
```
A mock API client for the deskpro API
that returns an error on post.
Use in tests, for example
with issue 856.
### Methods
#### \__init__
`def __init__(self, *args, **kwargs)`
Initialize self. See help(type(self)) for accurate signature.
---
#### create_ticket
`def create_ticket(self, ticket=None)`
Create a deskpro ticket using the deskpro API.
Arguments:
- ticket (`DeskProTicket`)
---
## MockAPIClient
```
MockAPIClient(peeringdb_server.deskpro.APIClient)
```
A mock API client for the deskpro API.
The IX-F importer uses this when
IXF_SEND_TICKETS=False
### Methods
#### \__init__
`def __init__(self, *args, **kwargs)`
Initialize self. See help(type(self)) for accurate signature.
---

View File

@@ -0,0 +1,170 @@
Generated from export_views.py on 2021-10-15 07:56:57.376975
# peeringdb_server.export_views
Define export views used for IX-F export and advanced search file download.
# Classes
---
## AdvancedSearchExportView
```
AdvancedSearchExportView(peeringdb_server.export_views.ExportView)
```
Allow exporting of advanced search result data.
### Methods
#### fetch
`def fetch(self, request)`
Fetch data from API according to GET parameters.
Note that `limit` and `depth` will be overwritten, other API
parameters will be passed along as-is.
Returns:
- dict: un-rendered dataset returned by API
---
#### generate
`def generate(self, request)`
Generate data for the reftag specified in self.tag
This function will call generate_<tag> and return the result.
Arguments:
- request <Request>
Returns:
- list: list containing rendered data rows ready for export
---
#### generate_fac
`def generate_fac(self, request)`
Fetch facility data from the API according to request and then render
it ready for export.
Arguments:
- request <Request>
Returns:
- list: list containing rendered data ready for export
---
#### generate_ix
`def generate_ix(self, request)`
Fetch exchange data from the API according to request and then render
it ready for export.
Arguments:
- request <Request>
Returns:
- list: list containing rendered data ready for export
---
#### generate_net
`def generate_net(self, request)`
Fetch network data from the API according to request and then render
it ready for export.
Arguments:
- request <Request>
Returns:
- list: list containing rendered data ready for export
---
#### generate_org
`def generate_org(self, request)`
Fetch organization data from the API according to request and then render
it ready for export.
Arguments:
- request <Request>
Returns:
- list: list containing rendered data ready for export
---
#### get
`def get(self, request, tag, fmt)`
Handle export.
LGTM Notes: signature-mismatch: order of arguments are defined by the
url routing set up for this view. (e.g., /<tag>/<fmt>)
The `get` method will never be called in a different
context where a mismatching signature would matter so
the lgtm warning can be ignored in this case.
---
## ExportView
```
ExportView(django.views.generic.base.View)
```
Base class for more complex data exports.
### Methods
#### generate
`def generate(self, request)`
Function that generates export data from request.
Override this.
---
#### response_csv
`def response_csv(self, data)`
Return Response object for CSV response.
Arguments:
- data <list>
Returns:
- HttpResponse
---
#### response_json
`def response_json(self, data)`
Return Response object for normal json response.
Arguments:
- data <list|dict>: serializable data, if list is passed you will need
to specify a value in self.json_root_key
Returns:
- JsonResponse
---
#### response_json_pretty
`def response_json_pretty(self, data)`
Return Response object for pretty (indented) json response.
Arguments:
- data <list|dict>: serializable data, if list is passed tou will need
to specify a value in self.json_root_key
Returns:
- HttpResponse: http response with appropriate json headers, cannot use
JsonResponse here because we need to specify indent level
---

View File

@@ -0,0 +1,164 @@
Generated from forms.py on 2021-10-15 07:56:57.376975
# peeringdb_server.forms
Custom django forms.
Note: This does not includes forms pointed directly
at the REST api to handle updates (such as /net, /ix, /fac or /org endpoints).
Look in rest.py and serializers.py for those.
# Classes
---
## AffiliateToOrgForm
```
AffiliateToOrgForm(django.forms.forms.Form)
```
A collection of Fields, plus their associated data.
### Instanced Attributes
These attributes / properties will be available on instances of the class
- media (`@property`): None
## OrgAdminUserPermissionForm
```
OrgAdminUserPermissionForm(django.forms.forms.Form)
```
A collection of Fields, plus their associated data.
### Instanced Attributes
These attributes / properties will be available on instances of the class
- media (`@property`): None
## OrganizationAPIKeyForm
```
OrganizationAPIKeyForm(django.forms.forms.Form)
```
A collection of Fields, plus their associated data.
### Instanced Attributes
These attributes / properties will be available on instances of the class
- media (`@property`): None
## OrganizationLogoUploadForm
```
OrganizationLogoUploadForm(django.forms.models.ModelForm)
```
The main implementation of all the Form logic. Note that this class is
different than Form. See the comments by the Form class for more info. Any
improvements to the form API should be made to this class, not to the Form
class.
### Instanced Attributes
These attributes / properties will be available on instances of the class
- media (`@property`): None
## PasswordChangeForm
```
PasswordChangeForm(django.forms.forms.Form)
```
A collection of Fields, plus their associated data.
### Instanced Attributes
These attributes / properties will be available on instances of the class
- media (`@property`): None
## PasswordResetForm
```
PasswordResetForm(django.forms.forms.Form)
```
A collection of Fields, plus their associated data.
### Instanced Attributes
These attributes / properties will be available on instances of the class
- media (`@property`): None
## UserCreationForm
```
UserCreationForm(django.contrib.auth.forms.UserCreationForm)
```
A form that creates a user, with no privileges, from the given username and
password.
### Instanced Attributes
These attributes / properties will be available on instances of the class
- media (`@property`): None
### Methods
#### clean
`def clean(self)`
Hook for doing any extra form-wide cleaning after Field.clean() has been
called on every field. Any ValidationError raised by this method will
not be associated with a particular field; it will have a special-case
association with the field named '__all__'.
---
## UserLocaleForm
```
UserLocaleForm(django.forms.forms.Form)
```
A collection of Fields, plus their associated data.
### Instanced Attributes
These attributes / properties will be available on instances of the class
- media (`@property`): None
## UsernameRetrieveForm
```
UsernameRetrieveForm(django.forms.forms.Form)
```
A collection of Fields, plus their associated data.
### Instanced Attributes
These attributes / properties will be available on instances of the class
- media (`@property`): None

View File

@@ -0,0 +1,3 @@
Generated from gendocs.py on 2021-10-15 07:56:57.136306
# peeringdb_server.gendocs

107
docs/dev/modules/geo.py.md Normal file
View File

@@ -0,0 +1,107 @@
Generated from geo.py on 2021-10-15 07:56:57.376975
# peeringdb_server.geo
Utilities for geocoding and geo normalization.
# Classes
---
## Melissa
```
Melissa(builtins.object)
```
Handle requests to the melissa global address
service used for geocoding and address normalization.
### Methods
#### \__init__
`def __init__(self, key, timeout=5)`
Initialize self. See help(type(self)) for accurate signature.
---
#### global_address
`def global_address(self, **kwargs)`
Send request to the global address service.
Keyword arguments:
- address1
- address2
- city
- country
- zipcode
---
#### sanitize
`def sanitize(self, **kwargs)`
Take an international address and sanitize it
using the melissa global address service.
---
#### sanitize_address_model
`def sanitize_address_model(self, instance)`
Take an instance of AddressModel and
run its address through the normalization
process.
Note that this will not actually change fields
on the instance.
Return dict with normalized address data and
geo coordinates.
---
## NotFound
```
NotFound(builtins.OSError)
```
Base class for I/O related errors.
## RequestError
```
RequestError(builtins.OSError)
```
Base class for I/O related errors.
### Methods
#### \__init__
`def __init__(self, exc)`
Initialize self. See help(type(self)) for accurate signature.
---
## Timeout
```
Timeout(builtins.OSError)
```
Base class for I/O related errors.
### Methods
#### \__init__
`def __init__(self)`
Initialize self. See help(type(self)) for accurate signature.
---

View File

@@ -0,0 +1,15 @@
Generated from import_views.py on 2021-10-15 07:56:57.376975
# peeringdb_server.import_views
Define ix-f import preview, review and post-mortem views.
# Functions
---
## enable_basic_auth
`def enable_basic_auth(fn)`
A simple decorator to enable basic auth for a specific view.
---

156
docs/dev/modules/inet.py.md Normal file
View File

@@ -0,0 +1,156 @@
Generated from inet.py on 2021-10-15 07:56:57.376975
# peeringdb_server.inet
RDAP lookup and validation.
Network validation.
Prefix renumbering.
# Functions
---
## asn_is_bogon
`def asn_is_bogon(asn)`
Test if an asn is bogon by being either in the documentation
or private asn ranges.
Arguments:
- asn<int>
Return:
- bool: True if in bogon range
---
## asn_is_in_ranges
`def asn_is_in_ranges(asn, ranges)`
Test if an asn falls within any of the ranges provided.
Arguments:
- asn<int>
- ranges<list[tuple(min,max)]>
Return:
- bool
---
## get_prefix_protocol
`def get_prefix_protocol(prefix)`
Take a network address space prefix string and return
a string describing the protocol.
Will raise a ValueError if it cannot determine protocol.
Returns:
str: IPv4 or IPv6
---
## network_is_bogon
`def network_is_bogon(network)`
Return if the passed ipaddress network is a bogon.
Arguments:
- network <ipaddress.IPv4Network|ipaddress.IPv6Network>
Return:
- bool
---
## network_is_pdb_valid
`def network_is_pdb_valid(network)`
Return if the passed ipaddress network is in pdb valid
address space.
Arguments:
- network <ipaddress.IPv4Network|ipaddress.IPv6Network>
Return:
- bool
---
## rdap_pretty_error_message
`def rdap_pretty_error_message(exc)`
Take an RdapException instance and return a customer friendly
error message (str).
---
## renumber_ipaddress
`def renumber_ipaddress(ipaddr, old_prefix, new_prefix)`
Renumber an ipaddress from old prefix to new prefix.
Arguments:
- ipaddr (ipaddress.ip_address)
- old_prefix (ipaddress.ip_network)
- new_prefix (ipaddress.ip_network)
Returns:
- ipaddress.ip_address: renumbered ip address
---
# Classes
---
## BogonAsn
```
BogonAsn(rdap.objects.RdapAsn)
```
On tutorial mode environments, return an instance
of this to provide an rdapasn result for asns in the
private and documentation ranges.
### Methods
#### \__init__
`def __init__(self, asn)`
Initialize self. See help(type(self)) for accurate signature.
---
## RdapInvalidRange
```
RdapInvalidRange(rdap.exceptions.RdapException)
```
Base exception used by this module.
## RdapLookup
```
RdapLookup(rdap.client.RdapClient)
```
Does RDAP lookups against defined URL.
### Methods
#### \__init__
`def __init__(self)`
Initialize an RdapClient.
config is a dict or rdap.config.Config object
config_dir is a string pointing to a config directory
---
#### get_asn
`def get_asn(self, asn)`
Handle asns that fall into the private/documentation ranges
manually - others are processed normally through rdap lookup.
---

107
docs/dev/modules/ixf.py.md Normal file
View File

@@ -0,0 +1,107 @@
Generated from ixf.py on 2021-10-15 07:56:57.376975
# peeringdb_server.ixf
IX-F importer implementation.
Handles import of ix-f feeds, creation of suggestions for networks and exchanges
to follow.
Handles notifications of networks and exchanges as part of that process.
A substantial part of the import logic is handled through models.py::IXFMemberData
# Classes
---
## MultipleVlansInPrefix
```
MultipleVlansInPrefix(builtins.ValueError)
```
This error is raised when an ix-f export contains
multiple vlan ids for the prefixes defined in the processed ixlan.
Since peeringdb treats each vlan as it's own exchange this currently
is not a compatible setup for import (see #889).
### Methods
#### \__init__
`def __init__(self, importer, *args, **kwargs)`
Initialize self. See help(type(self)) for accurate signature.
---
## PostMortem
```
PostMortem(builtins.object)
```
Generate postmortem report for ix-f import.
### Methods
#### _process_log_entry
`def _process_log_entry(self, log, entry)`
Process a single IX-F import log entry.
Argument(s):
- log <IXLanIXFMemberImportLog>
- entry <IXLanIXFMemberImportLogEntry>
---
#### _process_logs
`def _process_logs(self, limit=100)`
Process IX-F import logs.
KeywordArgument(s):
- limit <int=100>: limit amount of import logs to process
max limit is defined by server config `IXF_POSTMORTEM_LIMIT`
---
#### generate
`def generate(self, asn, **kwargs)`
Generate and return a new postmortem report.
Argument(s):
- asn <int>: asn of the network to run postmortem
report for
Keyword Argument(s):
- limit <int=100>: limit amount of import logs to process
max limit is defined by server config `IXF_POSTMORTEM_LIMIT`
Returns:
- dict: postmortem report
---
#### reset
`def reset(self, asn, **kwargs)`
Reset for a fresh run.
Argument(s):
- asn <int>: asn of the network to run postormem
report for
Keyword Argument(s):
- limit <int=100>: limit amount of import logs to process
max limit is defined by server config `IXF_POSTMORTEM_LIMIT`
---

View File

@@ -0,0 +1,42 @@
Generated from mail.py on 2021-10-15 07:56:57.376975
# peeringdb_server.mail
Utility functions for emailing users and admin staff.
# Functions
---
## mail_admins_with_from
`def mail_admins_with_from(subj, msg, from_addr, fail_silently=False, connection=None, html_message=None)`
Mail admins but allow specifying of from address.
---
## mail_username_retrieve
`def mail_username_retrieve(email, secret)`
Send an email to the specified email address containing
the url for username retrieval.
Arguments:
- email <str>
- secret <str>: username retrieval secret in the user's session
---
## mail_users_entity_merge
`def mail_users_entity_merge(users_source, users_target, entity_source, entity_target)`
Notify the users specified in users_source that their entity (entity_source) has
been merged with another entity (entity_target).
Notify the users specified in users_target that an entity has ben merged into their
entity (entity_target).
Arguments:
- users_source <list>: list of User objects
- users_target <list>: list of User objects
- entity_source <HandleRef>: handleref object, entity that was merged
- entity_target <HandleRef>: handleref object, entity that was merged into
---

View File

@@ -0,0 +1,83 @@
Generated from maintenance.py on 2021-10-15 07:56:57.376975
# peeringdb_server.maintenance
Django middleware to handle maintenance mode.
# Functions
---
## active
`def active()`
Return True if maintenance mode is currently active.
---
## off
`def off()`
Turn maintenance mode off.
---
## on
`def on(timeout=None)`
Turn maintenance mode on.
Keyword Arguments:
- timeout<int=None>: if specified will automatically
end maintenance mode after n seconds
---
## raise_if_active
`def raise_if_active()`
Raise ActionBlocked exception if maintenance mode is active.
---
# Classes
---
## ActionBlocked
```
ActionBlocked(builtins.Exception)
```
Common base class for all non-exit exceptions.
### Methods
#### \__init__
`def __init__(self)`
Initialize self. See help(type(self)) for accurate signature.
---
## Middleware
```
Middleware(builtins.object)
```
Middleware will return 503 json responses for all write
ops (POST PUT PATCH DELETE).
### Methods
#### \__call__
`def __call__(self, request)`
Call self as a function.
---
#### \__init__
`def __init__(self, get_response=None)`
Initialize self. See help(type(self)) for accurate signature.
---

View File

@@ -0,0 +1,34 @@
Generated from middleware.py on 2021-10-15 07:56:57.376975
# peeringdb_server.middleware
Custom django middleware.
# Classes
---
## CurrentRequestContext
```
CurrentRequestContext(builtins.object)
```
Middleware that sets the current request context.
This allows access to the current request from anywhere.
### Methods
#### \__call__
`def __call__(self, request)`
Call self as a function.
---
#### \__init__
`def __init__(self, get_response)`
Initialize self. See help(type(self)) for accurate signature.
---

View File

@@ -0,0 +1,42 @@
Generated from mock.py on 2021-10-15 07:56:57.376975
# peeringdb_server.mock
Handle generation of mock data for testing purposes.
# Classes
---
## Mock
```
Mock(builtins.object)
```
Class that allows creation of mock data in the database.
NOTE: This actually writes data to the database and should
only be used to populate a dev instance.
### Methods
#### \__init__
`def __init__(self)`
Initialize self. See help(type(self)) for accurate signature.
---
#### create
`def create(self, reftag, **kwargs)`
Create a new instance of model specified in `reftag`
Any arguments passed as kwargs will override mock field values.
Note: Unless there are no relationships passed in kwargs, required parent
objects will be automatically created as well.
Returns: The created instance.
---

View File

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,75 @@
Generated from org_admin_views.py on 2021-10-15 07:56:57.376975
# peeringdb_server.org_admin_views
View for organization administrative actions (/org endpoint).
# Functions
---
## extract_permission_id
`def extract_permission_id(source, dest, entity, org)`
Extract a user's permissioning id for the specified
entity from source <dict> and store it in dest <dict>.
Source should be a dict containing django-namespace-perms
(namespace, level) items.
Dest should be a dict where permission ids are to be
exracted to.
Entity can either be a HandleRef instance or class.
Org must be an Organization instance that owns the
entity.
---
## load_all_user_permissions
`def load_all_user_permissions(org)`
Return dict of all users with all their permissions for
the given org.
---
## load_entity_permissions
`def load_entity_permissions(org, entity)`
Return entity's permissions for the specified org.
---
## org_admin_required
`def org_admin_required(fnc)`
Decorator function that ensures that the requesting user
has administrative rights to the targeted organization.
Also sets "org" in kwargs.
---
## permission_ids
`def permission_ids(org)`
Return a dict of a valid permissioning ids for
the specified organization.
---
## save_user_permissions
`def save_user_permissions(org, user, perms)`
Save user permissions for the specified org and user.
Perms should be a dict of permissioning ids and permission levels.
---
## target_user_validate
`def target_user_validate(fnc)`
Decorator function that ensures that the targeted user
is a member of the targeted organization.
Should be below org_admin_required.
Also sets "user" in kwargs.
---

View File

@@ -0,0 +1,159 @@
Generated from permissions.py on 2021-10-15 07:56:57.376975
# peeringdb_server.permissions
Utilities for permission handling.
Permission logic is handled through django-grainy.
API key auth is handled through djangorestframework-api-key.
Determine permission holder from request (api key or user).
Read only user api key handling.
Censor API output data according to permissions using grainy Applicators.
# Functions
---
## check_permissions
`def check_permissions(obj, target, permissions, **kwargs)`
Use the provided permission holding object to initialize
the Permissions Util, which then checks permissions.
---
## check_permissions_from_request
`def check_permissions_from_request(request, target, flag, **kwargs)`
Call the check_permissions util but takes a request as
input, not a permission-holding object.
---
## get_key_from_request
`def get_key_from_request(request)`
Use the default KeyParser from drf-api-keys to pull the key out of the request.
---
## get_org_key_from_request
`def get_org_key_from_request(request)`
Return an org key from the request if the request
was made with an OrgKey.
Otherwise returns None.
---
## get_permission_holder_from_request
`def get_permission_holder_from_request(request)`
Return either an API Key instance or User instance
depending on how the request is Authenticated.
---
## get_user_from_request
`def get_user_from_request(request)`
Return a user from the request if the request
was made with either a User or UserAPIKey.
If request was made with OrgKey, returns None.
---
## get_user_key_from_request
`def get_user_key_from_request(request)`
Return a user API key from the request if the request
was made with an User API Key.
Otherwise returns None.
---
## init_permissions_helper
`def init_permissions_helper(obj)`
Initialize the Permission Util based on
whether the provided object is a UserAPIKey, OrgAPIKey,
or a different object.
---
## return_org_api_key_perms
`def return_org_api_key_perms(key)`
Load Permissions util with OrgAPIKey perms
and then add in that organization's user group perms
and general user group permissions.
---
## return_user_api_key_perms
`def return_user_api_key_perms(key)`
Initialize the Permissions Util with the
permissions of the user linked to the User API
key.
If the UserAPIKey is marked readonly, it downgrades
all permissions to readonly.
---
# Classes
---
## APIPermissionsApplicator
```
APIPermissionsApplicator(grainy.core.NamespaceKeyApplicator)
```
Applicator that looks for permission namespaces from
a specified field in the dict it is scanning
### Instanced Attributes
These attributes / properties will be available on instances of the class
- is_generating_api_cache (`@property`): None
### Methods
#### \__init__
`def __init__(self, request)`
Initialize self. See help(type(self)) for accurate signature.
---
## ModelViewSetPermissions
```
ModelViewSetPermissions(rest_framework.permissions.BasePermission)
```
Use as a permission class on a ModelRestViewSet
to automatically wire up the following views
to the correct permissions based on the handled object:
- retrieve
- list
- create
- destroy
- update
- partial update
### Methods
#### has_object_permission
`def has_object_permission(self, request, view, obj)`
Return `True` if permission is granted, `False` otherwise.
---
#### has_permission
`def has_permission(self, request, view)`
Return `True` if permission is granted, `False` otherwise.
---

View File

@@ -0,0 +1,3 @@
# peeringdb_server.pymdgen_init
pymdgen helper (doc generation)

View File

@@ -0,0 +1,61 @@
Generated from renderers.py on 2021-10-15 07:56:57.376975
# peeringdb_server.renderers
REST API renderer.
Ensure valid json output of the REST API.
# Classes
---
## JSONEncoder
```
JSONEncoder(rest_framework.utils.encoders.JSONEncoder)
```
Define json encoder to be able to encode
datatime and django countryfields.
Make the munge renderer use this encoder to encode json. This approach
may need to be tidied up a bit.
### Methods
#### default
`def default(self, obj)`
Default JSON serializer.
---
## MetaJSONRenderer
```
MetaJSONRenderer(peeringdb_server.renderers.MungeRenderer)
```
Renderer which serializes to JSON.
Does *not* apply JSON's character escaping for non-ascii characters.
### Methods
#### render
`def render(self, data, accepted_media_type=None, renderer_context=None)`
Tweak output rendering and pass to parent.
---
## MungeRenderer
```
MungeRenderer(rest_framework.renderers.BaseRenderer)
```
All renderers should extend this class, setting the `media_type`
and `format` attributes, and override the `.render()` method.

View File

@@ -0,0 +1,22 @@
Generated from request.py on 2021-10-15 07:56:57.376975
# peeringdb_server.request
Django HTTPRequest utilities.
# Functions
---
## bypass_validation
`def bypass_validation(request=None)`
Return whether the specified request is to bypass
certain data quality validations. (#741)
If not request is passed, attempt to get
the current request from the current request
context.
If no request can be obtained this will return False.
---

368
docs/dev/modules/rest.py.md Normal file
View File

@@ -0,0 +1,368 @@
Generated from rest.py on 2021-10-15 07:56:57.376975
# 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.
---

View File

@@ -0,0 +1,80 @@
Generated from rest_throttles.py on 2021-10-15 07:56:57.376975
# peeringdb_server.rest_throttles
Custom rate limit handlers for the REST API.
# Classes
---
## FilterDistanceThrottle
```
FilterDistanceThrottle(peeringdb_server.rest_throttles.FilterThrottle)
```
Rate limiting for ?distance= queries.
## FilterThrottle
```
FilterThrottle(rest_framework.throttling.SimpleRateThrottle)
```
Base class for API throttling targeted at specific query filters.
Scope name will be 'filter_{self.filter_name}'
### Methods
#### \__init__
`def __init__(self)`
Initialize self. See help(type(self)) for accurate signature.
---
#### allow_request
`def allow_request(self, request, view)`
Implement the check to see if the request should be throttled.
On success calls `throttle_success`.
On failure calls `throttle_failure`.
---
#### get_cache_key
`def get_cache_key(self, request, view)`
Should return a unique cache-key which can be used for throttling.
Must be overridden.
May return `None` if the request should not be throttled.
---
## IXFImportThrottle
```
IXFImportThrottle(rest_framework.throttling.UserRateThrottle)
```
Limits the rate of API calls that may be made by a given user.
The user id will be used as a unique cache key if the user is
authenticated. For anonymous requests, the IP address of the request will
be used.
### Methods
#### get_cache_key
`def get_cache_key(self, request, view)`
Should return a unique cache-key which can be used for throttling.
Must be overridden.
May return `None` if the request should not be throttled.
---

View File

@@ -0,0 +1,23 @@
Generated from search.py on 2021-10-15 07:56:57.376975
# peeringdb_server.search
Search implementation used for the peeringdb top search bar, name
searches through the api `name_search` filter, as well as advanced
search functionality.
Search logic is handled by django-haystack and whoosh.
Refer to search_indexes.py for search index definition.
# Functions
---
## search
`def search(term, autocomplete=False)`
Search searchable objects (ixp, network, facility ...) by term.
Returns result dict.
---

View File

@@ -0,0 +1,199 @@
Generated from search_indexes.py on 2021-10-15 07:56:57.376975
# peeringdb_server.search_indexes
Defines django-haystack search indexes.
# Classes
---
## EntityIndex
```
EntityIndex(haystack.indexes.SearchIndex)
```
Search index for org, net, ix and fac entities.
### Methods
#### build_queryset
`def build_queryset(self, using=None, start_date=None, end_date=None)`
Get the default QuerySet to index when doing an index update.
Subclasses can override this method to take into account related
model modification times.
The default is to use ``SearchIndex.index_queryset`` and filter
based on ``SearchIndex.get_updated_field``
---
#### get_model
`def get_model(self)`
Should return the ``Model`` class (not an instance) that the rest of the
``SearchIndex`` should use.
This method is required & you must override it to return the correct class.
---
#### get_updated_field
`def get_updated_field(self)`
Use this field to determine object age. This
is required for the --age parameter to function
in the update_index command.
---
#### prepare
`def prepare(self, obj)`
Fetches and adds/alters data before indexing.
---
## FacilityIndex
```
FacilityIndex(peeringdb_server.search_indexes.MainEntity, haystack.constants.Indexable)
```
Search index for org, net, ix and fac entities.
### Methods
#### get_model
`def get_model(self)`
Should return the ``Model`` class (not an instance) that the rest of the
``SearchIndex`` should use.
This method is required & you must override it to return the correct class.
---
## IXLanPrefixIndex
```
IXLanPrefixIndex(peeringdb_server.search_indexes.EntityIndex, haystack.constants.Indexable)
```
Search index for org, net, ix and fac entities.
### Methods
#### get_model
`def get_model(self)`
Should return the ``Model`` class (not an instance) that the rest of the
``SearchIndex`` should use.
This method is required & you must override it to return the correct class.
---
## InternetExchangeIndex
```
InternetExchangeIndex(peeringdb_server.search_indexes.MainEntity, haystack.constants.Indexable)
```
Search index for org, net, ix and fac entities.
### Methods
#### get_model
`def get_model(self)`
Should return the ``Model`` class (not an instance) that the rest of the
``SearchIndex`` should use.
This method is required & you must override it to return the correct class.
---
## MainEntity
```
MainEntity(peeringdb_server.search_indexes.EntityIndex)
```
Search index for org, net, ix and fac entities.
### Methods
#### prepare
`def prepare(self, obj)`
Fetches and adds/alters data before indexing.
---
## NetworkIXLanIndex
```
NetworkIXLanIndex(peeringdb_server.search_indexes.EntityIndex, haystack.constants.Indexable)
```
Search index for org, net, ix and fac entities.
### Methods
#### get_model
`def get_model(self)`
Should return the ``Model`` class (not an instance) that the rest of the
``SearchIndex`` should use.
This method is required & you must override it to return the correct class.
---
## NetworkIndex
```
NetworkIndex(peeringdb_server.search_indexes.MainEntity, haystack.constants.Indexable)
```
Search index for org, net, ix and fac entities.
### Methods
#### get_model
`def get_model(self)`
Should return the ``Model`` class (not an instance) that the rest of the
``SearchIndex`` should use.
This method is required & you must override it to return the correct class.
---
## OrganizationIndex
```
OrganizationIndex(peeringdb_server.search_indexes.MainEntity, haystack.constants.Indexable)
```
Search index for org, net, ix and fac entities.
### Methods
#### get_model
`def get_model(self)`
Should return the ``Model`` class (not an instance) that the rest of the
``SearchIndex`` should use.
This method is required & you must override it to return the correct class.
---

View File

@@ -0,0 +1,755 @@
Generated from serializers.py on 2021-10-15 07:56:57.376975
# peeringdb_server.serializers
REST API Serializer definitions.
REST API POST / PUT data validators.
New serializers should extend ModelSerializer class, which is a custom extension
of django-rest-framework's ModelSerializer.
Custom ModelSerializer implements logic for the expansion of relationships driven by the `depth` url parameter. The depth parameter indicates how many objects to recurse into.
Special api filtering implementation should be done through the `prepare_query`
method.
# Functions
---
## nested
`def nested(serializer, exclude=[], getter=None, through=None, **kwargs)`
Use this function to create nested serializer fields. Making
depth work otherwise while fetching related lists via handlref remains a mystery.
---
## queryable_field_xl
`def queryable_field_xl(fld)`
Translate <fld>_id into <fld> and also translate fac and net queries into "facility"
and "network" queries.
FIXME: should be renamed on model schema.
---
# Classes
---
## AddressSerializer
```
AddressSerializer(rest_framework.serializers.ModelSerializer)
```
A `ModelSerializer` is just a regular `Serializer`, except that:
* A set of default fields are automatically populated.
* A set of default validators are automatically populated.
* Default `.create()` and `.update()` implementations are provided.
The process of automatically determining a set of serializer fields
based on the model fields is reasonably complex, but you almost certainly
don't need to dig into the implementation.
If the `ModelSerializer` class *doesn't* generate the set of fields that
you need you should either declare the extra/differing fields explicitly on
the serializer class, or simply use a `Serializer` class.
## AsnRdapValidator
```
AsnRdapValidator(builtins.object)
```
A validator that queries rdap entries for the provided value (Asn)
and will fail if no matching asn is found.
### Methods
#### \__call__
`def __call__(self, attrs)`
Call self as a function.
---
#### \__init__
`def __init__(self, field=asn, message=None, methods=None)`
Initialize self. See help(type(self)) for accurate signature.
---
## FacilitySerializer
```
FacilitySerializer(peeringdb_server.serializers.SpatialSearchMixin, peeringdb_server.serializers.GeocodeSerializerMixin, peeringdb_server.serializers.ModelSerializer)
```
Serializer for peeringdb_server.models.Facility
Possible relationship queries:
- net_id, handled by prepare_query
- ix_id, handled by prepare_query
- org_id, handled by serializer
- org_name, hndled by prepare_query
### Methods
#### to_internal_value
`def to_internal_value(self, data)`
Dict of native values <- Dict of primitive datatypes.
---
#### to_representation
`def to_representation(self, instance)`
Object instance -> Dict of primitive datatypes.
---
## FieldMethodValidator
```
FieldMethodValidator(builtins.object)
```
A validator that will only allow a field to be set for certain
methods.
### Methods
#### \__call__
`def __call__(self, attrs)`
Call self as a function.
---
#### \__init__
`def __init__(self, field, methods, message=None)`
Initialize self. See help(type(self)) for accurate signature.
---
## GeocodeSerializerMixin
```
GeocodeSerializerMixin(builtins.object)
```
Override create() and update() method of serializer
to normalize the location against the Google Maps Geocode API
and resave the model instance with normalized address fields.
Can only be used if the model includes the GeocodeBaseMixin.
### Methods
#### _add_meta_information
`def _add_meta_information(self, metadata)`
Adds a dictionary of metadata to the "meta" field of the API
request, so that it ends up in the API response.
---
#### _geosync_information_present
`def _geosync_information_present(self, instance, validated_data)`
Determine if there is enough address information
to necessitate a geosync attempt.
---
#### _need_geosync
`def _need_geosync(self, instance, validated_data)`
Determine if any geofields that have changed need normalization.
Returns False if the only change is that fields have been deleted.
---
#### handle_geo_error
`def handle_geo_error(self, exc, instance)`
Issue #939: In the event that there is an error in geovalidating
the address (including address not found), a warning is returned in
the "meta" field of the response and null the latitude and
longitude on the instance.
---
#### needs_address_suggestion
`def needs_address_suggestion(self, suggested_address, instance)`
Issue #940: If the geovalidated address meaningfully differs
from the address the user provided, we return True to signal
a address suggestion should be provided to the user.
---
#### update
`def update(self, instance, validated_data)`
When updating a geo-enabled object,
update the model first
and then normalize the geofields.
---
## IXLanPrefixSerializer
```
IXLanPrefixSerializer(peeringdb_server.serializers.ModelSerializer)
```
Serializer for peeringdb_server.models.IXLanPrefix
Possible relationship queries:
- ixlan_id, handled by serializer
- ix_id, handled by prepare_query
## IXLanSerializer
```
IXLanSerializer(peeringdb_server.serializers.ModelSerializer)
```
Serializer for peeringdb_server.models.IXLan
Possible relationship queries:
- ix_id, handled by serializer
## InternetExchangeFacilitySerializer
```
InternetExchangeFacilitySerializer(peeringdb_server.serializers.ModelSerializer)
```
Serializer for peeringdb_server.models.InternetExchangeFacility
Possible relationship queries:
- fac_id, handled by serializer
- ix_id, handled by serializer
## InternetExchangeSerializer
```
InternetExchangeSerializer(peeringdb_server.serializers.ModelSerializer)
```
Serializer for peeringdb_server.models.InternetExchange
Possible relationship queries:
- org_id, handled by serializer
- fac_id, handled by prepare_query
- net_id, handled by prepare_query
- ixfac_id, handled by prepare_query
- ixlan_id, handled by prepare_query
### Methods
#### create
`def create(self, validated_data)`
Entities created via the API should go into the verification
queue with status pending if they are in the QUEUE_ENABLED
list.
---
#### to_representation
`def to_representation(self, data)`
Object instance -> Dict of primitive datatypes.
---
## ModelSerializer
```
ModelSerializer(rest_framework.serializers.ModelSerializer)
```
ModelSerializer that provides DB API with custom params.
Main problem with doing field ops here is data is already fetched, so while
it's fine for single columns, it doesn't help on speed for fk relationships.
However data is not yet serialized so there may be some gain.
Using custom method fields to introspect doesn't work at all, because
they're not called until they're serialized, and then are called once per row,
for example
test_depth = serializers.SerializerMethodField('check_for_fk')
def check_for_fk(self, obj):
print "check ", type(obj)
class Meta:
fields = [
'test_depth',
...
Best bet so far looks like overloading the single object GET in the model
view set, and adding on the relationships, but need to GET to GET the fields
defined yet not included in the query, may have to rewrite the base class,
which would mean talking to the dev and committing back or we'll have this problem
every update.
After testing, the time is all in serialization and transfer, so culling
related here should be fine.
arg[0] is a queryset, but seems to have already been evaluated
Addition Query arguments:
`fields` comma separated list of only fields to display
could cull the default list down quite a bit by default and make people ask explicitly for them
self.Meta.default_fields, but I'm not sure it matters, more testing
### Instanced Attributes
These attributes / properties will be available on instances of the class
- current_depth (`@property`): None
- depth (`@property`): None
- in_list (`@property`): None
- is_root (`@property`): None
### Class Methods
#### default_depth
`def default_depth(cls, is_list)`
Return default depth according to whether resultset is list or single GET.
---
#### depth_from_request
`def depth_from_request(cls, request, is_list)`
Derive aproporiate depth parameter from request. Max and default depth will vary depending on whether
result set is a list or single object.
This will return the depth specified in the request or the next best
possible depth.
---
#### is_unique_query
`def is_unique_query(cls, request)`
Check if the request parameters are expected to return a unique entity.
---
#### max_depth
`def max_depth(cls, is_list)`
Return max depth according to whether resultset is list or single GET.
---
#### prefetch_related
`def prefetch_related(cls, qset, request, prefetch=None, related=None, nested=, depth=None, is_list=False, single=None)`
Prefetch related sets according to depth specified in the request.
Prefetched set data will be located off the instances in an attribute
called "<tag>_set_active_prefetched" where tag is the handleref tag
of the objects the set will be holding.
---
#### queryable_relations
`def queryable_relations(self)`
Returns a list of all second level queryable relation fields.
---
### Methods
#### \__init__
`def __init__(self, *args, **kwargs)`
Initialize self. See help(type(self)) for accurate signature.
---
#### create
`def create(self, validated_data)`
Entities created via the API should go into the verification
queue with status pending if they are in the QUEUE_ENABLED
list.
---
#### finalize_create
`def finalize_create(self, request)`
This will be called on the end of POST request to this serializer.
---
#### finalize_delete
`def finalize_delete(self, request)`
This will be called on the end of DELETE request to this serializer.
---
#### finalize_update
`def finalize_update(self, request)`
This will be called on the end of PUT request to this serializer.
---
#### run_validation
`def run_validation(self, data=<class 'rest_framework.fields.empty'>)`
Custom validation handling.
Will run the vanilla django-rest-framework validation but
wrap it with logic to handle unique constraint errors to
restore soft-deleted objects that are blocking a save on basis
of a unique constraint violation.
---
#### save
`def save(self, **kwargs)`
Entities created via API that have status pending should
attempt to store which user created the item in the
verification queue instance.
---
#### to_representation
`def to_representation(self, data)`
Object instance -> Dict of primitive datatypes.
---
## NetworkContactSerializer
```
NetworkContactSerializer(peeringdb_server.serializers.ModelSerializer)
```
Serializer for peeringdb_server.models.NetworkContact
Possible relationship queries:
- net_id, handled by serializer
### Methods
#### to_representation
`def to_representation(self, data)`
Object instance -> Dict of primitive datatypes.
---
## NetworkFacilitySerializer
```
NetworkFacilitySerializer(peeringdb_server.serializers.ModelSerializer)
```
Serializer for peeringdb_server.models.NetworkFacility
Possible relationship queries:
- fac_id, handled by serializer
- net_id, handled by seralizers
### Methods
#### run_validation
`def run_validation(self, data=<class 'rest_framework.fields.empty'>)`
Custom validation handling.
Will run the vanilla django-rest-framework validation but
wrap it with logic to handle unique constraint errors to
restore soft-deleted objects that are blocking a save on basis
of a unique constraint violation.
---
## NetworkIXLanSerializer
```
NetworkIXLanSerializer(peeringdb_server.serializers.ModelSerializer)
```
Serializer for peeringdb_server.models.NetworkIXLan
Possible relationship queries:
- net_id, handled by serializer
- ixlan_id, handled by serializer
- ix_id, handled by prepare_query
### Class Methods
#### prepare_query
`def prepare_query(cls, qset, **kwargs)`
Allows filtering by indirect relationships.
Currently supports: ix_id
---
### Methods
#### _validate_network_contact
`def _validate_network_contact(self, data)`
Per github ticket #826, a Netixlan is only allowed to be added
if there is a network contact that the AC can contact to resolve issues.
---
#### run_validation
`def run_validation(self, data=<class 'rest_framework.fields.empty'>)`
Custom validation handling.
Will run the vanilla django-rest-framework validation but
wrap it with logic to handle unique constraint errors to
restore soft-deleted objects that are blocking a save on basis
of a unique constraint violation.
---
## NetworkSerializer
```
NetworkSerializer(peeringdb_server.serializers.ModelSerializer)
```
Serializer for peeringdb_server.models.Network
Possible realtionship queries:
- org_id, handled by serializer
- ix_id, handled by prepare_query
- ixlan_id, handled by prepare_query
- netfac_id, handled by prepare_query
- fac_id, handled by prepare_query
### Class Methods
#### prepare_query
`def prepare_query(cls, qset, **kwargs)`
Allows filtering by indirect relationships.
Currently supports: ixlan_id, ix_id, netixlan_id, netfac_id, fac_id
---
### Methods
#### create
`def create(self, validated_data)`
Entities created via the API should go into the verification
queue with status pending if they are in the QUEUE_ENABLED
list.
---
#### finalize_create
`def finalize_create(self, request)`
This will be called on the end of POST request to this serializer.
---
#### to_internal_value
`def to_internal_value(self, data)`
Dict of native values <- Dict of primitive datatypes.
---
## OrganizationSerializer
```
OrganizationSerializer(peeringdb_server.serializers.SpatialSearchMixin, peeringdb_server.serializers.GeocodeSerializerMixin, peeringdb_server.serializers.ModelSerializer)
```
Serializer for peeringdb_server.models.Organization
### Class Methods
#### prepare_query
`def prepare_query(cls, qset, **kwargs)`
Add special filter options
Currently supports:
- asn: filter by network asn
---
## ParentStatusException
```
ParentStatusException(builtins.OSError)
```
Throw this when an object cannot be created because its parent is
either status pending or deleted.
### Methods
#### \__init__
`def __init__(self, parent, typ)`
Initialize self. See help(type(self)) for accurate signature.
---
## RequestAwareListSerializer
```
RequestAwareListSerializer(rest_framework.serializers.ListSerializer)
```
A List serializer that has access to the originating
request.
Used as the list serializer class for all nested lists
so time filters can be applied to the resultset if the _ctf param
is set in the request.
### Instanced Attributes
These attributes / properties will be available on instances of the class
- request (`@property`): Retrieve the request from the root serializer.
### Methods
#### to_representation
`def to_representation(self, data)`
List of object instances -> List of dicts of primitive datatypes.
---
## RequiredForMethodValidator
```
RequiredForMethodValidator(builtins.object)
```
A validator that makes a field required for certain
methods.
### Methods
#### \__call__
`def __call__(self, attrs)`
Call self as a function.
---
#### \__init__
`def __init__(self, field, methods=['POST', 'PUT'], message=None)`
Initialize self. See help(type(self)) for accurate signature.
---
## SaneIntegerField
```
SaneIntegerField(rest_framework.fields.IntegerField)
```
Integer field that renders null values to 0.
### Methods
#### get_attribute
`def get_attribute(self, instance)`
Given the *outgoing* object instance, return the primitive value
that should be used for this field.
---
## SoftRequiredValidator
```
SoftRequiredValidator(builtins.object)
```
A validator that allows us to require that at least
one of the specified fields is set.
### Methods
#### \__call__
`def __call__(self, attrs)`
Call self as a function.
---
#### \__init__
`def __init__(self, fields, message=None)`
Initialize self. See help(type(self)) for accurate signature.
---
## SpatialSearchMixin
```
SpatialSearchMixin(builtins.object)
```
Mixin that enables spatial search for a model
with address fields.
At minimum, a model needs a country and city field, but
address1, address2, zipcode and state are also considered
if they exist.
## UniqueFieldValidator
```
UniqueFieldValidator(builtins.object)
```
For issue #70:
Django-side unique field validation.
Ideally this is done in mysql, however the other
duplicates need to be cleared first, so validate on the django side initially.
### Methods
#### \__call__
`def __call__(self, attrs)`
Call self as a function.
---
#### \__init__
`def __init__(self, fields, message=None, check_deleted=False)`
Initialize self. See help(type(self)) for accurate signature.
---

View File

@@ -0,0 +1,8 @@
Generated from settings.py on 2021-10-15 07:56:57.376975
# peeringdb_server.settings
(Being DEPRECATED) django settings preparation.
This is mostly DEPRECATED at this point and any new settings should be directly
defined in mainsite/settings.

View File

@@ -0,0 +1,85 @@
Generated from signals.py on 2021-10-15 07:56:57.376975
# peeringdb_server.signals
Django signal handlers
- org usergroup creation
- entity count updates (fac_count, net_count etc.)
- geocode when address model (org, fac) is saved
- verification queue creation on new objects
- asn rdap automation to automatically grant org / network to user
- user to org affiliation handling when targeted org has no users
- notify admin-com
- CORS enabling for GET api requests
# Functions
---
## addressmodel_save
`def addressmodel_save(sender, instance=None, **kwargs)`
Mark address model objects for geocode sync if one of the address
fields is updated.
---
## new_user_to_guests
`def new_user_to_guests(request, user, sociallogin=None, **kwargs)`
When a user is created via oauth login put them in the guest
group temporarily.
If pdb_settings.AUTO_VERIFY_USERS is toggled on in the settings, users get automatically verified (Note: this does
not include email verification, they will still need to do that).
---
## org_delete
`def org_delete(sender, instance, **kwargs)`
When an organization is HARD deleted, remove any
usergroups tied to the organization.
---
## org_save
`def org_save(sender, **kwargs)`
Create a user group for an organization when that
organization is created.
---
## uoar_creation
`def uoar_creation(sender, instance, created=False, **kwargs)`
Notify the approporiate management entity when a user to organization affiliation request is created.
Attempt to derive the targeted organization
from the ASN the user provided.
---
## update_counts_for_ixfac
`def update_counts_for_ixfac(ixfac)`
Whenever a ixfac is saved, update the fac_count for the related Exchange
and update ix_count for the related Facility.
---
## update_counts_for_netfac
`def update_counts_for_netfac(netfac)`
Whenever a netfac is saved, update the fac_count for the related Network
and update net_count for the related Facility.
---
## update_counts_for_netixlan
`def update_counts_for_netixlan(netixlan)`
Whenever a netixlan is saved, update the ix_count for the related Network
and update net_count for the related InternetExchange.
---
## update_network_attribute
`def update_network_attribute(instance, attribute)`
Updates 'attribute' field in Network whenever it's called.
---

View File

@@ -0,0 +1,5 @@
Generated from stats.py on 2021-10-15 07:56:57.376975
# peeringdb_server.stats
Load and maintain global stats (displayed in peeringdb footer).

View File

@@ -0,0 +1,5 @@
Generated from urls.py on 2021-10-15 07:56:57.376975
# peeringdb_server.urls
Django url to view routing.

View File

@@ -0,0 +1,46 @@
Generated from util.py on 2021-10-15 07:56:57.376975
# peeringdb_server.util
Assorted utility functions for peeringdb site templates.
# Functions
---
## coerce_ipaddr
`def coerce_ipaddr(value)`
ipaddresses can have multiple formats that are equivalent.
This function will standardize a ipaddress string.
Note: this function is not a validator. If it errors
It will return the original string.
---
# Classes
---
## APIPermissionsApplicator
```
APIPermissionsApplicator(grainy.core.NamespaceKeyApplicator)
```
Applicator that looks for permission namespaces from
a specified field in the dict it is scanning
### Instanced Attributes
These attributes / properties will be available on instances of the class
- is_generating_api_cache (`@property`): None
### Methods
#### \__init__
`def __init__(self, user)`
Initialize self. See help(type(self)) for accurate signature.
---

View File

@@ -0,0 +1,100 @@
Generated from validators.py on 2021-10-15 07:56:57.376975
# peeringdb_server.validators
peeringdb model / field validators
# Functions
---
## validate_address_space
`def validate_address_space(prefix)`
Validate an ip prefix according to peeringdb specs.
Arguments:
- prefix: ipaddress.IPv4Network or an ipaddress.IPv6Network
Raises:
- ValidationError on failed validation
---
## validate_irr_as_set
`def validate_irr_as_set(value)`
Validate irr as-set string.
- the as-set/rs-set name has to conform to RFC 2622 (5.1 and 5.2)
- the source may be specified by AS-SET@SOURCE or SOURCE::AS-SET
- multiple values must be separated by either comma, space or comma followed by space
Arguments:
- value: irr as-set string
Returns:
- str: validated irr as-set string
---
## validate_phonenumber
`def validate_phonenumber(phonenumber, country=None)`
Validate a phonenumber to E.164
Arguments:
- phonenumber (str)
Raises:
- ValidationError if phone number isn't valid E.164 and cannot
be made E.164 valid
Returns:
- str: validated phonenumber
---
## validate_prefix
`def validate_prefix(prefix)`
Validate ip prefix.
Arguments:
- prefix: ipaddress.IPv4Network or an ipaddress.IPv6Network
Raises:
- ValidationError on failed validation
Returns:
- ipaddress.ip_network instance
---
## validate_prefix_overlap
`def validate_prefix_overlap(prefix)`
Validate that a prefix does not overlap with another prefix
on an already existing ixlan.
Arguments:
- prefix: ipaddress.IPv4Network or an ipaddress.IPv6Network
Raises:
- ValidationError on failed validation
---
## validate_zipcode
`def validate_zipcode(zipcode, country)`
Validate a zipcode for a country. If a country has zipcodes, a zipcode
is required. If a country does not have zipcodes, it's not required.
Arguments:
- zipcode (can be Str or None at this point)
- country (two-letter country-code provided in data)
Raises:
- ValidationError if Zipcode is missing from a country WITH
zipcodes
Returns:
- str: zipcode
---

View File

@@ -0,0 +1,292 @@
Generated from views.py on 2021-10-15 07:56:57.376975
# peeringdb_server.views
View definitions:
- Login
- Logout
- Advanced search
- User Profile
- OAuth Profile
- Landing page
- Search results
- Entity views (network, facility, internet exchange and organization)
- Sponsorships
- User Registration
# Functions
---
## beta_sync_dt
`def beta_sync_dt()`
Return the next date for a beta sync.
This is currently hard coded to return 00:00Z for the
next Sunday.
---
## cancel_affiliation_request
`def cancel_affiliation_request(request, *args, **kwargs)`
Cancel a user's affiliation request.
---
## export_permissions
`def export_permissions(user, entity)`
Return dict of permission bools for the specified user and entity
to be used in template context.
---
## field_help
`def field_help(model, field)`
Helper function return help_text of a model
field.
---
## request_api_search
`def request_api_search(request)`
Triggered by typing something in the main peeringdb search bar
without hitting enter (quasi autocomplete).
---
## request_search
`def request_search(request)`
Triggered by hitting enter on the main search bar.
Renders a search result page.
---
## view_about
`def view_about(request)`
Render page containing about.
---
## view_advanced_search
`def view_advanced_search(request)`
View for advanced search.
---
## view_affiliate_to_org
`def view_affiliate_to_org(request, *args, **kwargs)`
Allow the user to request affiliation with an organization through
an ASN they provide.
---
## view_aup
`def view_aup(request)`
Render page containing acceptable use policy.
---
## view_component
`def view_component(request, component, data, title, perms=None, instance=None, **kwargs)`
Generic component view.
---
## view_exchange
`def view_exchange(request, id)`
View exchange data for exchange specified by id.
---
## view_facility
`def view_facility(request, id)`
View facility data for facility specified by id.
---
## view_index
`def view_index(request, errors=None)`
Landing page view.
---
## view_network
`def view_network(request, id)`
View network data for network specified by id.
---
## view_organization
`def view_organization(request, id)`
View organization data for org specified by id.
---
## view_partnerships
`def view_partnerships(request)`
View current partners.
---
## view_password_reset
`def view_password_reset(request, *args, **kwargs)`
Password reset initiation view.
---
## view_registration
`def view_registration(request, *args, **kwargs)`
User registration page view.
---
## view_request_ownership
`def view_request_ownership(request, *args, **kw)`
Render the form that allows users to request ownership
to an unclaimed organization.
---
## view_simple_content
`def view_simple_content(request, content_name)`
Render the content in templates/{{ content_name }} inside
the peeringdb layout.
---
## view_sponsorships
`def view_sponsorships(request)`
View current sponsorships.
---
## view_username_retrieve
`def view_username_retrieve(request, *args, **kwargs)`
Username retrieval view.
---
## view_username_retrieve_complete
`def view_username_retrieve_complete(request, *args, **kwargs)`
Username retrieval completion view.
Show the list of usernames associated to an email if
the correct secret is provided.
---
## view_username_retrieve_initiate
`def view_username_retrieve_initiate(request, *args, **kwargs)`
Username retrieval initiate view.
---
# Classes
---
## DoNotRender
```
DoNotRender(builtins.object)
```
Instance of this class is sent when a component attribute does not exist,
this can then be type checked in the templates to remove non existant attribute
rows while still allowing attributes with nonetype values to be rendered.
### Class Methods
#### permissioned
`def permissioned(cls, value, user, namespace, explicit=False)`
Check if the user has permissions to the supplied namespace
returns a DoNotRender instance if not, otherwise returns
the supplied value.
---
## LoginView
```
LoginView(two_factor.views.core.LoginView)
```
Extend the `LoginView` class provided
by `two_factor` because some
PDB specific functionality and checks need to be added.
### Methods
#### done
`def done(self, form_list, **kwargs)`
User authenticated successfully, set language options.
---
#### get
`def get(self, *args, **kwargs)`
If a user is already authenticated, don't show the
login process, instead redirect to /
---
#### get_context_data
`def get_context_data(self, form, **kwargs)`
If post request was rate limited the rate limit message
needs to be communicated via the template context.
---
#### get_device
`def get_device(self, step=None)`
Override this to can enable EmailDevice as a
challenge device for one time passwords.
---
#### get_email_device
`def get_email_device(self)`
Return an EmailDevice instance for the requesting user
which can be used for one time passwords.
---
#### get_redirect_url
`def get_redirect_url(self)`
Specify which redirect urls are valid.
---
#### post
`def post(self, *args, **kwargs)`
Posts to the `auth` step of the authentication
process need to be rate limited.
---
## OrganizationLogoUpload
```
OrganizationLogoUpload(django.views.generic.base.View)
```
Handles public upload and setting of organization logo (#346)
### Methods
#### delete
`def delete(self, request, id)`
delete the logo
---
#### post
`def post(self, request, id)`
upload and set a new logo
---