stackhpc / coral-credits

Track cloud credit usage for projects like Azimuth and Blazar
Apache License 2.0
1 stars 0 forks source link

Add simpler allocation API #23

Open JohnGarbutt opened 1 month ago

JohnGarbutt commented 1 month ago

Ideally we add a new REST API that allows updating a matching account with some resource allocations, e.g. to create an allocation, you can do a post something like this, with a failure if you reduce the allocation below the amount already consumed:

curl -s -X POST -H "$AUTH_HEADER" -H "$CONTENT_TYPE" -d \
    "{"provider_name\": \"mycloud\", "start\": \"$START_DATE\", "end\": \"$END_DATE\", \"resources\": {
        \"VCPU\": 1000,
        \"MEMORY_MB\": 240000,
        \"DISK_GB\": 50000
    }}" \
    http://$SITE:$PORT/resource_provider_account/$project_uuid/allocations

The update should also be easy to do, using the same set of inputs, find a matching allocation for that project_uuid and then update.

I think the DB schema is being used too heavily for the APIs.