univention.admin.rest package#
Subpackages#
- univention.admin.rest.client package
HTTPErrorBadRequestUnauthorizedForbiddenNotFoundPreconditionFailedUnprocessableEntityServerErrorServiceUnavailableConnectionErrorUnexpectedResponseResponseSessionClientUDMModuleShallowObjectReferencesObjectObject.moduleObject.object_typeObject.dnObject.propertiesObject.optionsObject.policiesObject.superordinateObject.positionObject.uriObject.from_response()Object.from_data()Object.reload()Object.save()Object.json_patch()Object.delete()Object.restore()Object.move()Object.generate_service_specific_password()Object.get_layout()Object.get_properties()Object.get_property_choices()Object.policy_result()
PatchDocument
- univention.admin.rest.server package
GatewayGateway.child_idGateway.PROCESSESGateway.SOCKETSGateway.set_default_headers()Gateway.prepare()Gateway.get()Gateway.post()Gateway.put()Gateway.delete()Gateway.patch()Gateway.options()Gateway.select_language()Gateway.main()Gateway.start_child()Gateway.start_server()Gateway.log_function()Gateway.get_locale()Gateway.get_socket_for_locale()Gateway.start_processes()Gateway.register_signal_handlers()Gateway.signal_handler_reload()Gateway.signal_handler_stop()Gateway.safe_kill()
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#
Bases:
HTTPError
- 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#
- 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]#
- 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]#
- class univention.admin.rest.async_client.UDM(uri: str, username: str | None, password: str | None, *args: Any, **kwargs: Any)[source]#
Bases:
Client- uri#
- username#
- password#
- bearer_token#
- 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#
- async new(position: str | None = None, superordinate: str | None = None, template: dict[str, Any] | None = None) Object[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#
- 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 properties#
- classmethod from_data(udm: UDM, entry: dict, headers: Mapping[str, str] | None = None) Object[source]#
- udm#
- representation#
- hal#
- etag#
- last_modified#
univention.admin.rest.hal module#
univention.admin.rest.html_ui module#
univention.admin.rest.http_conditional module#
univention.admin.rest.ldap_connection module#
- univention.admin.rest.ldap_connection.get_user_ldap_write_connection(auth_type, binddn, bindpw)[source]#
univention.admin.rest.module module#
- class univention.admin.rest.module.ResourceBase[source]#
Bases:
SanitizerBase,HAL,HTMLAbstract base class for all HTTP resources
- pool = <concurrent.futures.thread.ThreadPoolExecutor object>#
- requires_authentication = True#
- property debug_mode_enabled#
- property ldap_write_connection#
- class univention.admin.rest.module.Resource(application: Application, request: HTTPServerRequest, **kwargs: Any)[source]#
Bases:
ResourceBase,RequestHandlerBase class for all HTTP resources
- class univention.admin.rest.module.Nothing(application: Application, request: HTTPServerRequest, **kwargs: Any)[source]#
Bases:
Resource404 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 defor decorate this method with .gen.coroutine to make it asynchronous. If this method returns anAwaitableexecution will not proceed until theAwaitableis done.Added in version 3.1: Asynchronous support.
- class univention.admin.rest.module.Favicon(application: Application, request: HTTPServerRequest, **kwargs: Any)[source]#
Bases:
ResourceBase,StaticFileHandlerGet a 16*16px PNG representation of a UDM module
- classmethod get_absolute_path(root, object_type='')[source]#
Returns the absolute location of
pathrelative toroot.rootis the path configured for this StaticFileHandler (in most cases thestatic_pathApplication 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,ResourceList all used Link relations
- class univention.admin.rest.module.OpenAPI(application: Application, request: HTTPServerRequest, **kwargs: Any)[source]#
Bases:
OpenAPIBase,ResourceJSON-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'}#
- class univention.admin.rest.module.Directory(application: Application, request: HTTPServerRequest, **kwargs: Any)[source]#
Bases:
ResourceLDAP directory tree
- get_template = 'directory.html'#
- class univention.admin.rest.module.ObjectTypes(application: Application, request: HTTPServerRequest, **kwargs: Any)[source]#
Bases:
ResourceGet the object types of a specific flavor
- class univention.admin.rest.module.SubObjectTypes(application: Application, request: HTTPServerRequest, **kwargs: Any)[source]#
Bases:
ResourceA list of possible sub-object-types which can be created underneath of the specified container or superordinate.
- get_template = 'children_types.html'#
- 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)
- class univention.admin.rest.module.LdapBase(application: Application, request: HTTPServerRequest, **kwargs: Any)[source]#
Bases:
ResourceRedirect to the ldap base object
- class univention.admin.rest.module.LdapAttributeUnmap(application: Application, request: HTTPServerRequest, **kwargs: Any)[source]#
Bases:
ResourceTransform Base64 encoded LDAP attributes to a UDM object that fits. Object does not have to exist.
- class univention.admin.rest.module.ObjectLink(application: Application, request: HTTPServerRequest, **kwargs: Any)[source]#
Bases:
ResourceIf the object-type is not known but only the DN, this resource redirects to the correct object.
- class univention.admin.rest.module.ObjectByUiid(application: Application, request: HTTPServerRequest, **kwargs: Any)[source]#
Bases:
ObjectLinkRedirect to the object specified by its LDAP Entry-UUID
- class univention.admin.rest.module.ContainerQueryBase(application: Application, request: HTTPServerRequest, **kwargs: Any)[source]#
Bases:
ResourceBase class for queries to container structures, needed to build a tree representation
- get_template = 'tree.html'#
- class univention.admin.rest.module.Tree(application: Application, request: HTTPServerRequest, **kwargs: Any)[source]#
Bases:
ContainerQueryBaseGet 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/)
- class univention.admin.rest.module.MoveDestinations(application: Application, request: HTTPServerRequest, **kwargs: Any)[source]#
Bases:
ContainerQueryBaseGet the locations where a specified UDM module can be moved to
- class univention.admin.rest.module.Properties(application: Application, request: HTTPServerRequest, **kwargs: Any)[source]#
Bases:
ResourceGet the properties of a UDM module or UDM object (GET udm/users/user/properties)
- class univention.admin.rest.module.Layout(application: Application, request: HTTPServerRequest, **kwargs: Any)[source]#
Bases:
ResourceGet the layout representation of a UDM module
- class univention.admin.rest.module.ReportingBase[source]#
Bases:
objectBase class for UDM object report operations
- class univention.admin.rest.module.Report(application: Application, request: HTTPServerRequest, **kwargs: Any)[source]#
Bases:
ReportingBase,ResourceCreate a object report e.g. in CSV of PDF format (GET udm/users/user/report/$report_type?dn=…&dn=…)
- class univention.admin.rest.module.NextFreeIpAddress(application: Application, request: HTTPServerRequest, **kwargs: Any)[source]#
Bases:
ResourceGet the next free IP of the specified network (GET udm/networks/network/$DN/next-free-ip-address)
- class univention.admin.rest.module.Objects(application: Application, request: HTTPServerRequest, **kwargs: Any)[source]#
Bases:
ConditionalResource,FormBase,ReportingBase,_OpenAPIBase,ResourceSearch 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]#
- class univention.admin.rest.module.ObjectsMove(application: Application, request: HTTPServerRequest, **kwargs: Any)[source]#
Bases:
ResourceMove multiple objects at the same time
- class univention.admin.rest.module.Object(application: Application, request: HTTPServerRequest, **kwargs: Any)[source]#
Bases:
ConditionalResource,FormBase,_OpenAPIBase,ResourceGet, 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
- class univention.admin.rest.module.ObjectRestore(application: Application, request: HTTPServerRequest, **kwargs: Any)[source]#
Bases:
ResourceRestore an object from the recyclebin
- class univention.admin.rest.module.UserPhoto(application: Application, request: HTTPServerRequest, **kwargs: Any)[source]#
Bases:
ConditionalResource,ResourceGet a (cacheable) user profile picture in JPEG format
- class univention.admin.rest.module.ObjectAdd(application: Application, request: HTTPServerRequest, **kwargs: Any)[source]#
Bases:
FormBase,_OpenAPIBase,ResourceGET 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)
- class univention.admin.rest.module.ObjectCopy(application: Application, request: HTTPServerRequest, **kwargs: Any)[source]#
Bases:
ObjectAddCopy an object
- class univention.admin.rest.module.ObjectEdit(application: Application, request: HTTPServerRequest, **kwargs: Any)[source]#
-
GET a form containing ways to modify, remove, move a specific object
- class univention.admin.rest.module.ObjectMultiEdit(application: Application, request: HTTPServerRequest, **kwargs: Any)[source]#
Bases:
ObjectEditModify multiple objects at the same time
- class univention.admin.rest.module.DefaultContainers(application: Application, request: HTTPServerRequest, **kwargs: Any)[source]#
Bases:
ResourceGet list of default containers. GET udm/users/user/default-containers
- get_template = 'default_containers.html'#
- class univention.admin.rest.module.PropertyChoices(application: Application, request: HTTPServerRequest, **kwargs: Any)[source]#
Bases:
ResourceGet possible values/choices for the specified property. GET udm/users/user/$DN/properties/$name/choices
- get_template = 'property_choices.html'#
- 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:
ResourceGet 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:
PolicyResultBaseGet 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)
- class univention.admin.rest.module.PolicyResultContainer(application: Application, request: HTTPServerRequest, **kwargs: Any)[source]#
Bases:
PolicyResultBaseGet 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)
- class univention.admin.rest.module.Operations(application: Application, request: HTTPServerRequest, **kwargs: Any)[source]#
Bases:
ResourceGET /udm/progress/$progress-id (get the progress of a started operation like move, report, maybe add/put?, …)
- class univention.admin.rest.module.LicenseRequest(application: Application, request: HTTPServerRequest, **kwargs: Any)[source]#
Bases:
ResourceRequest a new license from the Univention license server
- class univention.admin.rest.module.LicenseCheck(application: Application, request: HTTPServerRequest, **kwargs: Any)[source]#
Bases:
ResourceCheck if the license has exceeded or is still valid
- class univention.admin.rest.module.License(application: Application, request: HTTPServerRequest, **kwargs: Any)[source]#
Bases:
ResourceGet information about the license
- class univention.admin.rest.module.LicenseImport(application: Application, request: HTTPServerRequest, **kwargs: Any)[source]#
Bases:
ResourceImport a new license
univention.admin.rest.openapi module#
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.PatchRepresentation(**kwargs)[source]#
Bases:
PatchDocument
- class univention.admin.rest.sanitizer.PatchDocumentSanitizer(*args, **kwargs)[source]#
Bases:
ListSanitizer
- 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:
StringSanitizerA 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.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#
univention.admin.rest.utils module#
- class univention.admin.rest.utils.RequestContextFilter(request_context, structured_logging=False)[source]#
Bases:
FilterInitialize 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.