Generic resource.absent state method.   Pagerduty state modules should be a thin wrapper over this method,
    with a custom diff function.

    This method calls delete_resource() and formats the result as a salt state return value.

    example:
            resource_absent("users", ["id","name","email"])

def resource_absent(resource, identifier_fields, profile='pagerduty', subdomain=None, api_key=None, **kwargs):
    '''
    Generic resource.absent state method.   Pagerduty state modules should be a thin wrapper over this method,
    with a custom diff function.

    This method calls delete_resource() and formats the result as a salt state return value.

    example:
            resource_absent("users", ["id","name","email"])
    '''
    ret = {'name': kwargs['name'],
           'changes': {},
           'result': None,
           'comment': ''}
    for k, v in kwargs.items():
        if k not in identifier_fields:
            continue
        result = delete_resource(resource,
                                 v,
                                 identifier_fields,
                                 profile=profile,
                                 subdomain=subdomain,
                                 api_key=api_key)
        if result is None:
            ret['result'] = True
            ret['comment'] = '{0} deleted'.format(v)
            return ret
        elif result is True:
            continue
        elif __opts__['test']:
            ret['comment'] = result
            return ret
        elif 'error' in result:
            ret['result'] = False
            ret['comment'] = result
            return ret
    return ret