def METHOD_NAME(data, roles, users, owner, ana, errors):
    """Create a deposit and add privileges and owner information."""
    from cap.modules.deposit.api import CAPDeposit
    # make sure the schema is valid first
    if not check_and_update_data_with_schema(data, ana):
        return
    with db.session.begin_nested():
        try:
            # saving original to return to user if wrong
            _data = copy.deepcopy(data)
            owner = get_existing_or_register_user(owner) if owner else None
            deposit = CAPDeposit.create(data=data, owner=owner)
            # add roles and users
            if roles:
                for role in roles:
                    _role = get_existing_or_register_role(role.strip())
                    deposit._add_egroup_permissions(
                        _role, ['deposit-read'], db.session)
            if users:
                for user in users:
                    _user = get_existing_or_register_user(user.strip())
                    deposit._add_user_permissions(
                        _user, ['deposit-read'], db.session)
            deposit.commit()
        except ValidationError as err:
            click.secho(f'Validation Error: {err.message}', fg='red')
            errors.append(_data)
            return
    db.session.commit()
    click.secho(f"Created deposit with id: {deposit['_deposit']['id']}", fg='green')  # noqa