This is an automated email from the ASF dual-hosted git repository.
nchung pushed a commit to branch master
in repository
https://gitbox.apache.org/repos/asf/incubator-sdap-in-situ-data-services.git
The following commit(s) were added to refs/heads/master by this push:
new 3609f2c feat: SDAP-395: CDMS JSON Schema Endpoint (#7)
3609f2c is described below
commit 3609f2cc4bbbd0786bece381a53781a17b593a6d
Author: wphyojpl <[email protected]>
AuthorDate: Wed Jul 13 09:16:12 2022 -0700
feat: SDAP-395: CDMS JSON Schema Endpoint (#7)
* feat: add CLI script
* chore: update readme
* chore: add changelog
* fix: added `meta` column as defaul column
* fix: add default column in correct place
* chore: update changelog + swagger
* chore: switch to SDAP ticket
* feat: add new endpoint for cdms schema
* chore: update swagger + changelog
* Update CHANGELOG.md
---
CHANGELOG.md | 1 +
parquet_flask/v1/__init__.py | 2 ++
parquet_flask/v1/cdms_schema.py | 25 +++++++++++++
.../v1/insitu_query_swagger/insitu-spec-0.0.1.yml | 41 ++++++++++++++++++++++
4 files changed, 69 insertions(+)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 796d47c..52cc0ad 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -8,6 +8,7 @@ and this project adheres to [Semantic
Versioning](https://semver.org/spec/v2.0.0
### Added
- CDMS-xxx: Added `CLI` script to ingest S3 data into the Parquet system
- SDAP-394: added meta as default column in in-situ endpoint response
+- SDAP-395: added cdms json schema endpoint
### Changed
### Deprecated
### Removed
diff --git a/parquet_flask/v1/__init__.py b/parquet_flask/v1/__init__.py
index f995485..e6b73b4 100644
--- a/parquet_flask/v1/__init__.py
+++ b/parquet_flask/v1/__init__.py
@@ -17,6 +17,7 @@ from flask import Blueprint
from flask_restx import Api
from .insitu_query_swagger import api as apidocs
+from .cdms_schema import api as cdms_schema_api
from .ingest_json_s3 import api as ingest_parquet_json_s3
from .replace_json_s3 import api as replace_parquet_json_s3
from .query_data import api as query_data
@@ -40,6 +41,7 @@ api = Api(blueprint,
)
# Register namespaces
+api.add_namespace(cdms_schema_api)
api.add_namespace(ingest_parquet_json_s3)
api.add_namespace(replace_parquet_json_s3)
api.add_namespace(query_data)
diff --git a/parquet_flask/v1/cdms_schema.py b/parquet_flask/v1/cdms_schema.py
new file mode 100644
index 0000000..5a6ded2
--- /dev/null
+++ b/parquet_flask/v1/cdms_schema.py
@@ -0,0 +1,25 @@
+import logging
+
+from flask_restx import Resource, Namespace, fields
+from parquet_flask.utils.config import Config
+from parquet_flask.utils.file_utils import FileUtils
+
+api = Namespace('cdms_schema', description="Retrieve CDMS JSON schema")
+LOGGER = logging.getLogger(__name__)
+
+
[email protected]('', methods=["get", "post"], strict_slashes=False)
[email protected]('/', methods=["get", "post"], strict_slashes=False)
+class CdmsSchema(Resource):
+ def __init__(self, api=None, *args, **kwargs):
+ super().__init__(api, args, kwargs)
+
+ @api.expect()
+ def get(self):
+ json_schema_path = Config().get_value('in_situ_schema')
+ if not FileUtils.file_exist(json_schema_path):
+ return {'message': f'file not found: {json_schema_path}'}, 404
+ json_schema = FileUtils.read_json(json_schema_path)
+ if json_schema is None:
+ return {'message': 'file is invalid json'}, 500
+ return json_schema, 200
diff --git a/parquet_flask/v1/insitu_query_swagger/insitu-spec-0.0.1.yml
b/parquet_flask/v1/insitu_query_swagger/insitu-spec-0.0.1.yml
index 7c1cca1..3150a3e 100644
--- a/parquet_flask/v1/insitu_query_swagger/insitu-spec-0.0.1.yml
+++ b/parquet_flask/v1/insitu_query_swagger/insitu-spec-0.0.1.yml
@@ -44,6 +44,45 @@ paths:
$ref: '#/components/schemas/QueryResponse'
default:
description: 'Invalid query'
+ '/query_data_doms_custom_pagination':
+ get:
+ summary: Query data source
+ tags:
+ - Query
+ parameters:
+ - $ref: '#/components/parameters/startIndexParam'
+ - $ref: '#/components/parameters/itemsPerPageParam'
+ - $ref: '#/components/parameters/providerParam'
+ - $ref: '#/components/parameters/projectParam'
+ - $ref: '#/components/parameters/platformParam'
+ - $ref: '#/components/parameters/startTimeParam'
+ - $ref: '#/components/parameters/endTimeParam'
+ - $ref: '#/components/parameters/minDepthParam'
+ - $ref: '#/components/parameters/maxDepthParam'
+ - $ref: '#/components/parameters/bboxParam'
+ - $ref: '#/components/parameters/variableParam'
+ - $ref: '#/components/parameters/columnsParam'
+ responses:
+ '200':
+ description: 'Successful query'
+ content:
+ application/json:
+ schema:
+ $ref: '#/components/schemas/QueryResponse'
+ default:
+ description: 'Invalid query'
+ '/cdms_schema':
+ get:
+ summary: get CDMS JSON Schema
+ responses:
+ '200':
+ description: 'Successful query'
+
+ '404':
+ description: 'File not found'
+
+ '500':
+ description: 'Other unexpected error'
components:
schemas:
@@ -53,6 +92,7 @@ components:
last:
type: string
example:
'http://rda-data.ucar.edu:8890/ws/search/icoads?startIndex=928610&endTime=2013-10-31T23%3A59%3A59Z&bbox=-45%2C15%2C-30%2C30&startTime=2012-08-01T00%3A00%3A00Z'
+ description: 'This is not available as query only knows the next page
in custom_pagination_query'
next:
type: string
example:
'http://rda-data.ucar.edu:8890/ws/search/icoads?startIndex=10&endTime=2013-10-31T23%3A59%3A59Z&bbox=-45%2C15%2C-30%2C30&startTime=2012-08-01T00%3A00%3A00Z'
@@ -65,6 +105,7 @@ components:
$ref: '#/components/schemas/Result'
totalResults:
type: integer
+ description: 'total number of results. NOte it may only be available
on the first page in custom_pagination_query'
example: 928618
minimum: 0
startIndex: