mrs_plugin/general.py
def configure(**kwargs):
    """Initializes and configures the MySQL REST Data Service

    Args:
        **kwargs: Additional options

    Keyword Args:
        enable_mrs (bool): Whether MRS should be enabled or disabled
        session (object): The database session to use
        interactive (bool): Indicates whether to execute in interactive mode

    Returns:
        True on success, None in interactive mode
    """

    enable_mrs = kwargs.get("enable_mrs")
    session = kwargs.get("session")
    interactive = kwargs.get("interactive", core.get_interactive_default())

    try:
        session = core.get_current_session(session)

        if interactive:
            print("MySQL Rest Data Service configuration.\n\n"
                  "Checking MRS metadata schema and version...")

        # Make sure the MRS metadata schema exists and has the right version
        schema_changed = core.ensure_rds_metadata_schema(
            session=session, auto_create_and_update=True,
            interactive=interactive)

        if interactive:
            if schema_changed:
                print("The MRS metadata has been configured.")
            else:
                print("The MRS metadata is well configured, no changes "
                      "performed.")

        if enable_mrs != None:
            res = session.run_sql("""
                UPDATE `mysql_rest_service_metadata`.config
                    SET service_enabled = ?
                WHERE id = 1
                """, [1 if enable_mrs else 0])

            if interactive:
                if enable_mrs:
                    print(f"The MySQL REST Data Service has been enabled.")
                else:
                    print(f"The MySQL REST Data Service has been disabled.")
        else:
            res = session.run_sql("""
                SELECT service_enabled
                FROM `mysql_rest_service_metadata`.config
                WHERE id = 1
                """)
            row = res.fetch_one()
            enable_mrs = row.get_field("service_enabled") \
                if row and row.get_field("service_enabled") else 0

        if not interactive:
            return {
                "schema_changed": schema_changed,
                "mrs_enabled": enable_mrs}
    except Exception as e:
        if interactive:
            print(f"Error: {str(e)}")
        else:
            raise
Initializes and configures the MySQL REST Data Service

    Args:
        **kwargs: Additional options

    Keyword Args:
        enable_mrs (bool): Whether MRS should be enabled or disabled
        session (object): The database session to use
        interactive (bool): Indicates whether to execute in interactive mode

    Returns:
        True on success, None in interactive mode
    
Initializes and configures the MySQL REST Data Service
Initializes and configures the MySQL REST Data Service
def configure(**kwargs):
    enable_mrs = kwargs.get("enable_mrs")
    session = kwargs.get("session")
    interactive = kwargs.get("interactive", core.get_interactive_default())
    try:
        session = core.get_current_session(session)
        if interactive:
            print("MySQL Rest Data Service configuration.\n\n"
                  "Checking MRS metadata schema and version...")
        schema_changed = core.ensure_rds_metadata_schema(
            session=session, auto_create_and_update=True,
            interactive=interactive)
        if interactive:
            if schema_changed:
                print("The MRS metadata has been configured.")
            else:
                print("The MRS metadata is well configured, no changes "
                      "performed.")
        if enable_mrs != None:
            res = session.run_sql("""
                UPDATE `mysql_rest_service_metadata`.config
                    SET service_enabled = ?
                WHERE id = 1
                """, [1 if enable_mrs else 0])
            if interactive:
                if enable_mrs:
                    print(f"The MySQL REST Data Service has been enabled.")
                else:
                    print(f"The MySQL REST Data Service has been disabled.")
        else:
            res = session.run_sql("""
                SELECT service_enabled
                FROM `mysql_rest_service_metadata`.config
                WHERE id = 1
                """)
            row = res.fetch_one()
            enable_mrs = row.get_field("service_enabled") \
                if row and row.get_field("service_enabled") else 0
        if not interactive:
            return {
                "schema_changed": schema_changed,
                "mrs_enabled": enable_mrs}
    except Exception as e:
        if interactive:
            print(f"Error: {str(e)}")
        else:
            raise
def configure ( ** kwargs ) : enable_mrs = kwargs . get ( "enable_mrs" ) session = kwargs . get ( "session" ) interactive = kwargs . get ( "interactive" , core . get_interactive_default ( ) ) try : session = core . get_current_session ( session ) if interactive : print ( "MySQL Rest Data Service configuration.\n\n" "Checking MRS metadata schema and version..." ) schema_changed = core . ensure_rds_metadata_schema ( session = session , auto_create_and_update = True , interactive = interactive ) if interactive : if schema_changed : print ( "The MRS metadata has been configured." ) else : print ( "The MRS metadata is well configured, no changes " "performed." ) if enable_mrs != None : res = session . run_sql ( """
                UPDATE `mysql_rest_service_metadata`.config
                    SET service_enabled = ?
                WHERE id = 1
                """ , [ 1 if enable_mrs else 0 ] ) if interactive : if enable_mrs : print ( f"The MySQL REST Data Service has been enabled." ) else : print ( f"The MySQL REST Data Service has been disabled." ) else : res = session . run_sql ( """
                SELECT service_enabled
                FROM `mysql_rest_service_metadata`.config
                WHERE id = 1
                """ ) row = res . fetch_one ( ) enable_mrs = row . get_field ( "service_enabled" ) if row and row . get_field ( "service_enabled" ) else 0 if not interactive : return { "schema_changed" : schema_changed , "mrs_enabled" : enable_mrs } except Exception as e : if interactive : print ( f"Error: {str(e)}" ) else : raise
Initializes and configures the MySQL REST Data Service
Initializes and configures the MySQL REST Data Service
"""Initializes and configures the MySQL REST Data Service

    Args:
        **kwargs: Additional options

    Keyword Args:
        enable_mrs (bool): Whether MRS should be enabled or disabled
        session (object): The database session to use
        interactive (bool): Indicates whether to execute in interactive mode

    Returns:
        True on success, None in interactive mode
    """ # Make sure the MRS metadata schema exists and has the right version

True on success, None in interactive mode
True on success None in interactive mode
**kwargs
None