Skip to content

Commit 188fcd8

Browse files
committed
chore: make update_hyper_data actions more specific
1 parent 984b66d commit 188fcd8

File tree

2 files changed

+42
-4
lines changed

2 files changed

+42
-4
lines changed

tableauserverclient/models/datasource_item.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -490,7 +490,7 @@ def _set_values(
490490
self._owner = owner
491491

492492
@classmethod
493-
def from_response(cls, resp: str, ns: dict) -> list["DatasourceItem"]:
493+
def from_response(cls, resp: bytes, ns: dict) -> list["DatasourceItem"]:
494494
all_datasource_items = list()
495495
parsed_response = fromstring(resp)
496496
all_datasource_xml = parsed_response.findall(".//t:datasource", namespaces=ns)

tableauserverclient/server/endpoint/datasources_endpoint.py

Lines changed: 41 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66

77
from contextlib import closing
88
from pathlib import Path
9-
from typing import Literal, Optional, TYPE_CHECKING, TypeVar, Union, overload
10-
from collections.abc import Iterable, Mapping, Sequence
9+
from typing import Literal, Optional, TYPE_CHECKING, TypedDict, TypeVar, Union, overload
10+
from collections.abc import Iterable, Sequence
1111

1212
from tableauserverclient.helpers.headers import fix_filename
1313
from tableauserverclient.models.dqw_item import DQWItem
@@ -56,6 +56,44 @@
5656
PathOrFileW = Union[FilePath, FileObjectW]
5757

5858

59+
HyperActionCondition = TypedDict(
60+
"HyperActionCondition",
61+
{
62+
"op": str,
63+
"target-col": str,
64+
"source-col": str,
65+
},
66+
)
67+
68+
HyperActionRow = TypedDict(
69+
"HyperActionRow",
70+
{
71+
"action": Literal[
72+
"update",
73+
"upsert",
74+
"delete",
75+
],
76+
"source-table": str,
77+
"target-table": str,
78+
"condition": HyperActionCondition,
79+
},
80+
)
81+
82+
HyperActionTable = TypedDict(
83+
"HyperActionTable",
84+
{
85+
"action": Literal[
86+
"insert",
87+
"replace",
88+
],
89+
"source-table": str,
90+
"target-table": str,
91+
},
92+
)
93+
94+
HyperAction = Union[HyperActionTable, HyperActionRow]
95+
96+
5997
class Datasources(QuerysetEndpoint[DatasourceItem], TaggingMixin[DatasourceItem]):
6098
def __init__(self, parent_srv: "Server") -> None:
6199
super().__init__(parent_srv)
@@ -648,7 +686,7 @@ def update_hyper_data(
648686
datasource_or_connection_item: Union[DatasourceItem, ConnectionItem, str],
649687
*,
650688
request_id: str,
651-
actions: Sequence[Mapping],
689+
actions: Sequence[HyperAction],
652690
payload: Optional[FilePath] = None,
653691
) -> JobItem:
654692
"""

0 commit comments

Comments
 (0)