"""Simple helper to paginate query  """  from flask import request, url_for    DEFAULT_PAGE_SIZE = 50  DEFAULT_PAGE_NUMBER = 1      def extract_pagination(page=None, per_page=None, **request_args):      page = int(page) if page is not None else DEFAULT_PAGE_NUMBER      per_page = int(per_page) if per_page is not None else DEFAULT_PAGE_SIZE      return page, per_page, request_args      def paginate(query, schema):      page, per_page, other_request_args = extract_pagination(**request.args)      page_obj = query.paginate(page=page, per_page=per_page)      next_ = url_for(          request.endpoint,          page=page_obj.next_num if page_obj.has_next else page_obj.page,          per_page=per_page,          **other_request_args,          **request.view_args      )      prev = url_for(          request.endpoint,          page=page_obj.prev_num if page_obj.has_prev else page_obj.page,          per_page=per_page,          **other_request_args,          **request.view_args      )        return {          "total": page_obj.total,          "pages": page_obj.pages,          "next": next_,          "prev": prev,          "results": schema.dump(page_obj.items),      }


from . import error_handler, views    __all__ = ["views", "error_handler"]


from flask import jsonify  from marshmallow import ValidationError    from taipy.core.exceptions.exceptions import (      NonExistingCycle,      NonExistingDataNode,      NonExistingDataNodeConfig,      NonExistingJob,      NonExistingScenario,      NonExistingScenarioConfig,      NonExistingSequence,      NonExistingSequenceConfig,      NonExistingTask,      NonExistingTaskConfig,  )    from .exceptions.exceptions import ConfigIdMissingException, ScenarioIdMissingException, SequenceNameMissingException  from .views import blueprint      def _create_404(e):      return {"message": e.message}, 404      @blueprint.errorhandler(ValidationError)  def handle_marshmallow_error(e):      """Return json error for marshmallow validation errors.        This will avoid having to try/catch ValidationErrors in all endpoints, returning      correct JSON response with associated HTTP 400 Status (https://tools.ietf.org/html/rfc7231#section-6.5.1)      """      return jsonify(e.messages), 400      @blueprint.errorhandler(ConfigIdMissingException)  def handle_config_id_missing_exception(e):      return jsonify({"message": e.message}), 400      @blueprint.errorhandler(ScenarioIdMissingException)  def handle_scenario_id_missing_exception(e):      return jsonify({"message": e.message}), 400      @blueprint.errorhandler(SequenceNameMissingException)  def handle_sequence_name_missing_exception(e):      return jsonify({"message": e.message}), 400      @blueprint.errorhandler(NonExistingDataNode)  def handle_data_node_not_found(e):      return _create_404(e)      @blueprint.errorhandler(NonExistingDataNodeConfig)  def handle_data_node_config_not_found(e):      return _create_404(e)      @blueprint.errorhandler(NonExistingCycle)  def handle_cycle_not_found(e):      return _create_404(e)      @blueprint.errorhandler(NonExistingJob)  def handle_job_not_found(e):      return _create_404(e)      @blueprint.errorhandler(NonExistingSequence)  def handle_sequence_not_found(e):      return _create_404(e)      @blueprint.errorhandler(NonExistingSequenceConfig)  def handle_sequence_config_not_found(e):      return _create_404(e)      @blueprint.errorhandler(NonExistingScenario)  def handle_scenario_not_found(e):      return _create_404(e)      @blueprint.errorhandler(NonExistingScenarioConfig)  def handle_scenario_config_not_found(e):      return _create_404(e)      @blueprint.errorhandler(NonExistingTask)  def handle_task_not_found(e):      return _create_404(e)      @blueprint.errorhandler(NonExistingTaskConfig)  def handle_task_config_not_found(e):      return _create_404(e)


from flask import Blueprint, current_app  from flask_restful import Api    from taipy.core.common._utils import _load_fct  from taipy.logger._taipy_logger import _TaipyLogger    from ..extensions import apispec  from .middlewares._middleware import _using_enterprise  from .resources import (      CycleList,      CycleResource,      DataNodeList,      DataNodeReader,      DataNodeResource,      DataNodeWriter,      JobExecutor,      JobList,      JobResource,      ScenarioExecutor,      ScenarioList,      ScenarioResource,      SequenceExecutor,      SequenceList,      SequenceResource,      TaskExecutor,      TaskList,      TaskResource,  )  from .schemas import CycleSchema, DataNodeSchema, JobSchema, ScenarioSchema, SequenceSchema, TaskSchema    _logger = _TaipyLogger._get_logger()      blueprint = Blueprint("api", __name__, url_prefix="/api/v1")    api = Api(blueprint)    api.add_resource(      DataNodeResource,      "/datanodes/<string:datanode_id>/",      endpoint="datanode_by_id",      resource_class_kwargs={"logger": _logger},  )    api.add_resource(      DataNodeReader,      "/datanodes/<string:datanode_id>/read/",      endpoint="datanode_reader",      resource_class_kwargs={"logger": _logger},  )    api.add_resource(      DataNodeWriter,      "/datanodes/<string:datanode_id>/write/",      endpoint="datanode_writer",      resource_class_kwargs={"logger": _logger},  )    api.add_resource(      DataNodeList,      "/datanodes/",      endpoint="datanodes",      resource_class_kwargs={"logger": _logger},  )    api.add_resource(      TaskResource,      "/tasks/<string:task_id>/",      endpoint="task_by_id",      resource_class_kwargs={"logger": _logger},  )    api.add_resource(TaskList, "/tasks/", endpoint="tasks", resource_class_kwargs={"logger": _logger})  api.add_resource(      TaskExecutor,      "/tasks/submit/<string:task_id>/",      endpoint="task_submit",      resource_class_kwargs={"logger": _logger},  )    api.add_resource(      SequenceResource,      "/sequences/<string:sequence_id>/",      endpoint="sequence_by_id",      resource_class_kwargs={"logger": _logger},  )  api.add_resource(      SequenceList,      "/sequences/",      endpoint="sequences",      resource_class_kwargs={"logger": _logger},  )  api.add_resource(      SequenceExecutor,      "/sequences/submit/<string:sequence_id>/",      endpoint="sequence_submit",      resource_class_kwargs={"logger": _logger},  )    api.add_resource(      ScenarioResource,      "/scenarios/<string:scenario_id>/",      endpoint="scenario_by_id",      resource_class_kwargs={"logger": _logger},  )  api.add_resource(      ScenarioList,      "/scenarios/",      endpoint="scenarios",      resource_class_kwargs={"logger": _logger},  )  api.add_resource(      ScenarioExecutor,      "/scenarios/submit/<string:scenario_id>/",      endpoint="scenario_submit",      resource_class_kwargs={"logger": _logger},  )    api.add_resource(      CycleResource,      "/cycles/<string:cycle_id>/",      endpoint="cycle_by_id",      resource_class_kwargs={"logger": _logger},  )  api.add_resource(      CycleList,      "/cycles/",      endpoint="cycles",      resource_class_kwargs={"logger": _logger},  )    api.add_resource(      JobResource,      "/jobs/<string:job_id>/",      endpoint="job_by_id",      resource_class_kwargs={"logger": _logger},  )  api.add_resource(JobList, "/jobs/", endpoint="jobs", resource_class_kwargs={"logger": _logger})  api.add_resource(      JobExecutor,      "/jobs/cancel/<string:job_id>/",      endpoint="job_cancel",      resource_class_kwargs={"logger": _logger},  )      def load_enterprise_resources(api: Api):      """      Load enterprise resources.      """        if not _using_enterprise():          return      load_resources = _load_fct("taipy.enterprise.rest.api.views", "_load_resources")      load_resources(api)      load_enterprise_resources(api)      def register_views():      apispec.spec.components.schema("DataNodeSchema", schema=DataNodeSchema)      apispec.spec.path(view=DataNodeResource, app=current_app)      apispec.spec.path(view=DataNodeList, app=current_app)      apispec.spec.path(view=DataNodeReader, app=current_app)      apispec.spec.path(view=DataNodeWriter, app=current_app)        apispec.spec.components.schema("TaskSchema", schema=TaskSchema)      apispec.spec.path(view=TaskResource, app=current_app)      apispec.spec.path(view=TaskList, app=current_app)      apispec.spec.path(view=TaskExecutor, app=current_app)        apispec.spec.components.schema("SequenceSchema", schema=SequenceSchema)      apispec.spec.path(view=SequenceResource, app=current_app)      apispec.spec.path(view=SequenceList, app=current_app)      apispec.spec.path(view=SequenceExecutor, app=current_app)        apispec.spec.components.schema("ScenarioSchema", schema=ScenarioSchema)      apispec.spec.path(view=ScenarioResource, app=current_app)      apispec.spec.path(view=ScenarioList, app=current_app)      apispec.spec.path(view=ScenarioExecutor, app=current_app)        apispec.spec.components.schema("CycleSchema", schema=CycleSchema)      apispec.spec.path(view=CycleResource, app=current_app)      apispec.spec.path(view=CycleList, app=current_app)        apispec.spec.components.schema("JobSchema", schema=JobSchema)      apispec.spec.path(view=JobResource, app=current_app)      apispec.spec.path(view=JobList, app=current_app)      apispec.spec.path(view=JobExecutor, app=current_app)        apispec.spec.components.schema(          "Any",          {              "description": "Any value",              "nullable": True,          },      )        if _using_enterprise():          _register_views = _load_fct("taipy.enterprise.rest.api.views", "_register_views")          _register_views(apispec)


from datetime import datetime    from flask import request  from flask_restful import Resource    from taipy.config.common.frequency import Frequency  from taipy.core import Cycle  from taipy.core.cycle._cycle_manager_factory import _CycleManagerFactory  from taipy.core.exceptions.exceptions import NonExistingCycle    from ...commons.to_from_model import _to_model  from ..middlewares._middleware import _middleware  from ..schemas import CycleResponseSchema, CycleSchema    REPOSITORY = "cycle"      def _get_or_raise(cycle_id: str) -> None:      manager = _CycleManagerFactory._build_manager()      cycle = manager._get(cycle_id)      if not cycle:          raise NonExistingCycle(cycle_id)      return cycle      class CycleResource(Resource):      """Single object resource        ---      get:        tags:          - api        description: |          Returns a `CycleSchema^` representing the unique `Cycle^` identified by the *cycle_id*          given as parameter. If no cycle corresponds to *cycle_id*, a `404` error is returned.            !!! Example                === "Curl"                  ```shell                      curl -X GET http://localhost:5000/api/v1/cycles/CYCLE_223894_e0fab919-b50b-4b9f-ac09-52f77474fa7a                  ```                  In this example the REST API is served on port 5000 on localhost. We are using curl command line                  client.                    `CYCLE_223894_e0fab919-b50b-4b9f-ac09-52f77474fa7a` is the value of the *cycle_id* parameter. It                  represents the identifier of the Cycle we want to retrieve.                    In case of success here is an example of the response:                  ``` JSON                  {"cycle": {                      "frequency": "Frequency.DAILY",                      "creation_date": "2022-08-04T17:13:32.797384",                      "id": "CYCLE_223894_e0fab919-b50b-4b9f-ac09-52f77474fa7a",                      "start_date": "2022-08-04T00:00:00",                      "end_date": "2022-08-04T23:59:59.999999",                      "name": "Frequency.DAILY_2022-08-04T17:13:32.797384"                  ```                    In case of failure here is an example of the response:                  ``` JSON                  {"message": "Cycle CYCLE_223894_e0fab919-b50b-4b9f-ac09-52f77474fa7a not found."}                  ```                === "Python"                  This Python example requires the 'requests' package to be installed (`pip install requests`).                  ```python                  import requests                      response = requests.get("http://localhost:5000/api/v1/cycles/CYCLE_223894_e0fab919-b50b-4b9f-ac09-52f77474fa7a")                      print(response)                      print(response.json())                  ```                  `CYCLE_223894_e0fab919-b50b-4b9f-ac09-52f77474fa7a` is the value of the  *cycle_id* parameter. It                  represents the identifier of the Cycle we want to retrieve.                    In case of success here is an output example:                  ```                  <Response [200]>                  {'cycle': {                      'frequency': 'Frequency.DAILY',                      'creation_date': '2022-08-04T17:13:32.797384',                      'id': 'CYCLE_223894_e0fab919-b50b-4b9f-ac09-52f77474fa7a',                      'start_date': '2022-08-04T00:00:00',                      'end_date': '2022-08-04T23:59:59.999999',                      'name': 'Frequency.DAILY_2022-08-04T17:13:32.797384'                  ```                    In case of failure here is an output example:                  ```                  <Response [404]>                  {'message': 'Cycle CYCLE_223894_e0fab919-b50b-4b9f-ac09-52f77474fa7a not found.'}                    ```            !!! Note            When the authorization feature is activated (available in Taipy Enterprise edition only), this endpoint              requires the `TAIPY_READER` role.          parameters:          - in: path            name: cycle_id            schema:              type: string            description: The identifier of the cycle to retrieve.        responses:          200:            content:              application/json:                schema:                  type: object                  properties:                    cycle: CycleSchema          404:            description: No cycle has the *cycle_id* identifier.      delete:        tags:          - api        description: |          Deletes the `Cycle^` identified by the  *cycle_id* given as parameter. If the cycle does not exist,          a 404 error is returned.            !!! Example                === "Curl"                  ```shell                      curl -X DELETE http://localhost:5000/api/v1/cycles/CYCLE_223894_e0fab919-b50b-4b9f-ac09-52f77474fa7a                  ```                  In this example the REST API is served on port 5000 on localhost. We are using curl command line                  client.                    `CYCLE_223894_e0fab919-b50b-4b9f-ac09-52f77474fa7a` is the value of the  *cycle_id* parameter. It                  represents the identifier of the Cycle we want to delete.                    In case of success here is an example of the response:                  ``` JSON                  {"message": "Cycle CYCLE_223894_e0fab919-b50b-4b9f-ac09-52f77474fa7a was deleted."}                  ```                    In case of failure here is an example of the response:                  ``` JSON                  {"message": "Cycle CYCLE_223894_e0fab919-b50b-4b9f-ac09-52f77474fa7a not found."}                  ```                === "Python"                  This Python example requires the 'requests' package to be installed (`pip install requests`).                  ```python                  import requests                      response = requests.delete("http://localhost:5000/api/v1/cycles/CYCLE_797384_ef210412-af91-4f41-b6e8-74d1648edcba")                      print(response)                      print(response.json())                  ```                  `CYCLE_223894_e0fab919-b50b-4b9f-ac09-52f77474fa7a` is the value of the  *cycle_id* parameter. It                  represents the identifier of the Cycle we want to delete.                    In case of success here is an output example:                  ```                  <Response [200]>                  {"message": "Cycle CYCLE_223894_e0fab919-b50b-4b9f-ac09-52f77474fa7a was deleted."}                  ```                    In case of failure here is an output example:                  ```                  <Response [404]>                  {'message': 'Cycle CYCLE_223894_e0fab919-b50b-4b9f-ac09-52f77474fa7a not found.'}                    ```            !!! Note              When the authorization feature is activated (available in Taipy Enterprise edition only), this endpoint              requires the `TAIPY_EDITOR` role.          parameters:          - in: path            name: cycle_id            schema:              type: string            description: The id of the cycle to delete.        responses:          200:            content:              application/json:                schema:                  type: object                  properties:                    message:                      type: string                      description: Status message.          404:            description: No cycle has the  *cycle_id* identifier.      """        def __init__(self, **kwargs):          self.logger = kwargs.get("logger")        @_middleware      def get(self, cycle_id):          schema = CycleResponseSchema()          cycle = _get_or_raise(cycle_id)          return {"cycle": schema.dump(_to_model(REPOSITORY, cycle))}        @_middleware      def delete(self, cycle_id):          manager = _CycleManagerFactory._build_manager()          _get_or_raise(cycle_id)          manager._delete(cycle_id)          return {"message": f"Cycle {cycle_id} was deleted."}      class CycleList(Resource):      """Creation and get_all        ---      get:        tags:          - api        description: |          Returns a `CycleSchema^` list representing all existing Cycles.            !!! Example                === "Curl"                  ```shell                      curl -X GET http://localhost:5000/api/v1/cycles                  ```                  In this example the REST API is served on port 5000 on localhost. We are using curl command line                  client.                    Here is an example of the response:                  ``` JSON                  [                      {                      "frequency": "Frequency.DAILY",                      "end_date": "2022-08-06T23:59:59.999999",                      "creation_date": "2022-08-06T15:45:50.223894",                      "start_date": "2022-08-06T00:00:00",                      "id": "CYCLE_223894_e0fab919-b50b-4b9f-ac09-52f77474fa7a",                      "name": "Frequency.DAILY_2022-08-06T15:45:50.223894"                      }                  ]                  ```                    If there is no cycle, the response is an empty list as follows:                  ``` JSON                  []                  ```                === "Python"                  This Python example requires the 'requests' package to be installed (`pip install requests`).                  ```python                  import requests                      response = requests.get("http://localhost:5000/api/v1/cycles")                      print(response)                      print(response.json())                  ```                    In case of success here is an output example:                  ```                  <Response [200]>                  [{                      "frequency": "Frequency.DAILY",                      "end_date": "2022-08-06T23:59:59.999999",                      "creation_date": "2022-08-06T15:45:50.223894",                      "start_date": "2022-08-06T00:00:00",                      "id": "CYCLE_223894_e0fab919-b50b-4b9f-ac09-52f77474fa7a",                      "name": "Frequency.DAILY_2022-08-06T15:45:50.223894"                      }                  ]                  ```                    If there is no cycle, the response is an empty list as follows:                  ```                  <Response [200]>                  []                  ```            !!! Note              When the authorization feature is activated (available in Taipy Enterprise edition only), this endpoint              requires the `TAIPY_READER` role.          responses:          200:            content:              application/json:                schema:                  allOf:                    - type: object                      properties:                        results:                          type: array                          items:                            $ref: '#/components/schemas/CycleSchema'      post:        tags:          - api        description: |          Creates a new cycle from the `CycleSchema^` given in the request body.            !!! Example                === "Curl"                  ```shell                      curl -X POST -H "Content-Type: application/json"\                      -d '{"frequency": "DAILY", "properties": {}, "creation_date": "2020-01-01T00:00:00",\                      "start_date": "2020-01-01T00:00:00", "end_date": "2020-01-01T00:00:00"}'\                      http://localhost:5000/api/v1/cycles                  ```                  In this example the REST API is served on port 5000 on localhost. We are using curl command line                  client.                    In the curl command line, a `CycleSchema^` is provided as JSON dictionary parameter with the curl                  option -d (--data) to specify the various attributes of the `Cycle^` to create:                  ``` JSON                  {                      "frequency": "DAILY",                      "properties": {},                      "creation_date": "2020-01-01T00:00:00",                      "start_date": "2020-01-01T00:00:00",                      "end_date": "2020-01-01T00:00:00"                  }                  ```                === "Python"                  This Python example requires the 'requests' package to be installed (`pip install requests`).                  ```python                  import requests                      cycle_schema = {                          "frequency": "DAILY",                          "properties": {},                          "creation_date": "2020-01-01T00:00:00",                          "start_date": "2020-01-01T00:00:00",                          "end_date": "2020-01-01T00:00:00"                      }                      response = requests.post("http://localhost:5000/api/v1/cycles", json=cycle_schema)                      print(response)                      print(response.json())                  ```                  A `CycleSchema^` is provided as a dictionary to specify the various attributes of the `Cycle^` to                  create.                    Here is the output example:                  ```                  <Response [201]>                  {                      'message': 'Cycle was created.',                      'cycle': {                          'frequency': 'Frequency.DAILY',                          'end_date': '2020-01-01T00:00:00',                          'creation_date': '2020-01-01T00:00:00',                          'start_date': '2020-01-01T00:00:00',                          'id': 'CYCLE_c9cc527f-a8c8-4238-8f31-42166a9817db',                          'name': 'Frequency.DAILY_2020-01-01T00:00:00',                          'properties': {}}}                  ```            !!! Note              When the authorization feature is activated (available in Taipy Enterprise edition only), this endpoint              requires the `TAIPY_EDITOR` role.          requestBody:          required: true          content:            application/json:              schema:                CycleSchema        responses:          201:            content:              application/json:                schema:                  type: object                  properties:                    message:                      type: string                      description: Status message.                    cycle: CycleSchema      """        def __init__(self, **kwargs):          self.logger = kwargs.get("logger")        @_middleware      def get(self):          schema = CycleResponseSchema(many=True)          manager = _CycleManagerFactory._build_manager()          cycles = [_to_model(REPOSITORY, cycle) for cycle in manager._get_all()]          return schema.dump(cycles)        @_middleware      def post(self):          schema = CycleResponseSchema()          manager = _CycleManagerFactory._build_manager()            cycle = self.__create_cycle_from_schema(schema.load(request.json))          manager._set(cycle)            return {              "message": "Cycle was created.",              "cycle": schema.dump(_to_model(REPOSITORY, cycle)),          }, 201        def __create_cycle_from_schema(self, cycle_schema: CycleSchema):          return Cycle(              id=cycle_schema.get("id"),              frequency=Frequency(getattr(Frequency, cycle_schema.get("frequency", "").upper())),              properties=cycle_schema.get("properties", {}),              creation_date=datetime.fromisoformat(cycle_schema.get("creation_date")),              start_date=datetime.fromisoformat(cycle_schema.get("start_date")),              end_date=datetime.fromisoformat(cycle_schema.get("end_date")),          )


from flask import request  from flask_restful import Resource    from taipy.config.config import Config  from taipy.core.exceptions.exceptions import NonExistingTask, NonExistingTaskConfig  from taipy.core.task._task_manager_factory import _TaskManagerFactory    from ...commons.to_from_model import _to_model  from ..exceptions.exceptions import ConfigIdMissingException  from ..middlewares._middleware import _middleware  from ..schemas import TaskSchema      def _get_or_raise(task_id: str):      manager = _TaskManagerFactory._build_manager()      task = manager._get(task_id)      if task is None:          raise NonExistingTask(task_id)      return task      REPOSITORY = "task"      class TaskResource(Resource):      """Single object resource        ---      get:        tags:          - api        summary: Get a task.        description: |          Return a single task by *task_id*. If the task does not exist, a 404 error is returned.            !!! Note            When the authorization feature is activated (available in the **Enterprise** edition only), this endpoint            requires `TAIPY_READER` role.            Code example:            ```shell            curl -X GET http://localhost:5000/api/v1/tasks/TASK_my_config_75750ed8-4e09-4e00-958d-e352ee426cc9          ```          parameters:          - in: path            name: task_id            schema:              type: string            description: The identifier of the task.        responses:          200:            content:              application/json:                schema:                  type: object                  properties:                    task: TaskSchema          404:            description: No task has the *task_id* identifier.      delete:        tags:          - api        summary: Delete a task.        description: |          Delete a task. If the task does not exist, a 404 error is returned.            !!! Note            When the authorization feature is activated (available in the **Enterprise** edition only), this endpoint            requires `TAIPY_EDITOR` role.            Code example:            ```shell            curl -X DELETE http://localhost:5000/api/v1/tasks/TASK_my_config_75750ed8-4e09-4e00-958d-e352ee426cc9          ```        parameters:          - in: path            name: task_id            schema:              type: string            description: The identifier of the task.        responses:          200:            content:              application/json:                schema:                  type: object                  properties:                    message:                      type: string                      description: Status message.          404:            description: No task has the *task_id* identifier.      """        def __init__(self, **kwargs):          self.logger = kwargs.get("logger")        @_middleware      def get(self, task_id):          schema = TaskSchema()          task = _get_or_raise(task_id)          return {"task": schema.dump(_to_model(REPOSITORY, task))}        @_middleware      def delete(self, task_id):          manager = _TaskManagerFactory._build_manager()          _get_or_raise(task_id)          manager._delete(task_id)          return {"message": f"Task {task_id} was deleted."}      class TaskList(Resource):      """Creation and get_all        ---      get:        tags:          - api        summary: Get all tasks.        description: |          Return an array of all tasks.            !!! Note            When the authorization feature is activated (available in the **Enterprise** edition only), this endpoint            requires `TAIPY_READER` role.            Code example:            ```shell            curl -X GET http://localhost:5000/api/v1/tasks          ```          responses:          200:            content:              application/json:                schema:                  allOf:                    - type: object                      properties:                        results:                          type: array                          items:                            $ref: '#/components/schemas/TaskSchema'      post:        tags:          - api        summary: Create a task.        description: |          Create a new task from its *config_id*. If the config does not exist, a 404 error is returned.            !!! Note            When the authorization feature is activated (available in the **Enterprise** edition only), this endpoint            requires `TAIPY_EDITOR` role.            Code example:            ```shell            curl -X POST http://localhost:5000/api/v1/tasks?config_id=my_task_config          ```        parameters:          - in: query            name: config_id            schema:              type: string            description: The identifier of the task configuration.        responses:          201:            content:              application/json:                schema:                  type: object                  properties:                    message:                      type: string                      description: Status message.                    task: TaskSchema      """        def __init__(self, **kwargs):          self.logger = kwargs.get("logger")        def fetch_config(self, config_id):          config = Config.tasks.get(config_id)          if not config:              raise NonExistingTaskConfig(config_id)          return config        @_middleware      def get(self):          schema = TaskSchema(many=True)          manager = _TaskManagerFactory._build_manager()          tasks = [_to_model(REPOSITORY, task) for task in manager._get_all()]          return schema.dump(tasks)        @_middleware      def post(self):          args = request.args          config_id = args.get("config_id")            schema = TaskSchema()          manager = _TaskManagerFactory._build_manager()          if not config_id:              raise ConfigIdMissingException            config = self.fetch_config(config_id)          task = manager._bulk_get_or_create([config])[0]            return {              "message": "Task was created.",              "task": schema.dump(_to_model(REPOSITORY, task)),          }, 201      class TaskExecutor(Resource):      """Execute a task        ---      post:        tags:          - api        summary: Execute a task.        description: |          Execute a task by *task_id*. If the task does not exist, a 404 error is returned.            !!! Note            When the authorization feature is activated (available in the **Enterprise** edition only), this endpoint            requires `TAIPY_EXECUTOR` role.            Code example:            ```shell            curl -X POST http://localhost:5000/api/v1/tasks/submit/TASK_my_config_75750ed8-4e09-4e00-958d-e352ee426cc9          ```          parameters:          - in: path            name: task_id            schema:              type: string        responses:          204:            content:              application/json:                schema:                  type: object                  properties:                    message:                      type: string                      description: Status message.                    task: TaskSchema          404:            description: No task has the *task_id* identifier.      """        def __init__(self, **kwargs):          self.logger = kwargs.get("logger")        @_middleware      def post(self, task_id):          manager = _TaskManagerFactory._build_manager()          task = _get_or_raise(task_id)          manager._orchestrator().submit_task(task)          return {"message": f"Task {task_id} was submitted."}


import uuid  from typing import Optional    from flask import request  from flask_restful import Resource    from taipy.config.config import Config  from taipy.core import Job, JobId  from taipy.core.exceptions.exceptions import NonExistingJob, NonExistingTaskConfig  from taipy.core.job._job_manager_factory import _JobManagerFactory  from taipy.core.task._task_manager_factory import _TaskManagerFactory    from ..exceptions.exceptions import ConfigIdMissingException  from ..middlewares._middleware import _middleware  from ..schemas import JobSchema      def _get_or_raise(job_id: str):      manager = _JobManagerFactory._build_manager()      job = manager._get(job_id)      if job is None:          raise NonExistingJob(job_id)      return job      class JobResource(Resource):      """Single object resource        ---      get:        tags:          - api        summary: Get a job.        description: |          Return a single job by *job_id*. If the job does not exist, a 404 error is returned.            !!! Note            When the authorization feature is activated (available in the **Enterprise** edition only), the            endpoint requires `TAIPY_READER` role.            Code example:            ```shell            curl -X GET http://localhost:5000/api/v1/jobs/JOB_my_task_config_75750ed8-4e09-4e00-958d-e352ee426cc9          ```          parameters:          - in: path            name: job_id            schema:              type: string            description: The identifier of the job.        responses:          200:            content:              application/json:                schema:                  type: object                  properties:                    job: JobSchema          404:            description: No job has the *job_id* identifier.      delete:        tags:          - api        summary: Delete a job.        description: |          Delete a job. If the job does not exist, a 404 error is returned.            !!! Note            When the authorization feature is activated (available in the **Enterprise** edition only), the endpoint            requires `TAIPY_EDITOR` role.            Code example:            ```shell            curl -X DELETE http://localhost:5000/api/v1/jobs/JOB_my_task_config_75750ed8-4e09-4e00-958d-e352ee426cc9          ```          parameters:          - in: path            name: job_id            schema:              type: string            description: The identifier of the job.        responses:          200:            content:              application/json:                schema:                  type: object                  properties:                    message:                      type: string                      description: Status message.          404:            description: No job has the *job_id* identifier.      """        def __init__(self, **kwargs):          self.logger = kwargs.get("logger")        @_middleware      def get(self, job_id):          schema = JobSchema()          job = _get_or_raise(job_id)          return {"job": schema.dump(job)}        @_middleware      def delete(self, job_id):          manager = _JobManagerFactory._build_manager()          job = _get_or_raise(job_id)          manager._delete(job)          return {"message": f"Job {job_id} was deleted."}      class JobList(Resource):      """Creation and get_all        ---      get:        tags:          - api        summary: Get all jobs.        description: |          Return an array of all jobs.            !!! Note            When the authorization feature is activated (available in the **Enterprise** edition only), the endpoint            requires `TAIPY_READER` role.            Code example:            ```shell            curl -X GET http://localhost:5000/api/v1/jobs          ```          responses:          200:            content:              application/json:                schema:                  allOf:                    - type: object                      properties:                        results:                          type: array                          items:                            $ref: '#/components/schemas/JobSchema'      post:        tags:          - api        summary: Create a job.        description: |          Create a job from a task *config_id*. If the config does not exist, a 404 error is returned.            !!! Note            When the authorization feature is activated (available in the **Enterprise** edition only), the endpoint            requires `TAIPY_EDITOR` role.            Code example:            ```shell            curl -X POST http://localhost:5000/api/v1/jobs?task_id=TASK_my_config_75750ed8-4e09-4e00-958d-e352ee426cc9          ```          parameters:          - in: query            name: task_id            schema:              type: string            description: The identifier of the task configuration.        responses:          201:            content:              application/json:                schema:                  type: object                  properties:                    message:                      type: string                      description: Status message.                    job: JobSchema      """        def __init__(self, **kwargs):          self.logger = kwargs.get("logger")        def fetch_config(self, config_id):          config = Config.tasks.get(config_id)          if not config:              raise NonExistingTaskConfig(config_id)          return config        @_middleware      def get(self):          schema = JobSchema(many=True)          manager = _JobManagerFactory._build_manager()          jobs = manager._get_all()          return schema.dump(jobs)        @_middleware      def post(self):          args = request.args          task_config_id = args.get("task_id")            if not task_config_id:              raise ConfigIdMissingException            manager = _JobManagerFactory._build_manager()          schema = JobSchema()          job = self.__create_job_from_schema(task_config_id)          manager._set(job)          return {              "message": "Job was created.",              "job": schema.dump(job),          }, 201        def __create_job_from_schema(self, task_config_id: str) -> Optional[Job]:          task_manager = _TaskManagerFactory._build_manager()          task = task_manager._bulk_get_or_create([self.fetch_config(task_config_id)])[0]          return Job(              id=JobId(f"JOB_{uuid.uuid4()}"), task=task, submit_id=f"SUBMISSION_{uuid.uuid4()}", submit_entity_id=task.id          )      class JobExecutor(Resource):      """Cancel a job        ---      post:        tags:          - api        summary: Cancel a job.        description: |          Cancel a job by *job_id*. If the job does not exist, a 404 error is returned.            !!! Note            When the authorization feature is activated (available in the **Enterprise** edition only), the endpoint            requires `TAIPY_EXECUTOR` role.            Code example:            ```shell            curl -X POST http://localhost:5000/api/v1/jobs/cancel/JOB_my_task_config_75750ed8-4e09-4e00-958d-e352ee426cc9          ```          parameters:          - in: path            name: job_id            schema:              type: string        responses:          204:            content:              application/json:                schema:                  type: object                  properties:                    message:                      type: string                      description: Status message.                    job: JobSchema          404:            description: No job has the *job_id* identifier.      """        def __init__(self, **kwargs):          self.logger = kwargs.get("logger")        @_middleware      def post(self, job_id):          manager = _JobManagerFactory._build_manager()          job = _get_or_raise(job_id)          manager._cancel(job)          return {"message": f"Job {job_id} was cancelled."}


from flask import request  from flask_restful import Resource    from taipy.core.exceptions.exceptions import NonExistingScenario, NonExistingSequence  from taipy.core.scenario._scenario_manager_factory import _ScenarioManagerFactory  from taipy.core.sequence._sequence_manager_factory import _SequenceManagerFactory    from ...commons.to_from_model import _to_model  from ..exceptions.exceptions import ScenarioIdMissingException, SequenceNameMissingException  from ..middlewares._middleware import _middleware  from ..schemas import SequenceResponseSchema      def _get_or_raise(sequence_id: str):      manager = _SequenceManagerFactory._build_manager()      sequence = manager._get(sequence_id)      if sequence is None:          raise NonExistingSequence(sequence_id)      return sequence      REPOSITORY = "sequence"      class SequenceResource(Resource):      """Single object resource        ---      get:        tags:          - api        summary: Get a sequence.        description: |          Return a single sequence by sequence_id. If the sequence does not exist, a 404 error is returned.            !!! Note            When the authorization feature is activated (available in the **Enterprise** edition only), this endpoint            requires _TAIPY_READER_ role.            Code example:            ```shell            curl -X GET http://localhost:5000/api/v1/sequences/SEQUENCE_my_config_75750ed8-4e09-4e00-958d-e352ee426cc9          ```          parameters:          - in: path            name: sequence_id            schema:              type: string            description: The identifier of the sequence.        responses:          200:            content:              application/json:                schema:                  type: object                  properties:                    sequence: SequenceSchema          404:            description: No sequence has the *sequence_id* identifier.      delete:        tags:          - api        summary: Delete a sequence.        description: |          Delete a sequence. If the sequence does not exist, a 404 error is returned.            !!! Note            When the authorization feature is activated (available in the **Enterprise** edition only), this endpoint            requires _TAIPY_EDITOR_ role.            Code example:            ```shell            curl -X DELETE http://localhost:5000/api/v1/sequences/SEQUENCE_my_config_75750ed8-4e09-4e00-958d-e352ee426cc9          ```          parameters:          - in: path            name: sequence_id            schema:              type: string            description: The identifier of the sequence.        responses:          200:            content:              application/json:                schema:                  type: object                  properties:                    message:                      type: string                      description: Status message.          404:            description: No sequence has the *sequence_id* identifier.      """        def __init__(self, **kwargs):          self.logger = kwargs.get("logger")        @_middleware      def get(self, sequence_id):          schema = SequenceResponseSchema()          sequence = _get_or_raise(sequence_id)          return {"sequence": schema.dump(_to_model(REPOSITORY, sequence))}        @_middleware      def delete(self, sequence_id):          manager = _SequenceManagerFactory._build_manager()          _get_or_raise(sequence_id)          manager._delete(sequence_id)          return {"message": f"Sequence {sequence_id} was deleted."}      class SequenceList(Resource):      """Creation and get_all        ---      get:        tags:          - api        summary: Get all sequences.        description: |          Return an array of all sequences.            !!! Note            When the authorization feature is activated (available in the **Enterprise** edition only), this endpoint            requires _TAIPY_READER_ role.            Code example:            ```shell            curl -X GET http://localhost:5000/api/v1/sequences          ```          responses:          200:            content:              application/json:                schema:                  allOf:                    - type: object                      properties:                        results:                          type: array                          items:                            $ref: '#/components/schemas/SequenceSchema'      post:        tags:          - api        summary: Create a sequence.        description: |          Create a sequence from scenario_id, sequence_name and task_ids. If the scenario_id does not exist or sequence_name is not provided, a 404 error is returned.          !!! Note            When the authorization feature is activated (available in the **Enterprise** edition only), this endpoint            requires _TAIPY_EDITOR_ role.            Code example:            ```shell            curl -X POST --data '{"scenario_id": "SCENARIO_scenario_id", "sequence_name": "sequence", "tasks": []}' http://localhost:5000/api/v1/sequences          ```          parameters:          - in: query            name: scenario_id            schema:              type: string            description: The Scenario the Sequence belongs to.            name: sequence_name            schema:              type: string            description: The name of the Sequence.            name: tasks            schema:              type: list[string]            description: A list of task id of the Sequence.          responses:          201:            content:              application/json:                schema:                  type: object                  properties:                    message:                      type: string                      description: Status message.                    sequence: SequenceSchema      """        def __init__(self, **kwargs):          self.logger = kwargs.get("logger")        @_middleware      def get(self):          schema = SequenceResponseSchema(many=True)          manager = _SequenceManagerFactory._build_manager()          sequences = [_to_model(REPOSITORY, sequence) for sequence in manager._get_all()]          return schema.dump(sequences)        @_middleware      def post(self):          sequence_data = request.json          scenario_id = sequence_data.get("scenario_id")          sequence_name = sequence_data.get("sequence_name")          sequence_task_ids = sequence_data.get("task_ids", [])            response_schema = SequenceResponseSchema()          if not scenario_id:              raise ScenarioIdMissingException          if not sequence_name:              raise SequenceNameMissingException            scenario = _ScenarioManagerFactory._build_manager()._get(scenario_id)          if not scenario:              raise NonExistingScenario(scenario_id=scenario_id)            scenario.add_sequence(sequence_name, sequence_task_ids)          sequence = scenario.sequences[sequence_name]            return {              "message": "Sequence was created.",              "sequence": response_schema.dump(_to_model(REPOSITORY, sequence)),          }, 201      class SequenceExecutor(Resource):      """Execute a sequence        ---      post:        tags:          - api        summary: Execute a sequence.        description: |          Execute a sequence from sequence_id. If the sequence does not exist, a 404 error is returned.            !!! Note            When the authorization feature is activated (available in the **Enterprise** edition only), This endpoint            requires _TAIPY_EXECUTOR_ role.            Code example:            ```shell            curl -X POST http://localhost:5000/api/v1/sequences/submit/SEQUENCE_my_config_75750ed8-4e09-4e00-958d-e352ee426cc9          ```          parameters:          - in: path            name: sequence_id            schema:              type: string        responses:          204:            content:              application/json:                schema:                  type: object                  properties:                    message:                      type: string                      description: Status message.                    sequence: SequenceSchema          404:              description: No sequence has the *sequence_id* identifier.      """        def __init__(self, **kwargs):          self.logger = kwargs.get("logger")        @_middleware      def post(self, sequence_id):          _get_or_raise(sequence_id)          manager = _SequenceManagerFactory._build_manager()          manager._submit(sequence_id)          return {"message": f"Sequence {sequence_id} was submitted."}


from .cycle import CycleList, CycleResource  from .datanode import DataNodeList, DataNodeReader, DataNodeResource, DataNodeWriter  from .job import JobExecutor, JobList, JobResource  from .scenario import ScenarioExecutor, ScenarioList, ScenarioResource  from .sequence import SequenceExecutor, SequenceList, SequenceResource  from .task import TaskExecutor, TaskList, TaskResource    __all__ = [      "DataNodeResource",      "DataNodeList",      "DataNodeReader",      "DataNodeWriter",      "TaskList",      "TaskResource",      "TaskExecutor",      "SequenceList",      "SequenceResource",      "SequenceExecutor",      "ScenarioList",      "ScenarioResource",      "ScenarioExecutor",      "CycleResource",      "CycleList",      "JobResource",      "JobList",      "JobExecutor",  ]


from typing import List    import numpy as np  import pandas as pd  from flask import request  from flask_restful import Resource    from taipy.config.config import Config  from taipy.core.data._data_manager_factory import _DataManagerFactory  from taipy.core.data.operator import Operator  from taipy.core.exceptions.exceptions import NonExistingDataNode, NonExistingDataNodeConfig    from ...commons.to_from_model import _to_model  from ..exceptions.exceptions import ConfigIdMissingException  from ..middlewares._middleware import _middleware  from ..schemas import (      CSVDataNodeConfigSchema,      DataNodeFilterSchema,      DataNodeSchema,      ExcelDataNodeConfigSchema,      GenericDataNodeConfigSchema,      InMemoryDataNodeConfigSchema,      JSONDataNodeConfigSchema,      PickleDataNodeConfigSchema,      SQLTableDataNodeConfigSchema,      SQLDataNodeConfigSchema,      MongoCollectionDataNodeConfigSchema,  )    ds_schema_map = {      "csv": CSVDataNodeConfigSchema,      "pickle": PickleDataNodeConfigSchema,      "in_memory": InMemoryDataNodeConfigSchema,      "sql_table": SQLTableDataNodeConfigSchema,      "sql": SQLDataNodeConfigSchema,      "mongo_collection": MongoCollectionDataNodeConfigSchema,      "excel": ExcelDataNodeConfigSchema,      "generic": GenericDataNodeConfigSchema,      "json": JSONDataNodeConfigSchema,  }    REPOSITORY = "data"      def _get_or_raise(data_node_id: str) -> None:      manager = _DataManagerFactory._build_manager()      data_node = manager._get(data_node_id)      if not data_node:          raise NonExistingDataNode(data_node_id)      return data_node      class DataNodeResource(Resource):      """Single object resource        ---      get:        tags:          - api        description: |          Returns a `DataNodeSchema^` representing the unique `DataNode^` identified by the *datanode_id*          given as parameter. If no data node corresponds to *datanode_id*, a `404` error is returned.            !!! Example                === "Curl"                  ```shell                      curl -X GET http://localhost:5000/api/v1/datanodes/DATANODE_hist_cfg_75750ed8-4e09-4e00-958d                      -e352ee426cc9                  ```                  In this example the REST API is served on port 5000 on localhost. We are using curl command line                  client.                    `DATANODE_hist_cfg_75750ed8-4e09-4e00-958d-e352ee426cc9` is the value of the *datanode_id* parameter. It                  represents the identifier of the data node we want to retrieve.                    In case of success here is an example of the response:                  ``` JSON                  {"datanode": {                      "id": "DATANODE_historical_data_set_9db1b542-2e45-44e7-8a85-03ef9ead173d",                      "config_id": "historical_data_set",                      "scope": "<Scope.SCENARIO: 2>",                      "storage_type": "csv",                      "name": "Name of my historical data node",                      "owner_id": "SCENARIO_my_awesome_scenario_97f3fd67-8556-4c62-9b3b-ef189a599a38",                      "last_edit_date": "2022-08-10T16:03:40.855082",                      "job_ids": [],                      "version": "latest",                      "cacheable": false,                      "validity_days": null,                      "validity_seconds": null,                      "edit_in_progress": false,                      "data_node_properties": {                          "path": "daily-min-temperatures.csv",                          "has_header": true}                      }}                  ```                    In case of failure here is an example of the response:                  ``` JSON                  {"message":"DataNode DATANODE_historical_data_set_9db1b542-2e45-44e7-8a85-03ef9ead173d not found"}                  ```                === "Python"                  This Python example requires the 'requests' package to be installed (`pip install requests`).                  ```python                  import requests                      response = requests.get(                      "http://localhost:5000/api/v1/datanodes/DATANODE_historical_data_set_9db1b542-2e45-44e7-8a85-03ef9ead173d")                      print(response)                      print(response.json())                  ```                  `DATANODE_hist_cfg_75750ed8-4e09-4e00-958d-e352ee426cc9` is the value of the *datanode_id* parameter. It                  represents the identifier of the data node we want to retrieve.                    In case of success here is an output example:                  ```                  <Response [200]>                  {"datanode": {                      "id": "DATANODE_historical_data_set_9db1b542-2e45-44e7-8a85-03ef9ead173d",                      "config_id": "historical_data_set",                      "scope": "<Scope.SCENARIO: 2>",                      "storage_type": "csv",                      "name": "Name of my historical data node",                      "owner_id": "SCENARIO_my_awesome_scenario_97f3fd67-8556-4c62-9b3b-ef189a599a38",                      "last_edit_date": "2022-08-10T16:03:40.855082",                      "job_ids": [],                      "version": "latest",                      "cacheable": false,                      "validity_days": null,                      "validity_seconds": null,                      "edit_in_progress": false,                      "data_node_properties": {                          "path": "daily-min-temperatures.csv",                          "has_header": true}                      }}                  ```                    In case of failure here is an output example:                  ```                  <Response [404]>                  {"message":"DataNode DATANODE_historical_data_set_9db1b542-2e45-44e7-8a85-03ef9ead173d not found"}                    ```            !!! Note            When the authorization feature is activated (available in Taipy Enterprise edition only), this endpoint              requires the `TAIPY_READER` role.          parameters:          - in: path            name: datanode_id            schema:              type: string            description: The identifier of the data node to retrieve.          responses:          200:            content:              application/json:                schema:                  type: object                  properties:                    datanode: DataNodeSchema          404:            description: No data node has the *datanode_id* identifier.      delete:        tags:          - api        summary: Delete a data node.        description: |          Deletes the `DataNode^` identified by the  *datanode_id* given as parameter. If the data node does not exist,          a 404 error is returned.            !!! Example                === "Curl"                  ```shell                      curl -X DELETE \                      http://localhost:5000/api/v1/datanodes/DATANODE_historical_data_set_9db1b542-2e45-44e7-8a85-03ef9ead173d                  ```                  In this example the REST API is served on port 5000 on localhost. We are using curl command line                  client.                    `DATANODE_historical_data_set_9db1b542-2e45-44e7-8a85-03ef9ead173d` is the value of the                  *datanode_id* parameter. It represents the identifier of the data node we want to delete.                    In case of success here is an example of the response:                  ``` JSON                  {"msg": "datanode DATANODE_historical_data_set_9db1b542-2e45-44e7-8a85-03ef9ead173d deleted"}                  ```                    In case of failure here is an example of the response:                  ``` JSON                  {"message": "Data node DATANODE_historical_data_set_9db1b542-2e45-44e7-8a85-03ef9ead173d not found."}                  ```                === "Python"                  This Python example requires the 'requests' package to be installed (`pip install requests`).                  ```python                  import requests                      response = requests.delete(                      "http://localhost:5000/api/v1/datanodes/DATANODE_historical_data_set_9db1b542-2e45-44e7-8a85-03ef9ead173d")                      print(response)                      print(response.json())                  ```                  `DATANODE_historical_data_set_9db1b542-2e45-44e7-8a85-03ef9ead173d` is the value of the                  *datanode_id* parameter. It represents the identifier of the Cycle we want to delete.                    In case of success here is an output example:                  ```                  <Response [200]>                  {"msg": "Data node DATANODE_historical_data_set_9db1b542-2e45-44e7-8a85-03ef9ead173d deleted."}                  ```                    In case of failure here is an output example:                  ```                  <Response [404]>                  {'message': 'Data node DATANODE_historical_data_set_9db1b542-2e45-44e7-8a85-03ef9ead173d not found.'}                    ```            !!! Note              When the authorization feature is activated (available in Taipy Enterprise edition only), this endpoint              requires the `TAIPY_EDITOR` role.          parameters:          - in: path            name: datanode_id            schema:              type: string            description: The identifier of the data node to delete.        responses:          200:            content:              application/json:                schema:                  type: object                  properties:                    message:                      type: string                      description: Status message.          404:            description: No data node has the *datanode_id* identifier.      """        def __init__(self, **kwargs):          self.logger = kwargs.get("logger")        @_middleware      def get(self, datanode_id):          schema = DataNodeSchema()          datanode = _get_or_raise(datanode_id)          return {"datanode": schema.dump(_to_model(REPOSITORY, datanode))}        @_middleware      def delete(self, datanode_id):          _get_or_raise(datanode_id)          manager = _DataManagerFactory._build_manager()          manager._delete(datanode_id)          return {"message": f"Data node {datanode_id} was deleted."}      class DataNodeList(Resource):      """Creation and get_all        ---      get:        tags:          - api        description: |          Returns a `DataNodeSchema^` list representing all existing data nodes.            !!! Example                === "Curl"                  ```shell                      curl -X GET http://localhost:5000/api/v1/datanodes                  ```                  In this example the REST API is served on port 5000 on localhost. We are using curl command line                  client.                    Here is an example of the response:                  ``` JSON                  [                      {"datanode": {                          "id": "DATANODE_historical_data_set_9db1b542-2e45-44e7-8a85-03ef9ead173d",                          "config_id": "historical_data_set",                          "scope": "<Scope.SCENARIO: 2>",                          "storage_type": "csv",                          "name": "Name of my historical data node",                          "owner_id": "SCENARIO_my_awesome_scenario_97f3fd67-8556-4c62-9b3b-ef189a599a38",                          "last_edit_date": "2022-08-10T16:03:40.855082",                          "job_ids": [],                          "version": "latest",                          "cacheable": false,                          "validity_days": null,                          "validity_seconds": null,                          "edit_in_progress": false,                          "data_node_properties": {                              "path": "daily-min-temperatures.csv",                              "has_header": true}                      }}                  ]                  ```                    If there is no data node, the response is an empty list as follows:                  ``` JSON                  []                  ```                === "Python"                  This Python example requires the 'requests' package to be installed (`pip install requests`).                  ```python                  import requests                      response = requests.get("http://localhost:5000/api/v1/datanodes")                      print(response)                      print(response.json())                  ```                    In case of success here is an output example:                  ```                  <Response [200]>                  [                      {"datanode": {                          "id": "DATANODE_historical_data_set_9db1b542-2e45-44e7-8a85-03ef9ead173d",                          "config_id": "historical_data_set",                          "scope": "<Scope.SCENARIO: 2>",                          "storage_type": "csv",                          "name": "Name of my historical data node",                          "owner_id": "SCENARIO_my_awesome_scenario_97f3fd67-8556-4c62-9b3b-ef189a599a38",                          "last_edit_date": "2022-08-10T16:03:40.855082",                          "job_ids": [],                          "version": "latest",                          "cacheable": false,                          "validity_days": null,                          "validity_seconds": null,                          "edit_in_progress": false,                          "data_node_properties": {                              "path": "daily-min-temperatures.csv",                              "has_header": true}                      }}                  ]                  ```                    If there is no data node, the response is an empty list as follows:                  ```                  <Response [200]>                  []                  ```            !!! Note              When the authorization feature is activated (available in Taipy Enterprise edition only), this endpoint              requires the `TAIPY_READER` role.          responses:          200:            content:              application/json:                schema:                  allOf:                    - type: object                      properties:                        results:                          type: array                          items:                            $ref: '#/components/schemas/DataNodeSchema'      post:        tags:          - api        description: |          Creates a new data node from the *config_id* given as parameter.            !!! Example                === "Curl"                  ```shell                      curl -X POST http://localhost:5000/api/v1/datanodes?config_id=historical_data_set                  ```                  In this example the REST API is served on port 5000 on localhost. We are using curl command line                  client.                    In this example the *config_id* value ("historical_data_set") is given as parameter directly in the                  url. A corresponding `DataNodeConfig^` must exist and must have been configured before.                    Here is the output message example:                  ```                  {"msg": "datanode created",                  "datanode": {                      "default_path": null,                      "path": "daily-min-temperatures.csv",                      "name": null,                      "storage_type": "csv",                      "scope": 2,                      "has_header": true}                  }                  ```                === "Python"                  This Python example requires the 'requests' package to be installed (`pip install requests`).                  ```python                  import requests                      response = requests.post("http://localhost:5000/api/v1/datanodes?config_id=historical_data_set")                      print(response)                      print(response.json())                  ```                  In this example the *config_id* value ("historical_data_set") is given as parameter directly in the                  url. A corresponding `DataNodeConfig^` must exist and must have been configured before.                    Here is the output example:                  ```                  <Response [201]>                  {'msg': 'datanode created',                  'datanode': {                      'name': None,                      'scope': 2,                      'path': 'daily-min-temperatures.csv',                      'storage_type': 'csv',                      'default_path': None,                      'has_header': True}}                  ```            !!! Note              When the authorization feature is activated (available in Taipy Enterprise edition only), this endpoint              requires the `TAIPY_EDITOR` role.          parameters:          - in: query            name: config_id            schema:              type: string            description: The identifier of the data node configuration.        responses:          201:            content:              application/json:                schema:                  type: object                  properties:                    message:                      type: string                      description: Status message.                    datanode: DataNodeSchema      """        def __init__(self, **kwargs):          self.logger = kwargs.get("logger")        def fetch_config(self, config_id):          config = Config.data_nodes.get(config_id)          if not config:              raise NonExistingDataNodeConfig(config_id)          return config        @_middleware      def get(self):          schema = DataNodeSchema(many=True)          manager = _DataManagerFactory._build_manager()          datanodes = [_to_model(REPOSITORY, datanode) for datanode in manager._get_all()]          return schema.dump(datanodes)        @_middleware      def post(self):          args = request.args          config_id = args.get("config_id")            if not config_id:              raise ConfigIdMissingException            config = self.fetch_config(config_id)          schema = ds_schema_map.get(config.storage_type)()          manager = _DataManagerFactory._build_manager()          manager._bulk_get_or_create({config})          return {              "message": "Data node was created.",              "datanode": schema.dump(config),          }, 201      class DataNodeReader(Resource):      """Single object resource        ---      get:        tags:          - api        description: |          Returns the data read from the data node identified by *datanode_id*. If the data node does not exist,          a 404 error is returned.            !!! Example                === "Curl"                    ```shell                    curl -X GET \                    http://localhost:5000/api/v1/datanodes/DATANODE_historical_data_set_9db1b542-2e45-44e7-8a85-03ef9ead173d/read                  ```                    `DATANODE_historical_data_set_9db1b542-2e45-44e7-8a85-03ef9ead173d` is the *datanode_id*                  parameter. It represents the identifier of the data node to read.                    Here is an output example. In this case, the storage type of the data node to read is `csv`,                  and no exposed type is specified. The data is exposed as a list of dictionaries, each dictionary                  representing a raw of the csv file.                  ```                  {"data": [                      {"Date": "1981-01-01", "Temp": 20.7}, {"Date": "1981-01-02", "Temp": 17.9},                      {"Date": "1981-01-03", "Temp": 18.8}, {"Date": "1981-01-04", "Temp": 14.6},                      {"Date": "1981-01-05", "Temp": 15.8}, {"Date": "1981-01-06", "Temp": 15.8},                      {"Date": "1981-01-07", "Temp": 15.8}                      ]}                  ```                === "Python"                  This Python example requires the 'requests' package to be installed (`pip install requests`).                  ```python                  import requests                      response = requests.get(                      "http://localhost:5000/api/v1/datanodes/DATANODE_historical_data_set_9db1b542-2e45-44e7-8a85-03ef9ead173d/read")                      print(response)                      print(response.json())                  ```                  `DATANODE_historical_data_set_9db1b542-2e45-44e7-8a85-03ef9ead173d` is the *datanode_id*                  parameter. It represents the identifier of the data node to read.                    Here is an output example. In this case, the storage type of the data node to read is `csv`,                  and no exposed type is specified. The data is exposed as a list of dictionaries, each dictionary                  representing a raw of the csv file.                  ```                  {"data": [                      {"Date": "1981-01-01", "Temp": 20.7}, {"Date": "1981-01-02", "Temp": 17.9},                      {"Date": "1981-01-03", "Temp": 18.8}, {"Date": "1981-01-04", "Temp": 14.6},                      {"Date": "1981-01-05", "Temp": 15.8}, {"Date": "1981-01-06", "Temp": 15.8},                      {"Date": "1981-01-07", "Temp": 15.8}                      ]}                  ```            !!! Note              When the authorization feature is activated (available in Taipy Enterprise edition only), this endpoint              requires the `TAIPY_READER` role.          parameters:          - in: path            name: datanode_id            schema:              type: string            description: The id of the data node to read.        requestBody:          content:            application/json:              schema:                DataNodeFilterSchema        responses:          200:            content:              application/json:                schema:                  type: object                  properties:                    data:                      type: Any                      description: The data read from the data node.          404:            description: No data node has the *datanode_id* identifier.      """        def __init__(self, **kwargs):          self.logger = kwargs.get("logger")        def __make_operators(self, schema: DataNodeFilterSchema) -> List:          return [              (                  x.get("key"),                  x.get("value"),                  Operator(getattr(Operator, x.get("operator", "").upper())),              )              for x in schema.get("operators")          ]        @_middleware      def get(self, datanode_id):          schema = DataNodeFilterSchema()          data = request.get_json(silent=True)          data_node = _get_or_raise(datanode_id)          operators = self.__make_operators(schema.load(data)) if data else []          data = data_node.filter(operators)          if isinstance(data, pd.DataFrame):              data = data.to_dict(orient="records")          elif isinstance(data, np.ndarray):              data = list(data)          return {"data": data}      class DataNodeWriter(Resource):      """Single object resource        ---      put:        tags:          - api        summary: Write into a data node.        description: |          Write data from request body into a data node by *datanode_id*. If the data node does not exist, a 404 error is returned.            !!! Note            When the authorization feature is activated (available in the **Enterprise** edition only), this endpoint requires `TAIPY_EDITOR` role.            Code example:            ```shell            curl -X PUT -d '[{"path": "/abc", "type": 1}, {"path": "/def", "type": 2}]' -H 'Content-Type: application/json'  http://localhost:5000/api/v1/datanodes/DATANODE_my_config_75750ed8-4e09-4e00-958d-e352ee426cc9/write          ```          parameters:          - in: path            name: datanode_id            schema:              type: string        requestBody:          content:            application/json:              schema:                Any        responses:          200:            content:              application/json:                schema:                  type: object                  properties:                    message:                      type: string                      description: Status message.          404:            description: No data node has the *datanode_id* identifier.      """        def __init__(self, **kwargs):          self.logger = kwargs.get("logger")        @_middleware      def put(self, datanode_id):          data = request.json          data_node = _get_or_raise(datanode_id)          data_node.write(data)          return {"message": f"Data node {datanode_id} was successfully written."}


from flask import request  from flask_restful import Resource    from taipy.config.config import Config  from taipy.core.exceptions.exceptions import NonExistingScenario, NonExistingScenarioConfig  from taipy.core.scenario._scenario_manager_factory import _ScenarioManagerFactory    from ...commons.to_from_model import _to_model  from ..exceptions.exceptions import ConfigIdMissingException  from ..middlewares._middleware import _middleware  from ..schemas import ScenarioResponseSchema      def _get_or_raise(scenario_id: str):      manager = _ScenarioManagerFactory._build_manager()      scenario = manager._get(scenario_id)      if scenario is None:          raise NonExistingScenario(scenario_id)      return scenario      REPOSITORY = "scenario"      class ScenarioResource(Resource):      """Single object resource        ---      get:        tags:          - api        description: |          Returns a `ScenarioSchema^` representing the unique scenario identified by *scenario_id*. If no scenario          corresponds to *scenario_id*, a `404` error is returned.            !!! Example                === "Curl"                  ```shell                      curl -X GET http://localhost:5000/api/v1/scenarios/SCENARIO_63cb358d-5834-4d73-84e4-a6343df5e08c                  ```                  In this example the REST API is served on port 5000 on localhost. We are using curl command line                  client.                    `SCENARIO_63cb358d-5834-4d73-84e4-a6343df5e08c` is the value of the *scenario_id* parameter. It                  represents the identifier of the Scenario we want to retrieve.                    In case of success here is an example of the response:                  ``` JSON                  {"scenario": {                      "cycle": "CYCLE_863418_fdd1499a-8925-4540-93fd-9dbfb4f0846d",                      "id": "SCENARIO_63cb358d-5834-4d73-84e4-a6343df5e08c",                      "properties": {},                      "tags": [],                      "version": "latest",                      "sequences": [                          "SEQUENCE_mean_baseline_5af317c9-34df-48b4-8a8a-bf4007e1de99",                          "SEQUENCE_arima_90aef6b9-8922-4a0c-b625-b2c6f3d19fa4"],                      "subscribers": [],                      "creation_date": "2022-08-15T19:21:01.871587",                      "primary_scenario": true}}                  ```                    In case of failure here is an example of the response:                  ``` JSON                  {"message": "SCENARIO_63cb358d-5834-4d73-84e4-a6343df5e08c not found."}                  ```                === "Python"                  This Python example requires the 'requests' package to be installed (`pip install requests`).                  ```python                  import requests                      response = requests.get(                      "http://localhost:5000/api/v1/scenarios/SCENARIO_63cb358d-5834-4d73-84e4-a6343df5e08c")                      print(response)                      print(response.json())                  ```                  `SCENARIO_63cb358d-5834-4d73-84e4-a6343df5e08c` is the value of the  *scenario_id* parameter. It                  represents the identifier of the Cycle we want to retrieve.                    In case of success here is an output example:                  ```                  <Response [200]>                  {"scenario": {                      "cycle": "CYCLE_863418_fdd1499a-8925-4540-93fd-9dbfb4f0846d",                      "id": "SCENARIO_63cb358d-5834-4d73-84e4-a6343df5e08c",                      "properties": {},                      "tags": [],                      "version": "latest",                      "sequences": [                          "SEQUENCE_mean_baseline_5af317c9-34df-48b4-8a8a-bf4007e1de99",                          "SEQUENCE_arima_90aef6b9-8922-4a0c-b625-b2c6f3d19fa4"],                      "subscribers": [],                      "creation_date": "2022-08-15T19:21:01.871587",                      "primary_scenario": true}}                  ```                    In case of failure here is an output example:                  ```                  <Response [404]>                  {'message': 'Scenario SCENARIO_63cb358d-5834-4d73-84e4-a6343df5e08c not found.'}                    ```            !!! Note              When the authorization feature is activated (available in Taipy Enterprise edition only), this endpoint              requires the `TAIPY_READER` role.            parameters:          - in: path            name: scenario_id            schema:              type: string            description: The identifier of the scenario to retrieve.        responses:          200:            content:              application/json:                schema:                  type: object                  properties:                    scenario: ScenarioSchema          404:            description: No scenario has the *scenario_id* identifier.      delete:        tags:          - api        description: |          Delete the `Scenario^` scenario identified by the *scenario_id* given as parameter. If the scenario does not          exist, a 404 error is returned.            !!! Example                === "Curl"                  ```shell                      curl -X DELETE http://localhost:5000/api/v1/scenarios/SCENARIO_63cb358d-5834-4d73-84e4-a6343df5e08c                  ```                  In this example the REST API is served on port 5000 on localhost. We are using curl command line                  client.                    `SCENARIO_63cb358d-5834-4d73-84e4-a6343df5e08c` is the value of the  *scenario_id* parameter. It                  represents the identifier of the scenario we want to delete.                    In case of success here is an example of the response:                  ``` JSON                  {"msg": "Scenario SCENARIO_63cb358d-5834-4d73-84e4-a6343df5e08c deleted."}                  ```                    In case of failure here is an example of the response:                  ``` JSON                  {"message": "Scenario SCENARIO_63cb358d-5834-4d73-84e4-a6343df5e08c not found."}                  ```                === "Python"                  This Python example requires the 'requests' package to be installed (`pip install requests`).                  ```python                  import requests                      response = requests.delete(                      "http://localhost:5000/api/v1/scenarios/SCENARIO_63cb358d-5834-4d73-84e4-a6343df5e08c")                      print(response)                      print(response.json())                  ```                  `SCENARIO_63cb358d-5834-4d73-84e4-a6343df5e08c` is the value of the *scenario_id* parameter. It                  represents the identifier of the Scenario we want to delete.                    In case of success here is an output example:                  ```                  <Response [200]>                  {"msg": "Scenario SCENARIO_63cb358d-5834-4d73-84e4-a6343df5e08c deleted."}                  ```                    In case of failure here is an output example:                  ```                  <Response [404]>                  {'message': 'Scenario SCENARIO_63cb358d-5834-4d73-84e4-a6343df5e08c not found.'}                    ```            !!! Note              When the authorization feature is activated (available in Taipy Enterprise edition only), this endpoint              requires the `TAIPY_EDITOR` role.          parameters:          - in: path            name: scenario_id            schema:              type: string            description: The identifier of the scenario to delete.        responses:          200:            content:              application/json:                schema:                  type: object                  properties:                    message:                      type: string                      description: Status message.          404:            description: No scenario has the *scenario_id* identifier.      """        def __init__(self, **kwargs):          self.logger = kwargs.get("logger")        @_middleware      def get(self, scenario_id):          schema = ScenarioResponseSchema()          scenario = _get_or_raise(scenario_id)          return {"scenario": schema.dump(_to_model(REPOSITORY, scenario))}        @_middleware      def delete(self, scenario_id):          manager = _ScenarioManagerFactory._build_manager()          _get_or_raise(scenario_id)          manager._delete(scenario_id)          return {"message": f"Scenario {scenario_id} was deleted."}      class ScenarioList(Resource):      """Creation and get_all        ---      get:        tags:          - api        summary: Get all scenarios.        description: |          Returns a `ScenarioSchema^` list representing all existing Scenarios.            !!! Example                === "Curl"                  ```shell                      curl -X GET http://localhost:5000/api/v1/scenarios                  ```                  In this example the REST API is served on port 5000 on localhost. We are using curl command line                  client.                    Here is an example of the response:                  ``` JSON                  [{                      "cycle": "CYCLE_863418_fdd1499a-8925-4540-93fd-9dbfb4f0846d",                      "id": "SCENARIO_63cb358d-5834-4d73-84e4-a6343df5e08c",                      "properties": {},                      "tags": [],                      "version": "latest",                      "sequences": [                          "SEQUENCE_mean_baseline_5af317c9-34df-48b4-8a8a-bf4007e1de99",                          "SEQUENCE_arima_90aef6b9-8922-4a0c-b625-b2c6f3d19fa4"],                      "subscribers": [],                      "creation_date": "2022-08-15T19:21:01.871587",                      "primary_scenario": true                      }                  ]                  ```                    If there is no scenario, the response is an empty list as follows:                  ``` JSON                  []                  ```                === "Python"                  This Python example requires the 'requests' package to be installed (`pip install requests`).                  ```python                  import requests                      response = requests.get("http://localhost:5000/api/v1/scenarios")                      print(response)                      print(response.json())                  ```                    In case of success here is an output example:                  ```                  <Response [200]>                  [{                      "cycle": "CYCLE_863418_fdd1499a-8925-4540-93fd-9dbfb4f0846d",                      "id": "SCENARIO_63cb358d-5834-4d73-84e4-a6343df5e08c",                      "properties": {},                      "tags": [],                      "version": "latest",                      "sequences": [                          "SEQUENCE_mean_baseline_5af317c9-34df-48b4-8a8a-bf4007e1de99",                          "SEQUENCE_arima_90aef6b9-8922-4a0c-b625-b2c6f3d19fa4"],                      "subscribers": [],                      "creation_date": "2022-08-15T19:21:01.871587",                      "primary_scenario": true                      }                  ]                  ```                    If there is no scenario, the response is an empty list as follows:                  ```                  <Response [200]>                  []                  ```            !!! Note              When the authorization feature is activated (available in Taipy Enterprise edition only), this endpoint              requires the `TAIPY_READER` role.          responses:          200:            content:              application/json:                schema:                  allOf:                    - type: object                      properties:                        results:                          type: array                          items:                            $ref: '#/components/schemas/ScenarioSchema'      post:        tags:          - api        description: |          Creates a new scenario from the  *config_id*. If the config does not exist, a 404 error is returned.            !!! Example                === "Curl"                  ```shell                      curl -X POST http://localhost:5000/api/v1/scenarios?config_id=my_scenario_config                  ```                  In this example the REST API is served on port 5000 on localhost. We are using curl command line                  client.                    In this example the *config_id* value ("my_scenario_config") is given as parameter directly in the                  url. A corresponding `ScenarioConfig^` must exist and must have been configured before.                    Here is the output message example:                  ```                  {"msg": "scenario created.",                  "scenario": {                      "cycle": "CYCLE_863418_fdd1499a-8925-4540-93fd-9dbfb4f0846d",                      "id": "SCENARIO_63cb358d-5834-4d73-84e4-a6343df5e08c",                      "properties": {},                      "tags": [],                      "version": "latest",                      "sequences": [                          "SEQUENCE_mean_baseline_5af317c9-34df-48b4-8a8a-bf4007e1de99",                          "SEQUENCE_arima_90aef6b9-8922-4a0c-b625-b2c6f3d19fa4"],                      "subscribers": [],                      "creation_date": "2022-08-15T19:21:01.871587",                      "primary_scenario": true}                  }                  ```                === "Python"                  This Python example requires the 'requests' package to be installed (`pip install requests`).                  ```python                  import requests                      response = requests.post("http://localhost:5000/api/v1/scenarios?config_id=my_scenario_config")                      print(response)                      print(response.json())                  ```                  In this example the *config_id* value ("my_scenario_config") is given as parameter directly in the                  url. A corresponding `ScenarioConfig^` must exist and must have been configured before.                    Here is the output example:                  ```                  <Response [201]>                  {"msg": "scenario created.",                  "scenario": {                      "cycle": "CYCLE_863418_fdd1499a-8925-4540-93fd-9dbfb4f0846d",                      "id": "SCENARIO_63cb358d-5834-4d73-84e4-a6343df5e08c",                      "properties": {},                      "tags": [],                      "version": "latest",                      "sequences": [                          "SEQUENCE_mean_baseline_5af317c9-34df-48b4-8a8a-bf4007e1de99",                          "SEQUENCE_arima_90aef6b9-8922-4a0c-b625-b2c6f3d19fa4"],                      "subscribers": [],                      "creation_date": "2022-08-15T19:21:01.871587",                      "primary_scenario": true}                  }                  ```            !!! Note              When the authorization feature is activated (available in Taipy Enterprise edition only), this endpoint              requires the `TAIPY_EDITOR` role.          parameters:          - in: query            name: config_id            schema:              type: string            description: The identifier of the scenario configuration.        responses:          201:            content:              application/json:                schema:                  type: object                  properties:                    message:                      type: string                      description: Status message.                    scenario: ScenarioSchema      """        def __init__(self, **kwargs):          self.logger = kwargs.get("logger")        def fetch_config(self, config_id):          config = Config.scenarios.get(config_id)          if not config:              raise NonExistingScenarioConfig(config_id)          return config        @_middleware      def get(self):          schema = ScenarioResponseSchema(many=True)          manager = _ScenarioManagerFactory._build_manager()          scenarios = [_to_model(REPOSITORY, scenario) for scenario in manager._get_all()]          return schema.dump(scenarios)        @_middleware      def post(self):          args = request.args          config_id = args.get("config_id")            response_schema = ScenarioResponseSchema()          manager = _ScenarioManagerFactory._build_manager()            if not config_id:              raise ConfigIdMissingException            config = self.fetch_config(config_id)          scenario = manager._create(config)            return {              "message": "Scenario was created.",              "scenario": response_schema.dump(_to_model(REPOSITORY, scenario)),          }, 201      class ScenarioExecutor(Resource):      """Execute a scenario        ---      post:        tags:          - api        description: |          Executes a scenario by *scenario_id*. If the scenario does not exist, a 404 error is returned.            !!! Example                === "Curl"                  ```shell                      curl -X POST http://localhost:5000/api/v1/scenarios/submit/SCENARIO_63cb358d-5834-4d73-84e4-a6343df5e08c                  ```                  In this example the REST API is served on port 5000 on localhost. We are using curl command line                  client.                    `SCENARIO_63cb358d-5834-4d73-84e4-a6343df5e08c` is the value of the *scenario_id* parameter. It                  represents the identifier of the Scenario we want to submit.                    Here is the output message example:                  ```                  {"message": "Executed scenario SCENARIO_63cb358d-5834-4d73-84e4-a6343df5e08c."}                  ```                === "Python"                  This Python example requires the 'requests' package to be installed (`pip install requests`).                  ```python                      import requests                          response = requests.post(                          "http://localhost:5000/api/v1/scenarios/submit/SCENARIO_63cb358d-5834-4d73-84e4-a6343df5e08c")                          print(response)                          print(response.json())                  ```                  `SCENARIO_63cb358d-5834-4d73-84e4-a6343df5e08c` is the value of the *scenario_id* parameter. It                  represents the identifier of the Scenario we want to submit.                    Here is the output example:                  ```                  <Response [202]>                  {"message": "Executed scenario SCENARIO_63cb358d-5834-4d73-84e4-a6343df5e08c."}                  ```            !!! Note              When the authorization feature is activated (available in Taipy Enterprise edition only), this endpoint              requires the `TAIPY_EXECUTOR` role.          parameters:          - in: path            name: scenario_id            schema:              type: string            description: The identifier of the scenario to submit.        responses:          202:            content:              application/json:                schema:                  type: object                  properties:                    message:                      type: string                      description: Status message.                    scenario: ScenarioSchema          404:            description: No scenario has the *scenario_id* identifier.      """        def __init__(self, **kwargs):          self.logger = kwargs.get("logger")        @_middleware      def post(self, scenario_id):          _get_or_raise(scenario_id)          manager = _ScenarioManagerFactory._build_manager()          manager._submit(scenario_id)          return {"message": f"Scenario {scenario_id} was submitted."}


#  # Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with  # the License. You may obtain a copy of the License at  #  #        http://www.apache.org/licenses/LICENSE-2.0  #  # Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on  # an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the  # specific language governing permissions and limitations under the License.


from functools import wraps  from importlib import util    from taipy.core.common._utils import _load_fct      def _middleware(f):      @wraps(f)      def wrapper(*args, **kwargs):          if _using_enterprise():              return _enterprise_middleware()(f)(*args, **kwargs)          else:              return f(*args, **kwargs)        return wrapper      def _using_enterprise():      return util.find_spec("taipy.enterprise") is not None      def _enterprise_middleware():      return _load_fct("taipy.enterprise.rest.api.middlewares._middleware", "_middleware")


class ConfigIdMissingException(Exception):      def __init__(self):          self.message = "Config id is missing."      class ScenarioIdMissingException(Exception):      def __init__(self):          self.message = "Scenario id is missing."      class SequenceNameMissingException(Exception):      def __init__(self):          self.message = "Sequence name is missing."


from marshmallow import Schema, fields      class CycleSchema(Schema):      name = fields.String()      frequency = fields.String()      properties = fields.Dict()      creation_date = fields.String()      start_date = fields.String()      end_date = fields.String()      class CycleResponseSchema(CycleSchema):      id = fields.String()


from marshmallow import Schema, fields      class TaskSchema(Schema):        config_id = fields.String()      id = fields.String()      owner_id = fields.String()      parent_ids = fields.List(fields.String)      input_ids = fields.List(fields.String)      function_name = fields.String()      function_module = fields.String()      output_ids = fields.List(fields.String)      version = fields.String()


from marshmallow import Schema, fields      class CallableSchema(Schema):      fct_name = fields.String()      fct_module = fields.String()      class JobSchema(Schema):      id = fields.String()      task_id = fields.String()      status = fields.String()      force = fields.Boolean()      creation_date = fields.String()      subscribers = fields.Nested(CallableSchema)      stacktrace = fields.List(fields.String)


from marshmallow import Schema, fields      class SequenceSchema(Schema):      owner_id = fields.String()      parent_ids = fields.List(fields.String)      tasks = fields.List(fields.String)      version = fields.String()      properties = fields.Dict()      class SequenceResponseSchema(SequenceSchema):      id = fields.String()      subscribers = fields.List(fields.Dict)


from .cycle import CycleResponseSchema, CycleSchema  from .datanode import (      CSVDataNodeConfigSchema,      DataNodeConfigSchema,      DataNodeFilterSchema,      DataNodeSchema,      ExcelDataNodeConfigSchema,      GenericDataNodeConfigSchema,      InMemoryDataNodeConfigSchema,      JSONDataNodeConfigSchema,      MongoCollectionDataNodeConfigSchema,      PickleDataNodeConfigSchema,      SQLDataNodeConfigSchema,      SQLTableDataNodeConfigSchema,  )  from .job import JobSchema  from .scenario import ScenarioResponseSchema, ScenarioSchema  from .sequence import SequenceResponseSchema, SequenceSchema  from .task import TaskSchema    __all__ = [      "DataNodeSchema",      "DataNodeFilterSchema",      "TaskSchema",      "SequenceSchema",      "SequenceResponseSchema",      "ScenarioSchema",      "ScenarioResponseSchema",      "CycleSchema",      "CycleResponseSchema",      "JobSchema",  ]