build(deps): bump github.com/vmware/govmomi from 0.23.0 to 0.26.1
Bumps [github.com/vmware/govmomi](https://github.com/vmware/govmomi) from 0.23.0 to 0.26.1. - [Release notes](https://github.com/vmware/govmomi/releases) - [Changelog](https://github.com/vmware/govmomi/blob/master/CHANGELOG.md) - [Commits](https://github.com/vmware/govmomi/compare/v0.23.0...v0.26.1) --- updated-dependencies: - dependency-name: github.com/vmware/govmomi dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com>
This commit is contained in:
parent
974c258382
commit
137819b9cd
77 changed files with 7610 additions and 486 deletions
14
vendor/github.com/vmware/govmomi/vapi/library/library.go
generated
vendored
14
vendor/github.com/vmware/govmomi/vapi/library/library.go
generated
vendored
|
|
@ -212,6 +212,20 @@ func (c *Manager) PublishLibrary(ctx context.Context, library *Library, subscrip
|
|||
return c.Do(ctx, url.Request(http.MethodPost, spec), nil)
|
||||
}
|
||||
|
||||
// UpdateLibrary can update one or both of the tag Description and Name fields.
|
||||
func (c *Manager) UpdateLibrary(ctx context.Context, l *Library) error {
|
||||
spec := struct {
|
||||
Library `json:"update_spec"`
|
||||
}{
|
||||
Library{
|
||||
Name: l.Name,
|
||||
Description: l.Description,
|
||||
},
|
||||
}
|
||||
url := c.Resource(internal.LibraryPath).WithID(l.ID)
|
||||
return c.Do(ctx, url.Request(http.MethodPatch, spec), nil)
|
||||
}
|
||||
|
||||
// DeleteLibrary deletes an existing library.
|
||||
func (c *Manager) DeleteLibrary(ctx context.Context, library *Library) error {
|
||||
path := internal.LocalLibraryPath
|
||||
|
|
|
|||
14
vendor/github.com/vmware/govmomi/vapi/library/library_item.go
generated
vendored
14
vendor/github.com/vmware/govmomi/vapi/library/library_item.go
generated
vendored
|
|
@ -120,6 +120,20 @@ func (c *Manager) PublishLibraryItem(ctx context.Context, item *Item, force bool
|
|||
return c.Do(ctx, url.Request(http.MethodPost, body), nil)
|
||||
}
|
||||
|
||||
// UpdateLibraryItem can update one or both of the item Description and Name fields.
|
||||
func (c *Manager) UpdateLibraryItem(ctx context.Context, item *Item) error {
|
||||
spec := struct {
|
||||
Item `json:"update_spec"`
|
||||
}{
|
||||
Item{
|
||||
Name: item.Name,
|
||||
Description: item.Description,
|
||||
},
|
||||
}
|
||||
url := c.Resource(internal.LibraryItemPath).WithID(item.ID)
|
||||
return c.Do(ctx, url.Request(http.MethodPatch, spec), nil)
|
||||
}
|
||||
|
||||
// DeleteLibraryItem deletes an existing library item.
|
||||
func (c *Manager) DeleteLibraryItem(ctx context.Context, item *Item) error {
|
||||
url := c.Resource(internal.LibraryItemPath).WithID(item.ID)
|
||||
|
|
|
|||
23
vendor/github.com/vmware/govmomi/vapi/rest/client.go
generated
vendored
23
vendor/github.com/vmware/govmomi/vapi/rest/client.go
generated
vendored
|
|
@ -25,6 +25,7 @@ import (
|
|||
"io/ioutil"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
|
|
@ -106,10 +107,21 @@ func (c *Client) UnmarshalJSON(b []byte) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
// isAPI returns true if path starts with "/api"
|
||||
// This hack allows helpers to support both endpoints:
|
||||
// "/rest" - value wrapped responses and structured error responses
|
||||
// "/api" - raw responses and no structured error responses
|
||||
func isAPI(path string) bool {
|
||||
return strings.HasPrefix(path, "/api")
|
||||
}
|
||||
|
||||
// Resource helper for the given path.
|
||||
func (c *Client) Resource(path string) *Resource {
|
||||
r := &Resource{u: c.URL()}
|
||||
r.u.Path = Path + path
|
||||
if !isAPI(path) {
|
||||
path = Path + path
|
||||
}
|
||||
r.u.Path = path
|
||||
return r
|
||||
}
|
||||
|
||||
|
|
@ -153,6 +165,7 @@ func (c *Client) Do(ctx context.Context, req *http.Request, resBody interface{})
|
|||
return c.Client.Do(ctx, req, func(res *http.Response) error {
|
||||
switch res.StatusCode {
|
||||
case http.StatusOK:
|
||||
case http.StatusCreated:
|
||||
case http.StatusNoContent:
|
||||
case http.StatusBadRequest:
|
||||
// TODO: structured error types
|
||||
|
|
@ -174,12 +187,18 @@ func (c *Client) Do(ctx context.Context, req *http.Request, resBody interface{})
|
|||
_, err := io.Copy(b, res.Body)
|
||||
return err
|
||||
default:
|
||||
d := json.NewDecoder(res.Body)
|
||||
if isAPI(req.URL.Path) {
|
||||
// Responses from the /api endpoint are not wrapped
|
||||
return d.Decode(resBody)
|
||||
}
|
||||
// Responses from the /rest endpoint are wrapped in this structure
|
||||
val := struct {
|
||||
Value interface{} `json:"value,omitempty"`
|
||||
}{
|
||||
resBody,
|
||||
}
|
||||
return json.NewDecoder(res.Body).Decode(&val)
|
||||
return d.Decode(&val)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
|
|
|||
9
vendor/github.com/vmware/govmomi/vapi/rest/resource.go
generated
vendored
9
vendor/github.com/vmware/govmomi/vapi/rest/resource.go
generated
vendored
|
|
@ -48,11 +48,12 @@ func (r *Resource) WithAction(action string) *Resource {
|
|||
return r.WithParam("~action", action)
|
||||
}
|
||||
|
||||
// WithParam sets adds a parameter to the URL.RawQuery
|
||||
// WithParam adds one parameter on the URL.RawQuery
|
||||
func (r *Resource) WithParam(name string, value string) *Resource {
|
||||
r.u.RawQuery = url.Values{
|
||||
name: []string{value},
|
||||
}.Encode()
|
||||
// ParseQuery handles empty case, and we control access to query string so shouldn't encounter an error case
|
||||
params, _ := url.ParseQuery(r.u.RawQuery)
|
||||
params[name] = []string{value}
|
||||
r.u.RawQuery = params.Encode()
|
||||
return r
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue