Skip to content

Commit

Permalink
Add device system-reboot command.
Browse files Browse the repository at this point in the history
  • Loading branch information
osery committed Sep 30, 2022
1 parent a5f49b5 commit cc3d777
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 @@ -19,6 +19,7 @@ func init() {
cmd.AddCommand(
getDeviceInformation,
getServices,
systemReboot,
)
}

Expand Down
29 changes: 29 additions & 0 deletions cmd/gonvif/device/system-reboot.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 systemReboot = &cobra.Command{
Use: "system-reboot",
Short: "Reboot Onvif device",
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 runSystemReboot(client)
},
}

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

0 comments on commit cc3d777

Please sign in to comment.