def present(name, **kwargs):
    '''
    Ensure that an account is present and properly configured

    name
        The email address associated with the Stormpath account

    directory_id
        The ID of a directory which the account belongs to. Required.

    password
        Required when creating a new account. If specified, it is advisable to
        reference the password in another database using an ``sdb://`` URL.
        Will NOT update the password if an account already exists.

    givenName
        Required when creating a new account.

    surname
        Required when creating a new account.

    username
        Optional. Must be unique across the owning directory. If not specified,
        the username will default to the email field.

    middleName
        Optional.

    status
        ``enabled`` accounts are able to login to their assigned applications,
        ``disabled`` accounts may not login to applications, ``unverified``
        accounts are disabled and have not verified their email address.

    customData.
        Optional. Must be specified as a dict.
    '''
    # Because __opts__ is not available outside of functions
    if __opts__.get('requests_lib', False):
        from requests.exceptions import HTTPError
    else:
        from urllib2 import HTTPError

    ret = {'name': name,
           'changes': {},
           'result': None,
           'comment': ''}
    info = {}
    try:
        result = __salt__['stormpath.show_account'](email=name, **kwargs)
        if len(result['items']) > 0:
            info = result['items'][0]
    except __HOLE__:
        pass
    needs_update = {}
    if info.get('email', False):
        for field in kwargs.keys():
            if info.get(field, None) != kwargs[field]:
                needs_update[field] = kwargs[field]
        del needs_update['directory_id']
        if 'password' in needs_update:
            del needs_update['password']
        if len(needs_update.keys()) < 1:
            ret['result'] = True
            ret['comment'] = 'Stormpath account {0} already exists and is correct'.format(name)
            return ret
    if __opts__['test']:
        if len(needs_update.keys()) < 1:
            ret['comment'] = 'Stormpath account {0} needs to be created'.format(name)
        else:
            if 'password' in needs_update:
                needs_update['password'] = '**HIDDEN**'
            ret['comment'] = ('Stormpath account {0} needs the following '
                'fields to be updated: '.format(', '.join(needs_update)))
        return ret
    if len(needs_update.keys()) < 1:
        info = __salt__['stormpath.create_account'](email=name, **kwargs)
        comps = info['href'].split('/')
        account_id = comps[-1]
        ret['changes'] = info
        ret['result'] = True
        kwargs['password'] = '**HIDDEN**'
        ret['comment'] = 'Created account ID {0} ({1}): {2}'.format(
            account_id, name, pprint.pformat(kwargs))
        return ret
    comps = info['href'].split('/')
    account_id = comps[-1]
    result = __salt__['stormpath.update_account'](account_id, items=needs_update)
    if result.get('href', None):
        ret['changes'] = needs_update
        ret['result'] = True
        if 'password' in needs_update:
            needs_update['password'] = '**HIDDEN**'
        ret['comment'] = 'Set the following fields for account ID {0} ({1}): {2}'.format(
            account_id, name, pprint.pformat(needs_update))
        return ret
    else:
        ret['result'] = False
        ret['comment'] = 'Failed to set the following fields for account ID {0} ({1}): {2}'.format(
            account_id, name, pprint.pformat(needs_update))
        return ret
dataset/ETHPy150Open saltstack/salt/salt/states/stormpath_account.py/present