Open chadell opened 2 years ago
I don't think this would belong in the nautobot-plugin-chatops itself. There are no endpoints in this plugin. If other plugins implement endpoints, they could likely implement this themselves. I believe there are already examples of something similar to this in another plugin, let me see if I can find that.
Thanks @smk4664 , it is a totally valid point. However, from another angle, almost all the Chatops rely on "endpoints", so if we don't implement it here, all the other plugins will need to reinvent the wheel every time. The point is that these feature would be "optional", so you don't need to define endpoints, it's just a helper if the specific chatops needs this feature (most likely) Open to review it and adapt as needed
@chadell / @smk4664 what is the latest on this type of effort?
@jvanderaa
We had a sync with @smk4664 , considering the latest enhancements from Nautobot, and we could approach it creating a new model:
chatops_endpoints:
- name: "my fancy endpoint"
slug: "my-fancy-endpoint"
url: "https:/...."
plugin: FK(nautobot-plugin)
secret: FK(secrets)
verify_ssl: True
With this, you can create you endpoints, for multiple chatops plugins, and the in the chat, define the actual endtpoint with each chatops command. So /ipfabric
will look for the chatops_endpoints
that has the ipfabric
plugin related.
Where would this be placed at?
I got in touch with Core to understand if this idea (URL Endpoints) could be an extensibility option for Core. I am trying to get a more complete understanding of different use-cases across plugins, not only chatops ones.
This is going to be put into a new Nautobot App to provide the Endpoints model, likely External API's
.
Proposed Functionality
Today, most of the chatops plugins define a custom endpoint in its configuration with some custom authentication configuration.
The idea would be that instead of solving only the multi-instance for one specific chatops, we could extend this
nautobot_chatops
configuration to support a new (optional)endpoints
(or similar) key with a list of multiple endpoints (with a reference name), so the user would be able to switch between them in execution time using his own session.For example:
This change obviously doesn’t affect the previous chatops (it’s backwards compatible), so from the custom chatops plugins we can choose to use these new endpoints that will exposed via a wrapper on the current sessions methods, not on the specific chatops which will only focus on using the new methods to retrieve the URL and the proper authentication.
This feature will expose two methods:
get_endpoint
andset_endpoint
, that will leverage on the user's session, to save the "active" endpoint.Use Case
As a user of a Chatops integration, I would like to easily change from one endpoint to another, affecting only this specific user context.
So, having several endpoints defined, a user can jump from one to another, so all the commands executed will refer to the "active" endpoint: