mds_plugin/bastion.py
def list_bastions(**kwargs):
    """Lists bastions

    This function will list all bastions of the compartment with the
    given compartment_id.

    Args:
        **kwargs: Optional parameters

    Keyword Args:
        compartment_id (str): OCID of the parent compartment
        valid_for_db_system_id (str): OCID of the db_system_id the bastions 
            needs to be valid for and therefore are in the same subnet
        config (dict): An OCI config object or None
        config_profile (str): The name of an OCI config profile
        interactive (bool): Indicates whether to execute in interactive mode
        return_type (str): "STR" will return a formatted string, "DICT" will
            return the object converted to a dict structure and "OBJ" will
            return the OCI Python object for internal plugin usage
        raise_exceptions (bool): If set to true exceptions are raised

    Returns:
        Based on return_type
    """

    compartment_id = kwargs.get("compartment_id")
    valid_for_db_system_id = kwargs.get("valid_for_db_system_id")

    config = kwargs.get("config")
    config_profile = kwargs.get("config_profile")

    interactive = kwargs.get("interactive", core.get_interactive_default())
    return_type = kwargs.get(
        "return_type",  # In interactive mode, default to formatted str return
        core.RETURN_STR if interactive else core.RETURN_DICT)
    raise_exceptions = kwargs.get(
        "raise_exceptions",  # On internal call (RETURN_OBJ), raise exceptions
        True if return_type == core.RETURN_OBJ else not interactive)

    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)
        current_bastion_id = configuration.get_current_bastion_id(
            config=config)

        import oci.exceptions
        try:
            # Initialize the  Object Store client
            bastion_client = core.get_oci_bastion_client(config=config)

            # List the bastions
            bastions = bastion_client.list_bastions(
                compartment_id=compartment_id).data

            # Filter out all deleted bastions
            bastions = [b for b in bastions if b.lifecycle_state != "DELETED"]

            # Filter out all bastions that are not valid for the given DbSystem
            if valid_for_db_system_id:
                # Just consider active bastions here
                bastions = [b for b in bastions if b.lifecycle_state == "ACTIVE"]
                valid_bastions = []
                db_system = mysql_database_service.get_db_system(
                    db_system_id=valid_for_db_system_id,
                    config=config, interactive=False,
                    return_python_object=True)
                for b in bastions:
                    bastion = bastion_client.get_bastion(bastion_id=b.id).data
                    if bastion.target_subnet_id == db_system.subnet_id:
                        valid_bastions.append(bastion)
                bastions = valid_bastions


            # Add the is_current field
            current_bastion_id = configuration.get_current_bastion_id(
                config=config)

            for b in bastions:
                # Add the is_current field to the object, also adding it to
                # the swagger_types so oci.util.to_dict() does include it
                setattr(b, "is_current", b.id == current_bastion_id)
                b.swagger_types["is_current"] = "bool"
                # bastions[i] = b

            if len(bastions) < 1 and interactive:
                print("This compartment contains no bastions.")
                bastions = None

            return core.oci_object(
                oci_object=bastions,
                return_type=return_type,
                format_function=format_bastion_listing,
                current=current_bastion_id)
        except oci.exceptions.ServiceError as e:
            if raise_exceptions:
                raise
            print(f'ERROR: {e.message}. (Code: {e.code}; Status: {e.status})')
    except Exception as e:
        if raise_exceptions:
            raise
        print(f'ERROR: {e}')
Lists bastions

    This function will list all bastions of the compartment with the
    given compartment_id.

    Args:
        **kwargs: Optional parameters

    Keyword Args:
        compartment_id (str): OCID of the parent compartment
        valid_for_db_system_id (str): OCID of the db_system_id the bastions 
            needs to be valid for and therefore are in the same subnet
        config (dict): An OCI config object or None
        config_profile (str): The name of an OCI config profile
        interactive (bool): Indicates whether to execute in interactive mode
        return_type (str): "STR" will return a formatted string, "DICT" will
            return the object converted to a dict structure and "OBJ" will
            return the OCI Python object for internal plugin usage
        raise_exceptions (bool): If set to true exceptions are raised

    Returns:
        Based on return_type
    
Lists bastions
This function will list all bastions of the compartment with the
given compartment_id.
Lists bastions This function will list all bastions of the compartment with the given compartment_id .
def list_bastions(**kwargs):
    compartment_id = kwargs.get("compartment_id")
    valid_for_db_system_id = kwargs.get("valid_for_db_system_id")
    config = kwargs.get("config")
    config_profile = kwargs.get("config_profile")
    interactive = kwargs.get("interactive", core.get_interactive_default())
    return_type = kwargs.get(
        "return_type",  
        core.RETURN_STR if interactive else core.RETURN_DICT)
    raise_exceptions = kwargs.get(
        "raise_exceptions",  
        True if return_type == core.RETURN_OBJ else not interactive)
    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)
        current_bastion_id = configuration.get_current_bastion_id(
            config=config)
        import oci.exceptions
        try:
            bastion_client = core.get_oci_bastion_client(config=config)
            bastions = bastion_client.list_bastions(
                compartment_id=compartment_id).data
            bastions = [b for b in bastions if b.lifecycle_state != "DELETED"]
            if valid_for_db_system_id:
                bastions = [b for b in bastions if b.lifecycle_state == "ACTIVE"]
                valid_bastions = []
                db_system = mysql_database_service.get_db_system(
                    db_system_id=valid_for_db_system_id,
                    config=config, interactive=False,
                    return_python_object=True)
                for b in bastions:
                    bastion = bastion_client.get_bastion(bastion_id=b.id).data
                    if bastion.target_subnet_id == db_system.subnet_id:
                        valid_bastions.append(bastion)
                bastions = valid_bastions
            current_bastion_id = configuration.get_current_bastion_id(
                config=config)
            for b in bastions:
                 to the object, also adding it to
                setattr(b, "is_current", b.id == current_bastion_id)
                b.swagger_types["is_current"] = "bool"
            if len(bastions) < 1 and interactive:
                print("This compartment contains no bastions.")
                bastions = None
            return core.oci_object(
                oci_object=bastions,
                return_type=return_type,
                format_function=format_bastion_listing,
                current=current_bastion_id)
        except oci.exceptions.ServiceError as e:
            if raise_exceptions:
                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 list_bastions ( ** kwargs ) : compartment_id = kwargs . get ( "compartment_id" ) valid_for_db_system_id = kwargs . get ( "valid_for_db_system_id" ) config = kwargs . get ( "config" ) config_profile = kwargs . get ( "config_profile" ) interactive = kwargs . get ( "interactive" , core . get_interactive_default ( ) ) return_type = kwargs . get ( "return_type" , core . RETURN_STR if interactive else core . RETURN_DICT ) raise_exceptions = kwargs . get ( "raise_exceptions" , True if return_type == core . RETURN_OBJ else not interactive ) 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 ) current_bastion_id = configuration . get_current_bastion_id ( config = config ) import oci . exceptions try : bastion_client = core . get_oci_bastion_client ( config = config ) bastions = bastion_client . list_bastions ( compartment_id = compartment_id ) . data bastions = [ b for b in bastions if b . lifecycle_state != "DELETED" ] if valid_for_db_system_id : bastions = [ b for b in bastions if b . lifecycle_state == "ACTIVE" ] valid_bastions = [ ] db_system = mysql_database_service . get_db_system ( db_system_id = valid_for_db_system_id , config = config , interactive = False , return_python_object = True ) for b in bastions : bastion = bastion_client . get_bastion ( bastion_id = b . id ) . data if bastion . target_subnet_id == db_system . subnet_id : valid_bastions . append ( bastion ) bastions = valid_bastions current_bastion_id = configuration . get_current_bastion_id ( config = config ) for b in bastions : setattr ( b , "is_current" , b . id == current_bastion_id ) b . swagger_types [ "is_current" ] = "bool" if len ( bastions ) < 1 and interactive : print ( "This compartment contains no bastions." ) bastions = None return core . oci_object ( oci_object = bastions , return_type = return_type , format_function = format_bastion_listing , current = current_bastion_id ) except oci . exceptions . ServiceError as e : if raise_exceptions : raise print ( f'ERROR: {e.message}. (Code: {e.code}; Status: {e.status})' ) except Exception as e : if raise_exceptions : raise print ( f'ERROR: {e}' )
Lists bastions
This function will list all bastions of the compartment with the
given compartment_id.
Lists bastions This function will list all bastions of the compartment with the given compartment_id .
"""Lists bastions

    This function will list all bastions of the compartment with the
    given compartment_id.

    Args:
        **kwargs: Optional parameters

    Keyword Args:
        compartment_id (str): OCID of the parent compartment
        valid_for_db_system_id (str): OCID of the db_system_id the bastions 
            needs to be valid for and therefore are in the same subnet
        config (dict): An OCI config object or None
        config_profile (str): The name of an OCI config profile
        interactive (bool): Indicates whether to execute in interactive mode
        return_type (str): "STR" will return a formatted string, "DICT" will
            return the object converted to a dict structure and "OBJ" will
            return the OCI Python object for internal plugin usage
        raise_exceptions (bool): If set to true exceptions are raised

    Returns:
        Based on return_type
    """ # In interactive mode, default to formatted str return # On internal call (RETURN_OBJ), raise exceptions # Initialize the  Object Store client # List the bastions # Filter out all deleted bastions # Filter out all bastions that are not valid for the given DbSystem # Just consider active bastions here # Add the is_current field # Add the is_current field to the object, also adding it to # the swagger_types so oci.util.to_dict() does include it # bastions[i] = b
Based on return_type
Based on return_type
**kwargs
None