golangzerotierapi

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Mar 15, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	BaseURL  string
	Token    string
	Insecure bool
}

Client represents a client for interacting with the ZeroTier API.

func NewClient

func NewClient(baseURL string, token string, insecure bool) *Client

NnwClient creates a new instance of Client with the provided base URL and API token.

func (*Client) CreateNetwork

func (c *Client) CreateNetwork() (Network, error)

CreateNetwork creates a new network. It returns the created Network struct and an error if any.

func (*Client) DeleteNetwork

func (c *Client) DeleteNetwork(networkID string) error

DeleteNetwork deletes a network identified by its ID. It returns an error if any.

func (*Client) DeleteNetworkMember

func (c *Client) DeleteNetworkMember(networkID string, memberID string) error

DeleteNetworkMember deletes a member from a network identified by their IDs. It returns an error if any.

func (*Client) GetNetwork

func (c *Client) GetNetwork(networkID string) (Network, error)

GetNetwork retrieves details of a specific network identified by its ID. It returns a Network struct and an error if any.

func (*Client) GetNetworkList

func (c *Client) GetNetworkList() ([]Network, error)

GetNetworkList retrieves a list of networks. It returns a slice of Network structs and an error if any.

func (*Client) GetNetworkMember

func (c *Client) GetNetworkMember(networkID string, memberID string) (NetworkMember, error)

GetNetworkMember retrieves details of a specific network member identified by its ID and the network's ID. It returns a NetworkMember struct and an error if any.

func (*Client) GetNetworkMemberList

func (c *Client) GetNetworkMemberList(networkID string) ([]NetworkMember, error)

GetNetworkMemberList retrieves a list of members belonging to a specific network identified by its ID. It returns a slice of NetworkMember structs and an error if any.

func (*Client) MakeDeleteRequest

func (c *Client) MakeDeleteRequest(url string) error

makeDeleteRequest performs a DELETE request to the specified URL. It returns an error if any.

func (*Client) MakeGetRequest

func (c *Client) MakeGetRequest(url string) ([]byte, error)

makeGetRequest performs a GET request to the specified URL. It returns the response body ([]byte) and an error if any.

func (*Client) MakePostRequest

func (c *Client) MakePostRequest(url string, data io.Reader) ([]byte, error)

makePostRequest performs a POST request to the specified URL with the provided data. It returns the response body ([]byte) and an error if any.

func (*Client) UpdateNetwork

func (c *Client) UpdateNetwork(networkID string, network UpdateNetwork) (Network, error)

UpdateNetwork updates an existing network identified by its ID with the provided data. It returns the updated Network struct and an error if any.

func (*Client) UpdateNetworkMember

func (c *Client) UpdateNetworkMember(networkID string, memberID string, member UpdateNetworkMember) (NetworkMember, error)

UpdateNetworkMember updates an existing member in a network identified by their IDs. It takes an UpdateNetworkMember struct containing the updated member information. It returns a NetworkMember struct and an error if any. STILL BROKEN!

type Network

type Network struct {
	ID                    string         `json:"id"`
	Type                  string         `json:"type"`
	Clock                 int64          `json:"clock"`
	Config                *NetworkConfig `json:"config"`
	Description           string         `json:"description"`
	RulesSource           string         `json:"rulesSource"`
	OwnerID               string         `json:"ownerId"`
	OnlineMemberCount     int            `json:"onlineMemberCount"`
	AuthorizedMemberCount int            `json:"authorizedMemberCount"`
	TotalMemberCount      int            `json:"totalMemberCount"`
	CapabilitiesByName    struct {
	} `json:"capabilitiesByName"`
	TagsByName struct {
		Server struct {
			Default int `json:"default"`
			Enums   struct {
				False int `json:"false"`
				True  int `json:"true"`
			} `json:"enums"`
			Flags struct {
			} `json:"flags"`
			ID int `json:"id"`
		} `json:"server"`
	} `json:"tagsByName"`
	UI struct {
		MembersHelpCollapsed  bool `json:"membersHelpCollapsed"`
		RulesHelpCollapsed    bool `json:"rulesHelpCollapsed"`
		SettingsHelpCollapsed bool `json:"settingsHelpCollapsed"`
		V4EasyMode            bool `json:"v4EasyMode"`
	} `json:"ui"`
}

type NetworkConfig

type NetworkConfig struct {
	AuthTokens        string   `json:"authTokens"`
	CreationTime      int64    `json:"creationTime"`
	Capabilities      []string `json:"capabilities"`
	EnableBroadcast   bool     `json:"enableBroadcast"`
	ID                string   `json:"id"`
	IPAssignmentPools []struct {
		IPRangeStart string `json:"ipRangeStart"`
		IPRangeEnd   string `json:"ipRangeEnd"`
	} `json:"ipAssignmentPools"`
	LastModified      int64       `json:"lastModified"`
	Mtu               int         `json:"mtu"`
	MulticastLimit    int         `json:"multicastLimit"`
	Name              string      `json:"name"`
	Private           bool        `json:"private"`
	RemoteTraceLevel  int         `json:"remoteTraceLevel"`
	RemoteTraceTarget interface{} `json:"remoteTraceTarget"`
	Routes            []struct {
		Target string `json:"target"`
		Via    string `json:"via,omitempty"`
	} `json:"routes"`
	Rules []Rules `json:"rules"`
	Tags  []struct {
		Default int `json:"default"`
		ID      int `json:"id"`
	} `json:"tags"`
	V4AssignMode struct {
		Zt bool `json:"zt"`
	} `json:"v4AssignMode"`
	V6AssignMode struct {
		SixPlane bool `json:"6plane"`
		Rfc4193  bool `json:"rfc4193"`
		Zt       bool `json:"zt"`
	} `json:"v6AssignMode"`
	DNS struct {
		Domain  string      `json:"domain"`
		Servers interface{} `json:"servers"`
	} `json:"dns"`
	SsoConfig struct {
		Enabled bool   `json:"enabled"`
		Mode    string `json:"mode"`
	} `json:"ssoConfig"`
}

type NetworkMember

type NetworkMember struct {
	ID           string `json:"id"`
	Type         string `json:"type"`
	Clock        int64  `json:"clock"`
	NetworkID    string `json:"networkId"`
	NodeID       string `json:"nodeId"`
	ControllerID string `json:"controllerId"`
	Hidden       bool   `json:"hidden"`
	Name         string `json:"name"`
	Description  string `json:"description"`
	Config       struct {
		ActiveBridge         bool     `json:"activeBridge"`
		Address              string   `json:"address"`
		Authorized           bool     `json:"authorized"`
		Capabilities         []int    `json:"capabilities"`
		CreationTime         int64    `json:"creationTime"`
		ID                   string   `json:"id"`
		Identity             string   `json:"identity"`
		IPAssignments        []string `json:"ipAssignments"`
		LastAuthorizedTime   int64    `json:"lastAuthorizedTime"`
		LastDeauthorizedTime int      `json:"lastDeauthorizedTime"`
		NoAutoAssignIps      bool     `json:"noAutoAssignIps"`
		Nwid                 string   `json:"nwid"`
		Objtype              string   `json:"objtype"`
		RemoteTraceLevel     int      `json:"remoteTraceLevel"`
		RemoteTraceTarget    string   `json:"remoteTraceTarget"`
		Revision             int      `json:"revision"`
		Tags                 [][]int  `json:"tags"`
		VMajor               int      `json:"vMajor"`
		VMinor               int      `json:"vMinor"`
		VRev                 int      `json:"vRev"`
		VProto               int      `json:"vProto"`
		SsoExempt            bool     `json:"ssoExempt"`
	} `json:"config"`
	LastOnline          int64  `json:"lastOnline"`
	LastSeen            int64  `json:"lastSeen"`
	PhysicalAddress     string `json:"physicalAddress"`
	PhysicalLocation    string `json:"physicalLocation"`
	ClientVersion       string `json:"clientVersion"`
	ProtocolVersion     int    `json:"protocolVersion"`
	SupportsRulesEngine bool   `json:"supportsRulesEngine"`
}

type Rules added in v0.1.1

type Rules struct {
	EtherType int    `json:"etherType,omitempty"`
	Not       bool   `json:"not,omitempty"`
	Or        bool   `json:"or,omitempty"`
	Type      string `json:"type"`
	ID        int    `json:"id,omitempty"`
	Value     int    `json:"value,omitempty"`
}

type UpdateNetwork

type UpdateNetwork struct {
	Config      NetworkConfig `json:"config"`
	Description string        `json:"description"`
	RulesSource string        `json:"rulesSource"`
	Permissions struct {
		Zero0000000000000000000000000000000 struct {
			A bool `json:"a"`
			D bool `json:"d"`
			M bool `json:"m"`
			R bool `json:"r"`
		} `json:"00000000-0000-0000-0000-000000000000"`
	} `json:"permissions"`
	OwnerID            string `json:"ownerId"`
	CapabilitiesByName struct {
	} `json:"capabilitiesByName"`
	TagsByName struct {
	} `json:"tagsByName"`
}

type UpdateNetworkMember

type UpdateNetworkMember struct {
	Hidden      bool   `json:"hidden"`
	Name        string `json:"name"`
	Description string `json:"description"`
	Config      struct {
		ActiveBridge    bool     `json:"activeBridge"`
		Authorized      bool     `json:"authorized"`
		Capabilities    []int    `json:"capabilities"`
		IPAssignments   []string `json:"ipAssignments"`
		NoAutoAssignIps bool     `json:"noAutoAssignIps"`
		Tags            [][]int  `json:"tags"`
	} `json:"config"`
}

Jump to

Keyboard shortcuts

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