PHANTOM REPOSITORY server interface between different PHANTOM tools, storing files and the metadata related to them.
The purpose of the examples in this folder is to facilitate a low-level access to the Repository, both to upload Files and Metadata and to access the information stored there.
The examples here also aim to serve as an example of the authentication and authorization process based on tokens.
Here is shown the different available scripts. The parameters are filled with some values such the access path to the REPOSITORY as localhost:8000.
Please, replace the values of the parameters for the appropriate values in your case.
A video demonstration of this scripts is available at YOUTUBE CURL DEMO.
curl -s -H "Content-Type: text/plain" -XGET http://localhost:8000/login?email="montana@abc.com"\&pw="new" --output token.txt;
your_string_token=`cat token.txt;`;
curl -s -H "Authorization: OAuth ${your_string_token}" -XGET localhost:8000/verifytoken;
your_string_token=`cat token.txt;`;
curl -s -H "Authorization: OAuth ${your_string_token}" -H "Content-Type: multipart/form-data" -XPOST -F "UploadFile=@../web/example.h" -F "UploadJSON=@../web/exampleh.json" http://localhost:8000/upload?DestFileName=main.h\&'Path=mypath/';
Example of json file: exampleh.json
{
"project": "phantom_tools_on_HPC",
"source": "user",
"data_type":"Usercase",
"name":"HPC",
"content":"src_file"
}
NOTICE: The 'project' and the 'source' are defined in the json file. We provided them in this way instead as a parameter because these fields should remain for a tool working in a project.
Command for downloading:
your_string_token=`cat token.txt;`;
curl -s -H "Authorization: OAuth ${your_string_token}" -H "Content-Type: multipart/form-data" -XGET http://localhost:8000/download?project=phantom_tools_on_HPC\&source=user\&filepath=mypath\&filename=main.c ;
Command for downloading into a new local FILE:
your_string_token=`cat token.txt;`;
curl -s -H "Authorization: OAuth ${your_string_token}" -H "Content-Type: multipart/form-data" -XGET http://localhost:8000/download?project=phantom_tools_on_HPC\&source=user\&filepath=mypath\&filename=main.c --output main.c ;
The field project is MANDATORY, but the parameters source and filepath are optional
your_string_token=`cat token.txt;`;
curl -s -H "Authorization: OAuth ${your_string_token}" -H "Content-Type: multipart/form-data" -XGET http://localhost:8000/downloadlist?project=phantom_tools_on_HPC\&source=user\&filepath=mypath ;
DOWNLOAD INTO A SINGLE ZIP ALL THE FILES IN A FOLDER (PROJECT + SOURCE(optional) + FILEPATH (optional))
The field project is MANDATORY, but the parameters source and filepath are optional
your_string_token=`cat token.txt;`;
curl -s -H "Authorization: OAuth ${your_string_token}" -H "Content-Type: multipart/form-data" -XGET http://localhost:8000/downloadzip?project=phantom_tools_on_HPC\&source=user\&filepath=mypath --output demo.zip;
other example downloading the full project is:
your_string_token=`cat token.txt;`;
curl -s -H "Authorization: OAuth ${your_string_token}" -H "Content-Type: multipart/form-data" -XGET http://localhost:8000/downloadzip?project=phantom_tools_on_HPC --output demo2.zip;
Command for downloading METADATA for a path and a filename:
your_string_token=`cat token.txt;`;
curl -s -H "Authorization: OAuth ${your_string_token}" -XGET http://localhost:8000/query_metadata?project=phantom_tools_on_HPC\&source=user\&Path=mypath%2F\&filename=main.c;
Command for downloading METADATA for files in a path:
your_string_token=`cat token.txt;`;
curl -s -H "Authorization: OAuth ${your_string_token}" -XGET http://localhost:8000/query_metadata?project=phantom_tools_on_HPC\&source=user\&Path=mypath%2F ;
your_string_token=`cat token.txt;`;
curl -s -H "Authorization: OAuth ${your_string_token}" -H "Content-Type: multipart/form-data" -XPOST http://localhost:8000/delete_metadata?project=demo\&source=user\&DestFileName=main.h\&'Path=mypath/';
Here is shown the different available scripts. The parameters are filled with some values such the access path to the REPOSITORY as localhost:8000.
Please, replace the values of the parameters for the appropriate values in your case.
curl http://localhost:8000;
curl -s http://localhost:8000/verify_es_connection;
Commands for deleting ALL the uploaded files and drop the Metadata stored in the database. Please, keep the request of confirmation:
read -p $'Do you wish to \033[1;37mDELETE\033[1;34m the Repository \033[1;37mDB\033[1;34m? (y/n)' confirm; echo -ne "${NO_COLOUR}";
if [[ ! ${confirm} = "" ]]; then
if [ ${confirm} == 'y' ] || [ ${confirm} == 'Y' ];then
curl -s -XGET http://localhost:8000/drop_db ;
fi;
fi;
This command prepares the system for running the users' scripts described below. This command creates the required structure in the database for storing the Metadata:
curl -s -XGET http://localhost:8000/new_db;
This command registers a new user and its password:
curl -s -H "Content-Type: application/json" -XPOST http://localhost:8000/signup?email="montana@abc.com"\&pw="new";
curl -s -XGET http://localhost:8000/_flush > /dev/null;
This project is realized through PHANTOM. The PHANTOM project receives funding under the European Union's Horizon 2020 Research and Innovation Programme under grant agreement number 688146.
Find a bug? Have a feature request? Please create an issue.
Montanana, Jose Miguel, HLRS
Cheptsov, Alexey, HLRS
Date | Version | Comment |
---|---|---|
2018-03-22 | 1.0 | First prototype |
Copyright (C) 2018 University of Stuttgart