コード例 #1
0
ファイル: webservice.py プロジェクト: hetida/hetida-designer
async def structure(parentId: Optional[str] = None) -> StructureResponse:
    """The hierarchical structure for easy assignment of sources/sinks in user interfaces

    This endpoint is required by the hetida designer UI to show and allow assignment of sources
    and sinks from hierachical views. A hierarchy should be a domain view of the data sources
    and sinks that users of the designer understand and which helps them to easily find the
    sources / sinks they want to attach to their workflows by browsing through the hierarchy.

    Note that more than one hierarchy can be provided by delivering more than one root node.
    This can be used to provide different semantical views onto the same data, like e.g. a
    geographical hierarchy and a business unit hierarchy.

    This endpoint employs lazy loading, i.e. only one hierarchy level is returned on a call.

    If no `parentId` is specified this yields only the root thingNodes and no sources/sinks
    (sources / sinks attached to root nodes are not allowed in the user interface)

    If `parentId` is a valid thingNode id the response contains all the thingNodes, sources and
    sinks with this `parentId` as thingNodeId, i.e. every element directly attached to it.

    IMPORTANT: In a real adpater implementation the information should be queried from a
    masterdata system on every invocation. It should not be kept in memory like in this
    demo adapter as it may be too large and may change.
    """

    return StructureResponse(
        id="python-demo-adapter",
        name="Python Demo Adapter",
        thingNodes=get_thing_nodes(parentId, include_sub_objects=False),
        sources=get_sources(parentId, include_sub_objects=False),
        sinks=get_sinks(parentId, include_sub_objects=False),
    )
コード例 #2
0
async def structure(parentId: Optional[str] = None):
    """The hierarchical structure for easy assignment of sources/sinks in user interfaces

    This endpoint is required by the hetida designer UI to show and allow assignment of sources
    and sinks from hierachical views. A hierarchy should be a domain view of the data sources
    and sinks that users of the designer understand and which helps them to easily find the
    sources / sinks they want to attach to their workflows by browsing through the hierarchy.

    Note that more than one hierarchy can be provided by delivering more than one root node.
    This can be used to provide different semantical views onto the same data, like e.g. a
    geographical hierarchy and a business unit hierarchy.

    This endpoint employs lazy loading, i.e. only one hierarchy level is returned on a call.

    If no `parentId` is specified this yields only the root thingNodes and no sources/sinks
    (sources / sinks attached to root nodes are not allowed in the user interface)

    If `parentId` is a valid thingNode id the response contains all the thingNodes, sources and
    sinks with this `parentId` as thingNodeId, i.e. every element directly attached to it.
    """

    return {
        "id": "python-demo-adapter",
        "name": "Python Demo Adapter",
        "thingNodes": get_thing_nodes(parentId, include_sub_objects=False),
        "sources": get_sources(parentId, include_sub_objects=False),
        "sinks": get_sinks(parentId, include_sub_objects=False),
    }
コード例 #3
0
ファイル: webservice.py プロジェクト: hetida/hetida-designer
async def sink(sink_id: str) -> StructureSink:
    """Get a single sink by id"""
    requested_sinks = [
        snk for snk in get_sinks(include_sub_objects=True)
        if snk["id"] == sink_id
    ]
    if len(requested_sinks) > 1:
        msg = f"Error: Multiple sinks with same id {str(requested_sinks)}"
        logger.info(msg)
        raise HTTPException(500, msg)

    if len(requested_sinks) < 1:
        msg = f"Requested sink with id {sink_id} not found."
        logger.info(msg)
        raise HTTPException(404, msg)
    return StructureSink.parse_obj(requested_sinks[0])
コード例 #4
0
ファイル: webservice.py プロジェクト: hetida/hetida-designer
async def sinks(filter_str: Optional[str] = Query(
    None, alias="filter")) -> MultipleSinksResponse:
    return_sinks = get_sinks(filter_str=filter_str, include_sub_objects=True)

    return MultipleSinksResponse(resultCount=len(return_sinks),
                                 sinks=return_sinks)