twclient

package
v0.0.0-...-dec90ee Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2019 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetCertificates

func GetCertificates(certFile string, keyFile string) (caPool *x509.CertPool, keyPair tls.Certificate)

GetCertificates reads and prepares certificate files

Types

type Base

type Base struct {
	Name           string `json:"name,omitempty"`
	Description    string `json:"description,omitempty"`
	Organization   string `json:"organization_name,omitempty"`
	OrganizationID int    `json:"organization_id,omitempty"`
	Addr1          int    `json:"addr1"`
	Addr2          int    `json:"addr2"`
	Addr3          int    `json:"addr3"`
	Addr4          int    `json:"addr4"`
	Address        string `json:"address,omitempty"`
}

Base base object

type ClientConfig

type ClientConfig struct {
	HostConfig
	TransportConfig
}

ClientConfig hold all config required for creating client

func NewClientConfig

func NewClientConfig(hostConf *HostConfig, certFile string, keyFile string, httpRequestTimeout int, httpPoolConnections int) ClientConfig

NewClientConfig creates new client config

type Credentials

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

Credentials houses client keys

type ErrorResp

type ErrorResp struct {
	Status     string
	ErrorMsg   string
	StatusCode int
}

ErrorResp custom response

type HostConfig

type HostConfig struct {
	Host string
	Port string
}

HostConfig holds config for connecting to Ipam Server

type IObjectManager

type IObjectManager interface {
	CreateNetwork(network Network) (string, error)
	GetNetwork(ipAddr string, orgName string) (*Network, error)
	CreateSubnet(subnet Subnet) (string, error)
	GetSubnet(subnetAddr string, orgName string) (*Subnet, error)
	GetNextFreeIp(subnetAddr string, orgName string) (string, error)
	CreateIPAddress(ipAddr string, macAddr string, subnetAddr string, domain string, org string, name string) (string, error)
	DeleteIPAddress(ip string, subnetAddr string, organization string) error
}

IObjectManager defines methods for managing objects

type IPObjDel

type IPObjDel struct {
	Addresses   []string `json:"addressArray,omitempty"`
	Org         string   `json:"organization_name,omitempty"`
	DelRRSChked uint     `json:"isDeleterrsChecked"`
}

IPObjDel for deleting IP Address

type IPObject

type IPObject struct {
	Base
	AllocType      int    `json:"alloc_type"`
	Class          string `json:"class_code,omitempty"`
	Domain         string `json:"domain_name,omitempty"`
	SubnetAddr     string `json:"subnet_address,omitempty"`
	UpdateNaA      bool   `json:"update_ns_a,omitempty"`
	UpdateNsPtr    bool   `json:"update_ns_ptr,omitempty"`
	DynUpdRrsA     bool   `json:"dyn_update_rrs_a,omitempty"`
	DynUpdRrsPtr   bool   `json:"dyn_update_rrs_ptr,omitempty"`
	DynUpdRrsCName bool   `json:"dyn_update_rrs_cname,omitempty"`
	DynUpdRrsMx    bool   `json:"dyn_update_rrs_mx,omitempty"`
}

IPObject to create IP Address

func NewIPObject

func NewIPObject(ipAddr string, subnet string, domain string, org string, name string) *IPObject

NewIPObject creates new instance of Ip object

type Network

type Network struct {
	Base
	MaskLen      int    `json:"mask_length,omitempty"`
	DMZVisible   string `json:"dmzVisible,omitempty"`
	DNSSecEnable string `json:"dnssec_enable,omitempty"`
	Discovery    string `json:"enable_discovery,omitempty"`
}

Network Represents IPV4 network

type ObjectManager

type ObjectManager struct {
	Client *RestClient
}

ObjectManager manages all object types

func NewObjectManager

func NewObjectManager(conf HostConfig, key string, cert string, poolSize int, timeout time.Duration) *ObjectManager

NewObjectManager create new instance

func (*ObjectManager) CreateIPAddress

func (objMgr *ObjectManager) CreateIPAddress(ipAddr string, macAddr string, subnetAddr string, domain string, org string, name string) (string, error)

CreateIPAddress creates Ip object

func (*ObjectManager) CreateNetwork

func (objMgr *ObjectManager) CreateNetwork(network Network) (string, error)

CreateNetwork creates new Network

func (*ObjectManager) CreateSubnet

func (objMgr *ObjectManager) CreateSubnet(subnet Subnet) (string, error)

CreateSubnet creates a new Subnet

func (*ObjectManager) DeleteIPAddress

func (objMgr *ObjectManager) DeleteIPAddress(ip string, subnetAddr string, organization string) error

DeleteIPAddress deletes Ip object

func (*ObjectManager) GetNetwork

func (objMgr *ObjectManager) GetNetwork(ipAddr string, orgName string) (*Network, error)

GetNetwork Fetches existing network details

func (*ObjectManager) GetNextFreeIP

func (objMgr *ObjectManager) GetNextFreeIP(subnetAddr string, orgName string) (string, error)

GetNextFreeIP creates a new Subnet

func (*ObjectManager) GetSubnet

func (objMgr *ObjectManager) GetSubnet(subnetAddr string, orgName string) (*Subnet, error)

GetSubnet fetches esisting subnet

type Payload

type Payload struct {
	Method string
	Path   string
	Params map[string]string
	Body   interface{}
}

Payload hold request payload

type RestClient

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

RestClient is a HTTP Client

func NewRestClient

func NewRestClient(conf HostConfig, key string, cert string, connPool int, connTimeout time.Duration) *RestClient

NewRestClient returns new Rest Client

func (*RestClient) Init

func (rc *RestClient) Init()

Init initialize rest client

func (*RestClient) MakeRequest

func (rc *RestClient) MakeRequest(payload Payload) ([]byte, *ErrorResp)

MakeRequest performs rest call

type Subnet

type Subnet struct {
	Base
	MaskLen       int    `json:"mask_length,omitempty"`
	RouterAddr    string `json:"routerAddress,omitempty"`
	NetworkAddr   string `json:"network_address,omitempty"`
	PrimaryDomain string `json:"primary_domain,omitempty"`
	SubnetAddress string `json:"fullAddress,omitempty"`
	NetworkMask   int    `json:"network_mask,omitempty"`
}

Subnet Represents IPV4 network

type TransportConfig

type TransportConfig struct {
	CertFile            string
	KeyFile             string
	CertPool            *x509.CertPool
	CertKeyPair         tls.Certificate
	HTTPRequestTimeout  time.Duration // in seconds
	HTTPPoolConnections int
}

TransportConfig contains HTTP transport config

func NewTransportConfig

func NewTransportConfig(certFile string, keyFile string, httpRequestTimeout int, httpPoolConnections int) (cfg TransportConfig)

NewTransportConfig creates the transport configuration

Jump to

Keyboard shortcuts

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