/**
  * @covers WindowsAzure\ServiceManagement\Models\AsynchronousOperationResult::setRequestId
  * @covers WindowsAzure\ServiceManagement\Models\AsynchronousOperationResult::getRequestId
  */
 public function testSetRequestId()
 {
     // Setup
     $expected = 'rsqasqoni12';
     $result = new AsynchronousOperationResult();
     // Test
     $result->setRequestId($expected);
     // Assert
     $this->assertEquals($expected, $result->getRequestId());
 }
 /**
  * Creates a new storage account in Windows Azure.
  * 
  * In the optional parameters either location or affinity group must be provided.
  * Because Create Storage Account is an asynchronous operation, it always returns
  * status code 202 (Accepted). To determine the status code for the operation 
  * once it is complete, call getOperationStatus API. The status code is embedded 
  * in the response for this operation; if successful, it will be 
  * status code 200 (OK).
  * 
  * @param string                             $name    The storage account name.
  * @param string                             $label   Name for the storage
  * account specified as a base64-encoded string. The name may be up to 100
  * characters in length. The name can be used identify the storage account for
  * your tracking purposes.
  * @param Models\CreateStorageServiceOptions $options The optional parameters.
  * 
  * @return Models\AsynchronousOperationResult
  * 
  * @see http://msdn.microsoft.com/en-us/library/windowsazure/hh264518.aspx 
  */
 public function createStorageService($name, $label, $options)
 {
     Validate::isString($name, 'name');
     Validate::notNullOrEmpty($name, 'name');
     Validate::isString($label, 'label');
     Validate::notNullOrEmpty($label, 'label');
     Validate::notNullOrEmpty($options, 'options');
     $affinityGroup = $options->getAffinityGroup();
     $location = $options->getLocation();
     Validate::isTrue(!empty($location) || !empty($affinityGroup), Resources::INVALID_CSA_OPT_MSG);
     $storageService = new StorageService();
     $storageService->setName($name);
     $storageService->setLabel($label);
     $storageService->setLocation($options->getLocation());
     $storageService->setAffinityGroup($options->getAffinityGroup());
     $storageService->setDescription($options->getDescription());
     $storageService->addSerializationProperty(XmlSerializer::ROOT_NAME, 'CreateStorageServiceInput');
     $context = new HttpCallContext();
     $context->setMethod(Resources::HTTP_POST);
     $context->setPath($this->_getStorageServicePath());
     $context->addStatusCode(Resources::STATUS_ACCEPTED);
     $context->setBody($storageService->serialize($this->dataSerializer));
     $context->addHeader(Resources::CONTENT_TYPE, Resources::XML_ATOM_CONTENT_TYPE);
     $response = $this->sendContext($context);
     return AsynchronousOperationResult::create($response->getHeader());
 }
Exemplo n.º 3
0
 /**
  * Cancels an in progress configuration change (update) or upgrade and returns
  * the deployment to its state before the upgrade or configuration change was
  * started.
  *
  * Note that you can rollback update or upgrade either by specifying the
  * deployment environment (staging or production), or by specifying the
  * deployment's unique name.
  *
  * @param string               $name    The hosted service name.
  * @param string               $mode    Specifies whether the rollback
  * should proceed automatically or not. Auto, The rollback proceeds without
  * further user input. Manual, You must call the walkUpgradeDomain API to apply
  * the rollback to each upgrade domain.
  * @param boolean              $force   Specifies whether the rollback
  * should proceed even when it will cause local data to be lost from some role
  * instances. True if the rollback should proceed; otherwise false if the
  * rollback should fail.
  * @param GetDeploymentOptions $options The optional parameters.
  *
  * @return none
  *
  * @see http://msdn.microsoft.com/en-us/library/windowsazure/hh403977.aspx
  */
 public function rollbackUpdateOrUpgrade($name, $mode, $force, $options)
 {
     Validate::isString($name, 'name');
     Validate::notNullOrEmpty($name, 'name');
     Validate::isString($mode, 'mode');
     Validate::isTrue(Mode::isValid($mode), Resources::INVALID_CHANGE_MODE_MSG);
     Validate::isBoolean($force, 'force');
     Validate::notNullOrEmpty($force, 'force');
     Validate::notNullOrEmpty($options, 'options');
     $xmlElements = array(Resources::XTAG_MODE => $mode, Resources::XTAG_FORCE => Utilities::booleanToString($force));
     $body = $this->_createRequestXml($xmlElements, Resources::XTAG_ROLLBACK_UPDATE_OR_UPGRADE);
     $context = new HttpCallContext();
     $context->setMethod(Resources::HTTP_POST);
     $context->setPath($this->_getDeploymentPath($name, $options) . '/');
     $context->addStatusCode(Resources::STATUS_ACCEPTED);
     $context->addQueryParameter(Resources::QP_COMP, Resources::QPV_ROLLBACK);
     $context->setBody($body);
     $context->addHeader(Resources::CONTENT_TYPE, Resources::XML_CONTENT_TYPE);
     assert(Utilities::endsWith($context->getPath(), '/'));
     $response = $this->sendContext($context);
     return AsynchronousOperationResult::create($response->getHeader());
 }