- class activelogic.Resource¶
This is the parent class for all resources.
Connectioninstantiates all resources:
c = await conn.config() rs = await conn.ruleset()
Each resource defines a subset of the system’s configuration and has its own set of privileges in the user database:
None - User can’t access the resource at all.
Read - User can run read-only commands on the resource.
Write - User can run all commands on the resource.
A session attached to the resource will always be in a transaction. There is also implicit locks on each resource that are taken when the first manipulative command is sent, and released when changes are committed or rolled back.
# Alt 1. async with await conn.config() as c: await c.update_value('DRDL_ENABLED', True) # Alt 2. await c.update_value('DRDL_ENABLED', True) await c.commit()
Issuing commands on an outdated resource will result in that
The machine id of the system that owns the resource.
>>> res.machineid '001122334455'
The firmware version running on the system that owns the resource.
>>> res.distversion '22.20.06.1'
Sets the commit message of the next commit.
commit_message (str) –
This function is typically used for setting proper commit message in context manager-based commits:
>>> with conn.config() as c: ... c.update("GEOLOGIC_ENABLED", True) ... c.set_commit_message("Enable GeoLogic function")
- async Resource.commit(commit_message=None)¶
Stores the current transaction to the database.
commit_message (str) – Message recorded in the commit log.
This command makes your changes visible to others.
It is usually a good practice to commit changes in batches. In particular if changes are committed to
Ruleset. This will reload the ruleset and take a lot of CPU resources from the system.
- async Resource.rollback()¶
Aborts the current transaction and discards the changes.
This also automatically happens if your connection drops or you exit the program without committing your changes.
Enables or disables the caching mechanism for the resource.
enable (bool) –
For optimal performance, caching should always be enabled. All resources have their caching enabled by default.
Invalidates a specific cache, or all caches tied to the current resource.
The cache is always invalidated if the current transaction is rolled back or committed.
cache_id (str) – Id of the cache to invalidate, or empty if all caches should be invalidated.