Documentation ¶
Overview ¶
Copyright 2023 Fred78290. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Index ¶
- Constants
- Variables
- func NewHttpClient(endpoint, userAgent, userName, password string, timeout time.Duration, ...) (api.Client, error)
- type APIClient
- func (c *APIClient) ChangePowerState(id string, operation model.VmPowerOperation) (*model.VmPowerState, error)
- func (c *APIClient) ConfigVMParams(id string, parameters *model.ConfigVmParamsParameter) (*model.ErrorModel, error)
- func (c *APIClient) CreateNICDevice(id string, parameters *model.NicDeviceParameter) (*model.NicDevice, error)
- func (c *APIClient) CreateNetwork(parameters *model.CreateVmnetParameter) (*model.Network, error)
- func (c *APIClient) CreateSharedFolder(id string, parameters *model.SharedFolder) (model.SharedFolders, error)
- func (c *APIClient) CreateVM(parameters *model.VmCloneParameter) (*model.VmInformation, error)
- func (c *APIClient) DeleteNICDevice(id string, index int) error
- func (c *APIClient) DeletePortforward(vmnet string, protocol string, port int) error
- func (c *APIClient) DeleteSharedFolder(id string, folderId string) error
- func (c *APIClient) DeleteVM(id string) error
- func (c *APIClient) GetAllNICDevices(id string) (*model.NicDevices, error)
- func (c *APIClient) GetAllNetworks() (*model.Networks, error)
- func (c *APIClient) GetAllSharedFolders(id string) (model.SharedFolders, error)
- func (c *APIClient) GetAllVMs() ([]model.Vmid, error)
- func (c *APIClient) GetIPAddress(id string) (*model.InlineResponse200, error)
- func (c *APIClient) GetMACToIPs(vmnet string) (*model.MactoIps, error)
- func (c *APIClient) GetNicInfo(id string) (*model.NicIpStackAll, error)
- func (c *APIClient) GetPortforwards(vmnet string) (*model.Portforwards, error)
- func (c *APIClient) GetPowerState(id string) (*model.VmPowerState, error)
- func (c *APIClient) GetVM(id string) (*model.VmInformation, error)
- func (c *APIClient) GetVMParams(id string, name string) (*model.ConfigVmParamsParameter, error)
- func (c *APIClient) GetVMRestrictions(id string) (*model.VmRestrictionsInformation, error)
- func (c *APIClient) RegisterVM(parameters *model.VmRegisterParameter) (*model.VmRegistrationInformation, error)
- func (c *APIClient) UpdateMacToIP(vmnet string, mac string, parameters *model.MacToIpParameter) (*model.ErrorModel, error)
- func (c *APIClient) UpdateNICDevice(id string, index int, parameters *model.NicDeviceParameter) (*model.NicDevice, error)
- func (c *APIClient) UpdatePortforward(vmnet string, protocol string, port int, ...) (*model.ErrorModel, error)
- func (c *APIClient) UpdateSharedFolder(id string, folderId string, parameters *model.SharedFolderParameter) (model.SharedFolders, error)
- func (c *APIClient) UpdateVM(id string, parameters *model.VmParameter) (*model.VmInformation, error)
- type APIKey
- type APIResponse
- type BasicAuth
- type Configuration
- type GenericSwaggerError
- type Logger
Constants ¶
const VMREST_CONTENT_TYPE = "application/vnd.vmware.vmw.rest-v1+json"
Variables ¶
var ( // ContextOAuth2 takes a oauth2.TokenSource as authentication for the request. ContextOAuth2 = contextKey("token") // ContextBasicAuth takes BasicAuth as authentication for the request. ContextBasicAuth = contextKey("basic") // ContextAccessToken takes a string oauth2 access token as authentication for the request. ContextAccessToken = contextKey("accesstoken") // ContextAPIKey takes an APIKey as authentication for the request ContextAPIKey = contextKey("apikey") )
Functions ¶
func NewHttpClient ¶
func NewHttpClient(endpoint, userAgent, userName, password string, timeout time.Duration, unsecureTLS bool) (api.Client, error)
NewHttpClient Changes the VM power state
- @param endpoint the endpoint to joint vmrest
- @param userAgent
- @param userName
- @param password
- @param timeout operation timeout in seconds
- @param unsecureTLS unsecure tls
@return api.Client
Types ¶
type APIClient ¶
APIClient manages communication with the VMware Workstation REST API API v1.3.0 In most cases there should be only one, shared, APIClient.
func NewAPIClient ¶
func NewAPIClient(cfg *Configuration) (*APIClient, error)
NewAPIClient creates a new API client. Requires a userAgent string describing your application. optionally a custom http.Client to allow for advanced features such as caching.
func (*APIClient) ChangePowerState ¶
func (c *APIClient) ChangePowerState(id string, operation model.VmPowerOperation) (*model.VmPowerState, error)
ChangePowerState Changes the VM power state
- @param id ID of VM
- @param operation VM power operation: on, off, shutdown, suspend, pause, unpause
@return VmPowerState
func (*APIClient) ConfigVMParams ¶
func (c *APIClient) ConfigVMParams(id string, parameters *model.ConfigVmParamsParameter) (*model.ErrorModel, error)
ConfigVMParams update the vm config params
- @param id ID of VM
- @param parameters Parameters set to the VM
@return ErrorModel
func (*APIClient) CreateNICDevice ¶
func (c *APIClient) CreateNICDevice(id string, parameters *model.NicDeviceParameter) (*model.NicDevice, error)
CreateNICDevice Creates a network adapter in the VM
- @param id ID of VM
- @param parameters Parameters of network adapter to create
@return NicDevice
func (*APIClient) CreateNetwork ¶
CreateNetwork Creates a virtual network
- @param parameters Host network to be created
@return Network
func (*APIClient) CreateSharedFolder ¶
func (c *APIClient) CreateSharedFolder(id string, parameters *model.SharedFolder) (model.SharedFolders, error)
CreateSharedFolder Mounts a new shared folder in the VM
- @param id ID of VM
- @param parameters Parameters of the shared folder to mount
@return SharedFolders
func (*APIClient) CreateVM ¶
func (c *APIClient) CreateVM(parameters *model.VmCloneParameter) (*model.VmInformation, error)
CreateVM Creates a copy of the VM
- @param params Parameters of VM to create
@return VmInformation
func (*APIClient) DeleteNICDevice ¶
DeleteNICDevice Deletes a VM network adapter
- @param id ID of VM
- @param index Index of VM network adapter
func (*APIClient) DeletePortforward ¶
DeletePortforward Deletes port forwarding
- @param vmnet NAT type of virtual network
- @param protocol Protocol type: tcp, udp
- @param port Host port number
func (*APIClient) DeleteSharedFolder ¶
DeleteSharedFolder Deletes a shared folder
- @param id ID of VM
- @param folderId ID of shared folder
func (*APIClient) GetAllNICDevices ¶
func (c *APIClient) GetAllNICDevices(id string) (*model.NicDevices, error)
GetAllNICDevices Returns all network adapters in the VM
- @param id ID of VM
@return NicDevices
func (*APIClient) GetAllSharedFolders ¶
func (c *APIClient) GetAllSharedFolders(id string) (model.SharedFolders, error)
GetAllSharedFolders Returns all shared folders mounted in the VM
- @param id ID of VM
@return SharedFolders
func (*APIClient) GetAllVMs ¶
GetAllVMs Returns a list of VM IDs and paths for all VMs @return []Vmid
func (*APIClient) GetIPAddress ¶
func (c *APIClient) GetIPAddress(id string) (*model.InlineResponse200, error)
GetIPAddress Returns the IP address of a VM
- @param id ID of VM
@return InlineResponse200
func (*APIClient) GetMACToIPs ¶
GetMACToIPs Returns all MAC-to-IP settings for DHCP service - @param vmnet Virtual network that has DHCP enabled
@return MactoIps
func (*APIClient) GetNicInfo ¶
func (c *APIClient) GetNicInfo(id string) (*model.NicIpStackAll, error)
GetNicInfo Returns the IP stack configuration of all NICs of a VM
- @param id ID of VM
@return NicIpStackAll
func (*APIClient) GetPortforwards ¶
func (c *APIClient) GetPortforwards(vmnet string) (*model.Portforwards, error)
GetPortforwards Returns all port forwardings
- @param vmnet NAT type of virtual network
@return Portforwards
func (*APIClient) GetPowerState ¶
func (c *APIClient) GetPowerState(id string) (*model.VmPowerState, error)
GetPowerState Returns the power state of the VM
- @param id ID of VM
@return VmPowerState
func (*APIClient) GetVM ¶
func (c *APIClient) GetVM(id string) (*model.VmInformation, error)
GetVM Returns the VM setting information of a VM
- @param id ID of VM
@return VmInformation
func (*APIClient) GetVMParams ¶
GetVMParams Get the VM config params
- @param id ID of VM
- @param name Name of the param
@return ConfigVmParamsParameter
func (*APIClient) GetVMRestrictions ¶
func (c *APIClient) GetVMRestrictions(id string) (*model.VmRestrictionsInformation, error)
GetVMRestrictions Returns the restrictions information of the VM
- @param id ID of VM
@return VmRestrictionsInformation
func (*APIClient) RegisterVM ¶
func (c *APIClient) RegisterVM(parameters *model.VmRegisterParameter) (*model.VmRegistrationInformation, error)
RegisterVM Register VM to VM Library
- @param parameters Parameters of the VM to register
@return VmRegistrationInformation
func (*APIClient) UpdateMacToIP ¶
func (c *APIClient) UpdateMacToIP(vmnet string, mac string, parameters *model.MacToIpParameter) (*model.ErrorModel, error)
UpdateMacToIP Updates the MAC-to-IP binding
- @param vmnet Virtual network that enabled DHCP
- @param mac Mac address that want to be mapped with a given IP
- @param parameters IP that will be assigned to given Mac address. If empty IP, the original Mac to IP binding will be deleted
@return ErrorModel
func (*APIClient) UpdateNICDevice ¶
func (c *APIClient) UpdateNICDevice(id string, index int, parameters *model.NicDeviceParameter) (*model.NicDevice, error)
UpdateNICDevice Updates a network adapter in the VM
- @param id ID of VM
- @param index Index of VM network adapter
- @param parameters Parameters of network adapter to update to
@return NicDevice
func (*APIClient) UpdatePortforward ¶
func (c *APIClient) UpdatePortforward(vmnet string, protocol string, port int, parameters *model.PortforwardParameter) (*model.ErrorModel, error)
UpdatePortforward Updates port forwarding
- @param vmnet NAT type of virtual network
- @param protocol Protocol type: tcp, udp
- @param port Host port number
- @param parameters Guest to forward to
@return ErrorModel
func (*APIClient) UpdateSharedFolder ¶
func (c *APIClient) UpdateSharedFolder(id string, folderId string, parameters *model.SharedFolderParameter) (model.SharedFolders, error)
UpdateSharedFolder Updates a shared folder mounted in the VM
- @param id ID of VM
- @param folderId ID of VM shared folder
- @param parameters Parameters of the shared folder to update to
@return SharedFolders
func (*APIClient) UpdateVM ¶
func (c *APIClient) UpdateVM(id string, parameters *model.VmParameter) (*model.VmInformation, error)
UpdateVM Updates the VM settings
- @param id ID of VM
- @param parameters VM definition
@return VmInformation
type APIKey ¶
APIKey provides API key based authentication to a request passed via context using ContextAPIKey
type APIResponse ¶
type APIResponse struct { *http.Response `json:"-"` Message string `json:"message,omitempty"` // Operation is the name of the swagger operation. Operation string `json:"operation,omitempty"` // RequestURL is the request URL. This value is always available, even if the // embedded *http.Response is nil. RequestURL string `json:"url,omitempty"` // Method is the HTTP method used for the request. This value is always // available, even if the embedded *http.Response is nil. Method string `json:"method,omitempty"` // Payload holds the contents of the response body (which may be nil or empty). // This is provided here as the raw response.Body() reader will have already // been drained. Payload []byte `json:"-"` }
func NewAPIResponse ¶
func NewAPIResponse(r *http.Response) *APIResponse
func NewAPIResponseWithError ¶
func NewAPIResponseWithError(errorMessage string) *APIResponse
type BasicAuth ¶
type BasicAuth struct { UserName string `json:"userName,omitempty"` Password string `json:"password,omitempty"` }
BasicAuth provides basic http authentication to a request passed via context using ContextBasicAuth
type Configuration ¶
type Configuration struct { Endpoint string `json:"endpoint,omitempty"` UserAgent string `json:"userAgent,omitempty"` UserName string `json:"userName,omitempty"` Password string `json:"password,omitempty"` Timeout time.Duration `json:"timeout,omitempty"` UnsecureTLS bool `json:"unsecure-tls,omitempty"` }
func NewConfiguration ¶
func NewConfiguration(username, password string, port int) *Configuration
type GenericSwaggerError ¶
type GenericSwaggerError struct {
// contains filtered or unexported fields
}
GenericSwaggerError Provides access to the body, error and model on returned errors.
func (GenericSwaggerError) Body ¶
func (e GenericSwaggerError) Body() []byte
Body returns the raw bytes of the response
func (GenericSwaggerError) Error ¶
func (e GenericSwaggerError) Error() string
Error returns non-empty string if there was an error.
func (GenericSwaggerError) Model ¶
func (e GenericSwaggerError) Model() interface{}
Model returns the unpacked model of the error