/**
  * Gets a rule. 
  *
  * @link http://msdn.microsoft.com/en-us/library/windowsazure/hh780772
  * 
  * @param string $topicPath        The path of the topic.
  * @param string $subscriptionName The name of the subscription.
  * @param string $ruleName         The name of the rule.
  *
  * @return RuleInfo
  */
 public function getRule($topicPath, $subscriptionName, $ruleName)
 {
     $httpCallContext = new HttpCallContext();
     $httpCallContext->setMethod(Resources::HTTP_GET);
     $httpCallContext->addStatusCode(Resources::STATUS_OK);
     $rulePath = sprintf(Resources::RULE_PATH, $topicPath, $subscriptionName, $ruleName);
     $httpCallContext->setPath($rulePath);
     $response = $this->sendContext($httpCallContext);
     $ruleInfo = new RuleInfo();
     $ruleInfo->parseXml($response->getBody());
     return $ruleInfo;
 }
 /**
  * Create task template HTTP call context
  *
  * @param WindowsAzure\MediaServices\Models\TaskTemplate $taskTemplate Task
  * template object to be created
  *
  * @return WindowsAzure\Common\Internal\Http\HttpCallContext
  */
 private function _getCreateTaskTemplateContext($taskTemplate)
 {
     Validate::isA($taskTemplate, 'WindowsAzure\\MediaServices\\Models\\TaskTemplate', 'taskTemplate');
     $result = new HttpCallContext();
     $result->setMethod(Resources::HTTP_POST);
     $result->setHeaders($this->_batchHeaders);
     $result->setUri($this->getUri());
     $result->setPath('/$1/TaskTemplates');
     $result->setBody($this->wrapAtomEntry($taskTemplate));
     $result->addStatusCode(Resources::STATUS_CREATED);
     return $result;
 }
 /**
  * Returns the status of the specified operation. After calling an asynchronous 
  * operation, you can call Get Operation Status to determine whether the 
  * operation has succeeded, failed, or is still in progress.
  * 
  * @param string $requestId The request ID for the request you wish to track.
  * 
  * @return Models\GetOperationStatusResult
  * 
  * @see http://msdn.microsoft.com/en-us/library/windowsazure/ee460783.aspx
  */
 public function getOperationStatus($requestId)
 {
     $context = new HttpCallContext();
     $context->setMethod(Resources::HTTP_GET);
     $context->setPath($this->_getOperationPath($requestId));
     $context->addStatusCode(Resources::STATUS_OK);
     $response = $this->sendContext($context);
     $serialized = $this->dataSerializer->unserialize($response->getBody());
     return GetOperationStatusResult::create($serialized);
 }
Exemplo n.º 4
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());
 }
 /**
  * Sends HTTP request with the specified parameters.
  * 
  * @param string $method         HTTP method used in the request
  * @param array  $headers        HTTP headers.
  * @param array  $queryParams    URL query parameters.
  * @param array  $postParameters The HTTP POST parameters.
  * @param string $path           URL path
  * @param int    $statusCode     Expected status code received in the response
  * @param string $body           Request body
  * 
  * @return \HTTP_Request2_Response
  */
 protected function send($method, $headers, $queryParams, $postParameters, $path, $statusCode, $body = Resources::EMPTY_STRING)
 {
     $context = new HttpCallContext();
     $context->setBody($body);
     $context->setHeaders($headers);
     $context->setMethod($method);
     $context->setPath($path);
     $context->setQueryParameters($queryParams);
     $context->setPostParameters($postParameters);
     if (is_array($statusCode)) {
         $context->setStatusCodes($statusCode);
     } else {
         $context->addStatusCode($statusCode);
     }
     return $this->sendContext($context);
 }
Exemplo n.º 6
0
 /**
  * Gets table entity.
  * 
  * @param string                     $table        The name of the table.
  * @param string                     $partitionKey The entity partition key.
  * @param string                     $rowKey       The entity row key.
  * @param Models\TableServiceOptions $options      The optional parameters.
  * 
  * @return Models\GetEntityResult
  * 
  * @see http://msdn.microsoft.com/en-us/library/windowsazure/dd179421.aspx
  */
 public function getEntity($table, $partitionKey, $rowKey, $options = null)
 {
     Validate::isString($table, 'table');
     Validate::notNullOrEmpty($table, 'table');
     Validate::isTrue(!is_null($partitionKey), Resources::NULL_TABLE_KEY_MSG);
     Validate::isTrue(!is_null($rowKey), Resources::NULL_TABLE_KEY_MSG);
     $method = Resources::HTTP_GET;
     $headers = array();
     $queryParams = array();
     $statusCode = Resources::STATUS_OK;
     $path = $this->_getEntityPath($table, $partitionKey, $rowKey);
     if (is_null($options)) {
         $options = new TableServiceOptions();
     }
     $this->addOptionalHeader($headers, Resources::CONTENT_TYPE, Resources::XML_ATOM_CONTENT_TYPE);
     $this->addOptionalQueryParam($queryParams, Resources::QP_TIMEOUT, $options->getTimeout());
     $context = new HttpCallContext();
     $context->setHeaders($headers);
     $context->setMethod($method);
     $context->setPath($path);
     $context->setQueryParameters($queryParams);
     $context->addStatusCode($statusCode);
     $response = $this->sendContext($context);
     $entity = $this->_atomSerializer->parseEntity($response->getBody());
     $result = new GetEntityResult();
     $result->setEntity($entity);
     return $result;
 }