Skip to content

Add tag support #19

Description

@luqasz

API has support for .tag which as name suggests, tags each response when request is tagged. This enables async usage of API and other issues:

  • Does library need to track each request and return a response when it is ready ?
  • API allows to use same tags multiple times
  • API may return multiple !trap errors
  • API behaves differently on different routeros versions
  • When tag is passed as '1' (int as a string) API must return same type.

on version 5.25 with url which is malformed:

<--- /tool/fetch (11)
<--- =url=http://wp.pl/xxx (21)
<--- .tag=3 (6)
<--- EOS

---> !re (3)
---> =status=connecting (18)
---> .tag=3 (6)
---> EOS
---> !re (3)
---> =status=failed (14)
---> .tag=3 (6)
---> EOS
---> !re (3)
---> =status=failed (14)
---> .tag=3 (6)
---> EOS

<--- /cancel (7)
<--- =tag=3 (6)
<--- .tag=7 (6)
<--- EOS

---> !trap (5)
---> =category=2 (11)
---> =message=interrupted (20)
---> .tag=3 (6)
---> EOS
---> !done (5)
---> .tag=7 (6)
---> EOS
---> !trap (5)
---> =message=failure: 301 Moved Permanently (39)
---> .tag=3 (6)
---> EOS
---> !done (5)
---> .tag=3 (6)
---> EOS

on version 6.1 with url that exists:

<--- /tool/fetch
<--- =url=http://noc.gts.pl/1mb.gts
<--- .tag=1
<--- EOS

---> !re
---> =status=connecting
---> .tag=1
---> EOS
---> !re
---> =status=downloading
---> =downloaded=753
---> =total=1000
---> =duration=2d09:29:51
---> .tag=1
---> EOS
---> !re
---> =status=finished
---> .tag=1
---> EOS
---> !done
---> .tag=1
---> EOS

on version 6.1 with url which is malformed:

<--- /tool/fetch
<--- =url=http://noc.gts.pl/1mb.gtsss
<--- .tag=1
<--- EOS

---> !re
---> =status=connecting
---> .tag=1
---> EOS
---> !re
---> =status=failed
---> .tag=1
---> EOS
---> !trap
---> =message=failure: closing connection: <404 Not Found> 217.153.108.10:80 (4)
---> .tag=1
---> EOS
---> !done
---> .tag=1
---> EOS

Canceling a listen command returns !trap which is not actually any error at all:

<--- '/ip/address/listen'
<--- '.tag=10'
<--- EOS

---> '!re'
---> '.tag=10'
---> '=.id=*A'
---> '=address=1.1.1.1/32'
---> '=network=1.1.1.1'
---> '=interface=br-lan'
---> '=actual-interface=br-lan'
---> '=invalid=false'
---> '=dynamic=false'
---> '=disabled=false'
---> EOS
---> '!re'
---> '.tag=10'
---> '=.id=*A'
---> '=.dead=true'
---> EOS

<--- '/cancel'
<--- '=tag=10'
<--- '.tag=20'
<--- EOS

---> '!trap'
---> '.tag=10'
---> '=category=2'
---> '=message=interrupted'
---> EOS
---> '!done'
---> '.tag=20'
---> EOS
---> '!done'
---> '.tag=10'
---> EOS

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions