-
Notifications
You must be signed in to change notification settings - Fork 7
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
Switch from telnet to API #6
Comments
Interested in this, will attempt to develop something to work out a pull request |
Okay, just made an initial API client implementation. It needs a lot of debugging and tests coverage, but it should be capable of doing some generic stuff at the moment. GitHub Repository Here Example usage: async with APIClient('<host>', <port>, '<username>', '<password>') as client:
await client.authenticate()
# Use functions from Telnet-based client
await client.get_devices()
# Use console commands
await client.api_request(ConsoleCommand('show version'))
# Multiline command expansion
await client.api_requests(ConsoleCommand('show', 'interfaces', ['1', '2']))
# Use RCI Post requests
await client.api_request({'show': {'version': {}}})
await client.api_requests([{'show': {'version': {}}}])
# Use dynamic accessors
await client.api.show.version()
await client.api.show('version')
await client.api.show.interfaces['1']
# Own sessions and out of context operation
session = aiohttp.ClientSession(timeout=50)
client = APIClient(..., session=session)
client.authenticate()
client.show.version()
await client.close()
# Telnet connector adapter (should be fast deprecated, but alas)
telnet_connection_object: TelnetConnection
async with APIClient.from_telnet_connection(telnet_connection_object) as client:
... I will continue refining this branch, but I would also like main developer (@foxel) to greenlight this progress, as this might require a major overhaul of the Telnet connector to maintain cross-compatibility. |
Hello @alryaz I've looked thru the code you are proposing and find it very promising. My initial idea was to have a single client with different connection methods available as Within my trial with HTTP API I faced a huge issue when guys from NDM Systems changed the way authentication works. Since that time I'm using Telnet as it's well documented in their CLI manuals. Currently deciding on which type of response is expected (dict/list/collection) is done by the Client class which is clearly limiting the development of HTTP connection as As of now, I see you have a separate |
@foxel FYI @notabene00 already created custom Also, there is well-documented set of helper functions written in PowerShell: https://github.com/ryzhovau/keenetic-powershell/tree/main/Public |
Hi @foxel,
Do you have plans to start using Keenetic API instead of telnet? I believe it will make the client more mature since JSON output the API returns is definitely more universal to parse comparing with tables returned in telnet mode.
The API is available on Keenetic devices by URL http://x.x.x.x/rci
The commands you use in TELNET are almost the same via API:
etc.
Thank you!
Regards,
Ilya
The text was updated successfully, but these errors were encountered: