- Java (>=8)
- sbt
- Run the server. Http port can be changed by config
sbt run
The API should be running on your port 8080 for default.
- URL: GET /instance-kinds
- Success Response:
[
{
"kind": "sc2-micro"
},
{
"kind": "sc2-small"
},
... (ommitted)
{
"kind": "sc2-hicpu-32"
}
]
Return prices of all instances. If kind
is specified, the prices of the given instance kinds are returned.
- URL: GET /prices
- Parameters:
- Optional:
- kind=[string] : The value is one or multiple instance kinds. For multiple instance kinds, you can specify multiple instance kinds by comma separation.
For example,
/prices?kind=sc2-hicpu-32,sc2-small,sc2-micro
- kind=[string] : The value is one or multiple instance kinds. For multiple instance kinds, you can specify multiple instance kinds by comma separation.
For example,
- Optional:
- Success Response:
[
{
"kind": "sc2-micro",
"price": 0.301
},
{
"kind": "sc2-small",
"price": 0.561
},
... (ommited)
{
"kind": "sc2-hicpu-32",
"price": 0.925
}
]
/prices
should return multiple prices. It is not clear by the requirements but returning one prices is subset of multiple one so I hope this is fine.- 500 error of the smartcloud can be fixed in next 3 times calling the api.
- One of smarcloud api calls returns 422 error, this api returns 422 error instead of returning prices partially. I choose this way because this way is simpler for callee of this API.
- Set retry policy for http client without waiting
- Use
ApplicativeError
insteadEither
. This is because of keeping original type. - Set
errorHandle
in theroutes
instead ofgetPrices
andgetInstanceKinds
because we may forget to seterrorHandle
in the new route method if we add a new endpoint. - I did
case ex : PriceService.Exception
in theerrorHandle
because we can get exhaustive type checking benefit bysealed trait
.