package main

import (
	"log"
	"time"

	"github.com/kr/pretty"

	"lc/common/onvif/profiles/recording"
	"lc/common/onvif/soap"
)

func main() {

	// Create soap client
	client := soap.NewClient(
		soap.WithTimeout(time.Second * 5),
	)
	client.AddHeader(soap.NewWSSSecurityHeader("root", "pass"))

	var token recording.RecordingReference
	// Create service instance and specify xaddr (which could be received in the devicemgmt.GetServices())
	r := recording.NewRecordingPort(client, "http://192.168.27.66/onvif/services")
	{
		cr := recording.CreateRecording{RecordingConfiguration: recording.RecordingConfiguration{}}
		cr.RecordingConfiguration.Content = "mycontent"
		cr.RecordingConfiguration.MaximumRetentionTime = "P7D" //"PT0M30S"
		cr.RecordingConfiguration.Source =
			recording.RecordingSourceInformation{
				SourceId:    "http://192.168.27.66/onvif/services",
				Name:        "mysourcename",
				Location:    "mysourcelocation",
				Description: "mysourcedescription",
				Address:     "http://192.168.27.66/onvif/services"}

		reply, _ := r.CreateRecording(&cr)

		token = reply.RecordingToken

		dr := recording.DeleteRecording{RecordingToken: token}
		r.DeleteRecording(&dr)

		r.GetRecordings(&recording.GetRecordings{})

	}

	// .............

}
