Tm1py: Update rules

Created on 19 Nov 2020  路  3Comments  路  Source: cubewise-code/tm1py

Is there a way to update rules?
I would like to deploy the rules from one instance/server to another. I know how to get the rules, but can I also update them?

question

Most helpful comment

  1. Create an instance of Cube by using the get method on the source TM1 connection
  2. Pass that Cube instance to the update method using the target TM1 connection.
from TM1py.Services import TM1Service


# Establish source TM1 connection
tm1_source = TM1Service()

# Establish Target TM1 connection
tm1_target = TM1Service()

# Get Cube metadata (this includes rules) from the source instance
SourceCubeWithRules = tm1_source.cubes.get('cube_name')

# Update the cube in target instance
tm1_target.cubes.update(SourceCubeWithRules)

All 3 comments

Hi hermie64,

I did it once in same instance. (Probably will work different instances)

This coding will help you;

##Rule Update
#Get SourceCube rule
SourceRule = SourceCube.rules
TargetCube = tm1_target.cubes.get("_Sales")
#Write Source to Target Rule
TargetCube.rules = SourceRule
#Update the Target Rule
tm1_target.cubes.update(TargetCube)

  1. Create an instance of Cube by using the get method on the source TM1 connection
  2. Pass that Cube instance to the update method using the target TM1 connection.
from TM1py.Services import TM1Service


# Establish source TM1 connection
tm1_source = TM1Service()

# Establish Target TM1 connection
tm1_target = TM1Service()

# Get Cube metadata (this includes rules) from the source instance
SourceCubeWithRules = tm1_source.cubes.get('cube_name')

# Update the cube in target instance
tm1_target.cubes.update(SourceCubeWithRules)

That worked, thanks @AliUgurGures and @rkvinoth

Was this page helpful?
0 / 5 - 0 ratings