/*================================================================================
Copyright (c) 2013 Steve Jin. All Rights Reserved.

Redistribution and use in source and binary forms, with or without modification, 
are permitted provided that the following conditions are met:

* Redistributions of source code must retain the above copyright notice, 
this list of conditions and the following disclaimer.

* Redistributions in binary form must reproduce the above copyright notice, 
this list of conditions and the following disclaimer in the documentation 
and/or other materials provided with the distribution.

* Neither the name of VMware, Inc. nor the names of its contributors may be used
to endorse or promote products derived from this software without specific prior 
written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 
IN NO EVENT SHALL VMWARE, INC. OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
POSSIBILITY OF SUCH DAMAGE.
================================================================================*/

package com.vmware.vim25.ws;

import com.vmware.vim25.*;
import org.apache.log4j.Logger;

import javax.net.ssl.TrustManager;
import java.lang.reflect.InvocationTargetException;
import java.rmi.RemoteException;
import java.util.Calendar;
import java.lang.Object;

/**
 * @author Steve Jin (http://www.doublecloud.org)
 * @version 5.1
 */

public class VimStub {

    private Client wsc = null;
    /**
     * Setup logger
     */
    private static Logger log = Logger.getLogger(VimStub.class);

    public VimStub(String url, boolean ignoreCert) {
        try {
            this.wsc = ClientCreator.getClient(url, ignoreCert);
        }
        catch (NoSuchMethodException e) {
            log.error("Error detected for url: " + url + " ignoreSSL: " + ignoreCert, e);
        }
        catch (IllegalAccessException e) {
            log.error("Error detected for url: " + url + " ignoreSSL: " + ignoreCert, e);
        }
        catch (InvocationTargetException e) {
            log.error("Error detected for url: " + url + " ignoreSSL: " + ignoreCert, e);
        }
        catch (InstantiationException e) {
            log.error("Error detected for url: " + url + " ignoreSSL: " + ignoreCert, e);
        }
    }

    public VimStub(String url, TrustManager trustManager) {
        try {
            this.wsc = ClientCreator.getClient(url, trustManager);
        } catch (Exception e) {
            log.error("Error detected for url: " + url + " trustManager: " + trustManager, e);
        }
    }

    public VimStub(Client wsc) {
        this.wsc = wsc;
    }

    public Client getWsc() {
        return wsc;
    }

    public void destroyPropertyFilter(ManagedObjectReference _this) throws java.rmi.RemoteException, RuntimeFault {
        Argument[] paras = new Argument[1];
        paras[0] = new Argument("_this", "ManagedObjectReference", _this);
        getWsc().invoke("DestroyPropertyFilter", paras, null);
    }

    public ManagedObjectReference createFilter(ManagedObjectReference _this, PropertyFilterSpec spec, boolean partialUpdates) throws java.rmi.RemoteException, InvalidProperty, RuntimeFault {
        Argument[] paras = new Argument[3];
        paras[0] = new Argument("_this", "ManagedObjectReference", _this);
        paras[1] = new Argument("spec", "PropertyFilterSpec", spec);
        paras[2] = new Argument("partialUpdates", "boolean", partialUpdates);
        return (ManagedObjectReference) getWsc().invoke("CreateFilter", paras, "ManagedObjectReference");
    }

    public ObjectContent[] retrieveProperties(ManagedObjectReference _this, PropertyFilterSpec[] specSet) throws java.rmi.RemoteException, InvalidProperty, RuntimeFault {
        Argument[] paras = new Argument[2];
        paras[0] = new Argument("_this", "ManagedObjectReference", _this);
        paras[1] = new Argument("specSet", "PropertyFilterSpec[]", specSet);
        return (ObjectContent[]) getWsc().invoke("RetrieveProperties", paras, "ObjectContent[]");
    }

    public UpdateSet checkForUpdates(ManagedObjectReference _this, String version) throws java.rmi.RemoteException, InvalidCollectorVersion, RuntimeFault {
        Argument[] paras = new Argument[2];
        paras[0] = new Argument("_this", "ManagedObjectReference", _this);
        paras[1] = new Argument("version", "String", version);
        return (UpdateSet) getWsc().invoke("CheckForUpdates", paras, "UpdateSet");
    }

    public UpdateSet waitForUpdates(ManagedObjectReference _this, String version) throws java.rmi.RemoteException, InvalidCollectorVersion, RuntimeFault {
        Argument[] paras = new Argument[2];
        paras[0] = new Argument("_this", "ManagedObjectReference", _this);
        paras[1] = new Argument("version", "String", version);
        return (UpdateSet) getWsc().invoke("WaitForUpdates", paras, "UpdateSet");
    }

    public void cancelWaitForUpdates(ManagedObjectReference _this) throws java.rmi.RemoteException, RuntimeFault {
        Argument[] paras = new Argument[1];
        paras[0] = new Argument("_this", "ManagedObjectReference", _this);
        getWsc().invoke("CancelWaitForUpdates", paras, null);
    }

    public UpdateSet waitForUpdatesEx(ManagedObjectReference _this, String version, WaitOptions options) throws java.rmi.RemoteException, InvalidCollectorVersion, RuntimeFault {
        Argument[] paras = new Argument[3];
        paras[0] = new Argument("_this", "ManagedObjectReference", _this);
        paras[1] = new Argument("version", "String", version);
        paras[2] = new Argument("options", "WaitOptions", options);
        return (UpdateSet) getWsc().invoke("WaitForUpdatesEx", paras, "UpdateSet");
    }

    public RetrieveResult retrievePropertiesEx(ManagedObjectReference _this, PropertyFilterSpec[] specSet, RetrieveOptions options) throws java.rmi.RemoteException, InvalidProperty, RuntimeFault {
        Argument[] paras = new Argument[3];
        paras[0] = new Argument("_this", "ManagedObjectReference", _this);
        paras[1] = new Argument("specSet", "PropertyFilterSpec[]", specSet);
        paras[2] = new Argument("options", "RetrieveOptions", options);
        return (RetrieveResult) getWsc().invoke("RetrievePropertiesEx", paras, "RetrieveResult");
    }

    public RetrieveResult continueRetrievePropertiesEx(ManagedObjectReference _this, String token) throws java.rmi.RemoteException, InvalidProperty, RuntimeFault {
        Argument[] paras = new Argument[2];
        paras[0] = new Argument("_this", "ManagedObjectReference", _this);
        paras[1] = new Argument("token", "String", token);
        return (RetrieveResult) getWsc().invoke("ContinueRetrievePropertiesEx", paras, "RetrieveResult");
    }

    public void cancelRetrievePropertiesEx(ManagedObjectReference _this, String token) throws java.rmi.RemoteException, InvalidProperty, RuntimeFault {
        Argument[] paras = new Argument[2];
        paras[0] = new Argument("_this", "ManagedObjectReference", _this);
        paras[1] = new Argument("token", "String", token);
        getWsc().invoke("CancelRetrievePropertiesEx", paras, null);
    }

    public ManagedObjectReference createPropertyCollector(ManagedObjectReference _this) throws java.rmi.RemoteException, RuntimeFault {
        Argument[] paras = new Argument[1];
        paras[0] = new Argument("_this", "ManagedObjectReference", _this);
        return (ManagedObjectReference) getWsc().invoke("CreatePropertyCollector", paras, "ManagedObjectReference");
    }

    public void destroyPropertyCollector(ManagedObjectReference _this) throws java.rmi.RemoteException, RuntimeFault {
        Argument[] paras = new Argument[1];
        paras[0] = new Argument("_this", "ManagedObjectReference", _this);
        getWsc().invoke("DestroyPropertyCollector", paras, null);
    }

    public int addAuthorizationRole(ManagedObjectReference _this, String name, String[] privIds) throws java.rmi.RemoteException, AlreadyExists, InvalidName, RuntimeFault {
        Argument[] paras = new Argument[3];
        paras[0] = new Argument("_this", "ManagedObjectReference", _this);
        paras[1] = new Argument("name", "String", name);
        paras[2] = new Argument("privIds", "String[]", privIds);
        Integer ret = (Integer) getWsc().invoke("AddAuthorizationRole", paras, "int");
        return ret.intValue();
    }

    public void removeAuthorizationRole(ManagedObjectReference _this, int roleId, boolean failIfUsed) throws java.rmi.RemoteException, NotFound, RemoveFailed, RuntimeFault {
        Argument[] paras = new Argument[3];
        paras[0] = new Argument("_this", "ManagedObjectReference", _this);
        paras[1] = new Argument("roleId", "int", roleId);
        paras[2] = new Argument("failIfUsed", "boolean", failIfUsed);
        getWsc().invoke("RemoveAuthorizationRole", paras, null);
    }

    public void updateAuthorizationRole(ManagedObjectReference _this, int roleId, String newName, String[] privIds) throws java.rmi.RemoteException, NotFound, InvalidName, AlreadyExists, RuntimeFault {
        Argument[] paras = new Argument[4];
        paras[0] = new Argument("_this", "ManagedObjectReference", _this);
        paras[1] = new Argument("roleId", "int", roleId);
        paras[2] = new Argument("newName", "String", newName);
        paras[3] = new Argument("privIds", "String[]", privIds);
        getWsc().invoke("UpdateAuthorizationRole", paras, null);
    }

    public void mergePermissions(ManagedObjectReference _this, int srcRoleId, int dstRoleId) throws java.rmi.RemoteException, NotFound, AuthMinimumAdminPermission, RuntimeFault {
        Argument[] paras = new Argument[3];
        paras[0] = new Argument("_this", "ManagedObjectReference", _this);
        paras[1] = new Argument("srcRoleId", "int", srcRoleId);
        paras[2] = new Argument("dstRoleId", "int", dstRoleId);
        getWsc().invoke("MergePermissions", paras, null);
    }

    public Permission[] retrieveRolePermissions(ManagedObjectReference _this, int roleId) throws java.rmi.RemoteException, NotFound, RuntimeFault {
        Argument[] paras = new Argument[2];
        paras[0] = new Argument("_this", "ManagedObjectReference", _this);
        paras[1] = new Argument("roleId", "int", roleId);
        return (Permission[]) getWsc().invoke("RetrieveRolePermissions", paras, "Permission[]");
    }

    public Permission[] retrieveEntityPermissions(ManagedObjectReference _this, ManagedObjectReference entity, boolean inherited) throws java.rmi.RemoteException, RuntimeFault {
        Argument[] paras = new Argument[3];
        paras[0] = new Argument("_this", "ManagedObjectReference", _this);
        paras[1] = new Argument("entity", "ManagedObjectReference", entity);
        paras[2] = new Argument("inherited", "boolean", inherited);
        return (Permission[]) getWsc().invoke("RetrieveEntityPermissions", paras, "Permission[]");
    }

    public Permission[] retrieveAllPermissions(ManagedObjectReference _this) throws java.rmi.RemoteException, RuntimeFault {
        Argument[] paras = new Argument[1];
        paras[0] = new Argument("_this", "ManagedObjectReference", _this);
        return (Permission[]) getWsc().invoke("RetrieveAllPermissions", paras, "Permission[]");
    }

    public void setEntityPermissions(ManagedObjectReference _this, ManagedObjectReference entity, Permission[] permission) throws java.rmi.RemoteException, UserNotFound, NotFound, AuthMinimumAdminPermission, RuntimeFault {
        Argument[] paras = new Argument[3];
        paras[0] = new Argument("_this", "ManagedObjectReference", _this);
        paras[1] = new Argument("entity", "ManagedObjectReference", entity);
        paras[2] = new Argument("permission", "Permission[]", permission);
        getWsc().invoke("SetEntityPermissions", paras, null);
    }

    public void resetEntityPermissions(ManagedObjectReference _this, ManagedObjectReference entity, Permission[] permission) throws java.rmi.RemoteException, UserNotFound, NotFound, AuthMinimumAdminPermission, RuntimeFault {
        Argument[] paras = new Argument[3];
        paras[0] = new Argument("_this", "ManagedObjectReference", _this);
        paras[1] = new Argument("entity", "ManagedObjectReference", entity);
        paras[2] = new Argument("permission", "Permission[]", permission);
        getWsc().invoke("ResetEntityPermissions", paras, null);
    }

    public void removeEntityPermission(ManagedObjectReference _this, ManagedObjectReference entity, String user, boolean isGroup) throws java.rmi.RemoteException, NotFound, AuthMinimumAdminPermission, RuntimeFault {
        Argument[] paras = new Argument[4];
        paras[0] = new Argument("_this", "ManagedObjectReference", _this);
        paras[1] = new Argument("entity", "ManagedObjectReference", entity);
        paras[2] = new Argument("user", "String", user);
        paras[3] = new Argument("isGroup", "boolean", isGroup);
        getWsc().invoke("RemoveEntityPermission", paras, null);
    }

    public boolean[] hasPrivilegeOnEntity(ManagedObjectReference _this, ManagedObjectReference entity, String sessionId, String[] privId) throws java.rmi.RemoteException, RuntimeFault {
        Argument[] paras = new Argument[4];
        paras[0] = new Argument("_this", "ManagedObjectReference", _this);
        paras[1] = new Argument("entity", "ManagedObjectReference", entity);
        paras[2] = new Argument("sessionId", "String", sessionId);
        paras[3] = new Argument("privId", "String[]", privId);
        return (boolean[]) getWsc().invoke("HasPrivilegeOnEntity", paras, "boolean[]");
    }

    public EntityPrivilege[] hasPrivilegeOnEntities(ManagedObjectReference _this, ManagedObjectReference[] entity, String sessionId, String[] privId) throws java.rmi.RemoteException, RuntimeFault {
        Argument[] paras = new Argument[4];
        paras[0] = new Argument("_this", "ManagedObjectReference", _this);
        paras[1] = new Argument("entity", "ManagedObjectReference[]", entity);
        paras[2] = new Argument("sessionId", "String", sessionId);
        paras[3] = new Argument("privId", "String[]", privId);
        return (EntityPrivilege[]) getWsc().invoke("HasPrivilegeOnEntities", paras, "EntityPrivilege[]");
    }

    public ManagedObjectReference reconfigureCluster_Task(ManagedObjectReference _this, ClusterConfigSpec spec, boolean modify) throws java.rmi.RemoteException, RuntimeFault {
        Argument[] paras = new Argument[3];
        paras[0] = new Argument("_this", "ManagedObjectReference", _this);
        paras[1] = new Argument("spec", "ClusterConfigSpec", spec);
        paras[2] = new Argument("modify", "boolean", modify);
        return (ManagedObjectReference) getWsc().invoke("ReconfigureCluster_Task", paras, "ManagedObjectReference");
    }

    public void applyRecommendation(ManagedObjectReference _this, String key) throws java.rmi.RemoteException, RuntimeFault {
        Argument[] paras = new Argument[2];
        paras[0] = new Argument("_this", "ManagedObjectReference", _this);
        paras[1] = new Argument("key", "String", key);
        getWsc().invoke("ApplyRecommendation", paras, null);
    }

    public void cancelRecommendation(ManagedObjectReference _this, String key) throws java.rmi.RemoteException, RuntimeFault {
        Argument[] paras = new Argument[2];
        paras[0] = new Argument("_this", "ManagedObjectReference", _this);
        paras[1] = new Argument("key", "String", key);
        getWsc().invoke("CancelRecommendation", paras, null);
    }

    public ClusterHostRecommendation[] recommendHostsForVm(ManagedObjectReference _this, ManagedObjectReference vm, ManagedObjectReference pool) throws java.rmi.RemoteException, RuntimeFault {
        Argument[] paras = new Argument[3];
        paras[0] = new Argument("_this", "ManagedObjectReference", _this);
        paras[1] = new Argument("vm", "ManagedObjectReference", vm);
        paras[2] = new Argument("pool", "ManagedObjectReference", pool);
        return (ClusterHostRecommendation[]) getWsc().invoke("RecommendHostsForVm", paras, "ClusterHostRecommendation[]");
    }

    public ManagedObjectReference addHost_Task(ManagedObjectReference _this, HostConnectSpec spec, boolean asConnected, ManagedObjectReference resourcePool, String license) throws java.rmi.RemoteException, InvalidLogin, HostConnectFault, DuplicateName, RuntimeFault {
        Argument[] paras = new Argument[5];
        paras[0] = new Argument("_this", "ManagedObjectReference", _this);
        paras[1] = new Argument("spec", "HostConnectSpec", spec);
        paras[2] = new Argument("asConnected", "boolean", asConnected);
        paras[3] = new Argument("resourcePool", "ManagedObjectReference", resourcePool);
        paras[4] = new Argument("license", "String", license);
        return (ManagedObjectReference) getWsc().invoke("AddHost_Task", paras, "ManagedObjectReference");
    }

    public ManagedObjectReference moveInto_Task(ManagedObjectReference _this, ManagedObjectReference[] host) throws java.rmi.RemoteException, DuplicateName, TooManyHosts, InvalidState, RuntimeFault {
        Argument[] paras = new Argument[2];
        paras[0] = new Argument("_this", "ManagedObjectReference", _this);
        paras[1] = new Argument("host", "ManagedObjectReference[]", host);
        return (ManagedObjectReference) getWsc().invoke("MoveInto_Task", paras, "ManagedObjectReference");
    }

    public ManagedObjectReference moveHostInto_Task(ManagedObjectReference _this, ManagedObjectReference host, ManagedObjectReference resourcePool) throws java.rmi.RemoteException, TooManyHosts, InvalidState, RuntimeFault {
        Argument[] paras = new Argument[3];
        paras[0] = new Argument("_this", "ManagedObjectReference", _this);
        paras[1] = new Argument("host", "ManagedObjectReference", host);
        paras[2] = new Argument("resourcePool", "ManagedObjectReference", resourcePool);
        return (ManagedObjectReference) getWsc().invoke("MoveHostInto_Task", paras, "ManagedObjectReference");
    }

    public void refreshRecommendation(ManagedObjectReference _this) throws java.rmi.RemoteException, RuntimeFault {
        Argument[] paras = new Argument[1];
        paras[0] = new Argument("_this", "ManagedObjectReference", _this);
        getWsc().invoke("RefreshRecommendation", paras, null);
    }

    public ClusterDasAdvancedRuntimeInfo retrieveDasAdvancedRuntimeInfo(ManagedObjectReference _this) throws java.rmi.RemoteException, RuntimeFault {
        Argument[] paras = new Argument[1];
        paras[0] = new Argument("_this", "ManagedObjectReference", _this);
        return (ClusterDasAdvancedRuntimeInfo) getWsc().invoke("RetrieveDasAdvancedRuntimeInfo", paras, "ClusterDasAdvancedRuntimeInfo");
    }

    public ClusterEnterMaintenanceResult clusterEnterMaintenanceMode(ManagedObjectReference _this, ManagedObjectReference[] host, OptionValue[] option) throws java.rmi.RemoteException, RuntimeFault {
        Argument[] paras = new Argument[3];
        paras[0] = new Argument("_this", "ManagedObjectReference", _this);
        paras[1] = new Argument("host", "ManagedObjectReference[]", host);
        paras[2] = new Argument("option", "OptionValue[]", option);
        return (ClusterEnterMaintenanceResult) getWsc().invoke("ClusterEnterMaintenanceMode", paras, "ClusterEnterMaintenanceResult");
    }

    public ManagedObjectReference reconfigureComputeResource_Task(ManagedObjectReference _this, ComputeResourceConfigSpec spec, boolean modify) throws java.rmi.RemoteException, RuntimeFault {
        Argument[] paras = new Argument[3];
        paras[0] = new Argument("_this", "ManagedObjectReference", _this);
        paras[1] = new Argument("spec", "ComputeResourceConfigSpec", spec);
        paras[2] = new Argument("modify", "boolean", modify);
        return (ManagedObjectReference) getWsc().invoke("ReconfigureComputeResource_Task", paras, "ManagedObjectReference");
    }

    public CustomFieldDef addCustomFieldDef(ManagedObjectReference _this, String name, String moType, PrivilegePolicyDef fieldDefPolicy, PrivilegePolicyDef fieldPolicy) throws java.rmi.RemoteException, DuplicateName, InvalidPrivilege, RuntimeFault {
        Argument[] paras = new Argument[5];
        paras[0] = new Argument("_this", "ManagedObjectReference", _this);
        paras[1] = new Argument("name", "String", name);
        paras[2] = new Argument("moType", "String", moType);
        paras[3] = new Argument("fieldDefPolicy", "PrivilegePolicyDef", fieldDefPolicy);
        paras[4] = new Argument("fieldPolicy", "PrivilegePolicyDef", fieldPolicy);
        return (CustomFieldDef) getWsc().invoke("AddCustomFieldDef", paras, "CustomFieldDef");
    }

    public void removeCustomFieldDef(ManagedObjectReference _this, int key) throws java.rmi.RemoteException, RuntimeFault {
        Argument[] paras = new Argument[2];
        paras[0] = new Argument("_this", "ManagedObjectReference", _this);
        paras[1] = new Argument("key", "int", key);
        getWsc().invoke("RemoveCustomFieldDef", paras, null);
    }

    public void renameCustomFieldDef(ManagedObjectReference _this, int key, String name) throws java.rmi.RemoteException, DuplicateName, RuntimeFault {
        Argument[] paras = new Argument[3];
        paras[0] = new Argument("_this", "ManagedObjectReference", _this);
        paras[1] = new Argument("key", "int", key);
        paras[2] = new Argument("name", "String", name);
        getWsc().invoke("RenameCustomFieldDef", paras, null);
    }

    public void setField(ManagedObjectReference _this, ManagedObjectReference entity, int key, String value) throws java.rmi.RemoteException, RuntimeFault {
        Argument[] paras = new Argument[4];
        paras[0] = new Argument("_this", "ManagedObjectReference", _this);
        paras[1] = new Argument("entity", "ManagedObjectReference", entity);
        paras[2] = new Argument("key", "int", key);
        paras[3] = new Argument("value", "String", value);
        getWsc().invoke("SetField", paras, null);
    }

    public boolean doesCustomizationSpecExist(ManagedObjectReference _this, String name) throws java.rmi.RemoteException, RuntimeFault {
        Argument[] paras = new Argument[2];
        paras[0] = new Argument("_this", "ManagedObjectReference", _this);
        paras[1] = new Argument("name", "String", name);
        Boolean ret = (Boolean) getWsc().invoke("DoesCustomizationSpecExist", paras, "boolean");
        return ret.booleanValue();
    }

    public CustomizationSpecItem getCustomizationSpec(ManagedObjectReference _this, String name) throws java.rmi.RemoteException, NotFound, RuntimeFault {
        Argument[] paras = new Argument[2];
        paras[0] = new Argument("_this", "ManagedObjectReference", _this);
        paras[1] = new Argument("name", "String", name);
        return (CustomizationSpecItem) getWsc().invoke("GetCustomizationSpec", paras, "CustomizationSpecItem");
    }

    public void createCustomizationSpec(ManagedObjectReference _this, CustomizationSpecItem item) throws java.rmi.RemoteException, CustomizationFault, AlreadyExists, RuntimeFault {
        Argument[] paras = new Argument[2];
        paras[0] = new Argument("_this", "ManagedObjectReference", _this);
        paras[1] = new Argument("item", "CustomizationSpecItem", item);
        getWsc().invoke("CreateCustomizationSpec", paras, null);
    }

    public void overwriteCustomizationSpec(ManagedObjectReference _this, CustomizationSpecItem item) throws java.rmi.RemoteException, CustomizationFault, NotFound, ConcurrentAccess, RuntimeFault {
        Argument[] paras = new Argument[2];
        paras[0] = new Argument("_this", "ManagedObjectReference", _this);
        paras[1] = new Argument("item", "CustomizationSpecItem", item);
        getWsc().invoke("OverwriteCustomizationSpec", paras, null);
    }

    public void deleteCustomizationSpec(ManagedObjectReference _this, String name) throws java.rmi.RemoteException, NotFound, RuntimeFault {
        Argument[] paras = new Argument[2];
        paras[0] = new Argument("_this", "ManagedObjectReference", _this);
        paras[1] = new Argument("name", "String", name);
        getWsc().invoke("DeleteCustomizationSpec", paras, null);
    }

    public void duplicateCustomizationSpec(ManagedObjectReference _this, String name, String newName) throws java.rmi.RemoteException, NotFound, AlreadyExists, RuntimeFault {
        Argument[] paras = new Argument[3];
        paras[0] = new Argument("_this", "ManagedObjectReference", _this);
        paras[1] = new Argument("name", "String", name);
        paras[2] = new Argument("newName", "String", newName);
        getWsc().invoke("DuplicateCustomizationSpec", paras, null);
    }

    public void renameCustomizationSpec(ManagedObjectReference _this, String name, String newName) throws java.rmi.RemoteException, NotFound, AlreadyExists, RuntimeFault {
        Argument[] paras = new Argument[3];
        paras[0] = new Argument("_this", "ManagedObjectReference", _this);
        paras[1] = new Argument("name", "String", name);
        paras[2] = new Argument("newName", "String", newName);
        getWsc().invoke("RenameCustomizationSpec", paras, null);
    }

    public String customizationSpecItemToXml(ManagedObjectReference _this, CustomizationSpecItem item) throws java.rmi.RemoteException, RuntimeFault {
        Argument[] paras = new Argument[2];
        paras[0] = new Argument("_this", "ManagedObjectReference", _this);
        paras[1] = new Argument("item", "CustomizationSpecItem", item);
        return (String) getWsc().invoke("CustomizationSpecItemToXml", paras, "String");
    }

    public CustomizationSpecItem xmlToCustomizationSpecItem(ManagedObjectReference _this, String specItemXml) throws java.rmi.RemoteException, CustomizationFault, RuntimeFault {
        Argument[] paras = new Argument[2];
        paras[0] = new Argument("_this", "ManagedObjectReference", _this);
        paras[1] = new Argument("specItemXml", "String", specItemXml);
        return (CustomizationSpecItem) getWsc().invoke("XmlToCustomizationSpecItem", paras, "CustomizationSpecItem");
    }

    public void checkCustomizationResources(ManagedObjectReference _this, String guestOs) throws java.rmi.RemoteException, CustomizationFault, RuntimeFault {
        Argument[] paras = new Argument[2];
        paras[0] = new Argument("_this", "ManagedObjectReference", _this);
        paras[1] = new Argument("guestOs", "String", guestOs);
        getWsc().invoke("CheckCustomizationResources", paras, null);
    }

    public HostConnectInfo queryConnectionInfo(ManagedObjectReference _this, String hostname, int port, String username, String password, String sslThumbprint) throws java.rmi.RemoteException, InvalidLogin, HostConnectFault, RuntimeFault {
        Argument[] paras = new Argument[6];
        paras[0] = new Argument("_this", "ManagedObjectReference", _this);
        paras[1] = new Argument("hostname", "String", hostname);
        paras[2] = new Argument("port", "int", port);
        paras[3] = new Argument("username", "String", username);
        paras[4] = new Argument("password", "String", password);
        paras[5] = new Argument("sslThumbprint", "String", sslThumbprint);
        return (HostConnectInfo) getWsc().invoke("QueryConnectionInfo", paras, "HostConnectInfo");
    }

    public ManagedObjectReference powerOnMultiVM_Task(ManagedObjectReference _this, ManagedObjectReference[] vm, OptionValue[] option) throws java.rmi.RemoteException, RuntimeFault {
        Argument[] paras = new Argument[3];
        paras[0] = new Argument("_this", "ManagedObjectReference", _this);
        paras[1] = new Argument("vm", "ManagedObjectReference[]", vm);
        paras[2] = new Argument("option", "OptionValue[]", option);
        return (ManagedObjectReference) getWsc().invoke("PowerOnMultiVM_Task", paras, "ManagedObjectReference");
    }

    public VirtualMachineConfigOptionDescriptor[] queryDatacenterConfigOptionDescriptor(ManagedObjectReference _this) throws java.rmi.RemoteException, RuntimeFault {
        Argument[] paras = new Argument[1];
        paras[0] = new Argument("_this", "ManagedObjectReference", _this);
        return (VirtualMachineConfigOptionDescriptor[]) getWsc().invoke("queryDatacenterConfigOptionDescriptor", paras, "VirtualMachineConfigOptionDescriptor[]");
    }

    public ManagedObjectReference reconfigureDatacenter_Task(ManagedObjectReference _this, DatacenterConfigSpec spec, boolean modify) throws java.rmi.RemoteException, RuntimeFault {
        Argument[] paras = new Argument[3];
        paras[0] = new Argument("_this", "ManagedObjectReference", _this);
        paras[1] = new Argument("spec", "DatacenterConfigSpec", spec);
        paras[2] = new Argument("modify", "boolean", modify);
        return (ManagedObjectReference) getWsc().invoke("ReconfigureDatacenter_Task", paras, "ManagedObjectReference");
    }

    public void refreshDatastore(ManagedObjectReference _this) throws java.rmi.RemoteException, NotFound, HostConfigFault, RuntimeFault {
        Argument[] paras = new Argument[1];
        paras[0] = new Argument("_this", "ManagedObjectReference", _this);
        getWsc().invoke("RefreshDatastore", paras, null);
    }

    public void refreshDatastoreStorageInfo(ManagedObjectReference _this) throws java.rmi.RemoteException, RuntimeFault {
        Argument[] paras = new Argument[1];
        paras[0] = new Argument("_this", "ManagedObjectReference", _this);
        getWsc().invoke("RefreshDatastoreStorageInfo", paras, null);
    }

    public ManagedObjectReference updateVirtualMachineFiles_Task(ManagedObjectReference _this, DatastoreMountPathDatastorePair[] mountPathDatastoreMapping) throws java.rmi.RemoteException, ResourceInUse, PlatformConfigFault, TaskInProgress, InvalidDatastore, RuntimeFault {
        Argument[] paras = new Argument[2];
        paras[0] = new Argument("_this", "ManagedObjectReference", _this);
        paras[1] = new Argument("mountPathDatastoreMapping", "DatastoreMountPathDatastorePair[]", mountPathDatastoreMapping);
        return (ManagedObjectReference) getWsc().invoke("UpdateVirtualMachineFiles_Task", paras, "ManagedObjectReference");
    }

    public void renameDatastore(ManagedObjectReference _this, String newName) throws java.rmi.RemoteException, DuplicateName, InvalidName, RuntimeFault {
        Argument[] paras = new Argument[2];
        paras[0] = new Argument("_this", "ManagedObjectReference", _this);
        paras[1] = new Argument("newName", "String", newName);
        getWsc().invoke("RenameDatastore", paras, null);
    }

    public void destroyDatastore(ManagedObjectReference _this) throws java.rmi.RemoteException, ResourceInUse, RuntimeFault {
        Argument[] paras = new Argument[1];
        paras[0] = new Argument("_this", "ManagedObjectReference", _this);
        getWsc().invoke("DestroyDatastore", paras, null);
    }

    public StoragePlacementResult datastoreEnterMaintenanceMode(ManagedObjectReference _this) throws java.rmi.RemoteException, InvalidState, RuntimeFault {
        Argument[] paras = new Argument[1];
        paras[0] = new Argument("_this", "ManagedObjectReference", _this);
        return (StoragePlacementResult) getWsc().invoke("DatastoreEnterMaintenanceMode", paras, "StoragePlacementResult");
    }

    public ManagedObjectReference datastoreExitMaintenanceMode_Task(ManagedObjectReference _this) throws java.rmi.RemoteException, InvalidState, RuntimeFault {
        Argument[] paras = new Argument[1];
        paras[0] = new Argument("_this", "ManagedObjectReference", _this);
        return (ManagedObjectReference) getWsc().invoke("DatastoreExitMaintenanceMode_Task", paras, "ManagedObjectReference");
    }

    public String createDirectory(ManagedObjectReference _this, ManagedObjectReference datastore, String displayName, String policy) throws java.rmi.RemoteException, CannotCreateFile, FileAlreadyExists, InvalidDatastore, RuntimeFault {
        Argument[] paras = new Argument[4];
        paras[0] = new Argument("_this", "ManagedObjectReference", _this);
        paras[1] = new Argument("datastore", "ManagedObjectReference", datastore);
