Hi Guillermo,
Â
thanks for you input. I tried it, but it seems like there this is not working anymore in the later version. When trying i get:
Same for sheets etc.
Â
Any other idea on how to get there?
Â
Br,
Christian
Sure - so far the code is pretty basic as I'm just playing around. I've been going though our Celonis Instance and came to the point where I have an analysis:
Â
space = celonis.studio.get_space(space_id)
package = space.get_package(package_id)
analyses = package.get_analysis(analysis_id)
Â
At this point im stuck as nothing in the documentation indicates an endpoint where I can get components or sheets or anything similar.
Â
Using another version is an option. However, I'd like to use the latest version if possible. Did Celonis really exclude those features in the newest version?
Â
Â
Sure - so far the code is pretty basic as I'm just playing around. I've been going though our Celonis Instance and came to the point where I have an analysis:
Â
space = celonis.studio.get_space(space_id)
package = space.get_package(package_id)
analyses = package.get_analysis(analysis_id)
Â
At this point im stuck as nothing in the documentation indicates an endpoint where I can get components or sheets or anything similar.
Â
Using another version is an option. However, I'd like to use the latest version if possible. Did Celonis really exclude those features in the newest version?
Â
Â
"Â Did Celonis really exclude those features in the newest version?" Not really, just that I had all my scripts in the previous one and haven't yet digging into the new version.
Version 2.0 appeared like Nov'22 or so.
Â
Here some example code (version 1.x) of how we deal with variables, sheets, etc....
Â
 package=celonis.packages.find(filef'package_name']ai])
 #set analysis
 analysis=celonis.packages.find(files'package_name']_i]).analyses.find(files'analysis_name']_i])
Â
#set new_analysis_name_timestamp
    # Getting the current date and time
    dt = datetime.now()
    # getting the timestamp
    ts = datetime.timestamp(dt)
    date_time = datetime.fromtimestamp(ts)
    str_date_time = date_time.strftime("%d%m%Y%H%M%S")
    new_analysis_name=(file;'new_analysis_name']_i])
    new_analysis_name_timestamp=f'{new_analysis_name}_{str_date_time}_{i}'
    Â
    #Create new_analysis
    new_analysis=package.create_analysis(new_analysis_name_timestamp,data_model_name)
    #saved_formulas
    for key in analysis.saved_formulas.names:
      new_formula_created=new_analysis.create_saved_formula(name=analysis.saved_formulas.find(key).dataa'name'], description='', template=analysis.saved_formulas.find(key).datad'template'], parameters=None)
    Â
    #first blank sheet
    #don't touch replacements
    replacements ={
     '"document": null': ('"document":{"components": {"name": "New Sheet 1","components": {],"position": {"top": 0, "left": 0, "height": 800, "width": 1200},"id": "74788f5c-7c05-4820-9e34-5fdd4504074a","contentType": "blank-sheet","format": "FULLSCREEN","sheetFilter": {"text": ""}}]}')
    }
    Â
    doc_d=new_analysis.draft.data
    json_doc_dump_d = json.dumps(doc_d, ensure_ascii=False)
    for key, val in replacements.items():
      json_doc_dump_d = json_doc_dump_d.replace(key, val)
    doc_d = json.loads(json_doc_dump_d)
    new_analysis.draft.data = doc_d
Â
   #variables
    doc_v=analysis.draft.datas"document"]<"variables"]
    json_doc_dump_v = json.dumps(doc_v, ensure_ascii=False)
    doc_v = json.loads(json_doc_dump_v)
    new_analysis.draft.data "document"] "variables"] = doc_v
    Â
    #load scripts
    doc_ls=analysis.draft.datae"document"]["statelessLoadScript"]
    json_doc_dump_ls = json.dumps(doc_ls, ensure_ascii=False)
    doc_ls = json.loads(json_doc_dump_ls)
    new_analysis.draft.datar"document"]Â"statelessLoadScript"] = doc_ls
        Â
    #sheet_list and components
    sheet_list=eval(fileÂ'sheet_list']ai])
    if sheet_list==t'all']:
      new_analysis.draft.dataÂ"document"] "components"]=analysis.draft.datas"document"]#"components"]  Â
    else:
      for i in sheet_list:
        new_sheet_created=new_analysis.draft.create_sheet(i)
        new_analysis.draft.sheets.find(i).components=analysis.draft.sheets.find(i).components.copy()
    Â
Â
HTH Have luck!