forked from netbox-community/go-netbox
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Helper functions for most common configurations.
- Loading branch information
Showing
5 changed files
with
54 additions
and
86 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,8 @@ | ||
|
||
generate: | ||
swagger generate client --target=./netbox --spec=./swagger.json --copyright-file=./copyright_header.txt | ||
|
||
clean: | ||
rm -rf netbox/* | ||
rm -rf netbox/client netbox/models | ||
|
||
integration: | ||
go test ./... -tags=integration |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package netbox | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/go-openapi/strfmt" | ||
runtimeclient "github.com/go-openapi/runtime/client" | ||
|
||
"github.com/digitalocean/go-netbox/netbox/client" | ||
) | ||
|
||
func NewNetboxAt(host string) *client.NetBox { | ||
t := client.DefaultTransportConfig().WithHost(host) | ||
return client.NewHTTPClientWithConfig(strfmt.Default, t) | ||
} | ||
|
||
const authHeaderName = "Authorization" | ||
const authHeaderFormat = "Token %v" | ||
func NewNetboxWithAPIKey(host string, apiToken string) *client.NetBox { | ||
t := runtimeclient.New(host, client.DefaultBasePath, client.DefaultSchemes) | ||
t.DefaultAuthentication = runtimeclient.APIKeyAuth(authHeaderName, "header", fmt.Sprintf(authHeaderFormat, apiToken)) | ||
return client.New(t, strfmt.Default) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters