Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 0 additions & 16 deletions lib/OpenCloud/ObjectStore/AbstractService.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,22 +29,6 @@ abstract class AbstractService extends CatalogService
const MAX_OBJECT_NAME_LEN = 1024;
const MAX_OBJECT_SIZE = 5102410241025;

/**
* List all available containers. If called by a CDN service, it returns CDN-enabled; if called by a regular
* service, normal containers are returned.
*
* @param array $filter
* @return Collection
*/
public function listContainers(array $filter = array())
{
$filter['format'] = 'json';

$class = ($this instanceof Service) ? 'Container' : 'CDNContainer';

return $this->resourceList($class, $this->getUrl(null, $filter), $this);
}

/**
* @return Resource\Account
*/
Expand Down
35 changes: 35 additions & 0 deletions lib/OpenCloud/ObjectStore/CDNService.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,46 @@

namespace OpenCloud\ObjectStore;

use OpenCloud\ObjectStore\Resource\CDNContainer;
use OpenCloud\ObjectStore\Resource\ContainerMetadata;

/**
* This is the CDN version of the ObjectStore service.
*/
class CDNService extends AbstractService
{
const DEFAULT_NAME = 'cloudFilesCDN';
const DEFAULT_TYPE = 'rax:object-cdn';

/**
* List CDN-enabled containers.
*
* @param array $filter
* @return \OpenCloud\Common\Collection\PaginatedIterator
*/
public function listContainers(array $filter = array())
{
$filter['format'] = 'json';
return $this->resourceList('CDNContainer', $this->getUrl(null, $filter), $this);
}

public function cdnContainer($data)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this need to be public?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes because the iterator is an external class

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah okay. I remember now. Thanks.

{
$container = new CDNContainer($this, $data);

$metadata = new ContainerMetadata();
$metadata->setArray(array(
'Streaming-Uri' => $data->cdn_streaming_uri,
'Ios-Uri' => $data->cdn_ios_uri,
'Ssl-Uri' => $data->cdn_ssl_uri,
'Enabled' => $data->cdn_enabled,
'Ttl' => $data->ttl,
'Log-Retention' => $data->log_retention,
'Uri' => $data->cdn_uri,
));

$container->setMetadata($metadata);

return $container;
}
}
12 changes: 12 additions & 0 deletions lib/OpenCloud/ObjectStore/Service.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,18 @@ public function getCdnService()
return $this->cdnService;
}

/**
* List all available containers.
*
* @param array $filter
* @return \OpenCloud\Common\Collection\PaginatedIterator
*/
public function listContainers(array $filter = array())

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for refactoring this down. It was silly to have a base class with conditional logic depending on the type of the instance.

{
$filter['format'] = 'json';
return $this->resourceList('Container', $this->getUrl(null, $filter), $this);
}

/**
* @param $data
* @return Container
Expand Down