mstrio.object_management.migration package¶
Submodules¶
mstrio.object_management.migration.migration module¶
—————— WORK IN PROGRESS ——————
In a current version, is available as a Functionality Preview. It is subject to change until it is released as Generally Available.
- class mstrio.object_management.migration.migration.Migration(save_path: Optional[str] = '/Users/ujaczewska/PycharmProjects/mstrio-py/production/migration.mmp', source_connection: Optional[Connection] = None, configuration: Optional[PackageConfig] = None, target_connection: Optional[Connection] = None, custom_package_path: Optional[str] = None, name: Optional[str] = None, create_undo: bool = True)¶
Bases:
Dictable
,ProgressBarMixin
A class encapsulating migration process from env A to env B.
Raises VersionException if either of environments are running IServer version lower than 11.3.0200
Raises AttributeError if parent directory of specified save_path is non-existent or points to another kind of file.
- configuration¶
a configuration of the migration
- Type:
- save_path¶
a full path used when saving import package to a
- Type:
str
- file. It is also used for saving undo package with the addition of
- `_undo` suffix. By default, uses ~cwd/migration.mmp and
- ~cwd/migration_undo.mmp.
- source_connection¶
A MicroStrategy connection object to the source env,
- Type:
- target_connection¶
A MicroStrategy connection object to the target env,
- Type:
- name¶
Name of the migration. Used for identification purposes for the convenience of the user,
- Type:
str
- package_import¶
a package import process object,
- Type:
- package_binary¶
actual data that is migrated
- Type:
Binary
- status¶
current status of migration,
- Type:
- create_undo¶
should a undo package be made
- Type:
bool
- undo_package¶
undo package binary for this import process. if create_undo is False, it is equal to None.
- Type:
Binary
- Additional args:
- custom_package_path(str): a full path to an already existing .mpp file.
This argument overrides save_path. Creating a Migration object with only source_connection, target_connection and custom_package_path allows for an easier export to the target by running migrate_package() on that Migration instance (instead of performing full migration with an import from the source first. See demos and examples for details.).
- create_package() bool ¶
Performs import of the object described in the migration configuration from the source environment and save it in a file at location specified in save_path parameter.
Raises AttributeError if source_connection is not specified.
Raises FileExistsError if a package or undo package with the same name already exist at`save_path` location.
- migrate_package(custom_package_path: Optional[str] = None, is_undo=False) bool ¶
Performs migration of already created package to the target environment. Import package will be loaded from custom_package_path. If custom_package_path not provided, the object previously acquired with the create_package() will be used. If create_undo parameter is set to True, package needed for undo process will be downloaded.
Raises AttributeError if target_connection is not specified.
- perform_full_migration() bool ¶
Perform ‘create_package()’ and ‘migrate_package()’ using configuration provided when creating Migration object.
- undo_migration()¶
Revert the migration using the package downloaded during migrate_package() or perform_full_migration().
Raises AttributeError if undo_binary is None.
- class mstrio.object_management.migration.migration.MigrationStatus(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)¶
Bases:
Enum
- CREATING_PACKAGE = 3¶
- CREATING_PACKAGE_COMPLETED = 5¶
- CREATING_PACKAGE_FAILED = 4¶
- MIGRATION_COMPLETED = 8¶
- MIGRATION_FAILED = 7¶
- MIGRATION_IN_PROGRESS = 6¶
- NOT_STARTED = 1¶
- STARTED = 2¶
- UNDO_COMPLETED = 11¶
- UNDO_FAILED = 10¶
- UNDO_STARTED = 9¶
- mstrio.object_management.migration.migration.bulk_full_migration(migrations: Union[Migration, List[Migration]], verbose: bool = False)¶
Run perform_full_migration() for each of the migrations provided. :param migrations: migrations to be executed :param verbose: if True, information about each step will be printed
- mstrio.object_management.migration.migration.bulk_migrate_package(migrations: Union[Migration, List[Migration]], verbose: bool = False)¶
Run migrate_package() for each of the migrations provided. :param migrations: migrations to be executed :param verbose: if True, information about each step will be printed
mstrio.object_management.migration.package module¶
—————— WORK IN PROGRESS ——————
In a current version, is available as a Functionality Preview. It is subject to change until it is released as Generally Available.
- class mstrio.object_management.migration.package.Package(connection: Connection, id: str)¶
Bases:
EntityBase
,DeleteMixin
Object representation of MicroStrategy Package object.
- connection¶
a MicroStrategy connection object
- Type:
- id¶
package ID
- Type:
str
- status¶
status of a package
- Type:
str
- settings¶
settings details of package
- Type:
- content¶
content details of package
- Type:
- classmethod create(connection: Connection, progress_bar: bool = False)¶
Create a Package object.
- Parameters:
connection – MicroStrategy connection object returned by connection.Connection()
progress_bar – boolean value that decides whether a progress bar will be displayed. defaults to False
- Returns:
A Package object.
- download_package_binary(progress_bar: bool = False) bytes ¶
Downloads a binary of a package.
- Parameters:
progress_bar – boolean value that decides whether a progress bar will be displayed. defaults to False
- Returns:
Contents of the downloaded binary of the package.
- update_config(package_config: PackageConfig)¶
Updates the config for the Package.
- Parameters:
package_config – new configuration to be updated for the Package
- Returns:
A boolean value of whether the update was successful.
- upload_package_binary(package_binary: bytes, progress_bar: bool = False)¶
Uploads a binary of a package.
- Parameters:
package_binary – binary of the package to be uploaded
progress_bar – boolean value that decides whether a progress bar will be displayed. defaults to False
- class mstrio.object_management.migration.package.PackageConfig(type: PackageUpdateType, settings: PackageSettings, content: Union[List[PackageContentInfo], PackageContentInfo])¶
Bases:
Dictable
Package Update Data Transfer Object
- type¶
type of package update
- Type:
- settings¶
settings details of package
- Type:
- content¶
content details of package
- Type:
- class PackageUpdateType(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)¶
Bases:
AutoName
Package update type: PROJECT: For user’s input, only accept non configuration object. But
the actual package contains all kinds of objects, including configuration objects.
- CONFIGURATION: Only contains configuration objects. 12 types in total,
including “Database connection“, “Transmitter“, “Database Instance“, “Database login“, “DBMS“, “Device“, “Event“, ”Language”, “Schedule“, ”Security Role”,”User”, “User group“.
PROJECT_SECURITY: Only contains user objects.
- CONFIGURATION = 'configuration'¶
- PROJECT = 'project'¶
- PROJECT_SECURITY = 'project_security'¶
- class mstrio.object_management.migration.package.PackageContentInfo(id: str, action: Union[Action, str] = Action.USE_EXISTING, name: Optional[str] = None, version: Optional[str] = None, type: Optional[ObjectTypes] = None, owner: Optional[Owner] = None, date_created: Optional[str] = None, date_modified: Optional[str] = None, include_dependents: Optional[bool] = None, explicit_included: Optional[bool] = None, level: Optional[Union[Level, str]] = None)¶
Bases:
Dictable
Object representation of package content information
- id¶
object ID
- Type:
str
- name¶
object name
- Type:
Optional[str]
- version¶
object version
- Type:
Optional[str]
- type¶
object type
- Type:
Optional[ObjectTypes]
- date_created¶
object creation date
- Type:
Optional[str]
- date_modified¶
object modification date
- Type:
Optional[str]
- include_dependents¶
whether include the dependents for this object or not
- Type:
Optional[bool]
- explicit_included¶
whether explicitly included or not
- Type:
Optional[bool]
- class Action(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)¶
Bases:
AutoName
The default action used for objects which don’t have actions explicitly, for example the dependents objects. USE_EXISTING: No change is made to the destination object. The source object is not copied. REPLACE: The destination object is replaced with the source object. Note the following:
If the conflict type is Exists identically except for path, or
Exists identically except for Distribution Services objects, the destination object is updated to reflect the path or Distribution Services addresses and contacts of the source object. • Replace moves the object into the same parent folder as source object. If the parent path is the same between source and destination but the grandparent path is different, Replace may appear to do nothing because Replace puts the object into the same parent path. • Non-empty folders in the destination location will never have the same version ID and modification time as the source, because the folder is copied first and the objects are added to it, thus changing version ID and modification times during the copy process.
KEEP_BOTH: No change is made to the destination object. The source object is duplicated if destination object doesn’t exist. But if the destination object exists with the same id and same version, this source object is ignored.If the destination object exists with the same id and different version, this source object is saved as new object. USE_NEWER: If the source object’s modification time is more recent than the destination object’s, the Replace action is used.Otherwise, the Use existing action is used. USE_OLDER: If the source object’s modification time is more recent than the destination object’s, the Use existing action is used. Otherwise, the Replace action is used. FORCE_REPLACE: Replace the object in the destination project with the version of the object in the update package, even if both versions of the object have the same Version ID. DELETE: Delete the object from the destination project. The version of the object in the update package is not imported into the destination project.Warning: If the object in the destination has any used-by dependencies when you import the update package, the import will fail. FORCE_KEEP_BOTH: No change is made to the destination object. The source object is always saved as a new object.
- DELETE = 'delete'¶
- FORCE_KEEP_BOTH = 'force_keep_both'¶
- FORCE_REPLACE = 'force_replace'¶
- KEEP_BOTH = 'keep_both'¶
- REPLACE = 'replace'¶
- USE_EXISTING = 'use_existing'¶
- USE_NEWER = 'use_newer'¶
- USE_OLDER = 'use_older'¶
- class Level(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)¶
Bases:
AutoName
- CONFIGURATION_OBJECT = 'configuration_object'¶
- PROJECT_OBJECT = 'project_object'¶
- UNKNOWN = 'unknown'¶
- class Owner(id: str, connection: Optional[Connection] = None)¶
Bases:
User
This class overrides from_dict() and __init__() methods as PackageContentInfo inherits from Dictable and not EntityBase. Therefore, despite Owner being a User, connection param here is optional. If connection is specified, User constructor will be used
- classmethod from_dict(source: Dict[str, Any], connection: Optional[Connection] = None)¶
- Overrides Dictable.from_dict() to instantiate an object from
a dictionary without calling any additional getters.
- Parameters:
cls (T) – Class (type) of an object that should be created.
source (Dict[str, Any]) – a dictionary from which an object will be constructed.
connection (Connection) – A MicroStrategy Connection object.
to_snake_case (bool, optional) – Set to True if attribute names
True. (should be converted from camel case to snake case. Defaults to) –
- Returns:
An object of type T.
- Return type:
T
- class mstrio.object_management.migration.package.PackageImport(connection: Connection, id: str)¶
Bases:
EntityBase
,DeleteMixin
Object representation of MicroStrategy PackageImportProcess object.
- connection¶
A MicroStrategy connection object
- Type:
- id¶
PackageImport ID
- Type:
str
- status¶
status of an import
- Type:
str
- undo_package_created¶
if the undo package have been created
- Type:
bool
- progress¶
progress of package import process
- Type:
int
- classmethod create(connection: Connection, package_id: str, generate_undo: bool, progress_bar=False)¶
Create a package import process.
- Parameters:
connection – MicroStrategy connection object returned by connection.Connection().
package_id – ID of the package that is to be imported
generate_undo – boolean value that specifies whether an undo package has to also be created
progress_bar – boolean value that decides whether a progress bar will be displayed. defaults to False
- Returns:
A PackageImport object.
- download_undo_binary(progress_bar=False)¶
Download undo package binary for this import process.
Args: progress_bar: boolean value that decides whether a progress bar will
be displayed. defaults to False
- Returns:
Contents of the Response object containing all of the information
returned by the server.
- class mstrio.object_management.migration.package.PackageSettings(default_action: DefaultAction = DefaultAction.USE_EXISTING, update_schema: Optional[UpdateSchema] = None, acl_on_replacing_objects: Optional[AclOnReplacingObjects] = None, acl_on_new_objects: Optional[AclOnNewObjects] = None)¶
Bases:
Dictable
Object representation of package settings details.
- default_action¶
default action for Package
- Type:
- update_schema¶
update_schema for Package
- Type:
Optional[UpdateSchema]
- acl_on_replacing_objects¶
ACL setting on replacing objects
- Type:
Optional[AclOnReplacingObjects]
- acl_on_new_objects¶
ACL setting on new objects
- Type:
Optional[AclOnNewObjects]
- class AclOnNewObjects(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)¶
Bases:
AutoName
If you add a new object to the destination project with the “Create New” or “Keep Both action”, you can choose to have the object inherit its ACL from the destination folder instead of keeping its own ACL. This is helpful when copying an object into a user’s profile folder, so that the user can have full control over the object.
- INHERIT_ACL_AS_DEST_FOLDER = 'inherit_acl_as_dest_folder'¶
- KEEP_ACL_AS_SOURCE_OBJECT = 'keep_acl_as_source_object'¶
- class AclOnReplacingObjects(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)¶
Bases:
AutoName
If you resolve a conflict with the “Replace” action, and the access control lists (ACL) of the objects are different between the two projects, you can choose whether to keep the existing ACL in the destination project or replace it with the ACL from the source project. Note: This is not supported for project security packages.
- REPLACE = 'replace'¶
- USE_EXISTING = 'use_existing'¶
- class DefaultAction(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)¶
Bases:
AutoName
The default action used for objects which don’t have actions explicitly, for example the dependents objects. USE_EXISTING: No change is made to the destination object. The source object is not copied. REPLACE: The destination object is replaced with the source object. Note the following:
If the conflict type is Exists identically except for path, or
Exists identically except for Distribution Services objects, the destination object is updated to reflect the path or Distribution Services addresses and contacts of the source object. • Replace moves the object into the same parent folder as source object. If the parent path is the same between source and destination but the grandparent path is different, Replace may appear to do nothing because Replace puts the object into the same parent path. • Non-empty folders in the destination location will never have the same version ID and modification time as the source, because the folder is copied first and the objects are added to it, thus changing version ID and modification times during the copy process.
KEEP_BOTH: No change is made to the destination object. The source object is duplicated if destination object doesn’t exist. But if the destination object exists with the same id and same version, this source object is ignored.If the destination object exists with the same id and different version, this source object is saved as new object. USE_NEWER: If the source object’s modification time is more recent than the destination object’s, the Replace action is used.Otherwise, the Use existing action is used. USE_OLDER: If the source object’s modification time is more recent than the destination object’s, the Use existing action is used. Otherwise, the Replace action is used. FORCE_REPLACE: Replace the object in the destination project with the version of the object in the update package, even if both versions of the object have the same Version ID. DELETE: Delete the object from the destination project. The version of the object in the update package is not imported into the destination project.Warning: If the object in the destination has any used-by dependencies when you import the update package, the import will fail. FORCE_KEEP_BOTH: No change is made to the destination object. The source object is always saved as a new object.
- DELETE = 'delete'¶
- FORCE_KEEP_BOTH = 'force_keep_both'¶
- FORCE_REPLACE = 'force_replace'¶
- KEEP_BOTH = 'keep_both'¶
- REPLACE = 'replace'¶
- USE_EXISTING = 'use_existing'¶
- USE_NEWER = 'use_newer'¶
- USE_OLDER = 'use_older'¶
- class UpdateSchema(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)¶
Bases:
AutoName
They allow you to configure the package to automatically perform certain schema update functions. These options can be useful if you make any changes to schema objects. Use the recalculate table keys and fact entry levels if you changed the key structure of a table or if you changed the level at which a fact is stored.Use the recalculate table logical sizes to override any modifications that you have made to logical table sizes. (Logical table sizes affect how the MicroStrategy SQL Engine determines which tables to use in a query.)
- RECAL_TABLE_KEYS_FACT_ENTRY_LEVEL = 'recal_table_keys_fact_entry_level'¶
- RECAL_TABLE_LOGICAL_SIZE = 'recal_table_logical_size'¶