public function testSetNumInstancesInvalidVersion()
 {
     $req = new SetNumInstancesRequest();
     $resp = new ApplicationError(ErrorCode::INVALID_VERSION, 'invalid version');
     $req->setInstances(3);
     $this->setExpectedException('\\google\\appengine\\api\\modules\\ModulesException');
     $this->apiProxyMock->expectCall('modules', 'SetNumInstances', $req, $resp);
     ModulesService::setNumInstances(3);
     $this->apiProxyMock->verify();
 }
Ejemplo n.º 2
0
 /**
  * Set the number of instances for a version of a module.
  *
  * This function does not work on automatically-scaled modules.
  *
  * @param string $module The name of the module to set the instance count for.
  * If null then the instance count for the current module will be set.
  *
  * @param string $version The version of the module to set the instance count
  * for. If null then the count for the version of the current instance will
  * be set.
  *
  * @throws \InvalidArgumentException If $instances is not an integer or if
  * $module or $version is not a string.
  * @throws ModulesException if the given combination of $module and $version
  * is invalid.
  * @throws TransientModulesException if there is an issue setting the
  * instance count.
  */
 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());
     }
 }