/** * Lists all of the containers in the given storage account. * * @param Models\ListContainersOptions $options The optional parameters. * * @return WindowsAzure\Blob\Models\ListContainersResult * * @see http://msdn.microsoft.com/en-us/library/windowsazure/dd179352.aspx */ public function listContainers($options = null) { $method = Resources::HTTP_GET; $headers = array(); $queryParams = array(); $postParams = array(); $path = Resources::EMPTY_STRING; $statusCode = Resources::STATUS_OK; if (is_null($options)) { $options = new ListContainersOptions(); } $this->addOptionalQueryParam($queryParams, Resources::QP_TIMEOUT, $options->getTimeout()); $this->addOptionalQueryParam($queryParams, Resources::QP_COMP, 'list'); $this->addOptionalQueryParam($queryParams, Resources::QP_PREFIX, $options->getPrefix()); $this->addOptionalQueryParam($queryParams, Resources::QP_MARKER, $options->getMarker()); $this->addOptionalQueryParam($queryParams, Resources::QP_MAX_RESULTS, $options->getMaxResults()); $isInclude = $options->getIncludeMetadata(); $isInclude = $isInclude ? 'metadata' : null; $this->addOptionalQueryParam($queryParams, Resources::QP_INCLUDE, $isInclude); $response = $this->send($method, $headers, $queryParams, $postParams, $path, $statusCode); $parsed = $this->dataSerializer->unserialize($response->getBody()); return ListContainersResult::create($parsed); }
/** * @covers WindowsAzure\Blob\BlobRestProxy::listContainers */ private function listContainersWorker($options) { $finished = false; while (!$finished) { try { $ret = is_null($options) ? $this->restProxy->listContainers() : $this->restProxy->listContainers($options); if (is_null($options)) { $options = new ListContainersOptions(); } if (!is_null($options->getTimeout()) && $options->getTimeout() < 1) { $this->assertTrue(false, 'Expect negative timeouts in $options to throw'); } $this->verifyListContainersWorker($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(500, $e->getCode(), 'getCode'); } } } }