Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/staskobzar/goami2
Simple Asterisk Manager Interface (AMI) library fo golang
https://github.com/staskobzar/goami2
ami asterisk go golang library
Last synced: about 1 month ago
JSON representation
Simple Asterisk Manager Interface (AMI) library fo golang
- Host: GitHub
- URL: https://github.com/staskobzar/goami2
- Owner: staskobzar
- License: mit
- Created: 2019-06-03T19:57:25.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2024-04-14T12:39:38.000Z (8 months ago)
- Last Synced: 2024-04-14T13:01:17.275Z (8 months ago)
- Topics: ami, asterisk, go, golang, library
- Language: Go
- Homepage:
- Size: 123 KB
- Stars: 14
- Watchers: 3
- Forks: 1
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-go - goami2 - AMI v2 library for Asterisk PBX. (Third-party APIs / Utility/Miscellaneous)
- awesome-go-extra - goami2 - 06-03T19:57:25Z|2022-06-24T15:33:22Z| (Third-party APIs / Fail injection)
README
# goami2: Simple Asterisk Manager Interface (AMI) library
[![Build Status](https://github.com/staskobzar/goami2/actions/workflows/ci.yml/badge.svg)](https://github.com/staskobzar/goami2/actions/workflows/ci.yml)
[![Go Report Card](https://goreportcard.com/badge/github.com/staskobzar/goami2)](https://goreportcard.com/report/github.com/staskobzar/goami2)
[![codecov](https://codecov.io/gh/staskobzar/goami2/branch/master/graph/badge.svg)](https://codecov.io/gh/staskobzar/goami2)
[![GitHub go.mod Go version of a Go module](https://img.shields.io/github/go-mod/go-version/gomods/athens.svg)](https://github.com/staskobzar/goami2)
[![GitHub release](https://img.shields.io/github/release/staskobzar/goami2.svg)](https://github.com/staskobzar/goami2/releases)
[![Go Reference](https://pkg.go.dev/badge/github.com/staskobzar/goami2.svg)](https://pkg.go.dev/github.com/staskobzar/goami2)Go library that provides interface to Asteris AMI. The library uses given ```net.Conn``` (tcp or tls), login
and starts reading AMI messages from connection and parse them into ```*Message``` object.
Provides simple interface to send messages to AMI.
It uses ```re2c``` to create very fast protocol parser. Run "make bench" for benchmark tests.Usage example:
```go
import (
"errors"
"fmt"
"log"
"net""github.com/staskobzar/goami2"
)func main() {
conn, err := net.Dial("tcp", "asterisk.host:5038")
if err != nil {
log.Fatalln(err)
}// login and create client
client, err := goami2.NewClient(conn, "admin", "pa55w0rd")
if err != nil {
log.Fatalln(err)
}log.Println("client connected and logged in")
// create AMI Action message and send to the asterisk.host
msg := goami2.NewAction("CoreStatus")
msg.AddActionID()
client.Send(msg.Byte())defer client.Close() // close connections and all channels
for {
select {
case msg := <-client.AllMessages():
log.Printf("Got message: %s\n", msg.JSON())
case err := <-client.Err():
// terminate on network closed
if errors.Is(err, goami2.ErrEOF) {
log.Fatalf("Connection error: %s", err)
}
log.Printf("WARNING: AMI client error: %s", err)
}
}
}
```## Docs
See documentation at [https://pkg.go.dev/github.com/staskobzar/goami2](https://pkg.go.dev/github.com/staskobzar/goami2)