Logo

Mikrotik ORM (mikorm)

Library Mikrotik API menggunakan ORM untuk mempermudah integrasi ke Mikrotik

Acknowledgements

Badges

MIT License
GPLv3 License
AGPL License

Authors

Installation

Install mikorm with go get

go get github.com/didintri196/[email protected]

Usage/Examples

package main

import (
	"fmt"
	"github.com/didintri196/mikorm"
)

func main() {
	config := mikorm.Configs{
		Ip:        "127.0.0.1",
		Port:      "8728",
		Username:  "admin",
		Password:  "",
		ModeDebug: true,
	}
	connRouteOS := mikorm.New(config)

......

}

Documentation

Documentation

Features

type SecretRepository struct {
    MikORM *mikorm.MikORM
}

func (repo SecretRepository) Browse(filter models.Secret) (secrets []models.Secret, err error) {
    err = repo.MikORM.Command("/ppp/secret").Where(&filter).Scan(&secrets).Error
    return
}

func (repo SecretRepository) Add(secret models.Secret) (err error) {
    return repo.MikORM.Command("/ppp/secret").Add(&secret).Error
}

func (repo SecretRepository) Read(filter models.Secret) (secret models.Secret, err error) {
    err = repo.MikORM.Command("/ppp/secret").Where(&filter).Print(&secret).Error
    return
}

func (repo SecretRepository) Edit(filter models.Secret, data models.Secret) (err error) {
    err = repo.MikORM.Command("/ppp/secret").SetByID("", &data).Error
    return
}

func (repo SecretRepository) Remove(ID string) (err error) {
    err = repo.MikORM.Command("/ppp/secret").RemoveByID(ID).Error
    return
}

func (repo SecretRepository) Enable(ID string) (err error) {
    err = repo.MikORM.Command("/ppp/secret").EnableByID(ID).Error
    return
}

func (repo SecretRepository) Disable(ID string) (err error) {
    err = repo.MikORM.Command("/ppp/secret").DisableByID(ID).Error
    return
}

GitHub

View Github