Using /sites

In this example we are going to explore deeply the options available when collecting and uploading sites from EOSC Performance. This example was created using Jupyter notebook, click here to the original notebook file.

Create the environment

To do so, we select an API endpoint and collect a token from our configuration. We also need an access token, in this example we use oidc-agent to get one.

[1]:
eosc_perf_api="https://performance.services.fedcloud.eu/api/v1/"
access_token=$(oidc-token egi-prod)

(Conditional) Register, if not done already

To use our service as user, first we need to accept the terms of usage and register. Make sure to read the terms and conditions.

[ ]:
curl -X 'POST' \
  "$eosc_perf_api/users:register" \
  -H "Authorization: Bearer $access_token"

Upload your site

To upload the site, you only need to use an authenticated POST request to /sites and attach the following content to the body:

  • name: Name of the site to display to the community.

  • address: Address of the site to display to the community (it might be virtual or physical).

  • description(Optional): Short description about the site for the community.

[3]:
name="my_site"
address="my_address.com"
curl -X 'POST' "$eosc_perf_api/sites" \
  -H 'accept: application/json' \
  -H "Authorization: Bearer $access_token" \
  -H 'Content-Type: application/json' \
  -d "{\"name\": \"$name\", \"address\": \"$address\", \
       \"description\": \"A free description for the community\"}" | jq
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   300  100   190  100   110    230    133 --:--:-- --:--:-- --:--:--   364
{
  "address": "my_address.com",
  "description": "A free description for the community",
  "id": "d9a42645-5cd4-403b-866c-793cc00e1665",
  "name": "my_site",
  "upload_datetime": "2022-02-24T13:32:25.830999"
}

Download your site

You can check your site is available by downloading the site.

Note the upload of sites needs to be validated by administrators. Therefore it will only be available to the community after the review is completed.

[4]:
sites=$(curl -X 'GET' "$eosc_perf_api/sites?name=$name")
echo $sites | jq '.items[0].id'
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   280  100   280    0     0  12727      0 --:--:-- --:--:-- --:--:-- 12727
"d9a42645-5cd4-403b-866c-793cc00e1665"

Upload your site flavors

Additionally to the site main attributes, you can also upload deployment flavors to a specific site. To upload a flavor, you only need to use an authenticated POST request to /sites/{id}/flavors and attach the following content to the body:

  • name: Name of the flavor to display to the community.

  • description(Optional): Short description about the flavor for the community.

[5]:
site_id=$(echo $sites | jq -r '.items[0].id')
name="flavor_1"
curl -X 'POST' "$eosc_perf_api/sites/$site_id/flavors" \
  -H 'accept: application/json' \
  -H "Authorization: Bearer $access_token" \
  -H 'Content-Type: application/json' \
  -d "{\"name\": \"$name\", \
       \"description\": \"A free description for the community\"}" | jq
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   246  100   164  100    82    206    103 --:--:-- --:--:-- --:--:--   309
{
  "description": "A free description for the community",
  "id": "efbd2510-8b45-4113-b691-9a6dae7dd5cf",
  "name": "flavor_1",
  "upload_datetime": "2022-02-24T13:34:11.627946"
}

Download your site flavor

You can check your site flavor is available by downloading the site flavors.

Note the upload of flavors needs to be validated by administrators. Therefore it will only be available to the community after the review is completed.

[6]:
flavors=$(curl -X 'GET' "$eosc_perf_api/sites/$site_id/flavors?name=$name")
echo $flavors | jq '.items[0].id'
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   254  100   254    0     0   4618      0 --:--:-- --:--:-- --:--:--  4618
"efbd2510-8b45-4113-b691-9a6dae7dd5cf"