octostar-python-client 0.1.759__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- octostar/__init__.py +9 -0
- octostar/api/__init__.py +1 -0
- octostar/api/apps/__init__.py +0 -0
- octostar/api/apps/deploy_app.py +210 -0
- octostar/api/apps/execute_app_job.py +188 -0
- octostar/api/apps/get_app_logs.py +210 -0
- octostar/api/apps/get_apps_url.py +188 -0
- octostar/api/apps/get_job_logs.py +210 -0
- octostar/api/apps/get_job_progress.py +162 -0
- octostar/api/apps/kill_job.py +160 -0
- octostar/api/apps/list_app_jobs.py +276 -0
- octostar/api/apps/list_apps.py +251 -0
- octostar/api/apps/set_job_progress.py +216 -0
- octostar/api/apps/undeploy_app.py +160 -0
- octostar/api/metadata/__init__.py +0 -0
- octostar/api/metadata/get_version.py +232 -0
- octostar/api/metadata/get_whoami.py +232 -0
- octostar/api/notifications/__init__.py +0 -0
- octostar/api/notifications/delete_stream.py +222 -0
- octostar/api/notifications/get_subscriptions.py +240 -0
- octostar/api/notifications/publish_notification.py +275 -0
- octostar/api/notifications/pull_events_from_stream.py +282 -0
- octostar/api/notifications/push_event_to_stream.py +265 -0
- octostar/api/notifications/toast.py +264 -0
- octostar/api/ontology/__init__.py +0 -0
- octostar/api/ontology/fetch_ontology_data.py +275 -0
- octostar/api/ontology/get_ontologies.py +237 -0
- octostar/api/ontology/multi_query.py +297 -0
- octostar/api/ontology/query.py +276 -0
- octostar/api/pipeline/__init__.py +1 -0
- octostar/api/pipeline/get_processing_status.py +185 -0
- octostar/api/pipeline/update_processing_status.py +164 -0
- octostar/api/search/__init__.py +0 -0
- octostar/api/search/get_annotations.py +153 -0
- octostar/api/workspace_data/__init__.py +0 -0
- octostar/api/workspace_data/delete_blob.py +212 -0
- octostar/api/workspace_data/delete_entities.py +326 -0
- octostar/api/workspace_data/download_blob.py +235 -0
- octostar/api/workspace_data/get_attachment.py +336 -0
- octostar/api/workspace_data/get_files_tree.py +397 -0
- octostar/api/workspace_data/upload_blob.py +235 -0
- octostar/api/workspace_data/upsert_entities.py +284 -0
- octostar/api/workspace_permissions/__init__.py +0 -0
- octostar/api/workspace_permissions/get_permissions.py +325 -0
- octostar/api/workspace_tags/__init__.py +0 -0
- octostar/api/workspace_tags/delete_tag_from_entities.py +141 -0
- octostar/api/workspace_tags/tag_entities.py +180 -0
- octostar/client.py +492 -0
- octostar/errors.py +50 -0
- octostar/models/__init__.py +249 -0
- octostar/models/acknowledgement.py +74 -0
- octostar/models/acknowledgement_with_data.py +82 -0
- octostar/models/app_status.py +239 -0
- octostar/models/app_status_annotations.py +66 -0
- octostar/models/app_status_labels.py +69 -0
- octostar/models/app_with_url.py +82 -0
- octostar/models/child_processing_status.py +118 -0
- octostar/models/delete_entities_response_401.py +74 -0
- octostar/models/delete_entities_response_409.py +82 -0
- octostar/models/delete_entities_response_500.py +82 -0
- octostar/models/delete_stream_response_401.py +74 -0
- octostar/models/delete_tag_from_entities_response_401.py +74 -0
- octostar/models/deploy_app_json_body.py +90 -0
- octostar/models/deploy_app_json_body_secrets.py +65 -0
- octostar/models/deploy_app_response_200.py +98 -0
- octostar/models/deploy_app_response_200_data.py +60 -0
- octostar/models/deploy_app_response_400.py +82 -0
- octostar/models/deploy_app_response_403.py +82 -0
- octostar/models/deploy_app_response_404.py +82 -0
- octostar/models/deploy_app_response_409.py +82 -0
- octostar/models/deploy_app_response_500.py +82 -0
- octostar/models/entity.py +80 -0
- octostar/models/entity_response.py +99 -0
- octostar/models/entity_response_s3_urls.py +93 -0
- octostar/models/entity_response_s3_urls_additional_property.py +105 -0
- octostar/models/entity_response_s3_urls_additional_property_fields.py +114 -0
- octostar/models/execute_app_job_json_body.py +151 -0
- octostar/models/execute_app_job_json_body_annotation.py +65 -0
- octostar/models/execute_app_job_response_401.py +74 -0
- octostar/models/fetch_ontology_data_response_200.py +60 -0
- octostar/models/fetch_ontology_data_response_401.py +74 -0
- octostar/models/fetch_ontology_data_response_500.py +82 -0
- octostar/models/get_app_logs_response_401.py +74 -0
- octostar/models/get_app_logs_response_404.py +74 -0
- octostar/models/get_app_logs_response_500.py +82 -0
- octostar/models/get_apps_url_json_body.py +76 -0
- octostar/models/get_apps_url_response_401.py +74 -0
- octostar/models/get_apps_url_response_500.py +82 -0
- octostar/models/get_attachment_response_200.py +74 -0
- octostar/models/get_attachment_response_401.py +74 -0
- octostar/models/get_files_tree_response_200.py +106 -0
- octostar/models/get_files_tree_response_200_status.py +8 -0
- octostar/models/get_files_tree_response_400.py +111 -0
- octostar/models/get_files_tree_response_400_data.py +60 -0
- octostar/models/get_files_tree_response_400_status.py +8 -0
- octostar/models/get_files_tree_response_401.py +74 -0
- octostar/models/get_files_tree_response_500.py +111 -0
- octostar/models/get_files_tree_response_500_data.py +60 -0
- octostar/models/get_files_tree_response_500_status.py +8 -0
- octostar/models/get_job_logs_response_401.py +74 -0
- octostar/models/get_job_logs_response_404.py +74 -0
- octostar/models/get_job_logs_response_500.py +82 -0
- octostar/models/get_job_progress_response_401.py +74 -0
- octostar/models/get_object_response_401.py +74 -0
- octostar/models/get_ontologies_response_401.py +74 -0
- octostar/models/get_ontologies_response_500.py +81 -0
- octostar/models/get_permissions_response_200.py +98 -0
- octostar/models/get_permissions_response_400.py +82 -0
- octostar/models/get_permissions_response_401.py +74 -0
- octostar/models/get_permissions_response_500.py +82 -0
- octostar/models/get_processing_status_response_200.py +104 -0
- octostar/models/get_processing_status_response_200_data.py +87 -0
- octostar/models/get_processing_status_response_400.py +82 -0
- octostar/models/get_processing_status_response_500.py +82 -0
- octostar/models/get_subscriptions_response_200_item.py +74 -0
- octostar/models/get_version_response_200.py +74 -0
- octostar/models/get_version_response_404.py +74 -0
- octostar/models/get_whoami_response_200.py +129 -0
- octostar/models/get_whoami_response_401.py +74 -0
- octostar/models/insert_entity.py +114 -0
- octostar/models/insert_entity_base.py +266 -0
- octostar/models/insert_entity_relationships_item.py +107 -0
- octostar/models/insert_entity_request.py +94 -0
- octostar/models/internal_server_error.py +82 -0
- octostar/models/job_execution_result.py +146 -0
- octostar/models/job_status.py +196 -0
- octostar/models/job_status_labels.py +60 -0
- octostar/models/job_with_url.py +82 -0
- octostar/models/kill_job_response_401.py +74 -0
- octostar/models/list_app_jobs_response_401.py +74 -0
- octostar/models/list_app_jobs_response_500.py +82 -0
- octostar/models/list_apps_response_401.py +74 -0
- octostar/models/list_apps_response_500.py +82 -0
- octostar/models/multi_query_json_body.py +100 -0
- octostar/models/multi_query_json_body_queries_item.py +80 -0
- octostar/models/multi_query_response_400.py +82 -0
- octostar/models/multi_query_response_401.py +74 -0
- octostar/models/not_found_error.py +74 -0
- octostar/models/octostar_event.py +96 -0
- octostar/models/octostar_event_octostar_payload.py +100 -0
- octostar/models/octostar_event_octostar_payload_level.py +11 -0
- octostar/models/os_notification.py +122 -0
- octostar/models/processing_status.py +262 -0
- octostar/models/processing_status_code.py +14 -0
- octostar/models/progress_request.py +73 -0
- octostar/models/publish_notification_response_401.py +74 -0
- octostar/models/pull_events_from_stream_response_401.py +74 -0
- octostar/models/push_event_to_stream_response_401.py +74 -0
- octostar/models/query_json_body.py +101 -0
- octostar/models/query_json_body_params.py +60 -0
- octostar/models/query_response_400.py +82 -0
- octostar/models/query_response_401.py +74 -0
- octostar/models/set_job_progress_response_401.py +74 -0
- octostar/models/string_to_value_label_map.py +99 -0
- octostar/models/string_to_value_label_map_data.py +89 -0
- octostar/models/string_to_value_label_map_data_additional_property.py +80 -0
- octostar/models/successful_get_tags.py +103 -0
- octostar/models/successful_insertion.py +98 -0
- octostar/models/tag_entities_response_401.py +74 -0
- octostar/models/toast_level.py +11 -0
- octostar/models/toast_response_401.py +74 -0
- octostar/models/undeploy_app_response_401.py +74 -0
- octostar/models/update_processing_status_response_200.py +82 -0
- octostar/models/update_processing_status_response_400.py +82 -0
- octostar/models/update_processing_status_response_500.py +82 -0
- octostar/models/upsert_entities_response_401.py +74 -0
- octostar/models/upsert_entity.py +114 -0
- octostar/models/upsert_entity_base.py +266 -0
- octostar/models/upsert_entity_relationships_item.py +107 -0
- octostar/py.typed +1 -0
- octostar/types.py +54 -0
- octostar/utils/__init__.py +15 -0
- octostar/utils/chat/__init__.py +0 -0
- octostar/utils/chat/chat.py +513 -0
- octostar/utils/chat/detokenize.py +105 -0
- octostar/utils/chat/get_default_model.py +50 -0
- octostar/utils/chat/list_models.py +91 -0
- octostar/utils/chat/tokenize.py +105 -0
- octostar/utils/commons.py +226 -0
- octostar/utils/exceptions.py +134 -0
- octostar/utils/jobs/__init__.py +0 -0
- octostar/utils/jobs/apps/__init__.py +0 -0
- octostar/utils/jobs/apps/deploy_app.py +81 -0
- octostar/utils/jobs/apps/execute_app_job.py +114 -0
- octostar/utils/jobs/apps/get_app_logs.py +113 -0
- octostar/utils/jobs/apps/get_app_secret.py +102 -0
- octostar/utils/jobs/apps/get_apps_url.py +73 -0
- octostar/utils/jobs/apps/list_app_jobs.py +62 -0
- octostar/utils/jobs/apps/list_apps.py +126 -0
- octostar/utils/jobs/apps/undeploy_app.py +48 -0
- octostar/utils/jobs/get_job_logs.py +113 -0
- octostar/utils/jobs/get_job_progress.py +76 -0
- octostar/utils/jobs/kill_job.py +47 -0
- octostar/utils/jobs/set_job_progress.py +67 -0
- octostar/utils/meta/__init__.py +0 -0
- octostar/utils/meta/get_version.py +30 -0
- octostar/utils/meta/get_whoami.py +30 -0
- octostar/utils/notifications/__init__.py +0 -0
- octostar/utils/notifications/delete_stream.py +58 -0
- octostar/utils/notifications/get_my_subscriptions.py +49 -0
- octostar/utils/notifications/publish_notification.py +73 -0
- octostar/utils/notifications/pull_event_from_stream.py +63 -0
- octostar/utils/notifications/pull_events_from_stream.py +64 -0
- octostar/utils/notifications/push_event_to_stream.py +109 -0
- octostar/utils/notifications/push_events_to_stream.py +137 -0
- octostar/utils/notifications/toast.py +92 -0
- octostar/utils/ontology/__init__.py +10 -0
- octostar/utils/ontology/fetch_ontology_data.py +141 -0
- octostar/utils/ontology/get_ontologies.py +55 -0
- octostar/utils/ontology/multiquery_ontology.py +287 -0
- octostar/utils/ontology/query_ontology.py +186 -0
- octostar/utils/pipeline/__init__.py +1 -0
- octostar/utils/pipeline/get_processing_status.py +230 -0
- octostar/utils/pipeline/update_processing_status.py +286 -0
- octostar/utils/search/__init__.py +11 -0
- octostar/utils/search/bulk_update.py +138 -0
- octostar/utils/search/count.py +117 -0
- octostar/utils/search/get_entity_annotations.py +304 -0
- octostar/utils/search/get_index_definition.py +111 -0
- octostar/utils/search/multi_search.py +129 -0
- octostar/utils/workspace/__init__.py +0 -0
- octostar/utils/workspace/delete_entities.py +247 -0
- octostar/utils/workspace/delete_entity.py +81 -0
- octostar/utils/workspace/delete_relationship.py +78 -0
- octostar/utils/workspace/delete_relationships.py +85 -0
- octostar/utils/workspace/delete_temporary_blob.py +85 -0
- octostar/utils/workspace/extract_entities.py +140 -0
- octostar/utils/workspace/get_filepath_from_item.py +85 -0
- octostar/utils/workspace/get_filepaths_from_items.py +100 -0
- octostar/utils/workspace/get_files_tree.py +102 -0
- octostar/utils/workspace/get_item_from_filepath.py +102 -0
- octostar/utils/workspace/get_items_from_filepaths.py +108 -0
- octostar/utils/workspace/linkcharts/__init__.py +0 -0
- octostar/utils/workspace/linkcharts/create_linkchart.py +241 -0
- octostar/utils/workspace/permissions/PermissionLevel.py +8 -0
- octostar/utils/workspace/permissions/__init__.py +1 -0
- octostar/utils/workspace/permissions/get_permissions.py +81 -0
- octostar/utils/workspace/read_attachment.py +284 -0
- octostar/utils/workspace/read_file.py +113 -0
- octostar/utils/workspace/read_temporary_blob.py +428 -0
- octostar/utils/workspace/saved_searches/__init__.py +0 -0
- octostar/utils/workspace/saved_searches/create_saved_search.py +183 -0
- octostar/utils/workspace/tags/__init__.py +0 -0
- octostar/utils/workspace/tags/delete_tag_from_entities.py +96 -0
- octostar/utils/workspace/tags/tag_entities.py +175 -0
- octostar/utils/workspace/upsert_entities.py +268 -0
- octostar/utils/workspace/upsert_entity.py +110 -0
- octostar/utils/workspace/upsert_relationship.py +128 -0
- octostar/utils/workspace/upsert_relationships.py +194 -0
- octostar/utils/workspace/write_attachment.py +263 -0
- octostar/utils/workspace/write_file.py +335 -0
- octostar/utils/workspace/write_temporary_blob.py +218 -0
- octostar_python_client-0.1.759.dist-info/METADATA +159 -0
- octostar_python_client-0.1.759.dist-info/RECORD +257 -0
- octostar_python_client-0.1.759.dist-info/WHEEL +5 -0
- octostar_python_client-0.1.759.dist-info/licenses/LICENSE +21 -0
- octostar_python_client-0.1.759.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import os
|
|
2
|
+
import logging
|
|
3
|
+
from typing import Union
|
|
4
|
+
|
|
5
|
+
_logger = logging.getLogger(__name__)
|
|
6
|
+
|
|
7
|
+
from ...api.notifications import push_event_to_stream
|
|
8
|
+
from ...models.octostar_event import OctostarEvent
|
|
9
|
+
from ...models.octostar_event_octostar_payload import OctostarEventOctostarPayload
|
|
10
|
+
from ...models.octostar_event_octostar_payload_level import (
|
|
11
|
+
OctostarEventOctostarPayloadLevel,
|
|
12
|
+
)
|
|
13
|
+
from ...client import Client
|
|
14
|
+
from ...types import UNSET
|
|
15
|
+
from ..exceptions import ApiConnectionError
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def sync(
|
|
19
|
+
message: str,
|
|
20
|
+
description: Union[str, None] = None,
|
|
21
|
+
level: Union[str, None] = None,
|
|
22
|
+
channel: str = "octostar:desktop:builtins:showToast",
|
|
23
|
+
stream_id: str = os.getenv("OS_JOB_ID") or os.getenv("OS_APP_ID"),
|
|
24
|
+
client: Client = None,
|
|
25
|
+
):
|
|
26
|
+
"""
|
|
27
|
+
# Add Event to Stream
|
|
28
|
+
|
|
29
|
+
Adds a new event to an event stream.
|
|
30
|
+
|
|
31
|
+
## Arguments
|
|
32
|
+
- `message`: The main content to write to the event.
|
|
33
|
+
- `description`: The secondary content to write to the event.
|
|
34
|
+
- `level`: A string detailing the event level. Can be "debug", "error", "info" or "warning".
|
|
35
|
+
- `channel`: The event channel. See OsMessageType for its possible values.
|
|
36
|
+
- `stream_id`: The unique ID for the event stream.
|
|
37
|
+
- `client`: The Client with which to connect to Octostar. If None, the default one is used.
|
|
38
|
+
|
|
39
|
+
## Returns
|
|
40
|
+
`True` if the event was added successfully to the stream.
|
|
41
|
+
|
|
42
|
+
## Raises
|
|
43
|
+
- `ApiConnectionError`: If the request was unsuccessful on the server.
|
|
44
|
+
"""
|
|
45
|
+
response = push_event_to_stream.sync_detailed(
|
|
46
|
+
stream_id=stream_id,
|
|
47
|
+
client=client,
|
|
48
|
+
json_body=OctostarEvent(
|
|
49
|
+
octostar_stream=channel,
|
|
50
|
+
octostar_payload=OctostarEventOctostarPayload(
|
|
51
|
+
message=message,
|
|
52
|
+
description=description if description else UNSET,
|
|
53
|
+
level=OctostarEventOctostarPayloadLevel(level) if level else UNSET,
|
|
54
|
+
),
|
|
55
|
+
),
|
|
56
|
+
)
|
|
57
|
+
if response.status_code not in (200, 201) or (
|
|
58
|
+
"status" in response.parsed.additional_properties
|
|
59
|
+
and response.parsed.additional_properties["status"] != "success"
|
|
60
|
+
):
|
|
61
|
+
raise ApiConnectionError("push_event_from_stream", response, client)
|
|
62
|
+
return True
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
async def asyncio(
|
|
66
|
+
message: str,
|
|
67
|
+
description: Union[str, None] = None,
|
|
68
|
+
level: Union[str, None] = None,
|
|
69
|
+
channel: str = "octostar:desktop:builtins:showToast",
|
|
70
|
+
stream_id: str = os.getenv("OS_JOB_ID") or os.getenv("OS_APP_ID"),
|
|
71
|
+
client: Client = None,
|
|
72
|
+
):
|
|
73
|
+
"""
|
|
74
|
+
# Add Event to Stream Asynchronously
|
|
75
|
+
|
|
76
|
+
Asynchronously adds a new event to an event stream.
|
|
77
|
+
|
|
78
|
+
## Arguments
|
|
79
|
+
- `message`: The main content to write to the event.
|
|
80
|
+
- `description`: The secondary content to write to the event.
|
|
81
|
+
- `level`: A string detailing the event level. Can be "debug", "error", "info" or "warning".
|
|
82
|
+
- `channel`: The event channel. See OsMessageType for its possible values.
|
|
83
|
+
- `stream_id`: The unique ID for the event stream.
|
|
84
|
+
- `client`: The Client with which to connect to Octostar. If None, the default one is used.
|
|
85
|
+
|
|
86
|
+
## Returns
|
|
87
|
+
`True` if the event was added successfully to the stream.
|
|
88
|
+
|
|
89
|
+
## Raises
|
|
90
|
+
- `ApiConnectionError`: If the request was unsuccessful on the server.
|
|
91
|
+
"""
|
|
92
|
+
response = await push_event_to_stream.asyncio_detailed(
|
|
93
|
+
stream_id=stream_id,
|
|
94
|
+
client=client,
|
|
95
|
+
json_body=OctostarEvent(
|
|
96
|
+
octostar_stream=channel,
|
|
97
|
+
octostar_payload=OctostarEventOctostarPayload(
|
|
98
|
+
message=message,
|
|
99
|
+
description=description if description else UNSET,
|
|
100
|
+
level=OctostarEventOctostarPayloadLevel(level) if level else UNSET,
|
|
101
|
+
),
|
|
102
|
+
),
|
|
103
|
+
)
|
|
104
|
+
if response.status_code not in (200, 201) or (
|
|
105
|
+
"status" in response.parsed.additional_properties
|
|
106
|
+
and response.parsed.additional_properties["status"] != "success"
|
|
107
|
+
):
|
|
108
|
+
raise ApiConnectionError("push_event_from_stream", response, client)
|
|
109
|
+
return True
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import os
|
|
2
|
+
import logging
|
|
3
|
+
from typing import TypedDict, List
|
|
4
|
+
|
|
5
|
+
_logger = logging.getLogger(__name__)
|
|
6
|
+
|
|
7
|
+
from ...api.notifications import push_event_to_stream
|
|
8
|
+
from ...models.octostar_event import OctostarEvent
|
|
9
|
+
from ...models.octostar_event_octostar_payload import OctostarEventOctostarPayload
|
|
10
|
+
from ...models.octostar_event_octostar_payload_level import (
|
|
11
|
+
OctostarEventOctostarPayloadLevel,
|
|
12
|
+
)
|
|
13
|
+
from ...client import Client
|
|
14
|
+
from ...types import UNSET
|
|
15
|
+
from ..exceptions import ApiConnectionError
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
class __PushEvent(TypedDict, total=False):
|
|
19
|
+
message: str
|
|
20
|
+
description: str
|
|
21
|
+
level: str
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
def sync(
|
|
25
|
+
events: List[__PushEvent],
|
|
26
|
+
channel: str = "octostar:desktop:builtins:showToast",
|
|
27
|
+
stream_id: str = os.getenv("OS_JOB_ID") or os.getenv("OS_APP_ID"),
|
|
28
|
+
client: Client = None,
|
|
29
|
+
):
|
|
30
|
+
"""
|
|
31
|
+
# Add Multiple Events to Stream
|
|
32
|
+
|
|
33
|
+
Adds N new events to an event stream, in order. Note that, when pulling from a stream,
|
|
34
|
+
events are returned in LIFO order.
|
|
35
|
+
|
|
36
|
+
## Arguments
|
|
37
|
+
- `events`: A list of dictionaries, one per event to add.
|
|
38
|
+
Each dictionary must contain:
|
|
39
|
+
- `message`: The main content to write to the event.
|
|
40
|
+
- `description`: The secondary content to write to the event.
|
|
41
|
+
- `level`: A string detailing the event level. Can be "debug", "error", "info" or "warning".
|
|
42
|
+
- `channel`: The event channel. See OsMessageType for its possible values.
|
|
43
|
+
- `stream_id`: The unique ID for the event stream.
|
|
44
|
+
- `client`: The Client with which to connect to Octostar. If None, the default one is used.
|
|
45
|
+
|
|
46
|
+
## Returns
|
|
47
|
+
The number of events successfully pushed to the stream.
|
|
48
|
+
|
|
49
|
+
## Raises
|
|
50
|
+
- `ApiConnectionError`: If the request was unsuccessful on the server.
|
|
51
|
+
"""
|
|
52
|
+
for i in range(len(events)):
|
|
53
|
+
event = events[i]
|
|
54
|
+
response = push_event_to_stream.sync_detailed(
|
|
55
|
+
stream_id=stream_id,
|
|
56
|
+
client=client,
|
|
57
|
+
json_body=OctostarEvent(
|
|
58
|
+
octostar_channel=channel,
|
|
59
|
+
octostar_payload=OctostarEventOctostarPayload(
|
|
60
|
+
message=event["message"],
|
|
61
|
+
description=(
|
|
62
|
+
UNSET
|
|
63
|
+
if "description" not in event or not event["description"]
|
|
64
|
+
else event["description"]
|
|
65
|
+
),
|
|
66
|
+
level=(
|
|
67
|
+
UNSET
|
|
68
|
+
if "level" not in event or not event["level"]
|
|
69
|
+
else OctostarEventOctostarPayloadLevel(event["level"])
|
|
70
|
+
),
|
|
71
|
+
),
|
|
72
|
+
),
|
|
73
|
+
)
|
|
74
|
+
if response.status_code not in (200, 201) or (
|
|
75
|
+
"status" in response.parsed.additional_properties
|
|
76
|
+
and response.parsed.additional_properties["status"] != "success"
|
|
77
|
+
):
|
|
78
|
+
raise ApiConnectionError("push_events_to_stream", response, client)
|
|
79
|
+
return i
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
async def asyncio(
|
|
83
|
+
events: List[__PushEvent],
|
|
84
|
+
channel: str = "octostar:desktop:builtins:showToast",
|
|
85
|
+
stream_id: str = os.getenv("OS_APP_ID"),
|
|
86
|
+
client: Client = None,
|
|
87
|
+
):
|
|
88
|
+
"""
|
|
89
|
+
# Add Multiple Events to Stream Asynchronously
|
|
90
|
+
|
|
91
|
+
Asynchronously adds N new events to an event stream, in order. Note that, when pulling from a stream,
|
|
92
|
+
events are returned in LIFO order.
|
|
93
|
+
|
|
94
|
+
## Arguments
|
|
95
|
+
- `events`: A list of dictionaries, one per event to add.
|
|
96
|
+
Each dictionary must contain:
|
|
97
|
+
- `message`: The main content to write to the event.
|
|
98
|
+
- `description`: The secondary content to write to the event.
|
|
99
|
+
- `level`: A string detailing the event level. Can be "debug", "error", "info" or "warning".
|
|
100
|
+
- `channel`: The event channel. See OsMessageType for its possible values.
|
|
101
|
+
- `stream_id`: The unique ID for the event stream.
|
|
102
|
+
- `client`: The Client with which to connect to Octostar. If None, the default one is used.
|
|
103
|
+
|
|
104
|
+
## Returns
|
|
105
|
+
The number of events successfully pushed to the stream.
|
|
106
|
+
|
|
107
|
+
## Raises
|
|
108
|
+
- `ApiConnectionError`: If the request was unsuccessful on the server.
|
|
109
|
+
"""
|
|
110
|
+
for i in range(len(events)):
|
|
111
|
+
event = events[i]
|
|
112
|
+
response = await push_event_to_stream.asyncio_detailed(
|
|
113
|
+
stream_id=stream_id,
|
|
114
|
+
client=client,
|
|
115
|
+
json_body=OctostarEvent(
|
|
116
|
+
octostar_channel=channel,
|
|
117
|
+
octostar_payload=OctostarEventOctostarPayload(
|
|
118
|
+
message=event["message"],
|
|
119
|
+
description=(
|
|
120
|
+
UNSET
|
|
121
|
+
if "description" not in event or not event["description"]
|
|
122
|
+
else event["description"]
|
|
123
|
+
),
|
|
124
|
+
level=(
|
|
125
|
+
UNSET
|
|
126
|
+
if "level" not in event or not event["level"]
|
|
127
|
+
else event["level"]
|
|
128
|
+
),
|
|
129
|
+
),
|
|
130
|
+
),
|
|
131
|
+
)
|
|
132
|
+
if response.status_code not in (200, 201) or (
|
|
133
|
+
"status" in response.parsed.additional_properties
|
|
134
|
+
and response.parsed.additional_properties["status"] != "success"
|
|
135
|
+
):
|
|
136
|
+
raise ApiConnectionError("push_events_to_stream", response, client)
|
|
137
|
+
return i
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
from typing import Union
|
|
2
|
+
import logging
|
|
3
|
+
|
|
4
|
+
_logger = logging.getLogger(__name__)
|
|
5
|
+
|
|
6
|
+
from ...api.notifications import toast
|
|
7
|
+
from ...types import UNSET
|
|
8
|
+
from ...client import Client
|
|
9
|
+
from ...models.octostar_event_octostar_payload_level import (
|
|
10
|
+
OctostarEventOctostarPayloadLevel,
|
|
11
|
+
)
|
|
12
|
+
from ..exceptions import ApiConnectionError
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
def sync(
|
|
16
|
+
message: str,
|
|
17
|
+
description: Union[str, None] = None,
|
|
18
|
+
level: Union[str, None] = None,
|
|
19
|
+
client: Client = None,
|
|
20
|
+
):
|
|
21
|
+
"""
|
|
22
|
+
# Send Browser Notification
|
|
23
|
+
|
|
24
|
+
Sends a simple notification to the user in the browser.
|
|
25
|
+
|
|
26
|
+
## Arguments
|
|
27
|
+
- `message`: The main string in the notification.
|
|
28
|
+
- `description`: The secondary string in the notification.
|
|
29
|
+
- `level`: A string detailing the icon to show in the notification. Can be "debug", "error", "info" or "warning".
|
|
30
|
+
- `client`: The Client with which to connect to Octostar. If None, the default one is used.
|
|
31
|
+
|
|
32
|
+
## Returns
|
|
33
|
+
`True` if the operation was successful.
|
|
34
|
+
|
|
35
|
+
## Raises
|
|
36
|
+
- `AttributeError`: If the level string is invalid.
|
|
37
|
+
- `ApiConnectionError`: If the request was unsuccessful on the server.
|
|
38
|
+
"""
|
|
39
|
+
if level and level not in ["debug", "error", "info", "warning"]:
|
|
40
|
+
raise AttributeError("Invalid level!")
|
|
41
|
+
response = toast.sync_detailed(
|
|
42
|
+
message=message,
|
|
43
|
+
description=UNSET if not description else description,
|
|
44
|
+
level=OctostarEventOctostarPayloadLevel(level) if level else UNSET,
|
|
45
|
+
client=client,
|
|
46
|
+
)
|
|
47
|
+
if response.status_code not in (200, 201) or (
|
|
48
|
+
"status" in response.parsed.additional_properties
|
|
49
|
+
and response.parsed.additional_properties["status"] != "success"
|
|
50
|
+
):
|
|
51
|
+
raise ApiConnectionError("toast", response, client)
|
|
52
|
+
return True
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
async def asyncio(
|
|
56
|
+
message: str,
|
|
57
|
+
description: Union[str, None] = None,
|
|
58
|
+
level: Union[str, None] = None,
|
|
59
|
+
client: Client = None,
|
|
60
|
+
):
|
|
61
|
+
"""
|
|
62
|
+
# Send Browser Notification Asynchronously
|
|
63
|
+
|
|
64
|
+
Asynchronously sends a simple notification to the user in the browser.
|
|
65
|
+
|
|
66
|
+
## Arguments
|
|
67
|
+
- `message`: The main string in the notification.
|
|
68
|
+
- `description`: The secondary string in the notification.
|
|
69
|
+
- `level`: A string detailing the icon to show in the notification. Can be "debug", "error", "info" or "warning".
|
|
70
|
+
- `client`: The Client with which to connect to Octostar. If None, the default one is used.
|
|
71
|
+
|
|
72
|
+
## Returns
|
|
73
|
+
`True` if the operation was successful.
|
|
74
|
+
|
|
75
|
+
## Raises
|
|
76
|
+
- `AttributeError`: If the level string is invalid.
|
|
77
|
+
- `ApiConnectionError`: If the request was unsuccessful on the server.
|
|
78
|
+
"""
|
|
79
|
+
if level and level not in ["debug", "error", "info", "warning"]:
|
|
80
|
+
raise AttributeError("Invalid level!")
|
|
81
|
+
response = await toast.asyncio_detailed(
|
|
82
|
+
message=message,
|
|
83
|
+
description=UNSET if not description else description,
|
|
84
|
+
level=OctostarEventOctostarPayloadLevel(level) if level else UNSET,
|
|
85
|
+
client=client,
|
|
86
|
+
)
|
|
87
|
+
if response.status_code not in (200, 201) or (
|
|
88
|
+
"status" in response.parsed.additional_properties
|
|
89
|
+
and response.parsed.additional_properties["status"] != "success"
|
|
90
|
+
):
|
|
91
|
+
raise ApiConnectionError("toast", response, client)
|
|
92
|
+
return True
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"""
|
|
2
|
+
# General SQL queries on one ontology
|
|
3
|
+
Use this to query your ontology for entities or data. The syntax is based on timbr/SQL. For more information, see the "fusion centre" documentation.
|
|
4
|
+
|
|
5
|
+
Example of a query:
|
|
6
|
+
```sql
|
|
7
|
+
SELECT * FROM os_thing WHERE os_workspace = 'my_workspace';
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
"""
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
from typing import Optional
|
|
2
|
+
import logging
|
|
3
|
+
|
|
4
|
+
_logger = logging.getLogger(__name__)
|
|
5
|
+
|
|
6
|
+
from ...api.ontology import fetch_ontology_data
|
|
7
|
+
from ...client import Client, get_default_client
|
|
8
|
+
from ..exceptions import ApiConnectionError
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
def _align_ontology(ontology):
|
|
12
|
+
"""Convert the optimized API format into the established SDK format.
|
|
13
|
+
|
|
14
|
+
The API now returns an optimized structure with three top-level dicts
|
|
15
|
+
(concepts, relationships, properties). SDK consumers expect the legacy
|
|
16
|
+
shape with:
|
|
17
|
+
- concepts keyed by name, each with parents (self at [0]),
|
|
18
|
+
primaryKeys, labelKeys, inheritanceLevel, allProperties (list of
|
|
19
|
+
dicts), properties (direct-only list of dicts), tags, relationships
|
|
20
|
+
- relationships as a flat list of dicts
|
|
21
|
+
"""
|
|
22
|
+
opt_properties = ontology.get("properties", {})
|
|
23
|
+
|
|
24
|
+
# ── Convert concepts ──────────────────────────────────────────────────
|
|
25
|
+
for concept_name, concept_dict in ontology.get("concepts", {}).items():
|
|
26
|
+
# parents: insert self at index 0 (legacy SDK convention)
|
|
27
|
+
concept_dict["parents"].insert(0, concept_name)
|
|
28
|
+
|
|
29
|
+
# Rename / synthesise legacy fields
|
|
30
|
+
concept_dict["labelKeys"] = concept_dict.get("label_keys", [])
|
|
31
|
+
concept_dict["inheritanceLevel"] = concept_dict.get("inheritance_level", 0)
|
|
32
|
+
|
|
33
|
+
# allProperties: full inherited list as dicts
|
|
34
|
+
concept_dict["allProperties"] = [
|
|
35
|
+
{
|
|
36
|
+
"property_name": pname,
|
|
37
|
+
"property_type": opt_properties[pname]["property_type"],
|
|
38
|
+
}
|
|
39
|
+
for pname in concept_dict.get("properties", [])
|
|
40
|
+
if pname in opt_properties
|
|
41
|
+
]
|
|
42
|
+
|
|
43
|
+
# properties: direct-only as dicts
|
|
44
|
+
concept_dict["properties"] = [
|
|
45
|
+
{
|
|
46
|
+
"property_name": pname,
|
|
47
|
+
"property_type": opt_properties[pname]["property_type"],
|
|
48
|
+
}
|
|
49
|
+
for pname in concept_dict.get("direct_properties", [])
|
|
50
|
+
if pname in opt_properties
|
|
51
|
+
]
|
|
52
|
+
|
|
53
|
+
# ── Convert relationships dict → flat list ────────
|
|
54
|
+
relationships_list = []
|
|
55
|
+
for rname, rdata in ontology.get("relationships", {}).items():
|
|
56
|
+
relationships_list.append(
|
|
57
|
+
{
|
|
58
|
+
"relationship_name": rname,
|
|
59
|
+
"is_mtm": rdata.get("is_mtm", False),
|
|
60
|
+
"concept": rdata.get("source_concept", ""),
|
|
61
|
+
"source_concept": rdata.get("source_concept", ""),
|
|
62
|
+
"target_concept": rdata.get("target_concept", ""),
|
|
63
|
+
"source_properties": ",".join(rdata.get("source_properties", [])),
|
|
64
|
+
"target_properties": ",".join(rdata.get("target_properties", [])),
|
|
65
|
+
"inverse_name": rdata.get("inverse_name"),
|
|
66
|
+
"inverse": rdata.get("is_inverse", False),
|
|
67
|
+
}
|
|
68
|
+
)
|
|
69
|
+
ontology["relationships"] = relationships_list
|
|
70
|
+
|
|
71
|
+
return ontology
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
def sync(ontology_name: Optional[str] = None, client: Optional[Client] = None):
|
|
75
|
+
"""
|
|
76
|
+
# Query Ontology Structure
|
|
77
|
+
|
|
78
|
+
Retrieves the structure of an ontology.
|
|
79
|
+
|
|
80
|
+
## Arguments
|
|
81
|
+
- `ontology_name`: The name of the ontology.
|
|
82
|
+
- `client`: The Client with which to connect to Octostar. If None, the default one is used.
|
|
83
|
+
|
|
84
|
+
## Returns
|
|
85
|
+
A dictionary containing a list of concepts and a list of relationships.
|
|
86
|
+
Each of these entries is in itself a dictionary.
|
|
87
|
+
|
|
88
|
+
## Raises
|
|
89
|
+
- `NotImplementedError`: If the operation is not supported for the ontology.
|
|
90
|
+
- `ApiConnectionError`: If the query was unsuccessful.
|
|
91
|
+
"""
|
|
92
|
+
if not client:
|
|
93
|
+
client = get_default_client()
|
|
94
|
+
if not ontology_name:
|
|
95
|
+
ontology_name = client.ontology
|
|
96
|
+
if ontology_name != client.ontology:
|
|
97
|
+
raise NotImplementedError(
|
|
98
|
+
"Only the client ontology is currently supported for this method!"
|
|
99
|
+
)
|
|
100
|
+
response = fetch_ontology_data.sync_detailed(client=client)
|
|
101
|
+
if response.status_code != 200:
|
|
102
|
+
raise ApiConnectionError("fetch_ontology_data", response, client)
|
|
103
|
+
if response.parsed is None:
|
|
104
|
+
raise ApiConnectionError("fetch_ontology_data", response, client)
|
|
105
|
+
ontology = response.parsed.additional_properties
|
|
106
|
+
return _align_ontology(ontology)
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
async def asyncio(ontology_name: Optional[str] = None, client: Optional[Client] = None):
|
|
110
|
+
"""
|
|
111
|
+
# Query Ontology Structure Asynchronously
|
|
112
|
+
|
|
113
|
+
Asynchronously retrieves the structure of an ontology.
|
|
114
|
+
|
|
115
|
+
## Arguments
|
|
116
|
+
- `ontology_name`: The name of the ontology.
|
|
117
|
+
- `client`: The Client with which to connect to Octostar. If None, the default one is used.
|
|
118
|
+
|
|
119
|
+
## Returns
|
|
120
|
+
A dictionary containing a list of concepts and a list of relationships.
|
|
121
|
+
Each of these entries is in itself a dictionary.
|
|
122
|
+
|
|
123
|
+
## Raises
|
|
124
|
+
- `NotImplementedError`: If the operation is not supported for the ontology.
|
|
125
|
+
- `ApiConnectionError`: If the query was unsuccessful.
|
|
126
|
+
"""
|
|
127
|
+
if not client:
|
|
128
|
+
client = get_default_client()
|
|
129
|
+
if not ontology_name:
|
|
130
|
+
ontology_name = client.ontology
|
|
131
|
+
if ontology_name != client.ontology:
|
|
132
|
+
raise NotImplementedError(
|
|
133
|
+
"Only the active ontology is currently supported for this method!"
|
|
134
|
+
)
|
|
135
|
+
response = await fetch_ontology_data.asyncio_detailed(client=client)
|
|
136
|
+
if response.status_code != 200:
|
|
137
|
+
raise ApiConnectionError("fetch_ontology_data", response, client)
|
|
138
|
+
if response.parsed is None:
|
|
139
|
+
raise ApiConnectionError("fetch_ontology_data", response, client)
|
|
140
|
+
ontology = response.parsed.additional_properties
|
|
141
|
+
return _align_ontology(ontology)
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import logging
|
|
2
|
+
|
|
3
|
+
_logger = logging.getLogger(__name__)
|
|
4
|
+
|
|
5
|
+
from ...api.ontology import get_ontologies
|
|
6
|
+
from ...client import Client
|
|
7
|
+
from ..exceptions import ApiConnectionError
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def sync(client: Client = None):
|
|
11
|
+
"""
|
|
12
|
+
# Query Ontology List
|
|
13
|
+
|
|
14
|
+
Retrieves the list of ontologies.
|
|
15
|
+
|
|
16
|
+
## Arguments
|
|
17
|
+
- `client`: The Client with which to connect to Octostar. If None, the default one is used.
|
|
18
|
+
|
|
19
|
+
## Returns
|
|
20
|
+
A list of strings, the names of the ontologies.
|
|
21
|
+
|
|
22
|
+
## Raises
|
|
23
|
+
- `ApiConnectionError`: If the query was unsuccessful.
|
|
24
|
+
"""
|
|
25
|
+
response = get_ontologies.sync_detailed(client=client)
|
|
26
|
+
if response.status_code != 200:
|
|
27
|
+
raise ApiConnectionError("get_ontologies", response, client)
|
|
28
|
+
content = response.parsed
|
|
29
|
+
if "status" in content and content["status"] != "success":
|
|
30
|
+
raise ApiConnectionError("get_ontologies", response, client)
|
|
31
|
+
return response.parsed["data"]
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
async def asyncio(client: Client = None):
|
|
35
|
+
"""
|
|
36
|
+
# Query Ontology List Asynchronously
|
|
37
|
+
|
|
38
|
+
Asynchronously retrieves the list of ontologies.
|
|
39
|
+
|
|
40
|
+
## Arguments
|
|
41
|
+
- `client`: The Client with which to connect to Octostar. If None, the default one is used.
|
|
42
|
+
|
|
43
|
+
## Returns
|
|
44
|
+
A list of strings, the names of the ontologies.
|
|
45
|
+
|
|
46
|
+
## Raises
|
|
47
|
+
- `ApiConnectionError`: If the query was unsuccessful.
|
|
48
|
+
"""
|
|
49
|
+
response = await get_ontologies.asyncio_detailed(client=client)
|
|
50
|
+
if response.status_code != 200:
|
|
51
|
+
raise ApiConnectionError("get_ontologies", response, client)
|
|
52
|
+
content = response.parsed
|
|
53
|
+
if "status" in content and content["status"] != "success":
|
|
54
|
+
raise ApiConnectionError("get_ontologies", response, client)
|
|
55
|
+
return response.parsed["data"]
|