Skip to main content

No project description provided

Project description

Python package

MikrotikApi

MikrotikApi is a project intended for managing RouterOS.

:warning: WARNING: This project is currently in a beta stage. It's still under active development and might undergo changes. Use it at your own risk.

Installation

MikrotikApi was developed using the Python programming language. You can install the project's dependencies with pip:

pip install mikrotikapi

Or using poetry:

poetry add mikrotikapi

Usage

import os
from mikrotikapi import ROSApi
from mikrotikapi.schemes import NatScheme
from mikrotikapi.schemes.fields.action import ActionController
from mikrotikapi.schemes.fields.chain import ChainController



your_login = os.getenv("your_login")
your_password = os.getenv("your_password")
mikrotik_address = os.getenv("mikrotik_address") # look setting www-ssl port
mikrotik_port = os.getenv("mikrotik_port")

api = ROSApi(
    url=mikrotik_address,
    username=your_login,
    password=your_password,
)

nat = NatScheme(
    src_address="172.22.8.0/30",
    chain="srcnat",
    action="masquerade",
)

# NatScheme(to_addresses=None, chain=<ChainController.srcnat: 'srcnat'>,
# dst_addresses=None, dst_address=None, src_address_list=None, src_address=IPv4Network
# ('172.22.8.0/30'), action=<ActionController.masquerade: 'masquerade'>, 
# to_ports=None, protocol=None, id=None, bytes=0, comment='', disabled=False, 
# dst_port=None, dynamic=None, invalid=None, log=False, log_prefix='', packets=None,
# routing_mark=None, in_interface='', out_interface='')

# or...

nat = NatScheme(
    src_address="172.22.8.0/30",
    chain=ChainController.srcnat,
    action=ActionController.masquerade,
)

# or...
nat = NatScheme()
nat.src_address = "172.22.8.0/30"
nat.chain = ChainController.srcnat
nat.action = ActionController.masquerade

# create
api.create(nat)

# or update
nat.comment = "first comment"
api.update(nat) # old api.objects(NatScheme).update(nat)

# or...

all_nats = api.objects(NatScheme).all()

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mikrotikapi-0.4.2.tar.gz (15.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mikrotikapi-0.4.2-py3-none-any.whl (29.7 kB view details)

Uploaded Python 3

File details

Details for the file mikrotikapi-0.4.2.tar.gz.

File metadata

  • Download URL: mikrotikapi-0.4.2.tar.gz
  • Upload date:
  • Size: 15.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.2 CPython/3.10.13 Linux/6.5.0-1015-azure

File hashes

Hashes for mikrotikapi-0.4.2.tar.gz
Algorithm Hash digest
SHA256 8858b1ebf510cb31226b0e40f1a39c9b11e8a9247f13133499bf27fc329386e5
MD5 cf91b44ab022b8d7ef8530cb9d342ec9
BLAKE2b-256 b60aaa384118697fd5249eab5877744c7c2e44ad8f1481dc4f1d52f30524f6f0

See more details on using hashes here.

File details

Details for the file mikrotikapi-0.4.2-py3-none-any.whl.

File metadata

  • Download URL: mikrotikapi-0.4.2-py3-none-any.whl
  • Upload date:
  • Size: 29.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.2 CPython/3.10.13 Linux/6.5.0-1015-azure

File hashes

Hashes for mikrotikapi-0.4.2-py3-none-any.whl
Algorithm Hash digest
SHA256 338d253d95cbe9e67e1b1820ac4e44d07225b60e110cb6ed56187fc1e27530ff
MD5 bc815879f2b38ee469578a31fa17a8b5
BLAKE2b-256 8cb8b4f9aa4b6bc9e1b8803ce22f9aa1c0a871bb2bfc9fa37b75bc612a93c27c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page