Newer
Older
apiclient "code.fbi.h-da.de/cocsn/swagger/apis/ciena/client/ciena_waveserver_interfaces"
yang "code.fbi.h-da.de/cocsn/yang-modules/generated/ciena"
"crypto/tls"
"github.com/go-openapi/runtime"
httptransport "github.com/go-openapi/runtime/client"
"github.com/go-openapi/strfmt"
"log"
"net/http"
)
type WaveserverClient struct {
transport *runtime.ClientTransport
client *apiclient.ClientService
}
func NewWaveserverClient(endpoint, requestPrefix, username, password string) WaveserverClient {
transport := httptransport.New(endpoint, requestPrefix+"/restconf", nil)
transport.Transport.(*http.Transport).TLSClientConfig = &tls.Config{InsecureSkipVerify: true}
transport.Debug = true
transport.DefaultMediaType = runtime.JSONMime
// create the API client, with the transport
client := apiclient.New(transport, strfmt.Default).(*apiclient.Client)
basicAuth := httptransport.BasicAuth(username, password)
// authenticate client
transport.DefaultAuthentication = basicAuth
// change consumer to ygot unmashaler. Must be done here to avoid startup issues of go-openapi
buf := make([]byte, 0)
transport.Consumers[runtime.JSONMime] = util.YANGConsumer{Data: &buf}
// make the request to get all logical interfaces. nil params for defaults
_, err := client.GetDataWaveserverInterfacesLogicalInterface(nil)
if err != nil {
log.Fatal(err)
}
logicalInterface := yang.CienaWaveserverInterfaces_WaveserverInterfaces{}
if err = yang.Unmarshal(buf, &logicalInterface); err != nil {
func (c WaveserverClient) GetConfig() string {
return "generic client, not implemented yet"
}