Permalink
Browse files

Add listPageBlobRanges wrapper

  • Loading branch information...
1 parent ee0a3a7 commit ed0551854fb6b250c9f8f4f4d00660a2b71fc9b1 Abdelrahman Elogeel committed Mar 21, 2012
@@ -116,6 +116,7 @@ class Resources
const QP_TIMEOUT = 'timeout';
const QP_DELIMITER = 'Delimiter';
const QP_REST_TYPE = 'restype';
+ const QP_SNAPSHOT = 'snapshot';
// Request body content types
const XML_CONTENT_TYPE = 'application/x-www-form-urlencoded';
@@ -58,6 +58,8 @@
use PEAR2\WindowsAzure\Services\Blob\Models\CreateBlobPagesOptions;
use PEAR2\WindowsAzure\Services\Blob\Models\CreateBlobPagesResult;
use PEAR2\WindowsAzure\Services\Blob\Models\PageWriteOption;
+use PEAR2\WindowsAzure\Services\Blob\Models\ListPageBlobRangesOptions;
+use PEAR2\WindowsAzure\Services\Blob\Models\ListPageBlobRangesResult;
/**
* This class constructs HTTP requests and receive HTTP responses for blob
@@ -898,9 +900,9 @@ public function getBlobProperties($container, $blob, $options = null)
$headers, $options->getAccessCondition()
);
- $headers[Resources::X_MS_LEASE_ID] = $options->getLeaseId();
- $queryParams['snapshot'] = $options->getSnapshot();
- $queryParams[Resources::QP_TIMEOUT] = strval($options->getTimeout());
+ $headers[Resources::X_MS_LEASE_ID] = $options->getLeaseId();
+ $queryParams[Resources::QP_SNAPSHOT] = $options->getSnapshot();
+ $queryParams[Resources::QP_TIMEOUT] = strval($options->getTimeout());
$response = $this->send($method, $headers, $queryParams, $path, $statusCode);
@@ -934,10 +936,10 @@ public function getBlobMetadata($container, $blob, $options = null)
$headers, $options->getAccessCondition()
);
- $headers[Resources::X_MS_LEASE_ID] = $options->getLeaseId();
- $queryParams['snapshot'] = $options->getSnapshot();
- $queryParams[Resources::QP_TIMEOUT] = strval($options->getTimeout());
- $queryParams[Resources::QP_COMP] = 'metadata';
+ $headers[Resources::X_MS_LEASE_ID] = $options->getLeaseId();
+ $queryParams[Resources::QP_SNAPSHOT] = $options->getSnapshot();
+ $queryParams[Resources::QP_TIMEOUT] = strval($options->getTimeout());
+ $queryParams[Resources::QP_COMP] = 'metadata';
$response = $this->send($method, $headers, $queryParams, $path, $statusCode);
@@ -948,17 +950,43 @@ public function getBlobMetadata($container, $blob, $options = null)
* 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\ListBlobRangesOptions $options optional parameters
+ * @param string $container name of the container
+ * @param string $blob name of the blob
+ * @param Models\ListPageBlobRangesOptions $options optional parameters
*
- * @return Models\ListBlobRangesResult
+ * @return Models\ListPageBlobRangesResult
*
* @see http://msdn.microsoft.com/en-us/library/windowsazure/ee691973.aspx
*/
public function listPageBlobRanges($container, $blob, $options = null)
{
- throw new \Exception(Resources::NOT_IMPLEMENTED_MSG);
+ $method = \HTTP_Request2::METHOD_GET;
+ $headers = array();
+ $queryParams = array();
+ $path = $container . '/' . $blob;
+ $statusCode = Resources::STATUS_OK;
+
+ if (is_null($options)) {
+ $options = new ListPageBlobRangesOptions();
+ }
+
+ $headers = $this->addOptionalAccessContitionHeader(
+ $headers, $options->getAccessCondition()
+ );
+
+ $headers = $this->_addOptionalRangeHeader(
+ $headers, $options->getRangeStart(), $options->getRangeEnd()
+ );
+
+ $headers[Resources::X_MS_LEASE_ID] = $options->getLeaseId();
+ $queryParams[Resources::QP_SNAPSHOT] = $options->getSnapshot();
+ $queryParams[Resources::QP_TIMEOUT] = strval($options->getTimeout());
+ $queryParams[Resources::QP_COMP] = 'pagelist';
+
+ $response = $this->send($method, $headers, $queryParams, $path, $statusCode);
+ $parsed = Utilities::unserialize($response->getBody());
+
+ return ListPageBlobRangesResult::create($response->getHeader(), $parsed);
}
/**
@@ -1088,8 +1116,8 @@ public function getBlob($container, $blob, $options = null)
$headers[Resources::X_MS_RANGE_GET_CONTENT_MD5] = $getMD5 ? 'true' : null;
$headers[Resources::X_MS_LEASE_ID] = $options->getLeaseId();
- $queryParams['snapshot'] = $options->getSnapshot();
- $queryParams[Resources::QP_TIMEOUT] = strval($options->getTimeout());
+ $queryParams[Resources::QP_SNAPSHOT] = $options->getSnapshot();
+ $queryParams[Resources::QP_TIMEOUT] = strval($options->getTimeout());
$response = $this->send($method, $headers, $queryParams, $path, $statusCode);
@@ -1127,8 +1155,8 @@ public function deleteBlob($container, $blob, $options = null)
$headers[Resources::X_MS_LEASE_ID] = $options->getLeaseId();
$headers[Resources::X_MS_DELETE_SNAPSHOTS] = $deleteSnapshots;
- $queryParams['snapshot'] = $options->getSnapshot();
- $queryParams[Resources::QP_TIMEOUT] = strval($options->getTimeout());
+ $queryParams[Resources::QP_SNAPSHOT] = $options->getSnapshot();
+ $queryParams[Resources::QP_TIMEOUT] = strval($options->getTimeout());
$this->send($method, $headers, $queryParams, $path, $statusCode);
}
@@ -342,11 +342,11 @@ public function getBlobMetadata($container, $blob, $options = null);
* 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\ListBlobRangesOptions $options optional parameters
+ * @param string $container name of the container
+ * @param string $blob name of the blob
+ * @param Models\ListPageBlobRangesOptions $options optional parameters
*
- * @return Models\ListBlobRangesResult
+ * @return Models\ListPageBlobRangesResult
*
* @see http://msdn.microsoft.com/en-us/library/windowsazure/ee691973.aspx
*/
@@ -0,0 +1,179 @@
+<?php
+
+/**
+ * LICENSE: Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * PHP version 5
+ *
+ * @category Microsoft
+ * @package PEAR2\WindowsAzure\Services\Blob\Models
+ * @author Abdelrahman Elogeel <Abdelrahman.Elogeel@microsoft.com>
+ * @copyright 2012 Microsoft Corporation
+ * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License 2.0
+ * @link http://pear.php.net/package/azure-sdk-for-php
+ */
+
+namespace PEAR2\WindowsAzure\Services\Blob\Models;
+use PEAR2\WindowsAzure\Validate;
+
+/**
+ * Optional parameters for listPageBlobRanges wrapper
+ *
+ * @category Microsoft
+ * @package PEAR2\WindowsAzure\Services\Blob\Models
+ * @author Abdelrahman Elogeel <Abdelrahman.Elogeel@microsoft.com>
+ * @copyright 2012 Microsoft Corporation
+ * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License 2.0
+ * @version Release: @package_version@
+ * @link http://pear.php.net/package/azure-sdk-for-php
+ */
+class ListPageBlobRangesOptions extends BlobServiceOptions
+{
+ /**
+ * @var string
+ */
+ private $_leaseId;
+
+ /**
+ * @var string
+ */
+ private $_snapshot;
+
+ /**
+ * @var integer
+ */
+ private $_rangeStart;
+
+ /**
+ * @var integer
+ */
+ private $_rangeEnd;
+
+ /**
+ * @var AccessCondition
+ */
+ private $_accessCondition;
+
+ /**
+ * Gets lease Id for the blob
+ *
+ * @return string
+ */
+ public function getLeaseId()
+ {
+ return $this->_leaseId;
+ }
+
+ /**
+ * Sets lease Id for the blob
+ *
+ * @param string $leaseId the blob lease id.
+ *
+ * @return none
+ */
+ public function setLeaseId($leaseId)
+ {
+ $this->_leaseId = $leaseId;
+ }
+
+ /**
+ * Gets blob snapshot.
+ *
+ * @return string.
+ */
+ public function getSnapshot()
+ {
+ return $this->_snapshot;
+ }
+
+ /**
+ * Sets blob snapshot.
+ *
+ * @param string $snapshot value.
+ *
+ * @return none.
+ */
+ public function setSnapshot($snapshot)
+ {
+ $this->_snapshot = $snapshot;
+ }
+
+ /**
+ * Gets rangeStart
+ *
+ * @return integer
+ */
+ public function getRangeStart()
+ {
+ return $this->_rangeStart;
+ }
+
+ /**
+ * Sets rangeStart
+ *
+ * @param integer $rangeStart the blob lease id.
+ *
+ * @return none
+ */
+ public function setRangeStart($rangeStart)
+ {
+ Validate::isInteger($rangeStart);
+ $this->_rangeStart = $rangeStart;
+ }
+
+ /**
+ * Gets rangeEnd
+ *
+ * @return integer
+ */
+ public function getRangeEnd()
+ {
+ return $this->_rangeEnd;
+ }
+
+ /**
+ * Sets rangeEnd
+ *
+ * @param integer $rangeEnd range end value in bytes
+ *
+ * @return none
+ */
+ public function setRangeEnd($rangeEnd)
+ {
+ Validate::isInteger($rangeEnd);
+ $this->_rangeEnd = $rangeEnd;
+ }
+
+ /**
+ * Gets access condition
+ *
+ * @return AccessCondition
+ */
+ public function getAccessCondition()
+ {
+ return $this->_accessCondition;
+ }
+
+ /**
+ * Sets access condition
+ *
+ * @param AccessCondition $accessCondition value to use.
+ *
+ * @return none.
+ */
+ public function setAccessCondition($accessCondition)
+ {
+ $this->_accessCondition = $accessCondition;
+ }
+}
+
+?>
Oops, something went wrong.

0 comments on commit ed05518

Please sign in to comment.