utils.fact_sheet
Parent class for all fact sheet types. Contains all methods that are identical between all fact sheet types.
Only used internally. To instantiate a fact sheet, use the respective child class, e.g. Application().
Follows the relation specified by key
from the current fact sheet and returns a list of all related fact sheets.
key
can either be the key of a relation, e.g. relApplicationToProcess
, or a fact sheet type, e.g. Process
.
In the latter case, the relation key is derived from the relation model. In case of ambiguous relation keys, a
warning is logged.
This function is usually never called directly. It's rather recommended to directly call fs.key, e.g.
app.processes()
or app.relApplicationToProcess()
.
depending on the usage, this method either loads a single fact sheet or all fact sheets of a certain type.
fs_type
: The fact sheet type to be loaded.
fs_id
: The id of the fact sheet to be loaded (if any, otherwise None
).
filter_list
: List of facet filters. See FactSheet.filter() for documentation.
Returns either the fact sheet (as json response, unprocessed) or the list of fact sheets (equally unprocessed).
All responses are harmonized to turn them into a more useful and "pythonic" data structure.
Careful when using this: It returns a list of all fact sheets in the workspace, so this can be huge.
Can be used to remove all demo fact sheets from a new workspace:
for fs in FactSheet.all():
fs.archive()
Returns a list of all fact sheets that match the facet filters.
Checks if a fact sheet type has already been loaded to the cache. If not, it loads all fact sheets of this type via self.load() and instantiates them, which stores them in the cache.
fs_type
: The fact sheet type, such as application.Application
. If None
: Load all fact sheets of all types.
Returns a list of all instances of the given fact sheet type.
force
: If set to True
, reload all fact sheets from LeanIX, even if this fact sheet type has already been
loaded.
Returns a list of all parent fact sheets of this fact sheet. This list usually contains only one element.
Creates a new fact sheet. name
is mandatory, description
, tags
and lifecycle
are optional.
tags
example: {"TagGroup": ["Tag 1", "Tag 2"...]}
lifecycle
example: {"plan": "2020-01-31", "phaseIn": "2021-01-31", "active": "2022-01-31",
"phaseOut": "2023-01-31", "endOfLife": "2024-01-31"}
Please ignore the trailing underscore "_", the method is called archive(...)
.
This documentation entry is just there to inform you that you can call archive
on both the FactSheet class
but also on an instance.
Examples:
FactSheet.archive("fac7f0a6-88be-49fd-8935-1fde3edd335d", "Fact sheet was redundant")
Application("My test application").archive("Fact sheet was redundant")
Please ignore the trailing underscore "_", the method is called restore(...)
.
This documentation entry is just there to inform you that you can call restore
on both the FactSheet class
but also on an instance.
Examples:
FactSheet.restore("fac7f0a6-88be-49fd-8935-1fde3edd335d", "Fact sheet was archived mistakenly")
Application("My test application").restore("Fact sheet was archived mistakenly")
This documentation entry is just there to inform you that you can call archive
on both the FactSheet class
but also on an instance.
Examples:
FactSheet.archive("fac7f0a6-88be-49fd-8935-1fde3edd335d", "Fact sheet was redundant")
Application("My test application").archive("Fact sheet was redundant")
This documentation entry is just there to inform you that you can call restore
on both the FactSheet class
but also on an instance.
Examples:
FactSheet.restore("fac7f0a6-88be-49fd-8935-1fde3edd335d", "Fact sheet was archived mistakenly")
Application("My test application").restore("Fact sheet was archived mistakenly")
Subscribes a user to a fact sheet.
user_id_or_email
is the user ID or e-mail address of the user to be subscribed.
subscription_type
is the role type to subscribe. Default: "RESPONSIBLE"
role_name
is The role name to be subscribed. Default: None
.
comment
is the comment to be added to the subscription. Default: Empty.
If a subscription of this user in this role_name
already exists, the comment is updated.
Returns the ["data"]
part of the API response object.
Updates the comment of an existing subscription given by the user, subscription_type and role_name.
Deletes a subscription.
Needs at least one of the following parameters to identify the subscription: subscription_id
,
subscription_user_id
, user_email
.
In case you want to delete only an individual role within the subscription and not the entire subscription
for this user, you can use the optional parameters role
and subscription_type
to specify the role you want
to delete. If you do this, please note: If you are deleting an individual role from - say - a RESPONSIBLE
subscription, and it's the last role in that subscription, you will end up with an empty RESPONSIBLE
subscription, which is maybe not what you expect.
To delete the entire subscription when the last role was deleted, set
options={"delete_entire_subscription_if_last_role_is_removed": True}
Creates a relation to another fact sheet. target
is a fact sheet, attributes
are the attributes
on the relation. If there are multiple relation types between the two fact sheet types, you need to
specify rel_type
, e.g. relApplicationToUserGroup
. All valid relation types can be found in your
auto-generated utils/ws_[workspace_name]/fact_sheet_types.py
.
Returns False
if the relation already exists, so that you don't need to .reload() after calling.
Example:
app = Application("My Application")
ug = UserGroup("My User Group")
attributes = {
"usageType": "owner",
"numberOfUsers": 101,
"functionalSuitability": "insufficient",
"description": r"This is a description.\nAnd this is line 2 of the description.",
"activeFrom": "2022-07-20",
"activeUntil": "2022-07-21"
}
app.create_relation(ug, attributes)
Example including relation type:
app = Application("My Application")
provider = Provider("My Provider")
attributes = {}
app.create_relation(ug, attributes, "relToRequires")
Deletes the relation between this fact sheet and the target
.
If there are multiple relation types between the two fact sheet types, you need to
specify rel_type
, e.g. relApplicationToUserGroup
. All valid relation types can be found in your
auto-generated utils/ws_[workspace_name]/fact_sheet_types.py
.
Example:
app = Application("My Application")
ug = UserGroup("My User Group")
app.delete_relation(ug)
Updates the relation between this fact sheet and the target
.
If there are multiple relation types between the two fact sheet types, you need to
specify rel_type
, e.g. relApplicationToUserGroup
. All valid relation types can be found in your
auto-generated utils/ws_[workspace_name]/fact_sheet_types.py
.
Note that if you omit any already existing attributes in the attributes
parameter, their values will not
be changed.
Example:
app = Application("My Application")
ug = UserGroup("My User Group")
attributes = {
"numberOfUsers": 201,
"description": "This is a new description."
}
# only updates the attributes "numberOfUsers" and "description".
app.update_relation(ug)
Replaces the target of an existing relation to the current fact sheet target
to the new fact sheet new_target
while keeping all of its relation attributes.
Returns the relation between this fact sheet and the target
. This is a convenience function to
access the attributes on the relation in an easy way.
If there are multiple relation types between the two fact sheet types, you need to
specify rel_type
, e.g. relApplicationToUserGroup
. All valid relation types can be found in your
auto-generated utils/ws_[workspace_name]/fact_sheet_types.py
. If you do not specify a relation type,
it will return the first relation that it finds. It will, however, not scan relToRequires and relToRequiredBy.
Example:
app = Application("My Application")
ug = UserGroup("My User Group")
rel = app.get_relation(ug)
print(rel["description"])
print(rel["activeFrom"])
Returns the first relation of this fact sheet to any target fact sheet with fact sheet type = fs_type
or
with relation type = rel_type
where the relation attribute given by the key in the match
dict matches the
value given by match[key].
Example - finding the owning user group of an application:
app.get_matching_relation("UserGroup", {"usageType", "owner"})
Adds a resource to a fact sheet. resourceType
needs to be a valid resource type as defined in LeanIX.
Example:
app.add_resource("My resource", "https://example.com/resource.html", "documentation", "My description")
Deletes the resource with the given resource_id
this fact sheet.
Gets all log events for this fact sheet.
Returns the ["data"]
part of the API response object.
Reloads this fact sheet from LeanIX. Reloading is not done automatically due to performance reasons,
so it can be done explicitly if required.
Example:
app.reload()
Sets (or breaks) the quality seal.
Possible values for status
: "APPROVED" (default), "DRAFT", "REJECTED", "BROKEN_QUALITY_SEAL"
Returns the URL that points to this fact sheet, including FQDN. Used in auto-generated e-mails.
Returns language-specific help texts and labels for a fact sheet field.
Updates a fact sheet field.
update
parameter is a dict with keys name
(field to update) and value
(new value of the field).
Examples:
application = Application("...")
application.update_field({"name": "/name", "value": "New name"})
application.update_field({"name": "/description", "value": "New description"})
application.update_field({"name": "/lifecycle", "value": {"phaseIn": "2020-01-01", "active": "2022-03-03"}})
application.update_field({"name": "/functionalSuitability", "value": "insufficient")
application.update_field({"name": "/technicalSuitability", "value": "adequate")