Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proxy feature #201

Open
TitouanS31 opened this issue Jun 18, 2024 · 4 comments · May be fixed by #225
Open

Proxy feature #201

TitouanS31 opened this issue Jun 18, 2024 · 4 comments · May be fixed by #225

Comments

@TitouanS31
Copy link

It would be great to have a proxy option for api calls. We could hence do something like this.

proxies = {
    "http": "http://my_super_proxy.com:1234",
    "https": "https://my_super_proxy.com:1234",
}

nautobot = pynautobot.api(
    url = "https://demo.nautobot.com",
    token = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
    proxies = proxies
)
@glennmatthews
Copy link
Contributor

As a workaround, you can probably set the standard HTTP_PROXY and HTTPS_PROXY environment variables.

@joewesch
Copy link
Contributor

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",
}

@TitouanS31
Copy link
Author

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.

@joewesch
Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants