Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package main
import (
apiclient "code.fbi.h-da.de/cocsn/gosdn/restconf/api/client/ciena_waveserver_interfaces"
"code.fbi.h-da.de/cocsn/gosdn/restconf/util"
gosdnyang "code.fbi.h-da.de/cocsn/gosdn/yang-processor"
"crypto/tls"
"github.com/go-openapi/runtime"
httptransport "github.com/go-openapi/runtime/client"
"github.com/go-openapi/strfmt"
"log"
"net/http"
)
// hostname or IP only. No protocol prefix and no request suffix (I'm looking at you C//)
const ENDPOINT = "developer.ciena.com"
// Ciena Emulation Cloud only
const REQUEST_PREFIX = "externalApi/o1/64/o2/58?md5=PaR-iVYPq_fTUCvlqUBoVg&expires=1600707600&path="
const USERNAME = "dev"
const PASSWORD = "dev131526"
func main() {
// create the transport
transport := httptransport.New(ENDPOINT, REQUEST_PREFIX+"/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 := gosdnyang.CienaWaveserverInterfaces_WaveserverInterfaces{}
if err = gosdnyang.Unmarshal(buf, &logicalInterface); err != nil {
log.Fatal(err)
}
logicalInterface.IsYANGGoStruct()
}