udm_rest_client package¶
Submodules¶
udm_rest_client.base module¶
Base classes for (simplified) UDM modules and objects.
- class udm_rest_client.base.BaseModule(name: str, connection: Any, api_version: int)[source]¶
Bases:
objectBase class for UDM module classes. UDM modules are basically UDM object factories.
Usage:
Get module using:
user_mod = UDM().get('users/user')
Create fresh, not yet saved BaseObject:
new_user = user_mod.new()
Load an existing object:
group = group_mod.get('cn=test,cn=groups,dc=example,dc=com') group = group_mod.get_by_id('Domain Users')
Search and load existing objects:
dc_slaves = dc_slave_mod.search(filter_s='cn=s10*') campus_groups = group_mod.search(base='ou=campus,dc=example,dc=com')
Load existing object(s) without
open()‘ing them:user_mod.meta.auto_open = False user = user_mod.get(dn) user.props.groups == []
- get(dn: str) BaseObject[source]¶
Load UDM object from LDAP.
- Parameters:
dn (str) – DN of the object to load.
- Returns:
an existing
BaseObjectinstance.- Return type:
- Raises:
univention.udm.exceptions.NoObject – if no object is found at dn
univention.udm.exceptions.WrongObjectType – if the object found at dn is not of type
self.name
- meta: BaseModuleMetadata = BaseModuleMetadata(supported_api_versions=(), suitable_for=[], used_api_version=None)¶
- new(superordinate: str | BaseObject = None) BaseObject[source]¶
Create a new, unsaved
BaseObjectobject.- Parameters:
superordinate (str or GenericObject) – DN or UDM object this one references as its superordinate (required by some modules)
- Returns:
a new, unsaved BaseObject object
- Return type:
- search(filter_s: str = '', base: str = '', scope: str = 'sub') Iterator[BaseObject][source]¶
Get all UDM objects from LDAP that match the given filter.
- Parameters:
filter_s (str) – LDAP filter (only object selector like uid=foo required, objectClasses will be set by the UDM module)
base (str) – LDAP search base.
scope (str) – LDAP search scope, e.g. base or sub or one.
- Returns:
iterator of
BaseObjectobjects- Return type:
Iterator(BaseObject)
- class udm_rest_client.base.BaseModuleMeta(name, bases, attrs)[source]¶
Bases:
typeThis is not a subclass of
univention.udm.plugins.Plugin, like in the originalunivention.udm.base.ModuleMeta, because we don’t need to load module specific code in the client.- udm_meta_class¶
alias of
BaseModuleMetadata
- class udm_rest_client.base.BaseModuleMetadata(meta: BaseModule.Meta)[source]¶
Bases:
objectBase class for UDM module meta data.
- auto_open = True¶
Whether UDM objects should be
open()‘ed.
- auto_reload = True¶
Whether UDM objects should be
reload()‘ed after saving.
- property identifying_property: str¶
UDM property of which the mapped LDAP attribute is used as first component in a DN, e.g. username (LDAP attribute uid) or name (LDAP attribute cn).
- instance(udm_module: BaseModule, api_version: int) BaseModuleMetadata[source]¶
- lookup_filter(filter_s: str = None) str[source]¶
Filter the UDM module uses to find its corresponding LDAP objects.
This can be used in two ways:
get the filter to find all objects:
myfilter_s = obj.meta.lookup_filter()
get the filter to find a subset of the corresponding LDAP objects (filter_s will be combined with & to the filter for all objects):
`myfilter = obj.meta.lookup_filter('(|(givenName=A*)(givenName=B*))')`
- Parameters:
filter_s (str) – optional LDAP filter expression
- Returns:
an LDAP filter string
- Return type:
str
- property mapping: LdapMapping¶
UDM properties to LDAP attributes mapping and vice versa.
- Returns:
a namedtuple containing two mappings: a) from UDM property to LDAP attribute and b) from LDAP attribute to UDM property
- Return type:
- suitable_for: Iterable[str]¶
- supported_api_versions: Iterable[int]¶
- used_api_version: int¶
- class udm_rest_client.base.BaseObject[source]¶
Bases:
objectBase class for UDM object classes.
Usage:
Creation of instances is always done through
BaseModule.new(),BaseModule.get()orBaseModule.search().Modify an object:
user.props.firstname = 'Peter' user.props.lastname = 'Pan' user.save()
Move an object:
user.position = 'cn=users,ou=Company,dc=example,dc=com' user.save()
Delete an object:
obj.delete()
After saving a
BaseObject, it isreload()‘ed automatically because UDM hooks and listener modules often add, modify or remove properties when saving to LDAP. As this involves LDAP, it can be disabled if the object is not used afterwards and performance is an issue:user_mod.meta.auto_reload = False
- dn: str¶
- options: Dict[str:bool]¶
- policies: Dict[str, str]¶
- position: str¶
- props: BaseObjectProperties¶
- reload() BaseObject[source]¶
Refresh object from LDAP.
- Returns:
self
- Return type:
- save() BaseObject[source]¶
Save object to LDAP.
- Returns:
self
- Return type:
- Raises:
univention.udm.exceptions.MoveError – when a move operation fails
- superordinate: str¶
- udm_prop_class¶
alias of
BaseObjectProperties
- class udm_rest_client.base.BaseObjectProperties(udm_obj: BaseObject)[source]¶
Bases:
Mapping,IterableContainer for UDM properties.
- update(other: BaseObjectProperties = None, **kwargs) None[source]¶
udm_rest_client.base_http module¶
Base classes for (simplified) UDM modules and objects using the UDM REST API (instead of the low level Python UDM API).
- exception udm_rest_client.base_http.BadSettingsWarning[source]¶
Bases:
UdmRestClientWarning
- class udm_rest_client.base_http.DnPropertyEncoder(property_name: str, dn: str, session: Session, udm_module_name: str = None)[source]¶
Bases:
objectGiven a DN, return a string object with the DN and an additional member
obj.objis a property that, when accessed, will return the UDM object the DN refers to. The property has to be await ‘ed.
- exception udm_rest_client.base_http.InsecureRequestWarning[source]¶
Bases:
UdmRestClientWarning
- class udm_rest_client.base_http.Session(username: str, password: str, url: str, max_client_tasks: int = 10, request_id: str = None, request_id_header: str = 'X-Request-ID', language: str = None, **kwargs)[source]¶
Bases:
object- async call_openapi(udm_module_name: str, operation: str, dn: str = None, api_model_obj: ApiModel | Dict[str, Any] = None, language: str = None, **kwargs) Tuple[ApiModel | List[ApiModel], int, Dict[str, str]][source]¶
- property session: ClientSession¶
- exception udm_rest_client.base_http.StaleObjectWarning[source]¶
Bases:
UdmRestClientWarning
- class udm_rest_client.base_http.UdmModule(name: str, session: Session)[source]¶
Bases:
BaseModuleBase class for UDM_HTTP module classes. UDM modules are basically UDM object factories.
Usage:
Get module using:
user_mod = UDM().get('users/user')
1 Create fresh, not yet saved UdmObject:
new_user = user_mod.new()
2 Load an existing object:
group = group_mod.get('cn=test,cn=groups,dc=example,dc=com') group = group_mod.get_by_id('Domain Users')
3 Search and load existing objects:
dc_slaves = dc_slave_mod.search(filter_s='cn=s10*') campus_groups = group_mod.search(base='ou=campus,dc=example,dc=com')
Load existing object(s) without open() ‘ing them:
user_mod.meta.auto_open = False user = user_mod.get(dn) user.props.groups == []
- async get(dn: str, language: str = None) UdmObject[source]¶
Load UDM object from LDAP.
- Parameters:
dn (str) – DN of the object to load
language (str) – Language used in the “Accept-Language” header for this request (optional)
- Returns:
an existing
udm_rest_client.BaseHttpObjectobject- Return type:
- Raises:
udm_rest_client.NoObject – if no object is found at dn
udm_rest_client.WrongObjectType – if the object found at dn is not of type
self.name
- meta: BaseModuleMetadata = UdmModuleMetadata(supported_api_versions=[0, 1, 2], suitable_for=['*/*'], used_api_version=None)¶
- async new(superordinate: str = None, language: str = None) UdmObject[source]¶
Create a new, unsaved BaseHttpObject object.
- Parameters:
superordinate (str or GenericObject) – DN or UDM object this one references as its superordinate (required by some modules)
language (str) – Language used in the “Accept-Language” header for this request (optional)
- Returns:
a new, unsaved
udm_rest_client.UdmObjectobject- Return type:
- async search(filter_s: str = '', base: str = '', scope: str = 'sub', language: str = None) AsyncIterator[UdmObject][source]¶
Get all UDM objects from LDAP that match the given filter.
- Parameters:
filter_s (str) – LDAP filter (only object selector like uid=foo required, objectClasses will be set by the UDM module)
base (str) – base dn for search
scope (str) – one of base, one, sub or children
language (str) – Language used in the “Accept-Language” header for this request (optional)
- Returns:
iterator of
UdmObjectobjects- Return type:
Iterator(udm_rest_client.UdmObject)
- class udm_rest_client.base_http.UdmModuleMeta(name, bases, attrs)[source]¶
Bases:
BaseModuleMeta- udm_meta_class¶
alias of
UdmModuleMetadata
- class udm_rest_client.base_http.UdmModuleMetadata(meta: BaseModule.Meta)[source]¶
Bases:
BaseModuleMetadataBase class for module meta data. Nothing here in the REST client
- property identifying_property: str¶
UDM Property of which the mapped LDAP attribute is used as first component in a DN, e.g. username (LDAP attribute uid) or name (LDAP attribute cn).
- lookup_filter(filter_s: str = None) str[source]¶
Filter the UDM module uses to find its corresponding LDAP objects.
This can be used in two ways:
- get the filter to find all objects:
myfilter_s = obj.meta.lookup_filter()
- get the filter to find a subset of the corresponding LDAP objects
(filter_s will be combined with & to the filter for all objects): myfilter = obj.meta.lookup_filter(‘(|(givenName=A*)(givenName=B*))’)
- Parameters:
filter_s (str) – optional LDAP filter expression
- Returns:
an LDAP filter string
- Return type:
str
- property mapping: LdapMapping¶
UDM properties to LDAP attributes mapping and vice versa.
- Returns:
a namedtuple containing two mappings: a) from UDM property to LDAP attribute and b) from LDAP attribute to UDM property
- Return type:
- class udm_rest_client.base_http.UdmObject[source]¶
Bases:
BaseObjectBase class for UDM_HTTP object classes.
Usage:
Creation of instances
udm_rest_client.UdmObjectis always done through aBaseHttpModulinstances py:meth:new(), py:meth:get() or py:meth:search() methods.Modify an object:
user.props.firstname = 'Peter' user.props.lastname = 'Pan' user.save()
Move an object:
user.position = 'cn=users,ou=Company,dc=example,dc=com' user.save()
Delete an object:
obj.delete()
After saving a
udm_rest_client.UdmObject, it isreload()‘ed automatically because UDM hooks and listener modules often add, modify or remove properties when saving to LDAP. As this involves LDAP, it can be disabled if the object is not used afterwards and performance is an issue:user_mod.meta.auto_reload = False
- async delete(language=None) None[source]¶
Remove the object from the LDAP database.
- Parameters:
language (str) – Language used in the “Accept-Language” header for this request (optional)
- Returns:
None
- async reload(language: str = None) UdmObject[source]¶
Refresh object from LDAP.
- Parameters:
language (str) – Language used in the “Accept-Language” header for this request (optional)
- Returns:
self
- Return type:
- async save(language: str = None) UdmObject[source]¶
Save object to LDAP (via UDM REST API).
- Parameters:
language (str) – Language used in the “Accept-Language” header for this request (optional)
- Returns:
self
- Return type:
- Raises:
ApiException – when the operation fails
- udm_prop_class¶
alias of
UdmObjectProperties
- class udm_rest_client.base_http.UdmObjectProperties(udm_obj: BaseObject)[source]¶
Bases:
BaseObjectPropertiesContainer for UDM properties.
udm_rest_client.exceptions module¶
- exception udm_rest_client.exceptions.APICommunicationError(msg: str = None, dn: str = None, module_name: str = None, error: dict = None, status: int = None, reason: str = None)[source]¶
Bases:
UdmErrorRaised when something goes wrong communicating.
- exception udm_rest_client.exceptions.ConfigurationError(msg: str = None, dn: str = None, module_name: str = None, error: dict = None, status: int = None, reason: str = None)[source]¶
Bases:
UdmError
- exception udm_rest_client.exceptions.CreateError(msg: str = None, dn: str = None, module_name: str = None, error: dict = None, status: int = None, reason: str = None)[source]¶
Bases:
UdmErrorRaised when an error occurred when creating an object.
- exception udm_rest_client.exceptions.DeletedError(msg: str = None, dn: str = None, module_name: str = None)[source]¶
Bases:
UdmError
- exception udm_rest_client.exceptions.MethodNotSupportedError(msg: str = None, dn: str = None, module_name: str = None, error: dict = None, status: int = None, reason: str = None)[source]¶
Bases:
UdmErrorRaised if the API client does not support a method.
- exception udm_rest_client.exceptions.ModifyError(msg: str = None, dn: str = None, module_name: str = None, error: dict = None, status: int = None, reason: str = None)[source]¶
Bases:
UdmErrorRaised if an error occurred when modifying an object.
- exception udm_rest_client.exceptions.MoveError(msg: str = None, dn: str = None, module_name: str = None, error: dict = None, status: int = None, reason: str = None)[source]¶
Bases:
UdmErrorRaised if an error occurred when moving an object.
- exception udm_rest_client.exceptions.MultipleObjects(msg: str = None, dn: str = None, module_name: str = None, error: dict = None, status: int = None, reason: str = None)[source]¶
Bases:
UdmErrorRaised when more than one UDM object was found when there should be at most one.
- exception udm_rest_client.exceptions.NoObject(msg: str = None, dn: str = None, module_name: str = None)[source]¶
Bases:
UdmErrorRaised when a UDM object could not be found at a DN.
- exception udm_rest_client.exceptions.NotYetSavedError(msg: str = None, dn: str = None, module_name: str = None, error: dict = None, status: int = None, reason: str = None)[source]¶
Bases:
UdmErrorRaised when a client tries to delete or reload a UDM object that is not yet saved.
- msg: str = 'Object has not been created/loaded yet.'¶
udm_rest_client.udm module¶
UDM REST API Client library
Python library to interact with the Univention UDM REST API, implementing the interface of the simple Python UDM API [1].
The API consists of UDM modules and UDM object. UDM modules are factories for UDM objects. UDM objects manipulate LDAP objects on the UCS server.
Usage:
async with UDM("myuser", "s3cr3t", "https://FQ.DN/univention/udm/") as udm:
user_mod = udm.get('users/user')
obj = user_mod.get(dn)
obj.props.firstname = 'foo' # modify property
obj.position = 'cn=users,cn=example,dc=com' # move LDAP object
obj.save() # apply changes and reload object from LDAP
obj = user_mod.get(dn)
obj.delete() # delete object
async for obj in udm.get('users/user').search('uid=a*'):
print(obj.props.firstname, obj.props.lastname)
[1] https://docs.software-univention.de/developer-reference-4.4.html#udm:rest_api
- class udm_rest_client.udm.UDM(username: str, password: str, url: str, max_client_tasks: int = 10, request_id: str = None, request_id_header: str = 'X-Request-ID', language: str = None, **kwargs)[source]¶
Bases:
objectFactory for creating
udm_rest_client.UdmModuleobjects:from udm_rest_client import UDM async def func(): async with UDM("myuser", "s3cr3t", "https://FQ.DN/univention/udm/") as udm: group_mod = udm.get('groups/group') obj = await group_mod.get(dn) # obj is of type udm_rest_client.base_http.UdmObject
HTTP(S) sessions will be closed upon existing the asynchronous context manager. It is recommended to make as many operations as possible in the same session.
- property api_version¶
Here only for backwards compatibility.
- get(name: str) UdmModule[source]¶
Context manager of type
udm_rest_client.UdmModuleto work with UDM objects of type name (e.g. users/user). Exiting the context manager automatically closes theaiohttp.ClientSession. Usage example:async with udm.get("users/user") as user_mod: user_obj = await user_mod.get($DN)- Parameters:
name (str) – UDM module name (e.g. users/user)
- Returns:
instance of
udm_rest_client.UdmModule- Return type:
- async modules_list(language: str = None) Sequence[str][source]¶
Get the list of UDM modules the server knows.
- Parameters:
language (str) – Language used in the “Accept-Language” header for this request (optional)
- Returns:
list of UDM module names
- Return type:
list(str)
- async obj_by_dn(dn: str, language: str = None) UdmObject[source]¶
Load a UDM object without knowing the UDM module type.
- Parameters:
dn (str) – DN of the object to load
- Returns:
udm_rest_client.UdmObjectinstance- Return type:
- Raises:
univention.udm.exceptions.NoObject – if no object is found at dn
univention.udm.exceptions.ImportError – if the Python module for the specific UDM module type could not be loaded
- set_language(language: str) None[source]¶
Set the language used in the “Accept-Language” header for each request in the current session.
- Parameters:
language (str) – Language used in the “Accept-Language” header
- Returns:
None
- async unknown_modules(language: str = None) Sequence[str][source]¶
Get the list of UDM modules the server knows, but this client doesn’t.
Unknown UDM modules cannot be used with this client library. When the list is non-empty, the package openapi-client-udm must be rebuilt to use them.
- Parameters:
language (str) – Language used in the “Accept-Language” header for this request (optional)
- Returns:
list of UDM modules known by the server but not this client
- Return type:
list(str)
- version(api_version: int) UDM[source]¶
This is not about versions of the UDM REST API. This is here only to provide better drop-in functionality when using this lib instead of the UDM Python API on a UCS system. It is not required to use this method.
- Parameters:
api_version (int) – ignored
- Returns:
self
- Return type:
Module contents¶
Top-level package for Python UDM REST Client.
- exception udm_rest_client.APICommunicationError(msg: str = None, dn: str = None, module_name: str = None, error: dict = None, status: int = None, reason: str = None)[source]¶
Bases:
UdmErrorRaised when something goes wrong communicating.
- exception udm_rest_client.ConfigurationError(msg: str = None, dn: str = None, module_name: str = None, error: dict = None, status: int = None, reason: str = None)[source]¶
Bases:
UdmError
- exception udm_rest_client.CreateError(msg: str = None, dn: str = None, module_name: str = None, error: dict = None, status: int = None, reason: str = None)[source]¶
Bases:
UdmErrorRaised when an error occurred when creating an object.
- exception udm_rest_client.DeletedError(msg: str = None, dn: str = None, module_name: str = None)[source]¶
Bases:
UdmError
- exception udm_rest_client.ModifyError(msg: str = None, dn: str = None, module_name: str = None, error: dict = None, status: int = None, reason: str = None)[source]¶
Bases:
UdmErrorRaised if an error occurred when modifying an object.
- exception udm_rest_client.MoveError(msg: str = None, dn: str = None, module_name: str = None, error: dict = None, status: int = None, reason: str = None)[source]¶
Bases:
UdmErrorRaised if an error occurred when moving an object.
- exception udm_rest_client.MultipleObjects(msg: str = None, dn: str = None, module_name: str = None, error: dict = None, status: int = None, reason: str = None)[source]¶
Bases:
UdmErrorRaised when more than one UDM object was found when there should be at most one.
- exception udm_rest_client.NoObject(msg: str = None, dn: str = None, module_name: str = None)[source]¶
Bases:
UdmErrorRaised when a UDM object could not be found at a DN.
- exception udm_rest_client.NotYetSavedError(msg: str = None, dn: str = None, module_name: str = None, error: dict = None, status: int = None, reason: str = None)[source]¶
Bases:
UdmErrorRaised when a client tries to delete or reload a UDM object that is not yet saved.
- msg: str = 'Object has not been created/loaded yet.'¶
- class udm_rest_client.UDM(username: str, password: str, url: str, max_client_tasks: int = 10, request_id: str = None, request_id_header: str = 'X-Request-ID', language: str = None, **kwargs)[source]¶
Bases:
objectFactory for creating
udm_rest_client.UdmModuleobjects:from udm_rest_client import UDM async def func(): async with UDM("myuser", "s3cr3t", "https://FQ.DN/univention/udm/") as udm: group_mod = udm.get('groups/group') obj = await group_mod.get(dn) # obj is of type udm_rest_client.base_http.UdmObject
HTTP(S) sessions will be closed upon existing the asynchronous context manager. It is recommended to make as many operations as possible in the same session.
- property api_version¶
Here only for backwards compatibility.
- get(name: str) UdmModule[source]¶
Context manager of type
udm_rest_client.UdmModuleto work with UDM objects of type name (e.g. users/user). Exiting the context manager automatically closes theaiohttp.ClientSession. Usage example:async with udm.get("users/user") as user_mod: user_obj = await user_mod.get($DN)- Parameters:
name (str) – UDM module name (e.g. users/user)
- Returns:
instance of
udm_rest_client.UdmModule- Return type:
- async modules_list(language: str = None) Sequence[str][source]¶
Get the list of UDM modules the server knows.
- Parameters:
language (str) – Language used in the “Accept-Language” header for this request (optional)
- Returns:
list of UDM module names
- Return type:
list(str)
- async obj_by_dn(dn: str, language: str = None) UdmObject[source]¶
Load a UDM object without knowing the UDM module type.
- Parameters:
dn (str) – DN of the object to load
- Returns:
udm_rest_client.UdmObjectinstance- Return type:
- Raises:
univention.udm.exceptions.NoObject – if no object is found at dn
univention.udm.exceptions.ImportError – if the Python module for the specific UDM module type could not be loaded
- set_language(language: str) None[source]¶
Set the language used in the “Accept-Language” header for each request in the current session.
- Parameters:
language (str) – Language used in the “Accept-Language” header
- Returns:
None
- async unknown_modules(language: str = None) Sequence[str][source]¶
Get the list of UDM modules the server knows, but this client doesn’t.
Unknown UDM modules cannot be used with this client library. When the list is non-empty, the package openapi-client-udm must be rebuilt to use them.
- Parameters:
language (str) – Language used in the “Accept-Language” header for this request (optional)
- Returns:
list of UDM modules known by the server but not this client
- Return type:
list(str)
- version(api_version: int) UDM[source]¶
This is not about versions of the UDM REST API. This is here only to provide better drop-in functionality when using this lib instead of the UDM Python API on a UCS system. It is not required to use this method.
- Parameters:
api_version (int) – ignored
- Returns:
self
- Return type:
- exception udm_rest_client.UdmError(msg: str = None, dn: str = None, module_name: str = None, error: dict = None, status: int = None, reason: str = None)[source]¶
Bases:
ExceptionBase class of Exceptions raised by (simplified) UDM modules.
- msg: str = ''¶
- class udm_rest_client.UdmModule(name: str, session: Session)[source]¶
Bases:
BaseModuleBase class for UDM_HTTP module classes. UDM modules are basically UDM object factories.
Usage:
Get module using:
user_mod = UDM().get('users/user')
1 Create fresh, not yet saved UdmObject:
new_user = user_mod.new()
2 Load an existing object:
group = group_mod.get('cn=test,cn=groups,dc=example,dc=com') group = group_mod.get_by_id('Domain Users')
3 Search and load existing objects:
dc_slaves = dc_slave_mod.search(filter_s='cn=s10*') campus_groups = group_mod.search(base='ou=campus,dc=example,dc=com')
Load existing object(s) without open() ‘ing them:
user_mod.meta.auto_open = False user = user_mod.get(dn) user.props.groups == []
- async get(dn: str, language: str = None) UdmObject[source]¶
Load UDM object from LDAP.
- Parameters:
dn (str) – DN of the object to load
language (str) – Language used in the “Accept-Language” header for this request (optional)
- Returns:
an existing
udm_rest_client.BaseHttpObjectobject- Return type:
- Raises:
udm_rest_client.NoObject – if no object is found at dn
udm_rest_client.WrongObjectType – if the object found at dn is not of type
self.name
- meta: BaseModuleMetadata = UdmModuleMetadata(supported_api_versions=[0, 1, 2], suitable_for=['*/*'], used_api_version=None)¶
- async new(superordinate: str = None, language: str = None) UdmObject[source]¶
Create a new, unsaved BaseHttpObject object.
- Parameters:
superordinate (str or GenericObject) – DN or UDM object this one references as its superordinate (required by some modules)
language (str) – Language used in the “Accept-Language” header for this request (optional)
- Returns:
a new, unsaved
udm_rest_client.UdmObjectobject- Return type:
- async search(filter_s: str = '', base: str = '', scope: str = 'sub', language: str = None) AsyncIterator[UdmObject][source]¶
Get all UDM objects from LDAP that match the given filter.
- Parameters:
filter_s (str) – LDAP filter (only object selector like uid=foo required, objectClasses will be set by the UDM module)
base (str) – base dn for search
scope (str) – one of base, one, sub or children
language (str) – Language used in the “Accept-Language” header for this request (optional)
- Returns:
iterator of
UdmObjectobjects- Return type:
Iterator(udm_rest_client.UdmObject)
- class udm_rest_client.UdmObject[source]¶
Bases:
BaseObjectBase class for UDM_HTTP object classes.
Usage:
Creation of instances
udm_rest_client.UdmObjectis always done through aBaseHttpModulinstances py:meth:new(), py:meth:get() or py:meth:search() methods.Modify an object:
user.props.firstname = 'Peter' user.props.lastname = 'Pan' user.save()
Move an object:
user.position = 'cn=users,ou=Company,dc=example,dc=com' user.save()
Delete an object:
obj.delete()
After saving a
udm_rest_client.UdmObject, it isreload()‘ed automatically because UDM hooks and listener modules often add, modify or remove properties when saving to LDAP. As this involves LDAP, it can be disabled if the object is not used afterwards and performance is an issue:user_mod.meta.auto_reload = False
- async delete(language=None) None[source]¶
Remove the object from the LDAP database.
- Parameters:
language (str) – Language used in the “Accept-Language” header for this request (optional)
- Returns:
None
- async reload(language: str = None) UdmObject[source]¶
Refresh object from LDAP.
- Parameters:
language (str) – Language used in the “Accept-Language” header for this request (optional)
- Returns:
self
- Return type:
- async save(language: str = None) UdmObject[source]¶
Save object to LDAP (via UDM REST API).
- Parameters:
language (str) – Language used in the “Accept-Language” header for this request (optional)
- Returns:
self
- Return type:
- Raises:
ApiException – when the operation fails
- udm_prop_class¶
alias of
UdmObjectProperties