-
Notifications
You must be signed in to change notification settings - Fork 31
Library updates for initialize and template flag handling #37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| <?php | ||
|
|
||
| namespace Platformsh\Client\Model; | ||
|
|
||
| use GuzzleHttp\ClientInterface; | ||
|
|
||
| /** | ||
| * Represents a Platform.sh catalog. | ||
| * | ||
| * @property-read int $id | ||
| * @property-read string $label | ||
| * @property-read bool $available | ||
| * @property-read bool $private | ||
| * @property-read string $zone | ||
| * @property-read string $endpoint | ||
| */ | ||
| class Catalog extends Resource | ||
| { | ||
| /** | ||
| * @inheritdoc | ||
| */ | ||
| protected function setData(array $data) | ||
| { | ||
| $data = isset($data['info']) ? $data['info'] : $data; | ||
| $this->data = $data; | ||
| } | ||
|
|
||
| /** | ||
| * @inheritdoc | ||
| */ | ||
| public static function wrapCollection(array $data, $baseUrl, ClientInterface $client) | ||
| { | ||
| $data = isset($data['info']) ? $data['info'] : []; | ||
|
|
||
| return parent::wrapCollection($data, $baseUrl, $client); | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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,13 +227,15 @@ 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. | ||
| * | ||
| * @see PlatformClient::getCatalog() | ||
| * @see PlatformClient::getRegions() | ||
| * @see Subscription::wait() | ||
| * | ||
|
|
@@ -241,18 +244,20 @@ 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, | ||
| 'plan' => $plan, | ||
| '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()); | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Pretty much the same objections as #39 - the catalog isn't a thing that lists items on GET /catalog, lets me GET a consitutuent item in GET/catalog/:id, etc, DELETE/PUT/PATCH to modify, POST to add to the list, etc, it's not a RESTful resource, so reusing the Resource model here is at least a bit awkward. |
||
| } | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.