patch any object in kubernetes based on URL

def _kpatch(url, data):
    ''' patch any object in kubernetes based on URL '''

    # Prepare headers
    headers = {"Content-Type": "application/json-patch+json"}
    # Make request
    ret = http.query(url, method='PATCH', header_dict=headers,
                     data=salt.utils.json.dumps(data))
    # Check requests status
    if ret.get('error'):
        log.error("Got an error: %s", ret.get("error"))
        return ret
    else:
        return salt.utils.json.loads(ret.get('body'))