Search in sources :

Example 1 with TaggingClient

use of com.vmware.photon.controller.model.adapters.vsphere.vapi.TaggingClient in project photon-model by vmware.

the class VsphereEnumerationHelper method retrieveAttachedTags.

/**
 * Retreives all tags for a MoRef from an endpoint.
 *
 * @return empty list if no tags found, never null
 */
static List<TagState> retrieveAttachedTags(VSphereIncrementalEnumerationService service, VapiConnection endpoint, ManagedObjectReference ref, List<String> tenantLinks) throws IOException, RpcException {
    TaggingClient taggingClient = endpoint.newTaggingClient();
    List<String> tagIds = taggingClient.getAttachedTags(ref);
    List<TagState> res = new ArrayList<>();
    for (String id : tagIds) {
        TagState cached = service.getTagCache().get(id, newTagRetriever(taggingClient));
        if (cached != null) {
            TagState tag = TagsUtil.newTagState(cached.key, cached.value, true, tenantLinks);
            res.add(tag);
        }
    }
    return res;
}
Also used : ArrayList(java.util.ArrayList) TaggingClient(com.vmware.photon.controller.model.adapters.vsphere.vapi.TaggingClient) TagState(com.vmware.photon.controller.model.resources.TagService.TagState)

Aggregations

TaggingClient (com.vmware.photon.controller.model.adapters.vsphere.vapi.TaggingClient)1 TagState (com.vmware.photon.controller.model.resources.TagService.TagState)1 ArrayList (java.util.ArrayList)1