コード例 #1
0
 public function parseResponseBody($body)
 {
     $response = parent::parseResponseBody($body);
     if (count($response) >= $this->getOption('limit.page')) {
         // Pop last element and save (we will need it for the next marker)
         $this->nextElement = array_pop($response);
     }
     return $response;
 }
コード例 #2
0
 public function parseResponseBody($body)
 {
     $parsed = parent::parseResponseBody($body);
     // Differentiate memory structure
     if (is_object($parsed) && isset($parsed->info->swap_free)) {
         $parsed->info = array($parsed->info);
     }
     return $parsed;
 }
コード例 #3
0
 /**
  * Get all the roles for which this user is associated with.
  *
  * @return \OpenCloud\Common\Collection\PaginatedIterator
  */
 public function getRoles()
 {
     $url = $this->getUrl();
     $url->addPath('roles');
     return PaginatedIterator::factory($this, array('baseUrl' => $url, 'resourceClass' => 'Role', 'key.collection' => 'roles', 'key.links' => 'roles_links'));
 }
コード例 #4
0
 /**
  * @mockFile Group_List
  * @mockPath Autoscale
  */
 public function test_Links()
 {
     $service = $this->getClient()->autoscaleService();
     $iterator = PaginatedIterator::factory($service, array('resourceClass' => 'Group', 'key.collection' => 'groups', 'key.links' => 'groups_links', 'baseUrl' => $service->getUrl('groups')));
     $iterator->populateAll();
     $this->assertInstanceOf('OpenCloud\\Autoscale\\Resource\\Group', $iterator->getElement(1));
 }
コード例 #5
0
ファイル: AbstractService.php プロジェクト: samj1912/repo
 /**
  * @codeCoverageIgnore
  */
 public function collection($class, $url = null, $parent = null, $data = null)
 {
     if (!$parent) {
         $parent = $this;
     }
     if (!$url) {
         $resource = $this->resolveResourceClass($class);
         $url = $parent->getUrl($resource::resourceName());
     }
     $options = $this->makeResourceIteratorOptions($this->resolveResourceClass($class));
     $options['baseUrl'] = $url;
     return PaginatedIterator::factory($parent, $options, $data);
 }
コード例 #6
0
ファイル: Service.php プロジェクト: santikrass/apache
 /**
  * Get all possible roles.
  *
  * @return \OpenCloud\Common\Collection\PaginatedIterator
  */
 public function getRoles()
 {
     return PaginatedIterator::factory($this, array('resourceClass' => 'Role', 'baseUrl' => $this->getUrl()->addPath('OS-KSADM')->addPath('roles'), 'key.marker' => 'id', 'key.collection' => 'roles'));
 }
コード例 #7
0
ファイル: Queue.php プロジェクト: enoch85/owncloud-testserver
 /**
  * This operation claims a set of messages, up to limit, from oldest to 
  * newest, skipping any that are already claimed. If no unclaimed messages 
  * are available, FALSE is returned.
  * 
  * You should delete the message when you have finished processing it, 
  * before the claim expires, to ensure the message is processed only once. 
  * Be aware that you must call the delete() method on the Message object and
  * pass in the Claim ID, rather than relying on the service's bulk delete 
  * deleteMessages() method. This is so that the server can return an error 
  * if the claim just expired, giving you a chance to roll back your processing 
  * of the given message, since another worker will likely claim the message 
  * and process it.
  * 
  * Just as with a message's age, the age given for the claim is relative to 
  * the server's clock, and is useful for determining how quickly messages are 
  * getting processed, and whether a given message's claim is about to expire.
  * 
  * When a claim expires, it is removed, allowing another client worker to 
  * claim the message in the case that the original worker fails to process it.
  * 
  * @param int $limit
  */
 public function claimMessages(array $options = array())
 {
     $limit = isset($options['limit']) ? $options['limit'] : Claim::LIMIT_DEFAULT;
     $grace = isset($options['grace']) ? $options['grace'] : Claim::GRACE_DEFAULT;
     $ttl = isset($options['ttl']) ? $options['ttl'] : Claim::TTL_DEFAULT;
     $json = json_encode((object) array('grace' => $grace, 'ttl' => $ttl));
     $url = $this->getUrl('claims', array('limit' => $limit));
     $response = $this->getClient()->post($url, self::getJsonHeader(), $json)->send();
     if ($response->getStatusCode() == 204) {
         return false;
     }
     $options = array('resourceClass' => 'Message', 'baseUrl' => $url);
     return PaginatedIterator::factory($this, $options, Formatter::decode($response));
 }