uipath 2.0.0.dev3__py3-none-any.whl → 2.0.1.dev1__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.
Potentially problematic release.
This version of uipath might be problematic. Click here for more details.
- uipath/__init__.py +24 -0
- uipath/_cli/README.md +11 -0
- uipath/_cli/__init__.py +54 -0
- uipath/_cli/_auth/_auth_server.py +165 -0
- uipath/_cli/_auth/_models.py +51 -0
- uipath/_cli/_auth/_oidc_utils.py +69 -0
- uipath/_cli/_auth/_portal_service.py +163 -0
- uipath/_cli/_auth/_utils.py +51 -0
- uipath/_cli/_auth/auth_config.json +6 -0
- uipath/_cli/_auth/index.html +167 -0
- uipath/_cli/_auth/localhost.crt +25 -0
- uipath/_cli/_auth/localhost.key +27 -0
- uipath/_cli/_runtime/_contracts.py +429 -0
- uipath/_cli/_runtime/_logging.py +193 -0
- uipath/_cli/_runtime/_runtime.py +264 -0
- uipath/_cli/_templates/.psmdcp.template +9 -0
- uipath/_cli/_templates/.rels.template +5 -0
- uipath/_cli/_templates/[Content_Types].xml.template +9 -0
- uipath/_cli/_templates/main.py.template +25 -0
- uipath/_cli/_templates/package.nuspec.template +10 -0
- uipath/_cli/_utils/_common.py +24 -0
- uipath/_cli/_utils/_input_args.py +126 -0
- uipath/_cli/_utils/_parse_ast.py +542 -0
- uipath/_cli/cli_auth.py +97 -0
- uipath/_cli/cli_deploy.py +13 -0
- uipath/_cli/cli_init.py +113 -0
- uipath/_cli/cli_new.py +76 -0
- uipath/_cli/cli_pack.py +337 -0
- uipath/_cli/cli_publish.py +113 -0
- uipath/_cli/cli_run.py +133 -0
- uipath/_cli/middlewares.py +113 -0
- uipath/_config.py +6 -0
- uipath/_execution_context.py +83 -0
- uipath/_folder_context.py +62 -0
- uipath/_models/__init__.py +37 -0
- uipath/_models/action_schema.py +26 -0
- uipath/_models/actions.py +64 -0
- uipath/_models/assets.py +48 -0
- uipath/_models/connections.py +51 -0
- uipath/_models/context_grounding.py +18 -0
- uipath/_models/context_grounding_index.py +60 -0
- uipath/_models/exceptions.py +6 -0
- uipath/_models/interrupt_models.py +28 -0
- uipath/_models/job.py +66 -0
- uipath/_models/llm_gateway.py +101 -0
- uipath/_models/processes.py +48 -0
- uipath/_models/queues.py +167 -0
- uipath/_services/__init__.py +26 -0
- uipath/_services/_base_service.py +250 -0
- uipath/_services/actions_service.py +271 -0
- uipath/_services/api_client.py +89 -0
- uipath/_services/assets_service.py +257 -0
- uipath/_services/buckets_service.py +268 -0
- uipath/_services/connections_service.py +185 -0
- uipath/_services/connections_service.pyi +50 -0
- uipath/_services/context_grounding_service.py +402 -0
- uipath/_services/folder_service.py +49 -0
- uipath/_services/jobs_service.py +265 -0
- uipath/_services/llm_gateway_service.py +311 -0
- uipath/_services/processes_service.py +168 -0
- uipath/_services/queues_service.py +314 -0
- uipath/_uipath.py +98 -0
- uipath/_utils/__init__.py +17 -0
- uipath/_utils/_endpoint.py +79 -0
- uipath/_utils/_infer_bindings.py +30 -0
- uipath/_utils/_logs.py +15 -0
- uipath/_utils/_request_override.py +18 -0
- uipath/_utils/_request_spec.py +23 -0
- uipath/_utils/_user_agent.py +16 -0
- uipath/_utils/constants.py +25 -0
- uipath/py.typed +0 -0
- {uipath-2.0.0.dev3.dist-info → uipath-2.0.1.dev1.dist-info}/METADATA +2 -3
- uipath-2.0.1.dev1.dist-info/RECORD +75 -0
- uipath-2.0.0.dev3.dist-info/RECORD +0 -4
- {uipath-2.0.0.dev3.dist-info → uipath-2.0.1.dev1.dist-info}/WHEEL +0 -0
- {uipath-2.0.0.dev3.dist-info → uipath-2.0.1.dev1.dist-info}/entry_points.txt +0 -0
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
# This file is generated by the build system. Do not edit it directly.
|
|
2
|
+
from typing import TYPE_CHECKING, Any, Protocol, TypeVar
|
|
3
|
+
|
|
4
|
+
from .._config import Config as Config
|
|
5
|
+
from .._execution_context import ExecutionContext as ExecutionContext
|
|
6
|
+
from .._models import Connection as Connection
|
|
7
|
+
from .._models import ConnectionToken as ConnectionToken
|
|
8
|
+
from .._utils import Endpoint as Endpoint
|
|
9
|
+
from .._utils import RequestSpec as RequestSpec
|
|
10
|
+
from .._utils.constants import ENTRYPOINT as ENTRYPOINT
|
|
11
|
+
from ._base_service import BaseService as BaseService
|
|
12
|
+
|
|
13
|
+
if TYPE_CHECKING:
|
|
14
|
+
from uipath_connectors.atlassian_jira import AtlassianJira # type: ignore
|
|
15
|
+
from uipath_connectors.box_box import BoxBox # type: ignore
|
|
16
|
+
from uipath_connectors.google_drive import GoogleDrive # type: ignore
|
|
17
|
+
from uipath_connectors.google_gmail import GoogleGmail # type: ignore
|
|
18
|
+
from uipath_connectors.google_sheets import GoogleSheets # type: ignore
|
|
19
|
+
from uipath_connectors.microsoft_github import MicrosoftGithub # type: ignore
|
|
20
|
+
from uipath_connectors.microsoft_onedrive import MicrosoftOneDrive # type: ignore
|
|
21
|
+
from uipath_connectors.oracle_netsuite import OracleNetsuite # type: ignore
|
|
22
|
+
from uipath_connectors.salesforce_sfdc import SalesforceSfdc # type: ignore
|
|
23
|
+
from uipath_connectors.salesforce_slack import SalesforceSlack # type: ignore
|
|
24
|
+
from uipath_connectors.uipath_airdk import UipathAirdk # type: ignore
|
|
25
|
+
|
|
26
|
+
T_co = TypeVar("T_co", covariant=True)
|
|
27
|
+
|
|
28
|
+
class Connector(Protocol[T_co]):
|
|
29
|
+
def __call__(self, *, client: Any, instance_id: str | int) -> T_co: ...
|
|
30
|
+
|
|
31
|
+
class ConnectionsService(BaseService):
|
|
32
|
+
def __init__(self, config: Config, execution_context: ExecutionContext) -> None: ...
|
|
33
|
+
def __call__(self, connector: Connector[T_co], key: str) -> T_co: ...
|
|
34
|
+
def __getattr__(self, name: str) -> Any: ...
|
|
35
|
+
def retrieve(self, key: str) -> Connection: ...
|
|
36
|
+
async def retrieve_async(self, key: str) -> Connection: ...
|
|
37
|
+
def retrieve_token(self, key: str) -> ConnectionToken: ...
|
|
38
|
+
async def retrieve_token_async(self, key: str) -> ConnectionToken: ...
|
|
39
|
+
|
|
40
|
+
atlassian_jira: "AtlassianJira"
|
|
41
|
+
box_box: "BoxBox"
|
|
42
|
+
google_drive: "GoogleDrive"
|
|
43
|
+
google_gmail: "GoogleGmail"
|
|
44
|
+
google_sheets: "GoogleSheets"
|
|
45
|
+
microsoft_github: "MicrosoftGithub"
|
|
46
|
+
microsoft_onedrive: "MicrosoftOneDrive"
|
|
47
|
+
oracle_netsuite: "OracleNetsuite"
|
|
48
|
+
salesforce_sfdc: "SalesforceSfdc"
|
|
49
|
+
salesforce_slack: "SalesforceSlack"
|
|
50
|
+
uipath_airdk: "UipathAirdk"
|
|
@@ -0,0 +1,402 @@
|
|
|
1
|
+
import json
|
|
2
|
+
from typing import Any, Dict, List, Optional
|
|
3
|
+
|
|
4
|
+
from pydantic import TypeAdapter
|
|
5
|
+
|
|
6
|
+
from .._config import Config
|
|
7
|
+
from .._execution_context import ExecutionContext
|
|
8
|
+
from .._folder_context import FolderContext
|
|
9
|
+
from .._models import IngestionInProgressException
|
|
10
|
+
from .._models.context_grounding import ContextGroundingQueryResponse
|
|
11
|
+
from .._models.context_grounding_index import ContextGroundingIndex
|
|
12
|
+
from .._utils import Endpoint, RequestSpec
|
|
13
|
+
from .._utils.constants import (
|
|
14
|
+
HEADER_FOLDER_KEY,
|
|
15
|
+
ORCHESTRATOR_STORAGE_BUCKET_DATA_SOURCE,
|
|
16
|
+
)
|
|
17
|
+
from ._base_service import BaseService
|
|
18
|
+
from .folder_service import FolderService
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
class ContextGroundingService(FolderContext, BaseService):
|
|
22
|
+
"""Service for managing semantic automation contexts in UiPath.
|
|
23
|
+
|
|
24
|
+
Context Grounding is a feature that helps in understanding and managing the
|
|
25
|
+
semantic context in which automation processes operate. It provides capabilities
|
|
26
|
+
for indexing, retrieving, and searching through contextual information that
|
|
27
|
+
can be used to enhance AI-enabled automation.
|
|
28
|
+
|
|
29
|
+
This service requires a valid folder key to be set in the environment, as
|
|
30
|
+
context grounding operations are always performed within a specific folder
|
|
31
|
+
context.
|
|
32
|
+
"""
|
|
33
|
+
|
|
34
|
+
def __init__(
|
|
35
|
+
self,
|
|
36
|
+
config: Config,
|
|
37
|
+
execution_context: ExecutionContext,
|
|
38
|
+
folders_service: FolderService,
|
|
39
|
+
) -> None:
|
|
40
|
+
self._folders_service = folders_service
|
|
41
|
+
super().__init__(config=config, execution_context=execution_context)
|
|
42
|
+
|
|
43
|
+
def retrieve(self, name: str) -> Optional[ContextGroundingIndex]:
|
|
44
|
+
"""Retrieve context grounding index information by its name.
|
|
45
|
+
|
|
46
|
+
This method fetches details about a specific context index, which can be
|
|
47
|
+
used to understand what type of contextual information is available for
|
|
48
|
+
automation processes.
|
|
49
|
+
|
|
50
|
+
Args:
|
|
51
|
+
name (str): The name of the context index to retrieve.
|
|
52
|
+
|
|
53
|
+
Returns:
|
|
54
|
+
Optional[ContextGroundingIndex]: The index information, including its configuration and metadata if found, otherwise None.
|
|
55
|
+
"""
|
|
56
|
+
spec = self._retrieve_spec(name)
|
|
57
|
+
|
|
58
|
+
response = self.request(
|
|
59
|
+
spec.method,
|
|
60
|
+
spec.endpoint,
|
|
61
|
+
params=spec.params,
|
|
62
|
+
).json()
|
|
63
|
+
return next(
|
|
64
|
+
(
|
|
65
|
+
ContextGroundingIndex.model_validate(item)
|
|
66
|
+
for item in response["value"]
|
|
67
|
+
if item["name"] == name
|
|
68
|
+
),
|
|
69
|
+
None,
|
|
70
|
+
)
|
|
71
|
+
|
|
72
|
+
async def retrieve_async(self, name: str) -> Optional[ContextGroundingIndex]:
|
|
73
|
+
"""Retrieve asynchronously context grounding index information by its name.
|
|
74
|
+
|
|
75
|
+
This method fetches details about a specific context index, which can be
|
|
76
|
+
used to understand what type of contextual information is available for
|
|
77
|
+
automation processes.
|
|
78
|
+
|
|
79
|
+
Args:
|
|
80
|
+
name (str): The name of the context index to retrieve.
|
|
81
|
+
|
|
82
|
+
Returns:
|
|
83
|
+
Optional[ContextGroundingIndex]: The index information, including its configuration and metadata if found, otherwise None.
|
|
84
|
+
|
|
85
|
+
"""
|
|
86
|
+
spec = self._retrieve_spec(name)
|
|
87
|
+
|
|
88
|
+
response = (
|
|
89
|
+
await self.request_async(
|
|
90
|
+
spec.method,
|
|
91
|
+
spec.endpoint,
|
|
92
|
+
params=spec.params,
|
|
93
|
+
)
|
|
94
|
+
).json()
|
|
95
|
+
return next(
|
|
96
|
+
(
|
|
97
|
+
ContextGroundingIndex.model_validate(item)
|
|
98
|
+
for item in response["value"]
|
|
99
|
+
if item["name"] == name
|
|
100
|
+
),
|
|
101
|
+
None,
|
|
102
|
+
)
|
|
103
|
+
|
|
104
|
+
def retrieve_by_id(self, id: str) -> Any:
|
|
105
|
+
"""Retrieve context grounding index information by its ID.
|
|
106
|
+
|
|
107
|
+
This method provides direct access to a context index using its unique
|
|
108
|
+
identifier, which can be more efficient than searching by name.
|
|
109
|
+
|
|
110
|
+
Args:
|
|
111
|
+
id (str): The unique identifier of the context index.
|
|
112
|
+
|
|
113
|
+
Returns:
|
|
114
|
+
Any: The index information, including its configuration and metadata.
|
|
115
|
+
"""
|
|
116
|
+
spec = self._retrieve_by_id_spec(id)
|
|
117
|
+
|
|
118
|
+
return self.request(
|
|
119
|
+
spec.method,
|
|
120
|
+
spec.endpoint,
|
|
121
|
+
params=spec.params,
|
|
122
|
+
).json()
|
|
123
|
+
|
|
124
|
+
async def retrieve_by_id_async(self, id: str) -> Any:
|
|
125
|
+
"""Retrieve asynchronously context grounding index information by its ID.
|
|
126
|
+
|
|
127
|
+
This method provides direct access to a context index using its unique
|
|
128
|
+
identifier, which can be more efficient than searching by name.
|
|
129
|
+
|
|
130
|
+
Args:
|
|
131
|
+
id (str): The unique identifier of the context index.
|
|
132
|
+
|
|
133
|
+
Returns:
|
|
134
|
+
Any: The index information, including its configuration and metadata.
|
|
135
|
+
|
|
136
|
+
"""
|
|
137
|
+
spec = self._retrieve_by_id_spec(id)
|
|
138
|
+
|
|
139
|
+
response = await self.request_async(
|
|
140
|
+
spec.method,
|
|
141
|
+
spec.endpoint,
|
|
142
|
+
params=spec.params,
|
|
143
|
+
)
|
|
144
|
+
|
|
145
|
+
return response.json()
|
|
146
|
+
|
|
147
|
+
def search(
|
|
148
|
+
self,
|
|
149
|
+
name: str,
|
|
150
|
+
query: str,
|
|
151
|
+
number_of_results: int = 10,
|
|
152
|
+
) -> List[ContextGroundingQueryResponse]:
|
|
153
|
+
"""Search for contextual information within a specific index.
|
|
154
|
+
|
|
155
|
+
This method performs a semantic search against the specified context index,
|
|
156
|
+
helping to find relevant information that can be used in automation processes.
|
|
157
|
+
The search is powered by AI and understands natural language queries.
|
|
158
|
+
|
|
159
|
+
Args:
|
|
160
|
+
name (str): The name of the context index to search in.
|
|
161
|
+
query (str): The search query in natural language.
|
|
162
|
+
number_of_results (int, optional): Maximum number of results to return.
|
|
163
|
+
Defaults to 10.
|
|
164
|
+
|
|
165
|
+
Returns:
|
|
166
|
+
List[ContextGroundingQueryResponse]: A list of search results, each containing
|
|
167
|
+
relevant contextual information and metadata.
|
|
168
|
+
"""
|
|
169
|
+
index = self.retrieve(name)
|
|
170
|
+
if index and index.in_progress_ingestion():
|
|
171
|
+
raise IngestionInProgressException(index_name=name)
|
|
172
|
+
|
|
173
|
+
spec = self._search_spec(name, query, number_of_results)
|
|
174
|
+
|
|
175
|
+
response = self.request(
|
|
176
|
+
spec.method,
|
|
177
|
+
spec.endpoint,
|
|
178
|
+
content=spec.content,
|
|
179
|
+
)
|
|
180
|
+
|
|
181
|
+
return TypeAdapter(List[ContextGroundingQueryResponse]).validate_python(
|
|
182
|
+
response.json()
|
|
183
|
+
)
|
|
184
|
+
|
|
185
|
+
async def search_async(
|
|
186
|
+
self,
|
|
187
|
+
name: str,
|
|
188
|
+
query: str,
|
|
189
|
+
number_of_results: int = 10,
|
|
190
|
+
) -> List[ContextGroundingQueryResponse]:
|
|
191
|
+
"""Search asynchronously for contextual information within a specific index.
|
|
192
|
+
|
|
193
|
+
This method performs a semantic search against the specified context index,
|
|
194
|
+
helping to find relevant information that can be used in automation processes.
|
|
195
|
+
The search is powered by AI and understands natural language queries.
|
|
196
|
+
|
|
197
|
+
Args:
|
|
198
|
+
name (str): The name of the context index to search in.
|
|
199
|
+
query (str): The search query in natural language.
|
|
200
|
+
number_of_results (int, optional): Maximum number of results to return.
|
|
201
|
+
Defaults to 10.
|
|
202
|
+
|
|
203
|
+
Returns:
|
|
204
|
+
List[ContextGroundingQueryResponse]: A list of search results, each containing
|
|
205
|
+
relevant contextual information and metadata.
|
|
206
|
+
"""
|
|
207
|
+
index = self.retrieve(name)
|
|
208
|
+
if index and index.in_progress_ingestion():
|
|
209
|
+
raise IngestionInProgressException(index_name=name)
|
|
210
|
+
spec = self._search_spec(name, query, number_of_results)
|
|
211
|
+
|
|
212
|
+
response = await self.request_async(
|
|
213
|
+
spec.method,
|
|
214
|
+
spec.endpoint,
|
|
215
|
+
content=spec.content,
|
|
216
|
+
)
|
|
217
|
+
|
|
218
|
+
return TypeAdapter(List[ContextGroundingQueryResponse]).validate_python(
|
|
219
|
+
response.json()
|
|
220
|
+
)
|
|
221
|
+
|
|
222
|
+
def get_or_create_index(
|
|
223
|
+
self,
|
|
224
|
+
name: str,
|
|
225
|
+
*,
|
|
226
|
+
description: Optional[str] = None,
|
|
227
|
+
storage_bucket_name: str,
|
|
228
|
+
file_name_glob: Optional[str] = None,
|
|
229
|
+
storage_bucket_folder_path: Optional[str] = None,
|
|
230
|
+
) -> ContextGroundingIndex:
|
|
231
|
+
spec = self._create_spec(
|
|
232
|
+
name,
|
|
233
|
+
description,
|
|
234
|
+
storage_bucket_name,
|
|
235
|
+
file_name_glob,
|
|
236
|
+
storage_bucket_folder_path,
|
|
237
|
+
)
|
|
238
|
+
index = self.retrieve(name=name)
|
|
239
|
+
if index:
|
|
240
|
+
return index
|
|
241
|
+
|
|
242
|
+
response = self.request(
|
|
243
|
+
spec.method,
|
|
244
|
+
spec.endpoint,
|
|
245
|
+
content=spec.content,
|
|
246
|
+
headers=spec.headers,
|
|
247
|
+
).json()
|
|
248
|
+
return ContextGroundingIndex.model_validate(response)
|
|
249
|
+
|
|
250
|
+
async def get_or_create_index_async(
|
|
251
|
+
self,
|
|
252
|
+
name: str,
|
|
253
|
+
*,
|
|
254
|
+
description: Optional[str] = None,
|
|
255
|
+
storage_bucket_name: str,
|
|
256
|
+
file_name_glob: Optional[str] = None,
|
|
257
|
+
storage_bucket_folder_path: Optional[str] = None,
|
|
258
|
+
) -> ContextGroundingIndex:
|
|
259
|
+
index = await self.retrieve_async(name=name)
|
|
260
|
+
if index:
|
|
261
|
+
return index
|
|
262
|
+
|
|
263
|
+
spec = self._create_spec(
|
|
264
|
+
name,
|
|
265
|
+
description,
|
|
266
|
+
storage_bucket_name,
|
|
267
|
+
file_name_glob,
|
|
268
|
+
storage_bucket_folder_path,
|
|
269
|
+
)
|
|
270
|
+
response = (
|
|
271
|
+
await self.request_async(
|
|
272
|
+
spec.method,
|
|
273
|
+
spec.endpoint,
|
|
274
|
+
content=spec.content,
|
|
275
|
+
headers=spec.headers,
|
|
276
|
+
)
|
|
277
|
+
).json()
|
|
278
|
+
return ContextGroundingIndex.model_validate(response)
|
|
279
|
+
|
|
280
|
+
def ingest_data(self, index: ContextGroundingIndex) -> None:
|
|
281
|
+
if not index.id:
|
|
282
|
+
return
|
|
283
|
+
spec = self._ingest_spec(index.id)
|
|
284
|
+
self.request(
|
|
285
|
+
spec.method,
|
|
286
|
+
spec.endpoint,
|
|
287
|
+
headers=spec.headers,
|
|
288
|
+
)
|
|
289
|
+
|
|
290
|
+
async def ingest_data_async(self, index: ContextGroundingIndex) -> None:
|
|
291
|
+
if not index.id:
|
|
292
|
+
return
|
|
293
|
+
spec = self._ingest_spec(index.id)
|
|
294
|
+
await self.request_async(
|
|
295
|
+
spec.method,
|
|
296
|
+
spec.endpoint,
|
|
297
|
+
headers=spec.headers,
|
|
298
|
+
)
|
|
299
|
+
|
|
300
|
+
def delete_index(self, index: ContextGroundingIndex) -> None:
|
|
301
|
+
if not index.id:
|
|
302
|
+
return
|
|
303
|
+
spec = self._delete_by_id_spec(index.id)
|
|
304
|
+
self.request(
|
|
305
|
+
spec.method,
|
|
306
|
+
spec.endpoint,
|
|
307
|
+
headers=spec.headers,
|
|
308
|
+
)
|
|
309
|
+
|
|
310
|
+
async def delete_index_async(self, index: ContextGroundingIndex) -> None:
|
|
311
|
+
if not index.id:
|
|
312
|
+
return
|
|
313
|
+
spec = self._delete_by_id_spec(index.id)
|
|
314
|
+
await self.request_async(
|
|
315
|
+
spec.method,
|
|
316
|
+
spec.endpoint,
|
|
317
|
+
headers=spec.headers,
|
|
318
|
+
)
|
|
319
|
+
|
|
320
|
+
@property
|
|
321
|
+
def custom_headers(self) -> Dict[str, str]:
|
|
322
|
+
self._folder_key = self._folder_key or (
|
|
323
|
+
self._folders_service.retrieve_key_by_folder_path(self._folder_path)
|
|
324
|
+
if self._folder_path
|
|
325
|
+
else None
|
|
326
|
+
)
|
|
327
|
+
|
|
328
|
+
if self._folder_key is None:
|
|
329
|
+
raise ValueError(f"Folder key is not set ({HEADER_FOLDER_KEY})")
|
|
330
|
+
|
|
331
|
+
return self.folder_headers
|
|
332
|
+
|
|
333
|
+
def _ingest_spec(self, key: str) -> RequestSpec:
|
|
334
|
+
return RequestSpec(
|
|
335
|
+
method="POST", endpoint=Endpoint(f"/ecs_/v2/indexes/{key}/ingest")
|
|
336
|
+
)
|
|
337
|
+
|
|
338
|
+
def _retrieve_spec(self, name: str) -> RequestSpec:
|
|
339
|
+
return RequestSpec(
|
|
340
|
+
method="GET",
|
|
341
|
+
endpoint=Endpoint("/ecs_/v2/indexes"),
|
|
342
|
+
params={"$filter": f"Name eq '{name}'"},
|
|
343
|
+
)
|
|
344
|
+
|
|
345
|
+
def _create_spec(
|
|
346
|
+
self,
|
|
347
|
+
name: str,
|
|
348
|
+
description: Optional[str],
|
|
349
|
+
storage_bucket_name: Optional[str],
|
|
350
|
+
file_name_glob: Optional[str],
|
|
351
|
+
storage_bucket_folder_path: Optional[str],
|
|
352
|
+
) -> RequestSpec:
|
|
353
|
+
storage_bucket_folder_path = (
|
|
354
|
+
storage_bucket_folder_path
|
|
355
|
+
if storage_bucket_folder_path
|
|
356
|
+
else self._folder_path
|
|
357
|
+
)
|
|
358
|
+
return RequestSpec(
|
|
359
|
+
method="POST",
|
|
360
|
+
endpoint=Endpoint("/ecs_/v2/indexes/create"),
|
|
361
|
+
content=json.dumps(
|
|
362
|
+
{
|
|
363
|
+
"name": name,
|
|
364
|
+
"description": description,
|
|
365
|
+
"dataSource": {
|
|
366
|
+
"@odata.type": ORCHESTRATOR_STORAGE_BUCKET_DATA_SOURCE,
|
|
367
|
+
"folder": storage_bucket_folder_path,
|
|
368
|
+
"bucketName": storage_bucket_name,
|
|
369
|
+
"fileNameGlob": file_name_glob
|
|
370
|
+
if file_name_glob is not None
|
|
371
|
+
else "*",
|
|
372
|
+
"directoryPath": "/",
|
|
373
|
+
},
|
|
374
|
+
}
|
|
375
|
+
),
|
|
376
|
+
)
|
|
377
|
+
|
|
378
|
+
def _retrieve_by_id_spec(self, id: str) -> RequestSpec:
|
|
379
|
+
return RequestSpec(
|
|
380
|
+
method="GET",
|
|
381
|
+
endpoint=Endpoint(f"/ecs_/v2/indexes/{id}"),
|
|
382
|
+
)
|
|
383
|
+
|
|
384
|
+
def _delete_by_id_spec(self, id: str) -> RequestSpec:
|
|
385
|
+
return RequestSpec(
|
|
386
|
+
method="DELETE",
|
|
387
|
+
endpoint=Endpoint(f"/ecs_/v2/indexes/{id}"),
|
|
388
|
+
)
|
|
389
|
+
|
|
390
|
+
def _search_spec(
|
|
391
|
+
self, name: str, query: str, number_of_results: int = 10
|
|
392
|
+
) -> RequestSpec:
|
|
393
|
+
return RequestSpec(
|
|
394
|
+
method="POST",
|
|
395
|
+
endpoint=Endpoint("/ecs_/v1/search"),
|
|
396
|
+
content=json.dumps(
|
|
397
|
+
{
|
|
398
|
+
"query": {"query": query, "numberOfResults": number_of_results},
|
|
399
|
+
"schema": {"name": name},
|
|
400
|
+
}
|
|
401
|
+
),
|
|
402
|
+
)
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
from typing import Optional
|
|
2
|
+
|
|
3
|
+
from .._config import Config
|
|
4
|
+
from .._execution_context import ExecutionContext
|
|
5
|
+
from .._utils import Endpoint, RequestSpec
|
|
6
|
+
from ._base_service import BaseService
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
def _retrieve_spec(folder_path: str) -> RequestSpec:
|
|
10
|
+
folder_name = folder_path.split("/")[-1]
|
|
11
|
+
return RequestSpec(
|
|
12
|
+
method="GET",
|
|
13
|
+
endpoint=Endpoint(
|
|
14
|
+
"orchestrator_/api/FoldersNavigation/GetFoldersForCurrentUser"
|
|
15
|
+
),
|
|
16
|
+
params={
|
|
17
|
+
"searchText": folder_name,
|
|
18
|
+
"take": 1,
|
|
19
|
+
},
|
|
20
|
+
)
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
class FolderService(BaseService):
|
|
24
|
+
"""Service for managing UiPath Folders.
|
|
25
|
+
|
|
26
|
+
A folder represents a single area for data organization
|
|
27
|
+
and access control - it is created when you need to categorize, manage, and enforce authorization rules for a group
|
|
28
|
+
of UiPath resources (i.e. processes, assets, connections, storage buckets etc.) or other folders
|
|
29
|
+
"""
|
|
30
|
+
|
|
31
|
+
def __init__(self, config: Config, execution_context: ExecutionContext) -> None:
|
|
32
|
+
super().__init__(config=config, execution_context=execution_context)
|
|
33
|
+
|
|
34
|
+
def retrieve_key_by_folder_path(self, folder_path: str) -> Optional[str]:
|
|
35
|
+
spec = _retrieve_spec(folder_path)
|
|
36
|
+
response = self.request(
|
|
37
|
+
spec.method,
|
|
38
|
+
url=spec.endpoint,
|
|
39
|
+
params=spec.params,
|
|
40
|
+
).json()
|
|
41
|
+
|
|
42
|
+
return next(
|
|
43
|
+
(
|
|
44
|
+
item["Key"]
|
|
45
|
+
for item in response["PageItems"]
|
|
46
|
+
if item["FullyQualifiedName"] == folder_path
|
|
47
|
+
),
|
|
48
|
+
None,
|
|
49
|
+
)
|