diff --git a/.github/workflows/NewUpdate.yml b/.github/workflows/NewUpdate.yml index ed6eb63b..2e9d4fd9 100644 --- a/.github/workflows/NewUpdate.yml +++ b/.github/workflows/NewUpdate.yml @@ -52,26 +52,38 @@ jobs: echo "Unzipping..." unzip -q sirius-*-linux-x64.zip echo "API Ready" + - name: Install Display Drivers & Libs + run: | + sudo apt-get update + sudo apt-get install -y xvfb libgtk-3-0t64 libasound2t64 libx11-xcb1 libnss3 libxss1 - name: Run Rest Api with strings run: | - bash .updater/api/sirius/bin/sirius REST --headless --api-mode=STABLE -p 8080 -s & + xvfb-run --auto-servernum --server-args="-screen 0 1024x768x24" \ + bash .updater/api/sirius/bin/sirius REST --gui --api-mode=STABLE -p 8080 -s & - name: Update api-docs-strings.json run: | while ! nc -z localhost 8080; do sleep 0.1; done - cd .updater/api wget -nv http://localhost:8080/v3/api-docs -O api-docs-strings.json + working-directory: .updater/api - name: Shutdown SIRIUS run: curl -X POST http://localhost:8080/actuator/shutdown - name: Run Rest Api with enums run: | - bash .updater/api/sirius/bin/sirius REST --headless --api-mode=STABLE --enums-as-ref -p 8080 -s & + xvfb-run --auto-servernum --server-args="-screen 0 1024x768x24" \ + bash .updater/api/sirius/bin/sirius REST --gui --api-mode=STABLE --enums-as-ref -p 8080 -s & - name: Update api-docs-enums.json run: | while ! nc -z localhost 8080; do sleep 0.1; done - cd .updater/api wget -nv http://localhost:8080/v3/api-docs -O api-docs-enums.json + working-directory: .updater/api - name: Shutdown SIRIUS run: curl -X POST http://localhost:8080/actuator/shutdown + - name: Format JSON files + run: | + sudo apt-get install -y moreutils + jq . api-docs-strings.json | sponge api-docs-strings.json + jq . api-docs-enums.json | sponge api-docs-enums.json + working-directory: .updater/api - name: Update Clients run: | # load package version from file @@ -98,32 +110,34 @@ jobs: echo "generating Finished!" - name: Format Python Package run: | - cp client-api_python/pysirius_api.py client-api_python/generated/PySirius - cp client-api_python/pysirius_sdk.py client-api_python/generated/PySirius - cp client-api_python/pysirius_helper.py client-api_python/generated/PySirius + cp pysirius_api.py generated/PySirius + cp pysirius_sdk.py generated/PySirius + cp pysirius_helper.py generated/PySirius - chmod +x ./client-api_python/formatting/format_init.sh - ./client-api_python/formatting/format_init.sh + chmod +x ./formatting/format_init.sh + ./formatting/format_init.sh + working-directory: client-api_python - name: Format R package run: | - cp client-api_r/rsirius_sdk.R client-api_r/generated/R/rsirius_sdk.R - cp client-api_r/rsirius_helper.R client-api_r/generated/R/rsirius_helper.R - echo >> client-api_r/generated/NAMESPACE - echo "# SDK" >> client-api_r/generated/NAMESPACE - echo "export(SiriusSDK)" >> client-api_r/generated/NAMESPACE - echo "export(Helper)" >> client-api_r/generated/NAMESPACE + cp rsirius_sdk.R generated/R/rsirius_sdk.R + cp rsirius_helper.R generated/R/rsirius_helper.R + echo >> generated/NAMESPACE + echo "# SDK" >> generated/NAMESPACE + echo "export(SiriusSDK)" >> generated/NAMESPACE + echo "export(Helper)" >> generated/NAMESPACE - chmod +x ./client-api_r/patches/list_syntax_fix.sh - ./client-api_r/patches/list_syntax_fix.sh + chmod +x ./patches/list_syntax_fix.sh + ./patches/list_syntax_fix.sh - chmod +x ./client-api_r/patches/insert_wait_for_job_completion_in_rsirius_api.sh - ./client-api_r/patches/insert_wait_for_job_completion_in_rsirius_api.sh + chmod +x ./patches/insert_wait_for_job_completion_in_rsirius_api.sh + ./patches/insert_wait_for_job_completion_in_rsirius_api.sh + working-directory: client-api_r - name: Remove Sirius Rest Api run: | - cd .updater/api rm -rf *sirius* rm -rf releases.json echo "Done" + working-directory: .updater/api - name: Remove Openapi Generator Files run: | rm -rf .updater/openapi_generator @@ -139,8 +153,7 @@ jobs: echo "dispatched workflow" echo "sleeping for 30s to make sure it started" sleep 30 - list=$(gh run list --workflow RManualGeneration --branch ${GITHUB_REF##*/}) - id=$(echo $list | grep -oP 'in_progress RManualGeneration RManualGeneration [^ ]* workflow_dispatch \K\d+') + id=$(gh run list --workflow RManualGeneration.yml --branch ${GITHUB_REF##*/} --json databaseId,status --jq '.[] | select(.status=="in_progress") | .databaseId') echo "run ID of RManualGeneration is: $id" gh run watch $id --exit-status --interval 3 echo "generation done!" diff --git a/.updater/api/api-docs-enums.json b/.updater/api/api-docs-enums.json index f8b3728b..b3115e3e 100644 --- a/.updater/api/api-docs-enums.json +++ b/.updater/api/api-docs-enums.json @@ -12,10 +12,6 @@ } ], "tags": [ - { - "name": "Tags", - "description": "[EXPERIMENTAL] This API allows managing tags and tag based data groupings. All endpoints are experimental and not part of the stable API specification. These endpoints can change at any time, even in minor updates." - }, { "name": "Info", "description": "Status und Information" @@ -32,6 +28,26 @@ "name": "Compounds", "description": "This compound based API allows to retrieve all AlignedFeatures that belong to the same compound (also known as a group of ion identities). It also provides for each AlignedFeature the corresponding annotation results (which are usually computed on a per-feature basis)" }, + { + "name": "Gui", + "description": "GUI Control: Open, control and close SIRIUS Graphical User Interface (GUI) on specified projects." + }, + { + "name": "Projects", + "description": "Manage SIRIUS projects." + }, + { + "name": "Runs", + "description": "[EXPERIMENTAL] This API allows accessing LC/MS runs. All endpoints are experimental and not part of the stable API specification. These endpoints can change at any time, even in minor updates." + }, + { + "name": "Compound Statistics", + "description": "[EXPERIMENTAL] This compound based API allows allows computing and accessing statistics for compounds (also known as a group of ion identities). All endpoints are experimental and not part of the stable API specification. These endpoints can change at any time, even in minor updates." + }, + { + "name": "Tags", + "description": "[EXPERIMENTAL] This API allows managing tags and tag based data groupings. All endpoints are experimental and not part of the stable API specification. These endpoints can change at any time, even in minor updates." + }, { "name": "Login and Account", "description": "Perform signIn, signOut and signUp. Get tokens and account information." @@ -51,18 +67,6 @@ { "name": "Features", "description": "This feature based API allows access features (aligned over runs) and there Annotations of a specified project-space. This is the entry point to access all raw annotation results an there summaries." - }, - { - "name": "Projects", - "description": "Manage SIRIUS projects." - }, - { - "name": "Runs", - "description": "[EXPERIMENTAL] This API allows accessing LC/MS runs. All endpoints are experimental and not part of the stable API specification. These endpoints can change at any time, even in minor updates." - }, - { - "name": "Compound Statistics", - "description": "[EXPERIMENTAL] This compound based API allows allows computing and accessing statistics for compounds (also known as a group of ion identities). All endpoints are experimental and not part of the stable API specification. These endpoints can change at any time, even in minor updates." } ], "paths": { @@ -1626,6 +1630,71 @@ } } }, + "/api/projects/{projectId}/gui": { + "post": { + "tags": [ + "Gui" + ], + "summary": "Open GUI instance on specified project-space and bring the GUI window to foreground.", + "description": "Open GUI instance on specified project-space and bring the GUI window to foreground.", + "operationId": "openGui", + "parameters": [ + { + "name": "projectId", + "in": "path", + "description": "of project-space the GUI instance will connect to.", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "201": { + "description": "Created" + } + } + }, + "delete": { + "tags": [ + "Gui" + ], + "summary": "Close GUI instance of given project-space if available.", + "description": "Close GUI instance of given project-space if available.", + "operationId": "closeGui", + "parameters": [ + { + "name": "projectId", + "in": "path", + "description": "if project-space the GUI instance is connected to.", + "required": true, + "schema": { + "type": "string" + } + }, + { + "name": "closeProject", + "in": "query", + "required": false, + "schema": { + "type": "boolean" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "type": "boolean" + } + } + } + } + } + } + }, "/api/projects/{projectId}/groups/{groupName}": { "get": { "tags": [ @@ -6781,6 +6850,31 @@ } } }, + "/api/guis": { + "get": { + "tags": [ + "Gui" + ], + "summary": "Get list of currently running gui windows, managed by this SIRIUS instance.", + "description": "Get list of currently running gui windows, managed by this SIRIUS instance.\n Note this will not show any Clients that are connected from a separate process!", + "operationId": "getGuis", + "responses": { + "200": { + "description": "List of GUI windows that are currently managed by this SIRIUS instance.", + "content": { + "application/json": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/GuiInfo" + } + } + } + } + } + } + } + }, "/api/default-job-config": { "get": { "tags": [ @@ -11037,6 +11131,15 @@ "CLP" ] }, + "GuiInfo": { + "type": "object", + "properties": { + "projectId": { + "type": "string", + "description": "The project this instance is running on" + } + } + }, "ConnectionCheck": { "required": [ "errors", @@ -11201,4 +11304,4 @@ } } } -} \ No newline at end of file +} diff --git a/.updater/api/api-docs-strings.json b/.updater/api/api-docs-strings.json index 16d1f54e..6ee25d2e 100644 --- a/.updater/api/api-docs-strings.json +++ b/.updater/api/api-docs-strings.json @@ -12,10 +12,6 @@ } ], "tags": [ - { - "name": "Tags", - "description": "[EXPERIMENTAL] This API allows managing tags and tag based data groupings. All endpoints are experimental and not part of the stable API specification. These endpoints can change at any time, even in minor updates." - }, { "name": "Info", "description": "Status und Information" @@ -32,6 +28,26 @@ "name": "Compounds", "description": "This compound based API allows to retrieve all AlignedFeatures that belong to the same compound (also known as a group of ion identities). It also provides for each AlignedFeature the corresponding annotation results (which are usually computed on a per-feature basis)" }, + { + "name": "Gui", + "description": "GUI Control: Open, control and close SIRIUS Graphical User Interface (GUI) on specified projects." + }, + { + "name": "Projects", + "description": "Manage SIRIUS projects." + }, + { + "name": "Runs", + "description": "[EXPERIMENTAL] This API allows accessing LC/MS runs. All endpoints are experimental and not part of the stable API specification. These endpoints can change at any time, even in minor updates." + }, + { + "name": "Compound Statistics", + "description": "[EXPERIMENTAL] This compound based API allows allows computing and accessing statistics for compounds (also known as a group of ion identities). All endpoints are experimental and not part of the stable API specification. These endpoints can change at any time, even in minor updates." + }, + { + "name": "Tags", + "description": "[EXPERIMENTAL] This API allows managing tags and tag based data groupings. All endpoints are experimental and not part of the stable API specification. These endpoints can change at any time, even in minor updates." + }, { "name": "Login and Account", "description": "Perform signIn, signOut and signUp. Get tokens and account information." @@ -51,18 +67,6 @@ { "name": "Features", "description": "This feature based API allows access features (aligned over runs) and there Annotations of a specified project-space. This is the entry point to access all raw annotation results an there summaries." - }, - { - "name": "Projects", - "description": "Manage SIRIUS projects." - }, - { - "name": "Runs", - "description": "[EXPERIMENTAL] This API allows accessing LC/MS runs. All endpoints are experimental and not part of the stable API specification. These endpoints can change at any time, even in minor updates." - }, - { - "name": "Compound Statistics", - "description": "[EXPERIMENTAL] This compound based API allows allows computing and accessing statistics for compounds (also known as a group of ion identities). All endpoints are experimental and not part of the stable API specification. These endpoints can change at any time, even in minor updates." } ], "paths": { @@ -1730,6 +1734,71 @@ } } }, + "/api/projects/{projectId}/gui": { + "post": { + "tags": [ + "Gui" + ], + "summary": "Open GUI instance on specified project-space and bring the GUI window to foreground.", + "description": "Open GUI instance on specified project-space and bring the GUI window to foreground.", + "operationId": "openGui", + "parameters": [ + { + "name": "projectId", + "in": "path", + "description": "of project-space the GUI instance will connect to.", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "201": { + "description": "Created" + } + } + }, + "delete": { + "tags": [ + "Gui" + ], + "summary": "Close GUI instance of given project-space if available.", + "description": "Close GUI instance of given project-space if available.", + "operationId": "closeGui", + "parameters": [ + { + "name": "projectId", + "in": "path", + "description": "if project-space the GUI instance is connected to.", + "required": true, + "schema": { + "type": "string" + } + }, + { + "name": "closeProject", + "in": "query", + "required": false, + "schema": { + "type": "boolean" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "type": "boolean" + } + } + } + } + } + } + }, "/api/projects/{projectId}/groups/{groupName}": { "get": { "tags": [ @@ -7206,6 +7275,31 @@ } } }, + "/api/guis": { + "get": { + "tags": [ + "Gui" + ], + "summary": "Get list of currently running gui windows, managed by this SIRIUS instance.", + "description": "Get list of currently running gui windows, managed by this SIRIUS instance.\n Note this will not show any Clients that are connected from a separate process!", + "operationId": "getGuis", + "responses": { + "200": { + "description": "List of GUI windows that are currently managed by this SIRIUS instance.", + "content": { + "application/json": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/GuiInfo" + } + } + } + } + } + } + } + }, "/api/default-job-config": { "get": { "tags": [ @@ -11420,6 +11514,15 @@ } } }, + "GuiInfo": { + "type": "object", + "properties": { + "projectId": { + "type": "string", + "description": "The project this instance is running on" + } + } + }, "ConnectionCheck": { "required": [ "errors", @@ -11571,4 +11674,4 @@ } } } -} \ No newline at end of file +} diff --git a/api-docs-enums.json b/api-docs-enums.json new file mode 100644 index 00000000..e69de29b diff --git a/api-docs-strings.json b/api-docs-strings.json new file mode 100644 index 00000000..e69de29b diff --git a/client-api_python/formatting/format_init.sh b/client-api_python/formatting/format_init.sh old mode 100644 new mode 100755 index 19e8dcde..e348ae6e --- a/client-api_python/formatting/format_init.sh +++ b/client-api_python/formatting/format_init.sh @@ -1,6 +1,6 @@ #!/bin/bash -file="./client-api_python/generated/PySirius/__init__.py" +file="./generated/PySirius/__init__.py" # Use sed to insert the new items before the closing bracket sed -i '/^]$/i\ "PySiriusAPI",\n "SiriusSDK",\n "Helper",' "$file" diff --git a/client-api_python/generated/.openapi-generator/FILES b/client-api_python/generated/.openapi-generator/FILES index 2e38d3b6..bb345b9c 100644 --- a/client-api_python/generated/.openapi-generator/FILES +++ b/client-api_python/generated/.openapi-generator/FILES @@ -6,6 +6,7 @@ PySirius/api/compound_statistics_api.py PySirius/api/compounds_api.py PySirius/api/feature_statistics_api.py PySirius/api/features_api.py +PySirius/api/gui_api.py PySirius/api/info_api.py PySirius/api/jobs_api.py PySirius/api/login_and_account_api.py @@ -70,6 +71,7 @@ PySirius/models/formula_candidate.py PySirius/models/formula_candidate_opt_field.py PySirius/models/fragment_node.py PySirius/models/fragmentation_tree.py +PySirius/models/gui_info.py PySirius/models/import_result.py PySirius/models/info.py PySirius/models/instrument_profile.py @@ -217,6 +219,8 @@ docs/FormulaCandidate.md docs/FormulaCandidateOptField.md docs/FragmentNode.md docs/FragmentationTree.md +docs/GuiApi.md +docs/GuiInfo.md docs/ImportResult.md docs/Info.md docs/InfoApi.md diff --git a/client-api_python/generated/PySirius/__init__.py b/client-api_python/generated/PySirius/__init__.py index d4afb829..a4a5c768 100644 --- a/client-api_python/generated/PySirius/__init__.py +++ b/client-api_python/generated/PySirius/__init__.py @@ -21,6 +21,7 @@ "CompoundsApi", "FeatureStatisticsApi", "FeaturesApi", + "GuiApi", "InfoApi", "JobsApi", "LoginAndAccountApi", @@ -89,6 +90,7 @@ "FormulaCandidateOptField", "FragmentNode", "FragmentationTree", + "GuiInfo", "ImportResult", "Info", "InstrumentProfile", @@ -187,6 +189,7 @@ from PySirius.api.compounds_api import CompoundsApi as CompoundsApi from PySirius.api.feature_statistics_api import FeatureStatisticsApi as FeatureStatisticsApi from PySirius.api.features_api import FeaturesApi as FeaturesApi +from PySirius.api.gui_api import GuiApi as GuiApi from PySirius.api.info_api import InfoApi as InfoApi from PySirius.api.jobs_api import JobsApi as JobsApi from PySirius.api.login_and_account_api import LoginAndAccountApi as LoginAndAccountApi @@ -259,6 +262,7 @@ from PySirius.models.formula_candidate_opt_field import FormulaCandidateOptField as FormulaCandidateOptField from PySirius.models.fragment_node import FragmentNode as FragmentNode from PySirius.models.fragmentation_tree import FragmentationTree as FragmentationTree +from PySirius.models.gui_info import GuiInfo as GuiInfo from PySirius.models.import_result import ImportResult as ImportResult from PySirius.models.info import Info as Info from PySirius.models.instrument_profile import InstrumentProfile as InstrumentProfile diff --git a/client-api_python/generated/PySirius/api/__init__.py b/client-api_python/generated/PySirius/api/__init__.py index 1c12f236..06ea846e 100644 --- a/client-api_python/generated/PySirius/api/__init__.py +++ b/client-api_python/generated/PySirius/api/__init__.py @@ -6,6 +6,7 @@ from PySirius.api.compounds_api import CompoundsApi from PySirius.api.feature_statistics_api import FeatureStatisticsApi from PySirius.api.features_api import FeaturesApi +from PySirius.api.gui_api import GuiApi from PySirius.api.info_api import InfoApi from PySirius.api.jobs_api import JobsApi from PySirius.api.login_and_account_api import LoginAndAccountApi diff --git a/client-api_python/generated/PySirius/api/gui_api.py b/client-api_python/generated/PySirius/api/gui_api.py new file mode 100644 index 00000000..ac19d2d5 --- /dev/null +++ b/client-api_python/generated/PySirius/api/gui_api.py @@ -0,0 +1,812 @@ +# coding: utf-8 + +""" + SIRIUS Nightsky API + + + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + +import warnings +from pydantic import validate_call, Field, StrictFloat, StrictStr, StrictInt +from typing import Any, Dict, List, Optional, Tuple, Union +from typing_extensions import Annotated + +from pydantic import Field, StrictBool, StrictStr +from typing import List, Optional +from typing_extensions import Annotated +from PySirius.models.gui_info import GuiInfo + +from PySirius.api_client import ApiClient, RequestSerialized +from PySirius.api_response import ApiResponse +from PySirius.rest import RESTResponseType + + +class GuiApi: + """NOTE: This class is auto generated by OpenAPI Generator + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + + def __init__(self, api_client=None) -> None: + if api_client is None: + api_client = ApiClient.get_default() + self.api_client = api_client + + + @validate_call + def close_gui( + self, + project_id: Annotated[StrictStr, Field(description="if project-space the GUI instance is connected to.")], + close_project: Optional[StrictBool] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> bool: + """Close GUI instance of given project-space if available. + + Close GUI instance of given project-space if available. + + :param project_id: if project-space the GUI instance is connected to. (required) + :type project_id: str + :param close_project: + :type close_project: bool + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._close_gui_serialize( + project_id=project_id, + close_project=close_project, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "bool", + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + + @validate_call + def close_gui_with_http_info( + self, + project_id: Annotated[StrictStr, Field(description="if project-space the GUI instance is connected to.")], + close_project: Optional[StrictBool] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[bool]: + """Close GUI instance of given project-space if available. + + Close GUI instance of given project-space if available. + + :param project_id: if project-space the GUI instance is connected to. (required) + :type project_id: str + :param close_project: + :type close_project: bool + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._close_gui_serialize( + project_id=project_id, + close_project=close_project, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "bool", + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + + @validate_call + def close_gui_without_preload_content( + self, + project_id: Annotated[StrictStr, Field(description="if project-space the GUI instance is connected to.")], + close_project: Optional[StrictBool] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """Close GUI instance of given project-space if available. + + Close GUI instance of given project-space if available. + + :param project_id: if project-space the GUI instance is connected to. (required) + :type project_id: str + :param close_project: + :type close_project: bool + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._close_gui_serialize( + project_id=project_id, + close_project=close_project, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "bool", + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + return response_data.response + + + def _close_gui_serialize( + self, + project_id, + close_project, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + + _host = None + + _collection_formats: Dict[str, str] = { + } + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[ + str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] + ] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + if project_id is not None: + _path_params['projectId'] = project_id + # process the query parameters + if close_project is not None: + + _query_params.append(('closeProject', close_project)) + + # process the header parameters + # process the form parameters + # process the body parameter + + + # set the HTTP header `Accept` + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'application/json' + ] + ) + + + # authentication setting + _auth_settings: List[str] = [ + ] + + return self.api_client.param_serialize( + method='DELETE', + resource_path='/api/projects/{projectId}/gui', + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth + ) + + + + + @validate_call + def get_guis( + self, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> List[GuiInfo]: + """Get list of currently running gui windows, managed by this SIRIUS instance. + + Get list of currently running gui windows, managed by this SIRIUS instance. Note this will not show any Clients that are connected from a separate process! + + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._get_guis_serialize( + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "List[GuiInfo]", + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + + @validate_call + def get_guis_with_http_info( + self, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[List[GuiInfo]]: + """Get list of currently running gui windows, managed by this SIRIUS instance. + + Get list of currently running gui windows, managed by this SIRIUS instance. Note this will not show any Clients that are connected from a separate process! + + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._get_guis_serialize( + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "List[GuiInfo]", + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + + @validate_call + def get_guis_without_preload_content( + self, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """Get list of currently running gui windows, managed by this SIRIUS instance. + + Get list of currently running gui windows, managed by this SIRIUS instance. Note this will not show any Clients that are connected from a separate process! + + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._get_guis_serialize( + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "List[GuiInfo]", + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + return response_data.response + + + def _get_guis_serialize( + self, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + + _host = None + + _collection_formats: Dict[str, str] = { + } + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[ + str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] + ] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + # process the query parameters + # process the header parameters + # process the form parameters + # process the body parameter + + + # set the HTTP header `Accept` + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'application/json' + ] + ) + + + # authentication setting + _auth_settings: List[str] = [ + ] + + return self.api_client.param_serialize( + method='GET', + resource_path='/api/guis', + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth + ) + + + + + @validate_call + def open_gui( + self, + project_id: Annotated[StrictStr, Field(description="of project-space the GUI instance will connect to.")], + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> None: + """Open GUI instance on specified project-space and bring the GUI window to foreground. + + Open GUI instance on specified project-space and bring the GUI window to foreground. + + :param project_id: of project-space the GUI instance will connect to. (required) + :type project_id: str + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._open_gui_serialize( + project_id=project_id, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '201': None, + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + + @validate_call + def open_gui_with_http_info( + self, + project_id: Annotated[StrictStr, Field(description="of project-space the GUI instance will connect to.")], + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[None]: + """Open GUI instance on specified project-space and bring the GUI window to foreground. + + Open GUI instance on specified project-space and bring the GUI window to foreground. + + :param project_id: of project-space the GUI instance will connect to. (required) + :type project_id: str + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._open_gui_serialize( + project_id=project_id, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '201': None, + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + + @validate_call + def open_gui_without_preload_content( + self, + project_id: Annotated[StrictStr, Field(description="of project-space the GUI instance will connect to.")], + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """Open GUI instance on specified project-space and bring the GUI window to foreground. + + Open GUI instance on specified project-space and bring the GUI window to foreground. + + :param project_id: of project-space the GUI instance will connect to. (required) + :type project_id: str + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._open_gui_serialize( + project_id=project_id, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '201': None, + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + return response_data.response + + + def _open_gui_serialize( + self, + project_id, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + + _host = None + + _collection_formats: Dict[str, str] = { + } + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[ + str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] + ] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + if project_id is not None: + _path_params['projectId'] = project_id + # process the query parameters + # process the header parameters + # process the form parameters + # process the body parameter + + + + + # authentication setting + _auth_settings: List[str] = [ + ] + + return self.api_client.param_serialize( + method='POST', + resource_path='/api/projects/{projectId}/gui', + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth + ) + + diff --git a/client-api_python/generated/PySirius/api_client.py b/client-api_python/generated/PySirius/api_client.py index 07fed19c..e041ec92 100644 --- a/client-api_python/generated/PySirius/api_client.py +++ b/client-api_python/generated/PySirius/api_client.py @@ -801,4 +801,4 @@ def __deserialize_model(self, data, klass): :return: model object. """ - return klass.from_dict(data) + return klass.from_dict(data) \ No newline at end of file diff --git a/client-api_python/generated/PySirius/models/__init__.py b/client-api_python/generated/PySirius/models/__init__.py index 95f83ff1..b9e10406 100644 --- a/client-api_python/generated/PySirius/models/__init__.py +++ b/client-api_python/generated/PySirius/models/__init__.py @@ -63,6 +63,7 @@ from PySirius.models.formula_candidate_opt_field import FormulaCandidateOptField from PySirius.models.fragment_node import FragmentNode from PySirius.models.fragmentation_tree import FragmentationTree +from PySirius.models.gui_info import GuiInfo from PySirius.models.import_result import ImportResult from PySirius.models.info import Info from PySirius.models.instrument_profile import InstrumentProfile diff --git a/client-api_python/generated/PySirius/models/gui_info.py b/client-api_python/generated/PySirius/models/gui_info.py new file mode 100644 index 00000000..234d774a --- /dev/null +++ b/client-api_python/generated/PySirius/models/gui_info.py @@ -0,0 +1,85 @@ +# coding: utf-8 + +""" + SIRIUS Nightsky API + + + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictStr +from typing import Any, ClassVar, Dict, List, Optional +from typing import Optional, Set +from typing_extensions import Self + +class GuiInfo(BaseModel): + """ + GuiInfo + """ # noqa: E501 + project_id: Optional[StrictStr] = Field(default=None, description="The project this instance is running on", alias="projectId") + __properties: ClassVar[List[str]] = ["projectId"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of GuiInfo from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([ + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of GuiInfo from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "projectId": obj.get("projectId") + }) + return _obj + + diff --git a/client-api_python/generated/PySirius/pysirius_api.py b/client-api_python/generated/PySirius/pysirius_api.py index 912ebc9c..9821a2fd 100644 --- a/client-api_python/generated/PySirius/pysirius_api.py +++ b/client-api_python/generated/PySirius/pysirius_api.py @@ -36,6 +36,10 @@ def features(self): """returns API endpoint of the FeaturesApi""" return PySirius.FeaturesApi(self.api_client) + def gui(self): + """returns API endpoint of the GuiApi""" + return PySirius.GuiApi(self.api_client) + def infos(self): """returns API endpoint of the InfoApi""" return PySirius.InfoApi(self.api_client) diff --git a/client-api_python/generated/README.md b/client-api_python/generated/README.md index 1568f057..e799e198 100644 --- a/client-api_python/generated/README.md +++ b/client-api_python/generated/README.md @@ -151,6 +151,9 @@ Class | Method | HTTP request | Description *FeaturesApi* | [**get_tags_for_aligned_features_experimental**](docs/FeaturesApi.md#get_tags_for_aligned_features_experimental) | **GET** /api/projects/{projectId}/aligned-features/tags/{objectId} | [EXPERIMENTAL] Get all tags associated with this Object *FeaturesApi* | [**get_traces_experimental**](docs/FeaturesApi.md#get_traces_experimental) | **GET** /api/projects/{projectId}/aligned-features/{alignedFeatureId}/traces | [EXPERIMENTAL] Returns the traces of the given feature (alignedFeatureId) *FeaturesApi* | [**remove_tag_from_aligned_feature_experimental**](docs/FeaturesApi.md#remove_tag_from_aligned_feature_experimental) | **DELETE** /api/projects/{projectId}/aligned-features/tags/{alignedFeatureId}/{tagName} | [EXPERIMENTAL] Delete tag with the given name from the feature (aligned over runs) with the specified ID in the specified project-space +*GuiApi* | [**close_gui**](docs/GuiApi.md#close_gui) | **DELETE** /api/projects/{projectId}/gui | Close GUI instance of given project-space if available. +*GuiApi* | [**get_guis**](docs/GuiApi.md#get_guis) | **GET** /api/guis | Get list of currently running gui windows, managed by this SIRIUS instance. +*GuiApi* | [**open_gui**](docs/GuiApi.md#open_gui) | **POST** /api/projects/{projectId}/gui | Open GUI instance on specified project-space and bring the GUI window to foreground. *InfoApi* | [**get_connection_check**](docs/InfoApi.md#get_connection_check) | **GET** /api/connection-status | *InfoApi* | [**get_info**](docs/InfoApi.md#get_info) | **GET** /api/info | *JobsApi* | [**delete_job**](docs/JobsApi.md#delete_job) | **DELETE** /api/projects/{projectId}/jobs/{jobId} | Delete job. @@ -271,6 +274,7 @@ Class | Method | HTTP request | Description - [FormulaCandidateOptField](docs/FormulaCandidateOptField.md) - [FragmentNode](docs/FragmentNode.md) - [FragmentationTree](docs/FragmentationTree.md) + - [GuiInfo](docs/GuiInfo.md) - [ImportResult](docs/ImportResult.md) - [Info](docs/Info.md) - [InstrumentProfile](docs/InstrumentProfile.md) diff --git a/client-api_python/generated/docs/GuiApi.md b/client-api_python/generated/docs/GuiApi.md new file mode 100644 index 00000000..ad383d8e --- /dev/null +++ b/client-api_python/generated/docs/GuiApi.md @@ -0,0 +1,210 @@ +# PySirius.GuiApi + +All URIs are relative to *http://localhost:8080* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**close_gui**](GuiApi.md#close_gui) | **DELETE** /api/projects/{projectId}/gui | Close GUI instance of given project-space if available. +[**get_guis**](GuiApi.md#get_guis) | **GET** /api/guis | Get list of currently running gui windows, managed by this SIRIUS instance. +[**open_gui**](GuiApi.md#open_gui) | **POST** /api/projects/{projectId}/gui | Open GUI instance on specified project-space and bring the GUI window to foreground. + + +# **close_gui** +> bool close_gui(project_id, close_project=close_project) + +Close GUI instance of given project-space if available. + +Close GUI instance of given project-space if available. + +### Example + + +```python +import PySirius +from PySirius.rest import ApiException +from pprint import pprint + +# Defining the host is optional and defaults to http://localhost:8080 +# See configuration.py for a list of all supported configuration parameters. +configuration = PySirius.Configuration( + host = "http://localhost:8080" +) + + +# Enter a context with an instance of the API client +with PySirius.ApiClient(configuration) as api_client: + # Create an instance of the API class + api_instance = PySirius.GuiApi(api_client) + project_id = 'project_id_example' # str | if project-space the GUI instance is connected to. + close_project = True # bool | (optional) + + try: + # Close GUI instance of given project-space if available. + api_response = api_instance.close_gui(project_id, close_project=close_project) + print("The response of GuiApi->close_gui:\n") + pprint(api_response) + except Exception as e: + print("Exception when calling GuiApi->close_gui: %s\n" % e) +``` + + + +### Parameters + + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **project_id** | **str**| if project-space the GUI instance is connected to. | + **close_project** | **bool**| | [optional] + +### Return type + +**bool** + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + +### HTTP response details + +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | OK | - | + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **get_guis** +> List[GuiInfo] get_guis() + +Get list of currently running gui windows, managed by this SIRIUS instance. + +Get list of currently running gui windows, managed by this SIRIUS instance. + Note this will not show any Clients that are connected from a separate process! + +### Example + + +```python +import PySirius +from PySirius.models.gui_info import GuiInfo +from PySirius.rest import ApiException +from pprint import pprint + +# Defining the host is optional and defaults to http://localhost:8080 +# See configuration.py for a list of all supported configuration parameters. +configuration = PySirius.Configuration( + host = "http://localhost:8080" +) + + +# Enter a context with an instance of the API client +with PySirius.ApiClient(configuration) as api_client: + # Create an instance of the API class + api_instance = PySirius.GuiApi(api_client) + + try: + # Get list of currently running gui windows, managed by this SIRIUS instance. + api_response = api_instance.get_guis() + print("The response of GuiApi->get_guis:\n") + pprint(api_response) + except Exception as e: + print("Exception when calling GuiApi->get_guis: %s\n" % e) +``` + + + +### Parameters + +This endpoint does not need any parameter. + +### Return type + +[**List[GuiInfo]**](GuiInfo.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + +### HTTP response details + +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | List of GUI windows that are currently managed by this SIRIUS instance. | - | + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **open_gui** +> open_gui(project_id) + +Open GUI instance on specified project-space and bring the GUI window to foreground. + +Open GUI instance on specified project-space and bring the GUI window to foreground. + +### Example + + +```python +import PySirius +from PySirius.rest import ApiException +from pprint import pprint + +# Defining the host is optional and defaults to http://localhost:8080 +# See configuration.py for a list of all supported configuration parameters. +configuration = PySirius.Configuration( + host = "http://localhost:8080" +) + + +# Enter a context with an instance of the API client +with PySirius.ApiClient(configuration) as api_client: + # Create an instance of the API class + api_instance = PySirius.GuiApi(api_client) + project_id = 'project_id_example' # str | of project-space the GUI instance will connect to. + + try: + # Open GUI instance on specified project-space and bring the GUI window to foreground. + api_instance.open_gui(project_id) + except Exception as e: + print("Exception when calling GuiApi->open_gui: %s\n" % e) +``` + + + +### Parameters + + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **project_id** | **str**| of project-space the GUI instance will connect to. | + +### Return type + +void (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: Not defined + +### HTTP response details + +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**201** | Created | - | + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + diff --git a/client-api_python/generated/docs/GuiInfo.md b/client-api_python/generated/docs/GuiInfo.md new file mode 100644 index 00000000..de6176ef --- /dev/null +++ b/client-api_python/generated/docs/GuiInfo.md @@ -0,0 +1,29 @@ +# GuiInfo + + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**project_id** | **str** | The project this instance is running on | [optional] + +## Example + +```python +from PySirius.models.gui_info import GuiInfo + +# TODO update the JSON string below +json = "{}" +# create an instance of GuiInfo from a JSON string +gui_info_instance = GuiInfo.from_json(json) +# print the JSON string representation of the object +print(GuiInfo.to_json()) + +# convert the object into a dict +gui_info_dict = gui_info_instance.to_dict() +# create an instance of GuiInfo from a dict +gui_info_from_dict = GuiInfo.from_dict(gui_info_dict) +``` +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/client-api_python/pysirius_api.py b/client-api_python/pysirius_api.py index 912ebc9c..9821a2fd 100644 --- a/client-api_python/pysirius_api.py +++ b/client-api_python/pysirius_api.py @@ -36,6 +36,10 @@ def features(self): """returns API endpoint of the FeaturesApi""" return PySirius.FeaturesApi(self.api_client) + def gui(self): + """returns API endpoint of the GuiApi""" + return PySirius.GuiApi(self.api_client) + def infos(self): """returns API endpoint of the InfoApi""" return PySirius.InfoApi(self.api_client) diff --git a/client-api_r/generated/.openapi-generator/FILES b/client-api_r/generated/.openapi-generator/FILES index 0fe3244b..0ff976a6 100644 --- a/client-api_r/generated/.openapi-generator/FILES +++ b/client-api_r/generated/.openapi-generator/FILES @@ -49,6 +49,8 @@ R/fold_change.R R/formula_candidate.R R/fragment_node.R R/fragmentation_tree.R +R/gui_api.R +R/gui_info.R R/import_result.R R/info.R R/info_api.R @@ -167,6 +169,8 @@ docs/FoldChange.md docs/FormulaCandidate.md docs/FragmentNode.md docs/FragmentationTree.md +docs/GuiApi.md +docs/GuiInfo.md docs/ImportResult.md docs/Info.md docs/InfoApi.md diff --git a/client-api_r/generated/NAMESPACE b/client-api_r/generated/NAMESPACE index e1912854..3a146c4e 100644 --- a/client-api_r/generated/NAMESPACE +++ b/client-api_r/generated/NAMESPACE @@ -54,6 +54,7 @@ export(FoldChange) export(FormulaCandidate) export(FragmentNode) export(FragmentationTree) +export(GuiInfo) export(ImportResult) export(Info) export(IsotopePatternAnnotation) @@ -126,6 +127,7 @@ export(CompoundStatisticsApi) export(CompoundsApi) export(FeatureStatisticsApi) export(FeaturesApi) +export(GuiApi) export(InfoApi) export(JobsApi) export(LoginAndAccountApi) diff --git a/client-api_r/generated/R/api_client.R b/client-api_r/generated/R/api_client.R index 613a620d..47fbdafd 100644 --- a/client-api_r/generated/R/api_client.R +++ b/client-api_r/generated/R/api_client.R @@ -4,418 +4,418 @@ #' #' The version of the OpenAPI document: 3.1 #' Generated by: https://openapi-generator.tech -#' -#' ApiClient Class -#' -#' Generic API client for OpenAPI client library builds. -#' OpenAPI generic API client. This client handles the client- -#' server communication, and is invariant across implementations. Specifics of -#' the methods and models for each application are generated from the OpenAPI Generator -#' templates. -#' -#' NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). -#' Ref: https://openapi-generator.tech -#' Do not edit the class manually. -#' -#' @docType class -#' @title ApiClient -#' @description ApiClient Class -#' @format An \code{R6Class} generator object -#' @field base_path Base url -#' @field user_agent Default user agent -#' @field default_headers Default headers -#' @field username Username for HTTP basic authentication -#' @field password Password for HTTP basic authentication -#' @field api_keys API keys -#' @field bearer_token Bearer token -#' @field timeout Default timeout in seconds -#' @field retry_status_codes vector of status codes to retry -#' @field max_retry_attempts maximum number of retries for the status codes -#' @export -ApiClient <- R6::R6Class( - "ApiClient", - public = list( - # base path of all requests - base_path = "http://localhost:8080", - # user agent in the HTTP request - user_agent = "OpenAPI-Generator/6.3.3/r", - # default headers in the HTTP request - default_headers = NULL, - # username (HTTP basic authentication) - username = NULL, - # password (HTTP basic authentication) - password = NULL, - # API keys - api_keys = NULL, - # Bearer token - bearer_token = NULL, - # Time Out (seconds) - timeout = NULL, - # Vector of status codes to retry - retry_status_codes = NULL, - # Maximum number of retry attempts for the retry status codes - max_retry_attempts = NULL, - #' Initialize a new ApiClient. - #' - #' @description - #' Initialize a new ApiClient. - #' - #' @param base_path Base path. - #' @param user_agent User agent. - #' @param default_headers Default headers. - #' @param username User name. - #' @param password Password. - #' @param api_keys API keys. - #' @param access_token Access token. - #' @param bearer_token Bearer token. - #' @param timeout Timeout. - #' @param retry_status_codes Status codes for retry. - #' @param max_retry_attempts Maxmium number of retry. - #' @export - initialize = function(base_path = NULL, user_agent = NULL, - default_headers = NULL, - username = NULL, password = NULL, api_keys = NULL, - access_token = NULL, bearer_token = NULL, timeout = NULL, - retry_status_codes = NULL, max_retry_attempts = NULL) { - if (!is.null(base_path)) { - self$base_path <- base_path - } - - if (!is.null(default_headers)) { - self$default_headers <- default_headers - } - - if (!is.null(username)) { - self$username <- username - } - - if (!is.null(password)) { - self$password <- password - } - - if (!is.null(access_token)) { - self$access_token <- access_token - } - - if (!is.null(bearer_token)) { - self$bearer_token <- bearer_token - } - - if (!is.null(api_keys)) { - self$api_keys <- api_keys - } else { - self$api_keys <- list() - } - - if (!is.null(user_agent)) { - self$`user_agent` <- user_agent - } - - if (!is.null(timeout)) { - self$timeout <- timeout - } - - if (!is.null(retry_status_codes)) { - self$retry_status_codes <- retry_status_codes - } - - if (!is.null(max_retry_attempts)) { - self$max_retry_attempts <- max_retry_attempts - } - }, - #' Prepare to make an API call with the retry logic. - #' - #' @description - #' Prepare to make an API call with the retry logic. - #' - #' @param url URL. - #' @param method HTTP method. - #' @param query_params The query parameters. - #' @param header_params The header parameters. - #' @param form_params The form parameters. - #' @param file_params The form parameters to upload files. - #' @param accepts The HTTP accept headers. - #' @param content_types The HTTP content-type headers. - #' @param body The HTTP request body. - #' @param is_oauth True if the endpoints required OAuth authentication. - #' @param oauth_scopes OAuth scopes. - #' @param stream_callback Callback function to process the data stream. - #' @param ... Other optional arguments. - #' @return HTTP response - #' @export - CallApi = function(url, method, query_params, header_params, form_params, - file_params, accepts, content_types, body, - is_oauth = FALSE, oauth_scopes = NULL, stream_callback = NULL, ...) { - - # set the URL - req <- request(url) - - resp <- self$Execute(req, method, query_params, header_params, form_params, - file_params, accepts, content_types, body, is_oauth = is_oauth, - oauth_scopes = oauth_scopes, stream_callback = stream_callback, ...) - }, - #' Make an API call - #' - #' @description - #' Make an API call - #' - #' @param req httr2 request. - #' @param method HTTP method. - #' @param query_params The query parameters. - #' @param header_params The header parameters. - #' @param form_params The form parameters. - #' @param file_params The form parameters for uploading files. - #' @param accepts The HTTP accept headers. - #' @param content_types The HTTP content-type headers. - #' @param body The HTTP request body. - #' @param is_oauth True if the endpoints required OAuth authentication. - #' @param oauth_scopes OAuth scopes. - #' @param stream_callback Callback function to process data stream. - #' @param ... Other optional arguments. - #' @return HTTP response - #' @export - Execute = function(req, method, query_params, header_params, form_params, - file_params, accepts, content_types, body, - is_oauth = FALSE, oauth_scopes = NULL, stream_callback = NULL, ...) { - - ## add headers - req <- req %>% req_headers(!!!header_params) - - ## add default headers - req <- req %>% req_headers(!!!self$default_headers) - - # set HTTP accept header - accept <- self$select_header(accepts) - if (!is.null(accept)) { - req <- req %>% req_headers("Accept" = accept) - } - - # set HTTP content-type header - content_type <- self$select_header(content_types) - if (!is.null(content_type)) { - req <- req %>% req_headers("Content-Type" = content_type) - } - - ## add query parameters - for (query_param in names(query_params)) { - if (typeof(query_params[[query_param]]) == "list") { - # for explode, e.g. a=1,a=2,a=3 - req <- req %>% req_url_query(!!!query_params[[query_param]]) - } else { # for non-explode, e.g. a=1,2,3 - tmp <- list() - tmp[[query_param]] <- query_params[[query_param]] - req <- req %>% req_url_query(!!!tmp) - } - } - - # has file upload? - if (!is.null(file_params) && length(file_params) != 0) { - # Create multipart body data - multipart_data <- list() - - # Add form parameters first - if (!is.null(form_params) && length(form_params) != 0) { - for (param_name in names(form_params)) { - param_value <- form_params[[param_name]] - is_json <- tryCatch({ - jsonlite::validate(param_value) - }, error = function(e) { - FALSE - }) - - if (is_json) { - multipart_data[[param_name]] <- curl::form_data(param_value, type = "application/json") - } else { - multipart_data[[param_name]] <- param_value - } - } - } - - # Add file parameters - handle multiple files with same name - for (param_name in names(file_params)) { - param_value <- file_params[[param_name]] - - if (is.list(param_value) && length(param_value) > 1) { - # Multiple files with same parameter name - for (i in seq_along(param_value)) { - multipart_data[[length(multipart_data) + 1]] <- param_value[[i]] - names(multipart_data)[length(multipart_data)] <- param_name - } - } else { - # Single file - multipart_data[[param_name]] <- param_value[[1]] - } - } - req <- req %>% req_body_multipart(!!!multipart_data) - } else { # no file upload - # add form parameters via req_body_form - if (!is.null(form_params) && length(form_params) != 0) { - req <- req %>% req_body_form(!!!form_params) - } - } - - # add body parameters - if (!is.null(body)) { - req <- req %>% req_body_raw(body) - } - - # set timeout - if (!is.null(self$timeout)) { - req <- req %>% req_timeout(self$timeout) - } - - # set retry - if (!is.null(self$max_retry_attempts)) { - req <- req %>% retry_max_tries(self$timeout) - req <- req %>% retry_max_seconds(self$timeout) - } - - # set user agent - if (!is.null(self$user_agent)) { - req <- req %>% req_user_agent(self$user_agent) - } - - # set HTTP verb - req <- req %>% req_method(method) - - # stream data - if (typeof(stream_callback) == "closure") { - req %>% req_stream(stream_callback) - } else { - # perform the HTTP request - resp <- req %>% - req_error(is_error = function(resp) FALSE) %>% - req_perform() - - # return ApiResponse - api_response <- ApiResponse$new() - api_response$status_code <- resp %>% resp_status() - api_response$status_code_desc <- resp %>% resp_status_desc() - if (length(resp$body) == 0) { - api_response$response <- NULL - } else { - api_response$response <- resp %>% resp_body_raw() - } - api_response$headers <- resp %>% resp_headers() - - api_response - } - }, - #' Deserialize the content of API response to the given type. - #' - #' @description - #' Deserialize the content of API response to the given type. - #' - #' @param raw_response Raw response. - #' @param return_type R return type. - #' @param pkg_env Package environment. - #' @return Deserialized object. - #' @export - deserialize = function(raw_response, return_type, pkg_env) { - # jsonlite fails with URLs as strings, pass them raw - if (grepl('^(http|https)://', raw_response)) { - resp_obj <- raw_response - } else { - resp_obj <- jsonlite::fromJSON(raw_response) - } - self$deserializeObj(resp_obj, return_type, pkg_env) - }, - #' Deserialize the response from jsonlite object based on the given type. - #' - #' @description - #' Deserialize the response from jsonlite object based on the given type. - #' by handling complex and nested types by iterating recursively - #' Example return_types will be like "array[integer]", "map(Pet)", "array[map(Tag)]", etc. - #' - #' @param obj Response object. - #' @param return_type R return type. - #' @param pkg_env Package environment. - #' @return Deserialized object. - #' @export - deserializeObj = function(obj, return_type, pkg_env) { - return_obj <- NULL - primitive_types <- c("character", "numeric", "integer", "logical", "complex") - - # To handle the "map" type - if (startsWith(return_type, "map(")) { - inner_return_type <- regmatches(return_type, - regexec(pattern = "map\\((.*)\\)", return_type))[[1]][2] - return_obj <- lapply(names(obj), function(name) { - self$deserializeObj(obj[[name]], inner_return_type, pkg_env) - }) - names(return_obj) <- names(obj) - } else if (startsWith(return_type, "array[")) { - # To handle the "array" type - inner_return_type <- regmatches(return_type, - regexec(pattern = "array\\[(.*)\\]", return_type))[[1]][2] - if (c(inner_return_type) %in% primitive_types) { - return_obj <- vector("list", length = length(obj)) - if (length(obj) > 0) { - for (row in 1:length(obj)) { - return_obj[[row]] <- self$deserializeObj(obj[row], inner_return_type, pkg_env) - } - } - } else { - if (!is.null(nrow(obj))) { - return_obj <- vector("list", length = nrow(obj)) - if (nrow(obj) > 0) { - for (row in 1:nrow(obj)) { - return_obj[[row]] <- self$deserializeObj(as.list(obj[row, , drop = FALSE]), - inner_return_type, pkg_env) - } - } - } - } - } else if (exists(return_type, pkg_env) && !(c(return_type) %in% primitive_types)) { - # To handle model objects which are not array or map containers (e.g. Pet) - return_type <- get(return_type, envir = as.environment(pkg_env)) - return_obj <- return_type$new() - # check if discriminator is defined - if (!is.null(return_obj$`_discriminator_property_name`)) { - data_type <- return_obj$`_discriminator_property_name` - # use discriminator mapping if provided - if (!is.null(return_obj$`_discriminator_mapping_name`)) { - data_type <- (return_obj$`_discriminator_mapping_name`)[[obj[[data_type]]]] - } else { - # no mapping provided, use the value directly - data_type <- obj[[data_type]] - } - # create an object of the mapped type (e.g. Cat) - return_type <- get(data_type, envir = as.environment(pkg_env)) - return_obj <- return_type$new() - } - return_obj$fromJSON( - jsonlite::toJSON(obj, digits = NA, auto_unbox = TRUE, null = 'null', na = 'null') - ) - } else { - # To handle primitive type - return_obj <- obj - } - return_obj - }, - #' Return a property header (for accept or content-type). - #' - #' @description - #' Return a property header (for accept or content-type). If JSON-related MIME is found, - #' return it. Otherwise, return the first one, if any. - #' - #' @param headers A list of headers - #' @return A header (e.g. 'application/json') - #' @export - select_header = function(headers) { - if (length(headers) == 0) { - return(invisible(NULL)) - } else { - for (header in headers) { - if (str_detect(header, "(?i)^(application/json|[^;/ \t]+/[^;/ \t]+[+]json)[ \t]*(;.*)?$")) { - # return JSON-related MIME - return(header) - } - } - - # not json mime type, simply return the first one - return(headers[[1]]) - } - } - ) -) +#' +#' ApiClient Class +#' +#' Generic API client for OpenAPI client library builds. +#' OpenAPI generic API client. This client handles the client- +#' server communication, and is invariant across implementations. Specifics of +#' the methods and models for each application are generated from the OpenAPI Generator +#' templates. +#' +#' NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). +#' Ref: https://openapi-generator.tech +#' Do not edit the class manually. +#' +#' @docType class +#' @title ApiClient +#' @description ApiClient Class +#' @format An \code{R6Class} generator object +#' @field base_path Base url +#' @field user_agent Default user agent +#' @field default_headers Default headers +#' @field username Username for HTTP basic authentication +#' @field password Password for HTTP basic authentication +#' @field api_keys API keys +#' @field bearer_token Bearer token +#' @field timeout Default timeout in seconds +#' @field retry_status_codes vector of status codes to retry +#' @field max_retry_attempts maximum number of retries for the status codes +#' @export +ApiClient <- R6::R6Class( + "ApiClient", + public = list( + # base path of all requests + base_path = "http://localhost:8080", + # user agent in the HTTP request + user_agent = "OpenAPI-Generator/6.3.3/r", + # default headers in the HTTP request + default_headers = NULL, + # username (HTTP basic authentication) + username = NULL, + # password (HTTP basic authentication) + password = NULL, + # API keys + api_keys = NULL, + # Bearer token + bearer_token = NULL, + # Time Out (seconds) + timeout = NULL, + # Vector of status codes to retry + retry_status_codes = NULL, + # Maximum number of retry attempts for the retry status codes + max_retry_attempts = NULL, + #' Initialize a new ApiClient. + #' + #' @description + #' Initialize a new ApiClient. + #' + #' @param base_path Base path. + #' @param user_agent User agent. + #' @param default_headers Default headers. + #' @param username User name. + #' @param password Password. + #' @param api_keys API keys. + #' @param access_token Access token. + #' @param bearer_token Bearer token. + #' @param timeout Timeout. + #' @param retry_status_codes Status codes for retry. + #' @param max_retry_attempts Maxmium number of retry. + #' @export + initialize = function(base_path = NULL, user_agent = NULL, + default_headers = NULL, + username = NULL, password = NULL, api_keys = NULL, + access_token = NULL, bearer_token = NULL, timeout = NULL, + retry_status_codes = NULL, max_retry_attempts = NULL) { + if (!is.null(base_path)) { + self$base_path <- base_path + } + + if (!is.null(default_headers)) { + self$default_headers <- default_headers + } + + if (!is.null(username)) { + self$username <- username + } + + if (!is.null(password)) { + self$password <- password + } + + if (!is.null(access_token)) { + self$access_token <- access_token + } + + if (!is.null(bearer_token)) { + self$bearer_token <- bearer_token + } + + if (!is.null(api_keys)) { + self$api_keys <- api_keys + } else { + self$api_keys <- list() + } + + if (!is.null(user_agent)) { + self$`user_agent` <- user_agent + } + + if (!is.null(timeout)) { + self$timeout <- timeout + } + + if (!is.null(retry_status_codes)) { + self$retry_status_codes <- retry_status_codes + } + + if (!is.null(max_retry_attempts)) { + self$max_retry_attempts <- max_retry_attempts + } + }, + #' Prepare to make an API call with the retry logic. + #' + #' @description + #' Prepare to make an API call with the retry logic. + #' + #' @param url URL. + #' @param method HTTP method. + #' @param query_params The query parameters. + #' @param header_params The header parameters. + #' @param form_params The form parameters. + #' @param file_params The form parameters to upload files. + #' @param accepts The HTTP accept headers. + #' @param content_types The HTTP content-type headers. + #' @param body The HTTP request body. + #' @param is_oauth True if the endpoints required OAuth authentication. + #' @param oauth_scopes OAuth scopes. + #' @param stream_callback Callback function to process the data stream. + #' @param ... Other optional arguments. + #' @return HTTP response + #' @export + CallApi = function(url, method, query_params, header_params, form_params, + file_params, accepts, content_types, body, + is_oauth = FALSE, oauth_scopes = NULL, stream_callback = NULL, ...) { + + # set the URL + req <- request(url) + + resp <- self$Execute(req, method, query_params, header_params, form_params, + file_params, accepts, content_types, body, is_oauth = is_oauth, + oauth_scopes = oauth_scopes, stream_callback = stream_callback, ...) + }, + #' Make an API call + #' + #' @description + #' Make an API call + #' + #' @param req httr2 request. + #' @param method HTTP method. + #' @param query_params The query parameters. + #' @param header_params The header parameters. + #' @param form_params The form parameters. + #' @param file_params The form parameters for uploading files. + #' @param accepts The HTTP accept headers. + #' @param content_types The HTTP content-type headers. + #' @param body The HTTP request body. + #' @param is_oauth True if the endpoints required OAuth authentication. + #' @param oauth_scopes OAuth scopes. + #' @param stream_callback Callback function to process data stream. + #' @param ... Other optional arguments. + #' @return HTTP response + #' @export + Execute = function(req, method, query_params, header_params, form_params, + file_params, accepts, content_types, body, + is_oauth = FALSE, oauth_scopes = NULL, stream_callback = NULL, ...) { + + ## add headers + req <- req %>% req_headers(!!!header_params) + + ## add default headers + req <- req %>% req_headers(!!!self$default_headers) + + # set HTTP accept header + accept <- self$select_header(accepts) + if (!is.null(accept)) { + req <- req %>% req_headers("Accept" = accept) + } + + # set HTTP content-type header + content_type <- self$select_header(content_types) + if (!is.null(content_type)) { + req <- req %>% req_headers("Content-Type" = content_type) + } + + ## add query parameters + for (query_param in names(query_params)) { + if (typeof(query_params[[query_param]]) == "list") { + # for explode, e.g. a=1,a=2,a=3 + req <- req %>% req_url_query(!!!query_params[[query_param]]) + } else { # for non-explode, e.g. a=1,2,3 + tmp <- list() + tmp[[query_param]] <- query_params[[query_param]] + req <- req %>% req_url_query(!!!tmp) + } + } + + # has file upload? + if (!is.null(file_params) && length(file_params) != 0) { + # Create multipart body data + multipart_data <- list() + + # Add form parameters first + if (!is.null(form_params) && length(form_params) != 0) { + for (param_name in names(form_params)) { + param_value <- form_params[[param_name]] + is_json <- tryCatch({ + jsonlite::validate(param_value) + }, error = function(e) { + FALSE + }) + + if (is_json) { + multipart_data[[param_name]] <- curl::form_data(param_value, type = "application/json") + } else { + multipart_data[[param_name]] <- param_value + } + } + } + + # Add file parameters - handle multiple files with same name + for (param_name in names(file_params)) { + param_value <- file_params[[param_name]] + + if (is.list(param_value) && length(param_value) > 1) { + # Multiple files with same parameter name + for (i in seq_along(param_value)) { + multipart_data[[length(multipart_data) + 1]] <- param_value[[i]] + names(multipart_data)[length(multipart_data)] <- param_name + } + } else { + # Single file + multipart_data[[param_name]] <- param_value[[1]] + } + } + req <- req %>% req_body_multipart(!!!multipart_data) + } else { # no file upload + # add form parameters via req_body_form + if (!is.null(form_params) && length(form_params) != 0) { + req <- req %>% req_body_form(!!!form_params) + } + } + + # add body parameters + if (!is.null(body)) { + req <- req %>% req_body_raw(body) + } + + # set timeout + if (!is.null(self$timeout)) { + req <- req %>% req_timeout(self$timeout) + } + + # set retry + if (!is.null(self$max_retry_attempts)) { + req <- req %>% retry_max_tries(self$timeout) + req <- req %>% retry_max_seconds(self$timeout) + } + + # set user agent + if (!is.null(self$user_agent)) { + req <- req %>% req_user_agent(self$user_agent) + } + + # set HTTP verb + req <- req %>% req_method(method) + + # stream data + if (typeof(stream_callback) == "closure") { + req %>% req_stream(stream_callback) + } else { + # perform the HTTP request + resp <- req %>% + req_error(is_error = function(resp) FALSE) %>% + req_perform() + + # return ApiResponse + api_response <- ApiResponse$new() + api_response$status_code <- resp %>% resp_status() + api_response$status_code_desc <- resp %>% resp_status_desc() + if (length(resp$body) == 0) { + api_response$response <- NULL + } else { + api_response$response <- resp %>% resp_body_raw() + } + api_response$headers <- resp %>% resp_headers() + + api_response + } + }, + #' Deserialize the content of API response to the given type. + #' + #' @description + #' Deserialize the content of API response to the given type. + #' + #' @param raw_response Raw response. + #' @param return_type R return type. + #' @param pkg_env Package environment. + #' @return Deserialized object. + #' @export + deserialize = function(raw_response, return_type, pkg_env) { + # jsonlite fails with URLs as strings, pass them raw + if (grepl('^(http|https)://', raw_response)) { + resp_obj <- raw_response + } else { + resp_obj <- jsonlite::fromJSON(raw_response) + } + self$deserializeObj(resp_obj, return_type, pkg_env) + }, + #' Deserialize the response from jsonlite object based on the given type. + #' + #' @description + #' Deserialize the response from jsonlite object based on the given type. + #' by handling complex and nested types by iterating recursively + #' Example return_types will be like "array[integer]", "map(Pet)", "array[map(Tag)]", etc. + #' + #' @param obj Response object. + #' @param return_type R return type. + #' @param pkg_env Package environment. + #' @return Deserialized object. + #' @export + deserializeObj = function(obj, return_type, pkg_env) { + return_obj <- NULL + primitive_types <- c("character", "numeric", "integer", "logical", "complex") + + # To handle the "map" type + if (startsWith(return_type, "map(")) { + inner_return_type <- regmatches(return_type, + regexec(pattern = "map\\((.*)\\)", return_type))[[1]][2] + return_obj <- lapply(names(obj), function(name) { + self$deserializeObj(obj[[name]], inner_return_type, pkg_env) + }) + names(return_obj) <- names(obj) + } else if (startsWith(return_type, "array[")) { + # To handle the "array" type + inner_return_type <- regmatches(return_type, + regexec(pattern = "array\\[(.*)\\]", return_type))[[1]][2] + if (c(inner_return_type) %in% primitive_types) { + return_obj <- vector("list", length = length(obj)) + if (length(obj) > 0) { + for (row in 1:length(obj)) { + return_obj[[row]] <- self$deserializeObj(obj[row], inner_return_type, pkg_env) + } + } + } else { + if (!is.null(nrow(obj))) { + return_obj <- vector("list", length = nrow(obj)) + if (nrow(obj) > 0) { + for (row in 1:nrow(obj)) { + return_obj[[row]] <- self$deserializeObj(as.list(obj[row, , drop = FALSE]), + inner_return_type, pkg_env) + } + } + } + } + } else if (exists(return_type, pkg_env) && !(c(return_type) %in% primitive_types)) { + # To handle model objects which are not array or map containers (e.g. Pet) + return_type <- get(return_type, envir = as.environment(pkg_env)) + return_obj <- return_type$new() + # check if discriminator is defined + if (!is.null(return_obj$`_discriminator_property_name`)) { + data_type <- return_obj$`_discriminator_property_name` + # use discriminator mapping if provided + if (!is.null(return_obj$`_discriminator_mapping_name`)) { + data_type <- (return_obj$`_discriminator_mapping_name`)[[obj[[data_type]]]] + } else { + # no mapping provided, use the value directly + data_type <- obj[[data_type]] + } + # create an object of the mapped type (e.g. Cat) + return_type <- get(data_type, envir = as.environment(pkg_env)) + return_obj <- return_type$new() + } + return_obj$fromJSON( + jsonlite::toJSON(obj, digits = NA, auto_unbox = TRUE, null = 'null', na = 'null') + ) + } else { + # To handle primitive type + return_obj <- obj + } + return_obj + }, + #' Return a property header (for accept or content-type). + #' + #' @description + #' Return a property header (for accept or content-type). If JSON-related MIME is found, + #' return it. Otherwise, return the first one, if any. + #' + #' @param headers A list of headers + #' @return A header (e.g. 'application/json') + #' @export + select_header = function(headers) { + if (length(headers) == 0) { + return(invisible(NULL)) + } else { + for (header in headers) { + if (str_detect(header, "(?i)^(application/json|[^;/ \t]+/[^;/ \t]+[+]json)[ \t]*(;.*)?$")) { + # return JSON-related MIME + return(header) + } + } + + # not json mime type, simply return the first one + return(headers[[1]]) + } + } + ) +) diff --git a/client-api_r/generated/R/gui_api.R b/client-api_r/generated/R/gui_api.R new file mode 100644 index 00000000..9726d937 --- /dev/null +++ b/client-api_r/generated/R/gui_api.R @@ -0,0 +1,396 @@ +#' SIRIUS Nightsky API +#' +#' REST API that provides the full functionality of SIRIUS and its web services as background service. It is intended as entry-point for scripting languages and software integration SDKs.This API is exposed by SIRIUS 6 +#' +#' The version of the OpenAPI document: 3.1 +#' Generated by: https://openapi-generator.tech +#' +#' @docType class +#' @title Gui operations +#' @description GuiApi +#' @format An \code{R6Class} generator object +#' @field api_client Handles the client-server communication. +#' +#' @examples +#' \dontrun{ +#' #################### CloseGui #################### +#' +#' library(RSirius) +#' var_project_id <- "project_id_example" # character | if project-space the GUI instance is connected to. +#' var_close_project <- "close_project_example" # character | (Optional) +#' +#' #Close GUI instance of given project-space if available. +#' api_instance <- rsirius_api$new() +#' +#' # to save the result into a file, simply add the optional `data_file` parameter, e.g. +#' # result <- api_instance$CloseGui(var_project_id, close_project = var_close_projectdata_file = "result.txt") +#' result <- api_instance$gui_api$CloseGui(var_project_id, close_project = var_close_project) +#' dput(result) +#' +#' +#' #################### GetGuis #################### +#' +#' library(RSirius) +#' +#' #Get list of currently running gui windows, managed by this SIRIUS instance. +#' api_instance <- rsirius_api$new() +#' +#' # to save the result into a file, simply add the optional `data_file` parameter, e.g. +#' # result <- api_instance$GetGuis(data_file = "result.txt") +#' result <- api_instance$gui_api$GetGuis() +#' dput(result) +#' +#' +#' #################### OpenGui #################### +#' +#' library(RSirius) +#' var_project_id <- "project_id_example" # character | of project-space the GUI instance will connect to. +#' +#' #Open GUI instance on specified project-space and bring the GUI window to foreground. +#' api_instance <- rsirius_api$new() +#' +#' api_instance$gui_api$OpenGui(var_project_id) +#' +#' +#' } +#' @importFrom R6 R6Class +#' @importFrom base64enc base64encode +#' @export +GuiApi <- R6::R6Class( + "GuiApi", + public = list( + api_client = NULL, + + #' @description + #' Initialize a new GuiApi. + #' + #' @param api_client An instance of API client. + initialize = function(api_client) { + if (!missing(api_client)) { + self$api_client <- api_client + } else { + self$api_client <- ApiClient$new() + } + }, + + #' @description + #' Close GUI instance of given project-space if available. + #' + #' @param project_id if project-space the GUI instance is connected to. + #' @param close_project (optional) No description + #' @param data_file (optional) name of the data file to save the result + #' @param ... Other optional arguments + #' + #' @return character + CloseGui = function(project_id, close_project = NULL, data_file = NULL, ...) { + local_var_response <- self$CloseGuiWithHttpInfo(project_id, close_project, data_file = data_file, ...) + if (local_var_response$status_code >= 200 && local_var_response$status_code <= 299) { + local_var_response$content + } else if (local_var_response$status_code >= 300 && local_var_response$status_code <= 399) { + local_var_response + } else if (local_var_response$status_code >= 400 && local_var_response$status_code <= 499) { + local_var_response + } else if (local_var_response$status_code >= 500 && local_var_response$status_code <= 599) { + local_var_response + } + }, + + #' @description + #' Close GUI instance of given project-space if available. + #' + #' @param project_id if project-space the GUI instance is connected to. + #' @param close_project (optional) No description + #' @param data_file (optional) name of the data file to save the result + #' @param ... Other optional arguments + #' + #' @return API response (character) with additional information such as HTTP status code, headers + CloseGuiWithHttpInfo = function(project_id, close_project = NULL, data_file = NULL, ...) { + args <- list(...) + query_params <- list() + header_params <- c() + form_params <- list() + file_params <- list() + local_var_body <- NULL + oauth_scopes <- NULL + is_oauth <- FALSE + + if (missing(`project_id`)) { + stop("Missing required parameter `project_id`.") + } + + + + query_params[["closeProject"]] <- `close_project` + + local_var_url_path <- "/api/projects/{projectId}/gui" + if (!missing(`project_id`)) { + local_var_url_path <- gsub("\\{projectId\\}", URLencode(as.character(`project_id`), reserved = TRUE), local_var_url_path) + } + + + # The Accept request HTTP header + local_var_accepts <- list("application/json") + + # The Content-Type representation header + local_var_content_types <- list() + + local_var_resp <- self$api_client$CallApi(url = paste0(self$api_client$base_path, local_var_url_path), + method = "DELETE", + query_params = query_params, + header_params = header_params, + form_params = form_params, + file_params = file_params, + accepts = local_var_accepts, + content_types = local_var_content_types, + body = local_var_body, + is_oauth = is_oauth, + oauth_scopes = oauth_scopes, + ...) + + if (local_var_resp$status_code >= 200 && local_var_resp$status_code <= 299) { + # save response in a file + if (!is.null(data_file)) { + write(local_var_resp$response, data_file) + } + + # Check if we are expecting a CSV response + is_csv_response <- any(grepl("csv", local_var_accepts, ignore.case = TRUE)) + + if (is_csv_response) { + # For CSV responses, parse into data.frame + csv_resp_obj <- tryCatch( + { + csv_text <- rawToChar(local_var_resp$response) + + # Detect separator by examining first line + first_line <- strsplit(csv_text, "\n")[[1]][1] + if (grepl("\t", first_line)) { + # Tab-separated (TSV) + read.csv(text = csv_text, stringsAsFactors = FALSE, sep = "\t") + } else { + # Comma-separated (CSV) + read.csv(text = csv_text, stringsAsFactors = FALSE, sep = ",") + } + }, + error = function(e) { + stop("Failed to parse CSV response") + } + ) + local_var_resp$content <- csv_resp_obj + } else { + # For JSON responses, deserialize normally + deserialized_resp_obj <- tryCatch( + self$api_client$deserialize(local_var_resp$response_as_text(), "character", loadNamespace("RSirius")), + error = function(e) { + stop("Failed to deserialize response") + } + ) + local_var_resp$content <- deserialized_resp_obj + } + local_var_resp + } else if (local_var_resp$status_code >= 300 && local_var_resp$status_code <= 399) { + ApiResponse$new(paste("Server returned ", local_var_resp$status_code, " response status code."), local_var_resp) + } else if (local_var_resp$status_code >= 400 && local_var_resp$status_code <= 499) { + ApiResponse$new("API client error", local_var_resp) + } else if (local_var_resp$status_code >= 500 && local_var_resp$status_code <= 599) { + if (is.null(local_var_resp$response) || local_var_resp$response == "") { + local_var_resp$response <- "API server error" + } + local_var_resp + } + }, + + #' @description + #' Get list of currently running gui windows, managed by this SIRIUS instance. + #' + #' @param data_file (optional) name of the data file to save the result + #' @param ... Other optional arguments + #' + #' @return array[GuiInfo] + GetGuis = function(data_file = NULL, ...) { + local_var_response <- self$GetGuisWithHttpInfo(data_file = data_file, ...) + if (local_var_response$status_code >= 200 && local_var_response$status_code <= 299) { + local_var_response$content + } else if (local_var_response$status_code >= 300 && local_var_response$status_code <= 399) { + local_var_response + } else if (local_var_response$status_code >= 400 && local_var_response$status_code <= 499) { + local_var_response + } else if (local_var_response$status_code >= 500 && local_var_response$status_code <= 599) { + local_var_response + } + }, + + #' @description + #' Get list of currently running gui windows, managed by this SIRIUS instance. + #' + #' @param data_file (optional) name of the data file to save the result + #' @param ... Other optional arguments + #' + #' @return API response (array[GuiInfo]) with additional information such as HTTP status code, headers + GetGuisWithHttpInfo = function(data_file = NULL, ...) { + args <- list(...) + query_params <- list() + header_params <- c() + form_params <- list() + file_params <- list() + local_var_body <- NULL + oauth_scopes <- NULL + is_oauth <- FALSE + + local_var_url_path <- "/api/guis" + + # The Accept request HTTP header + local_var_accepts <- list("application/json") + + # The Content-Type representation header + local_var_content_types <- list() + + local_var_resp <- self$api_client$CallApi(url = paste0(self$api_client$base_path, local_var_url_path), + method = "GET", + query_params = query_params, + header_params = header_params, + form_params = form_params, + file_params = file_params, + accepts = local_var_accepts, + content_types = local_var_content_types, + body = local_var_body, + is_oauth = is_oauth, + oauth_scopes = oauth_scopes, + ...) + + if (local_var_resp$status_code >= 200 && local_var_resp$status_code <= 299) { + # save response in a file + if (!is.null(data_file)) { + write(local_var_resp$response, data_file) + } + + # Check if we are expecting a CSV response + is_csv_response <- any(grepl("csv", local_var_accepts, ignore.case = TRUE)) + + if (is_csv_response) { + # For CSV responses, parse into data.frame + csv_resp_obj <- tryCatch( + { + csv_text <- rawToChar(local_var_resp$response) + + # Detect separator by examining first line + first_line <- strsplit(csv_text, "\n")[[1]][1] + if (grepl("\t", first_line)) { + # Tab-separated (TSV) + read.csv(text = csv_text, stringsAsFactors = FALSE, sep = "\t") + } else { + # Comma-separated (CSV) + read.csv(text = csv_text, stringsAsFactors = FALSE, sep = ",") + } + }, + error = function(e) { + stop("Failed to parse CSV response") + } + ) + local_var_resp$content <- csv_resp_obj + } else { + # For JSON responses, deserialize normally + deserialized_resp_obj <- tryCatch( + self$api_client$deserialize(local_var_resp$response_as_text(), "array[GuiInfo]", loadNamespace("RSirius")), + error = function(e) { + stop("Failed to deserialize response") + } + ) + local_var_resp$content <- deserialized_resp_obj + } + local_var_resp + } else if (local_var_resp$status_code >= 300 && local_var_resp$status_code <= 399) { + ApiResponse$new(paste("Server returned ", local_var_resp$status_code, " response status code."), local_var_resp) + } else if (local_var_resp$status_code >= 400 && local_var_resp$status_code <= 499) { + ApiResponse$new("API client error", local_var_resp) + } else if (local_var_resp$status_code >= 500 && local_var_resp$status_code <= 599) { + if (is.null(local_var_resp$response) || local_var_resp$response == "") { + local_var_resp$response <- "API server error" + } + local_var_resp + } + }, + + #' @description + #' Open GUI instance on specified project-space and bring the GUI window to foreground. + #' + #' @param project_id of project-space the GUI instance will connect to. + #' @param ... Other optional arguments + #' + #' @return void + OpenGui = function(project_id, ...) { + local_var_response <- self$OpenGuiWithHttpInfo(project_id, ...) + if (local_var_response$status_code >= 200 && local_var_response$status_code <= 299) { + local_var_response$content + } else if (local_var_response$status_code >= 300 && local_var_response$status_code <= 399) { + local_var_response + } else if (local_var_response$status_code >= 400 && local_var_response$status_code <= 499) { + local_var_response + } else if (local_var_response$status_code >= 500 && local_var_response$status_code <= 599) { + local_var_response + } + }, + + #' @description + #' Open GUI instance on specified project-space and bring the GUI window to foreground. + #' + #' @param project_id of project-space the GUI instance will connect to. + #' @param ... Other optional arguments + #' + #' @return API response (void) with additional information such as HTTP status code, headers + OpenGuiWithHttpInfo = function(project_id, ...) { + args <- list(...) + query_params <- list() + header_params <- c() + form_params <- list() + file_params <- list() + local_var_body <- NULL + oauth_scopes <- NULL + is_oauth <- FALSE + + if (missing(`project_id`)) { + stop("Missing required parameter `project_id`.") + } + + + local_var_url_path <- "/api/projects/{projectId}/gui" + if (!missing(`project_id`)) { + local_var_url_path <- gsub("\\{projectId\\}", URLencode(as.character(`project_id`), reserved = TRUE), local_var_url_path) + } + + + # The Accept request HTTP header + local_var_accepts <- list() + + # The Content-Type representation header + local_var_content_types <- list() + + local_var_resp <- self$api_client$CallApi(url = paste0(self$api_client$base_path, local_var_url_path), + method = "POST", + query_params = query_params, + header_params = header_params, + form_params = form_params, + file_params = file_params, + accepts = local_var_accepts, + content_types = local_var_content_types, + body = local_var_body, + is_oauth = is_oauth, + oauth_scopes = oauth_scopes, + ...) + + if (local_var_resp$status_code >= 200 && local_var_resp$status_code <= 299) { + local_var_resp$content <- NULL + local_var_resp + } else if (local_var_resp$status_code >= 300 && local_var_resp$status_code <= 399) { + ApiResponse$new(paste("Server returned ", local_var_resp$status_code, " response status code."), local_var_resp) + } else if (local_var_resp$status_code >= 400 && local_var_resp$status_code <= 499) { + ApiResponse$new("API client error", local_var_resp) + } else if (local_var_resp$status_code >= 500 && local_var_resp$status_code <= 599) { + if (is.null(local_var_resp$response) || local_var_resp$response == "") { + local_var_resp$response <- "API server error" + } + local_var_resp + } + } + ) +) diff --git a/client-api_r/generated/R/gui_info.R b/client-api_r/generated/R/gui_info.R new file mode 100644 index 00000000..1b4259fe --- /dev/null +++ b/client-api_r/generated/R/gui_info.R @@ -0,0 +1,159 @@ +#' Create a new GuiInfo +#' +#' @description +#' GuiInfo Class +#' +#' @docType class +#' @title GuiInfo +#' @description GuiInfo Class +#' @format An \code{R6Class} generator object +#' @field projectId The project this instance is running on character [optional] +#' @importFrom R6 R6Class +#' @importFrom jsonlite fromJSON toJSON +#' @export +GuiInfo <- R6::R6Class( + "GuiInfo", + public = list( + `projectId` = NULL, + + #' @description + #' Initialize a new GuiInfo class. + #' + #' @param projectId The project this instance is running on + #' @param ... Other optional arguments. + initialize = function(`projectId` = NULL, ...) { + if (!is.null(`projectId`)) { + if (!(is.character(`projectId`) && length(`projectId`) == 1)) { + stop(paste("Error! Invalid data for `projectId`. Must be a string:", `projectId`)) + } + self$`projectId` <- `projectId` + } + }, + + #' @description + #' Convert to an R object. This method is deprecated. Use `toSimpleType()` instead. + toJSON = function() { + .Deprecated(new = "toSimpleType", msg = "Use the '$toSimpleType()' method instead since that is more clearly named. Use '$toJSONString()' to get a JSON string") + return(self$toSimpleType()) + }, + + #' @description + #' Convert to a List + #' + #' Convert the R6 object to a list to work more easily with other tooling. + #' + #' @return GuiInfo as a base R list. + #' @examples + #' # convert array of GuiInfo (x) to a data frame + #' \dontrun{ + #' library(purrr) + #' library(tibble) + #' df <- x |> map(\(y)y$toList()) |> map(as_tibble) |> list_rbind() + #' df + #' } + toList = function() { + return(self$toSimpleType()) + }, + + #' @description + #' Convert GuiInfo to a base R type + #' + #' @return A base R type, e.g. a list or numeric/character array. + toSimpleType = function() { + GuiInfoObject <- list() + if (!is.null(self$`projectId`)) { + GuiInfoObject[["projectId"]] <- + self$`projectId` + } + return(GuiInfoObject) + }, + + #' @description + #' Deserialize JSON string into an instance of GuiInfo + #' + #' @param input_json the JSON input + #' @return the instance of GuiInfo + fromJSON = function(input_json) { + this_object <- jsonlite::fromJSON(input_json) + if (!is.null(this_object$`projectId`)) { + self$`projectId` <- this_object$`projectId` + } + self + }, + + #' @description + #' To JSON String + #' + #' @param ... Parameters passed to `jsonlite::toJSON` + #' @return GuiInfo in JSON format + toJSONString = function(...) { + simple <- self$toSimpleType() + json <- jsonlite::toJSON(simple, auto_unbox = TRUE, digits = NA, null = 'null', ...) + return(as.character(jsonlite::minify(json))) + }, + + #' @description + #' Deserialize JSON string into an instance of GuiInfo + #' + #' @param input_json the JSON input + #' @return the instance of GuiInfo + fromJSONString = function(input_json) { + this_object <- jsonlite::fromJSON(input_json) + self$`projectId` <- this_object$`projectId` + self + }, + + #' @description + #' Validate JSON input with respect to GuiInfo and throw an exception if invalid + #' + #' @param input the JSON input + validateJSON = function(input) { + input_json <- jsonlite::fromJSON(input) + }, + + #' @description + #' To string (JSON format) + #' + #' @return String representation of GuiInfo + toString = function() { + self$toJSONString() + }, + + #' @description + #' Return true if the values in all fields are valid. + #' + #' @return true if the values in all fields are valid. + isValid = function() { + TRUE + }, + + #' @description + #' Return a list of invalid fields (if any). + #' + #' @return A list of invalid fields (if any). + getInvalidFields = function() { + invalid_fields <- list() + invalid_fields + }, + + #' @description + #' Print the object + print = function() { + print(jsonlite::prettify(self$toJSONString())) + invisible(self) + } + ), + # Lock the class to prevent modifications to the method or field + lock_class = TRUE +) +## Uncomment below to unlock the class to allow modifications of the method or field +# GuiInfo$unlock() +# +## Below is an example to define the print function +# GuiInfo$set("public", "print", function(...) { +# print(jsonlite::prettify(self$toJSONString())) +# invisible(self) +# }) +## Uncomment below to lock the class to prevent modifications to the method or field +# GuiInfo$lock() + diff --git a/client-api_r/generated/R/rsirius_api.R b/client-api_r/generated/R/rsirius_api.R index 4816da6a..c44f36ac 100644 --- a/client-api_r/generated/R/rsirius_api.R +++ b/client-api_r/generated/R/rsirius_api.R @@ -23,6 +23,7 @@ #' @field compounds_api an instance of CompoundsApi #' @field feature_statistics_api an instance of FeatureStatisticsApi #' @field features_api an instance of FeaturesApi +#' @field gui_api an instance of GuiApi #' @field info_api an instance of InfoApi #' @field jobs_api an instance of JobsApi #' @field login_and_account_api an instance of LoginAndAccountApi @@ -40,6 +41,7 @@ rsirius_api <- R6::R6Class( compounds_api = NULL, feature_statistics_api = NULL, features_api = NULL, + gui_api = NULL, info_api = NULL, jobs_api = NULL, login_and_account_api = NULL, @@ -71,6 +73,8 @@ rsirius_api <- R6::R6Class( self$features_api <- FeaturesApi$new(self$api_client) + self$gui_api <- GuiApi$new(self$api_client) + self$info_api <- InfoApi$new(self$api_client) self$jobs_api <- JobsApi$new(self$api_client) diff --git a/client-api_r/generated/R/rsirius_sdk.R b/client-api_r/generated/R/rsirius_sdk.R index fe069d10..92789c8b 100644 --- a/client-api_r/generated/R/rsirius_sdk.R +++ b/client-api_r/generated/R/rsirius_sdk.R @@ -1,435 +1,435 @@ -SiriusSDK <- R6::R6Class( - "SiriusSDK", - public = list( - port = NULL, - host = NULL, - sirius_path = NULL, - projectspace = NULL, - workspace = NULL, - process = NULL, - process_id = NULL, - api_client = NULL, - run_command = NULL, - run_args = NULL, - - reset_sdk_class = function() { - self$port <- NULL - self$host <- NULL - self$sirius_path <- NULL - self$projectspace <- NULL - self$workspace <- NULL - self$process <- NULL - self$process_id <- NULL - self$api_client <- NULL - self$run_command <- NULL - self$run_args <- NULL - }, - - reset_sdk_process = function() { - self$process <- NULL - self$process_id <- NULL - }, - - connect = function(url) { - self$host <- url - self$api_client <- RSirius::ApiClient$new(self$host) - return(RSirius::rsirius_api$new(self$api_client)) - }, - - reconnect = function() { - if (!is.null(self$api_client) && !is.null(self$process) && self$process$is_alive()) { - return(RSirius::rsirius_api(self$api_client)) - } - cat("Cannot reconnect, api_client and/or process are NULL or process has terminated.\n") - return() - }, - - restart_sirius = function() { - if (!is.null(self$run_command) && !is.null(self$run_args) && !is.null(self$process) && !is.null(self$api_client)) { - if (inherits(self$shutdown_sirius(), "logical")) { - cat("Shutdown seems to have gone wrong, aborting restart...\n") - return() - } - - self$process <- processx::process$new(command = self$run_command, args = self$run_args) - for (i in 1:60) { - Sys.sleep(1) - tryCatch({ - if (self$process$is_alive()) { - found <- private$cycle_find_sirius_pid_and_port() - if (!found) { - cat("Could not find sirius.port file. Please terminate SIRIUS if needed and try specifying a port\n") - cat("Alternatively, try attaching to a running SIRIUS instance with attach_to_running_sirius()\n") - return() - } - # connect() sets self$host and self$api_client - host <- paste0('http://localhost:', self$port) - sirius_api <- self$connect(host) - return(sirius_api) - } else { - cat("The SIRIUS process seems to have exited during startup. Please investigate this error.\n") - self$reset_sdk_class() - } - }, error = function(e) { - cat(e$message, "\n") - }) - } - - cat("SIRIUS seems to have problems starting. Resetting SiriusSDK...\n") - self$reset_sdk_class() - return() - } - cat("Could not attempt REST restart, run_command, run_args, process or api_client are NULL.\n") - return() - }, - - attach_or_start_sirius = function(headless = NULL) { - sirius_api <- self$attach_to_sirius() - # attachment encountered issue - if (is.logical(sirius_api)) { - return() - } - # attachment did not encounter issue but also found no SIRIUS - else if (is.null(sirius_api)) { - sirius_api <- self$start_sirius(headless = headless) - } - # attachment successful - else { - message("Attached to running SIRIUS instance.") - } - return(sirius_api) - }, - - attach_to_sirius = function(sirius_major_version = NULL, sirius_port = NULL) { - - # check if connection to API client is possible - if (!is.null(self$api_client)) { - tryCatch({ - if (RSirius::ActuatorApi$new(self$api_client)$Health()$status == "UP") { - return(RSirius::rsirius_api$new(self$api_client)) - } - }, error = function(e) { - message("Found existing API Client, but could not reach API.") - }) - } - - # create and check API client from existing port - if (!is.null(self$port)) { - self$host <- paste0('http://localhost:', self$port) - sirius_api <- self$connect(self$host) - self$api_client <- sirius_api$api_client - tryCatch({ - if (RSirius::ActuatorApi$new(self$api_client)$Health()$status == "UP") { - return(RSirius::rsirius_api$new(self$api_client)) - } - }, error = function(e) { - message("Found existing port, but could not reach API under this port.") - }) - } - - # if client is not reachable, search for process and kill if necessary - if (!is.null(self$process)) { - if (self$process$is_alive()) { - message("The SIRIUS process still seems to be lingering, but no connection could be made to the API.") - message("Shutting down the process...") - if (inherits(self$shutdown_sirius(), "logical")) { - # before error messages will be done by shutdown function - message("Aborting....") - return(FALSE) - } - message("Process shut down successfully.") - } else { - message("Known process seems to have terminated at some time.") - } - } - - self$reset_sdk_class() - message("SiriusSDK has been reset. Continuing with search for new SIRIUS instance...") - - if (!is.null(sirius_port)) { - self$port <- sirius_port - } else { - found <- private$find_sirius_pid_and_port(sirius_major_version) - if (!found) { - message("No port file matching ~/.sirius/sirius-X.X.port was found.") - message("Please try providing the port.") - return() - } - } - - self$host <- paste0('http://localhost:', self$port) - sirius_api <- self$connect(self$host) - self$api_client <- sirius_api$api_client - - tryCatch({ - if (RSirius::ActuatorApi$new(self$api_client)$Health()$status == "UP") { - return(RSirius::rsirius_api$new(self$api_client)) - } - }, error = function(e) { - message("Created API client from process_id and port, but could not reach API.") - }) - - message("Files for SIRIUS process_id and port have been found, but do not belong to an alive API.") - message("Process_id and port files will be deleted and start_sirius will be called.") - private$delete_sirius_pid_and_port(sirius_major_version) - self$reset_sdk_class() - - return() - }, - - start_sirius = function(sirius_path = NULL, port = NULL, projectspace = NULL, workspace = NULL, forceStart = FALSE, headless = NULL) { - if (!is.null(self$process) && !forceStart) { - cat("Sirius seems to have already been started with PID:", self$process$get_pid(), ".\n") - cat("Use reconnect() to get a new API instance for your current SIRIUS.\n") - cat("Use shutdown_sirius() and then start_sirius() to restart SIRIUS and get a new API instance.\n") - cat("If you are sure the process is not running anymore, use reset_sdk_process() or reset the complete SDK using reset_sdk_class() before calling start() again.\n") - cat("[NOT RECOMMENDED] Use start with forceStart=TRUE to skip this warning and start a second service.\n") - return() - } - - self$workspace <- workspace - - if (!is.null(sirius_path)) { - if (!file.exists(sirius_path)) { - cat("Wrong path to executable.\n") - self$reset_sdk_class() - return() - } - self$sirius_path <- normalizePath(sirius_path) - } else { - if (Sys.getenv("PATH") == "" || !grepl("sirius", Sys.getenv("PATH"))) { - cat("Please provide a path to the sirius executable if not declared in PATH!\n") - self$reset_sdk_class() - return() - } - cat("Found SIRIUS in PATH! Using this information to start the application.\n") - self$sirius_path <- 'sirius' - } - - if (!is.null(projectspace)) { - if (!file.exists(projectspace)) { - cat("Wrong path to project space.\n") - self$reset_sdk_class() - return() - } - self$projectspace <- normalizePath(projectspace) - run_args <- c("--output", self$projectspace, "REST", "-s") - } else { - run_args <- c("REST", "-s") - } - - if (!is.null(workspace)) { - if (!file.exists(workspace)) { - cat("Wrong path to workspace\n") - self$reset_sdk_class() - return() - } - cat("[WARNING] Overwriting workspace location [NOT RECOMMENDED]\n") - self$workspace <- normalizePath(workspace) - run_args <- append(run_args, c("--workspace", workspace), 0) - } - - if (!is.null(port)) { - self$port <- port - run_args <- append(run_args, c("-p", as.character(port))) - } - - if (!is.null(headless) && headless == TRUE) { - run_args <- append(run_args, "--headless") - } else if (!is.null(headless) && headless == FALSE) { - run_args <- append(run_args, "--no-headless") - } - - self$run_command <- self$sirius_path - self$run_args <- run_args - self$process <- processx::process$new(command = self$run_command, args = self$run_args) - self$process_id <- self$process$get_pid() - - if (is.null(port)) { - cat("SIRIUS was started without specifying --port (-p), trying to find the sirius.port file.\n") - if (is.null(workspace)) { - found <- private$cycle_find_sirius_pid_and_port() - } else { - found <- private$cycle_find_sirius_pid_and_port(folder = workspace) - } - if (!found) { - cat("Could not find sirius.port file. Please terminate SIRIUS if needed and try specifying a port\n") - cat("Alternatively, try attaching to a running SIRIUS instance with attach_to_running_sirius()\n") - return() - } - } - - self$host <- paste0('http://localhost:', self$port) - sirius_api <- self$connect(self$host) - self$api_client <- sirius_api$api_client - - for (i in 1:30) { - Sys.sleep(1) - tryCatch({ - if (self$process$is_alive()) { - if (sirius_api$actuator_api$Health()$status == "UP") { - return(sirius_api) - } - } else { - cat("The SIRIUS process seems to have exited during startup. Please investigate this error.\n") - self$reset_sdk_class() - } - }, error = function(e) { - cat(e$message, "\n") - }) - } - - cat("SIRIUS seems to have problems starting. Resetting SiriusSDK...\n") - self$reset_sdk_class() - return() - }, - - shutdown_sirius = function() { - - tryCatch({ - code <- RSirius::ActuatorApi$new(self$api_client)$ShutdownWithHttpInfo()$status_code - Sys.sleep(3) - if (code == 200) { - cat("Sirius was shut down successfully\n") - self$reset_sdk_process() - return() - } - }, error = function(e) { - cat("An Exception occurred while trying to gracefully shutdown SIRIUS!\n") - cat(e$message, "\n") - }) - - if (!is.null(self$process)) { - self$process$interrupt() - Sys.sleep(3) - if (!self$process$is_alive()) { - cat("Sirius process has been terminated.\n") - self$reset_sdk_process() - return() - } - - self$process$kill() - Sys.sleep(3) - if (!self$process$is_alive()) { - cat("Sirius process has been killed.\n") - self$reset_sdk_process() - return() - } - - cat("Unable to stop Sirius! - Please manually terminate the process with PID ", self$process$get_pid(), "\n") - cat("After terminating the process, use start_sirius() to start a new instance of SIRIUS.\n") - return(FALSE) - } else if (!is.null(self$process_id)) { - system(paste("kill -SIGTERM", self$process_id)) - Sys.sleep(3) - tryCatch({ - system(paste("kill -0", self$process_id)) - }, error = function(e) { - cat("Sirius process has been terminated.\n") - self$reset_sdk_process() - return() - }) - - system(paste("kill -SIGKILL", self$process_id)) - Sys.sleep(3) - tryCatch({ - system(paste("kill -0", self$process_id)) - }, error = function(e) { - cat("Sirius process has been killed.\n") - self$reset_sdk_process() - return() - }) - - cat("Unable to stop Sirius! - Please manually terminate the process with PID ", self$process_id, "\n") - cat("After terminating the process, use start_sirius() to start a new instance of SIRIUS.\n") - return(FALSE) - } else { - cat("There does not seem to be any process or process_id to shut down...\n") - return(FALSE) - } - } - ), - - private = list( - are_all_vars_none = function() { - all_names <- ls(envir = self, all.names = TRUE) - # exclude functions - field_names <- all_names[sapply(all_names, function(name) !is.function(self[[name]]))] - # exclude ".__enclos_env__" - field_names <- field_names[-1] - all(sapply(field_names, function(name) is.null(self[[name]]))) - }, - - find_sirius_pid_and_port = function(sirius_version = NULL) { - result = private$get_sirius_pid_and_port(sirius_version) - if (is.logical(result)) { - return(FALSE) - } - pid_file = result[[1]] - port_file = result[[2]] - pid <- as.integer(readLines(pid_file, warn = FALSE)) - port <- as.integer(readLines(port_file, warn = FALSE)) - - self$process_id <- pid - self$port <- port - - message("Using port ", port, " from file ", port_file) - message("Using PID ", pid, " from file ", pid_file) - return(TRUE) - }, - - delete_sirius_pid_and_port = function(sirius_version = NULL) { - result = private$get_sirius_pid_and_port(sirius_version) - if (is.logical(result)) { - return(FALSE) - } - pid_file = result[[1]] - port_file = result[[2]] - file.remove(pid_file) - file.remove (port_file) - }, - - get_sirius_pid_and_port = function(sirius_version = NULL) { - if (Sys.info()['sysname']=="Windows") { - global_workspace <- file.path(Sys.getenv("USERPROFILE"), ".sirius") - } else { - global_workspace <- path.expand("~/.sirius") - } - - if (is.null(sirius_version) || sirius_version == "None") { - port_pattern_match <- "[0-9]*" - } else { - port_pattern_match <- sirius_version - } - - port_pattern <- file.path(global_workspace, paste0("sirius-", port_pattern_match, ".port")) - port_files <- Sys.glob(port_pattern) - - if (length(port_files) == 0) { - return(FALSE) - } - - if (length(port_files) > 1) { - message("Following sirius port files detected:") - for (f in port_files) { - message(f) - } - } - - port_file <- sort(port_files)[length(port_files)] - pid_file <- sub(".port$", ".pid", port_file) - - return(c(pid_file, port_file)) - }, - - cycle_find_sirius_pid_and_port = function() { - for (i in 1:30) { - Sys.sleep(1) - if (private$find_sirius_pid_and_port()) { - return(TRUE) - } - } - return(FALSE) - } - ) -) +SiriusSDK <- R6::R6Class( + "SiriusSDK", + public = list( + port = NULL, + host = NULL, + sirius_path = NULL, + projectspace = NULL, + workspace = NULL, + process = NULL, + process_id = NULL, + api_client = NULL, + run_command = NULL, + run_args = NULL, + + reset_sdk_class = function() { + self$port <- NULL + self$host <- NULL + self$sirius_path <- NULL + self$projectspace <- NULL + self$workspace <- NULL + self$process <- NULL + self$process_id <- NULL + self$api_client <- NULL + self$run_command <- NULL + self$run_args <- NULL + }, + + reset_sdk_process = function() { + self$process <- NULL + self$process_id <- NULL + }, + + connect = function(url) { + self$host <- url + self$api_client <- RSirius::ApiClient$new(self$host) + return(RSirius::rsirius_api$new(self$api_client)) + }, + + reconnect = function() { + if (!is.null(self$api_client) && !is.null(self$process) && self$process$is_alive()) { + return(RSirius::rsirius_api(self$api_client)) + } + cat("Cannot reconnect, api_client and/or process are NULL or process has terminated.\n") + return() + }, + + restart_sirius = function() { + if (!is.null(self$run_command) && !is.null(self$run_args) && !is.null(self$process) && !is.null(self$api_client)) { + if (inherits(self$shutdown_sirius(), "logical")) { + cat("Shutdown seems to have gone wrong, aborting restart...\n") + return() + } + + self$process <- processx::process$new(command = self$run_command, args = self$run_args) + for (i in 1:60) { + Sys.sleep(1) + tryCatch({ + if (self$process$is_alive()) { + found <- private$cycle_find_sirius_pid_and_port() + if (!found) { + cat("Could not find sirius.port file. Please terminate SIRIUS if needed and try specifying a port\n") + cat("Alternatively, try attaching to a running SIRIUS instance with attach_to_running_sirius()\n") + return() + } + # connect() sets self$host and self$api_client + host <- paste0('http://localhost:', self$port) + sirius_api <- self$connect(host) + return(sirius_api) + } else { + cat("The SIRIUS process seems to have exited during startup. Please investigate this error.\n") + self$reset_sdk_class() + } + }, error = function(e) { + cat(e$message, "\n") + }) + } + + cat("SIRIUS seems to have problems starting. Resetting SiriusSDK...\n") + self$reset_sdk_class() + return() + } + cat("Could not attempt REST restart, run_command, run_args, process or api_client are NULL.\n") + return() + }, + + attach_or_start_sirius = function(headless = NULL) { + sirius_api <- self$attach_to_sirius() + # attachment encountered issue + if (is.logical(sirius_api)) { + return() + } + # attachment did not encounter issue but also found no SIRIUS + else if (is.null(sirius_api)) { + sirius_api <- self$start_sirius(headless = headless) + } + # attachment successful + else { + message("Attached to running SIRIUS instance.") + } + return(sirius_api) + }, + + attach_to_sirius = function(sirius_major_version = NULL, sirius_port = NULL) { + + # check if connection to API client is possible + if (!is.null(self$api_client)) { + tryCatch({ + if (RSirius::ActuatorApi$new(self$api_client)$Health()$status == "UP") { + return(RSirius::rsirius_api$new(self$api_client)) + } + }, error = function(e) { + message("Found existing API Client, but could not reach API.") + }) + } + + # create and check API client from existing port + if (!is.null(self$port)) { + self$host <- paste0('http://localhost:', self$port) + sirius_api <- self$connect(self$host) + self$api_client <- sirius_api$api_client + tryCatch({ + if (RSirius::ActuatorApi$new(self$api_client)$Health()$status == "UP") { + return(RSirius::rsirius_api$new(self$api_client)) + } + }, error = function(e) { + message("Found existing port, but could not reach API under this port.") + }) + } + + # if client is not reachable, search for process and kill if necessary + if (!is.null(self$process)) { + if (self$process$is_alive()) { + message("The SIRIUS process still seems to be lingering, but no connection could be made to the API.") + message("Shutting down the process...") + if (inherits(self$shutdown_sirius(), "logical")) { + # before error messages will be done by shutdown function + message("Aborting....") + return(FALSE) + } + message("Process shut down successfully.") + } else { + message("Known process seems to have terminated at some time.") + } + } + + self$reset_sdk_class() + message("SiriusSDK has been reset. Continuing with search for new SIRIUS instance...") + + if (!is.null(sirius_port)) { + self$port <- sirius_port + } else { + found <- private$find_sirius_pid_and_port(sirius_major_version) + if (!found) { + message("No port file matching ~/.sirius/sirius-X.X.port was found.") + message("Please try providing the port.") + return() + } + } + + self$host <- paste0('http://localhost:', self$port) + sirius_api <- self$connect(self$host) + self$api_client <- sirius_api$api_client + + tryCatch({ + if (RSirius::ActuatorApi$new(self$api_client)$Health()$status == "UP") { + return(RSirius::rsirius_api$new(self$api_client)) + } + }, error = function(e) { + message("Created API client from process_id and port, but could not reach API.") + }) + + message("Files for SIRIUS process_id and port have been found, but do not belong to an alive API.") + message("Process_id and port files will be deleted and start_sirius will be called.") + private$delete_sirius_pid_and_port(sirius_major_version) + self$reset_sdk_class() + + return() + }, + + start_sirius = function(sirius_path = NULL, port = NULL, projectspace = NULL, workspace = NULL, forceStart = FALSE, headless = NULL) { + if (!is.null(self$process) && !forceStart) { + cat("Sirius seems to have already been started with PID:", self$process$get_pid(), ".\n") + cat("Use reconnect() to get a new API instance for your current SIRIUS.\n") + cat("Use shutdown_sirius() and then start_sirius() to restart SIRIUS and get a new API instance.\n") + cat("If you are sure the process is not running anymore, use reset_sdk_process() or reset the complete SDK using reset_sdk_class() before calling start() again.\n") + cat("[NOT RECOMMENDED] Use start with forceStart=TRUE to skip this warning and start a second service.\n") + return() + } + + self$workspace <- workspace + + if (!is.null(sirius_path)) { + if (!file.exists(sirius_path)) { + cat("Wrong path to executable.\n") + self$reset_sdk_class() + return() + } + self$sirius_path <- normalizePath(sirius_path) + } else { + if (Sys.getenv("PATH") == "" || !grepl("sirius", Sys.getenv("PATH"))) { + cat("Please provide a path to the sirius executable if not declared in PATH!\n") + self$reset_sdk_class() + return() + } + cat("Found SIRIUS in PATH! Using this information to start the application.\n") + self$sirius_path <- 'sirius' + } + + if (!is.null(projectspace)) { + if (!file.exists(projectspace)) { + cat("Wrong path to project space.\n") + self$reset_sdk_class() + return() + } + self$projectspace <- normalizePath(projectspace) + run_args <- c("--output", self$projectspace, "REST", "-s") + } else { + run_args <- c("REST", "-s") + } + + if (!is.null(workspace)) { + if (!file.exists(workspace)) { + cat("Wrong path to workspace\n") + self$reset_sdk_class() + return() + } + cat("[WARNING] Overwriting workspace location [NOT RECOMMENDED]\n") + self$workspace <- normalizePath(workspace) + run_args <- append(run_args, c("--workspace", workspace), 0) + } + + if (!is.null(port)) { + self$port <- port + run_args <- append(run_args, c("-p", as.character(port))) + } + + if (!is.null(headless) && headless == TRUE) { + run_args <- append(run_args, "--headless") + } else if (!is.null(headless) && headless == FALSE) { + run_args <- append(run_args, "--no-headless") + } + + self$run_command <- self$sirius_path + self$run_args <- run_args + self$process <- processx::process$new(command = self$run_command, args = self$run_args) + self$process_id <- self$process$get_pid() + + if (is.null(port)) { + cat("SIRIUS was started without specifying --port (-p), trying to find the sirius.port file.\n") + if (is.null(workspace)) { + found <- private$cycle_find_sirius_pid_and_port() + } else { + found <- private$cycle_find_sirius_pid_and_port(folder = workspace) + } + if (!found) { + cat("Could not find sirius.port file. Please terminate SIRIUS if needed and try specifying a port\n") + cat("Alternatively, try attaching to a running SIRIUS instance with attach_to_running_sirius()\n") + return() + } + } + + self$host <- paste0('http://localhost:', self$port) + sirius_api <- self$connect(self$host) + self$api_client <- sirius_api$api_client + + for (i in 1:30) { + Sys.sleep(1) + tryCatch({ + if (self$process$is_alive()) { + if (sirius_api$actuator_api$Health()$status == "UP") { + return(sirius_api) + } + } else { + cat("The SIRIUS process seems to have exited during startup. Please investigate this error.\n") + self$reset_sdk_class() + } + }, error = function(e) { + cat(e$message, "\n") + }) + } + + cat("SIRIUS seems to have problems starting. Resetting SiriusSDK...\n") + self$reset_sdk_class() + return() + }, + + shutdown_sirius = function() { + + tryCatch({ + code <- RSirius::ActuatorApi$new(self$api_client)$ShutdownWithHttpInfo()$status_code + Sys.sleep(3) + if (code == 200) { + cat("Sirius was shut down successfully\n") + self$reset_sdk_process() + return() + } + }, error = function(e) { + cat("An Exception occurred while trying to gracefully shutdown SIRIUS!\n") + cat(e$message, "\n") + }) + + if (!is.null(self$process)) { + self$process$interrupt() + Sys.sleep(3) + if (!self$process$is_alive()) { + cat("Sirius process has been terminated.\n") + self$reset_sdk_process() + return() + } + + self$process$kill() + Sys.sleep(3) + if (!self$process$is_alive()) { + cat("Sirius process has been killed.\n") + self$reset_sdk_process() + return() + } + + cat("Unable to stop Sirius! - Please manually terminate the process with PID ", self$process$get_pid(), "\n") + cat("After terminating the process, use start_sirius() to start a new instance of SIRIUS.\n") + return(FALSE) + } else if (!is.null(self$process_id)) { + system(paste("kill -SIGTERM", self$process_id)) + Sys.sleep(3) + tryCatch({ + system(paste("kill -0", self$process_id)) + }, error = function(e) { + cat("Sirius process has been terminated.\n") + self$reset_sdk_process() + return() + }) + + system(paste("kill -SIGKILL", self$process_id)) + Sys.sleep(3) + tryCatch({ + system(paste("kill -0", self$process_id)) + }, error = function(e) { + cat("Sirius process has been killed.\n") + self$reset_sdk_process() + return() + }) + + cat("Unable to stop Sirius! - Please manually terminate the process with PID ", self$process_id, "\n") + cat("After terminating the process, use start_sirius() to start a new instance of SIRIUS.\n") + return(FALSE) + } else { + cat("There does not seem to be any process or process_id to shut down...\n") + return(FALSE) + } + } + ), + + private = list( + are_all_vars_none = function() { + all_names <- ls(envir = self, all.names = TRUE) + # exclude functions + field_names <- all_names[sapply(all_names, function(name) !is.function(self[[name]]))] + # exclude ".__enclos_env__" + field_names <- field_names[-1] + all(sapply(field_names, function(name) is.null(self[[name]]))) + }, + + find_sirius_pid_and_port = function(sirius_version = NULL) { + result = private$get_sirius_pid_and_port(sirius_version) + if (is.logical(result)) { + return(FALSE) + } + pid_file = result[[1]] + port_file = result[[2]] + pid <- as.integer(readLines(pid_file, warn = FALSE)) + port <- as.integer(readLines(port_file, warn = FALSE)) + + self$process_id <- pid + self$port <- port + + message("Using port ", port, " from file ", port_file) + message("Using PID ", pid, " from file ", pid_file) + return(TRUE) + }, + + delete_sirius_pid_and_port = function(sirius_version = NULL) { + result = private$get_sirius_pid_and_port(sirius_version) + if (is.logical(result)) { + return(FALSE) + } + pid_file = result[[1]] + port_file = result[[2]] + file.remove(pid_file) + file.remove (port_file) + }, + + get_sirius_pid_and_port = function(sirius_version = NULL) { + if (Sys.info()['sysname']=="Windows") { + global_workspace <- file.path(Sys.getenv("USERPROFILE"), ".sirius") + } else { + global_workspace <- path.expand("~/.sirius") + } + + if (is.null(sirius_version) || sirius_version == "None") { + port_pattern_match <- "[0-9]*" + } else { + port_pattern_match <- sirius_version + } + + port_pattern <- file.path(global_workspace, paste0("sirius-", port_pattern_match, ".port")) + port_files <- Sys.glob(port_pattern) + + if (length(port_files) == 0) { + return(FALSE) + } + + if (length(port_files) > 1) { + message("Following sirius port files detected:") + for (f in port_files) { + message(f) + } + } + + port_file <- sort(port_files)[length(port_files)] + pid_file <- sub(".port$", ".pid", port_file) + + return(c(pid_file, port_file)) + }, + + cycle_find_sirius_pid_and_port = function() { + for (i in 1:30) { + Sys.sleep(1) + if (private$find_sirius_pid_and_port()) { + return(TRUE) + } + } + return(FALSE) + } + ) +) diff --git a/client-api_r/generated/README.md b/client-api_r/generated/README.md index 58b34edb..c6ebce18 100644 --- a/client-api_r/generated/README.md +++ b/client-api_r/generated/README.md @@ -140,6 +140,9 @@ Class | Method | HTTP request | Description *FeaturesApi* | [**GetTagsForAlignedFeaturesExperimental**](docs/FeaturesApi.md#GetTagsForAlignedFeaturesExperimental) | **GET** /api/projects/{projectId}/aligned-features/tags/{objectId} | [EXPERIMENTAL] Get all tags associated with this Object *FeaturesApi* | [**GetTracesExperimental**](docs/FeaturesApi.md#GetTracesExperimental) | **GET** /api/projects/{projectId}/aligned-features/{alignedFeatureId}/traces | [EXPERIMENTAL] Returns the traces of the given feature (alignedFeatureId) *FeaturesApi* | [**RemoveTagFromAlignedFeatureExperimental**](docs/FeaturesApi.md#RemoveTagFromAlignedFeatureExperimental) | **DELETE** /api/projects/{projectId}/aligned-features/tags/{alignedFeatureId}/{tagName} | [EXPERIMENTAL] Delete tag with the given name from the feature (aligned over runs) with the specified ID in the specified project-space +*GuiApi* | [**CloseGui**](docs/GuiApi.md#CloseGui) | **DELETE** /api/projects/{projectId}/gui | Close GUI instance of given project-space if available. +*GuiApi* | [**GetGuis**](docs/GuiApi.md#GetGuis) | **GET** /api/guis | Get list of currently running gui windows, managed by this SIRIUS instance. +*GuiApi* | [**OpenGui**](docs/GuiApi.md#OpenGui) | **POST** /api/projects/{projectId}/gui | Open GUI instance on specified project-space and bring the GUI window to foreground. *InfoApi* | [**GetConnectionCheck**](docs/InfoApi.md#GetConnectionCheck) | **GET** /api/connection-status | *InfoApi* | [**GetInfo**](docs/InfoApi.md#GetInfo) | **GET** /api/info | *JobsApi* | [**DeleteJob**](docs/JobsApi.md#DeleteJob) | **DELETE** /api/projects/{projectId}/jobs/{jobId} | Delete job. @@ -247,6 +250,7 @@ Class | Method | HTTP request | Description - [FormulaCandidate](docs/FormulaCandidate.md) - [FragmentNode](docs/FragmentNode.md) - [FragmentationTree](docs/FragmentationTree.md) + - [GuiInfo](docs/GuiInfo.md) - [ImportResult](docs/ImportResult.md) - [Info](docs/Info.md) - [IsotopePatternAnnotation](docs/IsotopePatternAnnotation.md) diff --git a/client-api_r/generated/docs/GuiApi.md b/client-api_r/generated/docs/GuiApi.md new file mode 100644 index 00000000..675fd395 --- /dev/null +++ b/client-api_r/generated/docs/GuiApi.md @@ -0,0 +1,146 @@ +# GuiApi + +All URIs are relative to *http://localhost:8080* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**CloseGui**](GuiApi.md#CloseGui) | **DELETE** /api/projects/{projectId}/gui | Close GUI instance of given project-space if available. +[**GetGuis**](GuiApi.md#GetGuis) | **GET** /api/guis | Get list of currently running gui windows, managed by this SIRIUS instance. +[**OpenGui**](GuiApi.md#OpenGui) | **POST** /api/projects/{projectId}/gui | Open GUI instance on specified project-space and bring the GUI window to foreground. + + +# **CloseGui** +> character CloseGui(project_id, close_project = var.close_project) + +Close GUI instance of given project-space if available. + +Close GUI instance of given project-space if available. + +### Example +```R +library(RSirius) + +# Close GUI instance of given project-space if available. +# +# prepare function argument(s) +var_project_id <- "project_id_example" # character | if project-space the GUI instance is connected to. +var_close_project <- "close_project_example" # character | (Optional) + +api_instance <- rsirius_api$new() +# to save the result into a file, simply add the optional `data_file` parameter, e.g. +# result <- api_instance$CloseGui(var_project_id, close_project = var_close_projectdata_file = "result.txt") +result <- api_instance$gui_api$CloseGui(var_project_id, close_project = var_close_project) +dput(result) +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **project_id** | **character**| if project-space the GUI instance is connected to. | + **close_project** | **character**| | [optional] + +### Return type + +**character** + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | OK | - | + +# **GetGuis** +> array[GuiInfo] GetGuis() + +Get list of currently running gui windows, managed by this SIRIUS instance. + +Get list of currently running gui windows, managed by this SIRIUS instance. Note this will not show any Clients that are connected from a separate process! + +### Example +```R +library(RSirius) + +# Get list of currently running gui windows, managed by this SIRIUS instance. +# + +api_instance <- rsirius_api$new() +# to save the result into a file, simply add the optional `data_file` parameter, e.g. +# result <- api_instance$GetGuis(data_file = "result.txt") +result <- api_instance$gui_api$GetGuis() +dput(result) +``` + +### Parameters +This endpoint does not need any parameter. + +### Return type + +[**array[GuiInfo]**](GuiInfo.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | List of GUI windows that are currently managed by this SIRIUS instance. | - | + +# **OpenGui** +> OpenGui(project_id) + +Open GUI instance on specified project-space and bring the GUI window to foreground. + +Open GUI instance on specified project-space and bring the GUI window to foreground. + +### Example +```R +library(RSirius) + +# Open GUI instance on specified project-space and bring the GUI window to foreground. +# +# prepare function argument(s) +var_project_id <- "project_id_example" # character | of project-space the GUI instance will connect to. + +api_instance <- rsirius_api$new() +api_instance$gui_api$OpenGui(var_project_id) +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **project_id** | **character**| of project-space the GUI instance will connect to. | + +### Return type + +void (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: Not defined + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **201** | Created | - | + diff --git a/client-api_r/generated/docs/GuiInfo.md b/client-api_r/generated/docs/GuiInfo.md new file mode 100644 index 00000000..b1671dd8 --- /dev/null +++ b/client-api_r/generated/docs/GuiInfo.md @@ -0,0 +1,9 @@ +# RSirius::GuiInfo + + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**projectId** | **character** | The project this instance is running on | [optional] + + diff --git a/client-api_r/generated/man/GuiApi.Rd b/client-api_r/generated/man/GuiApi.Rd new file mode 100644 index 00000000..1fd26ebc --- /dev/null +++ b/client-api_r/generated/man/GuiApi.Rd @@ -0,0 +1,263 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/gui_api.R +\docType{class} +\name{GuiApi} +\alias{GuiApi} +\title{Gui operations} +\format{ +An \code{R6Class} generator object +} +\description{ +GuiApi +} +\details{ +SIRIUS Nightsky API + +REST API that provides the full functionality of SIRIUS and its web services as background service. It is intended as entry-point for scripting languages and software integration SDKs.This API is exposed by SIRIUS 6 + +The version of the OpenAPI document: 3.1 +Generated by: https://openapi-generator.tech +} +\examples{ +\dontrun{ +#################### CloseGui #################### + +library(RSirius) +var_project_id <- "project_id_example" # character | if project-space the GUI instance is connected to. +var_close_project <- "close_project_example" # character | (Optional) + +#Close GUI instance of given project-space if available. +api_instance <- rsirius_api$new() + +# to save the result into a file, simply add the optional `data_file` parameter, e.g. +# result <- api_instance$CloseGui(var_project_id, close_project = var_close_projectdata_file = "result.txt") +result <- api_instance$gui_api$CloseGui(var_project_id, close_project = var_close_project) +dput(result) + + +#################### GetGuis #################### + +library(RSirius) + +#Get list of currently running gui windows, managed by this SIRIUS instance. +api_instance <- rsirius_api$new() + +# to save the result into a file, simply add the optional `data_file` parameter, e.g. +# result <- api_instance$GetGuis(data_file = "result.txt") +result <- api_instance$gui_api$GetGuis() +dput(result) + + +#################### OpenGui #################### + +library(RSirius) +var_project_id <- "project_id_example" # character | of project-space the GUI instance will connect to. + +#Open GUI instance on specified project-space and bring the GUI window to foreground. +api_instance <- rsirius_api$new() + +api_instance$gui_api$OpenGui(var_project_id) + + +} +} +\section{Public fields}{ +\if{html}{\out{