10000 Clean up hidden_views by making it an attribute of WorkbookItem by scuml · Pull Request #617 · tableau/server-client-python · GitHub
[go: up one dir, main page]

Skip to content

Clean up hidden_views by making it an attribute of WorkbookItem #617

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Nov 9, 2021
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
1 change: 1 addition & 0 deletions tableauserverclient/models/workbook_item.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ def __init__(self, project_id: str, name: str = None, show_tabs: bool = False) -
self.owner_id: Optional[str] = None
self.project_id = project_id
self.show_tabs = show_tabs
self.hidden_views = None
self.tags: Set[str] = set()
self.data_acceleration_config = {
"acceleration_enabled": None,
Expand Down
3 changes: 0 additions & 3 deletions tableauserverclient/server/endpoint/workbooks_endpoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,6 @@ def publish(
connection_credentials: Optional["ConnectionCredentials"] = None,
connections: Optional[Sequence[ConnectionItem]] = None,
as_job: bool = False,
hidden_views: Optional[Sequence[str]] = None,
skip_connection_check: bool = False,
):

Expand Down Expand Up @@ -388,7 +387,6 @@ def publish(
workbook_item,
connection_credentials=conn_creds,
connections=connections,
hidden_views=hidden_views,
)
else:
logger.info("Publishing {0} to server".format(filename))
Expand All @@ -410,7 +408,6 @@ def publish(
file_contents,
connection_credentials=conn_creds,
connections=connections,
hidden_views=hidden_views,
)
logger.debug("Request xml: {0} ".format(xml_request[:1000]))

Expand Down
11 changes: 3 additions & 8 deletions tableauserverclient/server/request_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -771,7 +771,6 @@ def _generate_xml(
workbook_item,
connection_credentials=None,
connections=None,
hidden_views=None,
):
xml_request = ET.Element("tsRequest")
workbook_element = ET.SubElement(xml_request, "workbook")
Expand All @@ -792,9 +791,9 @@ def _generate_xml(
for connection in connections:
_add_connections_element(connections_element, connection)

if hidden_views is not None:
views_element = ET.SubElement(workbook_element, "views")
for view_name in hidden_views:
if workbook_item.hidden_views is not None:
views_element = ET.SubElement(workbook_element, 'views')
for view_name in workbook_item.hidden_views:
_add_hiddenview_element(views_element, view_name)

return ET.tostring(xml_request)
Expand Down Expand Up @@ -832,13 +831,11 @@ def publish_req(
file_contents,
connection_credentials=None,
connections=None,
hidden_views=None,
):
xml_request = self._generate_xml(
workbook_item,
connection_credentials=connection_credentials,
connections=connections,
hidden_views=hidden_views,
)

parts = {
Expand All @@ -852,13 +849,11 @@ def publish_req_chunked(
workbook_item,
connection_credentials=None,
connections=None,
hidden_views=None,
):
xml_request = self._generate_xml(
workbook_item,
connection_credentials=connection_credentials,
connections=connections,
hidden_views=hidden_views,
)

parts = {"request_payload": ("", xml_request, "text/xml")}
Expand Down
9 changes: 4 additions & 5 deletions test/test_workbook.py
Original file line number Diff line number Diff line change
Expand Up @@ -591,11 +591,10 @@ def test_publish_with_hidden_view(self) -> None:
sample_workbook = os.path.join(TEST_ASSET_DIR, 'SampleWB.twbx')
publish_mode = self.server.PublishMode.CreateNew

new_workbook = self.server.workbooks.publish(new_workbook,
sample_workbook,
publish_mode,
hidden_views=['GDP per capita'])

new_workbook.hidden_views = ['GDP per capita']
new_workbook = self.server.workbooks.publish(
new_workbook, sample_workbook, publish_mode
)
request_body = m._adapter.request_history[0]._request.body
# order of attributes in xml is unspecified
self.assertTrue(re.search(rb'<views><view.*?hidden=\"true\".*?\/><\/views>', request_body))
Expand Down
0