diff --git a/src/Model/Catalog.php b/src/Model/Catalog.php new file mode 100644 index 0000000..f9c5ce6 --- /dev/null +++ b/src/Model/Catalog.php @@ -0,0 +1,37 @@ +data = $data; + } + + /** + * @inheritdoc + */ + public static function wrapCollection(array $data, $baseUrl, ClientInterface $client) + { + $data = isset($data['info']) ? $data['info'] : []; + + return parent::wrapCollection($data, $baseUrl, $client); + } +} diff --git a/src/Model/Subscription.php b/src/Model/Subscription.php index 47f0971..071eca5 100644 --- a/src/Model/Subscription.php +++ b/src/Model/Subscription.php @@ -16,6 +16,7 @@ * @property-read int $user_licenses Number of users. * @property-read string $project_id * @property-read string $project_title + * @property-read string $project_options * @property-read string $project_region * @property-read string $project_region_label * @property-read string $project_ui diff --git a/src/PlatformClient.php b/src/PlatformClient.php index 94dac42..c834422 100644 --- a/src/PlatformClient.php +++ b/src/PlatformClient.php @@ -9,6 +9,7 @@ use Platformsh\Client\Model\Plan; use Platformsh\Client\Model\Project; use Platformsh\Client\Model\Region; +use Platformsh\Client\Model\Catalog; use Platformsh\Client\Model\Result; use Platformsh\Client\Model\SshKey; use Platformsh\Client\Model\Subscription; @@ -232,7 +233,9 @@ protected function cleanRequest(array $request) * @param int $storage The storage of each environment, in MiB. * @param int $environments The number of available environments. * @param array $activationCallback An activation callback for the subscription. + * @param string $catalog The catalog item url. See getCatalog(). * + * @see PlatformClient::getCatalog() * @see PlatformClient::getRegions() * @see Subscription::wait() * @@ -241,8 +244,9 @@ protected function cleanRequest(array $request) * similar code to wait for the subscription's project to be provisioned * and activated. */ - public function createSubscription($region, $plan = 'development', $title = null, $storage = null, $environments = null, array $activationCallback = null) + public function createSubscription($region, $plan = 'development', $title = null, $storage = null, $environments = null, array $activationCallback = null, $catalog = null) { + $url = $this->accountsEndpoint . 'subscriptions'; $values = $this->cleanRequest([ 'project_region' => $region, @@ -251,8 +255,9 @@ public function createSubscription($region, $plan = 'development', $title = null 'storage' => $storage, 'environments' => $environments, 'activation_callback' => $activationCallback, + 'options_url' => $catalog, ]); - + return Subscription::create($values, $url, $this->connector->getClient()); } @@ -333,4 +338,14 @@ public function getRegions() { return Region::getCollection($this->accountsEndpoint . 'regions', 0, [], $this->getConnector()->getClient()); } + + /** + * Get the project options catalog. + * + * @return Catalog[] + */ + public function getCatalog() + { + return Catalog::create([], $this->accountsEndpoint . 'setup/catalog', $this->getConnector()->getClient()); + } }