Skip to content

Commit

Permalink
Add device get-network-interfaces command.
Browse files Browse the repository at this point in the history
  • Loading branch information
osery committed Nov 18, 2022
1 parent bc34702 commit cbfc11f
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
1 change: 1 addition & 0 deletions cmd/gonvif/device/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ func init() {
root.Command.AddCommand(cmd)
cmd.AddCommand(
getDeviceInformation,
getNetworkInterfaces,
getServices,
systemReboot,
)
Expand Down
29 changes: 29 additions & 0 deletions cmd/gonvif/device/get-network-interfaces.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package media

import (
"github.com/spf13/cobra"

"github.com/eyetowers/gonvif/cmd/gonvif/root"
"github.com/eyetowers/gonvif/pkg/generated/onvif/www_onvif_org/ver10/device/wsdl"
)

var getNetworkInterfaces = &cobra.Command{
Use: "get-network-interfaces",
Short: "List Onvif device network interfaces",
Args: cobra.NoArgs,
RunE: func(cmd *cobra.Command, args []string) error {
client, err := ServiceClient(root.URL, root.Username, root.Password, root.Verbose)
if err != nil {
return err
}
return runGetNetworkInterfaces(client)
},
}

func runGetNetworkInterfaces(client wsdl.Device) error {
resp, err := client.GetNetworkInterfaces(&wsdl.GetNetworkInterfaces{})
if err != nil {
return err
}
return root.OutputJSON(resp)
}

0 comments on commit cbfc11f

Please sign in to comment.