Documentation
¶
Index ¶
- type AttachedObjects
- type AttachedTags
- type Category
- type Manager
- func (c *Manager) AttachTag(ctx context.Context, tagID string, ref mo.Reference) error
- func (c *Manager) CreateCategory(ctx context.Context, category *Category) (string, error)
- func (c *Manager) CreateTag(ctx context.Context, tag *Tag) (string, error)
- func (c *Manager) DeleteCategory(ctx context.Context, category *Category) error
- func (c *Manager) DeleteTag(ctx context.Context, tag *Tag) error
- func (c *Manager) DetachTag(ctx context.Context, tagID string, ref mo.Reference) error
- func (c *Manager) GetAttachedObjectsOnTags(ctx context.Context, tagID []string) ([]AttachedObjects, error)
- func (c *Manager) GetAttachedTags(ctx context.Context, ref mo.Reference) ([]Tag, error)
- func (c *Manager) GetAttachedTagsOnObjects(ctx context.Context, objectID []mo.Reference) ([]AttachedTags, error)
- func (c *Manager) GetCategories(ctx context.Context) ([]Category, error)
- func (c *Manager) GetCategory(ctx context.Context, id string) (*Category, error)
- func (c *Manager) GetTag(ctx context.Context, id string) (*Tag, error)
- func (c *Manager) GetTagForCategory(ctx context.Context, id, category string) (*Tag, error)
- func (c *Manager) GetTags(ctx context.Context) ([]Tag, error)
- func (c *Manager) GetTagsForCategory(ctx context.Context, id string) ([]Tag, error)
- func (c *Manager) ListAttachedObjects(ctx context.Context, tagID string) ([]mo.Reference, error)
- func (c *Manager) ListAttachedObjectsOnTags(ctx context.Context, tagID []string) ([]AttachedObjects, error)
- func (c *Manager) ListAttachedTags(ctx context.Context, ref mo.Reference) ([]string, error)
- func (c *Manager) ListAttachedTagsOnObjects(ctx context.Context, objectID []mo.Reference) ([]AttachedTags, error)
- func (c *Manager) ListCategories(ctx context.Context) ([]string, error)
- func (c *Manager) ListTags(ctx context.Context) ([]string, error)
- func (c *Manager) ListTagsForCategory(ctx context.Context, id string) ([]string, error)
- func (c *Manager) UpdateCategory(ctx context.Context, category *Category) error
- func (c *Manager) UpdateTag(ctx context.Context, tag *Tag) error
- type Tag
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AttachedObjects ¶ added in v0.21.0
type AttachedObjects struct {
TagID string `json:"tag_id"`
Tag *Tag `json:"tag,omitempty"`
ObjectIDs []mo.Reference `json:"object_ids"`
}
AttachedObjects is the response type used by ListAttachedObjectsOnTags.
func (*AttachedObjects) UnmarshalJSON ¶ added in v0.21.0
func (t *AttachedObjects) UnmarshalJSON(b []byte) error
UnmarshalJSON implements json.Unmarshaler.
type AttachedTags ¶ added in v0.21.0
type AttachedTags struct {
ObjectID mo.Reference `json:"object_id"`
TagIDs []string `json:"tag_ids"`
Tags []Tag `json:"tags,omitempty"`
}
AttachedTags is the response type used by ListAttachedTagsOnObjects.
func (*AttachedTags) UnmarshalJSON ¶ added in v0.21.0
func (t *AttachedTags) UnmarshalJSON(b []byte) error
UnmarshalJSON implements json.Unmarshaler.
type Category ¶
type Category struct {
ID string `json:"id,omitempty"`
Name string `json:"name,omitempty"`
Description string `json:"description,omitempty"`
Cardinality string `json:"cardinality,omitempty"`
AssociableTypes []string `json:"associable_types,omitempty"`
UsedBy []string `json:"used_by,omitempty"`
}
Category provides methods to create, read, update, delete, and enumerate categories.
type Manager ¶
Manager extends rest.Client, adding tag related methods.
func NewManager ¶
NewManager creates a new Manager instance with the given client.
func (*Manager) CreateCategory ¶
CreateCategory creates a new category and returns the category ID.
func (*Manager) CreateTag ¶
CreateTag creates a new tag with the given Name, Description and CategoryID.
Example ¶
package main
import (
"context"
"fmt"
"github.com/vmware/govmomi/simulator"
"github.com/vmware/govmomi/vapi/rest"
"github.com/vmware/govmomi/vapi/tags"
"github.com/vmware/govmomi/vim25"
_ "github.com/vmware/govmomi/vapi/simulator"
)
func main() {
simulator.Run(func(ctx context.Context, vc *vim25.Client) error {
c := rest.NewClient(vc)
_ = c.Login(ctx, simulator.DefaultLogin)
m := tags.NewManager(c)
id, err := m.CreateCategory(ctx, &tags.Category{
AssociableTypes: []string{"VirtualMachine"},
Cardinality: "SINGLE",
Description: "This is My Category",
Name: "my-category",
})
if err != nil {
return err
}
id, err = m.CreateTag(ctx, &tags.Tag{
CategoryID: id,
Description: "This is My Tag",
Name: "my-tag",
})
if err != nil {
return err
}
tag, err := m.GetTag(ctx, id)
if err != nil {
return err
}
fmt.Println(tag.Name)
return nil
})
}
Output: my-tag
func (*Manager) DeleteCategory ¶
DeleteCategory deletes an existing category.
func (*Manager) DetachTag ¶
DetachTag detaches a tag ID from a managed object. If the tag is already removed from the object, then this operation is a no-op and an error will not be thrown.
func (*Manager) GetAttachedObjectsOnTags ¶ added in v0.21.0
func (c *Manager) GetAttachedObjectsOnTags(ctx context.Context, tagID []string) ([]AttachedObjects, error)
GetAttachedObjectsOnTags combines ListAttachedObjectsOnTags and populates each Tag field.
func (*Manager) GetAttachedTags ¶
GetAttachedTags fetches the array of tags attached to the given object.
func (*Manager) GetAttachedTagsOnObjects ¶ added in v0.21.0
func (c *Manager) GetAttachedTagsOnObjects(ctx context.Context, objectID []mo.Reference) ([]AttachedTags, error)
GetAttachedTagsOnObjects calls ListAttachedTagsOnObjects and populates each Tags field.
func (*Manager) GetCategories ¶
GetCategories fetches an array of category information in the system.
func (*Manager) GetCategory ¶
GetCategory fetches the category information for the given identifier. The id parameter can be a Category ID or Category Name.
func (*Manager) GetTag ¶
GetTag fetches the tag information for the given identifier. The id parameter can be a Tag ID or Tag Name.
func (*Manager) GetTagForCategory ¶ added in v0.20.0
GetTagForCategory fetches the tag information for the given identifier in the given category.
func (*Manager) GetTagsForCategory ¶
The id parameter can be a Category ID or Category Name.
func (*Manager) ListAttachedObjects ¶
ListAttachedObjects fetches the array of attached objects for the given tag ID.
func (*Manager) ListAttachedObjectsOnTags ¶ added in v0.21.0
func (c *Manager) ListAttachedObjectsOnTags(ctx context.Context, tagID []string) ([]AttachedObjects, error)
ListAttachedObjectsOnTags fetches the array of attached objects for the given tag IDs.
func (*Manager) ListAttachedTags ¶
ListAttachedTags fetches the array of tag IDs attached to the given object.
func (*Manager) ListAttachedTagsOnObjects ¶ added in v0.21.0
func (c *Manager) ListAttachedTagsOnObjects(ctx context.Context, objectID []mo.Reference) ([]AttachedTags, error)
ListAttachedTagsOnObjects fetches the array of attached tag IDs for the given object IDs.
func (*Manager) ListCategories ¶
ListCategories returns all category IDs in the system.
func (*Manager) ListTagsForCategory ¶
The id parameter can be a Category ID or Category Name.
func (*Manager) UpdateCategory ¶
UpdateCategory can update one or more of the AssociableTypes, Cardinality, Description and Name fields.
type Tag ¶
type Tag struct {
ID string `json:"id,omitempty"`
Description string `json:"description,omitempty"`
Name string `json:"name,omitempty"`
CategoryID string `json:"category_id,omitempty"`
UsedBy []string `json:"used_by,omitempty"`
}
Tag provides methods to create, read, update, delete, and enumerate tags.