(mesos_master_fqdn, mesos_secret_path)
return execute_request
Helper function for making all API requests
    :returns: a function that can be called to make a request
Helper function for making all API requests
    :returns: a function that can be called to make a request
Helper function for making all API requests : returns : a function that can be called to make a request
def base_api(mesos_master_fqdn, mesos_secret_path):
    """Helper function for making all API requests
    :returns: a function that can be called to make a request
    """

    def execute_request(method, endpoint, timeout=(3, 1), **kwargs):
        url = "http://%s:%d%s" % (mesos_master_fqdn, MESOS_MASTER_PORT, endpoint)
        s = Session()
        s.auth = (get_principal(mesos_secret_path), get_secret(mesos_secret_path))
        req = Request(method, url, **kwargs)
        prepared = s.prepare_request(req)
        try:
            resp = s.send(prepared, timeout=timeout,)
            resp.raise_for_status()
            return resp
        except HTTPError:
            raise HTTPError("Error executing API request calling %s." % url)

    return execute_request
def base_api ( mesos_master_fqdn , mesos_secret_path ) : def execute_request ( method , endpoint , timeout = ( 3 , 1 ) , * * kwargs ) : url = "http://%s:%d%s" % ( mesos_master_fqdn , MESOS_MASTER_PORT , endpoint ) s = Session ( ) s . auth = ( get_principal ( mesos_secret_path ) , get_secret ( mesos_secret_path ) ) req = Request ( method , url , * * kwargs ) prepared = s . prepare_request ( req ) try : resp = s . send ( prepared , timeout = timeout , ) resp . raise_for_status ( ) return resp except HTTPError : raise HTTPError ( "Error executing API request calling %s." % url ) return execute_request