InformaticsMatters / squonk2-data-manager-ui

Web UI for the Squonk Data Manager
data-manager-ui.vercel.app
Apache License 2.0
2 stars 0 forks source link

DM/AS Connection (Stage 1) #281

Closed alanbchristie closed 3 years ago

alanbchristie commented 3 years ago

The Data Manager (DM) will soon be able to communicate with the Account Server (AS).

In Stage 1 only Storage statistics will be delivered, which will be achieved via a "private" channel and won't need the UI.

UI changes (A) - Assisting the DM to connect to the AS

What the UI will need to do to facilitate this is to provide "real" Organisation, Unit and Product identities when using the following DM-API endpoints: -

The AS can serve-up these identities using: -

But you can use constants, as they're built-in and will not change for this stage: -

ORG_ID: str = 'org-00000000-dead-0000-0000-000000000000'
UNIT_ID: str = 'unit-00000000-dead-0000-0000-000000000000'
PRODUCT_DATASET_ID: str = 'product-00000000-dead-0000-0000-00000000000d'
PRODUCT_TIER_EVALUATION_ID: str = 'product-00000000-dead-0000-0000-00000000000e'
PRODUCT_TIER_BRONZE_ID: str = 'product-00000000-dead-0000-0000-00000000000b'
PRODUCT_TIER_SILVER_ID: str = 'product-00000000-dead-0000-0000-00000000000s'
PRODUCT_TIER_GOLD_ID: str = 'product-00000000-dead-0000-0000-000000000009'

Getting the IDs from the AS could be implemented but, to minimise development effort, the UI could use the above constants for the time-being.

Note - the AS still does not use authentication and all users belong to all Units and Organisations.

UI changes (B) - Getting storage statistics

Once the UI starts to pass orgs, units and products into the DM-API (development in progress) statistics will be available on the AS endpoint: -

At the moment only Storage will be recorded but (when the DM to API server connection is complete) you should start to see "real" storage values and coin usage using the above product endpoint. You should see storage size, coins, burn rates and spend predictions.

alanbchristie commented 3 years ago

The AS now keeps a track of the total size of all newly uploaded Datasets.

No Project or Project Storage measurements are handled atm. So the four Project Tier products will not change. Only the DATA_MANAGER_STORAGE_SUBSCRIPTION changes.

To exercise the DATA_MANAGER_STORAGE_SUBSCRIPTION you need to use the hard-coded organisation_id and unit_id values on the DM-API’s PUT /dataset endpoint. When the Dataset has finished uploading (which may take seconds or minutes depends on the size of the file your file) the DM sends a “Storage” message to the AS on behalf of the Unit so that it can keep track of the Unit’s current and peak storage values.

When a Dataset is removed another “Storage” message is sent to the AS so that it can adjust the current storage measurement for the Unit.

When you do a GET on the AS /product/organisation/{org_id}/unit/{unit_id} endpoint you will see changes to the DATA_MANAGER_STORAGE_SUBSCRIPTION object.

Specifically: -

storage.size.current is a new property in the response as storage.size.used is now used for the "peak" value.

If you look now you’ll see 158.8 KiB used (peak) with a current value of 0 Bytes. That’s because I uploaded two small datasets and then deleted them. That cost 0.1 coins with a billing prediction of 0.1. That’s correct because my “peak” was 0.1 coins but as I’m not using Dataset storage any more that’s my total bill. If we upload new datasets the prediction should reflect the new burn rate.