Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add post endpoints #2124

Merged
merged 13 commits into from
Sep 28, 2023
6 changes: 5 additions & 1 deletion apps/schematic/api/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -70,5 +70,9 @@ target/
#secrets
*secrets*

#schematic downloaded manifests
#schematic downloaded files
manifests
great_expectations

#integration tests
schematic_api/test/test_integration.py
1 change: 1 addition & 0 deletions apps/schematic/api/.openapi-generator-ignore
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,6 @@ setup.py
test-requirements.txt
schematic_api/test/test_storage_controller.py
schematic_api/test/test_schema_controller.py
schematic_api/test/test_manifest_validation_controller.py
schematic_api/test/test_versions_controller.py
tox.ini
4 changes: 3 additions & 1 deletion apps/schematic/api/.openapi-generator/FILES
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
AUTHORS.md
schematic_api/__init__.py
schematic_api/controllers/__init__.py
schematic_api/controllers/manifest_validation_controller.py
schematic_api/controllers/schema_controller.py
schematic_api/controllers/security_controller_.py
schematic_api/controllers/storage_controller.py
Expand All @@ -20,6 +21,7 @@ schematic_api/models/file.py
schematic_api/models/files_page.py
schematic_api/models/files_page_all_of.py
schematic_api/models/manifest.py
schematic_api/models/manifest_validation_result.py
schematic_api/models/manifests_page.py
schematic_api/models/manifests_page_all_of.py
schematic_api/models/node.py
Expand All @@ -37,6 +39,6 @@ schematic_api/models/validation_rules_page.py
schematic_api/models/validation_rules_page_all_of.py
schematic_api/openapi/openapi.yaml
schematic_api/test/__init__.py
schematic_api/test/test_versions_controller.py
schematic_api/test/test_manifest_validation_controller.py
schematic_api/typing_utils.py
schematic_api/util.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,164 @@
import connexion
import six
from typing import Dict
from typing import Tuple
from typing import Union

from schematic_api.models.basic_error import BasicError # noqa: E501
from schematic_api.models.manifest_validation_result import (
ManifestValidationResult,
) # noqa: E501
from schematic_api import util
from schematic_api.controllers import manifest_validation_controller_impl


def submit_manifest_csv(
schema_url,
component,
dataset_id,
asset_view_id,
body,
restrict_rules=None,
storage_method=None,
hide_blanks=None,
table_manipulation_method=None,
use_schema_label=None,
): # noqa: E501
"""Validates manifest in csv form, then submits it

Validates manifest in csv form, then submits it # noqa: E501

:param schema_url: The URL of a schema in jsonld form
:type schema_url: str
:param component: A component in a schema, either the dsplay label or schema label
:type component: str
:param dataset_id: The ID of a dataset.
:type dataset_id: str
:param asset_view_id: ID of view listing all project data assets. E.g. for Synapse this would be the Synapse ID of the fileview listing all data assets for a given project
:type asset_view_id: str
:param body: .csv file
:type body: str
:param restrict_rules: If True, validation suite will only run with in-house validation rule. If False, the Great Expectations suite will be utilized and all rules will be available.
:type restrict_rules: bool
:param storage_method: file_and_entities will store the manifest as a csv and create Synapse files for each row in the manifest. table_and_file will store the manifest as a table and a csv on Synapse. file_only will store the manifest as a csv only on Synapse. table_file_and_entities will perform the options file_with_entites and table in combination.
:type storage_method: str
:param hide_blanks: If true, annotations with blank values will be hidden from a dataset's annotation list in Synaspe. If false, annotations with blank values will be displayed.
:type hide_blanks: bool
:param table_manipulation_method: replace will remove the rows and columns from the existing table and store the new rows and columns, preserving the name and synID. upsert will add the new rows to the table and preserve the exisitng rows and columns in the existing table.
:type table_manipulation_method: str
:param use_schema_label: If true, store attributes using the schema label If false, store attributes using the display label
:type use_schema_label: bool

:rtype: Union[str, Tuple[str, int], Tuple[str, int, Dict[str, str]]
"""
return manifest_validation_controller_impl.submit_manifest_csv(
schema_url,
component,
dataset_id,
asset_view_id,
body,
restrict_rules,
storage_method,
hide_blanks,
table_manipulation_method,
use_schema_label,
)


def submit_manifest_json(
schema_url,
component,
dataset_id,
asset_view_id,
restrict_rules=None,
storage_method=None,
hide_blanks=None,
table_manipulation_method=None,
use_schema_label=None,
body=None,
): # noqa: E501
"""Validates a manifest in json form, then submits it

Validates a manifest in json form, then submits it in csv form # noqa: E501

:param schema_url: The URL of a schema in jsonld form
:type schema_url: str
:param component: A component in a schema, either the dsplay label or schema label
:type component: str
:param dataset_id: The ID of a dataset.
:type dataset_id: str
:param asset_view_id: ID of view listing all project data assets. E.g. for Synapse this would be the Synapse ID of the fileview listing all data assets for a given project
:type asset_view_id: str
:param restrict_rules: If True, validation suite will only run with in-house validation rule. If False, the Great Expectations suite will be utilized and all rules will be available.
:type restrict_rules: bool
:param storage_method: file_and_entities will store the manifest as a csv and create Synapse files for each row in the manifest. table_and_file will store the manifest as a table and a csv on Synapse. file_only will store the manifest as a csv only on Synapse. table_file_and_entities will perform the options file_with_entites and table in combination.
:type storage_method: str
:param hide_blanks: If true, annotations with blank values will be hidden from a dataset's annotation list in Synaspe. If false, annotations with blank values will be displayed.
:type hide_blanks: bool
:param table_manipulation_method: replace will remove the rows and columns from the existing table and store the new rows and columns, preserving the name and synID. upsert will add the new rows to the table and preserve the exisitng rows and columns in the existing table.
:type table_manipulation_method: str
:param use_schema_label: If true, store attributes using the schema label If false, store attributes using the display label
:type use_schema_label: bool
:param body: A manifest in json form
:type body: str

:rtype: Union[str, Tuple[str, int], Tuple[str, int, Dict[str, str]]
"""
return manifest_validation_controller_impl.submit_manifest_json(
schema_url,
component,
dataset_id,
asset_view_id,
restrict_rules,
storage_method,
hide_blanks,
table_manipulation_method,
use_schema_label,
body,
)


def validate_manifest_csv(
schema_url, component_label, body, restrict_rules=None
): # noqa: E501
"""Validates a manifest in csv form

Validates a manifest in csv form # noqa: E501

:param schema_url: The URL of a schema in jsonld form
:type schema_url: str
:param component_label: The label of a component in a schema
:type component_label: str
:param body: .csv file
:type body: str
:param restrict_rules: If True, validation suite will only run with in-house validation rule. If False, the Great Expectations suite will be utilized and all rules will be available.
:type restrict_rules: bool

:rtype: Union[ManifestValidationResult, Tuple[ManifestValidationResult, int], Tuple[ManifestValidationResult, int, Dict[str, str]]
"""
return manifest_validation_controller_impl.validate_manifest_csv(
schema_url, component_label, body, restrict_rules
)


def validate_manifest_json(
schema_url, component_label, restrict_rules=None, body=None
): # noqa: E501
"""Validates a manifest in json form

Validates a manifest in json form # noqa: E501

:param schema_url: The URL of a schema in jsonld form
:type schema_url: str
:param component_label: The label of a component in a schema
:type component_label: str
:param restrict_rules: If True, validation suite will only run with in-house validation rule. If False, the Great Expectations suite will be utilized and all rules will be available.
:type restrict_rules: bool
:param body: A manifest in json form
:type body: str

:rtype: Union[ManifestValidationResult, Tuple[ManifestValidationResult, int], Tuple[ManifestValidationResult, int, Dict[str, str]]
"""
return manifest_validation_controller_impl.validate_manifest_json(
schema_url, component_label, restrict_rules, body
)
Loading