Skip to content

Commit

Permalink
add generate manifest endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewelamb committed Jan 17, 2024
1 parent 436f7b0 commit e72c8a6
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 181 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,43 +10,6 @@
from schematic_api.controllers import manifest_generation_controller_impl


def generate_excel_manifest(
schema_url,
asset_view_id,
node_label,
add_annotations=None,
manifest_title=None,
dataset_id=None,
): # noqa: E501
"""Generates an excel file
Generates an excel file # noqa: E501
:param schema_url: The URL of a schema in jsonld form
:type schema_url: 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 node_label: The label of the source node in a schema
:type node_label: str
:param add_annotations: If true, annotations are added to the manifest
:type add_annotations: bool
:param manifest_title: If making one manifest, the title of the manifest If making multiple manifests, the prefix of the title of the manifests
:type manifest_title: str
:param dataset_id: The ID of a dataset.
:type dataset_id: str
:rtype: Union[file, Tuple[file, int], Tuple[file, int, Dict[str, str]]
"""
return manifest_generation_controller_impl.generate_excel_manifest(
schema_url,
asset_view_id,
node_label,
add_annotations,
manifest_title,
dataset_id,
)


def generate_google_sheet_manifests(
schema_url,
asset_view_id,
Expand Down
103 changes: 9 additions & 94 deletions apps/schematic/api/schematic_api/openapi/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1082,82 +1082,6 @@ paths:
tags:
- Schema
x-openapi-router-controller: schematic_api.controllers.schema_controller
/generateExcelManifest:
get:
description: Generates an excel file
operationId: generate_excel_manifest
parameters:
- description: The URL of a schema in jsonld form
explode: true
in: query
name: schemaUrl
required: true
schema:
$ref: '#/components/schemas/SchemaUrl'
style: form
- description: "If true, annotations are added to the manifest"
explode: true
in: query
name: addAnnotations
required: false
schema:
default: false
type: boolean
style: form
- description: 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
explode: true
in: query
name: assetViewId
required: true
schema:
$ref: '#/components/schemas/AssetViewId'
style: form
- description: "If making one manifest, the title of the manifest If making\
\ multiple manifests, the prefix of the title of the manifests"
explode: true
in: query
name: manifestTitle
required: false
schema:
type: string
style: form
- description: The label of the source node in a schema
explode: true
in: query
name: nodeLabel
required: true
schema:
$ref: '#/components/schemas/NodeLabel'
style: form
- description: The ID of a dataset.
explode: true
in: query
name: datasetId
required: false
schema:
$ref: '#/components/schemas/DatasetId'
style: form
responses:
"200":
content:
application/vnd.ms-excel:
schema:
format: binary
type: string
description: Success
"500":
content:
application/problem+json:
schema:
$ref: '#/components/schemas/BasicError'
description: The request cannot be fulfilled due to an unexpected server
error
summary: Generates an excel file
tags:
- ManifestGeneration
x-openapi-router-controller: schematic_api.controllers.manifest_generation_controller
/generateGoogleSheetManifests:
get:
description: Generates a list of google sheet links
Expand Down Expand Up @@ -2419,33 +2343,24 @@ components:
default: false
type: boolean
style: form
manifestTitle:
description: "If making one manifest, the title of the manifest If making multiple\
\ manifests, the prefix of the title of the manifests"
datasetIdArray:
description: An array of dataset ids
explode: true
in: query
name: manifestTitle
name: datasetIdArray
required: false
schema:
type: string
style: form
nodeLabelQuery:
description: The label of the source node in a schema
explode: true
in: query
name: nodeLabel
required: true
schema:
$ref: '#/components/schemas/NodeLabel'
$ref: '#/components/schemas/DatasetIdArray'
style: form
datasetIdArray:
description: An array of dataset ids
manifestTitle:
description: "If making one manifest, the title of the manifest If making multiple\
\ manifests, the prefix of the title of the manifests"
explode: true
in: query
name: datasetIdArray
name: manifestTitle
required: false
schema:
$ref: '#/components/schemas/DatasetIdArray'
type: string
style: form
nodeLabelArray:
description: An array of nodel labels
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@
)


class TestGenerateExcelManifests:
class GenerateExcelManifests:
"""Tests generate_excel_manifest"""

def test_success(self, test_schema_url: str) -> None:
def success(self, test_schema_url: str) -> None:
"""Test for successful result"""
with patch(GET_ACCESS_TOKEN_MOCK):
with patch(CREATE_SINGLE_MANIFEST_MOCK, return_value=BinaryIO()): # type: ignore
Expand All @@ -35,7 +35,7 @@ def test_success(self, test_schema_url: str) -> None:
assert status == 200
assert isinstance(result, BinaryIO)

def test_error_statuses(self) -> None:
def error_statuses(self) -> None:
"""Test for error statuses"""
with patch(GET_ACCESS_TOKEN_MOCK):
with patch(CREATE_SINGLE_MANIFEST_MOCK):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@

@pytest.mark.synapse
@pytest.mark.secrets
class TestGenerateExcelManifest(BaseTestCase):
class GenerateExcelManifest(BaseTestCase):
"""Tests google sheet manifest endpoint"""

def test_success(self) -> None:
Expand Down
50 changes: 7 additions & 43 deletions libs/schematic/api-description/build/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -753,35 +753,6 @@ paths:
$ref: '#/components/schemas/TangledTreeText'
'500':
$ref: '#/components/responses/InternalServerError'
/generateExcelManifest:
get:
tags:
- ManifestGeneration
summary: Generates an excel file
description: Generates an excel file
operationId: generateExcelManifest
parameters:
- $ref: '#/components/parameters/schemaUrl'
- $ref: '#/components/parameters/addAnnotations'
- $ref: '#/components/parameters/assetViewIdQuery'
- $ref: '#/components/parameters/manifestTitle'
- $ref: '#/components/parameters/nodeLabelQuery'
- name: datasetId
in: query
description: The ID of a dataset.
required: false
schema:
$ref: '#/components/schemas/DatasetId'
responses:
'200':
description: Success
content:
application/vnd.ms-excel:
schema:
type: string
format: binary
'500':
$ref: '#/components/responses/InternalServerError'
/generateGoogleSheetManifests:
get:
tags:
Expand Down Expand Up @@ -1537,27 +1508,20 @@ components:
schema:
type: boolean
default: false
manifestTitle:
name: manifestTitle
in: query
description: If making one manifest, the title of the manifest If making multiple manifests, the prefix of the title of the manifests
required: false
schema:
type: string
nodeLabelQuery:
name: nodeLabel
in: query
description: The label of the source node in a schema
required: true
schema:
$ref: '#/components/schemas/NodeLabel'
datasetIdArray:
name: datasetIdArray
in: query
description: An array of dataset ids
required: false
schema:
$ref: '#/components/schemas/DatasetIdArray'
manifestTitle:
name: manifestTitle
in: query
description: If making one manifest, the title of the manifest If making multiple manifests, the prefix of the title of the manifests
required: false
schema:
type: string
nodeLabelArray:
name: nodeLabelArray
in: query
Expand Down
3 changes: 0 additions & 3 deletions libs/schematic/api-description/src/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,5 @@ paths:
/tangledTreeText:
$ref: paths/tangledTreeText.yaml

/generateExcelManifest:
$ref: paths/generateExcelManifest.yaml

/generateGoogleSheetManifests:
$ref: paths/generateGoogleSheetManifests.yaml

0 comments on commit e72c8a6

Please sign in to comment.