Documentation ¶
Index ¶
- Constants
- Variables
- func IsRegularError(err error) bool
- func IsSoapFault(err error) bool
- func IsVimFault(err error) bool
- func ParseURL(s string) (*url.URL, error)
- func ThumbprintSHA1(cert *x509.Certificate) string
- func ToRegularError(err error) error
- func ToVimFault(err error) types.BaseMethodFault
- func Wrap(err error) error
- func WrapRegularError(err error) error
- func WrapSoapFault(f *Fault) error
- func WrapVimFault(v types.BaseMethodFault) error
- type Client
- func (c *Client) CloseIdleConnections()
- func (c *Client) Download(u *url.URL, param *Download) (io.ReadCloser, int64, error)
- func (c *Client) DownloadFile(file string, u *url.URL, param *Download) error
- func (c *Client) DownloadRequest(u *url.URL, param *Download) (*http.Response, error)
- func (c *Client) LoadThumbprints(file string) error
- func (c *Client) MarshalJSON() ([]byte, error)
- func (c *Client) NewServiceClient(path string, namespace string) *Client
- func (c *Client) ParseURL(urlStr string) (*url.URL, error)
- func (c *Client) RoundTrip(ctx context.Context, reqBody, resBody HasFault) error
- func (c *Client) SetCertificate(cert tls.Certificate)
- func (c *Client) SetRootCAs(file string) error
- func (c *Client) SetThumbprint(host string, thumbprint string)
- func (c *Client) Thumbprint(host string) string
- func (c *Client) URL() *url.URL
- func (c *Client) UnmarshalJSON(b []byte) error
- func (c *Client) Upload(f io.Reader, u *url.URL, param *Upload) error
- func (c *Client) UploadFile(file string, u *url.URL, param *Upload) error
- func (c *Client) WriteFile(file string, src io.Reader, size int64, s progress.Sinker, w io.Writer) error
- type Download
- type Envelope
- type Fault
- type HasFault
- type RoundTripper
- type Upload
Constants ¶
const ( DefaultVimNamespace = "urn:vim25" DefaultVimVersion = "6.5" DefaultMinVimVersion = "5.5" )
Variables ¶
var DefaultDownload = Download{
Method: "GET",
}
var DefaultUpload = Upload{
Type: "application/octet-stream",
Method: "PUT",
}
Functions ¶
func IsRegularError ¶
func IsSoapFault ¶
func IsVimFault ¶
func ParseURL ¶ added in v0.3.0
ParseURL is wrapper around url.Parse, where Scheme defaults to "https" and Path defaults to "/sdk"
func ThumbprintSHA1 ¶ added in v0.10.0
func ThumbprintSHA1(cert *x509.Certificate) string
ThumbprintSHA1 returns the thumbprint of the given cert in the same format used by the SDK and Client.SetThumbprint.
See: SSLVerifyFault.Thumbprint, SessionManagerGenericServiceTicket.Thumbprint, HostConnectSpec.SslThumbprint
func ToRegularError ¶
func ToVimFault ¶
func ToVimFault(err error) types.BaseMethodFault
func WrapRegularError ¶
func WrapSoapFault ¶
func WrapVimFault ¶
func WrapVimFault(v types.BaseMethodFault) error
Types ¶
type Client ¶
type Client struct { http.Client Namespace string // Vim namespace Version string // Vim version UserAgent string // contains filtered or unexported fields }
func (*Client) CloseIdleConnections ¶
func (c *Client) CloseIdleConnections()
func (*Client) DownloadFile ¶
DownloadFile GETs the given URL to a local file
func (*Client) DownloadRequest ¶ added in v0.9.0
DownloadRequest wraps http.Client.Do, returning the http.Response without checking its StatusCode
func (*Client) LoadThumbprints ¶ added in v0.10.0
LoadThumbprints from file with the give name. If name is empty or name does not exist this function will return nil.
func (*Client) MarshalJSON ¶
func (*Client) NewServiceClient ¶ added in v0.15.0
NewServiceClient creates a NewClient with the given URL.Path and namespace.
func (*Client) ParseURL ¶
ParseURL wraps url.Parse to rewrite the URL.Host field In the case of VM guest uploads or NFC lease URLs, a Host field with a value of "*" is rewritten to the Client's URL.Host.
func (*Client) SetCertificate ¶ added in v0.3.0
func (c *Client) SetCertificate(cert tls.Certificate)
func (*Client) SetRootCAs ¶ added in v0.10.0
SetRootCAs defines the set of root certificate authorities that clients use when verifying server certificates. By default TLS uses the host's root CA set.
See: http.Client.Transport.TLSClientConfig.RootCAs
func (*Client) SetThumbprint ¶ added in v0.10.0
SetThumbprint sets the known certificate thumbprint for the given host. A custom DialTLS function is used to support thumbprint based verification. We first try tls.Dial with the default tls.Config, only falling back to thumbprint verification if it fails with an x509.UnknownAuthorityError or x509.HostnameError
See: http.Client.Transport.DialTLS
func (*Client) Thumbprint ¶ added in v0.10.0
Thumbprint returns the certificate thumbprint for the given host if known to this client.
func (*Client) UnmarshalJSON ¶
func (*Client) UploadFile ¶
UploadFile PUTs the local file to the given URL
type Fault ¶
type Fault struct { XMLName xml.Name `xml:"http://schemas.xmlsoap.org/soap/envelope/ Fault"` Code string `xml:"faultcode"` String string `xml:"faultstring"` Detail struct { Fault types.AnyType `xml:",any,typeattr"` } `xml:"detail"` }