/**
  * @covers MicrosoftAzure\Storage\Blob\BlobRestProxy::listBlobs
  */
 private function listBlobsWorker($container, $options)
 {
     $finished = false;
     while (!$finished) {
         try {
             $ret = is_null($options) ? $this->restProxy->listBlobs($container) : $this->restProxy->listBlobs($container, $options);
             if (is_null($options)) {
                 $options = new ListBlobsOptions();
             }
             if (!is_null($options->getTimeout()) && $options->getTimeout() < 1) {
                 $this->assertTrue(false, 'Expect negative timeouts in $options to throw');
             }
             $this->verifyListBlobsWorker($ret, $options);
             if (strlen($ret->getNextMarker()) == 0) {
                 $finished = true;
             } else {
                 $options->setMarker($ret->getNextMarker());
             }
         } catch (ServiceException $e) {
             $finished = true;
             if (is_null($options->getTimeout()) || $options->getTimeout() >= 1) {
                 throw $e;
             } else {
                 $this->assertEquals(TestResources::STATUS_INTERNAL_SERVER_ERROR, $e->getCode(), 'getCode');
             }
         }
     }
 }
Ejemplo n.º 2
0
 /**
  * Lists all of the blobs in the given container.
  * 
  * @param string                  $container The container name.
  * @param Models\ListBlobsOptions $options   The optional parameters.
  * 
  * @return Models\ListBlobsResult
  * 
  * @see http://msdn.microsoft.com/en-us/library/windowsazure/dd135734.aspx
  */
 public function listBlobs($container, $options = null)
 {
     Validate::isString($container, 'container');
     $method = Resources::HTTP_GET;
     $headers = array();
     $postParams = array();
     $queryParams = array();
     $path = $container;
     $statusCode = Resources::STATUS_OK;
     if (is_null($options)) {
         $options = new ListBlobsOptions();
     }
     $this->addOptionalQueryParam($queryParams, Resources::QP_TIMEOUT, $options->getTimeout());
     $this->addOptionalQueryParam($queryParams, Resources::QP_REST_TYPE, 'container');
     $this->addOptionalQueryParam($queryParams, Resources::QP_COMP, 'list');
     $this->addOptionalQueryParam($queryParams, Resources::QP_PREFIX, str_replace('\\', '/', $options->getPrefix()));
     $this->addOptionalQueryParam($queryParams, Resources::QP_MARKER, $options->getMarker());
     $this->addOptionalQueryParam($queryParams, Resources::QP_DELIMITER, $options->getDelimiter());
     $this->addOptionalQueryParam($queryParams, Resources::QP_MAX_RESULTS, $options->getMaxResults());
     $includeMetadata = $options->getIncludeMetadata();
     $includeSnapshots = $options->getIncludeSnapshots();
     $includeUncommittedBlobs = $options->getIncludeUncommittedBlobs();
     $includeValue = $this->groupQueryValues(array($includeMetadata ? 'metadata' : null, $includeSnapshots ? 'snapshots' : null, $includeUncommittedBlobs ? 'uncommittedblobs' : null));
     $this->addOptionalQueryParam($queryParams, Resources::QP_INCLUDE, $includeValue);
     $response = $this->send($method, $headers, $queryParams, $postParams, $path, $statusCode);
     $parsed = $this->dataSerializer->unserialize($response->getBody());
     return ListBlobsResult::create($parsed);
 }