Wait until the flow completes.

    Args:
      timeout: timeout in seconds. None means default timeout (1 hour). 0 means
        no timeout (wait forever).

    Returns:
      Fresh flow object.
    Raises:
      PollTimeoutError: if timeout is reached.
      FlowFailedError: if the flow is not successful.

def WaitUntilDone(self, timeout=None):
    """Wait until the flow completes.

    Args:
      timeout: timeout in seconds. None means default timeout (1 hour). 0 means
        no timeout (wait forever).

    Returns:
      Fresh flow object.
    Raises:
      PollTimeoutError: if timeout is reached.
      FlowFailedError: if the flow is not successful.
    """

    f = utils.Poll(
        generator=self.Get,
        condition=lambda f: f.data.state != f.data.RUNNING,
        timeout=timeout)
    if f.data.state != f.data.TERMINATED:
      raise errors.FlowFailedError(
          "Flow %s (%s) failed: %s" %
          (self.flow_id, self.client_id, f.data.context.current_state))
    return f