def import_schema(self, path, *, title=None, target_data_model=None): """Import schema file from path Sisense does not support this in Windows Can be used to update an existing data model by adding it to target data model. To add a new model with a new title import_schema(path, title='New Title') To update an existing model import_schema(path, target_data_model=old_data_model) If updating an existing data model, no modifications to title will happen. Args: path: The path to the schema smodel file title: (Optional) Title to give the data model target_data_model: (Optional) The data model to update. """ PySenseUtils.validate_version(self, SisenseVersion.Version.LINUX, 'import_schema') target_data_model_id = target_data_model.get_oid( ) if target_data_model is not None else None query_params = {'title': title, 'datamodelId': target_data_model_id} data_model_json = self.connector.rest_call( 'post', 'api/v2/datamodel-imports/schema', query_params=query_params, json_payload=PySenseUtils.read_json(path)) return PySenseDataModel.DataModel(self, data_model_json)
def import_dashboards(self, path, *, action='overwrite', republish=True): """Import dashboard file from path Can be used to update an existing dashboard. Args: path (str): The path to the dash file action (str): Determines if the dashboard should be overwritten republish (bool): Whether to republish after import Returns: list[Dashboard]: The newly added dashboards """ query_params = {'action': action, 'republish': republish} json_obj = PySenseUtils.read_json(path) if isinstance(json_obj, list): json_array = json_obj else: json_array = [json_obj] result_json = self.connector.rest_call('post', 'api/v1/dashboards/import/bulk', query_params=query_params, json_payload=json_array) ret_arr = [] for dashboard_json in result_json["succeded"]: ret_arr.append(PySenseDashboard.Dashboard(self, dashboard_json)) return ret_arr