LibCloud\Compute\Providers\Rackspace\RackspaceProvider::listImages PHP Method

listImages() public method

public listImages ( $nodeImageId = null )
    public function listImages($nodeImageId = null)
    {
        $images = array();
        if ($nodeImageId) {
            try {
                $images[] = $this->getService()->image($nodeImageId);
            } catch (ClientErrorResponseException $e) {
                if (404 !== $e->getResponse()->getStatusCode()) {
                    throw $e;
                }
            }
        } else {
            foreach ($this->getService()->imageList() as $image) {
                $images[] = $image;
            }
        }
        return array_map(array($this, 'toImage'), $images);
    }

Usage Example

 public function testListImagesWithId()
 {
     $this->addMockSubscriber($this->getTestFilePath('Image'));
     $expectedId = 'df27d481-63a5-40ca-8920-3d132ed643d9';
     $images = $this->provider->listImages($expectedId);
     $this->assertCount(1, $images, 'listImages returns an array with exactly one item');
     $this->assertSame($expectedId, $images[0]->getId(), 'The NodeImage ID matches the ID that was requested');
 }