netdisco

package module
v0.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 1, 2021 License: Apache-2.0 Imports: 13 Imported by: 4

README

go-netdisco

It's a client lib written in go for netdisco.

For now only searching device is supported as it was the only thing we wanted for now.

Usage

import with go get github.com/orange-cloudfoundry/go-netdisco

You can now use lib in this way:

package main

import (
	"fmt"
	"github.com/orange-cloudfoundry/go-netdisco"
)

func main() {
	client := netdisco.NewClient("https://netdisco2-demo.herokuapp.com", "guest", "guest", false)
	devices, err := client.SearchDevice(&netdisco.SearchDeviceQuery{
		Layers:   "7",
		Matchall: false,
	})
	if err != nil {
		panic(err)
	}
	fmt.Println(devices)
}

Documentation

Index

Constants

View Source
const SeparatorByte byte = 255

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthTransport

type AuthTransport struct {
	ApiKey        string
	WrapTransport http.RoundTripper
}

func NewTransport

func NewTransport(apiKey string, insecureSkipVerify bool) *AuthTransport

func (AuthTransport) RoundTrip

func (t AuthTransport) RoundTrip(req *http.Request) (*http.Response, error)

type Client

type Client struct {
	// contains filtered or unexported fields
}

func NewClient

func NewClient(endpoint, username, password string, insecureSkipVerify bool) *Client

func (*Client) Do

func (c *Client) Do(method, path string, query, value interface{}) error

func (*Client) DoWithRetry

func (c *Client) DoWithRetry(req *http.Request, value interface{}) error

func (*Client) Login

func (c *Client) Login() error

func (*Client) NewRequest

func (c *Client) NewRequest(method, path string, body io.Reader) (*http.Request, error)

func (*Client) SearchDevice

func (c *Client) SearchDevice(query *SearchDeviceQuery) ([]Device, error)

func (*Client) UnmarshalResponse

func (c *Client) UnmarshalResponse(resp *http.Response, value interface{}, validResponseCode ...int) error

type Device

type Device struct {
	UptimeAge         string  `json:"uptime_age"`
	Location          string  `json:"location"`
	SinceLastArpnip   float64 `json:"since_last_arpnip"`
	FirstSeenStamp    string  `json:"first_seen_stamp"`
	OsVer             string  `json:"os_ver"`
	Name              string  `json:"name"`
	LastArpnipStamp   string  `json:"last_arpnip_stamp"`
	Model             string  `json:"model"`
	SinceFirstSeen    float64 `json:"since_first_seen"`
	IP                string  `json:"ip"`
	Serial            string  `json:"serial"`
	SinceLastMacsuck  float64 `json:"since_last_macsuck"`
	DNS               string  `json:"dns"`
	SinceLastDiscover float64 `json:"since_last_discover"`
	LastMacsuckStamp  string  `json:"last_macsuck_stamp"`
	LastDiscoverStamp string  `json:"last_discover_stamp"`
}

type SearchDeviceQuery

type SearchDeviceQuery struct {
	Q           string `json:"q" yaml:"q"`
	Name        string `json:"name" yaml:"name"`
	Location    string `json:"location" yaml:"location"`
	DNS         string `json:"dns" yaml:"dns"`
	Ip          string `json:"ip" yaml:"ip"`
	Description string `json:"description" yaml:"description"`
	Mac         string `json:"mac" yaml:"mac"`
	Model       string `json:"model" yaml:"model"`
	OS          string `json:"os" yaml:"os"`
	OSVer       string `json:"os_ver" yaml:"os_ver"`
	Vendor      string `json:"vendor" yaml:"vendor"`
	Layers      string `json:"layers" yaml:"layers"`
	Matchall    bool   `json:"matchall" yaml:"matchall"`
	// contains filtered or unexported fields
}

func (*SearchDeviceQuery) Id

func (q *SearchDeviceQuery) Id() uint64

func (*SearchDeviceQuery) Serialize

func (q *SearchDeviceQuery) Serialize() url.Values

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL