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

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

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

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

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

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

    ret = {'name': kwargs['name'],
           'changes': {},
           'result': None,
           'comment': ''}
    result = create_or_update_resource(resource,
                                       identifier_fields,
                                       kwargs,
                                       diff=diff,
                                       profile=profile,
                                       subdomain=subdomain,
                                       api_key=api_key)
    if result is True:
        pass
    elif result is None:
        ret['result'] = True
    elif __opts__['test']:
        ret['comment'] = result
    elif 'error' in result:
        ret['result'] = False
        ret['comment'] = result
    else:
        ret['result'] = True
        ret['comment'] = result
    return ret