Function: vCenter VAPI Plugin Get Attached Tags From Category

by Simon Sparks · 13 January 2026

To use this function add it to the class library file named vCenterVAPIService.ts

GitHub Repository: https://github.com/SimonSparksUK/Orchestrator

Filename: vCenterVAPIService.ts

Function getTagNameByID

private getTagNameByID(objVAPIClient: VAPIClient, strTagID: string): string {

    let objVAPITaggingTag: com_vmware_cis_tagging_tag = new com_vmware_cis_tagging_tag(objVAPIClient);

    let objVAPITagModel: com_vmware_cis_tagging_tag__model = objVAPITaggingTag.get(strTagID);

    let strResult: string = objVAPITagModel.name;

    return strResult;
}

Function getAttachedTagsFromCategory

public getAttachedTagsFromCategory(objVAPIClient: VAPIClient, objVcVirtualMachine: VcVirtualMachine, strTagCategoryName: string): com_vmware_cis_tagging_tag__model[] {

    let arrResult: com_vmware_cis_tagging_tag__model[] = [];
        
    let strTagCategoryID: string = this.findTagCategoryIDByName(objVAPIClient, strTagCategoryName);

    let arrTagIDs: string[] = this.listAttachedTagsFromSpecificCategoryID(objVAPIClient, objVcVirtualMachine, strTagCategoryID);

    arrResult = arrTagIDs.map((strTagID: string): com_vmware_cis_tagging_tag__model => {
        return this.getTagByID(objVAPIClient, strTagID);
    });
    
    return arrResult;
}


Discover more from Cloud Build Tools

Subscribe to get the latest posts sent to your email.

You may also like