{"modulePath":"github.com/openshift/machine-api-operator","version":"v0.2.1-0.20261119161144-2615267e69e2","isLatest":false,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package session\n\n## Functions\n\n```go\nfunc IsName(id string) bool\n```\nIsName returns true if the id is not an urn. this method came from vSphere sdk, see [https://github.com/vmware/govmomi/blob/a2fb82dc55a8eb00932233aa8028ce97140df784/vapi/tags/tags.go#L121](https://github.com/vmware/govmomi/blob/a2fb82dc55a8eb00932233aa8028ce97140df784/vapi/tags/tags.go#L121) for more context.\n\n## Types\n\n```go\ntype CachingTagsManager struct {\n\t*tags.Manager\n\t// contains filtered or unexported fields\n}\n```\nCachingTagsManager wraps tags.Manager from vSphere SDK for cache mapping between tags or categories name and their ids, and for caching the full tag/category objects themselves. Reasoning behind this is the implementation details of tags/categories lookup by name, to find a tag/category by name vSphere SDK gets a list of ids and then makes an additional request for every object till it will not find matched names. Such peculiarity causes a huge performance degradation within environments with a large number of tags/categories, because in the worst case number of rest requests for object lookup might be equal to the number of objects.\n\nSee tags.Manager methods for more details: [https://github.com/vmware/govmomi/blob/a2fb82dc55a8eb00932233aa8028ce97140df784/vapi/tags/tags.go#L172](https://github.com/vmware/govmomi/blob/a2fb82dc55a8eb00932233aa8028ce97140df784/vapi/tags/tags.go#L172)\n\nThis structure is intended to be used from a Session instance (Session.GetCachingTagsManager method specifically) presented in this module.\n\n```go\nfunc (t *CachingTagsManager) GetCategory(ctx context.Context, id string) (*tags.Category, error)\n```\nGetCategory fetches the category information for the given identifier. The id parameter can be a Category ID or Category Name. This method shadows original tags.Manager method and caches mapping between category name and its id as well as the full category object, so any hit path (object cache or name-\u003eid cache) returns without REST calls.\n\nIn case if a category was not found in vCenter, this would be cached for 12 hours and lookup won't happen till cache expiration.\n\n```go\nfunc (t *CachingTagsManager) GetTag(ctx context.Context, id string) (*tags.Tag, error)\n```\nGetTag fetches the tag information for the given identifier. The id parameter can be a Tag ID or Tag Name. This method shadows original tags.Manager method and caches mapping between tag name and its id as well as the full tag object, so any hit path (object cache or name-\u003eid cache) returns without REST calls.\n\nIn case if a tag was not found in vCenter, this would be cached for 12 hours and lookup won't happen till cache expiration.\n\n```go\nfunc (t *CachingTagsManager) ListTagsForCategory(ctx context.Context, id string) ([]string, error)\n```\nListTagsForCategory tag ids for the given category. The id parameter can be a Category ID or Category Name. Uses caching GetCategory method.\n\n```go\ntype Session struct {\n\t*govmomi.Client\n\tFinder     *find.Finder\n\tDatacenter *object.Datacenter\n\tTagManager *tags.Manager\n\t// contains filtered or unexported fields\n}\n```\nSession is a vSphere session with a configured Finder. This implementation is inspired by cluster-api-provider-vsphere's session caching pattern to avoid excessive vCenter login/logout cycles for REST API operations. Reference: [https://github.com/kubernetes-sigs/cluster-api-provider-vsphere/blob/main/pkg/session/session.go](https://github.com/kubernetes-sigs/cluster-api-provider-vsphere/blob/main/pkg/session/session.go)\n\n```go\nfunc GetOrCreate(\n\tctx context.Context,\n\tserver, datacenter, username, password string, insecure bool) (*Session, error)\n```\nGetOrCreate gets a cached session or creates a new one if one does not already exist.\n\n```go\nfunc (s *Session) FindRefByInstanceUUID(ctx context.Context, UUID string) (object.Reference, error)\n```\nFindByInstanceUUID finds an object by its instance UUID.\n\n```go\nfunc (s *Session) FindVM(ctx context.Context, UUID, name string) (*object.VirtualMachine, error)\n```\n\n```go\nfunc (s *Session) GetCachingTagsManager() *CachingTagsManager\n```\nGetCachingTagsManager returns the per-session CachingTagsManager that wraps the cached TagManager. It is created once when the session is created, so no new vCenter login/logout happens on access.\n\n```go\nfunc (s *Session) GetTask(ctx context.Context, taskRef string) (*mo.Task, error)\n```\n\n","path":"github.com/openshift/machine-api-operator/pkg/controller/vsphere/session","name":"session","synopsis":"","isRedistributable":true}
