예제 #1
0
def get_user(username, without_fields=['password']):
    """Retrieve a user from the database
    Args:
        username (str): Name of the user.

    Kwargs:
        without_fields (list): List of fields you do not want to include.

    Basic Usage:
        >>> from vFense.user.users import get_user
        >>> username = '******'
        >>> get_user(username, without_fields=['password'])

    Return:
        Dictionary of user properties.
        {
            u'current_customer': u'default',
            u'enabled': True,
            u'full_name': u'TopPatchAgentCommunicationAccount',
            u'default_customer': u'default',
            u'user_name': u'agent',
            u'email': u'*****@*****.**'
        }
    """
    data = fetch_user(username, without_fields)
    return(data)
예제 #2
0
def get_user_property(username, user_property):
    """Retrieve user property.
    Args:
        username (str):  Name of the user.
        user_property (str): Property you want to retrieve.

    Basic Usage:
        >>> from vFense.user.users get_user_property
        >>> username = '******'
        >>> user_property = 'current_customer'
        >>> get_user_property(username, user_property)

    Return:
        String
    """
    user_data = fetch_user(username)
    user_key = None
    if user_data:
        user_key = user_data.get(user_property)

    return(user_key)