Skip to content
65 changes: 65 additions & 0 deletions src/Storage/Device/Exoscale.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
<?php

namespace Utopia\Storage\Device;

use Utopia\Storage\Storage;

class Exoscale extends S3
{
//https://community.exoscale.com/documentation/platform/exoscale-datacenter-zones/
/**
* Exoscale Regions constants
*/
const CH_GVA_2 = 'ch-gva-2';
const CH_DK_2 = 'ch-dk-2';
const DE_FRA_1 = 'de-fra-1';
const DE_MUC_1 = 'de-muc-1';
const AT_VIE_1 = 'at-vie-1';
const AT_VIE_2 = 'at-vie-2';
const BG_SOF_1 = 'bg-sof-1';

/**
* Exoscale Constructor
*
* @param string $root
* @param string $apiKey
* @param string $apiSecret
* @param string $bucket
* @param string $region
* @param string $acl
*/
public function __construct(string $root, string $apiKey, string $apiSecret, string $bucket, string $region = self::CH_GVA_2, string $acl = self::ACL_PRIVATE)
{
parent::__construct($root, $apiKey, $apiSecret, $bucket, $region, $acl);

if (isset($this->regionEndpointMap[$region])) {
$this->headers['host'] = $this->regionEndpointMap[$region];
} else {
throw new \InvalidArgumentException('Invalid or unsupported region');
}
}

/**
* @return string
*/
public function getName(): string
{
return 'Exoscale Storage';
}

/**
* @return string
*/
public function getDescription(): string
{
return 'Exoscale Storage';
}

/**
* @return string
*/
public function getType(): string
{
return Storage::DEVICE_EXOSCALE;
}
}
2 changes: 2 additions & 0 deletions src/Storage/Storage.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ class Storage

const DEVICE_LINODE = 'linode';

const DEVICE_EXOSCALE = 'exoscale';

/**
* Devices.
*
Expand Down
36 changes: 36 additions & 0 deletions tests/Storage/Device/ExoscaleTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php

namespace Utopia\Tests\Storage\Device;

use Utopia\Storage\Device\Exoscale;
use Utopia\Tests\Storage\S3Base;

class ExoscaleTest extends S3Base
{
protected function init(): void
{
$this->root = '/root';
$apiKey = 'YOUR_EXOSCALE_API_KEY';
$apiSecret = 'YOUR_EXOSCALE_API_SECRET';
$bucket = 'YOUR_EXOSCALE_BUCKET';
$region = Exoscale::CH_GVA_2;
$acl = Exoscale::ACL_PRIVATE;

$this->object = new Exoscale($this->root, $apiKey, $apiSecret, $bucket, $region, $acl);
}

protected function getAdapterName(): string
{
return 'Exoscale Storage';
}

protected function getAdapterType(): string
{
return $this->object->getType();
}

protected function getAdapterDescription(): string
{
return 'Exoscale Storage';
}
}