mds_plugin/bastion.py
def delete_session(**kwargs):
    """Deletes a Bastion Session with the given id

    If no id is given, it will prompt the user for the id.

    Args:
        **kwargs: Optional parameters

    Keyword Args:
        session_name (str): The name of the bastion session
        session_id (str): The id of the bastion session
        bastion_name (str): The name of the bastion.
        bastion_id (str): OCID of the bastion.
        compartment_id (str): OCID of the compartment.
        config (dict): An OCI config object or None.
        config_profile (str): The name of an OCI config profile
        ignore_current (bool): Whether the current bastion should be ignored
        interactive (bool): Indicates whether to execute in interactive mode
        raise_exceptions (bool): If set to true exceptions are raised

    Returns:
       None
    """

    session_name = kwargs.get("session_name")
    session_id = kwargs.get("session_id")
    bastion_name = kwargs.get("bastion_name")
    bastion_id = kwargs.get("bastion_id")
    compartment_id = kwargs.get("compartment_id")
    ignore_current = kwargs.get("ignore_current", False)
    config = kwargs.get("config")
    config_profile = kwargs.get("config_profile")

    interactive = kwargs.get("interactive", core.get_interactive_default())
    raise_exceptions = kwargs.get("raise_exceptions", not interactive)

    import mysqlsh

    # Get the active config and compartment
    try:
        config = configuration.get_current_config(
            config=config, config_profile=config_profile,
            interactive=interactive)
        compartment_id = configuration.get_current_compartment_id(
            compartment_id=compartment_id, config=config)
        if not ignore_current and bastion_name is None:
            bastion_id = configuration.get_current_bastion_id(
                bastion_id=bastion_id, config=config)

        import oci.exceptions
        try:
            if not session_id:
                bastion = get_bastion(
                    bastion_name=bastion_name,
                    bastion_id=bastion_id, compartment_id=compartment_id,
                    config=config, ignore_current=ignore_current,
                    interactive=interactive, return_type=core.RETURN_OBJ)
                if not bastion:
                    raise ValueError(
                        "No bastion given or found. "
                        "Operation cancelled.")

                session = get_session(
                    session_name=session_name, session_id=session_id,
                    bastion_id=bastion.id, compartment_id=compartment_id,
                    config=config, ignore_current=ignore_current,
                    interactive=interactive, return_type=core.RETURN_OBJ)
                if not session:
                    raise ValueError(
                        "No bastion session given or found. "
                        "Operation cancelled.")

                session_id = session.id

            if interactive:
                # Prompt the user for specifying a compartment
                prompt = mysqlsh.globals.shell.prompt(
                    f"Are you sure you want to delete the bastion session? "
                    f"[yes/NO]: ",
                    {'defaultValue': 'no'}).strip().lower()
                if prompt != "yes":
                    raise Exception("Deletion aborted.\n")

            # Initialize the Bastion client
            bastion_client = core.get_oci_bastion_client(config=config)

            bastion_client.delete_session(session_id=session_id)

            if interactive:
                print(f"The bastion session is being deleted.")

        except oci.exceptions.ServiceError as e:
            if interactive:
                raise
            print(f'ERROR: {e.message}. (Code: {e.code}; Status: {e.status})')
    except (Exception) as e:
        if raise_exceptions:
            raise
        print(f'ERROR: {e}')
Deletes a Bastion Session with the given id

    If no id is given, it will prompt the user for the id.

    Args:
        **kwargs: Optional parameters

    Keyword Args:
        session_name (str): The name of the bastion session
        session_id (str): The id of the bastion session
        bastion_name (str): The name of the bastion.
        bastion_id (str): OCID of the bastion.
        compartment_id (str): OCID of the compartment.
        config (dict): An OCI config object or None.
        config_profile (str): The name of an OCI config profile
        ignore_current (bool): Whether the current bastion should be ignored
        interactive (bool): Indicates whether to execute in interactive mode
        raise_exceptions (bool): If set to true exceptions are raised

    Returns:
       None
    
Deletes a Bastion Session with the given id
If no id is given, it will prompt the user for the id.
Deletes a Bastion Session with the given id If no id is given it will prompt the user for the id .
def delete_session(**kwargs):
    session_name = kwargs.get("session_name")
    session_id = kwargs.get("session_id")
    bastion_name = kwargs.get("bastion_name")
    bastion_id = kwargs.get("bastion_id")
    compartment_id = kwargs.get("compartment_id")
    ignore_current = kwargs.get("ignore_current", False)
    config = kwargs.get("config")
    config_profile = kwargs.get("config_profile")
    interactive = kwargs.get("interactive", core.get_interactive_default())
    raise_exceptions = kwargs.get("raise_exceptions", not interactive)
    import mysqlsh
    try:
        config = configuration.get_current_config(
            config=config, config_profile=config_profile,
            interactive=interactive)
        compartment_id = configuration.get_current_compartment_id(
            compartment_id=compartment_id, config=config)
        if not ignore_current and bastion_name is None:
            bastion_id = configuration.get_current_bastion_id(
                bastion_id=bastion_id, config=config)
        import oci.exceptions
        try:
            if not session_id:
                bastion = get_bastion(
                    bastion_name=bastion_name,
                    bastion_id=bastion_id, compartment_id=compartment_id,
                    config=config, ignore_current=ignore_current,
                    interactive=interactive, return_type=core.RETURN_OBJ)
                if not bastion:
                    raise ValueError(
                        "No bastion given or found. "
                        "Operation cancelled.")
                session = get_session(
                    session_name=session_name, session_id=session_id,
                    bastion_id=bastion.id, compartment_id=compartment_id,
                    config=config, ignore_current=ignore_current,
                    interactive=interactive, return_type=core.RETURN_OBJ)
                if not session:
                    raise ValueError(
                        "No bastion session given or found. "
                        "Operation cancelled.")
                session_id = session.id
            if interactive:
                prompt = mysqlsh.globals.shell.prompt(
                    f"Are you sure you want to delete the bastion session? "
                    f"[yes/NO]: ",
                    {'defaultValue': 'no'}).strip().lower()
                if prompt != "yes":
                    raise Exception("Deletion aborted.\n")
            bastion_client = core.get_oci_bastion_client(config=config)
            bastion_client.delete_session(session_id=session_id)
            if interactive:
                print(f"The bastion session is being deleted.")
        except oci.exceptions.ServiceError as e:
            if interactive:
                raise
            print(f'ERROR: {e.message}. (Code: {e.code}; Status: {e.status})')
    except (Exception) as e:
        if raise_exceptions:
            raise
        print(f'ERROR: {e}')
def delete_session ( ** kwargs ) : session_name = kwargs . get ( "session_name" ) session_id = kwargs . get ( "session_id" ) bastion_name = kwargs . get ( "bastion_name" ) bastion_id = kwargs . get ( "bastion_id" ) compartment_id = kwargs . get ( "compartment_id" ) ignore_current = kwargs . get ( "ignore_current" , False ) config = kwargs . get ( "config" ) config_profile = kwargs . get ( "config_profile" ) interactive = kwargs . get ( "interactive" , core . get_interactive_default ( ) ) raise_exceptions = kwargs . get ( "raise_exceptions" , not interactive ) import mysqlsh try : config = configuration . get_current_config ( config = config , config_profile = config_profile , interactive = interactive ) compartment_id = configuration . get_current_compartment_id ( compartment_id = compartment_id , config = config ) if not ignore_current and bastion_name is None : bastion_id = configuration . get_current_bastion_id ( bastion_id = bastion_id , config = config ) import oci . exceptions try : if not session_id : bastion = get_bastion ( bastion_name = bastion_name , bastion_id = bastion_id , compartment_id = compartment_id , config = config , ignore_current = ignore_current , interactive = interactive , return_type = core . RETURN_OBJ ) if not bastion : raise ValueError ( "No bastion given or found. " "Operation cancelled." ) session = get_session ( session_name = session_name , session_id = session_id , bastion_id = bastion . id , compartment_id = compartment_id , config = config , ignore_current = ignore_current , interactive = interactive , return_type = core . RETURN_OBJ ) if not session : raise ValueError ( "No bastion session given or found. " "Operation cancelled." ) session_id = session . id if interactive : prompt = mysqlsh . globals . shell . prompt ( f"Are you sure you want to delete the bastion session? " f"[yes/NO]: " , { 'defaultValue' : 'no' } ) . strip ( ) . lower ( ) if prompt != "yes" : raise Exception ( "Deletion aborted.\n" ) bastion_client = core . get_oci_bastion_client ( config = config ) bastion_client . delete_session ( session_id = session_id ) if interactive : print ( f"The bastion session is being deleted." ) except oci . exceptions . ServiceError as e : if interactive : raise print ( f'ERROR: {e.message}. (Code: {e.code}; Status: {e.status})' ) except ( Exception ) as e : if raise_exceptions : raise print ( f'ERROR: {e}' )
Deletes a Bastion Session with the given id
If no id is given, it will prompt the user for the id.
Deletes a Bastion Session with the given id If no id is given it will prompt the user for the id .
"""Deletes a Bastion Session with the given id

    If no id is given, it will prompt the user for the id.

    Args:
        **kwargs: Optional parameters

    Keyword Args:
        session_name (str): The name of the bastion session
        session_id (str): The id of the bastion session
        bastion_name (str): The name of the bastion.
        bastion_id (str): OCID of the bastion.
        compartment_id (str): OCID of the compartment.
        config (dict): An OCI config object or None.
        config_profile (str): The name of an OCI config profile
        ignore_current (bool): Whether the current bastion should be ignored
        interactive (bool): Indicates whether to execute in interactive mode
        raise_exceptions (bool): If set to true exceptions are raised

    Returns:
       None
    """ # Get the active config and compartment # Prompt the user for specifying a compartment # Initialize the Bastion client
None
**kwargs
None