From 1bdb22f8a6f8c6c146717046f80406c97b0abe8b Mon Sep 17 00:00:00 2001 From: Shawna Date: Mon, 5 Aug 2019 09:21:01 -0400 Subject: [PATCH 1/3] library updates to allow for the project create command in the cli to handle a template and initialize flag --- src/Model/Catalog copy.php | 37 +++++++++++++++++++++++++++++++++++++ src/Model/Subscription.php | 1 + src/PlatformClient.php | 19 +++++++++++++++++-- 3 files changed, 55 insertions(+), 2 deletions(-) create mode 100644 src/Model/Catalog copy.php diff --git a/src/Model/Catalog copy.php b/src/Model/Catalog copy.php new file mode 100644 index 00000000..f9c5ce67 --- /dev/null +++ b/src/Model/Catalog copy.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 47f0971e..071eca58 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 94dac42b..932b88b0 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; @@ -226,6 +227,7 @@ protected function cleanRequest(array $request) /** * Create a new Platform.sh subscription. * + * @param string $catalog The catalog item url. See getCatalog(). * @param string $region The region ID. See getRegions(). * @param string $plan The plan. See Subscription::$availablePlans. * @param string $title The project title. @@ -233,6 +235,7 @@ protected function cleanRequest(array $request) * @param int $environments The number of available environments. * @param array $activationCallback An activation callback for the subscription. * + * @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($catalog, $region, $plan = 'development', $title = null, $storage = null, $environments = null, array $activationCallback = null) { + $url = $this->accountsEndpoint . 'subscriptions'; $values = $this->cleanRequest([ 'project_region' => $region, @@ -250,9 +254,10 @@ public function createSubscription($region, $plan = 'development', $title = null 'project_title' => $title, 'storage' => $storage, 'environments' => $environments, + 'options_url' => $catalog, 'activation_callback' => $activationCallback, ]); - + 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()); + } } From e059a001aa2cfb2c20c74c1e9b16bdbac628d531 Mon Sep 17 00:00:00 2001 From: Shawna Date: Wed, 7 Aug 2019 08:31:10 -0400 Subject: [PATCH 2/3] fixing my local --- src/Model/{Catalog copy.php => Catalog.php} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename src/Model/{Catalog copy.php => Catalog.php} (100%) diff --git a/src/Model/Catalog copy.php b/src/Model/Catalog.php similarity index 100% rename from src/Model/Catalog copy.php rename to src/Model/Catalog.php From 0ca194fd43b6a8bf4653cea67cb58799cada48d1 Mon Sep 17 00:00:00 2001 From: Shawna Date: Fri, 30 Aug 2019 07:10:51 -0400 Subject: [PATCH 3/3] moving catalog for bw --- src/PlatformClient.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/PlatformClient.php b/src/PlatformClient.php index 932b88b0..c8344226 100644 --- a/src/PlatformClient.php +++ b/src/PlatformClient.php @@ -227,13 +227,13 @@ protected function cleanRequest(array $request) /** * Create a new Platform.sh subscription. * - * @param string $catalog The catalog item url. See getCatalog(). * @param string $region The region ID. See getRegions(). * @param string $plan The plan. See Subscription::$availablePlans. * @param string $title The project title. * @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() @@ -244,7 +244,7 @@ protected function cleanRequest(array $request) * similar code to wait for the subscription's project to be provisioned * and activated. */ - public function createSubscription($catalog, $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'; @@ -254,8 +254,8 @@ public function createSubscription($catalog, $region, $plan = 'development', $ti 'project_title' => $title, 'storage' => $storage, 'environments' => $environments, - 'options_url' => $catalog, 'activation_callback' => $activationCallback, + 'options_url' => $catalog, ]); return Subscription::create($values, $url, $this->connector->getClient());