system.kanoa.tooling.importTools(paramsDict, userId)
Imports a file from exportTools, all or nothing: if any tool has an error, nothing is written. A tool's location, asset type and family-tool items are matched by path; a missing one is an error. A tooling type in the file that doesn't exist is created (or made a tooling type), with a warning. A cycle rate whose machine is missing, or that its machine refuses, is left off with a warning. Imported tools arrive unmounted with fresh life counts. Run with dryRun first to preview
Parameters
paramsDict Dictionary
| - data | Dictionary or String | The export file - the whole file or just its 'data' - as a dictionary or JSON string |
| - onDuplicate | String | Not required. What to do when a tool with the same name is already in its site: 'rename' (default, imports it as 'name (2)'), 'skip', or 'overwrite' (replaces its fields and positions, keeping which positions are blocked, and sets the file's cycle rates; an error while the tool is mounted) |
| - dryRun | Boolean | Not required. Defaults to True: reports what would happen and writes nothing. Pass False to import |
userId Integer: Id of the user executing the function
Returns
Dictionary {'passed' (Boolean), 'dryRun' (Boolean), 'message' (String), 'results': [{'assetName', 'importedName', 'action' ('create', 'rename', 'overwrite' or 'skip'; None if the tool has errors), 'toolingAssetId' (None in a dry run), 'warnings' (List of String), 'errors' (List of String)}]}
Example
paramsDict = {'data': data, 'onDuplicate': 'rename', 'dryRun': True}
userId = 5
result = system.kanoa.tooling.importTools(paramsDict, userId)
print result['message']