Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "uipath"
version = "2.1.64"
version = "2.1.65"
description = "Python SDK and CLI for UiPath Platform, enabling programmatic interaction with automation services, process management, and deployment tools."
readme = { file = "README.md", content-type = "text/markdown" }
requires-python = ">=3.10"
Expand Down
21 changes: 15 additions & 6 deletions src/uipath/_services/connections_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from .._execution_context import ExecutionContext
from .._utils import Endpoint, RequestSpec, infer_bindings
from ..models import Connection, ConnectionToken, EventArguments
from ..models.connections import ConnectionTokenType
from ..tracing._traced import traced
from ._base_service import BaseService

Expand Down Expand Up @@ -71,7 +72,9 @@ async def retrieve_async(self, key: str) -> Connection:
run_type="uipath",
hide_output=True,
)
def retrieve_token(self, key: str) -> ConnectionToken:
def retrieve_token(
self, key: str, token_type: ConnectionTokenType = ConnectionTokenType.DIRECT
) -> ConnectionToken:
"""Retrieve an authentication token for a connection.

This method obtains a fresh authentication token that can be used to
Expand All @@ -80,12 +83,13 @@ def retrieve_token(self, key: str) -> ConnectionToken:

Args:
key (str): The unique identifier of the connection.
token_type (ConnectionTokenType): The token type to use.

Returns:
ConnectionToken: The authentication token details, including the token
value and any associated metadata.
"""
spec = self._retrieve_token_spec(key)
spec = self._retrieve_token_spec(key, token_type)
response = self.request(spec.method, url=spec.endpoint, params=spec.params)
return ConnectionToken.model_validate(response.json())

Expand All @@ -94,7 +98,9 @@ def retrieve_token(self, key: str) -> ConnectionToken:
run_type="uipath",
hide_output=True,
)
async def retrieve_token_async(self, key: str) -> ConnectionToken:
async def retrieve_token_async(
self, key: str, token_type: ConnectionTokenType = ConnectionTokenType.DIRECT
) -> ConnectionToken:
"""Asynchronously retrieve an authentication token for a connection.

This method obtains a fresh authentication token that can be used to
Expand All @@ -103,12 +109,13 @@ async def retrieve_token_async(self, key: str) -> ConnectionToken:

Args:
key (str): The unique identifier of the connection.
token_type (ConnectionTokenType): The token type to use.

Returns:
ConnectionToken: The authentication token details, including the token
value and any associated metadata.
"""
spec = self._retrieve_token_spec(key)
spec = self._retrieve_token_spec(key, token_type)
response = await self.request_async(
spec.method, url=spec.endpoint, params=spec.params
)
Expand Down Expand Up @@ -198,9 +205,11 @@ def _retrieve_spec(self, key: str) -> RequestSpec:
endpoint=Endpoint(f"/connections_/api/v1/Connections/{key}"),
)

def _retrieve_token_spec(self, key: str) -> RequestSpec:
def _retrieve_token_spec(
self, key: str, token_type: ConnectionTokenType = ConnectionTokenType.DIRECT
) -> RequestSpec:
return RequestSpec(
method="GET",
endpoint=Endpoint(f"/connections_/api/v1/Connections/{key}/token"),
params={"tokenType": "direct"},
params={"tokenType": token_type.value},
)
27 changes: 26 additions & 1 deletion src/uipath/agent/models/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,31 @@ class AgentProcessToolResourceConfig(BaseAgentToolResourceConfig):
)


class AgentIntegrationToolParameter(BaseModel):
"""Agent integration tool parameter."""

name: str = Field(..., alias="name")
type: str = Field(..., alias="type")
value: Optional[Any] = Field(None, alias="value")
field_location: str = Field(..., alias="fieldLocation")

# Useful Metadata
display_name: Optional[str] = Field(None, alias="displayName")
display_value: Optional[str] = Field(None, alias="displayValue")
description: Optional[str] = Field(None, alias="description")
position: Optional[str] = Field(None, alias="position")
field_variant: Optional[str] = Field(None, alias="fieldVariant")
dynamic: Optional[bool] = Field(None, alias="dynamic")
is_cascading: Optional[bool] = Field(None, alias="isCascading")
sort_order: Optional[int] = Field(..., alias="sortOrder")
required: Optional[bool] = Field(None, alias="required")
# enum_values, dynamic_behavior and reference not typed currently

model_config = ConfigDict(
validate_by_name=True, validate_by_alias=True, extra="allow"
)


class AgentIntegrationToolProperties(BaseModel):
"""Properties specific to tool configuration."""

Expand All @@ -107,6 +132,7 @@ class AgentIntegrationToolProperties(BaseModel):
method: str = Field(..., alias="method")
connection: Connection = Field(..., alias="connection")
body_structure: dict[str, Any] = Field(..., alias="bodyStructure")
parameters: List[AgentIntegrationToolParameter] = Field([], alias="parameters")

model_config = ConfigDict(
validate_by_name=True, validate_by_alias=True, extra="allow"
Expand All @@ -118,7 +144,6 @@ class AgentIntegrationToolResourceConfig(BaseAgentToolResourceConfig):

type: Literal[AgentToolType.INTEGRATION] = AgentToolType.INTEGRATION
properties: AgentIntegrationToolProperties

model_config = ConfigDict(
validate_by_name=True, validate_by_alias=True, extra="allow"
)
Expand Down
6 changes: 6 additions & 0 deletions src/uipath/models/connections.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from enum import Enum
from typing import Any, Optional

from pydantic import BaseModel, ConfigDict, Field
Expand Down Expand Up @@ -30,6 +31,11 @@ class Connection(BaseModel):
element_version: Optional[str] = Field(default=None, alias="elementVersion")


class ConnectionTokenType(str, Enum):
DIRECT = "direct"
BEARER = "bearer"


class ConnectionToken(BaseModel):
model_config = ConfigDict(
validate_by_name=True,
Expand Down
Loading
Loading