/**
  * Creates BlobProperties object from $parsed response in array representation
  * 
  * @param array $headers HTTP response headers
  * @param array $parsed  parsed response in array format.
  * 
  * @return ListPageBlobRangesResult
  */
 public static function create($headers, $parsed)
 {
     $result = new ListPageBlobRangesResult();
     $headers = array_change_key_case($headers);
     $date = $headers[Resources::LAST_MODIFIED];
     $date = Utilities::rfc1123ToDateTime($date);
     $blobLength = intval($headers[Resources::X_MS_BLOB_CONTENT_LENGTH]);
     $rawPageRanges = array();
     if (!empty($parsed['PageRange'])) {
         $parsed = array_change_key_case($parsed);
         $rawPageRanges = Utilities::getArray($parsed['pagerange']);
     }
     $result->_pageRanges = array();
     foreach ($rawPageRanges as $value) {
         $result->_pageRanges[] = new PageRange(intval($value['Start']), intval($value['End']));
     }
     $result->setContentLength($blobLength);
     $result->setEtag($headers[Resources::ETAG]);
     $result->setLastModified($date);
     return $result;
 }
 /**
  * @covers WindowsAzure\Blob\Models\ListPageBlobRangesResult::setPageRanges
  * @covers WindowsAzure\Blob\Models\ListPageBlobRangesResult::getPageRanges
  */
 public function testSetPageRanges()
 {
     // Setup
     $expected = array(0 => new PageRange(0, 10), 1 => new PageRange(20, 40));
     $result = new ListPageBlobRangesResult();
     // Test
     $result->setPageRanges($expected);
     // Assert
     $this->assertEquals($expected, $result->getPageRanges());
 }
Пример #3
0
 /**
  * Returns a list of active page ranges for a page blob. Active page ranges are 
  * those that have been populated with data.
  * 
  * @param string                           $container name of the container
  * @param string                           $blob      name of the blob
  * @param Models\ListPageBlobRangesOptions $options   optional parameters
  * 
  * @return Models\ListPageBlobRangesResult
  * 
  * @see http://msdn.microsoft.com/en-us/library/windowsazure/ee691973.aspx
  */
 public function listPageBlobRanges($container, $blob, $options = null)
 {
     Validate::isString($container, 'container');
     Validate::isString($blob, 'blob');
     Validate::notNullOrEmpty($blob, 'blob');
     $method = Resources::HTTP_GET;
     $headers = array();
     $queryParams = array();
     $postParams = array();
     $path = $this->_createPath($container, $blob);
     $statusCode = Resources::STATUS_OK;
     if (is_null($options)) {
         $options = new ListPageBlobRangesOptions();
     }
     $headers = $this->addOptionalAccessConditionHeader($headers, $options->getAccessCondition());
     $headers = $this->_addOptionalRangeHeader($headers, $options->getRangeStart(), $options->getRangeEnd());
     $this->addOptionalHeader($headers, Resources::X_MS_LEASE_ID, $options->getLeaseId());
     $this->addOptionalQueryParam($queryParams, Resources::QP_SNAPSHOT, $options->getSnapshot());
     $this->addOptionalQueryParam($queryParams, Resources::QP_TIMEOUT, $options->getTimeout());
     $this->addOptionalQueryParam($queryParams, Resources::QP_COMP, 'pagelist');
     $response = $this->send($method, $headers, $queryParams, $postParams, $path, $statusCode);
     $parsed = $this->dataSerializer->unserialize($response->getBody());
     return ListPageBlobRangesResult::create($response->getHeader(), $parsed);
 }