mrs_plugin/general.py
def ls(path=None, session=None):
    """Lists the schemas that are currently offered via MRS

    Args:
        path (str): The path to use.
        session (object): The database session to use.

    Returns:
        None
    """

    try:
        session = core.get_current_session(session)

        # Make sure the MRS metadata schema exists and has the right version
        core.ensure_rds_metadata_schema(session)

        service = None
        schema = None
        content_set = None

        # If a path was given, try to get the corresponding objects
        if path is not None:
            service, schema, content_set = core.analyze_service_path(
                path=path, session=session)
        # If no path was given, check if current objects are set
        else:
            service = core.get_current_service(session=session)
            schema = core.get_current_schema(session=session)
            content_set = core.get_current_content_set(session=session)

        # If there is not current_service set, list all services
        if not service:
            print("List of MRS Services\n")
            services = mrs_services.get_services(
                session=session, interactive=False)
            if services and len(services) > 0:
                print(mrs_services.format_service_listing(services=services,
                                                          print_header=True))
            else:
                print("No services available.\n\nUse mrs.add.service() "
                      "to add a service.")
            return

        # List service content
        if service and not schema and not content_set:
            print(f"MRS Service {service.get('host_ctx')}\n")
            schemas = mrs_schemas.get_schemas(
                service_id=service.get('id'), session=session,
                interactive=False, return_formatted=False)
            content_sets = mrs_content_sets.get_content_sets(
                service_id=service.get('id'), session=session,
                interactive=False)
            auth_apps = mrs_auth_apps.get_auth_apps(
                service_id=service.get('id'), session=session,
                interactive=False)

            if len(schemas) == 0 and len(content_sets) == 0:
                print("No schemas added to this service yet.\n\n"
                      "Use mrs.add.schema() to add a schema to the service.")
            if len(schemas) > 0:
                print("List of Schemas")
                print(mrs_schemas.format_schema_listing(
                    schemas=schemas, print_header=True) + "\n")
            if len(content_sets) > 0:
                print("List of Content Sets")
                print(mrs_content_sets.format_content_set_listing(
                    content_sets=content_sets, print_header=True) + "\n")
            if len(auth_apps) > 0:
                print("List of Authentication Apps")
                print(mrs_auth_apps.format_auth_app_listing(
                    auth_apps=auth_apps, print_header=True) + "\n")

        # List schema objects
        if service and schema:
            print(f"MRS Service {service.get('host_ctx')}"
                  f"{schema.get('request_path')} - Database Objects\n")
            db_objects = mrs_db_objects.get_db_objects(
                schema_id=schema.get('id'), session=session,
                interactive=False)
            if len(db_objects) > 0:
                print(mrs_db_objects.format_db_object_listing(
                    db_objects=db_objects, print_header=True))
            else:
                print("No database objects added to this schema yet.\n\n"
                      "Use mrs.add.db_object() to add an object to the "
                      "schema.")

        # List content_set files
        if service and content_set:
            print(f"MRS Service {service.get('host_ctx')}"
                  f"{content_set.get('request_path')} - Content Files\n")
            content_files = mrs_content_files.get_content_files(
                content_set_id=content_set.get('id'), session=session,
                interactive=False)
            if len(content_files) > 0:
                print(mrs_content_files.format_content_file_listing(
                    content_files=content_files, print_header=True))
            else:
                print("No content files added to this content set yet.\n\n"
                      "Use mrs.add.content_file() to add a file to the "
                      "content set.")

    except Exception as e:
        print(f"Error: {str(e)}")
Lists the schemas that are currently offered via MRS

    Args:
        path (str): The path to use.
        session (object): The database session to use.

    Returns:
        None
    
Lists the schemas that are currently offered via MRS
Lists the schemas that are currently offered via MRS
def ls(path=None, session=None):
    try:
        session = core.get_current_session(session)
        core.ensure_rds_metadata_schema(session)
        service = None
        schema = None
        content_set = None
        if path is not None:
            service, schema, content_set = core.analyze_service_path(
                path=path, session=session)
        else:
            service = core.get_current_service(session=session)
            schema = core.get_current_schema(session=session)
            content_set = core.get_current_content_set(session=session)
        if not service:
            print("List of MRS Services\n")
            services = mrs_services.get_services(
                session=session, interactive=False)
            if services and len(services) > 0:
                print(mrs_services.format_service_listing(services=services,
                                                          print_header=True))
            else:
                print("No services available.\n\nUse mrs.add.service() "
                      "to add a service.")
            return
        if service and not schema and not content_set:
            print(f"MRS Service {service.get('host_ctx')}\n")
            schemas = mrs_schemas.get_schemas(
                service_id=service.get('id'), session=session,
                interactive=False, return_formatted=False)
            content_sets = mrs_content_sets.get_content_sets(
                service_id=service.get('id'), session=session,
                interactive=False)
            auth_apps = mrs_auth_apps.get_auth_apps(
                service_id=service.get('id'), session=session,
                interactive=False)
            if len(schemas) == 0 and len(content_sets) == 0:
                print("No schemas added to this service yet.\n\n"
                      "Use mrs.add.schema() to add a schema to the service.")
            if len(schemas) > 0:
                print("List of Schemas")
                print(mrs_schemas.format_schema_listing(
                    schemas=schemas, print_header=True) + "\n")
            if len(content_sets) > 0:
                print("List of Content Sets")
                print(mrs_content_sets.format_content_set_listing(
                    content_sets=content_sets, print_header=True) + "\n")
            if len(auth_apps) > 0:
                print("List of Authentication Apps")
                print(mrs_auth_apps.format_auth_app_listing(
                    auth_apps=auth_apps, print_header=True) + "\n")
        if service and schema:
            print(f"MRS Service {service.get('host_ctx')}"
                  f"{schema.get('request_path')} - Database Objects\n")
            db_objects = mrs_db_objects.get_db_objects(
                schema_id=schema.get('id'), session=session,
                interactive=False)
            if len(db_objects) > 0:
                print(mrs_db_objects.format_db_object_listing(
                    db_objects=db_objects, print_header=True))
            else:
                print("No database objects added to this schema yet.\n\n"
                      "Use mrs.add.db_object() to add an object to the "
                      "schema.")
        if service and content_set:
            print(f"MRS Service {service.get('host_ctx')}"
                  f"{content_set.get('request_path')} - Content Files\n")
            content_files = mrs_content_files.get_content_files(
                content_set_id=content_set.get('id'), session=session,
                interactive=False)
            if len(content_files) > 0:
                print(mrs_content_files.format_content_file_listing(
                    content_files=content_files, print_header=True))
            else:
                print("No content files added to this content set yet.\n\n"
                      "Use mrs.add.content_file() to add a file to the "
                      "content set.")
    except Exception as e:
        print(f"Error: {str(e)}")
def ls ( path = None , session = None ) : try : session = core . get_current_session ( session ) core . ensure_rds_metadata_schema ( session ) service = None schema = None content_set = None if path is not None : service , schema , content_set = core . analyze_service_path ( path = path , session = session ) else : service = core . get_current_service ( session = session ) schema = core . get_current_schema ( session = session ) content_set = core . get_current_content_set ( session = session ) if not service : print ( "List of MRS Services\n" ) services = mrs_services . get_services ( session = session , interactive = False ) if services and len ( services ) > 0 : print ( mrs_services . format_service_listing ( services = services , print_header = True ) ) else : print ( "No services available.\n\nUse mrs.add.service() " "to add a service." ) return if service and not schema and not content_set : print ( f"MRS Service {service.get('host_ctx')}\n" ) schemas = mrs_schemas . get_schemas ( service_id = service . get ( 'id' ) , session = session , interactive = False , return_formatted = False ) content_sets = mrs_content_sets . get_content_sets ( service_id = service . get ( 'id' ) , session = session , interactive = False ) auth_apps = mrs_auth_apps . get_auth_apps ( service_id = service . get ( 'id' ) , session = session , interactive = False ) if len ( schemas ) == 0 and len ( content_sets ) == 0 : print ( "No schemas added to this service yet.\n\n" "Use mrs.add.schema() to add a schema to the service." ) if len ( schemas ) > 0 : print ( "List of Schemas" ) print ( mrs_schemas . format_schema_listing ( schemas = schemas , print_header = True ) + "\n" ) if len ( content_sets ) > 0 : print ( "List of Content Sets" ) print ( mrs_content_sets . format_content_set_listing ( content_sets = content_sets , print_header = True ) + "\n" ) if len ( auth_apps ) > 0 : print ( "List of Authentication Apps" ) print ( mrs_auth_apps . format_auth_app_listing ( auth_apps = auth_apps , print_header = True ) + "\n" ) if service and schema : print ( f"MRS Service {service.get('host_ctx')}" f"{schema.get('request_path')} - Database Objects\n" ) db_objects = mrs_db_objects . get_db_objects ( schema_id = schema . get ( 'id' ) , session = session , interactive = False ) if len ( db_objects ) > 0 : print ( mrs_db_objects . format_db_object_listing ( db_objects = db_objects , print_header = True ) ) else : print ( "No database objects added to this schema yet.\n\n" "Use mrs.add.db_object() to add an object to the " "schema." ) if service and content_set : print ( f"MRS Service {service.get('host_ctx')}" f"{content_set.get('request_path')} - Content Files\n" ) content_files = mrs_content_files . get_content_files ( content_set_id = content_set . get ( 'id' ) , session = session , interactive = False ) if len ( content_files ) > 0 : print ( mrs_content_files . format_content_file_listing ( content_files = content_files , print_header = True ) ) else : print ( "No content files added to this content set yet.\n\n" "Use mrs.add.content_file() to add a file to the " "content set." ) except Exception as e : print ( f"Error: {str(e)}" )
Lists the schemas that are currently offered via MRS
Lists the schemas that are currently offered via MRS
"""Lists the schemas that are currently offered via MRS

    Args:
        path (str): The path to use.
        session (object): The database session to use.

    Returns:
        None
    """ # Make sure the MRS metadata schema exists and has the right version
 # If a path was given, try to get the corresponding objects
 # If no path was given, check if current objects are set
 # If there is not current_service set, list all services
 # List service content
 # List schema objects
 # List content_set files

None
path
The path to use.
The path to use .
session
The database session to use.
The database session to use .