Skip to content

Commit 38bc4f8

Browse files
committed
Removed deprecated workflow operations
Signed-off-by: Albert Callarisa <albert@diagrid.io>
1 parent a1e0354 commit 38bc4f8

9 files changed

Lines changed: 0 additions & 1150 deletions

File tree

dapr/aio/clients/grpc/client.py

Lines changed: 0 additions & 320 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,9 @@
1414
"""
1515

1616
import asyncio
17-
import json
1817
import socket
1918
import time
2019
import uuid
21-
from datetime import datetime
2220
from typing import Any, Awaitable, Callable, Dict, List, Optional, Sequence, Text, Union
2321
from urllib.parse import urlencode
2422
from warnings import warn
@@ -57,7 +55,6 @@
5755
MetadataTuple,
5856
convert_dict_to_grpc_dict_of_any,
5957
convert_value_to_struct,
60-
getWorkflowRuntimeStatus,
6158
to_bytes,
6259
validateNotBlankString,
6360
validateNotNone,
@@ -80,12 +77,10 @@
8077
GetBulkSecretResponse,
8178
GetMetadataResponse,
8279
GetSecretResponse,
83-
GetWorkflowResponse,
8480
InvokeMethodResponse,
8581
QueryResponse,
8682
QueryResponseItem,
8783
RegisteredComponents,
88-
StartWorkflowResponse,
8984
StateResponse,
9085
TopicEventResponse,
9186
TryLockResponse,
@@ -1493,321 +1488,6 @@ async def decrypt(self, data: Union[str, bytes], options: DecryptOptions):
14931488
resp_stream = self._stub.DecryptAlpha1(req_iterator)
14941489
return DecryptResponse(resp_stream)
14951490

1496-
async def start_workflow(
1497-
self,
1498-
workflow_component: str,
1499-
workflow_name: str,
1500-
input: Optional[Union[Any, bytes]] = None,
1501-
instance_id: Optional[str] = None,
1502-
workflow_options: Optional[Dict[str, str]] = dict(),
1503-
send_raw_bytes: bool = False,
1504-
) -> StartWorkflowResponse:
1505-
"""Starts a workflow.
1506-
Deprecated: use dapr-ext-workflow instead
1507-
1508-
Args:
1509-
workflow_component (str): the name of the workflow component
1510-
that will run the workflow. e.g. `dapr`.
1511-
workflow_name (str): the name of the workflow that will be executed.
1512-
input (Optional[Union[Any, bytes]]): the input that the workflow will receive.
1513-
The input value will be serialized to JSON
1514-
by default. Use the send_raw_bytes param
1515-
to send unencoded binary input.
1516-
instance_id (Optional[str]): the name of the workflow instance,
1517-
e.g. `order_processing_workflow-103784`.
1518-
workflow_options (Optional[Dict[str, str]]): the key-value options
1519-
that the workflow will receive.
1520-
send_raw_bytes (bool) if true, no serialization will be performed on the input
1521-
bytes
1522-
1523-
Returns:
1524-
:class:`StartWorkflowResponse`: Instance ID associated with the started workflow
1525-
"""
1526-
# Warnings and input validation
1527-
warn(
1528-
'This Workflow API (Beta) method is deprecated and will be removed in a future version. Use the dapr-ext-workflow package instead.',
1529-
UserWarning,
1530-
stacklevel=2,
1531-
)
1532-
validateNotBlankString(
1533-
instance_id=instance_id,
1534-
workflow_component=workflow_component,
1535-
workflow_name=workflow_name,
1536-
)
1537-
1538-
if instance_id is None:
1539-
instance_id = str(uuid.uuid4())
1540-
1541-
if isinstance(input, bytes) and send_raw_bytes:
1542-
encoded_data = input
1543-
else:
1544-
try:
1545-
encoded_data = json.dumps(input).encode('utf-8') if input is not None else bytes([])
1546-
except TypeError:
1547-
raise DaprInternalError('start_workflow: input data must be JSON serializable')
1548-
except ValueError as e:
1549-
raise DaprInternalError(f'start_workflow JSON serialization error: {e}')
1550-
1551-
# Actual start workflow invocation
1552-
req = api_v1.StartWorkflowRequest(
1553-
instance_id=instance_id,
1554-
workflow_component=workflow_component,
1555-
workflow_name=workflow_name,
1556-
options=workflow_options,
1557-
input=encoded_data,
1558-
)
1559-
1560-
try:
1561-
response = self._stub.StartWorkflowBeta1(req)
1562-
return StartWorkflowResponse(instance_id=response.instance_id)
1563-
except grpc.aio.AioRpcError as err:
1564-
raise DaprInternalError(err.details())
1565-
1566-
async def get_workflow(self, instance_id: str, workflow_component: str) -> GetWorkflowResponse:
1567-
"""Gets information on a workflow.
1568-
Deprecated: use dapr-ext-workflow instead
1569-
1570-
Args:
1571-
instance_id (str): the ID of the workflow instance,
1572-
e.g. `order_processing_workflow-103784`.
1573-
workflow_component (str): the name of the workflow component
1574-
that will run the workflow. e.g. `dapr`.
1575-
1576-
Returns:
1577-
:class:`GetWorkflowResponse`: Instance ID associated with the started workflow
1578-
"""
1579-
# Warnings and input validation
1580-
warn(
1581-
'This Workflow API (Beta) method is deprecated and will be removed in a future version. Use the dapr-ext-workflow package instead.',
1582-
UserWarning,
1583-
stacklevel=2,
1584-
)
1585-
validateNotBlankString(instance_id=instance_id, workflow_component=workflow_component)
1586-
# Actual get workflow invocation
1587-
req = api_v1.GetWorkflowRequest(
1588-
instance_id=instance_id, workflow_component=workflow_component
1589-
)
1590-
1591-
try:
1592-
resp = self._stub.GetWorkflowBeta1(req)
1593-
# not found workflows return no error, but empty status
1594-
if resp.runtime_status == '':
1595-
raise DaprInternalError('no such instance exists')
1596-
if resp.created_at is None:
1597-
resp.created_at = datetime.now
1598-
if resp.last_updated_at is None:
1599-
resp.last_updated_at = datetime.now
1600-
return GetWorkflowResponse(
1601-
instance_id=instance_id,
1602-
workflow_name=resp.workflow_name,
1603-
created_at=resp.created_at,
1604-
last_updated_at=resp.last_updated_at,
1605-
runtime_status=getWorkflowRuntimeStatus(resp.runtime_status),
1606-
properties=resp.properties,
1607-
)
1608-
except grpc.aio.AioRpcError as err:
1609-
raise DaprInternalError(err.details())
1610-
1611-
async def terminate_workflow(self, instance_id: str, workflow_component: str) -> DaprResponse:
1612-
"""Terminates a workflow.
1613-
Deprecated: use dapr-ext-workflow instead
1614-
1615-
Args:
1616-
instance_id (str): the ID of the workflow instance, e.g.
1617-
`order_processing_workflow-103784`.
1618-
workflow_component (str): the name of the workflow component
1619-
that will run the workflow. e.g. `dapr`.
1620-
Returns:
1621-
:class:`DaprResponse` gRPC metadata returned from callee
1622-
1623-
"""
1624-
# Warnings and input validation
1625-
warn(
1626-
'This Workflow API (Beta) method is deprecated and will be removed in a future version. Use the dapr-ext-workflow package instead.',
1627-
UserWarning,
1628-
stacklevel=2,
1629-
)
1630-
validateNotBlankString(instance_id=instance_id, workflow_component=workflow_component)
1631-
# Actual terminate workflow invocation
1632-
req = api_v1.TerminateWorkflowRequest(
1633-
instance_id=instance_id, workflow_component=workflow_component
1634-
)
1635-
1636-
try:
1637-
_, call = self._stub.TerminateWorkflowBeta1.with_call(req)
1638-
return DaprResponse(headers=call.initial_metadata())
1639-
except grpc.aio.AioRpcError as err:
1640-
raise DaprInternalError(err.details())
1641-
1642-
async def raise_workflow_event(
1643-
self,
1644-
instance_id: str,
1645-
workflow_component: str,
1646-
event_name: str,
1647-
event_data: Optional[Union[Any, bytes]] = None,
1648-
send_raw_bytes: bool = False,
1649-
) -> DaprResponse:
1650-
"""Raises an event on a workflow.
1651-
Deprecated: use dapr-ext-workflow instead
1652-
1653-
Args:
1654-
instance_id (str): the ID of the workflow instance,
1655-
e.g. `order_processing_workflow-103784`.
1656-
workflow_component (str): the name of the workflow component
1657-
that will run the workflow. e.g. `dapr`.
1658-
event_name (str): the name of the event to be raised on
1659-
the workflow.
1660-
event_data (Optional[Union[Any, bytes]]): the input that the workflow will receive.
1661-
The input value will be serialized to JSON
1662-
by default. Use the send_raw_bytes param
1663-
to send unencoded binary input.
1664-
send_raw_bytes (bool) if true, no serialization will be performed on the input
1665-
bytes
1666-
1667-
Returns:
1668-
:class:`DaprResponse` gRPC metadata returned from callee
1669-
"""
1670-
# Warnings and input validation
1671-
warn(
1672-
'This Workflow API (Beta) method is deprecated and will be removed in a future version. Use the dapr-ext-workflow package instead.',
1673-
UserWarning,
1674-
stacklevel=2,
1675-
)
1676-
validateNotBlankString(
1677-
instance_id=instance_id, workflow_component=workflow_component, event_name=event_name
1678-
)
1679-
if isinstance(event_data, bytes) and send_raw_bytes:
1680-
encoded_data = event_data
1681-
else:
1682-
if event_data is not None:
1683-
try:
1684-
encoded_data = (
1685-
json.dumps(event_data).encode('utf-8')
1686-
if event_data is not None
1687-
else bytes([])
1688-
)
1689-
except TypeError:
1690-
raise DaprInternalError(
1691-
'raise_workflow_event:\
1692-
event_data must be JSON serializable'
1693-
)
1694-
except ValueError as e:
1695-
raise DaprInternalError(f'raise_workflow_event JSON serialization error: {e}')
1696-
encoded_data = json.dumps(event_data).encode('utf-8')
1697-
else:
1698-
encoded_data = bytes([])
1699-
# Actual workflow raise event invocation
1700-
req = api_v1.raise_workflow_event(
1701-
instance_id=instance_id,
1702-
workflow_component=workflow_component,
1703-
event_name=event_name,
1704-
event_data=encoded_data,
1705-
)
1706-
1707-
try:
1708-
_, call = self._stub.RaiseEventWorkflowBeta1.with_call(req)
1709-
return DaprResponse(headers=call.initial_metadata())
1710-
except grpc.aio.AioRpcError as err:
1711-
raise DaprInternalError(err.details())
1712-
1713-
async def pause_workflow(self, instance_id: str, workflow_component: str) -> DaprResponse:
1714-
"""Pause a workflow.
1715-
Deprecated: use dapr-ext-workflow instead
1716-
1717-
Args:
1718-
instance_id (str): the ID of the workflow instance,
1719-
e.g. `order_processing_workflow-103784`.
1720-
workflow_component (str): the name of the workflow component
1721-
that will run the workflow. e.g. `dapr`.
1722-
1723-
Returns:
1724-
:class:`DaprResponse` gRPC metadata returned from callee
1725-
1726-
"""
1727-
# Warnings and input validation
1728-
warn(
1729-
'This Workflow API (Beta) method is deprecated and will be removed in a future version. Use the dapr-ext-workflow package instead.',
1730-
UserWarning,
1731-
stacklevel=2,
1732-
)
1733-
validateNotBlankString(instance_id=instance_id, workflow_component=workflow_component)
1734-
# Actual pause workflow invocation
1735-
req = api_v1.PauseWorkflowRequest(
1736-
instance_id=instance_id, workflow_component=workflow_component
1737-
)
1738-
1739-
try:
1740-
_, call = self._stub.PauseWorkflowBeta1.with_call(req)
1741-
1742-
return DaprResponse(headers=call.initial_metadata())
1743-
except grpc.aio.AioRpcError as err:
1744-
raise DaprInternalError(err.details())
1745-
1746-
async def resume_workflow(self, instance_id: str, workflow_component: str) -> DaprResponse:
1747-
"""Resumes a workflow.
1748-
Deprecated: use dapr-ext-workflow instead
1749-
1750-
Args:
1751-
instance_id (str): the ID of the workflow instance,
1752-
e.g. `order_processing_workflow-103784`.
1753-
workflow_component (str): the name of the workflow component
1754-
that will run the workflow. e.g. `dapr`.
1755-
1756-
Returns:
1757-
:class:`DaprResponse` gRPC metadata returned from callee
1758-
"""
1759-
# Warnings and input validation
1760-
warn(
1761-
'This Workflow API (Beta) method is deprecated and will be removed in a future version. Use the dapr-ext-workflow package instead.',
1762-
UserWarning,
1763-
stacklevel=2,
1764-
)
1765-
validateNotBlankString(instance_id=instance_id, workflow_component=workflow_component)
1766-
# Actual resume workflow invocation
1767-
req = api_v1.ResumeWorkflowRequest(
1768-
instance_id=instance_id, workflow_component=workflow_component
1769-
)
1770-
1771-
try:
1772-
_, call = self._stub.ResumeWorkflowBeta1.with_call(req)
1773-
1774-
return DaprResponse(headers=call.initial_metadata())
1775-
except grpc.aio.AioRpcError as err:
1776-
raise DaprInternalError(err.details())
1777-
1778-
async def purge_workflow(self, instance_id: str, workflow_component: str) -> DaprResponse:
1779-
"""Purges a workflow.
1780-
Deprecated: use dapr-ext-workflow instead
1781-
1782-
Args:
1783-
instance_id (str): the ID of the workflow instance,
1784-
e.g. `order_processing_workflow-103784`.
1785-
workflow_component (str): the name of the workflow component
1786-
that will run the workflow. e.g. `dapr`.
1787-
1788-
Returns:
1789-
:class:`DaprResponse` gRPC metadata returned from callee
1790-
"""
1791-
# Warnings and input validation
1792-
warn(
1793-
'This Workflow API (Beta) method is deprecated and will be removed in a future version. Use the dapr-ext-workflow package instead.',
1794-
UserWarning,
1795-
stacklevel=2,
1796-
)
1797-
validateNotBlankString(instance_id=instance_id, workflow_component=workflow_component)
1798-
# Actual purge workflow invocation
1799-
req = api_v1.PurgeWorkflowRequest(
1800-
instance_id=instance_id, workflow_component=workflow_component
1801-
)
1802-
1803-
try:
1804-
_, call = self._stub.PurgeWorkflowBeta1.with_call(req)
1805-
1806-
return DaprResponse(headers=call.initial_metadata())
1807-
1808-
except grpc.aio.AioRpcError as err:
1809-
raise DaprInternalError(err.details())
1810-
18111491
async def converse_alpha1(
18121492
self,
18131493
name: str,

0 commit comments

Comments
 (0)