public static function setNumInstances($instances,
                                         $module = null,
                                         $version = null) {
    $req = new SetNumInstancesRequest();
    $resp = new SetNumInstancesResponse();

    if (!is_int($instances)) {
      throw new \InvalidArgumentException(
          '$instances must be an integer. Actual type: ' . gettype($instances));
    }
    $req->setInstances($instances);

    if ($module !== null) {
      if (!is_string($module)) {
        throw new \InvalidArgumentException(
            '$module must be a string. Actual type: ' . gettype($module));
      }
      $req->setModule($module);
    }

    if ($version !== null) {
      if (!is_string($version)) {
        throw new \InvalidArgumentException(
            '$version must be a string. Actual type: ' . gettype($version));
      }
      $req->setVersion($version);
    }

    try {
      ApiProxy::makeSyncCall('modules', 'SetNumInstances', $req, $resp);
    } catch (ApplicationError $e) {
      throw self::errorCodeToException($e->getApplicationError());
    }
  }