UpCloudLtd/upcloud-php-api

Not all server plans are in PriceZone

derkgort opened this issue · 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?

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.

Darep commented

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...

Thank you for creating the issue and providing the PR. #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.