public function testStopModuleWithTransientError()
 {
     $req = new StopModuleRequest();
     $resp = new ApplicationError(ErrorCode::TRANSIENT_ERROR, 'invalid version');
     $req->setModule('module1');
     $req->setVersion('v1');
     $this->setExpectedException('\\google\\appengine\\api\\modules\\TransientModulesException');
     $this->apiProxyMock->expectCall('modules', 'StopModule', $req, $resp);
     ModulesService::stopVersion('module1', 'v1');
     $this->apiProxyMock->verify();
 }
Example #2
0
 /**
  * Stops all instances of the given version of a module.
  * *
  * @param string $module The name of the module to stop. If null then the
  * current module will be stopped.
  *
  * @param string $version The version of the module to stop. If null then the
  * current version will be stopped.
  *
  * @throws \InvalidArgumentException If $module or $version is not a string.
  * @throws ModulesException if the given combination of $module and $version
  * instance is invalid.
  * @throws InvalidModuleStateException if the given $version is already
  * stopped or cannot be stopped.
  * @throws TransientModulesException if there is an issue stopping the module
  * version.
  */
 public static function stopVersion($module = null, $version = null)
 {
     $req = new StopModuleRequest();
     $resp = new StopModuleResponse();
     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', 'StopModule', $req, $resp);
     } catch (ApplicationError $e) {
         throw self::errorCodeToException($e->getApplicationError());
     }
 }