File tree 1 file changed +39
-0
lines changed
1 file changed +39
-0
lines changed Original file line number Diff line number Diff line change @@ -30,6 +30,45 @@ can pass `nil`:
30
30
c.Dcim .DcimDeviceTypesCreate (createRequest, nil )
31
31
```
32
32
33
+ If you connect to netbox via HTTPS you have to create an HTTPS configured transport:
34
+ ```
35
+ package main
36
+
37
+ import (
38
+ "os"
39
+
40
+ httptransport "github.com/go-openapi/runtime/client"
41
+ "github.com/netbox-community/go-netbox/netbox/client"
42
+ "github.com/netbox-community/go-netbox/netbox/client/dcim"
43
+
44
+ log "github.com/sirupsen/logrus"
45
+ )
46
+
47
+ func main() {
48
+ token := os.Getenv("NETBOX_TOKEN")
49
+ if token == "" {
50
+ log.Fatalf("Please provide netbox API token via env var NETBOX_TOKEN")
51
+ }
52
+
53
+ netboxHost := os.Getenv("NETBOX_HOST")
54
+ if netboxHost == "" {
55
+ log.Fatalf("Please provide netbox host via env var NETBOX_HOST")
56
+ }
57
+
58
+ transport := httptransport.New(netboxHost, client.DefaultBasePath, []string{"https"})
59
+ transport.DefaultAuthentication = httptransport.APIKeyAuth("Authorization", "header", "Token "+token)
60
+
61
+ c := client.New(transport, nil)
62
+
63
+ req := dcim.NewDcimSitesListParams()
64
+ res, err := c.Dcim.DcimSitesList(req, nil)
65
+ if err != nil {
66
+ log.Fatalf("Cannot get sites list: %v", err)
67
+ }
68
+ log.Infof("res: %v", res)
69
+ }
70
+ ```
71
+
33
72
Go Module support
34
73
================
35
74
You can’t perform that action at this time.
0 commit comments