code: void waitForAllDropletEventsToComplete(@Nonnull String instanceId, int timeout) throws InternalException, CloudException {
          APITrace.begin(getProvider(), "listVirtualMachineStatus");
          try {
              // allow maximum five minutes for events to complete
              long wait = System.currentTimeMillis() + timeout * 60 * 1000;
              boolean eventsPending = false;
              while( System.currentTimeMillis() < wait ) {
                  Actions actions = DigitalOceanModelFactory.getDropletEvents(getProvider(), instanceId);
                  for( Action action : actions.getActions() ) {
                      if( "in-progress".equalsIgnoreCase(action.getStatus()) ) {
                          eventsPending = true;
                      }
                  }
                  if( !eventsPending ) {
                      break;
                  }
                  try {
                      // must be careful here not to cause rate limits
                      Thread.sleep(30000);
                  }
                  catch( InterruptedException e ) {
                      break;
                  }
              }
              // if events are still pending the cloud will fail the next operation anyway
          }
          finally {
              APITrace.end();
          }
      }
docs: Wait for specified number of minutes for all pending droplet events to complete
  @param instanceId Id of the droplet
  @param timeout Time in minutes to wait for events to complete
  @throws InternalException
  @throws CloudException