diff --git a/README.md b/README.md index b1de0e9..98d4322 100644 --- a/README.md +++ b/README.md @@ -2,26 +2,155 @@ This project presents a Flask-based API for validating RO-Crates. -## Project Structure +## API +#### Request Validation of RO-Crate + +
+ POST v1/ro_crates/{crate_id}/validation (Request validation of RO-Crate validation in Object Store) + +##### Path Parameters + +| name | type | data type | description | +|------------|-----------|-------------------------|-----------------------------------------------------------------------| +| crate_id | required | string | RO-Crate identifer string | + +##### Parameters + +| name | type | data type | description | +|------------|-----------|-------------------------|-----------------------------------------------------------------------| +| root_path | optional | string | Root path which contains the RO-Crate | +| webhook_url | optional | string | Webhook to send validation result to | +| minio_config | required | dictionary | MinIO Configuration Details | + +`minio_config` +> | name | type | data type | description | +> |------------|-----------|-------------------------|-----------------------------------------------------------------------| +> | endpoint | required | string | MinIO endpoint | +> | accesskey | required | string | MinIO access key or username | +> | secret | required | string | MinIO secret or password | +> | ssl | required | boolean | Use SSL encryption for MinIO access? | +> | bucket | required | string | MinIO bucket containing RO-Crate | + +##### Responses + +| http code | content-type | response | +|---------------|-----------------------------------|---------------------------------------------------------------------| +| `202` | `application/json` | `{"message": "Validation in progress"}` | +| `400` | `application/json` | `{"message": "No RO-Crate with prefix: "}` | +| `500` | `application/json` | `{"message": "Internal server errors"}` | + +```javascript +curl -X 'POST' \ + 'http://localhost:5001/v1/ro_crates//validation' \ + -H 'accept: application/json' \ + -H 'Content-Type: application/json' \ + -d '{ + "minio_config": { + "accesskey": "", + "bucket": "ro-crates", + "endpoint": "minio:9000", + "secret": "", + "ssl": false + }, + "profile_name": "", + "webhook_url": "" +}' ``` -app/ -├── ro_crates/ -│ ├── routes/ -│ │ ├── __init__.py # Registers blueprints -│ │ └── post_routes.py # POST API routes -│ └── __init__.py -├── services/ -│ ├── logging_service.py # Centralised logging -│ └── validation_service.py # Queue RO-Crates for validation -├── tasks/ -│ └── validation_tasks.py # Validate RO-Crates -├── utils/ -│ ├── config.py # Configuration -│ ├── minio_utils.py # Methods for interacting with MinIO -│ └── webhook_utils.py # Methods for sending webhooks + +
+ + +#### Get RO-Crate Validation Result + +
+ GET v1/ro_crates/{crate_id}/validation (Obtain RO-Crate validation result from Object Store) + +##### Path Parameters + +| name | type | data type | description | +|------------|-----------|-------------------------|-----------------------------------------------------------------------| +| crate_id | required | string | RO-Crate identifer string | + +##### Parameters + +| name | type | data type | description | +|------------|-----------|-------------------------|-----------------------------------------------------------------------| +| root_path | optional | string | Root path which contains the RO-Crate | +| minio_config | required | dictionary | MinIO Configuration Details | + +`minio_config` +> | name | type | data type | description | +> |------------|-----------|-------------------------|-----------------------------------------------------------------------| +> | endpoint | required | string | MinIO endpoint | +> | accesskey | required | string | MinIO access key or username | +> | secret | required | string | MinIO secret or password | +> | ssl | required | boolean | Use SSL encryption for MinIO access? | +> | bucket | required | string | MinIO bucket containing RO-Crate | + +##### Responses + +| http code | content-type | response | +|---------------|-----------------------------------|---------------------------------------------------------------------| +| `200` | `application/json` | `Successful Validation` | +| `422` | `application/json` | `Error: Details of Validation Error` | +| `404` | `application/json` | `Not found` | + +##### Example cURL + +```javascript + curl -X 'GET' \ + 'http://localhost:5001/v1/ro_crates//validation' \ + -H 'accept: application/json' \ + -H 'Content-Type: application/json' \ + -d '{ + "minio_config": { + "accesskey": "", + "bucket": "ro-crates", + "endpoint": "minio:9000", + "secret": "", + "ssl": false + } +}' +``` + +
+ +#### Validate RO-Crate Metadata + +
+ POST v1/ro_crates/validate_metadata (validates submitted RO-Crate Metadata) + +##### Parameters + +| name | type | data type | description | +|------------|-----------|-------------------------|-----------------------------------------------------------------------| +| crate_json | required | string | RO-Crate metadata, stored as a single string | +| profile_name | optional | string | RO-Crate profile to validate against | + + +##### Responses + +| http code | content-type | response | +|---------------|-----------------------------------|---------------------------------------------------------------------| +| `200` | `application/json` | `Successful Validation` | +| `422` | `application/json` | `Error: Details of Validation Error` | + +##### Example cURL + +```javascript + curl -X 'POST' \ + 'http://localhost:5001/v1/ro_crates/validate_metadata' \ + -H 'accept: application/json' \ + -H 'Content-Type: application/json' \ + -d '{ + "crate_json": "{'\''test1'\'':'\''test2'\''}" + }' ``` +
+ + ## Setting up the project ### Prerequisites @@ -68,22 +197,22 @@ For testing locally developed containers use the alternate Docker Compose file: docker compose --file docker-compose-develop.yml up --build ``` -## Example Usage +### Project Structure -Submission of validation of RO-Crate with the ID of `ro_crate_1`. No webhook is used here: -```bash -curl -X 'POST' \ - 'http://localhost:5001/ro_crates/v1/ro_crate_1/validation' \ - -H 'accept: application/json' \ - -H 'Content-Type: application/json' \ - -d '{}' -``` - -Retrieval of validation result for RO-Crate `ro_crate_1`: -```bash -curl -X 'GET' \ - 'http://localhost:5001/ro_crates/v1/ro_crate_1/validation' \ - -H 'accept: application/json' \ - -H 'Content-Type: application/json' \ - -d '{}' ``` +app/ +├── ro_crates/ +│ ├── routes/ +│ │ ├── __init__.py # Registers blueprints +│ │ └── post_routes.py # POST API routes +│ └── __init__.py +├── services/ +│ ├── logging_service.py # Centralised logging +│ └── validation_service.py # Queue RO-Crates for validation +├── tasks/ +│ └── validation_tasks.py # Validate RO-Crates +├── utils/ +│ ├── config.py # Configuration +│ ├── minio_utils.py # Methods for interacting with MinIO +│ └── webhook_utils.py # Methods for sending webhooks +``` \ No newline at end of file diff --git a/requirements.in b/requirements.in index 79fd9f4..a2e7a54 100644 --- a/requirements.in +++ b/requirements.in @@ -1,7 +1,7 @@ celery==5.5.3 minio==7.2.16 -requests==2.32.4 -Flask==3.0.3 +requests==2.32.5 +Flask==3.1.2 Werkzeug==3.1.3 redis==6.4.0 python-dotenv==1.1.1 diff --git a/requirements.txt b/requirements.txt index 8ddc396..13fd7ef 100644 --- a/requirements.txt +++ b/requirements.txt @@ -53,7 +53,7 @@ colorlog==6.9.0 # via roc-validator enum-tools==0.12.0 # via roc-validator -flask==3.0.3 +flask==3.1.2 # via # -r requirements.in # apiflask @@ -83,6 +83,7 @@ markdown-it-py==3.0.0 # via rich markupsafe==3.0.2 # via + # flask # jinja2 # werkzeug marshmallow==4.0.0 @@ -135,7 +136,7 @@ rdflib[html]==7.1.4 # roc-validator redis==6.4.0 # via -r requirements.in -requests==2.32.4 +requests==2.32.5 # via # -r requirements.in # requests-cache