Open TitouanS31 opened 5 months ago
As a workaround, you can probably set the standard HTTP_PROXY
and HTTPS_PROXY
environment variables.
This should already be possible by modifying the http session directly after you instantiate the API class in the same way you modify headers or other items.
nautobot = pynautobot.api(
url = "https://demo.nautobot.com",
token = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
)
nautobot.http_session.proxies = {
"http": "http://my_super_proxy.com:1234",
"https": "https://my_super_proxy.com:1234",
}
I though modifying the http session after the API instanciation would do the trick... but the api validation fails before exiting the call. I could catch the error and patch the session after all but I think that is not very clean. For now, I have just added 2 lines to the API __init__
function to handle the proxy.
Yes, I thought of that after giving you that update. We really need to change that auto-validation to happen during your first API call rather than on instantiation.
It would be great to have a proxy option for api calls. We could hence do something like this.