upcloud-php-api icon indicating copy to clipboard operation
upcloud-php-api copied to clipboard

Not all server plans are in PriceZone

Open derkgort opened this issue 5 years ago • 3 comments

Hi,

Not all server plans are defined in PriceZone.

Only these 2:

    'server_plan_1x_cpu_1_gb' => '\Upcloud\ApiClient\Model\Price',
    'server_plan_2x_cpu_2_gb' => '\Upcloud\ApiClient\Model\Price'

https://github.com/UpCloudLtd/upcloud-php-api/blob/master/lib/Model/PriceZone.php#L63

This is the full list:

server_plan_1xCPU-1GB server_plan_1xCPU-2GB server_plan_20xCPU-128GB server_plan_20xCPU-96GB server_plan_2xCPU-4GB server_plan_4xCPU-8GB server_plan_6xCPU-16GB server_plan_8xCPU-32GB

Is there a reason they are not defined?

derkgort avatar Jul 02 '19 14:07 derkgort

I just added pull request: #21 Not sure that's the way it's done, because it looks like generated code.

I also added a function to get the plan based on the value returned in ServerApi.

derkgort avatar Jul 02 '19 14:07 derkgort

Yeah, I think the plans were generated with swagger from some incomplete yaml file by the original author of this library... IMO the best solution would be to remove all hard-coded plans/string, and use the plans API: GET /1.2/plan https://developers.upcloud.com/7-plans/ - and pass server create etc. the "name" of the plan you want. Just an idea though...

Darep avatar Aug 20 '19 11:08 Darep

Thank you for creating the issue and providing the PR. https://github.com/UpCloudLtd/upcloud-php-api/pull/21

For now all server plans are in PriceZone.

I agree with Darep's solution and since we will face this issue again in the future, I'll leave this issue open for now.

alienhaxor avatar Oct 11 '19 12:10 alienhaxor