From 2ffda43f7cec891cba71f3d868350018148adb48 Mon Sep 17 00:00:00 2001 From: Martin Weise <martin.weise@tuwien.ac.at> Date: Fri, 19 Jan 2024 10:44:45 +0100 Subject: [PATCH] Updated documentation --- .docs/.swagger/api-analyse.yaml | 103 ++- .docs/.swagger/api-metadata.yaml | 784 +++++++++--------- .docs/.swagger/api-search.yaml | 169 +++- .docs/deployment-docker-compose.md | 60 +- .docs/system-services-search.md | 2 +- .docs/usage-overview.md | 104 ++- dbrepo-analyse-service/app.py | 22 +- .../as-yml/determine_stat.yml | 52 ++ .../as-yml/determine_stats.yml | 24 + dbrepo-analyse-service/as-yml/determinedt.yml | 44 +- dbrepo-analyse-service/as-yml/determinepk.yml | 34 +- dbrepo-analyse-service/as-yml/health.yml | 25 +- dbrepo-search-service/README.md | 35 +- dbrepo-search-service/app/__init__.py | 2 +- dbrepo-search-service/app/api/routes.py | 8 +- dbrepo-search-service/us-yml/get_column.yml | 53 -- dbrepo-search-service/us-yml/get_columns.yml | 31 - dbrepo-search-service/us-yml/get_database.yml | 38 - .../us-yml/get_database_table.yml | 59 -- .../us-yml/get_database_table_column.yml | 63 -- .../us-yml/get_database_table_columns.yml | 42 - .../us-yml/get_database_tables.yml | 40 - .../us-yml/get_databases.yml | 31 - dbrepo-search-service/us-yml/get_fields.yml | 37 + .../us-yml/get_identifier.yml | 57 -- .../us-yml/get_identifiers.yml | 31 - dbrepo-search-service/us-yml/get_table.yml | 54 -- dbrepo-search-service/us-yml/get_tables.yml | 34 - dbrepo-search-service/us-yml/get_user.yml | 0 dbrepo-search-service/us-yml/get_users.yml | 0 .../us-yml/post_fuzzy_search.yml | 31 + .../us-yml/post_general_search.yml | 50 ++ dbrepo-search-service/us-yml/post_search.yml | 84 -- mkdocs.yml | 1 + 34 files changed, 1046 insertions(+), 1158 deletions(-) create mode 100644 dbrepo-analyse-service/as-yml/determine_stat.yml create mode 100644 dbrepo-analyse-service/as-yml/determine_stats.yml delete mode 100644 dbrepo-search-service/us-yml/get_column.yml delete mode 100644 dbrepo-search-service/us-yml/get_columns.yml delete mode 100644 dbrepo-search-service/us-yml/get_database.yml delete mode 100644 dbrepo-search-service/us-yml/get_database_table.yml delete mode 100644 dbrepo-search-service/us-yml/get_database_table_column.yml delete mode 100644 dbrepo-search-service/us-yml/get_database_table_columns.yml delete mode 100644 dbrepo-search-service/us-yml/get_database_tables.yml delete mode 100644 dbrepo-search-service/us-yml/get_databases.yml create mode 100644 dbrepo-search-service/us-yml/get_fields.yml delete mode 100644 dbrepo-search-service/us-yml/get_identifier.yml delete mode 100644 dbrepo-search-service/us-yml/get_identifiers.yml delete mode 100644 dbrepo-search-service/us-yml/get_table.yml delete mode 100644 dbrepo-search-service/us-yml/get_tables.yml delete mode 100644 dbrepo-search-service/us-yml/get_user.yml delete mode 100644 dbrepo-search-service/us-yml/get_users.yml create mode 100644 dbrepo-search-service/us-yml/post_fuzzy_search.yml create mode 100644 dbrepo-search-service/us-yml/post_general_search.yml delete mode 100644 dbrepo-search-service/us-yml/post_search.yml diff --git a/.docs/.swagger/api-analyse.yaml b/.docs/.swagger/api-analyse.yaml index 4ec0ed6e72..d40208256c 100644 --- a/.docs/.swagger/api-analyse.yaml +++ b/.docs/.swagger/api-analyse.yaml @@ -48,6 +48,8 @@ paths: '405': description: Invalid input summary: Determine datatypes + tags: + - analyse-endpoint /api/analyse/determinepk: post: consumes: @@ -76,30 +78,109 @@ paths: '405': description: Invalid input summary: Determine primary keys + tags: + - analyse-endpoint + /api/analyse/determinestat: + post: + operationId: determinestat + requestBody: + content: + application/json: + schema: + properties: + database_id: + example: 1 + type: integer + table_id: + example: 1 + type: integer + required: + - database_id + - table_id + type: object + responses: + '200': + content: + application/json: + schema: + properties: + message: + example: Analysed statistical properties + type: string + status: + example: '200' + type: integer + required: + - message + - status + type: object + description: Determined statistics + '400': + description: Invalid input + ontent: + application/json: + schema: + properties: + message: + example: Analysed statistical properties + type: string + status: + example: '200' + type: integer + required: + - message + - status + type: object + summary: Determine statistics + tags: + - analyse-endpoint + /api/analyse/determinestats: + post: + operationId: determinestats + requestBody: + content: + application/json: + schema: + properties: + filepath: + example: file.csv + type: string + separator: + example: ',' + type: string + required: + - filepath + - separator + type: object + responses: + '200': + description: Determined statistics + '400': + description: Invalid input + summary: Determine statistics + tags: + - analyse-endpoint /health: get: consumes: - application/json description: This is a simple API which checks if the application is healthy - parameters: - - description: to-do description - in: body - name: body - required: true + produces: + - application/json + responses: + '200': + description: OK schema: properties: status: example: UP type: string type: object - produces: - - application/json - responses: - '200': - description: OK summary: Check if application is running + tags: + - health-endpoint servers: - description: Generated server url url: http://localhost:5000 - description: Sandbox - url: https://dbrepo2.tuwien.ac.at + url: https://test.dbrepo.tuwien.ac.at diff --git a/.docs/.swagger/api-metadata.yaml b/.docs/.swagger/api-metadata.yaml index 55cafa0239..ee2919a16e 100644 --- a/.docs/.swagger/api-metadata.yaml +++ b/.docs/.swagger/api-metadata.yaml @@ -44,14 +44,16 @@ paths: application/json: schema: $ref: '#/components/schemas/ApiErrorDto' - "403": - description: Find table history is not permitted + "200": + description: Find table history successfully content: application/json: schema: - $ref: '#/components/schemas/ApiErrorDto' - "409": - description: Query store failed to query table history + type: array + items: + $ref: '#/components/schemas/TableHistoryDto' + "403": + description: Find table history is not permitted content: application/json: schema: @@ -62,14 +64,12 @@ paths: application/json: schema: $ref: '#/components/schemas/ApiErrorDto' - "200": - description: Find table history successfully + "409": + description: Query store failed to query table history content: application/json: schema: - type: array - items: - $ref: '#/components/schemas/TableHistoryDto' + $ref: '#/components/schemas/ApiErrorDto' security: - bearerAuth: [] head: @@ -97,14 +97,16 @@ paths: application/json: schema: $ref: '#/components/schemas/ApiErrorDto' - "403": - description: Find table history is not permitted + "200": + description: Find table history successfully content: application/json: schema: - $ref: '#/components/schemas/ApiErrorDto' - "409": - description: Query store failed to query table history + type: array + items: + $ref: '#/components/schemas/TableHistoryDto' + "403": + description: Find table history is not permitted content: application/json: schema: @@ -115,14 +117,12 @@ paths: application/json: schema: $ref: '#/components/schemas/ApiErrorDto' - "200": - description: Find table history successfully + "409": + description: Query store failed to query table history content: application/json: schema: - type: array - items: - $ref: '#/components/schemas/TableHistoryDto' + $ref: '#/components/schemas/ApiErrorDto' security: - bearerAuth: [] /api/database/{databaseId}/table/{tableId}/data: @@ -176,6 +176,12 @@ paths: schema: type: string responses: + "422": + description: Could not import csv via sidecar + content: + application/json: + schema: + $ref: '#/components/schemas/ApiErrorDto' "403": description: Access to the database is forbidden content: @@ -200,12 +206,6 @@ paths: application/json: schema: $ref: '#/components/schemas/ApiErrorDto' - "422": - description: Could not import csv via sidecar - content: - application/json: - schema: - $ref: '#/components/schemas/ApiErrorDto' security: - bearerAuth: [] post: @@ -233,20 +233,14 @@ paths: $ref: '#/components/schemas/TableCsvDto' required: true responses: - "403": - description: Access to the database is forbidden - content: - application/json: - schema: - $ref: '#/components/schemas/ApiErrorDto' "202": description: Inserted data successfully content: '*/*': schema: type: object - "400": - description: Insert table data is malformed + "403": + description: Access to the database is forbidden content: application/json: schema: @@ -257,6 +251,12 @@ paths: application/json: schema: $ref: '#/components/schemas/ApiErrorDto' + "400": + description: Insert table data is malformed + content: + application/json: + schema: + $ref: '#/components/schemas/ApiErrorDto' security: - bearerAuth: [] delete: @@ -286,20 +286,20 @@ paths: responses: "202": description: Deleted table data successfully - "403": - description: Access to the database is forbidden + "400": + description: Table data or query is malformed content: application/json: schema: $ref: '#/components/schemas/ApiErrorDto' - "404": - description: Table or database could not be found + "403": + description: Access to the database is forbidden content: application/json: schema: $ref: '#/components/schemas/ApiErrorDto' - "400": - description: Table data or query is malformed + "404": + description: Table or database could not be found content: application/json: schema: @@ -356,6 +356,12 @@ paths: schema: type: string responses: + "422": + description: Could not import csv via sidecar + content: + application/json: + schema: + $ref: '#/components/schemas/ApiErrorDto' "403": description: Access to the database is forbidden content: @@ -380,12 +386,6 @@ paths: application/json: schema: $ref: '#/components/schemas/ApiErrorDto' - "422": - description: Could not import csv via sidecar - content: - application/json: - schema: - $ref: '#/components/schemas/ApiErrorDto' security: - bearerAuth: [] /api/user/{id}: @@ -441,32 +441,32 @@ paths: $ref: '#/components/schemas/UserUpdateDto' required: true responses: - "202": - description: Modified user information - content: - application/json: - schema: - $ref: '#/components/schemas/UserDto' "404": description: User attribute was not found content: application/json: schema: $ref: '#/components/schemas/ApiErrorDto' + "202": + description: Modified user information + content: + application/json: + schema: + $ref: '#/components/schemas/UserDto' "403": description: Modify user is not permitted content: application/json: schema: $ref: '#/components/schemas/ApiErrorDto' - "405": - description: Foreign user modification + "400": + description: Modify user query is malformed content: application/json: schema: $ref: '#/components/schemas/ApiErrorDto' - "400": - description: Modify user query is malformed + "405": + description: Foreign user modification content: application/json: schema: @@ -493,12 +493,6 @@ paths: $ref: '#/components/schemas/UserThemeSetDto' required: true responses: - "404": - description: User or user attribute was not found - content: - application/json: - schema: - $ref: '#/components/schemas/ApiErrorDto' "403": description: Modify user is not permitted content: @@ -511,6 +505,12 @@ paths: application/json: schema: $ref: '#/components/schemas/UserDto' + "404": + description: User or user attribute was not found + content: + application/json: + schema: + $ref: '#/components/schemas/ApiErrorDto' "405": description: Foreign user modification content: @@ -539,14 +539,8 @@ paths: $ref: '#/components/schemas/UserPasswordDto' required: true responses: - "202": - description: Modified user password - content: - application/json: - schema: - $ref: '#/components/schemas/UserDto' - "405": - description: Foreign user modification + "503": + description: Authentication service does not respond content: application/json: schema: @@ -557,14 +551,20 @@ paths: application/json: schema: $ref: '#/components/schemas/ApiErrorDto' + "202": + description: Modified user password + content: + application/json: + schema: + $ref: '#/components/schemas/UserDto' "403": description: Modify is not allowed content: application/json: schema: $ref: '#/components/schemas/ApiErrorDto' - "503": - description: Authentication service does not respond + "405": + description: Foreign user modification content: application/json: schema: @@ -585,18 +585,18 @@ paths: type: integer format: int64 responses: - "404": - description: Could not find ontology - content: - application/json: - schema: - $ref: '#/components/schemas/ApiErrorDto' "200": description: Find one ontology content: application/json: schema: $ref: '#/components/schemas/OntologyDto' + "404": + description: Could not find ontology + content: + application/json: + schema: + $ref: '#/components/schemas/ApiErrorDto' put: tags: - ontology-endpoint @@ -616,18 +616,18 @@ paths: $ref: '#/components/schemas/OntologyModifyDto' required: true responses: - "202": - description: Updated ontology successfully - content: - application/json: - schema: - $ref: '#/components/schemas/OntologyDto' "404": description: Could not find ontology content: application/json: schema: $ref: '#/components/schemas/ApiErrorDto' + "202": + description: Updated ontology successfully + content: + application/json: + schema: + $ref: '#/components/schemas/OntologyDto' security: - bearerAuth: [] delete: @@ -643,16 +643,16 @@ paths: type: integer format: int64 responses: - "202": - description: Deleted ontology successfully - content: - application/json: {} "404": description: Could not find ontology content: application/json: schema: $ref: '#/components/schemas/ApiErrorDto' + "202": + description: Deleted ontology successfully + content: + application/json: {} security: - bearerAuth: [] /api/maintenance/message/{id}: @@ -837,12 +837,6 @@ paths: $ref: '#/components/schemas/DatabaseModifyVisibilityDto' required: true responses: - "404": - description: Database could not be found - content: - application/json: - schema: - $ref: '#/components/schemas/ApiErrorDto' "403": description: Visibility modification is not permitted content: @@ -855,6 +849,12 @@ paths: application/json: schema: $ref: '#/components/schemas/DatabaseDto' + "404": + description: Database could not be found + content: + application/json: + schema: + $ref: '#/components/schemas/ApiErrorDto' security: - bearerAuth: [] /api/database/{id}/transfer: @@ -883,18 +883,18 @@ paths: application/json: schema: $ref: '#/components/schemas/ApiErrorDto' - "202": - description: Transfer of ownership was successful - content: - application/json: - schema: - $ref: '#/components/schemas/DatabaseDto' "403": description: Transfer of ownership is not permitted content: application/json: schema: $ref: '#/components/schemas/ApiErrorDto' + "202": + description: Transfer of ownership was successful + content: + application/json: + schema: + $ref: '#/components/schemas/DatabaseDto' security: - bearerAuth: [] /api/database/{id}/table/{tableId}/column/{columnId}: @@ -934,21 +934,15 @@ paths: $ref: '#/components/schemas/ColumnSemanticsUpdateDto' required: true responses: - "403": - description: Access to the database is forbidden - content: - application/json: - schema: - $ref: '#/components/schemas/ApiErrorDto' - "404": - description: Table or database could not be found + "400": + description: Update semantic concept query is malformed or update unit of + measurement query is malformed content: application/json: schema: $ref: '#/components/schemas/ApiErrorDto' - "400": - description: Update semantic concept query is malformed or update unit of - measurement query is malformed + "403": + description: Access to the database is forbidden content: application/json: schema: @@ -959,6 +953,12 @@ paths: application/json: schema: $ref: '#/components/schemas/ColumnDto' + "404": + description: Table or database could not be found + content: + application/json: + schema: + $ref: '#/components/schemas/ApiErrorDto' security: - bearerAuth: [] /api/database/{id}/access/{userId}: @@ -987,27 +987,27 @@ paths: $ref: '#/components/schemas/DatabaseModifyAccessDto' required: true responses: - "403": - description: Modify access not permitted when no access is granted in the - first place + "400": + description: Modify access query or database connection is malformed content: application/json: schema: $ref: '#/components/schemas/ApiErrorDto' - "400": - description: Modify access query or database connection is malformed + "403": + description: Modify access not permitted when no access is granted in the + first place content: application/json: schema: $ref: '#/components/schemas/ApiErrorDto' - "202": - description: Modify access succeeded "404": description: Database or user not found content: application/json: schema: $ref: '#/components/schemas/ApiErrorDto' + "202": + description: Modify access succeeded security: - bearerAuth: [] post: @@ -1041,12 +1041,6 @@ paths: application/json: schema: $ref: '#/components/schemas/ApiErrorDto' - "405": - description: Granting access not permitted - content: - application/json: - schema: - $ref: '#/components/schemas/ApiErrorDto' "202": description: Granting access succeeded "404": @@ -1055,6 +1049,12 @@ paths: application/json: schema: $ref: '#/components/schemas/ApiErrorDto' + "405": + description: Granting access not permitted + content: + application/json: + schema: + $ref: '#/components/schemas/ApiErrorDto' "400": description: Granting access query or database connection is malformed content: @@ -1094,14 +1094,14 @@ paths: application/json: schema: $ref: '#/components/schemas/ApiErrorDto' - "202": - description: Revoked access successfully "403": description: Revoke of access not permitted as no access was found content: application/json: schema: $ref: '#/components/schemas/ApiErrorDto' + "202": + description: Revoked access successfully security: - bearerAuth: [] /api/database/{databaseId}/query/{queryId}: @@ -1124,20 +1124,20 @@ paths: type: integer format: int64 responses: - "501": - description: Image is not supported + "404": + description: "Database, query or user could not be found" content: application/json: schema: $ref: '#/components/schemas/ApiErrorDto' - "504": - description: Query store failed to select query + "405": + description: Find query is not permitted content: application/json: schema: $ref: '#/components/schemas/ApiErrorDto' - "404": - description: "Database, query or user could not be found" + "503": + description: Connection to the database failed content: application/json: schema: @@ -1148,14 +1148,14 @@ paths: application/json: schema: $ref: '#/components/schemas/QueryDto' - "503": - description: Connection to the database failed + "501": + description: Image is not supported content: application/json: schema: $ref: '#/components/schemas/ApiErrorDto' - "405": - description: Find query is not permitted + "504": + description: Query store failed to select query content: application/json: schema: @@ -1187,20 +1187,20 @@ paths: $ref: '#/components/schemas/QueryPersistDto' required: true responses: - "412": - description: Query is already persisted + "400": + description: Image not supported content: application/json: schema: $ref: '#/components/schemas/ApiErrorDto' - "403": - description: Not allowed to persist query + "404": + description: "Database, query or user could not be found" content: application/json: schema: $ref: '#/components/schemas/ApiErrorDto' - "400": - description: Image not supported + "403": + description: Not allowed to persist query content: application/json: schema: @@ -1211,8 +1211,8 @@ paths: application/json: schema: $ref: '#/components/schemas/ApiErrorDto' - "404": - description: "Database, query or user could not be found" + "412": + description: Query is already persisted content: application/json: schema: @@ -1252,12 +1252,18 @@ paths: $ref: '#/components/schemas/SignupRequestDto' required: true responses: + "201": + description: Created user + content: + application/json: + schema: + $ref: '#/components/schemas/UserBriefDto' "400": description: Parameters are not well-formed (likely email) content: application/json: {} - "404": - description: default role not found + "417": + description: User with e-mail already exists content: application/json: schema: @@ -1268,18 +1274,12 @@ paths: application/json: schema: $ref: '#/components/schemas/ApiErrorDto' - "417": - description: User with e-mail already exists + "404": + description: default role not found content: application/json: schema: $ref: '#/components/schemas/ApiErrorDto' - "201": - description: Created user - content: - application/json: - schema: - $ref: '#/components/schemas/UserBriefDto' /api/semantic/ontology: get: tags: @@ -1375,12 +1375,6 @@ paths: $ref: '#/components/schemas/ImageCreateDto' required: true responses: - "400": - description: Image specification is invalid - content: - application/json: - schema: - $ref: '#/components/schemas/ApiErrorDto' "201": description: Created image content: @@ -1393,6 +1387,12 @@ paths: application/json: schema: $ref: '#/components/schemas/ApiErrorDto' + "400": + description: Image specification is invalid + content: + application/json: + schema: + $ref: '#/components/schemas/ApiErrorDto' security: - bearerAuth: [] /api/identifier: @@ -1457,20 +1457,14 @@ paths: $ref: '#/components/schemas/IdentifierSaveDto' required: true responses: - "201": - description: Created identifier - content: - application/json: - schema: - $ref: '#/components/schemas/IdentifierDto' - "409": - description: Identifier for this resource already exists + "502": + description: Query information could not be retrieved content: application/json: schema: $ref: '#/components/schemas/ApiErrorDto' - "503": - description: DataCite system did not respond + "405": + description: Creating identifier not permitted content: application/json: schema: @@ -1481,14 +1475,14 @@ paths: application/json: schema: $ref: '#/components/schemas/ApiErrorDto' - "502": - description: Query information could not be retrieved + "406": + description: Creating identifier not allowed content: application/json: schema: $ref: '#/components/schemas/ApiErrorDto' - "406": - description: Creating identifier not allowed + "400": + description: Identifier form contains invalid request data content: application/json: schema: @@ -1499,18 +1493,24 @@ paths: application/json: schema: $ref: '#/components/schemas/ApiErrorDto' - "400": - description: Identifier form contains invalid request data + "503": + description: DataCite system did not respond content: application/json: schema: $ref: '#/components/schemas/ApiErrorDto' - "405": - description: Creating identifier not permitted + "409": + description: Identifier for this resource already exists content: application/json: schema: $ref: '#/components/schemas/ApiErrorDto' + "201": + description: Created identifier + content: + application/json: + schema: + $ref: '#/components/schemas/IdentifierDto' "403": description: Insufficient access rights or authorities content: @@ -1558,9 +1558,8 @@ paths: $ref: '#/components/schemas/DatabaseCreateDto' required: true responses: - "403": - description: Database create permission is missing or grant permissions - at broker service failed + "503": + description: Connection to the database failed content: application/json: schema: @@ -1571,24 +1570,25 @@ paths: application/json: schema: $ref: '#/components/schemas/ApiErrorDto' - "201": - description: Created a new database + "400": + description: Database create query is malformed or image is not supported content: application/json: schema: - $ref: '#/components/schemas/DatabaseBriefDto' - "503": - description: Connection to the database failed + $ref: '#/components/schemas/ApiErrorDto' + "403": + description: Database create permission is missing or grant permissions + at broker service failed content: application/json: schema: $ref: '#/components/schemas/ApiErrorDto' - "400": - description: Database create query is malformed or image is not supported + "201": + description: Created a new database content: application/json: schema: - $ref: '#/components/schemas/ApiErrorDto' + $ref: '#/components/schemas/DatabaseBriefDto' "404": description: "Container, user or database could not be found" content: @@ -1609,6 +1609,12 @@ paths: schema: type: string responses: + "404": + description: User not found + content: + application/json: + schema: + $ref: '#/components/schemas/ApiErrorDto' "200": description: Count databases content: @@ -1617,12 +1623,6 @@ paths: type: array items: $ref: '#/components/schemas/DatabaseDto' - "404": - description: User not found - content: - application/json: - schema: - $ref: '#/components/schemas/ApiErrorDto' /api/database/{databaseId}/view: get: tags: @@ -1672,50 +1672,50 @@ paths: $ref: '#/components/schemas/ViewCreateDto' required: true responses: - "423": - description: Create view resulted in an invalid query statement + "403": + description: Credentials missing content: application/json: schema: $ref: '#/components/schemas/ApiErrorDto' - "201": - description: Create view successfully + "404": + description: Database or user could not be found content: application/json: schema: - $ref: '#/components/schemas/ViewBriefDto' - "403": - description: Credentials missing + $ref: '#/components/schemas/ApiErrorDto' + "405": + description: Create view is not permitted content: application/json: schema: $ref: '#/components/schemas/ApiErrorDto' - "401": - description: Credentials missing + "201": + description: Create view successfully content: application/json: schema: - $ref: '#/components/schemas/ApiErrorDto' + $ref: '#/components/schemas/ViewBriefDto' "503": description: Connection to the database failed content: application/json: schema: $ref: '#/components/schemas/ApiErrorDto' - "404": - description: Database or user could not be found + "401": + description: Credentials missing content: application/json: schema: $ref: '#/components/schemas/ApiErrorDto' - "405": - description: Create view is not permitted + "400": + description: Create view query is malformed content: application/json: schema: $ref: '#/components/schemas/ApiErrorDto' - "400": - description: Create view query is malformed + "423": + description: Create view resulted in an invalid query statement content: application/json: schema: @@ -1777,12 +1777,12 @@ paths: $ref: '#/components/schemas/TableCreateDto' required: true responses: - "404": - description: "Database, container or user could not be found" + "201": + description: Created a new table content: application/json: schema: - $ref: '#/components/schemas/ApiErrorDto' + $ref: '#/components/schemas/TableBriefDto' "409": description: Create table conflicts with existing table name content: @@ -1795,12 +1795,12 @@ paths: application/json: schema: $ref: '#/components/schemas/ApiErrorDto' - "201": - description: Created a new table + "404": + description: "Database, container or user could not be found" content: application/json: schema: - $ref: '#/components/schemas/TableBriefDto' + $ref: '#/components/schemas/ApiErrorDto' "403": description: Create table not permitted content: @@ -1837,20 +1837,20 @@ paths: responses: "202": description: Import table data successfully - "403": - description: Access to the database is forbidden + "422": + description: Could not import csv via sidecar content: application/json: schema: $ref: '#/components/schemas/ApiErrorDto' - "404": - description: Table or database could not be found + "403": + description: Access to the database is forbidden content: application/json: schema: $ref: '#/components/schemas/ApiErrorDto' - "422": - description: Could not import csv via sidecar + "404": + description: Table or database could not be found content: application/json: schema: @@ -1882,8 +1882,16 @@ paths: schema: type: boolean responses: - "404": - description: "Database, container or user could not be found" + "200": + description: List queries + content: + application/json: + schema: + type: array + items: + $ref: '#/components/schemas/QueryBriefDto' + "405": + description: Find all queries is not permitted content: application/json: schema: @@ -1895,14 +1903,12 @@ paths: application/json: schema: $ref: '#/components/schemas/ApiErrorDto' - "200": - description: List queries + "503": + description: Connection to the database failed content: application/json: schema: - type: array - items: - $ref: '#/components/schemas/QueryBriefDto' + $ref: '#/components/schemas/ApiErrorDto' "501": description: Image is not supported content: @@ -1915,14 +1921,8 @@ paths: application/json: schema: $ref: '#/components/schemas/ApiErrorDto' - "503": - description: Connection to the database failed - content: - application/json: - schema: - $ref: '#/components/schemas/ApiErrorDto' - "405": - description: Find all queries is not permitted + "404": + description: "Database, container or user could not be found" content: application/json: schema: @@ -1973,14 +1973,8 @@ paths: $ref: '#/components/schemas/ExecuteStatementDto' required: true responses: - "400": - description: Image is not supported - content: - application/json: - schema: - $ref: '#/components/schemas/ApiErrorDto' - "409": - description: Could not store query in query store + "404": + description: "Database, query or user could not be found" content: application/json: schema: @@ -1991,8 +1985,8 @@ paths: application/json: schema: $ref: '#/components/schemas/QueryResultDto' - "404": - description: "Database, query or user could not be found" + "400": + description: Image is not supported content: application/json: schema: @@ -2009,6 +2003,12 @@ paths: application/json: schema: $ref: '#/components/schemas/ApiErrorDto' + "409": + description: Could not store query in query store + content: + application/json: + schema: + $ref: '#/components/schemas/ApiErrorDto' security: - bearerAuth: [] /api/container: @@ -2045,6 +2045,12 @@ paths: $ref: '#/components/schemas/ContainerCreateRequestDto' required: true responses: + "404": + description: Container image or user could not be found + content: + application/json: + schema: + $ref: '#/components/schemas/ApiErrorDto' "201": description: Created a new container content: @@ -2057,12 +2063,6 @@ paths: application/json: schema: $ref: '#/components/schemas/ApiErrorDto' - "404": - description: Container image or user could not be found - content: - application/json: - schema: - $ref: '#/components/schemas/ApiErrorDto' security: - bearerAuth: [] /api/semantic/unit: @@ -2104,28 +2104,28 @@ paths: schema: type: string responses: - "417": - description: Generated query or uri is malformed + "404": + description: Could not find ontology content: application/json: schema: $ref: '#/components/schemas/ApiErrorDto' - "200": - description: Found entities + "400": + description: Filter params are invalid content: application/json: schema: - type: array - items: - $ref: '#/components/schemas/EntityDto' - "404": - description: Could not find ontology + $ref: '#/components/schemas/ApiErrorDto' + "200": + description: Found entities content: application/json: schema: - $ref: '#/components/schemas/ApiErrorDto' - "400": - description: Filter params are invalid + type: array + items: + $ref: '#/components/schemas/EntityDto' + "417": + description: Generated query or uri is malformed content: application/json: schema: @@ -2158,24 +2158,12 @@ paths: type: integer format: int64 responses: - "417": - description: Generated query is malformed - content: - application/json: - schema: - $ref: '#/components/schemas/ApiErrorDto' "404": description: Could not find the table content: application/json: schema: $ref: '#/components/schemas/ApiErrorDto' - "422": - description: Ontology does not have rdf or sparql endpoint - content: - application/json: - schema: - $ref: '#/components/schemas/ApiErrorDto' "200": description: Suggested table semantics successfully content: @@ -2184,6 +2172,18 @@ paths: type: array items: $ref: '#/components/schemas/TableColumnEntityDto' + "417": + description: Generated query is malformed + content: + application/json: + schema: + $ref: '#/components/schemas/ApiErrorDto' + "422": + description: Ontology does not have rdf or sparql endpoint + content: + application/json: + schema: + $ref: '#/components/schemas/ApiErrorDto' security: - bearerAuth: [] /api/semantic/database/{databaseId}/table/{tableId}/column/{columnId}: @@ -2212,8 +2212,8 @@ paths: type: integer format: int64 responses: - "417": - description: Generated query is malformed + "404": + description: Could not find the table column content: application/json: schema: @@ -2226,8 +2226,8 @@ paths: type: array items: $ref: '#/components/schemas/TableColumnEntityDto' - "404": - description: Could not find the table column + "417": + description: Generated query is malformed content: application/json: schema: @@ -2274,12 +2274,6 @@ paths: schema: type: string responses: - "409": - description: Exported resource was not found - content: - text/csv: - schema: - $ref: '#/components/schemas/ApiErrorDto' "200": description: Found identifier successfully content: @@ -2292,10 +2286,11 @@ paths: text/bibliography; style=apa: {} text/bibliography; style=ieee: {} text/bibliography; style=bibtex: {} - "422": - description: Failed to retrieve from database sidecar + "400": + description: "Identifier could not be exported, the requested style is not\ + \ known" content: - text/csv: + text/bibliography: schema: $ref: '#/components/schemas/ApiErrorDto' "503": @@ -2304,11 +2299,16 @@ paths: text/csv: schema: $ref: '#/components/schemas/ApiErrorDto' - "400": - description: "Identifier could not be exported, the requested style is not\ - \ known" + "409": + description: Exported resource was not found content: - text/bibliography: + text/csv: + schema: + $ref: '#/components/schemas/ApiErrorDto' + "422": + description: Failed to retrieve from database sidecar + content: + text/csv: schema: $ref: '#/components/schemas/ApiErrorDto' "410": @@ -2436,32 +2436,26 @@ paths: type: string format: date-time responses: - "201": - description: Created identifier + "404": + description: "Table, database or user was not found" content: application/json: schema: - $ref: '#/components/schemas/IdentifierDto' + $ref: '#/components/schemas/ApiErrorDto' "503": description: Database connection could not be established content: application/json: schema: $ref: '#/components/schemas/ApiErrorDto' - "403": - description: Operation is not allowed - content: - application/json: - schema: - $ref: '#/components/schemas/ApiErrorDto' "422": description: Sidecar operation could not be completed content: application/json: schema: $ref: '#/components/schemas/ApiErrorDto' - "404": - description: "Table, database or user was not found" + "403": + description: Operation is not allowed content: application/json: schema: @@ -2478,6 +2472,12 @@ paths: application/json: schema: $ref: '#/components/schemas/ApiErrorDto' + "201": + description: Created identifier + content: + application/json: + schema: + $ref: '#/components/schemas/IdentifierDto' security: - bearerAuth: [] /api/database/{id}/access: @@ -2500,14 +2500,14 @@ paths: application/json: schema: $ref: '#/components/schemas/DatabaseAccessDto' - "404": - description: Database not found + "403": + description: No access to this database content: application/json: schema: $ref: '#/components/schemas/ApiErrorDto' - "403": - description: No access to this database + "404": + description: Database not found content: application/json: schema: @@ -2573,14 +2573,14 @@ paths: type: integer format: int64 responses: - "400": - description: Delete view query is malformed + "403": + description: Deletion not allowed content: application/json: schema: $ref: '#/components/schemas/ApiErrorDto' - "403": - description: Deletion not allowed + "503": + description: Connection to the database failed content: application/json: schema: @@ -2591,8 +2591,8 @@ paths: application/json: schema: $ref: '#/components/schemas/ApiErrorDto' - "503": - description: Connection to the database failed + "404": + description: "Database, view or user could not be found" content: application/json: schema: @@ -2603,8 +2603,8 @@ paths: application/json: schema: $ref: '#/components/schemas/ApiErrorDto' - "404": - description: "Database, view or user could not be found" + "400": + description: Delete view query is malformed content: application/json: schema: @@ -2645,30 +2645,30 @@ paths: type: integer format: int64 responses: - "404": - description: "Database, view, container or user could not be found" + "403": + description: View data not allowed content: application/json: schema: $ref: '#/components/schemas/ApiErrorDto' - "200": - description: Find data successfully + "404": + description: "Database, view, container or user could not be found" content: application/json: schema: - $ref: '#/components/schemas/QueryResultDto' + $ref: '#/components/schemas/ApiErrorDto' "400": description: Pagination not in valid range or find data query is malformed content: application/json: schema: $ref: '#/components/schemas/ApiErrorDto' - "403": - description: View data not allowed + "200": + description: Find data successfully content: application/json: schema: - $ref: '#/components/schemas/ApiErrorDto' + $ref: '#/components/schemas/QueryResultDto' security: - bearerAuth: [] /api/database/{databaseId}/view/{viewId}/data/count: @@ -2697,20 +2697,14 @@ paths: application/json: schema: $ref: '#/components/schemas/ApiErrorDto' - "403": - description: Count data not allowed - content: - application/json: - schema: - $ref: '#/components/schemas/ApiErrorDto' - "409": - description: Could not count query data + "400": + description: Pagination not in valid range or find data query is malformed content: application/json: schema: $ref: '#/components/schemas/ApiErrorDto' - "400": - description: Pagination not in valid range or find data query is malformed + "403": + description: Count data not allowed content: application/json: schema: @@ -2722,6 +2716,12 @@ paths: schema: type: integer format: int64 + "409": + description: Could not count query data + content: + application/json: + schema: + $ref: '#/components/schemas/ApiErrorDto' security: - bearerAuth: [] /api/database/{databaseId}/table/{tableId}: @@ -2744,14 +2744,14 @@ paths: type: integer format: int64 responses: - "404": - description: "Table, database or container could not be found" + "403": + description: Access to the database is forbidden content: application/json: schema: $ref: '#/components/schemas/ApiErrorDto' - "403": - description: Access to the database is forbidden + "404": + description: "Table, database or container could not be found" content: application/json: schema: @@ -2789,20 +2789,20 @@ paths: type: integer format: int64 responses: - "404": - description: "Table, database or container could not be found" + "202": + description: Delete table successfully + "403": + description: Access to the database is forbidden content: application/json: schema: $ref: '#/components/schemas/ApiErrorDto' - "403": - description: Access to the database is forbidden + "404": + description: "Table, database or container could not be found" content: application/json: schema: $ref: '#/components/schemas/ApiErrorDto' - "202": - description: Delete table successfully "400": description: Delete table query resulted in an invalid query statement content: @@ -2837,6 +2837,12 @@ paths: type: string format: date-time responses: + "422": + description: Could not import csv via sidecar + content: + application/json: + schema: + $ref: '#/components/schemas/ApiErrorDto' "403": description: Access to the database is forbidden content: @@ -2855,12 +2861,6 @@ paths: application/json: schema: $ref: '#/components/schemas/ApiErrorDto' - "422": - description: Could not import csv via sidecar - content: - application/json: - schema: - $ref: '#/components/schemas/ApiErrorDto' "202": description: Get table data count successfully content: @@ -2895,8 +2895,8 @@ paths: schema: type: string responses: - "400": - description: Image is not supported + "404": + description: Database or query could not be found content: application/json: schema: @@ -2907,8 +2907,8 @@ paths: '*/*': schema: type: object - "410": - description: Could not find in S3 storage + "400": + description: Image is not supported content: application/json: schema: @@ -2925,14 +2925,14 @@ paths: application/json: schema: $ref: '#/components/schemas/ApiErrorDto' - "409": - description: Export of query failed + "410": + description: Could not find in S3 storage content: application/json: schema: $ref: '#/components/schemas/ApiErrorDto' - "404": - description: Database or query could not be found + "409": + description: Export of query failed content: application/json: schema: @@ -2984,14 +2984,8 @@ paths: schema: type: string responses: - "400": - description: Image is not supported - content: - application/json: - schema: - $ref: '#/components/schemas/ApiErrorDto' - "409": - description: Could not store query in query store + "404": + description: Database or query could not be found content: application/json: schema: @@ -3002,6 +2996,12 @@ paths: application/json: schema: $ref: '#/components/schemas/QueryResultDto' + "400": + description: Image is not supported + content: + application/json: + schema: + $ref: '#/components/schemas/ApiErrorDto' "403": description: Execute query not permitted content: @@ -3014,8 +3014,8 @@ paths: application/json: schema: $ref: '#/components/schemas/ApiErrorDto' - "404": - description: Database or query could not be found + "409": + description: Could not store query in query store content: application/json: schema: @@ -3042,8 +3042,8 @@ paths: type: integer format: int64 responses: - "400": - description: Image is not supported + "404": + description: Database or query could not be found content: application/json: schema: @@ -3054,20 +3054,20 @@ paths: application/json: schema: $ref: '#/components/schemas/QueryResultDto' - "403": - description: Execute query not permitted + "400": + description: Image is not supported content: application/json: schema: $ref: '#/components/schemas/ApiErrorDto' - "417": - description: Could not parse columns + "403": + description: Execute query not permitted content: application/json: schema: $ref: '#/components/schemas/ApiErrorDto' - "404": - description: Database or query could not be found + "417": + description: Could not parse columns content: application/json: schema: @@ -3128,18 +3128,18 @@ paths: type: integer format: int64 responses: - "202": - description: Deleted container successfully - content: - '*/*': - schema: - type: object "404": description: Container not found content: application/json: schema: $ref: '#/components/schemas/ApiErrorDto' + "202": + description: Deleted container successfully + content: + '*/*': + schema: + type: object security: - bearerAuth: [] /api/pid/{id}: @@ -3162,18 +3162,18 @@ paths: application/json: schema: $ref: '#/components/schemas/ApiErrorDto' - "202": - description: Deleted identifier - content: - '*/*': - schema: - type: object "403": description: Deleting identifier not permitted content: application/json: schema: $ref: '#/components/schemas/ApiErrorDto' + "202": + description: Deleted identifier + content: + '*/*': + schema: + type: object security: - bearerAuth: [] components: @@ -6642,14 +6642,14 @@ components: type: string resumptionToken: type: string + parametersString: + type: string fromDate: type: string format: date-time untilDate: type: string format: date-time - parametersString: - type: string BannerMessageDto: required: - id diff --git a/.docs/.swagger/api-search.yaml b/.docs/.swagger/api-search.yaml index 3baf836362..6c6822d5fd 100644 --- a/.docs/.swagger/api-search.yaml +++ b/.docs/.swagger/api-search.yaml @@ -14,7 +14,174 @@ info: title: Database Repository Search Service API version: $TAG openapi: 3.0.0 -paths: {} +paths: + /api/search: + post: + consumes: + - application/json + description: Performs a fuzzy search + operationId: post_fuzzy_search + parameters: + - in: body + name: body + required: true + schema: + properties: + search_term: + example: air quality + type: string + type: object + produces: + - application/json + responses: + '200': + content: + application/json: + schema: + properties: + results: + items: + type: object + type: array + type: object + description: OK, contains the elements formatted as an array of JSON arrays + summary: Performs a fuzzy search + tags: + - search-endpoint + /api/search/{type}: + post: + consumes: + - application/json + description: Performs a general search + operationId: post_general_search + parameters: + - description: The search type. + in: path + name: type + required: true + schema: + enum: + - database + - table + - view + - column + - user + - identifier + - concept + - unit + type: string + - in: body + name: body + required: true + schema: + properties: + field_value_pairs: + type: object + search_term: + example: air quality + type: string + t1: + example: 0 + type: integer + t2: + example: 100 + type: integer + type: object + produces: + - application/json + responses: + '200': + content: + application/json: + schema: + properties: + results: + items: + type: object + type: array + type: + description: Same as the requested type + enum: + - database + - table + - view + - column + - user + - identifier + - concept + - unit + type: string + type: object + description: OK, contains the elements formatted as an array of JSON arrays + summary: Performs a general search + tags: + - search-endpoint + /api/search/{type}/fields: + get: + operationId: get_fields + parameters: + - description: The search type. + in: path + name: type + required: true + schema: + enum: + - database + - table + - view + - column + - user + - identifier + - concept + - unit + type: string + responses: + '200': + content: + application/json: + schema: + properties: + results: + items: + properties: + attr_friendly_name: + example: Name + type: string + attr_name: + example: name + type: string + type: + description: OpenSearch data types. + example: string + type: string + type: object + type: array + type: object + description: List of fields + '404': + description: Invalid type. + summary: Get searchable fields + tags: + - search-endpoint + /health: + get: + consumes: + - application/json + description: 'Return UP if the instance is ready to serve connections. + + ' + produces: + - application/json + responses: + '200': + description: OK, service is up and running + schema: + $ref: '#/definitions/Column' + '404': + description: Service is not yet ready + summary: Return a healthcheck + tags: + - actuator servers: - description: Generated server url url: http://localhost:4000 diff --git a/.docs/deployment-docker-compose.md b/.docs/deployment-docker-compose.md index 9f20302cd2..c8938279ca 100644 --- a/.docs/deployment-docker-compose.md +++ b/.docs/deployment-docker-compose.md @@ -93,18 +93,38 @@ core infrastructure and a single Docker container for all user-generated databas Install DBRepo with the default configuration from the Debian container: - curl -sSL https://gitlab.phaidra.org/fair-data-austria-db-repository/fda-services/-/raw/dev/install.sh | bash + curl -sSL https://gitlab.phaidra.org/fair-data-austria-db-repository/fda-services/-/raw/master/install.sh | bash View the logs: docker compose logs -f -You should now be able to view the front end at [http://localhost:80](http://localhost:80). +You should now be able to view the front end at [http://localhost](http://localhost). Please be warned that the default configuration is not intended for public deployments. It is only intended to have a running system within minutes to play around within the system and explore features. It is strongly advised to change the default `.env` environment variables. +### Troubleshooting + +In case the deployment is unsuccessful, we have explanations on their origin and solutions to the most common errors: + +**Are you trying to mount a directory onto a file (or vice-versa)?** + +: *Origin*: Docker Compose does not find all files referenced in the `volumes` section of your `docker-compose.yml` + file. +: *Solution*: Ensure all mounted files in the `volumes` section of your `docker-compose.yml` exist and have correct + file permissions (`0644`) to be found in the filesystem. Note that paths containing directories may not + work when using Windows instead of the supported Linux. + +**The Docker images have been updated but my deployment is not receiving the updates** + +: *Origin*: Your local Docker image cache is not up-to-date and needs to fetch the remote changes. +: *Solution*: Update your local Docker image cache by executing `docker compose pull`, it automatically downloads + all Docker images that have updates. Then apply the new images with `docker compose up -d`. + +## Security + !!! warning "Known security issues with the default configuration" The system is auto-configured for a small, local, test deployment and is *not* secure! You need to make modifications @@ -142,42 +162,6 @@ the default `.env` environment variables. [simple guide](http://nginx.org/en/docs/http/configuring_https_servers.html) on how to install a SSL/TLS certificate on NGINX. -## Upgrade Guide - -### 1.2 to 1.3 - -In case you have a previous deployment from version 1.2, shut down the containers and back them up manually. You can do -this by using the `busybox` image. Replace `deadbeef` with your container name or hash: - -```console -export NAME=dbrepo-userdb-xyz -docker run --rm --volumes-from $NAME -v /home/$USER/backup:/backup busybox tar pcvfz /backup/$NAME.tar.gz /var/lib/mysql -``` - -!!! danger "Wipe all traces of DBRepo from your system" - - To erase all traces of DBRepo from your computer or virtual machine, the following commands delete all containers, - volumes and networks that are present, execute the following **dangerous** command. It will **wipe** all information - about DBRepo from your system (excluding the images). - - ```console - docker container stop $(docker container ls -aq -f name=^/dbrepo-.*) || true - docker container rm $(docker container ls -aq -f name=^/dbrepo-.*) || true - docker volume rm $(docker volume ls -q -f name=^dbrepo-.*) || true - docker network rm $(docker network ls -q -f name=^dbrepo-.*) || true - ``` - -You can restore the volume *after* downloading the new 1.3 images and creating the infrastructure: - -```console -export NAME=dbrepo-userdb-xyz -export PORT=12345 -docker container create -h $NAME --name $NAME -p $PORT:3306 -e MARIADB_ROOT_PASSWORD=mariadb --network userdb -v /backup mariadb:10.5 -docker run --rm --volumes-from $NAME -v /home/$USER/backup/.tar.gz:/backup/$NAME.tar.gz busybox sh -c 'cd /backup && tar xvfz /backup/$NAME.tar.gz && cp -r /backup/var/lib/mysql/* /var/lib/mysql' -``` - -Future releases will be backwards compatible and will come with migration scripts. - ## Limitations !!! info "Alternative Deployments" diff --git a/.docs/system-services-search.md b/.docs/system-services-search.md index a3fe10e816..397feff381 100644 --- a/.docs/system-services-search.md +++ b/.docs/system-services-search.md @@ -71,7 +71,7 @@ between 32 - 50 °F"* instead. ## Examples -See the [usage page](../usage-search). +TBD ## Limitations diff --git a/.docs/usage-overview.md b/.docs/usage-overview.md index 4fff4799b3..af1ce9cbf8 100644 --- a/.docs/usage-overview.md +++ b/.docs/usage-overview.md @@ -1130,12 +1130,110 @@ A user wants a public database to be private and only give specific users access === "Terminal" - tbd + Obtain an access token: + + ```bash + curl -sSL \ + -X POST \ + -d 'username=foo&password=bar&grant_type=password&client_id=dbrepo-client&scope=openid&client_secret=MUwRc7yfXSJwX8AdRMWaQC3Nep1VjwgG' \ + http://localhost/api/auth/realms/dbrepo/protocol/openid-connect/token | jq .access_token + ``` + + !!! note + + Please note that the `client_secret` is different for your DBRepo instance. This is a default client secret that + likely has been replaced. Please contact your DBRepo administrator to get the `client_secret` for your instance. + Similar you need to replace `localhost` with your actual DBRepo instance hostname, e.g. `test.dbrepo.tuwien.ac.at`. + + To change the visibility of a database where you are the owner (this is the case for self-created databases), send + a request to the HTTP API: + + ```bash + curl -sSL \ + -X PUT \ + -H "Authorization: Bearer ACCESS_TOKEN" \ + -d '{"is_public":true}' \ + http://localhost/api/database/1/visibility + ``` + + To give a user (with id `e9bf38a0-a254-4040-87e3-92e0f09e29c8` access to this database (e.g. read access), update + their access using the HTTP API: + + ```bash + curl -sSL \ + -X POST \ + -H "Authorization: Bearer ACCESS_TOKEN" \ + -d '{"type":"read"}' \ + http://localhost/api/database/1/access/e9bf38a0-a254-4040-87e3-92e0f09e29c8 + ``` + + In case the user already has access, use the method `PUT`. === "JDBC" - tbd + To change the visibility of a database as administrator with direct JDBC access to + the [Metadata Database](../system-databases-metadata), change the visibility directly by executing the SQL-query + in the `fda` schema: + + ```sql + UPDATE `fda`.`mdb_databases` SET `is_public` = TRUE; + ``` + + To give a user (with id `e9bf38a0-a254-4040-87e3-92e0f09e29c8` access to this database (e.g. read access), update + their access using the JDBC API: + + ```sql + INSERT INTO `fda`.`mdb_have_access` (`user_id`, `database_id`, `access_type`) + VALUES ('e9bf38a0-a254-4040-87e3-92e0f09e29c8', 1, 'READ'); + ``` + + In case the user already has access, use an `UPDATE` query. === "Python" - tbd \ No newline at end of file + Obtain an access token: + + ```python + import requests + + response = requests.post("http://localhost/api/auth/realms/dbrepo/protocol/openid-connect/token", json={ + "username": "foo", + "password": "bar", + "grant_type": "password", + "client_id": "dbrepo-client", + "scope": "openid", + "client_secret": "MUwRc7yfXSJwX8AdRMWaQC3Nep1VjwgG" + }) + access_token = response.json()["access_token"] + print(access_token) + ``` + + !!! note + + Please note that the `client_secret` is different for your DBRepo instance. This is a default client secret that + likely has been replaced. Please contact your DBRepo administrator to get the `client_secret` for your instance. + Similar you need to replace `localhost` with your actual DBRepo instance hostname, e.g. `test.dbrepo.tuwien.ac.at`. + + To change the visibility of a database where you are the owner (this is the case for self-created databases), send + a request to the HTTP API: + + ```python + requests.put("http://localhost/api/database/1/visibility", headers={ + "Authorization": "Bearer " + access_token + }, json={ + "is_public": True + }) + ``` + + To give a user (with id `e9bf38a0-a254-4040-87e3-92e0f09e29c8` access to this database (e.g. read access), update + their access using the HTTP API: + + ```python + requests.post("http://localhost/api/database/1/access/e9bf38a0-a254-4040-87e3-92e0f09e29c8", headers={ + "Authorization": "Bearer " + access_token + }, json={ + "type": "read" + }) + ``` + + In case the user already has access, use the method `put`. \ No newline at end of file diff --git a/dbrepo-analyse-service/app.py b/dbrepo-analyse-service/app.py index d7d206d23d..4d4c5cda88 100644 --- a/dbrepo-analyse-service/app.py +++ b/dbrepo-analyse-service/app.py @@ -66,15 +66,9 @@ swagger_config = { { "endpoint": "api-analyse", "route": "/api-analyse.json", - "rule_filter": lambda rule: rule.endpoint.startswith("analyze"), + "rule_filter": lambda rule: True, "model_filter": lambda tag: True, # all in - }, - { - "endpoint": "api-mdb", - "route": "/api-mdb.json", - "rule_filter": lambda rule: rule.endpoint.startswith("mdb"), - "model_filter": lambda tag: True, # all in - }, + } ], "static_url_path": "/flasgger_static", "swagger_ui": True, @@ -102,7 +96,7 @@ template = { }, "servers": [ {"url": "http://localhost:5000", "description": "Generated server url"}, - {"url": "https://dbrepo2.tuwien.ac.at", "description": "Sandbox"}, + {"url": "https://test.dbrepo.tuwien.ac.at", "description": "Sandbox"}, ], } @@ -175,8 +169,9 @@ def determinepk(): return Response(res, mimetype="application/json"), 500 -@app.route("/api/analyse/determineStats", methods=["POST"], endpoint="analyze_stats") -def determineStats(): +@app.route("/api/analyse/determinestats", methods=["POST"], endpoint="analyse_determinestats") +@swag_from("as-yml/determine_stats.yml") +def determinestats(): logging.debug( "endpoint to determine the statistical properties, body = %s", request ) @@ -189,8 +184,9 @@ def determineStats(): return determine_stats(filepath, separator) -@app.route("/api/analyse/determineStat", methods=["POST"]) -def determineStat(): +@app.route("/api/analyse/determinestat", methods=["POST"], endpoint="analyse_determinestat") +@swag_from("as-yml/determine_stat.yml") +def determinestat(): input_json = request.get_json() if "database_id" not in input_json: diff --git a/dbrepo-analyse-service/as-yml/determine_stat.yml b/dbrepo-analyse-service/as-yml/determine_stat.yml new file mode 100644 index 0000000000..658e8af2b8 --- /dev/null +++ b/dbrepo-analyse-service/as-yml/determine_stat.yml @@ -0,0 +1,52 @@ +tags: + - analyse-endpoint +summary: Determine statistics +operationId: determinestat +requestBody: + content: + application/json: + schema: + required: + - database_id + - table_id + type: object + properties: + database_id: + type: "integer" + example: 1 + table_id: + type: "integer" + example: 1 +responses: + "200": + description: Determined statistics + content: + application/json: + schema: + required: + - message + - status + type: object + properties: + message: + type: "string" + example: "Analysed statistical properties" + status: + type: "integer" + example: "200" + 400: + description: "Invalid input" + ontent: + application/json: + schema: + required: + - message + - status + type: object + properties: + message: + type: "string" + example: "Analysed statistical properties" + status: + type: "integer" + example: "200" diff --git a/dbrepo-analyse-service/as-yml/determine_stats.yml b/dbrepo-analyse-service/as-yml/determine_stats.yml new file mode 100644 index 0000000000..68b71dd527 --- /dev/null +++ b/dbrepo-analyse-service/as-yml/determine_stats.yml @@ -0,0 +1,24 @@ +tags: + - analyse-endpoint +summary: Determine statistics +operationId: determinestats +requestBody: + content: + application/json: + schema: + required: + - filepath + - separator + type: object + properties: + filepath: + type: "string" + example: "file.csv" + separator: + type: "string" + example: "," +responses: + "200": + description: Determined statistics + "400": + description: "Invalid input" diff --git a/dbrepo-analyse-service/as-yml/determinedt.yml b/dbrepo-analyse-service/as-yml/determinedt.yml index 0c41bcead8..b7d554d231 100644 --- a/dbrepo-analyse-service/as-yml/determinedt.yml +++ b/dbrepo-analyse-service/as-yml/determinedt.yml @@ -1,30 +1,32 @@ +tags: + - analyse-endpoint summary: "Determine datatypes" description: "This is a simple API which returns the datatypes of a (path) csv file" consumes: -- "application/json" + - "application/json" produces: -- "application/json" + - "application/json" parameters: -- in: "body" - name: "body" - description: "to-do description" - required: true - schema: - type: "object" - properties: - filename: - type: "string" - example : "sample.csv" - enum: - type: "boolean" - example: true - enum_tol: - example: 0.1 - separator: - type: "string" - example: "," + - in: "body" + name: "body" + description: "to-do description" + required: true + schema: + type: "object" + properties: + filename: + type: "string" + example: "sample.csv" + enum: + type: "boolean" + example: true + enum_tol: + example: 0.1 + separator: + type: "string" + example: "," responses: - 200: + 200: description: "OK" 405: description: "Invalid input" \ No newline at end of file diff --git a/dbrepo-analyse-service/as-yml/determinepk.yml b/dbrepo-analyse-service/as-yml/determinepk.yml index 24446e939a..ca7253844d 100644 --- a/dbrepo-analyse-service/as-yml/determinepk.yml +++ b/dbrepo-analyse-service/as-yml/determinepk.yml @@ -1,25 +1,27 @@ +tags: + - analyse-endpoint summary: "Determine primary keys" description: "This is a simple API which returns the primary keys + ranking of a (path) csv file" consumes: -- "application/json" + - "application/json" produces: -- "application/json" + - "application/json" parameters: -- in: "body" - name: "body" - description: "to-do description" - required: true - schema: - type: "object" - properties: - filepath: - type: "string" - example : "/data/testdt08.csv" - seperator: - type: "string" - example: "," + - in: "body" + name: "body" + description: "to-do description" + required: true + schema: + type: "object" + properties: + filepath: + type: "string" + example: "/data/testdt08.csv" + seperator: + type: "string" + example: "," responses: - 200: + 200: description: "OK" 405: description: "Invalid input" \ No newline at end of file diff --git a/dbrepo-analyse-service/as-yml/health.yml b/dbrepo-analyse-service/as-yml/health.yml index 9b34f955d1..a0f7ebcbac 100644 --- a/dbrepo-analyse-service/as-yml/health.yml +++ b/dbrepo-analyse-service/as-yml/health.yml @@ -1,21 +1,18 @@ +tags: + - health-endpoint summary: "Check if application is running" description: "This is a simple API which checks if the application is healthy" consumes: -- "application/json" + - "application/json" produces: -- "application/json" -parameters: -- in: "body" - name: "body" - description: "to-do description" - required: true - schema: - type: "object" - properties: - status: - type: "string" - example : "UP" + - "application/json" responses: - 200: + 200: description: "OK" + schema: + type: "object" + properties: + status: + type: "string" + example: "UP" \ No newline at end of file diff --git a/dbrepo-search-service/README.md b/dbrepo-search-service/README.md index 4ee261b34a..a05a200d2d 100644 --- a/dbrepo-search-service/README.md +++ b/dbrepo-search-service/README.md @@ -1,33 +1,14 @@ -# Search service +# Search Service -🚧 WIP 🚧 +## Actuator -The dbrepo search service is used to enable searching for -entries in the opensearch databse. +- Health: http://localhost:5000/api/search/health +- Prometheus: http://localhost:5000/metrics -## Running the app -Test the app locally: -```shell -pipenv install && pipenv run flask run --debug --port 4000 -``` +## Swagger UI Endpoints -## Overview -Here's an overview about the different endpoints available at this service: -(`<index>` has to be one of the following indices: -table, user, database, column, identifier, concept, unit, view) +- Swagger UI: http://localhost:5000/swagger-ui/ ---- -`/api/search/<index>` : -returns all entries for a given index +## OpenAPI Endpoints ---- -`/api/search/<index>/fields`: -returns all the fields that are saved in a given entry - ---- -`/api/search`: -this is the main endpoint for searching entries in the opensearch db. -You can specify a search term, a time period -and certain fields that should match a certain value. - -ToDo: Continue \ No newline at end of file +- OpenAPI v3 as .json: http://localhost:5000/api-search.json \ No newline at end of file diff --git a/dbrepo-search-service/app/__init__.py b/dbrepo-search-service/app/__init__.py index 9236706cb8..c8cd7d4073 100644 --- a/dbrepo-search-service/app/__init__.py +++ b/dbrepo-search-service/app/__init__.py @@ -52,7 +52,7 @@ def create_app(config_class=Config): { "endpoint": "api-search", "route": "/api-search.json", - "rule_filter": lambda rule: rule.endpoint.startswith('actuator'), + "rule_filter": lambda rule: True, "model_filter": lambda tag: True, # all in } ], diff --git a/dbrepo-search-service/app/api/routes.py b/dbrepo-search-service/app/api/routes.py index d99a4c81ac..72c6134b4e 100644 --- a/dbrepo-search-service/app/api/routes.py +++ b/dbrepo-search-service/app/api/routes.py @@ -52,13 +52,12 @@ def general_filter(index, results): @api_bp.route("/health", methods=["GET"], endpoint="actuator_health") -@swag_from("us-yml/get_health") # ToDo: get the SWAG right +@swag_from("../../us-yml/get_health.yml") def health(): return {"status": "UP"} @api_bp.route("/api/search/<string:index>", methods=["GET"], endpoint="search_get_index") -@swag_from("us-yml") # ToDo: get the SWAG right def get_index(index): """ returns all entries in a specific index @@ -81,6 +80,7 @@ def get_index(index): @api_bp.route("/api/search/<string:type>/fields", methods=["GET"], endpoint="search_get_index_fields") +@swag_from("../../us-yml/get_fields.yml") def get_fields(type): """ returns a list of attributes of the data for a specific index. @@ -90,7 +90,7 @@ def get_fields(type): logging.info(f'Searching in index database for type: {type}') if type not in available_types: return { - "results": {}, + "results": {}, # FIXME this can't be right }, 404 fields = get_fields_for_index(type) logging.debug(f'get fields for type {type} resulted in {len(fields)} field(s)') @@ -98,6 +98,7 @@ def get_fields(type): @api_bp.route("/api/search", methods=["POST"], endpoint="search_fuzzy_search") +@swag_from("../../us-yml/post_fuzzy_search.yml") def post_fuzzy_search(): """ Main endpoint for fuzzy searching. @@ -118,6 +119,7 @@ def post_fuzzy_search(): @api_bp.route("/api/search/<string:type>", methods=["POST"], endpoint="search_general_search") +@swag_from("../../us-yml/post_general_search.yml") def post_general_search(type): """ Main endpoint for fuzzy searching. diff --git a/dbrepo-search-service/us-yml/get_column.yml b/dbrepo-search-service/us-yml/get_column.yml deleted file mode 100644 index b1cb98c2a5..0000000000 --- a/dbrepo-search-service/us-yml/get_column.yml +++ /dev/null @@ -1,53 +0,0 @@ -summary: Return a detailed information about a specific column in the elastic search instance -description: | - Return a detailed information about a specific column in the elastic search instance -consumes: - - application/json -produces: - - application/json -parameters: - - in: "path" - type: "integer" - name: "column_id" - description: "The ID of the column to retrieve further information about" - required: true -definitions: - Column: - type: object - properties: - id: - type: integer - description: The id of the column - name: - type: string - description: The name of the column - internal_name: - type: string - description: The internal name of the column - column_type: - type: string - description: The type of the column - is_public: - type: boolean - description: Whether the column is public or not - is_null_allowed: - type: boolean - description: Whether the column allows null values or not - is_primary_key: - type: boolean - description: Whether the column is a primary key or not - table_id: - type: integer - description: The id of the table the column belongs to - database_id: - type: integer - description: The id of the database the column belongs to -responses: - 200: - description: OK, contains the detailed information about the column - schema: - $ref: "#/definitions/Column" - 404: - description: No column with such ID exists in the elastic search instance -tags: - - get_column_endpoint \ No newline at end of file diff --git a/dbrepo-search-service/us-yml/get_columns.yml b/dbrepo-search-service/us-yml/get_columns.yml deleted file mode 100644 index 32e8854d44..0000000000 --- a/dbrepo-search-service/us-yml/get_columns.yml +++ /dev/null @@ -1,31 +0,0 @@ -summary: Return a short information about all columns in the elastic search instance -description: | - Return a short information about all columns in the elastic search instance -consumes: - - application/json -produces: - - application/json -definitions: - Column: - type: object - properties: - id: - type: integer - description: The id of the column - name: - type: string - description: The name of the column - column_type: - type: string - description: The type of the column -responses: - 200: - description: OK, contains the elements formatted as a JSON array - schema: - type: array - items: - $ref: '#/definitions/Column' - 404: - description: No matching element found, no columns exist in the elastic search instance -tags: - - get_columns_endpoint \ No newline at end of file diff --git a/dbrepo-search-service/us-yml/get_database.yml b/dbrepo-search-service/us-yml/get_database.yml deleted file mode 100644 index 0c71b980de..0000000000 --- a/dbrepo-search-service/us-yml/get_database.yml +++ /dev/null @@ -1,38 +0,0 @@ -summary: Return a detailed information about a specific database in the elastic search instance -description: | - Return a detailed information about a specific database in the elastic search instance -consumes: - - application/json -produces: - - application/json -parameters: - - in: "path" - type: "integer" - name: "db_id" - description: "The ID of the database to retrieve further information about" - required: true -definitions: - Database: - type: object - properties: - id: - type: integer - description: The id of the database - internal_name: - type: string - description: The internal name of the database - name: - type: string - description: The name of the database - public: - type: boolean - description: Whether the database is public or not -responses: - 200: - description: OK, contains the detailed information about the database - schema: - $ref: "#/definitions/Database" - 404: - description: No database with such ID exists in the elastic search instance -tags: - - get_database_endpoint \ No newline at end of file diff --git a/dbrepo-search-service/us-yml/get_database_table.yml b/dbrepo-search-service/us-yml/get_database_table.yml deleted file mode 100644 index 8820497004..0000000000 --- a/dbrepo-search-service/us-yml/get_database_table.yml +++ /dev/null @@ -1,59 +0,0 @@ -summary: Return a detailed information about a specific table in the elastic search instance (that is contained in the given database) -description: | - Return a detailed information about a specific table in the elastic search instance (that is contained in the given database) -consumes: - - application/json -produces: - - application/json -parameters: - - in: "path" - type: "integer" - name: "table_id" - description: "The ID of the table to retrieve further information about" - required: true - - in: "path" - type: "integer" - name: "database_id" - description: "The ID of the database to retrieve the tables from" - required: true -definitions: - Table: - type: object - properties: - id: - type: integer - description: The id of the table - name: - type: string - description: The name of the table - internal_name: - type: string - description: The internal name of the table - description: - type: string - description: The description of the table - database_id: - type: integer - description: The id of the database the table belongs to - public: - type: boolean - description: Whether the table is public or not - owner: - type: object - description: The owner of the table - properties: - id: - type: integer - description: The id of the owner - username: - type: string - description: The username of the owner -responses: - 200: - description: OK, contains the detailed information about the table (that is contained in the given database) - schema: - $ref: "#/definitions/Table" - 404: - description: No table with such ID exists in the elastic search instance for that specific database -tags: - - get_database_table_endpoint \ No newline at end of file diff --git a/dbrepo-search-service/us-yml/get_database_table_column.yml b/dbrepo-search-service/us-yml/get_database_table_column.yml deleted file mode 100644 index 838e46c0b9..0000000000 --- a/dbrepo-search-service/us-yml/get_database_table_column.yml +++ /dev/null @@ -1,63 +0,0 @@ -summary: Return a detailed information about a specific column in the elastic search instance in a specific table in a specific database -description: | - Return a detailed information about a specific column in the elastic search instance in a specific table in a specific database -consumes: - - application/json -produces: - - application/json -parameters: - - in: "path" - type: "integer" - name: "column_id" - description: "The ID of the column to retrieve further information about" - required: true - - in: "path" - type: "integer" - name: "table_id" - description: "The ID of the table to retrieve further information about" - required: true - - in: "path" - type: "integer" - name: "database_id" - description: "The ID of the database to retrieve further information about" - required: true -definitions: - Column: - type: object - properties: - id: - type: integer - description: The id of the column - name: - type: string - description: The name of the column - internal_name: - type: string - description: The internal name of the column - column_type: - type: string - description: The type of the column - is_public: - type: boolean - description: Whether the column is public or not - is_null_allowed: - type: boolean - description: Whether the column allows null values or not - is_primary_key: - type: boolean - description: Whether the column is a primary key or not - table_id: - type: integer - description: The id of the table the column belongs to - database_id: - type: integer - description: The id of the database the column belongs to -responses: - 200: - description: OK, contains the detailed information about the column in the elastic search instance (in that table in that database) - schema: - $ref: "#/definitions/Column" - 404: - description: No column with such ID exists in the elastic search instance (in that table in that database) -tags: - - get_database_column_endpoint \ No newline at end of file diff --git a/dbrepo-search-service/us-yml/get_database_table_columns.yml b/dbrepo-search-service/us-yml/get_database_table_columns.yml deleted file mode 100644 index 5a703f83a7..0000000000 --- a/dbrepo-search-service/us-yml/get_database_table_columns.yml +++ /dev/null @@ -1,42 +0,0 @@ -summary: Return a short information about all columns in the elastic search instance in a specific table in a specific database -description: | - Return a short information about all columns in the elastic search instance in a specific table in a specific database -consumes: - - application/json -produces: - - application/json -parameters: - - in: "path" - type: "integer" - name: "table_id" - description: "The ID of the table to retrieve further information about" - required: true - - in: "path" - type: "integer" - name: "database_id" - description: "The ID of the database to retrieve further information about" - required: true -definitions: - Column: - type: object - properties: - id: - type: integer - description: The id of the column - name: - type: string - description: The name of the column - column_type: - type: string - description: The type of the column -responses: - 200: - description: OK, contains the elements formatted as a JSON array - schema: - type: array - items: - $ref: '#/definitions/Column' - 404: - description: No matching element found, no columns exist in the elastic search instance (in that table in that database) -tags: - - get_database_table_columns_endpoint \ No newline at end of file diff --git a/dbrepo-search-service/us-yml/get_database_tables.yml b/dbrepo-search-service/us-yml/get_database_tables.yml deleted file mode 100644 index 1bad4ccece..0000000000 --- a/dbrepo-search-service/us-yml/get_database_tables.yml +++ /dev/null @@ -1,40 +0,0 @@ -summary: Return a short information about all tables in the elastic search instance, that are contained in the given database -description: | - Return a short information about all tables in the elastic search instance that are contained in the given database -consumes: - - application/json -produces: - - application/json -parameters: - - in: "path" - type: "integer" - name: "database_id" - description: "The ID of the database to retrieve the tables from" - required: true -definitions: - Table: - type: object - properties: - id: - type: integer - description: The id of the table - name: - type: string - description: The name of the table - description: - type: string - description: The description of the table - database_id: - type: integer - description: The id of the database the table belongs to -responses: - 200: - description: OK, contains the elements formatted as a JSON array - schema: - type: array - items: - $ref: '#/definitions/Table' - 404: - description: No matching element found, no tables exist in the elastic search instance that are contained in the given database -tags: - - get_database_tables_endpoint \ No newline at end of file diff --git a/dbrepo-search-service/us-yml/get_databases.yml b/dbrepo-search-service/us-yml/get_databases.yml deleted file mode 100644 index 8727fafb4e..0000000000 --- a/dbrepo-search-service/us-yml/get_databases.yml +++ /dev/null @@ -1,31 +0,0 @@ -summary: Return a short information about all databases in the elastic search instance -description: | - Return a short information about all databases in the elastic search instance -consumes: - - application/json -produces: - - application/json -definitions: - Database: - type: object - properties: - id: - type: integer - description: The id of the database - name: - type: string - description: The name of the database - public: - type: boolean - description: The public status of the database -responses: - 200: - description: OK, contains the elements formatted as a JSON array - schema: - type: array - items: - $ref: '#/definitions/Database' - 404: - description: No matching element found, no databases exist in the elastic search instance -tags: - - get_databases_endpoint \ No newline at end of file diff --git a/dbrepo-search-service/us-yml/get_fields.yml b/dbrepo-search-service/us-yml/get_fields.yml new file mode 100644 index 0000000000..6ff4c87974 --- /dev/null +++ b/dbrepo-search-service/us-yml/get_fields.yml @@ -0,0 +1,37 @@ +tags: + - search-endpoint +summary: Get searchable fields +operationId: get_fields +parameters: + - in: path + name: type + schema: + type: string + enum: [ database, table, view, column, user, identifier, concept, unit ] + required: true + description: The search type. +responses: + "200": + description: "List of fields" + content: + application/json: + schema: + type: object + properties: + results: + type: array + items: + type: object + properties: + attr_name: + type: "string" + example: "name" + attr_friendly_name: + type: "string" + example: "Name" + type: + type: "string" + example: "string" + description: OpenSearch data types. + "404": + description: Invalid type. diff --git a/dbrepo-search-service/us-yml/get_identifier.yml b/dbrepo-search-service/us-yml/get_identifier.yml deleted file mode 100644 index cd200025cd..0000000000 --- a/dbrepo-search-service/us-yml/get_identifier.yml +++ /dev/null @@ -1,57 +0,0 @@ -summary: Return a detailed information about a specific identifier in the elastic search instance -description: | - Return a detailed information about a specific identifier in the elastic search instance -consumes: - - application/json -produces: - - application/json -parameters: - - in: "path" - type: "integer" - name: "identifier_id" - description: "The ID of the identifier to retrieve further information about" - required: true -definitions: - Identifier: - type: object - properties: - id: - type: integer - description: The id of the identifier - name: - type: string - description: The name of the identifier - description: - type: string - description: The description of the identifier - type: - type: string - description: The type of object the identifier refers to - visibility: - type: string - description: The visibility of the identifier - publisher: - type: string - description: The publisher of the identifier - publication_date: - type: object - description: The publication date of the identifier - properties: - year: - type: integer - description: The year of the publication date - month: - type: integer - description: The month of the publication date - day: - type: integer - description: The day of the publication date -responses: - 200: - description: OK, contains the detailed information about the identifier - schema: - $ref: "#/definitions/Identifier" - 404: - description: No identifier with such ID exists in the elastic search instance -tags: - - get_identifier_endpoint \ No newline at end of file diff --git a/dbrepo-search-service/us-yml/get_identifiers.yml b/dbrepo-search-service/us-yml/get_identifiers.yml deleted file mode 100644 index cc2f323122..0000000000 --- a/dbrepo-search-service/us-yml/get_identifiers.yml +++ /dev/null @@ -1,31 +0,0 @@ -summary: Return a short information about all identifiers in the elastic search instance -description: | - Return a short information about all identifiers in the elastic search instance -consumes: - - application/json -produces: - - application/json -definitions: - Identifier: - type: object - properties: - id: - type: integer - description: The id of the identifier - name: - type: string - description: The name of the identifier - type: - type: string - description: The type of object the identifier refers to -responses: - 200: - description: OK, contains the elements formatted as a JSON array - schema: - type: array - items: - $ref: '#/definitions/Identifier' - 404: - description: No matching element found, no identifiers exist in the elastic search instance -tags: - - get_identifiers_endpoint \ No newline at end of file diff --git a/dbrepo-search-service/us-yml/get_table.yml b/dbrepo-search-service/us-yml/get_table.yml deleted file mode 100644 index 886dac0336..0000000000 --- a/dbrepo-search-service/us-yml/get_table.yml +++ /dev/null @@ -1,54 +0,0 @@ -summary: Return a detailed information about a specific table in the elastic search instance -description: | - Return a detailed information about a specific table in the elastic search instance -consumes: - - application/json -produces: - - application/json -parameters: - - in: "path" - type: "integer" - name: "table_id" - description: "The ID of the table to retrieve further information about" - required: true -definitions: - Table: - type: object - properties: - id: - type: integer - description: The id of the table - name: - type: string - description: The name of the table - internal_name: - type: string - description: The internal name of the table - description: - type: string - description: The description of the table - database_id: - type: integer - description: The id of the database the table belongs to - public: - type: boolean - description: Whether the table is public or not - owner: - type: object - description: The owner of the table - properties: - id: - type: integer - description: The id of the owner - username: - type: string - description: The username of the owner -responses: - 200: - description: OK, contains the detailed information about the table - schema: - $ref: "#/definitions/Table" - 404: - description: No table with such ID exists in the elastic search instance -tags: - - get_table_endpoint \ No newline at end of file diff --git a/dbrepo-search-service/us-yml/get_tables.yml b/dbrepo-search-service/us-yml/get_tables.yml deleted file mode 100644 index f5b70798c7..0000000000 --- a/dbrepo-search-service/us-yml/get_tables.yml +++ /dev/null @@ -1,34 +0,0 @@ -summary: Return a short information about all tables in the elastic search instance -description: | - Return a short information about all tables in the elastic search instance -consumes: - - application/json -produces: - - application/json -definitions: - Table: - type: object - properties: - id: - type: integer - description: The id of the table - name: - type: string - description: The name of the table - description: - type: string - description: The description of the table - database_id: - type: integer - description: The id of the database the table belongs to -responses: - 200: - description: OK, contains the elements formatted as a JSON array - schema: - type: array - items: - $ref: '#/definitions/Table' - 404: - description: No matching element found, no tables exist in the elastic search instance -tags: - - get_tables_endpoint \ No newline at end of file diff --git a/dbrepo-search-service/us-yml/get_user.yml b/dbrepo-search-service/us-yml/get_user.yml deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/dbrepo-search-service/us-yml/get_users.yml b/dbrepo-search-service/us-yml/get_users.yml deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/dbrepo-search-service/us-yml/post_fuzzy_search.yml b/dbrepo-search-service/us-yml/post_fuzzy_search.yml new file mode 100644 index 0000000000..09769209f1 --- /dev/null +++ b/dbrepo-search-service/us-yml/post_fuzzy_search.yml @@ -0,0 +1,31 @@ +tags: + - search-endpoint +summary: Performs a fuzzy search +operationId: post_fuzzy_search +description: Performs a fuzzy search +consumes: + - application/json +produces: + - application/json +parameters: + - in: "body" + name: "body" + required: true + schema: + type: "object" + properties: + search_term: + type: "string" + example: "air quality" +responses: + 200: + description: OK, contains the elements formatted as an array of JSON arrays + content: + application/json: + schema: + type: object + properties: + results: + type: array + items: + type: object diff --git a/dbrepo-search-service/us-yml/post_general_search.yml b/dbrepo-search-service/us-yml/post_general_search.yml new file mode 100644 index 0000000000..a57f133708 --- /dev/null +++ b/dbrepo-search-service/us-yml/post_general_search.yml @@ -0,0 +1,50 @@ +tags: + - search-endpoint +summary: Performs a general search +operationId: post_general_search +description: Performs a general search +consumes: + - application/json +produces: + - application/json +parameters: + - in: path + name: type + schema: + type: string + enum: [ database, table, view, column, user, identifier, concept, unit ] + required: true + description: The search type. + - in: "body" + name: "body" + required: true + schema: + type: "object" + properties: + search_term: + type: "string" + example: "air quality" + field_value_pairs: + type: "object" + t1: + type: "integer" + example: 0 + t2: + type: "integer" + example: 100 +responses: + 200: + description: OK, contains the elements formatted as an array of JSON arrays + content: + application/json: + schema: + type: object + properties: + results: + type: array + items: + type: object + type: + type: string + enum: [ database, table, view, column, user, identifier, concept, unit ] + description: "Same as the requested type" diff --git a/dbrepo-search-service/us-yml/post_search.yml b/dbrepo-search-service/us-yml/post_search.yml deleted file mode 100644 index 613e0c012a..0000000000 --- a/dbrepo-search-service/us-yml/post_search.yml +++ /dev/null @@ -1,84 +0,0 @@ -summary: Return all tables, databases, columns, users and identifiers in the elastic search instance -description: | - Return all tables, databases, columns, users and identifiers in the elastic search instance -consumes: - - application/json -produces: - - application/json -definitions: - Table: - type: object - properties: - id: - type: integer - description: The id of the table - name: - type: string - description: The name of the table - description: - type: string - description: The description of the table - database_id: - type: integer - description: The id of the database the table belongs to - Column: - type: object - properties: - id: - type: integer - description: The id of the column - name: - type: string - description: The name of the column - column_type: - type: string - description: The type of the column - Database: - type: object - properties: - id: - type: integer - description: The id of the database - name: - type: string - description: The name of the database - public: - type: boolean - description: The public status of the database - Identifier: - type: object - properties: - id: - type: integer - description: The id of the identifier - name: - type: string - description: The name of the identifier - type: - type: string - description: The type of object the identifier refers to - User: - type: object - properties: - id: - type: integer - description: The id of the user - username: - type: string - description: The username of the user -responses: - 200: - description: OK, contains the elements formatted as an array of JSON arrays - schema: - type: array - items: - type: array - items: - oneOf: - - $ref: '#/definitions/Table' - - $ref: '#/definitions/Column' - - $ref: '#/definitions/Database' - - $ref: '#/definitions/Identifier' - - $ref: '#/definitions/User' -tags: - - search_endpoint \ No newline at end of file diff --git a/mkdocs.yml b/mkdocs.yml index 1ea18e2c80..3eef0cf8c1 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -79,6 +79,7 @@ theme: name: material markdown_extensions: - attr_list + - def_list - md_in_html - admonition - pymdownx.details -- GitLab