mds_plugin/user.py
def add_user_to_group(user_name=None, group_name=None, user_id=None,
                      group_id=None, config=None, return_object=False):
    """Adds a user to a group

    Args:
        user_name (str): The name of the user.
        group_name (str): The name of the group.
        user_id (str): The OCID of the user
        group_id (str): The OCID of the group
        config (object): An OCI config object or None.
        return_object (bool): If the object should be returned

    Returns:
        The membership object or None
    """

    # Get the current config
    try:
        config = configuration.get_current_config(config=config)
    except ValueError as e:
        print(e)
        return

    import oci.identity

    # Get user
    user = get_user(user_name=user_name, user_id=user_id, config=config)
    if user is None:
        print("Operation cancelled.")
        return
    user_name = user.name

    # Get user
    group = get_group(name=group_name, group_id=group_id, config=config)
    if group is None:
        print("Operation cancelled.")
        return

    # Create Details
    details = oci.identity.models.AddUserToGroupDetails(
        group_id=group.id,
        user_id=user.id
    )
    group_name = group.name

    # Initialize the identity client
    identity = core.get_oci_identity_client(config=config)

    # Add the user to the group
    try:
        membership = identity.add_user_to_group(details).data
    except oci.exceptions.ServiceError as e:
        print(f'ERROR: {e.message}. (Code: {e.code}; Status: {e.status})')
        return
    except (ValueError, oci.exceptions.ClientError) as e:
        print(f'ERROR: {e}')

    # Return the response
    if return_object:
        return membership
    else:
        print(f"User {user_name} was added to {group_name}.")
Adds a user to a group

    Args:
        user_name (str): The name of the user.
        group_name (str): The name of the group.
        user_id (str): The OCID of the user
        group_id (str): The OCID of the group
        config (object): An OCI config object or None.
        return_object (bool): If the object should be returned

    Returns:
        The membership object or None
    
Adds a user to a group
Adds a user to a group
def add_user_to_group(user_name=None, group_name=None, user_id=None,
                      group_id=None, config=None, return_object=False):
    try:
        config = configuration.get_current_config(config=config)
    except ValueError as e:
        print(e)
        return
    import oci.identity
    user = get_user(user_name=user_name, user_id=user_id, config=config)
    if user is None:
        print("Operation cancelled.")
        return
    user_name = user.name
    group = get_group(name=group_name, group_id=group_id, config=config)
    if group is None:
        print("Operation cancelled.")
        return
    details = oci.identity.models.AddUserToGroupDetails(
        group_id=group.id,
        user_id=user.id
    )
    group_name = group.name
    identity = core.get_oci_identity_client(config=config)
    try:
        membership = identity.add_user_to_group(details).data
    except oci.exceptions.ServiceError as e:
        print(f'ERROR: {e.message}. (Code: {e.code}; Status: {e.status})')
        return
    except (ValueError, oci.exceptions.ClientError) as e:
        print(f'ERROR: {e}')
    if return_object:
        return membership
    else:
        print(f"User {user_name} was added to {group_name}.")
def add_user_to_group ( user_name = None , group_name = None , user_id = None , group_id = None , config = None , return_object = False ) : try : config = configuration . get_current_config ( config = config ) except ValueError as e : print ( e ) return import oci . identity user = get_user ( user_name = user_name , user_id = user_id , config = config ) if user is None : print ( "Operation cancelled." ) return user_name = user . name group = get_group ( name = group_name , group_id = group_id , config = config ) if group is None : print ( "Operation cancelled." ) return details = oci . identity . models . AddUserToGroupDetails ( group_id = group . id , user_id = user . id ) group_name = group . name identity = core . get_oci_identity_client ( config = config ) try : membership = identity . add_user_to_group ( details ) . data except oci . exceptions . ServiceError as e : print ( f'ERROR: {e.message}. (Code: {e.code}; Status: {e.status})' ) return except ( ValueError , oci . exceptions . ClientError ) as e : print ( f'ERROR: {e}' ) if return_object : return membership else : print ( f"User {user_name} was added to {group_name}." )
Adds a user to a group
Adds a user to a group
"""Adds a user to a group

    Args:
        user_name (str): The name of the user.
        group_name (str): The name of the group.
        user_id (str): The OCID of the user
        group_id (str): The OCID of the group
        config (object): An OCI config object or None.
        return_object (bool): If the object should be returned

    Returns:
        The membership object or None
    """ # Get the current config
 # Get user
 # Get user
 # Create Details
 # Initialize the identity client
 # Add the user to the group
 # Return the response

The membership object or None
The membership object or None
user_name
The name of the user.
The name of the user .
group_name
The name of the group.
The name of the group .
user_id
The OCID of the user
The OCID of the user
group_id
The OCID of the group
The OCID of the group
config
An OCI config object or None.
An OCI config object or None .
return_object
If the object should be returned
If the object should be returned