Skip to content

package

Module to interact with Packages.

This module contains class to interact with Packages in Studio.

Typical usage example:

```python
package = space.get_package(PACKAGE_ID)
package = space.create_package("NEW_PACKAGE")
package.publish()

package_history = package.get_history()
package.delete()
```

Package

Bases: ContentNode

Package object to interact with package specific studio endpoints.

permissions class-attribute instance-attribute

permissions = Field(None, alias='permissions')

tenant_id class-attribute instance-attribute

tenant_id = Field(None, alias='tenantId')

name class-attribute instance-attribute

name = Field(None, alias='name')

root_node_key instance-attribute

root_node_key

Key of root content node.

base class-attribute instance-attribute

base = Field(None, alias='base')

asset_type class-attribute instance-attribute

asset_type = Field(None, alias='assetType')

node_type class-attribute instance-attribute

node_type = Field(None, alias='nodeType')

parent_node_key class-attribute instance-attribute

parent_node_key = Field(None, alias='parentNodeKey')

parent_node_id class-attribute instance-attribute

parent_node_id = Field(None, alias='parentNodeId')

invalid_content class-attribute instance-attribute

invalid_content = Field(None, alias='invalidContent')

serialized_content instance-attribute

serialized_content

Serialized content of content node.

serialization_type class-attribute instance-attribute

serialization_type = Field(None, alias='serializationType')

draft_id class-attribute instance-attribute

draft_id = Field(None, alias='draftId')

working_draft_id class-attribute instance-attribute

working_draft_id = Field(None, alias='workingDraftId')

activated_draft_id class-attribute instance-attribute

activated_draft_id = Field(None, alias='activatedDraftId')

show_in_viewer_mode class-attribute instance-attribute

show_in_viewer_mode = Field(None, alias='showInViewerMode')

public_available class-attribute instance-attribute

public_available = Field(None, alias='publicAvailable')

embeddable class-attribute instance-attribute

embeddable = Field(None, alias='embeddable')

root_node_id instance-attribute

root_node_id

Id of of root content node.

order class-attribute instance-attribute

order = Field(None, alias='order')

source class-attribute instance-attribute

source = Field(None, alias='source')

asset_metadata_transport class-attribute instance-attribute

asset_metadata_transport = Field(
    None, alias="assetMetadataTransport"
)

change_date class-attribute instance-attribute

change_date = Field(None, alias='changeDate')

created_by_id class-attribute instance-attribute

created_by_id = Field(None, alias='createdById')

creation_date class-attribute instance-attribute

creation_date = Field(None, alias='creationDate')

created_by_name class-attribute instance-attribute

created_by_name = Field(None, alias='createdByName')

updated_by class-attribute instance-attribute

updated_by = Field(None, alias='updatedBy')

root class-attribute instance-attribute

root = Field(None, alias='root')

asset class-attribute instance-attribute

asset = Field(None, alias='asset')

object_id class-attribute instance-attribute

object_id = Field(None, alias='objectId')

root_with_key instance-attribute

root_with_key

identifier class-attribute instance-attribute

identifier = Field(None, alias='identifier')

client class-attribute instance-attribute

client = Field(..., exclude=True)

id instance-attribute

id

Id of package.

key instance-attribute

key

Key of package.

space_id instance-attribute

space_id

Id of space where package is located.

from_transport classmethod

from_transport(client, content_node_transport)

Creates high-level content node object from given ContentNodeTransport.

Parameters:

  • client (Client) –

    Client to use to make API calls for given content node.

  • content_node_transport (ContentNodeTransport) –

    ContentNodeTransport object containing properties of content node.

Returns:

  • ContentNode

    A ContentNode object with properties from transport and given client.

copy_to

copy_to(
    destination_package,
    destination_team_domain,
    overwrite=False,
    delete_source=False,
    **kwargs
)

Copies a content node to the specified domain and package in the same realm (ex. eu-1).

Parameters:

  • destination_package (Package) –

    The Package object to copy the asset to.

  • destination_team_domain (str) –

    The of the destination team url: https://..celonis.cloud/

  • overwrite (bool, default: False ) –

    If true, any node with the same key will be overwritten. If false, a PyCelonisNodeAlreadyExistsError will be raised.

  • delete_source (bool, default: False ) –

    If true, deletes the node from the source. If false, keeps the source node.

  • **kwargs (Any, default: {} ) –

    Additional parameters set for ContentNodeCopyTransport

Returns:

Examples:

Copy a package:

package = space.get_package(<package_id>)
new_package = space.create_package("NEW_PACKAGE")
new_package.publish()
copied_package_transport = package.copy_to(new_package, <destination_team_domain>)

Copy a package asset:

new_package = space.create_package("NEW_PACKAGE")
copied_analysis_transport = analysis.copy_to(
    new_package, <destination_team_domain>
)

is_package staticmethod

is_package(content_node_transport)

Returns whether content node transport is package.

Parameters:

Returns:

  • bool

    Boolean if transport is package.

is_folder staticmethod

is_folder(content_node_transport)

Returns whether content node transport is package.

Parameters:

Returns:

  • bool

    Boolean if transport is folder.

is_analysis staticmethod

is_analysis(content_node_transport)

Returns whether content node transport is analysis.

Parameters:

Returns:

  • bool

    Boolean if transport is analysis.

is_knowledge_model staticmethod

is_knowledge_model(content_node_transport)

Returns whether content node transport is knowledge model.

Parameters:

Returns:

  • bool

    Boolean if transport is knowledge model.

is_action_flow staticmethod

is_action_flow(content_node_transport)

Returns whether content node transport is action flow.

Parameters:

Returns:

  • bool

    Boolean if transport is action flow.

is_view staticmethod

is_view(content_node_transport)

Returns whether content node transport is view.

Parameters:

Returns:

  • bool

    Boolean if transport is view.

is_simulation staticmethod

is_simulation(content_node_transport)

Returns whether content node transport is simulation.

Parameters:

Returns:

  • bool

    Boolean if transport is simulation.

is_skill staticmethod

is_skill(content_node_transport)

Returns whether content node transport is skill.

Parameters:

Returns:

  • bool

    Boolean if transport is skill.

update

update()

Updating packages is not supported by EMS.

sync

sync()

Syncs package properties with EMS.

delete

delete()

Deletes package.

publish

publish(version=None, node_ids_to_exclude=None)

Publishes package with given version.

Parameters:

  • version (Optional[str], default: None ) –

    Version to publish package with. Has to be of format X.X.X. By default gets next package version.

  • node_ids_to_exclude (Optional[List[str]], default: None ) –

    Nodes to exclude from publishing.

Examples:

Publish new version of package:

package.publish()
Publish new version of package with set version and exclude certain nodes from publishing:
folder = package.get_folder("<folder_id>")
package.publish(version="1.0.0", node_ids_to_exclude=[folder.id])

get_history

get_history()

Returns package history of all published versions.

Returns:

load_version

load_version(version, root_draft_id)

Loads previously published package version.

Parameters:

  • version (str) –

    Version to load.

  • root_draft_id (str) –

    Draft id of version to load (can be found in package history).

create_variable

create_variable(key, value, type_, runtime=True, **kwargs)

Creates new variable for given package.

Parameters:

  • key (str) –

    Key of variable.

  • value (str) –

    Value to be set for variable.

  • type_ (str) –

    Type of variable, e.g. 'DATA_MODEL'.

  • runtime (bool, default: True ) –

    If true, variable can be referenced inside Knowledge Models and Views, and the value can be actively changed from the publishing App in Apps.

  • **kwargs (Any, default: {} ) –

    Additional parameters set for VariableDefinitionWithValue object.

Returns:

  • Variable

    A variable object for newly created variable.

Examples:

Create data model variable:

data_model_variable = package.create_variable(
    key="pycelonis_tutorial_data_model",
    value=data_model.id,
    type_="DATA_MODEL"
)

get_variables

get_variables(type_=None)

Returns variables located in given package.

Parameters:

  • type_ (Optional[str], default: None ) –

    If set, only variables of given type are returned.

Returns:

get_variable

get_variable(key)

Gets variable located in package with given key.

Parameters:

  • key (str) –

    Key of variable.

Returns:

  • Variable

    A Variable object for variable with given key.

Raises:

get_content_node

get_content_node(id_)

Gets content node located in package with given id.

Parameters:

  • id_ (str) –

    Id of content node.

Returns:

  • ContentNode

    A ContentNode object for content node with given id.

Raises:

get_content_nodes

get_content_nodes(asset_type=None, node_type=None)

Gets all content nodes of given package.

Returns:

get_action_flow

get_action_flow(id_)

Gets action flow of given package.

Parameters:

  • id_ (str) –

    Id of action flow.

Returns:

get_action_flows

get_action_flows()

Gets all action flows of given package.

Returns:

create_analysis

create_analysis(
    name,
    key=None,
    data_model_id=None,
    change_default_event_log=False,
    **kwargs
)

Creates new analysis with name in given package.

Parameters:

  • name (str) –

    Name of new analysis.

  • key (Optional[str], default: None ) –

    Key of new analysis. Defaults to name.

  • data_model_id (Optional[str], default: None ) –

    Id of data model to use.

  • change_default_event_log (bool, default: False ) –

    Whether to change default event log or not.

Returns:

  • Analysis

    An analysis object for newly created analysis.

Examples:

Create empty analysis with reference to data model:

data_model_variable = package.create_variable(
    key="data_model_variable",
    value=data_model.id,
    type_="DATA_MODEL"
)

analysis = package.create_analysis(
    name="Analysis",
    data_model_id=f"${{{{{data_model_variable.key}}}}}"
)

get_analysis

get_analysis(id_)

Gets analysis of given package.

Parameters:

  • id_ (str) –

    Id of analysis.

Returns:

get_analyses

get_analyses()

Gets all analyses of given package.

Returns:

create_folder

create_folder(name, key=None, **kwargs)

Create new folder with name in given package.

Parameters:

  • name (str) –

    Name of new folder.

  • key (Optional[str], default: None ) –

    Key of new folder. Defaults to name.

  • **kwargs (Any, default: {} ) –

    Additional parameters set for SaveContentNodeTransport object.

Returns:

  • Folder

    A Folder object for newly created folder.

Examples:

Create empty folder:

folder = package.create_folder(name="Folder", key="folder")

get_folder

get_folder(id_)

Get folder of given package.

Parameters:

  • id_ (str) –

    Id of folder.

Returns:

  • Folder

    Folder with given id.

get_folders

get_folders()

Get all folders of given package.

Returns:

create_knowledge_model

create_knowledge_model(
    content,
    with_autogenerated_data_model_data=True,
    with_variable_replacement=True,
)

Creates new knowledge model in given package.

Parameters:

  • content (Dict) –

    Content of new knowledge model.

  • with_autogenerated_data_model_data (bool, default: True ) –

    Defines whether automatically generated records and kpis are added.

  • with_variable_replacement (bool, default: True ) –

    Defines whether used variables are replaced automatically.

Returns:

  • KnowledgeModel

    A KnowledgeModel object for newly created knowledge model.

Examples:

Create empty knowledge model with new data model variable:

data_model_variable = package.create_variable(
    key="data_model_variable",
    value=data_model.id,
    type_="DATA_MODEL"
)

content = {
    "kind" : "BASE",
    "metadata" : {"key":"knowledge_model_key", "displayName":"Test Knowledge Model"},
    "dataModelId" : f"${{{{{data_model_variable.key}}}}}"
}
knowledge_model = package.create_knowledge_model(content)

get_knowledge_model

get_knowledge_model(id_)

Gets knowledge_model of given package.

Parameters:

  • id_ (str) –

    Id of knowledge_model.

Returns:

get_knowledge_models

get_knowledge_models()

Gets all knowledge models of given package.

Returns:

get_simulation

get_simulation(id_)

Gets simulation of given package.

Parameters:

  • id_ (str) –

    Id of simulation.

Returns:

get_simulations

get_simulations()

Gets all simulations of given package.

Returns:

get_skill

get_skill(id_)

Gets skill of given package.

Parameters:

  • id_ (str) –

    Id of skill.

Returns:

  • Skill

    Skill with given id.

get_skills

get_skills()

Gets all skills of given package.

Returns:

create_view

create_view(
    name,
    key=None,
    knowledge_model_key=None,
    base_key=None,
    board_asset_type=BoardAssetType.BOARD,
    template=False,
    allow_advanced_filters=True,
    app_store_based=False,
    **kwargs
)

Creates new view with name in given package.

Parameters:

  • name (str) –

    name for the view

  • key (Optional[str], default: None ) –

    key for the view that is going to be created

  • knowledge_model_key (Optional[str], default: None ) –

    knowledge model key if you want to link it to the view during creation

  • base_key (Optional[str], default: None ) –

    to create an extended view defines the base view key for linking

  • allow_advanced_filters (bool, default: True ) –

    toggle to make the view allow advanced filters

Returns:

  • View

    An view object for newly created view.

Examples:

Create an empty view:

    view = package.create_view(
        name="TEST_VIEW"
    )

get_view

get_view(id_)

Gets view of given package.

Parameters:

  • id_ (str) –

    Id of view.

Returns:

  • View

    View with given id.

get_views

get_views()

Gets all views of given package.

Returns: