def custom_resource_delete(event, _): request_type = "Delete" resource_properties = get_resource_propertices(event, _) resource = resource_properties["Resource"] qs_api = QuicksightApi(resource_properties) try: if resource == "all": qs_api.delete_all_resources() elif resource == "datasource": qs_api.delete_data_source() elif resource == "dataset": qs_api.delete_data_sets() elif resource == "analysis": qs_api.delete_analysis() elif resource == "dashboard": qs_api.delete_dashboard() else: logger.error( f"Not handling request resource:{resource}, request_type:{request_type}" ) raise ValueError( f"Received unsupported request request_type:{request_type}, resource:{resource}" ) except Exception as error: # Do logging in addition to crhelper exception handeling log_exception(error) raise (error) logger.info( f"finished with request_type:{request_type} resource:{resource}") return None
def custom_resource_update(event, _): # For update we delete all the resources and re-create new ones. Any user customization on QuickSight may be lost try: process_delete_request(event) process_create_request( event) # once deleted re-create all the resources except Exception as error: resource_properties = get_resource_propertices(event) qs_api = QuicksightApi(resource_properties) qs_api.delete_all_resources() # Do logging in addition to crhelper exception handeling log_exception(error) raise (error) return None
def custom_resource_create(event, _): request_type = "Create" resource_properties = get_resource_propertices(event, _) resource = resource_properties["Resource"] qs_api = QuicksightApi(resource_properties) try: if resource == "all": qs_api.create_all_resources() elif resource == "datasource": qs_api.create_data_source() elif resource == "dataset": qs_api.create_data_sets() elif resource == "analysis": qs_api.create_analysis() elif resource == "dashboard": qs_api.create_dashboard() else: logger.error( f"Not handling request resource:{resource}, request_type:{request_type}" ) raise ValueError( f"Received unsupported request request_type:{request_type}, resource:{resource}" ) if resource in ["all", "analysis", "dashboard"]: analysis_url = qs_api.quicksight_application.get_analysis().url dashboard_url = qs_api.quicksight_application.get_dashboard().url helper.Data.update({ "analysis_url": analysis_url, "dashboard_url": dashboard_url }) except Exception as error: # Do logging in addition to crhelper exception handeling log_exception(error) qs_api.delete_all_resources() raise (error) logger.info( f"finished with request_type:{request_type} resource:{resource}") return None
def custom_resource_create(event, _): request_type = 'Create' resource_properties = get_resource_propertices(event, _) resource = resource_properties['Resource'] qs_api = QuicksightApi(resource_properties) try: if resource == 'all': qs_api.create_all_resources() elif resource == 'datasource': qs_api.create_data_source() elif resource == 'dataset': qs_api.create_data_sets() elif resource == 'analysis': qs_api.create_analysis() elif resource == 'dashboard': qs_api.create_dashboard() else: logger.error( f'Not handling request resource:{resource}, request_type:{request_type}' ) raise ValueError( f'Received unsupported request request_type:{request_type}, resource:{resource}' ) if resource in ['all', 'analysis', 'dashboard']: analysis_url = qs_api.quicksight_application.get_analysis().url dashboard_url = qs_api.quicksight_application.get_dashboard().url helper.Data.update({ 'analysis_url': analysis_url, 'dashboard_url': dashboard_url }) except Exception as error: # Do logging in addition to crhelper exception handeling log_exception(error) qs_api.delete_all_resources() raise (error) logger.info( f'finished with request_type:{request_type} resource:{resource}') return None
def custom_resource_update(event, _): # For update we delete all the resources and re-create new ones. Any user customization on QuickSight may be lost request_type = "Update" resource_properties = get_resource_propertices(event, _) resource = resource_properties["Resource"] qs_api = QuicksightApi(resource_properties) try: # First delete all the resources if resource == "all": qs_api.delete_all_resources() elif resource == "datasource": qs_api.delete_data_source() elif resource == "dataset": qs_api.delete_data_sets() elif resource == "analysis": qs_api.delete_analysis() elif resource == "dashboard": qs_api.delete_dashboard() else: logger.error( f"Not handling request resource:{resource}, request_type:{request_type}" ) raise ValueError( f"Received unsupported request request_type:{request_type}, resource:{resource}" ) # once deleted re-create all the resources if resource == "all": qs_api.create_all_resources() elif resource == "datasource": qs_api.create_data_source() elif resource == "dataset": qs_api.create_data_sets() elif resource == "analysis": qs_api.create_analysis() elif resource == "dashboard": qs_api.create_dashboard() else: logger.error( f"Not handling request resource:{resource}, request_type:{request_type}" ) raise ValueError( f"Received unsupported request request_type:{request_type}, resource:{resource}" ) if resource in ["all", "analysis", "dashboard"]: analysis_url = qs_api.quicksight_application.get_analysis().url dashboard_url = qs_api.quicksight_application.get_dashboard().url helper.Data.update({ "analysis_url": analysis_url, "dashboard_url": dashboard_url }) logger.error( f"Not handling request resource:{resource}, request_type:{request_type}" ) raise ValueError( f"Received unsupported request request_type:{request_type}, resource:{resource}" ) except Exception as error: qs_api.delete_all_resources() # Do logging in addition to crhelper exception handeling log_exception(error) raise (error) return None