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(alias='permissions')

tenant_id class-attribute instance-attribute

tenant_id = Field(alias='tenantId')

name class-attribute instance-attribute

name = Field(alias='name')

root_node_key class-attribute instance-attribute

root_node_key = Field(alias='rootNodeKey')

base class-attribute instance-attribute

base = Field(alias='base')

asset_type class-attribute instance-attribute

asset_type = Field(alias='assetType')

node_type class-attribute instance-attribute

node_type = Field(alias='nodeType')

parent_node_key class-attribute instance-attribute

parent_node_key = Field(alias='parentNodeKey')

parent_node_id class-attribute instance-attribute

parent_node_id = Field(alias='parentNodeId')

invalid_content class-attribute instance-attribute

invalid_content = Field(alias='invalidContent')

serialized_content instance-attribute

serialized_content

Serialized content of content node.

serialization_type class-attribute instance-attribute

serialization_type = Field(alias='serializationType')

draft_id class-attribute instance-attribute

draft_id = Field(alias='draftId')

working_draft_id class-attribute instance-attribute

working_draft_id = Field(alias='workingDraftId')

activated_draft_id class-attribute instance-attribute

activated_draft_id = Field(alias='activatedDraftId')

show_in_viewer_mode class-attribute instance-attribute

show_in_viewer_mode = Field(alias='showInViewerMode')

public_available class-attribute instance-attribute

public_available = Field(alias='publicAvailable')

embeddable class-attribute instance-attribute

embeddable = Field(alias='embeddable')

root_node_id class-attribute instance-attribute

root_node_id = Field(alias='rootNodeId')

order class-attribute instance-attribute

order = Field(alias='order')

source class-attribute instance-attribute

source = Field(alias='source')

asset_metadata_transport class-attribute instance-attribute

asset_metadata_transport = Field(
    alias="assetMetadataTransport"
)

change_date class-attribute instance-attribute

change_date = Field(alias='changeDate')

created_by_id class-attribute instance-attribute

created_by_id = Field(alias='createdById')

creation_date class-attribute instance-attribute

creation_date = Field(alias='creationDate')

created_by_name class-attribute instance-attribute

created_by_name = Field(alias='createdByName')

updated_by class-attribute instance-attribute

updated_by = Field(alias='updatedBy')

root class-attribute instance-attribute

root = Field(alias='root')

asset class-attribute instance-attribute

asset = Field(alias='asset')

object_id class-attribute instance-attribute

object_id = Field(alias='objectId')

root_with_key instance-attribute

root_with_key

identifier class-attribute instance-attribute

identifier = Field(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.

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:

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: