Documentation ¶
Index ¶
- Constants
- Variables
- func IsCertificateUntrusted(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 ThumbprintSHA256(cert *x509.Certificate) string
- func ToVimFault(err error) types.BaseMethodFault
- func WrapSoapFault(f *Fault) error
- func WrapVimFault(v types.BaseMethodFault) error
- type Client
- func (c *Client) Certificate() *tls.Certificate
- func (c *Client) CloseIdleConnections()
- func (c *Client) DefaultTransport() *http.Transport
- func (c *Client) Do(ctx context.Context, req *http.Request, f func(*http.Response) error) error
- func (c *Client) Download(ctx context.Context, u *url.URL, param *Download) (io.ReadCloser, int64, error)
- func (c *Client) DownloadFile(ctx context.Context, file string, u *url.URL, param *Download) error
- func (c *Client) DownloadRequest(ctx context.Context, u *url.URL, param *Download) (*http.Response, error)
- func (c *Client) KnownThumbprint(tp string) bool
- 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(pemPaths string) error
- func (c *Client) SetThumbprint(host string, thumbprint string)
- func (c *Client) Thumbprint(host string) string
- func (c *Client) Tunnel() *Client
- func (c *Client) URL() *url.URL
- func (c *Client) UnmarshalJSON(b []byte) error
- func (c *Client) Upload(ctx context.Context, f io.Reader, u *url.URL, param *Upload) error
- func (c *Client) UploadFile(ctx context.Context, file string, u *url.URL, param *Upload) error
- func (c *Client) UseJSON(useJSON bool)
- func (c *Client) UseServiceVersion(kind ...string) error
- func (c *Client) WithHeader(ctx context.Context, header Header) context.Context
- func (c *Client) WriteFile(ctx context.Context, file string, src io.Reader, size int64, s progress.Sinker, ...) error
- type Download
- type Envelope
- type Fault
- type HasFault
- type Header
- type RoundTripper
- type Signer
- type Upload
Constants ¶
const (
SessionCookieName = "vmware_soap_session"
)
Variables ¶
var DefaultDownload = Download{
Method: "GET",
}
var DefaultUpload = Upload{
Type: "application/octet-stream",
Method: "PUT",
}
var ( // Trace reads an http request or response from rc and writes to w. // The content type (kind) should be one of "xml" or "json". Trace = func(rc io.ReadCloser, w io.Writer, kind string) io.ReadCloser { return debug.NewTeeReader(rc, w) } )
Functions ¶
func IsCertificateUntrusted ¶ added in v0.30.6
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 ThumbprintSHA256 ¶ added in v0.36.1
func ThumbprintSHA256(cert *x509.Certificate) string
ThumbprintSHA256 returns the sha256 thumbprint of the given cert.
func ToVimFault ¶
func ToVimFault(err error) types.BaseMethodFault
func WrapSoapFault ¶
func WrapVimFault ¶
func WrapVimFault(v types.BaseMethodFault) error
Types ¶
type Client ¶
type Client struct { http.Client Namespace string `json:"namespace"` // Vim namespace Version string `json:"version"` // Vim version Types types.Func `json:"types"` UserAgent string `json:"userAgent"` // contains filtered or unexported fields }
func (*Client) Certificate ¶ added in v0.18.0
func (c *Client) Certificate() *tls.Certificate
Certificate returns the current TLS certificate.
func (*Client) CloseIdleConnections ¶
func (c *Client) CloseIdleConnections()
func (*Client) DefaultTransport ¶ added in v0.23.0
func (*Client) Do ¶ added in v0.19.0
Do is equivalent to http.Client.Do and takes care of API specifics including logging, user-agent header, handling cookies, measuring responsiveness of the API
func (*Client) Download ¶ added in v0.6.0
func (c *Client) Download(ctx context.Context, u *url.URL, param *Download) (io.ReadCloser, int64, error)
Download GETs the remote file from the given URL
func (*Client) DownloadFile ¶
DownloadFile GETs the given URL to a local file
func (*Client) DownloadRequest ¶ added in v0.9.0
func (c *Client) DownloadRequest(ctx context.Context, u *url.URL, param *Download) (*http.Response, error)
DownloadRequest wraps http.Client.Do, returning the http.Response without checking its StatusCode
func (*Client) KnownThumbprint ¶ added in v0.33.0
KnownThumbprint checks whether the provided thumbprint is known to this client.
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 ¶
MarshalJSON writes the Client configuration to JSON.
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)
SetCertificate st a certificate for TLS use.
func (*Client) SetRootCAs ¶ added in v0.10.0
SetRootCAs defines the set of PEM-encoded file locations of root certificate authorities the client uses when verifying server certificates instead of the TLS defaults which uses the host's root CA set. Multiple PEM file locations can be specified using the OS-specific PathListSeparator.
See: http.Client.Transport.TLSClientConfig.RootCAs and https://pkg.go.dev/os#PathListSeparator
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) Tunnel ¶ added in v0.18.0
Tunnel returns a Client configured to proxy requests through vCenter's http port 80, to the SDK tunnel virtual host. Use of the SDK tunnel is required by LoginExtensionByCertificate() and optional for other methods.
func (*Client) UnmarshalJSON ¶
UnmarshalJSON rads Client configuration from JSON.
func (*Client) UploadFile ¶
UploadFile PUTs the local file to the given URL
func (*Client) UseJSON ¶ added in v0.31.0
UseJSON changes the protocol between SOAP and JSON. Starting with vCenter 8.0.1 JSON over HTTP can be used. Note this method has no locking and clients should be careful to not interfere with concurrent use of the client instance.
func (*Client) UseServiceVersion ¶ added in v0.37.0
UseServiceVersion sets Client.Version to the current version of the service endpoint via /sdk/vimServiceVersions.xml
func (*Client) WithHeader ¶ added in v0.18.0
WithHeader can be used to modify the outgoing request soap.Header fields.
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"` }
func ToSoapFault ¶
type Header ¶
type Header struct { Action string `xml:"-"` // Action is the 'SOAPAction' HTTP header value. Defaults to "Client.Namespace/Client.Version". Cookie string `xml:"vcSessionCookie,omitempty"` // Cookie is a vCenter session cookie that can be used with other SDK endpoints (e.g. pbm). ID string `xml:"operationID,omitempty"` // ID is the operationID used by ESX/vCenter logging for correlation. Security interface{} `xml:",omitempty"` // Security is used for SAML token authentication and request signing. }
Header includes optional soap Header fields.