Models#

Activity log#

class ActivityReportFilter#

Builder class to create an activity report filter for use with get_activity_report_where().

All text-based fields are always case-insensitive.

Examples

>>> # Activity report for this library only
>>> pygranta_system_filter = ActivityReportFilter().with_application_name("PyGranta System")
>>> client.get_activity_report_where(pygranta_system_filter)
>>> # Activity report relating to the MI_Training database
>>> mi_training_filter = ActivityReportFilter().with_database_key("MI_Training", exact_match=True)
>>> client.get_activity_report_where(mi_training_filter)
>>> # Activity report for a domain user
>>> domain_user_filter = ActivityReportFilter().with_username("DOMAIN\\user", exact_match=True)
>>> client.get_activity_report_where(domain_user_filter)
>>> # Activity report for edit operations using MI Training database using MI Scripting Toolkit, made last month
>>> first_of_this_month = datetime.date.today().replace(day=1)
>>> last_of_last_month = first_of_this_month - datetime.timedelta(days=1)
>>> first_of_last_month = last_of_last_month.replace(day=1)
>>> combination_filter = (
...     ActivityReportFilter()
...     .with_application_name("Scripting Toolkit")
...     .with_database_key("MI_Training")
...     .with_usage_mode(ActivityUsageMode.EDIT)
...     .with_date_from(first_of_last_month, inclusive=True)
...     .with_date_to(last_of_last_month, inclusive=True)
... )
>>> view_filter.get_activity_report_where(combination_filter)
with_application_name(application_name, exact_match=False)#

Filter based on a single application name used as part of the activity.

For filtering based on multiple applications simultaneously, use the with_application_names() method.

Parameters:
application_namestr

The name of the application used as part of the activity.

exact_matchbool, optional

If true, the application name must match exactly, excluding case sensitivity. Defaults to false, in which case a partial match is allowed.

Returns:
ActivityReportFilter

The current ActivityReportFilter object.

with_application_names(application_names, exact_match=False)#

Filter based on multiple application names used as part of the activity.

For partial filtering based on multiple applications simultaneously, use the with_application_names() method.

Parameters:
application_nameslist of str

The names of applications used as part of the activity.

exact_matchbool, optional

If true, every application name must be involved in the activity for it to be returned. Defaults to false, in which case the activity may contain additional application names not specified here.

Returns:
ActivityReportFilter

The current ActivityReportFilter object.

with_database_key(database_key, exact_match=False)#

Filter based on a database key used as part of the activity.

If database_key = None, then the exact_match argument is ignored.

Parameters:
database_keystr or None

The name of the database key used as part of the activity. To find activities relating to application use only, specify None.

exact_matchbool, optional

If true, the database key must match exactly, excluding case sensitivity. Defaults to false, in which case a partial match is allowed.

Returns:
ActivityReportFilter

The current ActivityReportFilter object.

with_date_from(date_from, inclusive=False)#

Filter based on the earliest allowed date of the activity.

Parameters:
date_fromdatetime.date

The earliest allowed date of the activity.

inclusivebool, optional

If true, activities occurring on the specified date are allowed. Defaults to false, in which case activities occurring on the specified date are not allowed.

Returns:
ActivityReportFilter

The current ActivityReportFilter object.

with_date_to(date_to, inclusive=False)#

Filter based on the latest allowed date of the activity.

Parameters:
date_todatetime.date

The latest allowed date of the activity.

inclusivebool, optional

If true, activities occurring on the specified date are allowed. Defaults to false, in which case activities occurring on the specified date are not allowed.

Returns:
ActivityReportFilter

The current ActivityReportFilter object.

with_usage_mode(usage_mode)#

Filter based on the usage mode of the activity.

Parameters:
usage_modeActivityUsageMode

The usage mode of the activity.

Returns:
ActivityReportFilter

The current ActivityReportFilter object.

with_username(username, exact_match=False)#

Filter based on the username of the user who performed the activity.

Parameters:
usernamestr

The username of the user who performed the activity.

exact_matchbool, optional

If true, the username must match exactly, excluding case sensitivity. Defaults to false, in which case a partial match is allowed.

Returns:
ActivityReportFilter

The current ActivityReportFilter object.

class ActivityItem(activity_date, application_names, username, usage_mode, database_key)#

Describes an activity report item as obtained from the API.

Read-only dataclass - do not directly instantiate or modify instances of this class.

activity_date: date#

The date on which the activity occurred.

application_names: list[str]#

The application or applications used in the activity.

username: str#

The user who performed the activity.

usage_mode: ActivityUsageMode#

The usage mode associated with the activity.

database_key: str | None#

The database key used in the activity.

class ActivityUsageMode(value)#

Usage modes for an activity.

Can be used in ActivityReportFilter.with_usage_mode().

VIEW = 'view'#
EDIT = 'edit'#
class GrantaMIVersion(version, binary_compatibility_version)#

Information about a Granta MI version.

version: tuple[int, ...]#

The full version number as a n-tuple of integers, where n >= 2.

binary_compatibility_version: str#

The binary compatibility version.

property major_minor_version: tuple[int, int]#

The Granta MI version as a 2-tuple of integers. Used to determine API compatibility between versions.

Returns:
tuple of int

The major-minor version as a 2-tuple of ints.