socialwifi / RouterOS-api

Python API to RouterBoard devices produced by MikroTik.
MIT License
251 stars 100 forks source link

Syntax Error When Setting v6 BGP Instance AS #91

Closed argoA closed 1 year ago

argoA commented 1 year ago

I am having issues with setting the AS of the /routing/bgp/instance on v6 RouterOS devices. The problem is 'as' is a keyword in Python. Used primarily for importing libraries under a separate alias. Attempting to use it in conjunction with the .set() command results in a syntax error.

Below is the code that I am attempting to implement:

bgp_instance = self.api.get_resource('/routing/bgp/instance')
bgp_instance = bgp_instance.get()
bgp_instance.set(id='*0', as='12345', router_id='192.168.1.1')

Is there a Pythonic way to work around this or a better way to utilize the library to accomplish what I am doing?

argoA commented 1 year ago

Utilizing ChatGPT, I was able to come to a work around utilizing the following code:

paramaters = {
             'id': '*0',
             'as': '12345',
             'router_id': '192.168.1.1'
         }

self.api.get_resource('/routing/bgp/instance').set(**paramaters)