The External Python API provided by the Python interpreter included in the CEI/Ansys distributions can now be used to manipulate items and item categories as a part of ACLs.
This object is a Python representation of a Nexus item category. When this object is created, a GUID will automatically be generated for the object and the date is set to the current time/date with the current timezone.
The following attributes are available on an ItemCategoryREST object:
category.add_owner(group_name)
Add a user group to the owners set attribute. group_name must be a valid group name string.
category.add_viewer(group_name)
Add a user group to the viewers set attribute. group_name must be a valid group name string.
category.add_changer(group_name)
Add a user group to the changers set attribute. group_name must a valid group name string.
category.add_deleter(group_name)
Add a user group to the deleters set attribute. group_name must be a valid group name string.
category.remove_owner(group_name)
Remove a user group from the owners set attribute. group_name must be a valid group name string.
category.remove_viewer(group_name)
Remove a user group from the viewers set attribute. group_name must be a valid group name string.
category.remove_changer(group_name)
Remove a user group from the changers set attribute. group_name must be a valid group name string.
category.remove_deleter(group_name)
Remove a user group from the deleters set attribute. group_name must be a valid group name string.
Note, all fields may be used only for ItemCategory object type queries, just like in a typical Query Expression.
ItemCategory fields
ic_guid |
item category guid |
ic_date |
item category date |
ic_name |
item category name |
This document only covers ACLs specific information and use cases of ItemREST. Please visit the original document for detailed information on ItemREST.
ACLs is available through the following additional attributes on an ItemREST object:
item.add_category(category)
Add an item category to the categories set attribute. The value passed can either be a category name string or an ItemCategoryREST object.
item.remove_category(category)
Remove an item category from the categories set attribute. The value passed can either be a category name string or an ItemCategoryREST object.
A simple example of how this API might be used:
import cei
from template_editor import report_objects, report_remote_server
server = report_remote_server.Server(url="http://localhost:8000", username="nexus", password="cei")
### Creating categories
ic = server.create_item_category('bumper')
ic.add_owner('nexus')
ic1 = server.create_item_category('bumper1')
ic1.add_owner('cei')
ic1.add_changer('nexus')
ic2 = server.create_item_category('bumper2')
ic2.add_owner('cei')
ic2.add_viewer('nexus')
ic2.add_deleter('nexus')
categs = [ic, ic1, ic2]
# upload
error = server.put_objects(categs)
### Fetching categories with queries using Query Expressions. For example: created after 2020-02-17
categs=server.get_objects(objtype=report_objects.ItemCategoryREST, query='A|ic_date|gt|2020-02-17T05%3A59%3A00.000Z;')
### Creating items and setting categories
item = server.create_item(name="Simple header", source="My Python script")
item.set_payload_html("<h1>An Example Header</h1>")
# set categories
item.categories = categs
# removing
item.remove_category(ic2)
item.remove_category(ic)
# adding back
item.add_category(ic)
# upload
error = server.put_objects([item])