rest

package
v0.0.0-...-bf8c4fd Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	DefaultHost = "127.0.0.1"
	DefaultPort = 8697
)
View Source
const (
	VMWareRestContentType      string = "application/vnd.vmware.vmw.rest-v1+json"
	ApplicationJSONContentType string = "application/json"
)
View Source
const (
	VMWareAPI_GetAllVirtualNetworks               = "/vmnet"
	VMWareAPI_GetAllMacToIpSettingsForDhcpService = "/vmnet/{vmnet}/mactoip"
	VMWareAPI_GetAllPortForwardings               = "/vmnet/{vmnet}/portforward"
	VMWareAPI_UpdateMacToIpBinding                = "/vmnet/{vmnet}/mactoip/{mac}"
	VMWareAPI_UpdatePortForwarding                = "/vmnet/{vmnet}/portforward/{protocol}/{port}"
	VMWareAPI_CreateVirtualNetwork                = "/vmnets"
	VMWareAPI_DeletePortForwarding                = "/vmnet/{vmnet}/portforward/{protocol}/{port}"

	VMWareAPI_GetVmList                    = "/vms"
	VMWareAPI_GetVm                        = "/vms/{id}"
	VMWareAPI_GetVmConfigParams            = "/vms/{id}/params/{name}"
	VMWareAPI_GetVmRestrictionsInformation = "/vms/{id}/restrictions"
	VMWareAPI_UpdateVmSetting              = "/vms/{id}"
	VMWareAPI_UpdateVmConfigParams         = "/vms/{id}/params"
	VMWareAPI_CreateVmCopy                 = "/vms"
	VMWareAPI_RegisterVmToVmLibrary        = "/vms/registration"
	VMWareAPI_DeleteVm                     = "/vms/{id}"

	VMWareAPI_GetVmIpAddress                   = "/vms/{id}/ip"
	VMWareAPI_GetAllVmNetworkAdapters          = "/vms/{id}/nic"
	VMWareAPI_GetIpStackConfigurationOfAllNics = "/vms/{id}/nicips"
	VMWareAPI_UpdateVmNetworkAdapter           = "/vms/{id}/nic/{index}"
	VMWareAPI_CreateVmNetworkAdapter           = "/vms/{id}/nic"
	VMWareAPI_DeleteVmNetworkAdapter           = "/vms/{id}/nic/{index}"

	VMWareAPI_GetVmPowerState    = "/vms/{id}/power"
	VMWareAPI_ChangeVmPowerState = "/vms/{id}/power"

	VMWareAPI_GetVmAllSharedFoldersMounted = "/vms/{id}/sharedfolders"
	VMWareAPI_UpdateVmSharedFolderMounted  = "/vms/{id}/sharedfolders/{folder_id}"
	VMWareAPI_MountVmNewSharedFolder       = "/vms/{id}/sharedfolders"
	VMWareAPI_DeleteSharedFolder           = "/vms/{id}/sharedfolders/{folder_id}"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ChangeVmPowerStateRequest

type ChangeVmPowerStateRequest struct {
}

type ChangeVmPowerStateResponse

type ChangeVmPowerStateResponse struct {
	PowerState string `json:"power_state"`
}

type Client

type Client struct {
	Client   *resty.Client
	BaseURL  *url.URL
	Username string
	Password string
	Insecure bool
}

Client to invoke VMWare Fusion RESTful API.

func NewClient

func NewClient(username, password, baseUrl string) (*Client, error)

func (*Client) GetVmList

func (c *Client) GetVmList(request GetVmListRequest, params Params) (*GetVmListResponse, *VmwareFusionError)

type CreateVirtualNetworkRequest

type CreateVirtualNetworkRequest struct {
	Name string `json:"name"`
	Type string `json:"type"`
}

type CreateVirtualNetworkResponse

type CreateVirtualNetworkResponse struct {
	Name   string `json:"name"`
	Type   string `json:"type"`
	Dhcp   string `json:"dhcp"`
	Subnet string `json:"subnet"`
	Mask   string `json:"mask"`
}

type CreateVmCopyRequest

type CreateVmCopyRequest struct {
	Name     string `json:"name"`
	ParentId string `json:"parentId"`
}

type CreateVmCopyResponse

type CreateVmCopyResponse struct {
	Id  string `json:"id"`
	Cpu struct {
		Processors int `json:"processors"`
	} `json:"cpu"`
	Memory int `json:"memory"`
}

type CreateVmNetworkAdapterRequest

type CreateVmNetworkAdapterRequest struct {
	Type  string `json:"type"`
	Vmnet string `json:"vmnet"`
}

type CreateVmNetworkAdapterResponse

type CreateVmNetworkAdapterResponse struct {
	Index      int    `json:"index"`
	Type       string `json:"type"`
	Vmnet      string `json:"vmnet"`
	MacAddress string `json:"macAddress"`
}

type DeletePortForwardingRequest

type DeletePortForwardingRequest struct {
}

type DeletePortForwardingResponse

type DeletePortForwardingResponse struct {
}

type DeleteSharedFolderRequest

type DeleteSharedFolderRequest struct {
}

type DeleteSharedFolderResponse

type DeleteSharedFolderResponse struct {
}

type DeleteVmNetworkAdapterRequest

type DeleteVmNetworkAdapterRequest struct {
}

type DeleteVmNetworkAdapterResponse

type DeleteVmNetworkAdapterResponse struct {
}

type DeleteVmRequest

type DeleteVmRequest struct {
}

type DeleteVmResponse

type DeleteVmResponse struct {
}

type GetAllMacToIpSettingsForDhcpServiceResponse

type GetAllMacToIpSettingsForDhcpServiceResponse struct {
	Num      int `json:"num"`
	MacToIps []struct {
		Vmnet string `json:"vmnet"`
		Mac   string `json:"mac"`
		Ip    string `json:"ip"`
	} `json:"mactoips"`
}

type GetAllPortForwardingsResponse

type GetAllPortForwardingsResponse struct {
	Num             int `json:"num"`
	PortForwardings []struct {
		Port     int    `json:"port"`
		Protocol string `json:"protocol"`
		Desc     string `json:"desc"`
		Guest    struct {
			Ip   string `json:"ip"`
			Port int    `json:"port"`
		} `json:"guest"`
	} `json:"port_forwardings"`
}

type GetAllVirtualNetworksResponse

type GetAllVirtualNetworksResponse struct {
	Num    int `json:"num"`
	VmNets []struct {
		Name   string `json:"name"`
		Type   string `json:"bridged"`
		DHCP   string `json:"dhcp"`
		Subnet string `json:"subnet"`
		Mask   string `json:"mask"`
	} `json:"vmnets"`
}

type GetAllVmNetworkAdaptersResponse

type GetAllVmNetworkAdaptersResponse struct {
	Num  int `json:"num"`
	Nics []struct {
		Index      int    `json:"index"`
		Type       string `json:"type"`
		Vmnet      string `json:"vmnet"`
		MacAddress string `json:"macAddress"`
	} `json:"nics"`
}

type GetIpStackConfigurationOfAllNics

type GetIpStackConfigurationOfAllNics struct {
	Nics struct {
		Mac string   `json:"mac"`
		Ip  []string `json:"ip"`
		Dns struct {
			Hostname   string   `json:"hostname"`
			Domainname string   `json:"domainname"`
			Server     []string `json:"server"`
			Search     []string `json:"search"`
		} `json:"dns"`
		Wins struct {
			Primary   string `json:"primary"`
			Secondary string `json:"secondary"`
		} `json:"wins"`
		Dhcp4 struct {
			Enabled bool   `json:"enabled"`
			Setting string `json:"setting"`
		} `json:"dhcp4"`
		Dhcp6 struct {
			Enabled bool   `json:"enabled"`
			Setting string `json:"setting"`
		} `json:"dhcp6"`
	} `json:"nics"`
	Routes []struct {
		Dest      string `json:"dest"`
		Prefix    int    `json:"prefix"`
		Nexthop   string `json:"nexthop"`
		Interface int    `json:"interface"`
		Type      int    `json:"type"`
		Metric    int    `json:"metric"`
	} `json:"routes"`
	Dns struct {
		Hostname   string   `json:"hostname"`
		Domainname string   `json:"domainname"`
		Server     []string `json:"server"`
		Search     []string `json:"search"`
	} `json:"dns"`
	Wins struct {
		Primary   string `json:"primary"`
		Secondary string `json:"secondary"`
	} `json:"wins"`
	DhcpV4 struct {
		Enabled bool   `json:"enabled"`
		Setting string `json:"setting"`
	} `json:"dhcpv4"`
	DhcpV6 struct {
		Enabled bool   `json:"enabled"`
		Setting string `json:"setting"`
	} `json:"dhcpv6"`
}

type GetVmAllSharedFoldersMountedResponse

type GetVmAllSharedFoldersMountedResponse = []struct {
	FolderId string `json:"folder_id"`
	HostPath string `json:"host_path"`
	Flags    int    `json:"flags"`
}

type GetVmConfigParamsResponse

type GetVmConfigParamsResponse struct {
	Name  string `json:"name"`
	Value string `json:"value"`
}

type GetVmIpAddressResponse

type GetVmIpAddressResponse struct {
	Ip string `json:"ip"`
}

type GetVmListRequest

type GetVmListRequest struct {
}

type GetVmListResponse

type GetVmListResponse = []struct {
	Id   string `json:"id"`
	Path string `json:"path"`
}

type GetVmPowerStateResponse

type GetVmPowerStateResponse struct {
	PowerState string `json:"power_state"`
}

type GetVmRestrictionsInformationResponse

type GetVmRestrictionsInformationResponse struct {
	Id                  string `json:"id"`
	ManagedOrg          string `json:"managedOrg"`
	IntegrityConstraint string `json:"integrityconstraint"`
	Cpu                 struct {
		Processors int `json:"processors"`
	} `json:"cpu"`
	Memory        int `json:"memory"`
	ApplianceView struct {
		Author        string `json:"author"`
		Version       string `json:"version"`
		Port          int    `json:"port"`
		ShowAtPowerOn string `json:"showAtPowerOn"`
	} `json:"applianceView"`
	CddvdList struct {
		Num     int `json:"num"`
		Devices []struct {
			Index            int    `json:"index"`
			StartConnected   string `json:"startConnected"`
			ConnectionStatus int    `json:"connectionStatus"`
			DevicePath       string `json:"devicePath"`
		} `json:"devices"`
	} `json:"cddvdList"`
	FloopyList struct {
		Num     int `json:"num"`
		Devices []struct {
			Index            int    `json:"index"`
			StartConnected   string `json:"startConnected"`
			ConnectionStatus int    `json:"connectionStatus"`
			DevicePath       string `json:"devicePath"`
		} `json:"devices"`
	} `json:"floopyList"`
	FirewareType   int `json:"firewareType"`
	GuestIsolation struct {
		CopyDisabled  string `json:"copyDisabled"`
		DndDisabled   string `json:"dndDisabled"`
		HgfsDisabled  string `json:"hgfsDisabled"`
		PasteDisabled string `json:"pasteDisabled"`
	} `json:"guestIsolation"`
	NicList struct {
		Num  int `json:"num"`
		Nics []struct {
			Index      int    `json:"index"`
			Type       string `json:"type"`
			VmNet      string `json:"vmnet"`
			MacAddress string `json:"macAddress"`
		} `json:"nics"`
	} `json:"niclist"`
	ParallelPortList struct {
		Num     int `json:"num"`
		Devices []struct {
			Index            int    `json:"index"`
			StartConnected   string `json:"startConnected"`
			ConnectionStatus int    `json:"connectionStatus"`
			DevicePath       string `json:"devicePath"`
		} `json:"devices"`
	} `json:"parallelPortList"`
	SerialPortList struct {
		Num     int `json:"num"`
		Devices []struct {
			Index            int    `json:"index"`
			StartConnected   string `json:"startConnected"`
			ConnectionStatus int    `json:"connectionStatus"`
			DevicePath       string `json:"devicePath"`
		} `json:"devices"`
	} `json:"serialPortList"`
	UsbList struct {
		Num        int `json:"num"`
		UsbDevices []struct {
			Index       int    `json:"index"`
			Connected   string `json:"connected"`
			BackingInfo string `json:"backingInfo"`
			BackingType int    `json:"BackingType"`
		} `json:"usbDevices"`
	} `json:"usbList"`
	RemoteVNC struct {
		VNCEnabled string `json:"VNCEnabled"`
		VNCPort    int    `json:"VNCPort"`
	} `json:"remoteVNC"`
}

type GetVmSettingInformationRequest

type GetVmSettingInformationRequest struct {
}

type GetVmSettingInformationResponse

type GetVmSettingInformationResponse struct {
	Id  string `json:"id"`
	Cpu struct {
		Processors int `json:"processors"`
	} `json:"cpu"`
	Memory int `json:"memory"`
}

type MountVmNewSharedFolderRequest

type MountVmNewSharedFolderRequest struct {
	FolderId string `json:"folder_id"`
	HostPath string `json:"host_path"`
	Flags    int    `json:"flags"`
}

type MountVmNewSharedFolderResponse

type MountVmNewSharedFolderResponse = []struct {
	FolderId string `json:"folder_id"`
	HostPath string `json:"host_path"`
	Flags    int    `json:"flags"`
}

type Params

type Params = map[string]interface{}

type RegisterVmToVmLibraryRequest

type RegisterVmToVmLibraryRequest struct {
	Name string `json:"name"`
	Path string `json:"path"`
}

type RegisterVmToVmLibraryResponse

type RegisterVmToVmLibraryResponse struct {
	Id   string `json:"id"`
	Path string `json:"path"`
}

type UpdateMacToIpBindingRequest

type UpdateMacToIpBindingRequest struct {
	IP string `json:"IP"`
}

type UpdateMacToIpBindingResponse

type UpdateMacToIpBindingResponse struct {
	Code    int    `json:"code"`
	Message string `json:"message"`
}

type UpdatePortForwardingRequest

type UpdatePortForwardingRequest struct {
	GuestIp   string `json:"guestIp"`
	GuestPort int    `json:"guestPort"`
	Desc      string `json:"desc"`
}

type UpdatePortForwardingResponse

type UpdatePortForwardingResponse = VmwareFusionError

type UpdateVmConfigParamsRequest

type UpdateVmConfigParamsRequest struct {
	Name  string `json:"name"`
	Value string `json:"value"`
}

type UpdateVmConfigParamsResponse

type UpdateVmConfigParamsResponse = VmwareFusionError

type UpdateVmNetworkAdapterRequest

type UpdateVmNetworkAdapterRequest struct {
	Type  string `json:"type"`
	VmNet string `json:"vmnet"`
}

type UpdateVmNetworkAdapterResponse

type UpdateVmNetworkAdapterResponse struct {
	Index      int    `json:"index"`
	Type       string `json:"type"`
	VmNet      string `json:"vmnet"`
	MacAddress string `json:"macAddress"`
}

type UpdateVmSettingRequest

type UpdateVmSettingRequest struct {
	Processors int `json:"processors"`
	Memory     int `json:"memory"`
}

type UpdateVmSettingResponse

type UpdateVmSettingResponse struct {
	Id  string `json:"id"`
	Cpu struct {
		Processors int `json:"processors"`
	} `json:"cpu"`
	Memory int `json:"memory"`
}

type UpdateVmSharedFolderMountedRequest

type UpdateVmSharedFolderMountedRequest struct {
	HostPath string `json:"host_path"`
	Flags    int    `json:"flags"`
}

type UpdateVmSharedFolderMountedResponse

type UpdateVmSharedFolderMountedResponse = []struct {
	FolderId string `json:"folder_id"`
	HostPath string `json:"host_path"`
	Flags    int    `json:"flags"`
}

type VmwareFusionError

type VmwareFusionError struct {
	Code    int    `json:"code"`
	Message string `json:"message"`
}

func FromRawError

func FromRawError(err error) VmwareFusionError

func SendRequest

func SendRequest[T any, R any](client *Client, method string, url string, request T, params Params) (*R, *VmwareFusionError)

Jump to

Keyboard shortcuts

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