def create_ledger(self): """Create a ledger and wait for it to be active.""" if self.ledger_exist(): logger.info('Ledger already exist!') return True DdlServices.do_create_ledger(self.ledger_name) wait_for_active(self.ledger_name) DdlServices.reset_ledgers()
def create_table_indexes(self, index_attributes=[]): """Create index on tables in a particular ledger.""" logger.info('Creating index on all tables in a single transaction...') with qldb.session(self.ledger_name) as session: for index_attribute in index_attributes: session.execute_lambda( lambda x: DdlServices.do_create_table_index(x, self.hash_table_name, index_attribute), lambda retry_attempt: logger.info('Retrying due to OCC conflict...')) logger.info('Index created successfully.')
def ledger_name_parser_choices(default=config.LEDGER_NAME, parser=None, location='form'): parser = reqparse.RequestParser() if not parser else parser ledgers = DdlServices.ledger_list() choices = [] for ledger in ledgers: if ledger.get('State') == config.ACTIVE_STATE: choices.append(ledger.get('Name')) parser.add_argument('ledger_name', choices=choices, help='Ledger name', location=location, default=default, required=True, nullable=False, case_sensitive=True, trim=True) return parser
def delete(self): """Delete QLDB Ledger""" args = ledger_name_choices.parse_args(req=None, strict=False) return DdlServices.delete_ledger(**args)
def post(self): """Create QLDB Ledger""" args = ledger_name_plain.parse_args(req=None, strict=False) return DdlServices.create_ledger(**args)
def get(self): """Returns information about a ledger, including its state and when it was created.""" args = ledger_name_choices.parse_args(req=None, strict=False) return DdlServices.describe_ledger(**args)
def get(self): """List all QLDB ledgers in a given account""" return DdlServices.get_ledger_list()
def post(self): """Create index on table in a particular ledger""" args = table_index_create.parse_args(req=None, strict=False) return DdlServices.create_table_index(**args)
def delete(self): """Drop QLDB Table""" args = table_name.parse_args(req=None, strict=False) return DdlServices.drop_table(**args)
def post(self): """Create QLDB Table""" args = table_name.parse_args(req=None, strict=False) return DdlServices.create_table(**args)
def get(self): """List all the tables in the configured ledger in QLDB""" args = ledger_name_choices.parse_args(req=None, strict=False) return DdlServices.list_tables(**args)
def drop_table(self): """Create a Table""" with qldb.session(self.ledger_name) as session: session.execute_lambda(lambda x: DdlServices.do_drop_table(x, self.hash_table_name), lambda retry_attempt: logger.info('Retrying due to OCC conflict...')) logger.info('Table dropped successfully.')
def drop_ledger(self): """Delete a ledger.""" set_deletion_protection(self.ledger_name, False) DdlServices.do_delete_ledger(self.ledger_name) wait_for_deleted(self.ledger_name) DdlServices.reset_ledgers()