Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated curl cmds for the GCBM dynamic endpoints #194

Merged
merged 3 commits into from
Oct 8, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
196 changes: 169 additions & 27 deletions local/rest_api_gcbm/curl.md
Original file line number Diff line number Diff line change
@@ -1,29 +1,32 @@
<h3> GCBM API Endpoints </h3>

### Create a new GCBM simulation
The title of a new simulation can be passed or the default title `simulation` will be used. (i.e the default title of the simulation is `simulation`, here the title `run4` is used)

| **Method** | **Endpoint** | **Response code** |
|--- | ---| --- |
| POST| `/gcbm/new` | 200 OK (Success) |
The title of a new simulation can be passed or the default title `simulation` will be used. (i.e the default title of the simulation is `simulation`, here the title `run4` is used)

| **Method** | **Endpoint** | **Response code** |
| ---------- | ------------ | ----------------- |
| POST | `/gcbm/new` | 200 OK (Success) |

Example:

```
curl -d "title=run4" -X POST http://localhost:8080/gcbm/new
```

Expected response (Success):

```json
{
"data": "New simulation started. Please move on to the next stage for uploading files at /gcbm/upload."
"data": "New simulation started. Please move on to the next stage for uploading files at /gcbm/upload."
}
```

### Upload configuration files
### Upload configuration files

Upload all of the files required to run the simulation.
| **Method** | **Endpoint** | **Response codes** |
|--- | ---| --- |
| **Method** | **Endpoint** | **Response codes** |
|--- | ---| --- |
| POST| `/gcbm/upload` | 200 OK (Success), 400 (Error) |

Example:
Expand Down Expand Up @@ -54,19 +57,154 @@ curl -F disturbances='@disturbances/disturbances_2011_moja.tiff' \
```

Expected response (Success):

```json
{
"data": "All files uploaded succesfully. Proceed to the next step of the API at gcbm/dynamic."
}
```

### Run the simulation
After uploading your files, you can run the simulation through this endpoint.
You can upload all the simulation files at once or upload them separately. To upload files separately follow the commands below.

### Upload Disturbances file

Upload Disturbances file to run the simulation.
| **Method** | **Endpoint** | **Response codes** |
|--- | ---| --- |
| POST| `/gcbm/upload/disturbances` | 200 OK (Success), 400 (Error) |

Example:

Go to the location of the unzipped file `GCBM_New_Demo_Run.zip`

```
cd path-to-unzipped-file
```

Upload all the files present in the disturbances folder.

```
curl -F disturbances='@disturbances/disturbances_2011_moja.tiff' \
-F disturbances='@disturbances/disturbances_2012_moja.tiff' \
-F disturbances='@disturbances/disturbances_2013_moja.tiff' \
-F disturbances='@disturbances/disturbances_2014_moja.tiff' \
-F disturbances='@disturbances/disturbances_2015_moja.tiff' \
-F disturbances='@disturbances/disturbances_2016_moja.tiff' \
-F disturbances='@disturbances/disturbances_2018_moja.tiff' \
-F title="run4" \
http://localhost:8080/gcbm/upload/disturbances
```

Expected response (Success):

```json
{
"data": "Disturbances file uploaded succesfully. Proceed to the next step."
}
```

### Upload Classifiers file

Upload Classifiers file to run the simulation.
| **Method** | **Endpoint** | **Response codes** |
|--- | ---| --- |
| POST| `/gcbm/upload/classifiers` | 200 OK (Success), 400 (Error) |

Example:

Go to the location of the unzipped file `GCBM_New_Demo_Run.zip`

```
cd path-to-unzipped-file
```

Upload all the files present in the disturbances folder.

```
curl -F classifiers='@classifiers/Classifier1_moja.tiff' \
-F classifiers='@classifiers/Classifier2_moja.tiff' \
-F title="run4" \
http://localhost:8080/gcbm/upload/classifiers
```

Expected response (Success):

```json
{
"data": "Classifiers file uploaded succesfully. Proceed to the next step."
}
```

| **Method** | **Endpoint** | **Response code** |
|--- | ---| --- |
| POST | `/gcbm/dynamic` | 200 OK (Success) |
### Upload Miscellaneous file

Upload Miscellaneous file to run the simulation.
| **Method** | **Endpoint** | **Response codes** |
|--- | ---| --- |
| POST| `/gcbm/upload/miscellaneous` | 200 OK (Success), 400 (Error) |

Example:

Go to the location of the unzipped file `GCBM_New_Demo_Run.zip`

```
cd path-to-unzipped-file
```

Upload all the files present in the disturbances folder.

```
curl -F miscellaneous='@miscellaneous/initial_age_moja.tiff' \
-F miscellaneous='@miscellaneous/mean_annual_temperature_moja.tiff' \
-F title="run4" \
http://localhost:8080/gcbm/upload/miscellaneous
```

Expected response (Success):

```json
{
"data": "Miscellaneous file uploaded succesfully. Proceed to the next step."
}
```

### Upload db file

Upload db file to run the simulation.
| **Method** | **Endpoint** | **Response codes** |
|--- | ---| --- |
| POST| `/gcbm/upload/db` | 200 OK (Success), 400 (Error) |

Example:

Go to the location of the unzipped file `GCBM_New_Demo_Run.zip`

```
cd path-to-unzipped-file
```

Upload all the files present in the disturbances folder.

```
curl -F db='@db/gcbm_input.db' \
-F title="run4" \
http://localhost:8080/gcbm/upload/db
```

Expected response (Success):

```json
{
"data": "db file uploaded succesfully. Proceed to the next step."
}
```

### Run the simulation

After uploading your files, you can run the simulation through this endpoint.

| **Method** | **Endpoint** | **Response code** |
| ---------- | --------------- | ----------------- |
| POST | `/gcbm/dynamic` | 200 OK (Success) |

Example:

Expand All @@ -75,59 +213,63 @@ curl -d "title=run4" -X POST http://localhost:8080/gcbm/dynamic
```

Expected response (Success):

```json
{
"status": "Run started"
}
```

### Get status of the simulation

| **Method** | **Endpoint** | **Response code** |
|--- | ---| --- |
| POST | `/gcbm/status` | 200 OK (Success) |
### Get status of the simulation

| **Method** | **Endpoint** | **Response code** |
| ---------- | -------------- | ----------------- |
| POST | `/gcbm/status` | 200 OK (Success) |

```
curl -d "title=run4" -X POST http://localhost:8080/gcbm/status
```


Expected response (In progress):

```json
{
"finished": "In Progress"
}
```

Expected response (When simulation completes):

```json
{
"finished": "Output is ready to download at gcbm/download"
}
```

### Download the result of simulation
| **Method** | **Endpoint** | **Response code** |
|--- | ---| --- |
| POST | `/gcbm/download` | 200 OK (Success) |
### Download the result of simulation

| **Method** | **Endpoint** | **Response code** |
| ---------- | ---------------- | ----------------- |
| POST | `/gcbm/download` | 200 OK (Success) |

A file named `output.zip` will be obtained. This file contains the outputs generated, which can be analysed on unzipping.

```
curl -d "title=run4" -X POST http://localhost:8080/gcbm/download -L -o run4.zip
```

### List all of the simulations
| **Method** | **Endpoint** | **Response code** |
|--- | ---| --- |
| GET | `/gcbm/list` | 200 OK (Success) |
### List all of the simulations

| **Method** | **Endpoint** | **Response code** |
| ---------- | ------------ | ----------------- |
| GET | `/gcbm/list` | 200 OK (Success) |

```
curl http://localhost:8080/gcbm/list
```

Expected response (Success):

```json
{
"data": ["run4"],
Expand Down