9.3 Edit a Personal Template

By using the Aruba WsEndUser method UpdatePersonalTemplate it is possible to update the attributes of the created personal template:

• TemplateDescription string
• TemplateExtendedDescription opzionale
• OSVersion string opzionale
• OSFamilyID int
• ApplianceTypeID int opzionale
• Revision string
• username
• password
• TemplateBounds

Parameters
UpdatePersonalTemplate
Type: UpdatePersonalTemplate
UpdatePersonalTemplate type item which contains all the information required to edit the template.
Returns
The method returns a WsResult item containing information on the result of the call to the method.
//BaseWsEndUser.SetUpdatePersonalTemplate Method (c# .NET) 
private static void SetUpdatePersonalTemplate(WsEndUserClient client)
{
    try
    {
        //create a new item called updateTemplate,
        //UpdatePersonalTemplate class
        UpdatePersonalTemplate updateTemplate = new UpdatePersonalTemplate()
        {
            TemplateDescription = "Personal template",
            TemplateExtendedDescription = "Extended Description",
            OSVersion = "Windows server 2008",
            OSFamilyID = 1,
            ApplianceTypeID = 1,
            Revision = "1.0",
            TemplateUsername = "username",
            TemplatePassword = "password",
            TemplateBounds = new List<TemplateBound>(){
                new TemplateBound(){
                    TemplateBoundID = 1,
                    ResourceType = ResourceTypes.Cpu,
                    DefaultValue = 1,
                    MinValue = 1,
                    MaxValue = 4
                },
                new TemplateBound(){
                    TemplateBoundID = 1,
                    ResourceType = ResourceTypes.Ram,
                    DefaultValue = 2,
                    MinValue = 1,
                    MaxValue = 6
                }
            }.ToArray(),
            Icon = File.ReadAllBytes("C:\\temp\\icon.jpg")
        };

        //call method SetUpdatePersonalTemplate,
        //obtaining a WsResult item
        WsResult result = client.SetUpdatePersonalTemplate(updateTemplate);

        //if the call is not successful, re-run the error indicating the message
        if (!result.Success)
        {
            throw new ApplicationException(result.ResultMessage);
        }
    }
    catch (Exception ex)
    {
        //re-run the generic error
        Console.WriteLine(ex.Message);
    }
}
//BaseWsEndUser.setUpdatePersonalTemplate Method (JAVA) 
private static void setUpdatePersonalTemplate(IWsEndUser client)
{
    try
    {
        //create a new item called updateTemplate,
        //UpdatePersonalTemplate class
        UpdatePersonalTemplate updateTemplate = new UpdatePersonalTemplate();
        updateTemplate.setTemplateDescription("Personal template");
        updateTemplate.setTemplateExtendedDescription(
            "Extended Description");
        updateTemplate.setOSVersion("Windows server 2008");
        updateTemplate.setOSFamilyID(1);
        updateTemplate.setApplianceTypeID(1);
        updateTemplate.setRevision("1.0");
        updateTemplate.setTemplateUsername("username");
        updateTemplate.setTemplatePassword("password");
        
        File f = new File("C:\\temp\\icon.jpg");
        byte[] data = new byte[(int)f.length()];
        InputStream inStream = new FileInputStream(f);
        inStream.read(data);
        inStream.close();
        updateTemplate.setIcon(data);
      
        ArrayOfTemplateBound templateBound = new ArrayOfTemplateBound();
        TemplateBound template1 = new TemplateBound();
        template1.setTemplateBoundID(1);
        template1.setResourceType(ResourceTypes.CPU);
        template1.setDefaultValue(1);
        template1.setMinValue(1);
        template1.setMaxValue(4);
        templateBound.getTemplateBound().add(template1);
        TemplateBound template2 = new TemplateBound();
        template2.setTemplateBoundID(1);
        template2.setResourceType(ResourceTypes.RAM);
        template2.setDefaultValue(2);
        template2.setMinValue(1);
        template2.setMaxValue(6);
        templateBound.getTemplateBound().add(template2);
        updateTemplate.setTemplateBounds(templateBound);

        //call method setUpdatePersonalTemplate,
        //obtaining a WsResult item
        WsResult result = client.setUpdatePersonalTemplate(updateTemplate);

        //if the call is not successful, re-run the error indicating the message
        if (!result.isSuccess())
        {
            throw new Exception(result.getResultMessage());
        }
    }
    catch (Exception ex)
    {
        //generic exception
        System.out.println(ex);
    }
}
Version
API: v2.8 URL: https://api.dc1.computing.cloud.it/WsEndUser/v2.8/WsEndUser.svc?wsdl
See also