######################
Python UDM REST Client
######################
|python| |license| |code style| |codecov| |docspassing|
Python library to interact with the Univention `UDM REST API`_,
implements the interface of the `Python UDM API`_.
* Free software: GNU Affero General Public License version 3
* Documentation: https://udm-rest-client.readthedocs.io
Features
========
* Asynchronous
* Automatic handling of HTTP(S) sessions
* Type annotations
* 100% test coverage (unittests + integration tests)
* Python 3.9, 3.10, 3.11
Usage
=====
The ``UDM`` context manager opens and closes a HTTP session::
>>> import asyncio
>>> from udm_rest_client.udm import UDM
>>>
>>> async def get_obj(mod_name, dn):
... async with UDM(
... "USERNAME",
... "PASSWORD",
... "https://FQDN.OF.UCS/univention/udm",
... ssl_ca_cert="ucs-root-ca.crt"
... ) as udm:
... mod = udm.get(mod_name)
... return await mod.get(dn)
...
>>> obj = asyncio.run(get_obj("users/user", "uid=foo,cn=users,BASE-DN"))
>>>
>>> print(obj)
UdmObject('users/user', 'uid=foo,cn=users,BASE-DN')
>>> print(obj.props.username)
foo
There are more examples in the `docs`_ *usage* section.
If the SSL CA certificate is not available ``verify_ssl=False`` can be used in place of ``ssl_ca_cert=...``. Obviously that is not safe! The CA of any UCS server can always be downloaded from ``http://FQDN.OF.UCS/ucs-root-ca.crt``.
Installation
============
1. Install *Python UDM REST Client* via pip from `PyPI`_::
$ pip install udm-rest-client
If you see a complaint about docker needing a higher version of urrlib3, upgrade::
$ pip install --upgrade urllib3
2. Install the OpenAPI client library used by the udm-rest-client. It is created by software from the `OpenAPI Generator`_ project. You need to either have a local Java installation (Java 8+) or run the projects Docker container. The process is scripted::
$ update_openapi_client --generator docker ucs.master.fqdn.or.ip # use Docker
$ update_openapi_client --generator java ucs.master.fqdn.or.ip # use Java
Use ``--insecure`` to ignore SSL verification errors. See ``--help`` for more options.
Use ``--username`` and ``--password`` to provide credentials if access to your openapi.json is protected. This is the
default in newer versions of UCS and thus credentials are needed.
**Important**:
Whenever a new UDM module is installed in the domain, it is necessary to rerun ``update_openapi_client``.
The new UDM module will otherwise not be available in the *Python UDM REST Client*.
Very few apps (like UCS\@school and Open-Xchange) install new UDM modules.
New extended attributes do *not* require to rebuild the OpenAPI client library.
Logging
=======
Standard logging is used for tracking the library's activity.
To capture the log messages for this project, subscribe to a logger named ``udm_rest_client``.
The *UDM REST API* on the UCS server logs into the file ``/var/log/univention/directory-manager-rest.log``.
Credits
=======
This package was created with Cookiecutter_ and the `audreyr/cookiecutter-pypackage`_ project template.
.. _Cookiecutter: https://github.com/audreyr/cookiecutter
.. _`audreyr/cookiecutter-pypackage`: https://github.com/audreyr/cookiecutter-pypackage
.. _`UDM REST API`: https://docs.software-univention.de/developer-reference-4.4.html#udm:rest_api
.. _`Python UDM API`: https://github.com/univention/univention-corporate-server/blob/4.4-8/management/univention-directory-manager-modules/modules/univention/udm/__init__.py
.. _`OpenAPI Generator`: https://github.com/OpenAPITools/openapi-generator
.. _`docs`: https://udm-rest-client.readthedocs.io
.. _`PyPI`: https://pypi.org/project/udm-rest-client/
.. |license| image:: https://img.shields.io/badge/License-AGPL%20v3-orange.svg
:alt: GNU AGPL V3 license
:target: https://www.gnu.org/licenses/agpl-3.0
.. |python| image:: https://img.shields.io/badge/python-3.9+-blue.svg
:alt: Python 3.9+
:target: https://www.python.org/
.. |code style| image:: https://img.shields.io/badge/code%20style-black-000000.svg
:alt: Code style: black
:target: https://github.com/psf/black
.. |codecov| image:: https://codecov.io/gh/univention/python-udm-rest-api-client/branch/master/graph/badge.svg
:alt: Code coverage
:target: https://codecov.io/gh/univention/python-udm-rest-api-client
.. |docspassing| image:: https://readthedocs.org/projects/udm-rest-client/badge/?version=latest
:alt: Documentation Status
:target: https://udm-rest-client.readthedocs.io/en/latest/?badge=latest
=======
History
=======
1.3.1 (2025-02-18)
------------------
* Update docker dependency to v7.
* Drop support for python 3.6, python 3.7 and python 3.8.
1.2.3 (2024-01-16)
-------------------
* The client now handles HTTP status responses from the UDM REST API based on generic range (e.g. 2xx-3xx) instead of specific codes.
1.2.2 (2023-06-05)
-------------------
* Fix ``update_openapi_client`` crashing with newer versions of the Python Docker client and ``requests`` (Issue #10).
* Testing fixes (Issues #5 and #9)
1.2.1 (2023-02-15)
-------------------
* Update OpenAPI client library generator (openapitools/openapi-generator-cli) to version ``5.4.0`` to support Python 3.11..
1.1.1 (2023-01-16)
-------------------
* Move operations succeed, when a language header is set.
1.1.0 (2022-11-29)
-------------------
* Adjust objectType return value of ``users/self`` to latest UCS erratum.
1.0.13 (2022-11-09)
-------------------
* Fix error handling in base_http.py.
1.0.12 (2022-11-02)
-------------------
* Add the possibility to send an Accept-Language header with each request.
1.0.11 (2022-10-19)
-------------------
* Handle UDM REST API doing immediate moves (without redirects) for objects without subordinates.
1.0.10 (2022-10-13)
-------------------
* Pass trough UDM REST API error in ``CreateError`` and ``ModifyError`` exceptions.
1.0.9 (2022-09-15)
------------------
* Format the correlation ID as a hex value.
1.0.8 (2022-09-11)
------------------
* Send a correlation ID with each request.
* Raise version of generated client library ``openapi-client-udm`` to ``1.0.1``.
1.0.7 (2022-01-18)
------------------
* Lower required version of ``click`` library, for compatibility with ``typer<0.4.0``.
1.0.6 (2022-01-05)
------------------
* UCS 5.0 container for testing is now run using LXD.
* Fix deprecated use of ``ruamel.yaml`` in tests.
1.0.5 (2021-12-09)
------------------
* Add process wide cache for the LDAP base of each host.
1.0.4 (2021-11-15)
------------------
* Update `aiohttp <https://github.com/aio-libs/aiohttp>`_ to (at least) Version ``3.8.1``, which fixes `aiohttp not honoring "no_proxy" <https://github.com/aio-libs/aiohttp/issues/4431>`_.
* Update development and testing dependencies.
1.0.3 (2021-03-25)
------------------
* Fix handling of values that are lists of dicts (e.g. ``dnsEntryZoneAlias`` of computer objects).
1.0.2 (2021-03-25)
------------------
* Fix not sending policy modifications to server.
1.0.1 (2021-02-10)
------------------
* The script to create/update the OpenAPI client ``update_openapi_client`` has been updated to use the OpenAPI Generator version ``5.0.0``.
* The ``update_openapi_client`` script now verifies the checksum of the downloaded JAR file.
1.0.0 (2021-02-03)
------------------
* **Breaking API CHANGE**: The ``options`` attribute of UDM objects is now a dictionary. It mirrors the UDM REST APIs ``options`` attribute value. Before it was a list, which did not allow to disable default options (Bug #50974).
0.4.0 (2020-04-06)
------------------
* Add the possibility to provide credentials in the update_openapi_client script to download the schema file.
0.3.1 (2020-03-19)
------------------
* Update download URL of openapi-generator jar.
0.3.0 (2020-03-18)
------------------
* allow setting properties that only exist after enabling an option (`Bug #50972 <http://forge.univention.org/bugzilla/show_bug.cgi?id=50972>`_)
0.2.1 (2019-12-14)
------------------
* fix not detecting changes in mutable property values
0.2.0 (2019-12-10)
------------------
* ``Mapping`` and ``Iterable`` interfaces were added to the object properties class. Adds item access (``obj.props["key"]``), ``obj.props.get("key")``, ``len(obj.props)``, ``key in obj.props``, ``obj.props.keys()``, ``obj.props.values()``, ``obj.props.items()``
* documentation improvements
* HTTP basic passwords are no longer logged
* map ``options`` and ``policies`` back to original values (were being rewritten to pep8 conform keys by the OpenAPI client)
0.1.1 (2019-11-25)
------------------
* allow specifying existing JAR for open api client build
* various small fixes to handle RTD and Travis-CI
0.1.0 (2019-11-22)
------------------
* First release.
Raw data
{
"_id": null,
"home_page": "https://github.com/univention/python-udm-rest-api-client",
"name": "udm-rest-client",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.9",
"maintainer_email": null,
"keywords": "Univention UCS UDM REST",
"author": "Daniel Troeder",
"author_email": "troeder@univention.de",
"download_url": "https://files.pythonhosted.org/packages/36/d2/c84b8433808861210b3bfd8828f5b43ed1d9ce5431a442ed5b59bcb277da/udm_rest_client-1.3.1.tar.gz",
"platform": null,
"description": "######################\nPython UDM REST Client\n######################\n\n|python| |license| |code style| |codecov| |docspassing|\n\nPython library to interact with the Univention `UDM REST API`_,\nimplements the interface of the `Python UDM API`_.\n\n* Free software: GNU Affero General Public License version 3\n* Documentation: https://udm-rest-client.readthedocs.io\n\n\nFeatures\n========\n\n* Asynchronous\n* Automatic handling of HTTP(S) sessions\n* Type annotations\n* 100% test coverage (unittests + integration tests)\n* Python 3.9, 3.10, 3.11\n\n\nUsage\n=====\n\nThe ``UDM`` context manager opens and closes a HTTP session::\n\n >>> import asyncio\n >>> from udm_rest_client.udm import UDM\n >>>\n >>> async def get_obj(mod_name, dn):\n ... async with UDM(\n ... \"USERNAME\",\n ... \"PASSWORD\",\n ... \"https://FQDN.OF.UCS/univention/udm\",\n ... ssl_ca_cert=\"ucs-root-ca.crt\"\n ... ) as udm:\n ... mod = udm.get(mod_name)\n ... return await mod.get(dn)\n ...\n >>> obj = asyncio.run(get_obj(\"users/user\", \"uid=foo,cn=users,BASE-DN\"))\n >>>\n >>> print(obj)\n UdmObject('users/user', 'uid=foo,cn=users,BASE-DN')\n >>> print(obj.props.username)\n foo\n\nThere are more examples in the `docs`_ *usage* section.\n\nIf the SSL CA certificate is not available ``verify_ssl=False`` can be used in place of ``ssl_ca_cert=...``. Obviously that is not safe! The CA of any UCS server can always be downloaded from ``http://FQDN.OF.UCS/ucs-root-ca.crt``.\n\n\nInstallation\n============\n\n1. Install *Python UDM REST Client* via pip from `PyPI`_::\n\n $ pip install udm-rest-client\n\n If you see a complaint about docker needing a higher version of urrlib3, upgrade::\n\n $ pip install --upgrade urllib3\n\n2. Install the OpenAPI client library used by the udm-rest-client. It is created by software from the `OpenAPI Generator`_ project. You need to either have a local Java installation (Java 8+) or run the projects Docker container. The process is scripted::\n\n $ update_openapi_client --generator docker ucs.master.fqdn.or.ip # use Docker\n $ update_openapi_client --generator java ucs.master.fqdn.or.ip # use Java\n\nUse ``--insecure`` to ignore SSL verification errors. See ``--help`` for more options.\n\nUse ``--username`` and ``--password`` to provide credentials if access to your openapi.json is protected. This is the\ndefault in newer versions of UCS and thus credentials are needed.\n\n**Important**:\nWhenever a new UDM module is installed in the domain, it is necessary to rerun ``update_openapi_client``.\nThe new UDM module will otherwise not be available in the *Python UDM REST Client*.\nVery few apps (like UCS\\@school and Open-Xchange) install new UDM modules.\nNew extended attributes do *not* require to rebuild the OpenAPI client library.\n\nLogging\n=======\n\nStandard logging is used for tracking the library's activity.\nTo capture the log messages for this project, subscribe to a logger named ``udm_rest_client``.\n\nThe *UDM REST API* on the UCS server logs into the file ``/var/log/univention/directory-manager-rest.log``.\n\nCredits\n=======\n\nThis package was created with Cookiecutter_ and the `audreyr/cookiecutter-pypackage`_ project template.\n\n.. _Cookiecutter: https://github.com/audreyr/cookiecutter\n.. _`audreyr/cookiecutter-pypackage`: https://github.com/audreyr/cookiecutter-pypackage\n.. _`UDM REST API`: https://docs.software-univention.de/developer-reference-4.4.html#udm:rest_api\n.. _`Python UDM API`: https://github.com/univention/univention-corporate-server/blob/4.4-8/management/univention-directory-manager-modules/modules/univention/udm/__init__.py\n.. _`OpenAPI Generator`: https://github.com/OpenAPITools/openapi-generator\n.. _`docs`: https://udm-rest-client.readthedocs.io\n.. _`PyPI`: https://pypi.org/project/udm-rest-client/\n.. |license| image:: https://img.shields.io/badge/License-AGPL%20v3-orange.svg\n :alt: GNU AGPL V3 license\n :target: https://www.gnu.org/licenses/agpl-3.0\n.. |python| image:: https://img.shields.io/badge/python-3.9+-blue.svg\n :alt: Python 3.9+\n :target: https://www.python.org/\n.. |code style| image:: https://img.shields.io/badge/code%20style-black-000000.svg\n :alt: Code style: black\n :target: https://github.com/psf/black\n.. |codecov| image:: https://codecov.io/gh/univention/python-udm-rest-api-client/branch/master/graph/badge.svg\n :alt: Code coverage\n :target: https://codecov.io/gh/univention/python-udm-rest-api-client\n.. |docspassing| image:: https://readthedocs.org/projects/udm-rest-client/badge/?version=latest\n :alt: Documentation Status\n :target: https://udm-rest-client.readthedocs.io/en/latest/?badge=latest\n\n\n=======\nHistory\n=======\n\n1.3.1 (2025-02-18)\n------------------\n\n* Update docker dependency to v7.\n* Drop support for python 3.6, python 3.7 and python 3.8.\n\n1.2.3 (2024-01-16)\n-------------------\n\n* The client now handles HTTP status responses from the UDM REST API based on generic range (e.g. 2xx-3xx) instead of specific codes.\n\n1.2.2 (2023-06-05)\n-------------------\n\n* Fix ``update_openapi_client`` crashing with newer versions of the Python Docker client and ``requests`` (Issue #10).\n* Testing fixes (Issues #5 and #9)\n\n1.2.1 (2023-02-15)\n-------------------\n\n* Update OpenAPI client library generator (openapitools/openapi-generator-cli) to version ``5.4.0`` to support Python 3.11..\n\n1.1.1 (2023-01-16)\n-------------------\n\n* Move operations succeed, when a language header is set.\n\n1.1.0 (2022-11-29)\n-------------------\n\n* Adjust objectType return value of ``users/self`` to latest UCS erratum.\n\n1.0.13 (2022-11-09)\n-------------------\n\n* Fix error handling in base_http.py.\n\n1.0.12 (2022-11-02)\n-------------------\n\n* Add the possibility to send an Accept-Language header with each request.\n\n1.0.11 (2022-10-19)\n-------------------\n\n* Handle UDM REST API doing immediate moves (without redirects) for objects without subordinates.\n\n1.0.10 (2022-10-13)\n-------------------\n\n* Pass trough UDM REST API error in ``CreateError`` and ``ModifyError`` exceptions.\n\n1.0.9 (2022-09-15)\n------------------\n\n* Format the correlation ID as a hex value.\n\n1.0.8 (2022-09-11)\n------------------\n\n* Send a correlation ID with each request.\n* Raise version of generated client library ``openapi-client-udm`` to ``1.0.1``.\n\n1.0.7 (2022-01-18)\n------------------\n\n* Lower required version of ``click`` library, for compatibility with ``typer<0.4.0``.\n\n1.0.6 (2022-01-05)\n------------------\n\n* UCS 5.0 container for testing is now run using LXD.\n* Fix deprecated use of ``ruamel.yaml`` in tests.\n\n1.0.5 (2021-12-09)\n------------------\n\n* Add process wide cache for the LDAP base of each host.\n\n1.0.4 (2021-11-15)\n------------------\n\n* Update `aiohttp <https://github.com/aio-libs/aiohttp>`_ to (at least) Version ``3.8.1``, which fixes `aiohttp not honoring \"no_proxy\" <https://github.com/aio-libs/aiohttp/issues/4431>`_.\n* Update development and testing dependencies.\n\n1.0.3 (2021-03-25)\n------------------\n\n* Fix handling of values that are lists of dicts (e.g. ``dnsEntryZoneAlias`` of computer objects).\n\n1.0.2 (2021-03-25)\n------------------\n\n* Fix not sending policy modifications to server.\n\n1.0.1 (2021-02-10)\n------------------\n\n* The script to create/update the OpenAPI client ``update_openapi_client`` has been updated to use the OpenAPI Generator version ``5.0.0``.\n* The ``update_openapi_client`` script now verifies the checksum of the downloaded JAR file.\n\n1.0.0 (2021-02-03)\n------------------\n\n* **Breaking API CHANGE**: The ``options`` attribute of UDM objects is now a dictionary. It mirrors the UDM REST APIs ``options`` attribute value. Before it was a list, which did not allow to disable default options (Bug #50974).\n\n0.4.0 (2020-04-06)\n------------------\n\n* Add the possibility to provide credentials in the update_openapi_client script to download the schema file.\n\n0.3.1 (2020-03-19)\n------------------\n\n* Update download URL of openapi-generator jar.\n\n0.3.0 (2020-03-18)\n------------------\n\n* allow setting properties that only exist after enabling an option (`Bug #50972 <http://forge.univention.org/bugzilla/show_bug.cgi?id=50972>`_)\n\n0.2.1 (2019-12-14)\n------------------\n\n* fix not detecting changes in mutable property values\n\n0.2.0 (2019-12-10)\n------------------\n\n* ``Mapping`` and ``Iterable`` interfaces were added to the object properties class. Adds item access (``obj.props[\"key\"]``), ``obj.props.get(\"key\")``, ``len(obj.props)``, ``key in obj.props``, ``obj.props.keys()``, ``obj.props.values()``, ``obj.props.items()``\n* documentation improvements\n* HTTP basic passwords are no longer logged\n* map ``options`` and ``policies`` back to original values (were being rewritten to pep8 conform keys by the OpenAPI client)\n\n0.1.1 (2019-11-25)\n------------------\n\n* allow specifying existing JAR for open api client build\n* various small fixes to handle RTD and Travis-CI\n\n0.1.0 (2019-11-22)\n------------------\n\n* First release.\n",
"bugtrack_url": null,
"license": "GNU Affero General Public License v3",
"summary": "Python library to interact with the Univention UDM REST API. Implements the simple Python UDM API.",
"version": "1.3.1",
"project_urls": {
"Homepage": "https://github.com/univention/python-udm-rest-api-client"
},
"split_keywords": [
"univention",
"ucs",
"udm",
"rest"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "353ddad94cd4b7ee85c7f7d053d462baeac1f27e8d337dd06edc7b3863745293",
"md5": "1d75b812fe8054f5c7bda3eff20a344c",
"sha256": "f66b92e2dd1cdf315297475b52ed130e857a56b60d7cff8122bd64a30445321b"
},
"downloads": -1,
"filename": "udm_rest_client-1.3.1-py2.py3-none-any.whl",
"has_sig": false,
"md5_digest": "1d75b812fe8054f5c7bda3eff20a344c",
"packagetype": "bdist_wheel",
"python_version": "py2.py3",
"requires_python": ">=3.9",
"size": 32482,
"upload_time": "2025-02-20T11:39:08",
"upload_time_iso_8601": "2025-02-20T11:39:08.042057Z",
"url": "https://files.pythonhosted.org/packages/35/3d/dad94cd4b7ee85c7f7d053d462baeac1f27e8d337dd06edc7b3863745293/udm_rest_client-1.3.1-py2.py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "36d2c84b8433808861210b3bfd8828f5b43ed1d9ce5431a442ed5b59bcb277da",
"md5": "807d04d74e7317cab8f9c5dd4b7f6be1",
"sha256": "b935a46130350123f94a44539767d6510f56fea7bea1f673e056f0ca279be869"
},
"downloads": -1,
"filename": "udm_rest_client-1.3.1.tar.gz",
"has_sig": false,
"md5_digest": "807d04d74e7317cab8f9c5dd4b7f6be1",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.9",
"size": 57678,
"upload_time": "2025-02-20T11:39:10",
"upload_time_iso_8601": "2025-02-20T11:39:10.430732Z",
"url": "https://files.pythonhosted.org/packages/36/d2/c84b8433808861210b3bfd8828f5b43ed1d9ce5431a442ed5b59bcb277da/udm_rest_client-1.3.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-02-20 11:39:10",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "univention",
"github_project": "python-udm-rest-api-client",
"travis_ci": true,
"coveralls": false,
"github_actions": false,
"requirements": [
{
"name": "aiohttp",
"specs": [
[
">=",
"3.8.1"
],
[
"<",
"4"
]
]
},
{
"name": "async-property",
"specs": [
[
"<",
"0.3"
],
[
">=",
"0.2.1"
]
]
},
{
"name": "click",
"specs": [
[
"<",
"9"
],
[
">=",
"7"
]
]
},
{
"name": "docker",
"specs": [
[
">=",
"7.1"
],
[
"<",
"8"
]
]
},
{
"name": "requests",
"specs": [
[
">=",
"2.26"
],
[
"<",
"3"
]
]
}
],
"tox": true,
"lcname": "udm-rest-client"
}