com.vmware.vcloud.sdk
Class Task

java.lang.Object
  extended by com.vmware.vcloud.sdk.VcloudResource<T>
      extended by com.vmware.vcloud.sdk.VcloudEntity<com.vmware.vcloud.api.rest.schema.TaskType>
          extended by com.vmware.vcloud.sdk.Task

public class Task
extends VcloudEntity<com.vmware.vcloud.api.rest.schema.TaskType>

Helper class to access the Task Resource in vCloud API.

See Also:
TaskType

Constructor Summary
Task(VcloudClient client, com.vmware.vcloud.api.rest.schema.TaskType taskResource_v1_5)
          Constructor to create the Task.
 
Method Summary
 void cancelTask()
          Canceling a task.
static void cancelTask(VcloudClient client, com.vmware.vcloud.api.rest.schema.ReferenceType taskReference)
          Canceling a task.
 com.vmware.vcloud.api.rest.schema.ReferenceType getBlockingTaskReference()
          Returns the blocking task reference.
 com.vmware.vcloud.api.rest.schema.ReferenceType getOrgReference()
          Returns the Organization reference on which the task was started
static com.vmware.vcloud.api.rest.schema.ReferenceType getOrgReference(VcloudClient client, com.vmware.vcloud.api.rest.schema.ReferenceType taskReference)
          Returns the Organization reference on which the task was started
 Integer getProgress()
          Returns the progress of the task.
static Integer getProgress(VcloudClient client, com.vmware.vcloud.api.rest.schema.ReferenceType taskReference)
          Returns the progress of the task.
static Task getTaskById(VcloudClient client, String vCloudId)
          Get Task helper using the vCloud ID
static Task getTaskByReference(VcloudClient client, com.vmware.vcloud.api.rest.schema.ReferenceType taskRef)
          Returns Task helper for the given Task Ref.
 com.vmware.vcloud.api.rest.schema.ReferenceType getUserReference()
          Returns the user reference (who initiates the task)
static com.vmware.vcloud.api.rest.schema.ReferenceType getUserReference(VcloudClient client, com.vmware.vcloud.api.rest.schema.ReferenceType taskReference)
          Returns the user reference who initiated the task
 Boolean isBlockingTask()
          Returns true if the task is a blocking task request.
 Task updateTask(com.vmware.vcloud.api.rest.schema.TaskType taskType)
          Updating the Custom Task.
 void waitForTask(long timeout)
          Waits for the current task to be completed.
 void waitForTask(long timeout, long period)
          Waits for the current task to be completed.
static void waitForTask(VcloudClient client, com.vmware.vcloud.api.rest.schema.ReferenceType taskRef, long timeout)
          Waits for the current task to be completed.
static void waitForTask(VcloudClient client, com.vmware.vcloud.api.rest.schema.ReferenceType taskRef, long timeout, long period)
          Waits for the current task to be completed.
 
Methods inherited from class com.vmware.vcloud.sdk.VcloudEntity
getMetadata, getReference, getTasks
 
Methods inherited from class com.vmware.vcloud.sdk.VcloudResource
getResource
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Task

public Task(VcloudClient client,
            com.vmware.vcloud.api.rest.schema.TaskType taskResource_v1_5)
Constructor to create the Task. The Task object will be returned as a result of vApp operations (e.g. clonevApp, powerOff, ...) and any such long running asynchronous operation.

Parameters:
client - The VcloudClient used to communicate with the vCloud
Method Detail

isBlockingTask

public Boolean isBlockingTask()
Returns true if the task is a blocking task request. This blocking task request can be aborted, resumed or failed using the BlockingTask

Returns:
Boolean
Since:
API 1.5, SDK 1.5

getBlockingTaskReference

public com.vmware.vcloud.api.rest.schema.ReferenceType getBlockingTaskReference()
                                                                         throws VCloudException
Returns the blocking task reference. The BlockingTask can be used to resume, abort or fail the blocking task.

Returns:
ReferenceType
Throws:
VCloudException
Since:
API 1.5, SDK 1.5

getTaskByReference

public static Task getTaskByReference(VcloudClient client,
                                      com.vmware.vcloud.api.rest.schema.ReferenceType taskRef)
                               throws VCloudException
Returns Task helper for the given Task Ref.

Parameters:
client - vCloud API client VcloudClient
taskRef - Task Ref ReferenceType
Returns:
Task helper Task
Throws:
VCloudException

getUserReference

public com.vmware.vcloud.api.rest.schema.ReferenceType getUserReference()
Returns the user reference (who initiates the task)

Returns:
ReferenceType
Since:
API 1.5, SDK 1.5

getUserReference

public static com.vmware.vcloud.api.rest.schema.ReferenceType getUserReference(VcloudClient client,
                                                                               com.vmware.vcloud.api.rest.schema.ReferenceType taskReference)
                                                                        throws VCloudException
Returns the user reference who initiated the task

Parameters:
client - VcloudClient
taskReference - task reference
Returns:
ReferenceType
Throws:
VCloudException
Since:
API 1.5, SDK 1.5

getOrgReference

public com.vmware.vcloud.api.rest.schema.ReferenceType getOrgReference()
Returns the Organization reference on which the task was started

Returns:
ReferenceType
Since:
API 1.5, SDK 1.5

getOrgReference

public static com.vmware.vcloud.api.rest.schema.ReferenceType getOrgReference(VcloudClient client,
                                                                              com.vmware.vcloud.api.rest.schema.ReferenceType taskReference)
                                                                       throws VCloudException
Returns the Organization reference on which the task was started

Parameters:
client - VcloudClient
taskReference - task reference
Returns:
ReferenceType
Throws:
VCloudException
Since:
API 1.5, SDK 1.5

getProgress

public Integer getProgress()
Returns the progress of the task.

Returns:
Integer
Since:
API 1.5, SDK 1.5

getProgress

public static Integer getProgress(VcloudClient client,
                                  com.vmware.vcloud.api.rest.schema.ReferenceType taskReference)
                           throws VCloudException
Returns the progress of the task.

Parameters:
client - VcloudClient
taskReference - task reference
Returns:
Integer
Throws:
VCloudException
Since:
API 1.5, SDK 1.5

cancelTask

public void cancelTask()
                throws VCloudException
Canceling a task. Only running tasks could be canceled.

Throws:
VCloudException
Since:
API 1.5, SDK 1.5

cancelTask

public static void cancelTask(VcloudClient client,
                              com.vmware.vcloud.api.rest.schema.ReferenceType taskReference)
                       throws VCloudException
Canceling a task. Only running tasks could be canceled.

Parameters:
client - VcloudClient
taskReference - task reference
Throws:
VCloudException
Since:
API 1.5, SDK 1.5

waitForTask

public void waitForTask(long timeout)
                 throws VCloudException,
                        TimeoutException
Waits for the current task to be completed. This method checks/polls until which ever happens first. 1. Waits until the timeout happens. 2. Waits until if the task status is success. 3. Waits and throws VCloudException if the task status is aborted, cancelled and errored.

Parameters:
timeout - timeout in milliseconds until which this method checks/polls for the task status. If the timeout is set to <=0, timeout is infinite.
Throws:
VCloudException
TimeoutException
Since:
API 1.5, SDK 1.5

waitForTask

public static void waitForTask(VcloudClient client,
                               com.vmware.vcloud.api.rest.schema.ReferenceType taskRef,
                               long timeout)
                        throws VCloudException,
                               TimeoutException
Waits for the current task to be completed. This method checks/polls until which ever happens first. 1. Waits until the timeout happens. 2. Waits until if the task status is success. 3. Waits and throws VCloudException if the task status is aborted, cancelled and errored.

Parameters:
client - VcloudClient
taskRef - ReferenceType
timeout - timeout in milliseconds until which this method checks/polls for the task status. If the timeout is set to <=0, timeout is infinite.
Throws:
VCloudException
TimeoutException
Since:
API 1.5, SDK 1.5

waitForTask

public void waitForTask(long timeout,
                        long period)
                 throws VCloudException,
                        TimeoutException
Waits for the current task to be completed. This method checks/polls until which ever happens first. 1. Waits until the timeout happens. 2. Waits until if the task status is success. 3. Waits and throws VCloudException if the task status is aborted, cancelled and errored.

Parameters:
timeout - timeout in milliseconds until which this method checks/polls for the task status. If the timeout is set to <=0, timeout is infinite.
period - Subsequent wait for task checks take place at approximately regular intervals separated by the specified period. This reduces the number of API calls for checking the task status.
Throws:
VCloudException
TimeoutException
Since:
API 1.5, SDK 1.5

waitForTask

public static void waitForTask(VcloudClient client,
                               com.vmware.vcloud.api.rest.schema.ReferenceType taskRef,
                               long timeout,
                               long period)
                        throws VCloudException,
                               TimeoutException
Waits for the current task to be completed. This method checks/polls until which ever happens first. 1. Waits until the timeout happens. 2. Waits until if the task status is success. 3. Waits and throws VCloudException if the task status is aborted, cancelled and errored.

Parameters:
client - VcloudClient
taskRef - ReferenceType
timeout - timeout in milliseconds until which this method checks/polls for the task status. If the timeout is set to <=0, timeout is infinite.
period - Subsequent wait for task checks take place at approximately regular intervals separated by the specified period. This reduces the number of API calls for checking the task status.
Throws:
VCloudException
TimeoutException
Since:
API 1.5, SDK 1.5

getTaskById

public static Task getTaskById(VcloudClient client,
                               String vCloudId)
                        throws VCloudException
Get Task helper using the vCloud ID

Parameters:
client - VcloudClient
vCloudId - format - The vCloud ID is of the form: "urn:vcloud:type:uuid". For example: "urn:vcloud:media:d9d976ba-e0ec-4682-a67d-380af49b54e1". String
Returns:
AdminVdc
Throws:
VCloudException
Since:
API 1.5, SDK 1.5

updateTask

public Task updateTask(com.vmware.vcloud.api.rest.schema.TaskType taskType)
                throws VCloudException
Updating the Custom Task.

Parameters:
taskType - TaskType
Returns:
Task
Throws:
VCloudException
Since:
API 5.1, SDK 5.1


Copyright © 2016. All Rights Reserved.