File tree Expand file tree Collapse file tree 3 files changed +31
-0
lines changed Expand file tree Collapse file tree 3 files changed +31
-0
lines changed Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ module github.com/netbox-community/go-netbox/v3
33go 1.21
44
55require (
6+ github.com/deepmap/oapi-codegen v1.15.0
67 github.com/oapi-codegen/runtime v1.0.0
78 gopkg.in/yaml.v2 v2.4.0
89)
Original file line number Diff line number Diff line change @@ -5,6 +5,8 @@ github.com/bmatcuk/doublestar v1.1.1/go.mod h1:UD6OnuiIn0yFxxA2le/rnRU1G4RaI4UvF
55github.202132.xyz/davecgh/go-spew v1.1.0 /go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38 =
66github.202132.xyz/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c =
77github.202132.xyz/davecgh/go-spew v1.1.1 /go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38 =
8+ github.com/deepmap/oapi-codegen v1.15.0 h1:SQqViaeb4k2vMul8gx12oDOIadEtoRqTdLkxjzqtQ90 =
9+ github.com/deepmap/oapi-codegen v1.15.0 /go.mod h1:a6KoHV7lMRwsPoEg2C6NDHiXYV3EQfiFocOlJ8dgJQE =
810github.202132.xyz/google/uuid v1.3.1 h1:KjJaJ9iWZ3jOFZIf1Lqf4laDRCasjl0BCmnEGxkdLb4 =
911github.202132.xyz/google/uuid v1.3.1 /go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo =
1012github.202132.xyz/juju/gnuflag v0.0.0-20171113085948-2ce1bb71843d /go.mod h1:2PavIy+JPciBPrBUjwbNvtwB6RQlve+hkpll6QSNmOE =
Original file line number Diff line number Diff line change @@ -2,3 +2,31 @@ package netbox
22
33//go:generate oapi-codegen -package netbox -generate types -o types.go api/openapi.yaml
44//go:generate oapi-codegen -package netbox -generate client -o client.go api/openapi.yaml
5+
6+ import (
7+ "fmt"
8+
9+ "github.com/deepmap/oapi-codegen/pkg/securityprovider"
10+ )
11+
12+ const authHeaderName = "Authorization"
13+ const authHeaderFormat = "Token %v"
14+
15+ func NewClientWithToken (host string , token string , opts ... ClientOption ) (* Client , error ) {
16+ provider , err := securityprovider .NewSecurityProviderApiKey (
17+ "header" ,
18+ authHeaderName ,
19+ fmt .Sprintf (authHeaderFormat , token ),
20+ )
21+
22+ if err != nil {
23+ return nil , err
24+ }
25+
26+ opts = append (
27+ opts ,
28+ WithRequestEditorFn (provider .Intercept ),
29+ )
30+
31+ return NewClient (host , opts ... )
32+ }
You can’t perform that action at this time.
0 commit comments