rokka-io / rokka-dashboard

Serverless dashboard for rokka.io
https://rokka.io
MIT License
7 stars 0 forks source link

Implement billing API #71

Open chregu opened 6 years ago

chregu commented 6 years ago

The backend has now info about past and future costs -> https://api.rokka.io/billing/$org

Would be nice, if we could display in the dashboard in a nice format, for the current and the last few months maybe (the ?from and ?to parameters exist like in the /stats call, but default to the current month and the returned data is always for the full month)

It has the format

{
  "$master_organiation": {
    "$year-$month": {
      "organizations": {
        "$org1": {
          "traffic": {
            "$tier1": {
              "amount_in_gb": 0.05,
              "price_per_gb": 0.5,
              "price_in_chf": 0.03
            },
            "total": {
              "amount_in_gb": 0.05,
              "price_in_chf": 0.03
            }
          },
          "storage": {
            "$tier1": {
              "amount_in_gb": 20.66,
              "price_per_gb": 0.4,
              "price_in_chf": 24.26
            },
            "total": {
              "amount_in_gb": 154.66,
              "price_in_chf": 24.26
            }
          },
          "total": {
            "price_in_chf": 24.29
          }
        },
        "$org2": {
          "traffic": {
            ...
          }
      },
      "combined": {
        "traffic": {
          "$tier1": {
            "amount_in_gb": 5.0,
            "price_per_gb": 0.5,
            "price_in_chf": 2.5
          },
          "total": {
            "amount_in_gb": 5.0,
            "price_in_chf": 2.5
          }
        },
        "storage": {
          "$tier": {
            "amount_in_gb": 40,
            "price_per_gb": 0.4,
            "price_in_chf": 16
          },
          "total": {
            "amount_in_gb": 40,
            "price_in_chf": 16.0
          }
        },
        "total": {
          "price_in_chf": 30.29
        }
      },
      "combined_forecast": {
        "traffic": {
          "$tier1": {
            "amount_in_gb": 20.25,
            "price_per_gb": 0.5,
            "price_in_chf": 10.13
          },
          "total": {
            "amount_in_gb": 20.25,
            "price_in_chf": 10.13
          }
        },
        "storage": {
          "$tier2": {
            "amount_in_gb": 200.99,
            "price_per_gb": 0.4,
            "price_in_chf": 80.6
          },
          "total": {
            "amount_in_gb": 50,
            "price_in_chf": 25.6
          }
        },
        "total": {
          "price_in_chf": 143.73
        }
      }
    }
  }
}