univention.admin.rest package

Contents

univention.admin.rest package#

Subpackages#

Submodules#

univention.admin.rest.async_client module#

Sample asynchronous client for the UDM REST API.

>>> import asyncio
>>> from univention.admin.rest.async_client import UDM
>>>
>>> uri = 'http://localhost/univention/udm/'
>>> async def main():
>>>     async with UDM.http(uri, 'Administrator', 'univention') as udm:
>>>         module = await udm.get('users/user')
>>>         print(f'Found {module}')
>>>         objs = module.search()
>>>         async for obj in objs:
>>>             if not obj:
>>>                 continue
>>>             obj = await obj.open()
>>>             print(f'Object {obj}')
>>>             for group in obj.objects.groups:
>>>                 grp = await group.open()
>>>                 print(f'Group {grp}')
>>>
>>> asyncio.run(main())
exception univention.admin.rest.async_client.HTTPError(code: int, message: str, response: ClientResponse | None, error_details: dict | None = None)[source]#

Bases: Exception

code#
response#
error_details#
exception univention.admin.rest.async_client.BadRequest(code: int, message: str, response: ClientResponse | None, error_details: dict | None = None)[source]#

Bases: HTTPError

code#
error_details#
response#
exception univention.admin.rest.async_client.Unauthorized(code: int, message: str, response: ClientResponse | None, error_details: dict | None = None)[source]#

Bases: HTTPError

code#
error_details#
response#
exception univention.admin.rest.async_client.Forbidden(code: int, message: str, response: ClientResponse | None, error_details: dict | None = None)[source]#

Bases: HTTPError

code#
error_details#
response#
exception univention.admin.rest.async_client.NotFound(code: int, message: str, response: ClientResponse | None, error_details: dict | None = None)[source]#

Bases: HTTPError

code#
error_details#
response#
exception univention.admin.rest.async_client.PreconditionFailed(code: int, message: str, response: ClientResponse | None, error_details: dict | None = None)[source]#

Bases: HTTPError

code#
error_details#
response#
exception univention.admin.rest.async_client.UnprocessableEntity(code: int, message: str, response: ClientResponse | None, error_details: dict | None = None)[source]#

Bases: HTTPError

code#
error_details#
response#
exception univention.admin.rest.async_client.ServerError(code: int, message: str, response: ClientResponse | None, error_details: dict | None = None)[source]#

Bases: HTTPError

code#
error_details#
response#
exception univention.admin.rest.async_client.ServiceUnavailable(code: int, message: str, response: ClientResponse | None, error_details: dict | None = None)[source]#

Bases: HTTPError

code#
error_details#
response#
exception univention.admin.rest.async_client.ConnectionError[source]#

Bases: Exception

exception univention.admin.rest.async_client.UnexpectedResponse[source]#

Bases: ConnectionError

class univention.admin.rest.async_client.Response(response: ClientResponse, data: Any, uri: str)[source]#

Bases: object

response#
data#
uri#
class univention.admin.rest.async_client.Session(credentials: UDM, language: str = 'en-US', reconnect: bool = True, user_agent: str = 'univention.lib/1.0', enable_caching: bool = False, concurrency_limit: int = 10)[source]#

Bases: object

language#
credentials#
reconnect#
user_agent#
enable_caching#
default_headers#
session#
create_session(concurrency_limit: int = 10) ClientSession[source]#
get_method(method: str) Callable[..., aiohttp.ClientResponse][source]#
async request(method: str, uri: str, data: dict | None = None, expect_json: bool = False, **headers: str) Any[source]#
async make_request(method: str, uri: str, data: dict | None = None, expect_json: bool = False, allow_redirects: bool = True, custom_redirect_handling: bool = False, **headers: str) Response[source]#
async eval_response(response: ClientResponse, expect_json: bool = False) Any[source]#
get_relations(entry: dict, relation: str, name: str | None = None, template: dict[str, Any] | None = None) Iterator[dict[str, str]][source]#
get_relation(entry: dict, relation: str, name: str | None = None, template: dict[str, Any] | None = None) dict[str, str][source]#
async resolve_relations(entry: dict, relation: str, name: str | None = None, template: dict[str, Any] | None = None) AsyncIterator[Any][source]#
async resolve_relation(entry: dict, relation: str, name: str | None = None, template: dict[str, Any] | None = None) Any[source]#
class univention.admin.rest.async_client.Client(client: Session)[source]#

Bases: object

client#
class univention.admin.rest.async_client.UDM(uri: str, username: str | None, password: str | None, *args: Any, **kwargs: Any)[source]#

Bases: Client

classmethod http(uri: str, username: str, password: str) UDM[source]#
classmethod bearer(uri: str, bearer_token: str) UDM[source]#
uri#
username#
password#
bearer_token#
entry: dict | Any | None#
async load() None[source]#
async reload() None[source]#
async get_ldap_base() str | None[source]#
async modules(name: str | None = None) AsyncIterator[Module][source]#
async obj_by_dn(dn: str) Object[source]#
async obj_by_uuid(uuid: str) Object[source]#
async get(name: str) Module | None[source]#
async get_object(object_type: str, dn: str) Object | None[source]#
class univention.admin.rest.async_client.Module(udm: UDM, uri: str, name: str, title: str, *args: Any, **kwargs: Any)[source]#

Bases: Client

udm#
uri#
username#
password#
name#
title#
relations: dict#
async load_relations() None[source]#
async new(position: str | None = None, superordinate: str | None = None, template: dict[str, Any] | None = None) Object[source]#
async get(dn: str, properties: list[str] | None = None) Object | None[source]#
async get_by_entry_uuid(uuid: str, properties: list[str] | None = None) Object | None[source]#
async get_by_id(dn: str, properties: list[str] | None = None) Object | None[source]#
async search(filter: dict[str, str] | str | bytes | None = None, position: str | None = None, scope: str | None = 'sub', hidden: bool = False, superordinate: str | None = None, opened: bool = False, properties: list[str] | None = None) AsyncIterator[Any][source]#
async get_layout() Any | None[source]#
async get_properties() Any | None[source]#
async get_property_choices(property: str) Any | None[source]#
async policy_result(policy_module: str, position: str, policy: str | None = None) dict[source]#
async get_report_types() list[str][source]#
async create_report(report_type: str, object_dns: list[str]) Any[source]#
class univention.admin.rest.async_client.ShallowObject(udm: UDM, dn: str | None, uri: str, *args: Any, **kwargs: Any)[source]#

Bases: Client

dn#
udm#
uri#
async open() Object[source]#
class univention.admin.rest.async_client.References(obj: Object | None = None)[source]#

Bases: object

obj#
udm#
class univention.admin.rest.async_client.Object(udm: UDM, representation: dict, etag: str | None = None, last_modified: str | None = None, *args: Any, **kwargs: Any)[source]#

Bases: Client

property module#
property object_type: str#
property dn: str | None#
property properties#
property options: dict#
property policies: dict#
property superordinate: str | None#
property position: str | None#
property uri: str | None#
classmethod from_response(udm: UDM, response: Response) Object[source]#
classmethod from_data(udm: UDM, entry: dict, headers: Mapping[str, str] | None = None) Object[source]#
udm#
representation#
hal#
etag#
last_modified#
async reload() None[source]#
async save(reload: bool = True) Response[source]#
async json_patch(patch: dict, reload: bool = True) Response[source]#
async delete(remove_referring: bool = False) bytes[source]#
async restore(reload: bool = True) Response[source]#

Restore an object from the recyclebin.

async move(position: str, reload: bool = True) None[source]#
async generate_service_specific_password(service: str) Any | None[source]#
async get_layout() Any | None[source]#
async get_properties() Any | None[source]#
async get_property_choices(property: str) Any | None[source]#
async policy_result(policy_module: str, policy: str | None = None) dict[source]#
class univention.admin.rest.async_client.PatchDocument[source]#

Bases: object

application/json-patch+json representation

patch#
add(path_segments, value)[source]#
replace(path_segments, value)[source]#
remove(path_segments, value)[source]#
move(path_segments, from_segments)[source]#
copy(path_segments, from_segments)[source]#
test(path_segments, value)[source]#
expand_path(path_segments)[source]#

univention.admin.rest.hal module#

class univention.admin.rest.hal.HAL[source]#

Bases: object

content_negotiation_hal_json(response, data)[source]#
get_hal_json(response)[source]#
add_resource(obj, relation, ressource)[source]#
get_resource(obj, relation, **query)[source]#
get_resources(obj, relation)[source]#

univention.admin.rest.html_ui module#

class univention.admin.rest.html_ui.HTML[source]#

Bases: object

property head_template#
template_vars()[source]#
content_negotiation_html(response, data)[source]#
get_html(response: dict)[source]#
get_error_html(response: dict)[source]#
get_html_layout(root, response, layout, properties)[source]#
render_layout(layout, fieldset, properties, response)[source]#
get_html_form(_form, response)[source]#
render_form_field(parent_element, field)[source]#
get_html_button(_button, response)[source]#
add_form(obj, action, method, **kwargs)[source]#
add_form_element(form, name, value, type='text', element='input', **kwargs)[source]#
add_button(obj, action, method, **kwargs)[source]#
add_layout(obj, layout, name=None, href=None)[source]#
classmethod sanitize_html_id(label)[source]#
bread_crumbs_navigation()[source]#
render_template(template_path, data)[source]#

univention.admin.rest.http_conditional module#

univention.admin.rest.http_conditional.last_modified(date)[source]#
class univention.admin.rest.http_conditional.ConditionalResource[source]#

Bases: object

set_entity_tags(obj, check_conditionals=True, remove_after_check=False)[source]#
get_etag(obj)[source]#
modified_from_timestamp(timestamp)[source]#
check_conditional_requests()[source]#
check_conditional_request_modified_since(last_modified)[source]#
check_conditional_request_unmodified_since(last_modified)[source]#
check_conditional_request_etag(etag)[source]#

univention.admin.rest.ldap_connection module#

univention.admin.rest.ldap_connection.get_user_ldap_write_connection(auth_type, binddn, bindpw)[source]#
univention.admin.rest.ldap_connection.get_user_ldap_read_connection(auth_type, binddn, bindpw)[source]#
univention.admin.rest.ldap_connection.get_machine_ldap_write_connection()[source]#
univention.admin.rest.ldap_connection.get_machine_ldap_read_connection()[source]#
univention.admin.rest.ldap_connection.get_admin_ldap_write_connection()[source]#
univention.admin.rest.ldap_connection.get_admin_ldap_read_connection()[source]#
univention.admin.rest.ldap_connection.get_ldap_connection(type_, auth_type, binddn, bindpw)[source]#

univention.admin.rest.module module#

class univention.admin.rest.module.ResourceBase[source]#

Bases: SanitizerBase, HAL, HTML

Abstract base class for all HTTP resources

pool = <concurrent.futures.thread.ThreadPoolExecutor object>#
pool_submit(cb, *args, **kwargs)[source]#
pool_wrapper(func, *a, **kw)[source]#
requires_authentication = True#
property debug_mode_enabled#
force_authorization(auth_type=None, error_information=None)[source]#
set_default_headers()[source]#
prepare()[source]#
parse_authorization(authorization)[source]#
property ldap_write_connection#
get_module(object_type, ldap_connection=None)[source]#
get_module_object(object_type, dn, ldap_connection=None)[source]#
get_object_by_dn(dn, ldap_connection=None)[source]#
get_object(object_type, dn, ldap_connection=None)[source]#
check_acceptable()[source]#
decode_request_arguments()[source]#
decode_form_arguments()[source]#
get_body_argument(name, *args)[source]#
get_body_arguments(name, *args)[source]#
content_negotiation(response)[source]#
content_negotiation_json(response, data)[source]#
get_json(response)[source]#
urljoin(*args, **query)[source]#
abspath(*args)[source]#
log_exception(typ, value, tb)[source]#
write_error(status_code, exc_info=None, **kwargs)[source]#
add_caching(expires=None, public=False, must_revalidate=False, no_cache=False, no_store=False, no_transform=False, max_age=None, shared_max_age=None, proxy_revalidate=False)[source]#
vary()[source]#
get_parent_object_type(module)[source]#
class univention.admin.rest.module.Resource(application: Application, request: HTTPServerRequest, **kwargs: Any)[source]#

Bases: ResourceBase, RequestHandler

Base class for all HTTP resources

options(*args, **kwargs)[source]#

Display API descriptions.

get_openapi_schema(object_type=None)[source]#
options_json(response)[source]#
handle_udm_errors(action, *args, **kwargs)[source]#
class univention.admin.rest.module.Nothing(application: Application, request: HTTPServerRequest, **kwargs: Any)[source]#

Bases: Resource

404 error page

prepare(*args, **kwargs)[source]#

Called at the beginning of a request before get/post/etc.

Override this method to perform common initialization regardless of the request method.

Asynchronous support: Use async def or decorate this method with .gen.coroutine to make it asynchronous. If this method returns an Awaitable execution will not proceed until the Awaitable is done.

Added in version 3.1: Asynchronous support.

class univention.admin.rest.module.Favicon(application: Application, request: HTTPServerRequest, **kwargs: Any)[source]#

Bases: ResourceBase, StaticFileHandler

Get a 16*16px PNG representation of a UDM module

classmethod get_absolute_path(root, object_type='')[source]#

Returns the absolute location of path relative to root.

root is the path configured for this StaticFileHandler (in most cases the static_path Application setting).

This class method may be overridden in subclasses. By default it returns a filesystem path, but other strings may be used as long as they are unique and understood by the subclass’s overridden get_content.

Added in version 3.1.

class univention.admin.rest.module.Relations(application: Application, request: HTTPServerRequest, **kwargs: Any)[source]#

Bases: RelationsBase, Resource

List all used Link relations

class univention.admin.rest.module.OpenAPI(application: Application, request: HTTPServerRequest, **kwargs: Any)[source]#

Bases: OpenAPIBase, Resource

JSON-Endpoint to get the openapi.json schema definition

class univention.admin.rest.module.Modules(application: Application, request: HTTPServerRequest, **kwargs: Any)[source]#

Bases: Resource

mapping = {'appcenter': 'appcenter/app', 'computers': 'computers/computer', 'contacts': 'users/contact', 'container': 'container', 'dhcp': 'dhcp/dhcp', 'dns': 'dns/dns', 'groups': 'groups/group', 'kerberos': 'kerberos/kdcentry', 'mail': 'mail/mail', 'nagios': 'nagios/nagios', 'navigation': 'object', 'networks': 'networks/network', 'policies': 'policies/policy', 'portal': 'portals/all', 'printers': 'shares/print', 'saml': 'saml/serviceprovider', 'self': 'users/self', 'settings': 'settings/settings', 'shares': 'shares/share', 'users': 'users/user'}#
get()[source]#
bread_crumbs_navigation()[source]#
class univention.admin.rest.module.Directory(application: Application, request: HTTPServerRequest, **kwargs: Any)[source]#

Bases: Resource

LDAP directory tree

get_template = 'directory.html'#
async get(container: str | None = <univention.admin.rest.sanitizer.Query object>, object_type: str | None = <univention.admin.rest.sanitizer.Query object>)[source]#
get_html(response)[source]#
class univention.admin.rest.module.ObjectTypes(application: Application, request: HTTPServerRequest, **kwargs: Any)[source]#

Bases: Resource

Get the object types of a specific flavor

async get(module_type, superordinate: str | None = <univention.admin.rest.sanitizer.Query object>)[source]#
class univention.admin.rest.module.SubObjectTypes(application: Application, request: HTTPServerRequest, **kwargs: Any)[source]#

Bases: Resource

A list of possible sub-object-types which can be created underneath of the specified container or superordinate.

get_template = 'children_types.html'#
template_vars()[source]#
get(object_type=None, position=None)[source]#

Returns the list of object types matching the given flavor or container.

requests.options = {}

‘superordinate’ – if available only types for the given superordinate are returned (not for the navigation) ‘container’ – if available only types suitable for the given container are returned (only for the navigation)

module_definition(modules)[source]#
class univention.admin.rest.module.LdapBase(application: Application, request: HTTPServerRequest, **kwargs: Any)[source]#

Bases: Resource

Redirect to the ldap base object

get()[source]#
class univention.admin.rest.module.LdapAttributeUnmap(application: Application, request: HTTPServerRequest, **kwargs: Any)[source]#

Bases: Resource

Transform Base64 encoded LDAP attributes to a UDM object that fits. Object does not have to exist.

async post(representation: dict = <univention.admin.rest.sanitizer.JSONPayload object>)[source]#

Bases: Resource

If the object-type is not known but only the DN, this resource redirects to the correct object.

get(dn)[source]#
class univention.admin.rest.module.ObjectByUiid(application: Application, request: HTTPServerRequest, **kwargs: Any)[source]#

Bases: ObjectLink

Redirect to the object specified by its LDAP Entry-UUID

get(uuid)[source]#
class univention.admin.rest.module.ContainerQueryBase(application: Application, request: HTTPServerRequest, **kwargs: Any)[source]#

Bases: Resource

Base class for queries to container structures, needed to build a tree representation

get_template = 'tree.html'#
template_vars()[source]#
class univention.admin.rest.module.Tree(application: Application, request: HTTPServerRequest, **kwargs: Any)[source]#

Bases: ContainerQueryBase

Get a LDAP directory tree representation of a UDM module supporting tree-views (e.g. directory/DNS/DHCP) (GET udm/(dns/dns|dhcp/dhcp|directory)/tree/)

async get(object_type, container: str = <univention.admin.rest.sanitizer.Query object>, level: str = <univention.admin.rest.sanitizer.Query object>)[source]#
class univention.admin.rest.module.MoveDestinations(application: Application, request: HTTPServerRequest, **kwargs: Any)[source]#

Bases: ContainerQueryBase

Get the locations where a specified UDM module can be moved to

async get(object_type, container: str = <univention.admin.rest.sanitizer.Query object>)[source]#
class univention.admin.rest.module.Properties(application: Application, request: HTTPServerRequest, **kwargs: Any)[source]#

Bases: Resource

Get the properties of a UDM module or UDM object (GET udm/users/user/properties)

async get(object_type, dn=None, searchable: bool = <univention.admin.rest.sanitizer.Query object>)[source]#
classmethod get_properties(module, dn=None)[source]#
class univention.admin.rest.module.Layout(application: Application, request: HTTPServerRequest, **kwargs: Any)[source]#

Bases: Resource

Get the layout representation of a UDM module

get(object_type, dn=None)[source]#
classmethod get_layout(module, dn=None)[source]#
classmethod get_apps_layout(layout)[source]#
classmethod get_reference_layout(layout)[source]#
class univention.admin.rest.module.ReportingBase[source]#

Bases: object

Base class for UDM object report operations

initialize()[source]#
class univention.admin.rest.module.Report(application: Application, request: HTTPServerRequest, **kwargs: Any)[source]#

Bases: ReportingBase, Resource

Create a object report e.g. in CSV of PDF format (GET udm/users/user/report/$report_type?dn=…&dn=…)

async get(object_type, report_type)[source]#
async post(object_type, report_type, dn: list[str] = <univention.admin.rest.sanitizer.Query object>)[source]#
async create_report(object_type, report_type, dns)[source]#
class univention.admin.rest.module.NextFreeIpAddress(application: Application, request: HTTPServerRequest, **kwargs: Any)[source]#

Bases: Resource

Get the next free IP of the specified network (GET udm/networks/network/$DN/next-free-ip-address)

get(object_type, dn)[source]#

Returns the next IP configuration based on the given network object

‘increaseCounter’ – if given and set to True, network object counter for IP addresses is increased

class univention.admin.rest.module.FormBase[source]#

Bases: object

Base class for form elements

add_property_form_elements(module, form, properties, values)[source]#
decode_form_arguments()[source]#
superordinate_dn_to_object(module, superordinate)[source]#
class univention.admin.rest.module.Objects(application: Application, request: HTTPServerRequest, **kwargs: Any)[source]#

Bases: ConditionalResource, FormBase, ReportingBase, _OpenAPIBase, Resource

Search for objects

get_template = 'search_form.html'#
async get(object_type: str, position: str = <univention.admin.rest.sanitizer.Query object>, ldap_filter: str = <univention.admin.rest.sanitizer.Query object>, query: dict = <univention.admin.rest.sanitizer.Query object>, property: str = <univention.admin.rest.sanitizer.Query object>, scope: str = <univention.admin.rest.sanitizer.Query object>, hidden: bool = <univention.admin.rest.sanitizer.Query object>, opened: bool = <univention.admin.rest.sanitizer.Query object>, properties: list[str] = <univention.admin.rest.sanitizer.Query object>, superordinate: str | None = <univention.admin.rest.sanitizer.Query object>, dir: str = <univention.admin.rest.sanitizer.Query object>, by: str = <univention.admin.rest.sanitizer.Query object>, page: int = <univention.admin.rest.sanitizer.Query object>, limit: int = <univention.admin.rest.sanitizer.Query object>)[source]#

Search for {module.object_name_plural} objects

async search(module, container, ldap_filter, superordinate, scope, hidden, items_per_page, page, by, reverse, opened)[source]#
get_html(response)[source]#
async post(object_type, representation: dict = <univention.admin.rest.sanitizer.JSONPayload object>, patch_document: list = <univention.admin.rest.sanitizer.PatchRepresentation object>)[source]#

Create a new {module.object_name} object

options_html(response)[source]#
class univention.admin.rest.module.ObjectsMove(application: Application, request: HTTPServerRequest, **kwargs: Any)[source]#

Bases: Resource

Move multiple objects at the same time

async post(object_type, position: str = <univention.admin.rest.sanitizer.Body object>, dn: list[str] = <univention.admin.rest.sanitizer.Body object>)[source]#
class univention.admin.rest.module.Object(application: Application, request: HTTPServerRequest, **kwargs: Any)[source]#

Bases: ConditionalResource, FormBase, _OpenAPIBase, Resource

Get, modify, create, remove, rename or move an UDM object

async get(object_type: str, dn: str, properties: list[str] = <univention.admin.rest.sanitizer.Query object>, copy: bool = <univention.admin.rest.sanitizer.Query object>)[source]#

Get a representation of the {module.object_name} object with all its properties, policies, options, metadata and references. Includes also instructions how to modify, remove or move the object.

classmethod get_representation(module, obj, properties, ldap_connection, copy=False, add=False, opened=True)[source]#
async put(object_type, dn, representation: dict = <univention.admin.rest.sanitizer.JSONPayload object>, patch_document: list = <univention.admin.rest.sanitizer.PatchRepresentation object>)[source]#

Modify or move an {module.object_name} object

async patch(object_type, dn, representation: dict = <univention.admin.rest.sanitizer.JSONPayload object>, patch_document: list = <univention.admin.rest.sanitizer.PatchRepresentation object>)[source]#

Modify an {module.object_name} object (moving is currently not possible)

async create(object_type, dn=None, representation=None, result=None, **kwargs)[source]#
async modify(module, obj, representation, result, **kwargs)[source]#
set_properties(module, obj, representation, result)[source]#
set_property(obj, property_name, value, result, multi_error, password_properties)[source]#
set_patch_properties(module, obj, patch_document, result)[source]#
set_patch_property(module, obj, op, property_name, value, result, multi_error)[source]#
async move(module, dn, position)[source]#
async delete(object_type, dn, cleanup: bool = <univention.admin.rest.sanitizer.Query object>, recursive: bool = <univention.admin.rest.sanitizer.Query object>)[source]#

Remove a {module.object_name_plural} object

class univention.admin.rest.module.ObjectRestore(application: Application, request: HTTPServerRequest, **kwargs: Any)[source]#

Bases: Resource

Restore an object from the recyclebin

async post(object_type, dn)[source]#

Restore a {module.object_name_plural} object from the recyclebin

class univention.admin.rest.module.UserPhoto(application: Application, request: HTTPServerRequest, **kwargs: Any)[source]#

Bases: ConditionalResource, Resource

Get a (cacheable) user profile picture in JPEG format

async get(object_type, dn)[source]#
async post(object_type, dn)[source]#
class univention.admin.rest.module.ObjectAdd(application: Application, request: HTTPServerRequest, **kwargs: Any)[source]#

Bases: FormBase, _OpenAPIBase, Resource

GET a form containing information about all properties, methods, URLs to create a specific object

async get(object_type, position: str = <univention.admin.rest.sanitizer.Query object>, superordinate: str = <univention.admin.rest.sanitizer.Query object>, template: str = <univention.admin.rest.sanitizer.Query object>)[source]#

Get a template for creating an {module.object_name} object (contains all properties and their default values)

get_create_form(module, dn=None, copy=False, template=None, position=None, superordinate=None)[source]#
get_html(response)[source]#
class univention.admin.rest.module.ObjectCopy(application: Application, request: HTTPServerRequest, **kwargs: Any)[source]#

Bases: ObjectAdd

Copy an object

async get(object_type, dn: str = <univention.admin.rest.sanitizer.Query object>)[source]#

Get a template for creating an {module.object_name} object (contains all properties and their default values)

class univention.admin.rest.module.ObjectEdit(application: Application, request: HTTPServerRequest, **kwargs: Any)[source]#

Bases: FormBase, Resource

GET a form containing ways to modify, remove, move a specific object

async get(object_type, dn)[source]#
get_html(response)[source]#
class univention.admin.rest.module.ObjectMultiEdit(application: Application, request: HTTPServerRequest, **kwargs: Any)[source]#

Bases: ObjectEdit

Modify multiple objects at the same time

class univention.admin.rest.module.DefaultContainers(application: Application, request: HTTPServerRequest, **kwargs: Any)[source]#

Bases: Resource

Get list of default containers. GET udm/users/user/default-containers

get_template = 'default_containers.html'#
template_vars()[source]#
async get(object_type)[source]#
class univention.admin.rest.module.PropertyChoices(application: Application, request: HTTPServerRequest, **kwargs: Any)[source]#

Bases: Resource

Get possible values/choices for the specified property. GET udm/users/user/$DN/properties/$name/choices

get_template = 'property_choices.html'#
template_vars()[source]#
async get(object_type, dn, property_, dn_: str = <univention.admin.rest.sanitizer.Query object>, property: str = <univention.admin.rest.sanitizer.Query object>, value: str = <univention.admin.rest.sanitizer.Query object>, hidden: bool = <univention.admin.rest.sanitizer.Query object>, dependencies: str = <univention.admin.rest.sanitizer.Query object>)[source]#
class univention.admin.rest.module.PolicyResultBase(application: Application, request: HTTPServerRequest, **kwargs: Any)[source]#

Bases: Resource

Get the possible policies of the policy-type for user objects located at the container

class univention.admin.rest.module.PolicyResult(application: Application, request: HTTPServerRequest, **kwargs: Any)[source]#

Bases: PolicyResultBase

Get the possible policies of the policy-type for user objects located at the container. GET udm/users/user/$userdn/policies/$policy_type/?policy=$dn (for a existing object)

async get(object_type, dn, policy_type, policy: str = <univention.admin.rest.sanitizer.Query object>)[source]#
class univention.admin.rest.module.PolicyResultContainer(application: Application, request: HTTPServerRequest, **kwargs: Any)[source]#

Bases: PolicyResultBase

Get the possible policies of the policy-type for user objects located at the container. GET udm/users/user/policies/$policy_type/?policy=$dn&position=$dn (for a container, where a object should be created in)

async get(object_type, policy_type, policy: str = <univention.admin.rest.sanitizer.Query object>, position: str = <univention.admin.rest.sanitizer.Query object>)[source]#
class univention.admin.rest.module.Operations(application: Application, request: HTTPServerRequest, **kwargs: Any)[source]#

Bases: Resource

GET /udm/progress/$progress-id (get the progress of a started operation like move, report, maybe add/put?, …)

check_acceptable()[source]#
get(progress)[source]#
get_html(response)[source]#
class univention.admin.rest.module.LicenseRequest(application: Application, request: HTTPServerRequest, **kwargs: Any)[source]#

Bases: Resource

Request a new license from the Univention license server

async get(email: str = <univention.admin.rest.sanitizer.Query object>)[source]#
class univention.admin.rest.module.LicenseCheck(application: Application, request: HTTPServerRequest, **kwargs: Any)[source]#

Bases: Resource

Check if the license has exceeded or is still valid

get()[source]#
class univention.admin.rest.module.License(application: Application, request: HTTPServerRequest, **kwargs: Any)[source]#

Bases: Resource

Get information about the license

get()[source]#
class univention.admin.rest.module.LicenseImport(application: Application, request: HTTPServerRequest, **kwargs: Any)[source]#

Bases: Resource

Import a new license

async get(license: str = <univention.admin.rest.sanitizer.Query object>)[source]#
post()[source]#
import_license(fd)[source]#
class univention.admin.rest.module.ServiceSpecificPassword(application: Application, request: HTTPServerRequest, **kwargs: Any)[source]#

Bases: Resource

Let a new autogenerated service specific password be created

async post(object_type, dn, service: str = <univention.admin.rest.sanitizer.Body object>)[source]#
class univention.admin.rest.module.Application(**settings)[source]#

Bases: Application

The main tornado application

multi_regex(chars)[source]#
reload()[source]#

univention.admin.rest.openapi module#

class univention.admin.rest.openapi.RelationsBase[source]#

Bases: object

get(relation)[source]#
class univention.admin.rest.openapi.OpenAPIBase[source]#

Bases: _OpenAPIBase

requires_authentication = True#
check_acceptable()[source]#
prepare()[source]#
get(object_type=None)[source]#
get_json(response)[source]#

univention.admin.rest.sanitizer module#

class univention.admin.rest.sanitizer.Param(sanitizer, alias=None, description=None, deprecated=None, example=None, examples=None, style=None, explode=None)[source]#

Bases: object

class univention.admin.rest.sanitizer.Path(sanitizer, alias=None, description=None, deprecated=None, example=None, examples=None, style=None, explode=None)[source]#

Bases: Param

class univention.admin.rest.sanitizer.Body(sanitizer, content_type='application/json', **kwargs)[source]#

Bases: Param

class univention.admin.rest.sanitizer.Query(sanitizer, alias=None, description=None, deprecated=None, example=None, examples=None, style=None, explode=None)[source]#

Bases: Param

class univention.admin.rest.sanitizer.Payload(content_type, sanitizer=None)[source]#

Bases: object

make_sanitizer(body_params)[source]#
class univention.admin.rest.sanitizer.JSONPayload(**kwargs)[source]#

Bases: Payload

make_sanitizer(body_params)[source]#
class univention.admin.rest.sanitizer.Base64EncodingSanitizer(**kwargs)[source]#

Bases: Sanitizer

class univention.admin.rest.sanitizer.PatchDocument(cls=None, **kwargs)[source]#

Bases: Payload

class univention.admin.rest.sanitizer.PatchRepresentation(**kwargs)[source]#

Bases: PatchDocument

univention.admin.rest.sanitizer.sanitize(method)[source]#
class univention.admin.rest.sanitizer.PatchDocumentSanitizer(*args, **kwargs)[source]#

Bases: ListSanitizer

parse_patch_document(value, name)[source]#
class univention.admin.rest.sanitizer.PatchRepresentationSanitizer(*args, **kwargs)[source]#

Bases: PatchDocumentSanitizer

class univention.admin.rest.sanitizer.DictSanitizer(sanitizers, allow_other_keys=True, **kwargs)[source]#

Bases: DictSanitizer

class univention.admin.rest.sanitizer.QueryStringSanitizer(sanitizers, allow_other_keys=True, **kwargs)[source]#

Bases: DictSanitizer

class univention.admin.rest.sanitizer.ObjectPropertySanitizer(**kwargs)[source]#

Bases: StringSanitizer

A LDAP attribute name. must at least be 1 character long.

This sanitizer prevents LDAP search filter injections in the attribute name.

TODO: in theory we should only allow existing searchable properties for the requested object type

class univention.admin.rest.sanitizer.PropertiesSanitizer(*args, **kwargs)[source]#

Bases: DictSanitizer

sanitize(properties, module, obj)[source]#

Sanitize function. Internally calls _sanitize with the correct values and returns the new value (together with a flag indicating whether the value was found at all). If you write your own Sanitize class, you probably want to override _sanitize().

_sanitize(value, name, further_arguments)#

The method where the actual sanitizing takes place.

The standard method just returns value so be sure to override this method in your Sanitize class.

Parameters:
  • value (Any) – the value as found in request.options.

  • name (str) – the name of the argument currently sanitized.

  • further_arguments (dict[str, Any]) – dictionary holding the values of those additional arguments in request.options that are needed for sanitizing. the arguments come straight from the not altered options dict (i.e. before potentially changing sanitizing happened).

class univention.admin.rest.sanitizer.PropertySanitizer(*args, **kwargs)[source]#

Bases: Sanitizer

class univention.admin.rest.sanitizer.BoolSanitizer(**kwargs)[source]#

Bases: ChoicesSanitizer

class univention.admin.rest.sanitizer.LDAPFilterSanitizer(regex_pattern: Pattern[str] | str | None = None, re_flags: int = 0, minimum: int | None = None, maximum: int | None = None, **kwargs: Any)[source]#

Bases: StringSanitizer

class univention.admin.rest.sanitizer.DNSanitizer(**kwargs)[source]#

Bases: DNSanitizer

base = [[('dc', 'example', 1)], [('dc', 'org', 1)]]#
baselen = 2#
base_internal = [[('cn', 'internal', 1)]]#
base_internal_len = 1#
class univention.admin.rest.sanitizer.SanitizerBase[source]#

Bases: object

sanitize_arguments(sanitizer, *args, **kwargs)[source]#
raise_sanitization_errors(errors)[source]#
raise_sanitization_multi_error(multi_error, field='properties', type='body')[source]#
raise_sanitization_error(field, message, type='body')[source]#

univention.admin.rest.shared_memory module#

class univention.admin.rest.shared_memory.JsonEncoder(*, skipkeys=False, ensure_ascii=True, check_circular=True, allow_nan=True, sort_keys=False, indent=None, separators=None, default=None)[source]#

Bases: JSONEncoder

Constructor for JSONEncoder, with sensible defaults.

If skipkeys is false, then it is a TypeError to attempt encoding of keys that are not str, int, float or None. If skipkeys is True, such items are simply skipped.

If ensure_ascii is true, the output is guaranteed to be str objects with all incoming non-ASCII characters escaped. If ensure_ascii is false, the output can contain non-ASCII characters.

If check_circular is true, then lists, dicts, and custom encoded objects will be checked for circular references during encoding to prevent an infinite recursion (which would cause an RecursionError). Otherwise, no such check takes place.

If allow_nan is true, then NaN, Infinity, and -Infinity will be encoded as such. This behavior is not JSON specification compliant, but is consistent with most JavaScript based encoders and decoders. Otherwise, it will be a ValueError to encode such floats.

If sort_keys is true, then the output of dictionaries will be sorted by key; this is useful for regression tests to ensure that JSON serializations can be compared on a day-to-day basis.

If indent is a non-negative integer, then JSON array elements and object members will be pretty-printed with that indent level. An indent level of 0 will only insert newlines. None is the most compact representation.

If specified, separators should be an (item_separator, key_separator) tuple. The default is (’, ‘, ‘: ‘) if indent is None and (‘,’, ‘: ‘) otherwise. To get the most compact JSON representation, you should specify (‘,’, ‘:’) to eliminate whitespace.

If specified, default is a function that gets called for objects that can’t otherwise be serialized. It should return a JSON encodable version of the object or raise a TypeError.

default(o)[source]#

Implement this method in a subclass such that it returns a serializable object for o, or calls the base implementation (to raise a TypeError).

For example, to support arbitrary iterators, you could implement default like this:

def default(self, o):
    try:
        iterable = iter(o)
    except TypeError:
        pass
    else:
        return list(iterable)
    # Let the base class default method raise the TypeError
    return JSONEncoder.default(self, o)

univention.admin.rest.utils module#

univention.admin.rest.utils.init_request_context_logging(request_context)[source]#
class univention.admin.rest.utils.RequestContextFilter(request_context, structured_logging=False)[source]#

Bases: Filter

Initialize a filter.

Initialize with the name of the logger which, together with its children, will have its events allowed through the filter. If no name is specified, allow every event.

filter(record)[source]#

Determine if the specified record is to be logged.

Returns True if the record should be logged, or False otherwise. If deemed appropriate, the record may be modified in-place.

univention.admin.rest.utils.parse_content_type(content_type)[source]#
exception univention.admin.rest.utils.NotFound(object_type=None, dn=None)[source]#

Bases: HTTPError

univention.admin.rest.utils.superordinate_names(module)[source]#
univention.admin.rest.utils.decode_properties(module, obj, properties)[source]#
univention.admin.rest.utils.encode_properties(module, obj, properties)[source]#
univention.admin.rest.utils.quote_dn(dn)[source]#
univention.admin.rest.utils.unquote_dn(dn)[source]#