def delete_dashboards(sdmonitor: SdMonitorClient, ids: List): for id in ids: ok, res = sdmonitor.delete_dashboard(dashboard={"id": id}) if not ok: print(f"error deleting the dashboard {id}: {res}") return EXIT_CODES.ERR_DELETING_DASHBOARD print(f"Deleted dashboard {id}") return EXIT_CODES.OK
# Check the result if ok: print('Panel added successfully') dashboard_configuration = res['dashboard'] else: print(res) sys.exit(1) # Remove the time series panel ok, res = sdclient.remove_dashboard_panel(dashboard_configuration, PANEL_NAME) # Check the result if ok: print('Panel removed successfully') dashboard_configuration = res['dashboard'] else: print(res) sys.exit(1) # Delete the dashboard ok, res = sdclient.delete_dashboard(dashboard_configuration) # Check the result if ok: print('Dashboard deleted successfully') else: print(res) sys.exit(1) print('IBM Cloud IAM auth worked successfully!')
pattern = arg if len(args) != 1: usage() sdc_token = args[0] # # Instantiate the SDC client # sdclient = SdMonitorClient(sdc_token) # # List the dashboards # ok, res = sdclient.get_dashboards() if not ok: print(res) sys.exit(1) # # Delete all the dashboards containing pattern # for dashboard in res['dashboards']: if pattern in dashboard['name']: print(("Deleting " + dashboard['name'])) ok, res = sdclient.delete_dashboard(dashboard) if not ok: print(res) sys.exit(1)
# ok, res = sdclient_v1.get_dashboards() if not ok: print(res) sys.exit(1) for dashboard in res['dashboards']: file_name = '{}.json'.format(dashboard['id']) print( ('Saving v1 dashboard {} to file {}...'.format(dashboard['name'], file_name))) sdclient_v1.save_dashboard_to_file(dashboard, file_name) print('Importing dashboard to v2...') ok, res = sdclient_v2.create_dashboard_from_file( 'import of {}'.format(dashboard['name']), file_name, None, shared=dashboard['isShared'], public=dashboard['isPublic']) if ok: print(('Dashboard {} imported!'.format(dashboard['name']))) sdclient_v2.delete_dashboard(res['dashboard']) else: print(('Dashboard {} import failed:'.format(dashboard['name']))) print(res) print('\n')