archive/v1/client/findByName.js
function rootSearch(args) {
		
		// get the datacenters
		return _client.retrieve({
			type: 'Datacenter',
			properties: ['name', 'datastoreFolder', 'hostFolder', 'networkFolder', 'vmFolder']
		})
		.then(function(dcs) {

			// look through each of the dcs and map the return values
			return Promise.map(dcs, function(dc) {
				
				var folderId;
				
				// get the correct folder id to start search from or if searching
				if (args.type === 'Datastore') {
					folderId = dc.datastoreFolder;
				}
				else if (args.type === 'HostSystem') {
					folderId = dc.hostFolder;
				}
				else if (args.type === 'Network') {
					folderId = dc.networkFolder;
				}
				else if (args.type === 'VirtualMachine') {
					folderId = dc.vmFolder;
				}
				
				// return the entity details
				return {
					type: 'Folder',
					id: folderId
				};
			});
		});
	}
function rootSearch(args) {
		
		// get the datacenters
		return _client.retrieve({
			type: 'Datacenter',
			properties: ['name', 'datastoreFolder', 'hostFolder', 'networkFolder', 'vmFolder']
		})
		.then(function(dcs) {

			// look through each of the dcs and map the return values
			return Promise.map(dcs, function(dc) {
				
				var folderId;
				
				// get the correct folder id to start search from or if searching
				if (args.type === 'Datastore') {
					folderId = dc.datastoreFolder;
				}
				else if (args.type === 'HostSystem') {
					folderId = dc.hostFolder;
				}
				else if (args.type === 'Network') {
					folderId = dc.networkFolder;
				}
				else if (args.type === 'VirtualMachine') {
					folderId = dc.vmFolder;
				}
				
				// return the entity details
				return {
					type: 'Folder',
					id: folderId
				};
			});
		});
	}
function rootSearch ( args ) { // get the datacenters return _client . retrieve ( { type : 'Datacenter' , properties : [ 'name' , 'datastoreFolder' , 'hostFolder' , 'networkFolder' , 'vmFolder' ] } ) . then ( function ( dcs ) { // look through each of the dcs and map the return values return Promise . map ( dcs , function ( dc ) { var folderId ; // get the correct folder id to start search from or if searching if ( args . type === 'Datastore' ) { folderId = dc . datastoreFolder ; } else if ( args . type === 'HostSystem' ) { folderId = dc . hostFolder ; } else if ( args . type === 'Network' ) { folderId = dc . networkFolder ; } else if ( args . type === 'VirtualMachine' ) { folderId = dc . vmFolder ; } // return the entity details return { type : 'Folder' , id : folderId } ; } ) ; } ) ; }
search the top level folders in each datacenter
search the top level folders in each datacenter