Skip to content
Snippets Groups Projects
Commit 5d2b81f0 authored by Menou Lucas's avatar Menou Lucas
Browse files

refactor: clarify rest api

parent d0ad7cfd
No related branches found
No related tags found
1 merge request!4feat/updating
This commit is part of merge request !4. Comments created here will be created in the context of that merge request.
......@@ -75,10 +75,11 @@ User will need to transmit the HTTP Authorization header like this :
Authorization: Bearer <token>
```
Example with curl:
Example with `curl`:
```bash
curl http://localhost:8080/database --header 'Authorizarion: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c'
$ curl "http://localhost:8080/database" \
--header 'Authorizarion: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c'
```
## Keycloak
......@@ -140,7 +141,9 @@ We can therefore request a token from keycloak via this client. But first we nee
You can now send a request to keycloak to get a token :
```bash
curl -k --data "grant_type=client_credentials&client_id=anis-server&client_secret=**********" http://localhost:8180/auth/realms/anis/protocol/openid-connect/token
$ curl -k \
--data "grant_type=client_credentials&client_id=anis-server&client_secret=**********" \
"http://localhost:8180/auth/realms/anis/protocol/openid-connect/token"
```
Replace `**********` with the secret obtained from the keycloak interface.
......
......@@ -3,18 +3,24 @@
## Introduction
ANIS provides scientific projects and for each project datasets extracted from databases.
ANIS allows to associate files (fits, png, xml, ...) to the projects and datasets.
We will see here how to associate data with projects and datasets.
ANIS also allows to associate files such as `fits`, `png`, `xml`, etc, to illustrate projects and datasets.
This page describes how to associate those files with projects and datasets.
## Server data path
First of all you have to specify the directory where the data will be stored.
This directory will become the root directory for ANIS server.
First of all you have to specify the directory containing the future files and data.
This directory becomes the root directory for the ANIS _server_.
Go to the `docker-compose.yml` file to configure the `DATA_PATH` environment variable.
![anis_server_data_path](img/anis_server_data_path.png)
Here you can see that the data directory is set to `/data`
Here you can see that the data directory is configured to `/data`.
While downloading and installing ANIS, remember you [downloaded](installation.md#data) examples file to start the app.
You then symlinked them to the directory `data` at the root of the project. The latter files and directory find their use now.
They are mounted in the _server container_ at the root of the ANIS _server_ for it to serve them properly.
## Admin files explorer
......@@ -24,7 +30,7 @@ Please note that if authentication is enabled you will need to send a token to p
If you want to explore the ANIS `root` directory type:
```bash
curl http://localhost:8080/admin-file-explorer
$ curl "http://localhost:8080/admin-file-explorer"
```
![admin_file_explorer_root](img/admin_file_explorer_root.png)
......@@ -32,7 +38,7 @@ curl http://localhost:8080/admin-file-explorer
If you want to explore the `DEFAULT` directory type:
```bash
curl http://localhost:8080/admin-file-explorer/DEFAULT
$ curl "http://localhost:8080/admin-file-explorer/DEFAULT"
```
![admin_file_explorer_default_directory](img/admin_file_explorer_default_directory.png)
......@@ -46,10 +52,37 @@ To configure the data path of a project you have to fill in the property `data_p
Example:
```bash
curl -d '{"name":"default","label":"Default instance","description":"Instance for the test","scientific_manager":"M. Durand","instrument":"Multiple","wavelength_domain":"Visible imaging / Spectroscopy","display":10,"data_path":"\/DEFAULT","files_path":"\/INSTANCE_FILES","public":true,"portal_logo":"","design_color":"#7AC29A","design_background_color":"#ffffff","design_logo":"/logo.png","design_favicon":"/favicon.ico","samp_enabled":true,"back_to_portal":true,"search_by_criteria_allowed":true,"search_by_criteria_label":"Search","search_multiple_allowed":false,"search_multiple_label":"Search multiple","search_multiple_all_datasets_selected":false,"documentation_allowed":false,"documentation_label":"Documentation"}' --header 'Content-Type: application/json' -X POST http://localhost/instance
$ curl -d '{
"name": "default",
"label": "Default instance",
"description": "Instance for the test",
"scientific_manager": "M. Durand",
"instrument": "Multiple",
"wavelength_domain": "Visible imaging / Spectroscopy",
"display": 10,
"data_path": "/DEFAULT",
"files_path": "/INSTANCE_FILES",
"public": true,
"portal_logo": "",
"design_color": "#7AC29A",
"design_background_color": "#ffffff",
"design_logo": "/logo.png",
"design_favicon": "/favicon.ico",
"samp_enabled": true,
"back_to_portal": true,
"search_by_criteria_allowed": true,
"search_by_criteria_label": "Search",
"search_multiple_allowed": false,
"search_multiple_label": "Search multiple",
"search_multiple_all_datasets_selected": false,
"documentation_allowed": false,
"documentation_label": "Documentation"
}' \
--header 'Content-Type: application/json' \
-X POST "http://localhost/instance"
```
You can also configure a directory for storing files related to the project : `files_path`.
You can also configure a directory for storing files related to the project: `files_path`.
The directory path will start from the data path directory of the project.
Files related to the project such as the logo, images will be stored in this directory.
......@@ -61,7 +94,7 @@ Please note that if the instace is private you will need to send a token to perf
If you want to explore the files for default project directory type:
```bash
curl http://localhost:8080/instance/default/file-explorer
$ curl "http://localhost:8080/instance/default/file-explorer"
```
![instance_file_explorer_default_directory](img/instance_file_explorer_default_directory.png)
......@@ -75,7 +108,25 @@ To configure the data_path of a dataset you have to fill in the property in the
Example:
```bash
curl -d '{"name":"vipers_dr2_w1","table_ref":"aspic_vipers_dr2_w1","label":"VIPERS-W1 (DR2)","description":"VIPERS W1 dataset","display":10,"data_path":"\/ASPIC\/VIPERS_DR2","public":true,"download_json":true,"download_csv":true,"download_ascii":true,"download_vo":false,"server_link_enabled":false,"datatable_enabled":true,"datatable_selectable_rows":false,"id_database":1}' --header 'Content-Type: application/json' -X POST http://localhost/dataset-family/1/dataset
$ curl -d '{
"name": "vipers_dr2_w1",
"table_ref": "aspic_vipers_dr2_w1",
"label": "VIPERS-W1 (DR2)",
"description": "VIPERS W1 dataset",
"display": 10,
"data_path": "/ASPIC/VIPERS_DR2",
"public": true,
"download_json": true,
"download_csv": true,
"download_ascii": true,
"download_vo": false,
"server_link_enabled": false,
"datatable_enabled": true,
"datatable_selectable_rows": false,
"id_database": 1
}' \
--header 'Content-Type: application/json' \
-X POST "http://localhost/dataset-family/1/dataset"
```
Here you can see that the data directory for this dataset is set to `/ASPIC/VIPERS_DR2`
......@@ -88,21 +139,22 @@ Please note that if the dataset is private you will need to send a token to perf
Example:
```bash
curl http://localhost:8080/dataset/vipers_dr2_w1/file-explorer
$ curl "http://localhost:8080/dataset/vipers_dr2_w1/file-explorer"
```
![dataset_file_explorer](img/dataset_file_explorer.png)
If you want explore the spec1d directory you can execute :
If you want explore the spec1d directory you can execute:
```bash
curl http://localhost:8080/dataset/vipers_dr2_w1/file-explorer/spec1D
$ curl "http://localhost:8080/dataset/vipers_dr2_w1/file-explorer/spec1D"
```
![dataset_file_explorer_spec1d_directory](img/dataset_file_explorer_spec1d_directory.png)
If a user want to download the file `VIPERS_101121877_bis.fits` you can execute :
If a user want to download the file `VIPERS_101121877_bis.fits` you can execute:
```bash
curl http://localhost:8080/dataset/vipers_dr2_w1/file-explorer/spec1D/VIPERS_101121877_bis.fits
$ curl \
"http://localhost:8080/dataset/vipers_dr2_w1/file-explorer/spec1D/VIPERS_101121877_bis.fits"
```
......@@ -33,7 +33,7 @@ When the dataset is created and the attributes are added, the metamodel assigns
The user can list the attributes available for a dataset.
```bash
curl "http://localhost:8080/dataset/observations/attribute"
$ curl "http://localhost:8080/dataset/observations/attribute"
```
To add a list of attributes in a dataset search the user must add the query parameter `a`.
......@@ -48,14 +48,14 @@ a=1;2;3
Example:
```bash
curl "http://localhost:8080/search/observations?a=1;2;3"
$ curl "http://localhost:8080/search/observations?a=1;2;3"
```
The user can choose the output order of the attributes.
Example if the user wants to see attribute 3 before 2:
```bash
curl "http://localhost:8080/search/observations?a=1;3;2"
$ curl "http://localhost:8080/search/observations?a=1;3;2"
```
### Count
......@@ -65,13 +65,13 @@ This will return the number of records found for a search.
For example, if the user wants to retrieve the number of records in the observations dataset:
```bash
curl "http://localhost:8080/search/observations?a=count"
$ curl "http://localhost:8080/search/observations?a=count"
```
if the user wants to retrieve the number of records in the observations dataset when the ID observations is greater than 424:
```bash
curl "http://localhost:8080/search/observations?a=count&c=1::gt::424"
$ curl "http://localhost:8080/search/observations?a=count&c=1::gt::424"
```
### All
......@@ -81,7 +81,7 @@ This will return all attributes available for the dataset.
For example, if the user wants to retrieve all columns for this dataset observations search:
```bash
curl "http://localhost:8080/search/observations?a=all&c=1::gt::424"
$ curl "http://localhost:8080/search/observations?a=all&c=1::gt::424"
```
## Criteria (param c)
......@@ -124,7 +124,7 @@ For example if the user wants to search for the observation with the number 418:
Complete example with observations dataset:
```bash
curl "http://localhost:8080/search/observations?a=1;2;3&c=1::eq::418"
$ curl "http://localhost:8080/search/observations?a=1;2;3&c=1::eq::418"
```
### Not equal
......@@ -140,7 +140,7 @@ For example if the user wants to search all observations except 418:
Complete example with observations dataset:
```bash
curl "http://localhost:8080/search/observations?a=1;2;3&c=1::neq::418"
$ curl "http://localhost:8080/search/observations?a=1;2;3&c=1::neq::418"
```
### Between
......@@ -156,7 +156,7 @@ For example if the user wants to search all observations between 418 and 420:
Complete example with observations dataset:
```bash
curl "http://localhost:8080/search/observations?a=1;2;3&c=1::bw::418|420"
$ curl "http://localhost:8080/search/observations?a=1;2;3&c=1::bw::418|420"
```
### Greater than
......@@ -172,7 +172,7 @@ For example if the user wants to search all observations with ID greater than 42
Complete example with observations dataset:
```bash
curl "http://localhost:8080/search/observations?a=1;2;3&c=1::gt::424"
$ curl "http://localhost:8080/search/observations?a=1;2;3&c=1::gt::424"
```
### Greater than equal
......@@ -188,7 +188,7 @@ For example if the user wants to search all observations with ID greater than or
Complete example with observations dataset:
```bash
curl "http://localhost:8080/search/observations?a=1;2;3&c=1::gte::424"
$ curl "http://localhost:8080/search/observations?a=1;2;3&c=1::gte::424"
```
### Less than
......@@ -204,7 +204,7 @@ For example if the user wants to search all observations with ID less than 424:
Complete example with observations dataset:
```bash
curl "http://localhost:8080/search/observations?a=1;2;3&c=1::lt::424"
$ curl "http://localhost:8080/search/observations?a=1;2;3&c=1::lt::424"
```
### Less than equal
......@@ -220,7 +220,7 @@ For example if the user wants to search all observations with ID less than or eq
Complete example with observations dataset:
```bash
curl "http://localhost:8080/search/observations?a=1;2;3&c=1::lte::424"
$ curl "http://localhost:8080/search/observations?a=1;2;3&c=1::lte::424"
```
### Like
......@@ -236,7 +236,7 @@ For example if the user wants to search observations object name (M 15) which co
Complete example with observations dataset:
```bash
curl "http://localhost:8080/search/observations?a=1;2;3;7&c=7::lk::15"
$ curl "http://localhost:8080/search/observations?a=1;2;3;7&c=7::lk::15"
```
### Not like
......@@ -252,7 +252,7 @@ For example if the user wants to search observations object name which not conta
Complete example with observations dataset:
```bash
curl "http://localhost:8080/search/observations?a=1;2;3;7&c=7::nlk::15"
$ curl "http://localhost:8080/search/observations?a=1;2;3;7&c=7::nlk::15"
```
### In
......@@ -268,7 +268,7 @@ For example if the user wants to search observations number 418 and 419 and 420:
Complete example with observations dataset:
```bash
curl "http://localhost:8080/search/observations?a=1;2;3&c=1::in::418|419|420"
$ curl "http://localhost:8080/search/observations?a=1;2;3&c=1::in::418|419|420"
```
### Not in
......@@ -284,7 +284,7 @@ For example if the user wants to search observations which do not have the numbe
Complete example with observations dataset:
```bash
curl "http://localhost:8080/search/observations?a=1;2;3&c=1::nin::418|419|420"
$ curl "http://localhost:8080/search/observations?a=1;2;3&c=1::nin::418|419|420"
```
### Null
......@@ -300,7 +300,7 @@ For example if the user wants to search cards whose type is null:
Complete example with sp_cards dataset:
```bash
curl "http://localhost:8080/search/sp_cards?a=1;2;3;4;5;6&c=6::nl"
$ curl "http://localhost:8080/search/sp_cards?a=1;2;3;4;5;6&c=6::nl"
```
### Not null
......@@ -316,7 +316,7 @@ For example if the user wants to search cards whose type is not null:
Complete example with sp_cards dataset:
```bash
curl "http://localhost:8080/search/sp_cards?a=1;2;3;4;5;6&c=6::nnl"
$ curl "http://localhost:8080/search/sp_cards?a=1;2;3;4;5;6&c=6::nnl"
```
### Json
......@@ -332,7 +332,7 @@ For example if the user wants to search cards when the json_schema contains the
Complete example with sp_cards dataset:
```bash
curl "http://localhost:8080/search/sp_cards?a=1;2;3;4;5;6;7&c=7::js::name|eq|MXT-EVT-CAL"
$ curl "http://localhost:8080/search/sp_cards?a=1;2;3;4;5;6;7&c=7::js::name|eq|MXT-EVT-CAL"
```
## Cone-search (param cs)
......@@ -355,7 +355,7 @@ cs=322.5:12.167:100
Complete example with observations dataset:
```bash
curl "http://localhost:8080/search/observations?a=1;2;3&cs=322.5:12.167:100"
$ curl "http://localhost:8080/search/observations?a=1;2;3&cs=322.5:12.167:100"
```
Warning: For searching via a cone-search in a dataset the dataset config must contains cone-search parameters
......@@ -363,7 +363,7 @@ and flag cone-search enabled must be to true.
Example see `config->cone-search` for dataset observations:
```bash
curl "http://localhost:8080/dataset/observations"
$ curl "http://localhost:8080/dataset/observations"
```
## Order (param o)
......@@ -387,7 +387,7 @@ o=4:a;7:d
Complete example with observations dataset:
```bash
curl "http://localhost:8080/search/observations?a=1;2;3;4;5;6;7&o=4:a;7:d"
$ curl "http://localhost:8080/search/observations?a=1;2;3;4;5;6;7&o=4:a;7:d"
```
## Pagination (param p)
......@@ -411,7 +411,7 @@ Pagination requires ordering the result for example by observations ID.
Complete example with observations dataset:
```bash
curl "http://localhost:8080/search/observations?a=1;2;3&o=1:a&p=2:1"
$ curl "http://localhost:8080/search/observations?a=1;2;3&o=1:a&p=2:1"
```
## Result format
......@@ -429,26 +429,23 @@ The user can choose between 4 formats:
For example if the user wants all observations in csv format:
```bash
curl "http://localhost:8080/search/observations?a=1;2;3&f=csv"
$ curl "http://localhost:8080/search/observations?a=1;2;3&f=csv"
```
## Search trajectory parameter (param s: not of use for a search)
## Trajectory parameter (param s)
There is, for the client, an optional parameter `s`. The latter is used to check
on which step, the user is passed on `criteria`, `output` or `result` during a search through a dataset (1 if
passed, 0 if not).
For the client, an optional parameter `s` exists. The latter indicates on which step a user passed on. The steps `criteria`, `output` or `result` precisely.
While searching each step takes 1 if passed, 0 if not.
For instance, if the user passed through all of them while searching a dataset,
you will see in the search bar something like:
For instance, if the user passed through all them while searching a dataset, you should see in the search bar something like:
```
"http://localhost:4200/instance/default/search/result/observed_spectra?s=111&a=1;3;4;5;7;8;9;11"
```
If you stopped at the result table, you will see:
If you stopped at the result table, you should see:
```
"http://localhost:4200/instance/default/search/result/observed_spectra?s=110&a=1;3;4;5;7;8;9;11"
```
This parameter is _not of use for a search, and can be omitted safely_ while
performing a query. We mention it here, for the sake of completeness and
clarity.
This parameter is _not of use for a search, and can be omitted safely_ while performing a query.
This mention is made for the sake of completeness and clarity.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment