Skip to content

Commit

Permalink
added get routes for type
Browse files Browse the repository at this point in the history
  • Loading branch information
Allan-Nava committed Jan 27, 2023
1 parent 055adef commit 12623b9
Show file tree
Hide file tree
Showing 6 changed files with 60 additions and 26 deletions.
6 changes: 6 additions & 0 deletions haivision/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ const (
// ROUTES
LIST_ROUTES = "/api/gateway/%s/routes"
CREATE_ROUTE = "/api/devices/%s/updates"
// STATS
ROUTES_STATISTICS = "/api/gateway/%s/statistics"
//
)

Expand All @@ -22,4 +24,8 @@ var (
return fmt.Sprintf(CREATE_ROUTE, deviceId)
}
//
GET_ROUTES_STATISTICS = func(deviceId string) string {
return fmt.Sprintf(ROUTES_STATISTICS, deviceId)
}
//
)
27 changes: 12 additions & 15 deletions haivision/haivision.go
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
package haivision

import (
"errors"
"fmt"
"strings"

"github.com/go-resty/resty/v2"

"github.com/Allan-Nava/Haivision-go-sdk/haivision/device"
"github.com/Allan-Nava/Haivision-go-sdk/haivision/route"
"github.com/Allan-Nava/Haivision-go-sdk/haivision/rtmp"
"github.com/Allan-Nava/Haivision-go-sdk/haivision/rtsp"
"github.com/Allan-Nava/Haivision-go-sdk/haivision/session"
"github.com/Allan-Nava/Haivision-go-sdk/haivision/srt"
"github.com/go-resty/resty/v2"
udprtp "github.com/Allan-Nava/Haivision-go-sdk/haivision/udp_rtp"
)

type Haivision struct {
Expand All @@ -20,32 +22,27 @@ type Haivision struct {
}

type IHaivisionClient interface {
//
HealthCheck() error
IsDebug() bool
// auth stuff
InitSession(username string, password string) (*session.BaseResponseInitSession, error)
GetSessionInfo() (*session.ResponseSessionInfo, error)
GetDeviceInfo() (*device.BaseResponseDeviceInfo, error)
// Streaming
//GetRoutes(deviceId string) (route.ResponseRoutes[TS, TD], error)
GetRoutesSRT(deviceId string) (route.ResponseRoutes[srt.RequestSourceModelSRT, srt.RequestDestinationModelSrt], error)
GetRoutesRTMP(deviceId string) (route.ResponseRoutes[rtmp.RequestSourceModelRTMP, rtmp.RequestDestinationModelRtmp], error)
// GetRoutes(deviceId string) (route.ResponseRoutes[TS, TD], error)
GetRoutesSRT(deviceId string) (*route.ResponseRoutes[srt.RequestSourceModelSRT, srt.RequestDestinationModelSrt], error)
GetRoutesRTMP(deviceId string) (*route.ResponseRoutes[rtmp.RequestSourceModelRTMP, rtmp.RequestDestinationModelRtmp], error)
GetRoutesRtsp(deviceId string) (*route.ResponseRoutes[rtsp.RequestSourceModelRTSP, rtsp.RequestDestinationModelRtsp], error)
GetRoutesUdpRtp(deviceId string) (*route.ResponseRoutes[udprtp.RequestSourceModelUdpRtp, udprtp.RequestDestinationModelUdpRtp], error)
// CreateRoute() error
//
}

func (o *Haivision) HealthCheck() error {
resp, err := o.restClient.R().
SetHeader("Accept", "application/json").
Get(o.Url)
//
_, err := o.restyGet(o.Url, nil)
if err != nil {
return err
}
//
if !strings.Contains(resp.Status(), "200") {
o.debugPrint(fmt.Sprintf("resp -> %v", resp))
return errors.New("could not connect haproxy")
return nil
}
return nil
}
Expand Down
39 changes: 28 additions & 11 deletions haivision/route.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
package haivision

import "log"
import (
"log"

"github.com/Allan-Nava/Haivision-go-sdk/haivision/route"
"github.com/Allan-Nava/Haivision-go-sdk/haivision/rtmp"
"github.com/Allan-Nava/Haivision-go-sdk/haivision/rtsp"
"github.com/Allan-Nava/Haivision-go-sdk/haivision/srt"
udprtp "github.com/Allan-Nava/Haivision-go-sdk/haivision/udp_rtp"
)

/*
Requests
Expand All @@ -19,13 +27,25 @@ Response
"pendingRouteCreates": 1
}
*/
func (o *Haivision) GetRoutes(deviceId string) error {
resp, err := o.restyGet(GET_LIST_OF_ROUTES(deviceId), nil)
if err != nil {
return err
}
log.Println(resp)
return nil

func (o *Haivision) GetRoutesSRT(deviceId string) (*route.ResponseRoutes[srt.RequestSourceModelSRT, srt.RequestDestinationModelSrt], error) {
log.Println("GetRoutesSRT ", deviceId)
return nil, nil
}

func (o *Haivision) GetRoutesRTMP(deviceId string) (*route.ResponseRoutes[rtmp.RequestSourceModelRTMP, rtmp.RequestDestinationModelRtmp], error) {
log.Println("GetRoutesRTMP ", deviceId)
return nil, nil
}

func (o *Haivision) GetRoutesRtsp(deviceId string) (*route.ResponseRoutes[rtsp.RequestSourceModelRTSP, rtsp.RequestDestinationModelRtsp], error) {
log.Println("GetRoutesRtsp ", deviceId)
return nil, nil
}

func (o *Haivision) GetRoutesUdpRtp(deviceId string) (*route.ResponseRoutes[udprtp.RequestSourceModelUdpRtp, udprtp.RequestDestinationModelUdpRtp], error) {
log.Println("GetRoutesRtsp ", deviceId)
return nil, nil
}

/*
Expand Down Expand Up @@ -59,6 +79,3 @@ Response
"status": "[success message]"
}
*/
func (o *Haivision) CreateRoute(name string) error {
return nil
}
12 changes: 12 additions & 0 deletions haivision/stats.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package haivision

/*
GET /api/gateway/[Device ID]/statistics?routeID=[Route ID]
cookie: sessionID: [Session ID]
*/

/*
Requests
GET /api/gateway/[Device ID]/statistics?routeID=[Route ID]&sourceID=[Source ID]
cookie: sessionID: [Session ID]
*/
1 change: 1 addition & 0 deletions haivision/stats/request.go
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package stats
1 change: 1 addition & 0 deletions haivision/stats/response.go
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package stats

0 comments on commit 12623b9

Please sign in to comment.