-
Notifications
You must be signed in to change notification settings - Fork 444
1580 list extracts on schedule #1604
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
jacalata
merged 6 commits into
tableau:development
from
casey-crawford-cfa:1580-list-extracts-on-schedule
May 14, 2025
Merged
Changes from 4 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
cb28446
determine what datasources or workbooks are associated with a schedule
casey-crawford-cfa 0763983
black formatting
casey-crawford-cfa 8d9893a
mypy found an issue with str|none
casey-crawford-cfa e7ddaaa
Merge branch 'development' into 1580-list-extracts-on-schedule
jacalata aa46f45
- Fixing test asset to have real value instead of api documentation v…
casey-crawford-cfa 081a15a
Merge branch 'development' into 1580-list-extracts-on-schedule
casey-crawford-cfa File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
from typing import Optional, List | ||
from defusedxml.ElementTree import fromstring | ||
import xml.etree.ElementTree as ET | ||
|
||
|
||
class ExtractItem: | ||
""" | ||
An extract refresh task item. | ||
|
||
Attributes | ||
---------- | ||
id : str | ||
The ID of the extract refresh task | ||
priority : int | ||
The priority of the task | ||
type : str | ||
The type of extract refresh (incremental or full) | ||
workbook_id : str, optional | ||
The ID of the workbook if this is a workbook extract | ||
datasource_id : str, optional | ||
The ID of the datasource if this is a datasource extract | ||
""" | ||
|
||
def __init__( | ||
self, priority: int, refresh_type: str, workbook_id: Optional[str] = None, datasource_id: Optional[str] = None | ||
): | ||
self._id: Optional[str] = None | ||
self._priority = priority | ||
self._type = refresh_type | ||
self._workbook_id = workbook_id | ||
self._datasource_id = datasource_id | ||
|
||
@property | ||
def id(self) -> Optional[str]: | ||
return self._id | ||
|
||
@property | ||
def priority(self) -> int: | ||
return self._priority | ||
|
||
@property | ||
def type(self) -> str: | ||
return self._type | ||
|
||
@property | ||
def workbook_id(self) -> Optional[str]: | ||
return self._workbook_id | ||
|
||
@property | ||
def datasource_id(self) -> Optional[str]: | ||
return self._datasource_id | ||
|
||
@classmethod | ||
def from_response(cls, resp: str, ns: dict) -> List["ExtractItem"]: | ||
"""Create ExtractItem objects from XML response.""" | ||
parsed_response = fromstring(resp) | ||
return cls.from_xml_element(parsed_response, ns) | ||
|
||
@classmethod | ||
def from_xml_element(cls, parsed_response: ET.Element, ns: dict) -> List["ExtractItem"]: | ||
"""Create ExtractItem objects from XML element.""" | ||
all_extract_items = [] | ||
all_extract_xml = parsed_response.findall(".//t:extract", namespaces=ns) | ||
|
||
for extract_xml in all_extract_xml: | ||
extract_id = extract_xml.get("id", None) | ||
priority = int(extract_xml.get("priority", 0)) | ||
refresh_type = extract_xml.get("type", "") | ||
|
||
# Check for workbook or datasource | ||
workbook_elem = extract_xml.find(".//t:workbook", namespaces=ns) | ||
datasource_elem = extract_xml.find(".//t:datasource", namespaces=ns) | ||
|
||
workbook_id = workbook_elem.get("id", None) if workbook_elem is not None else None | ||
datasource_id = datasource_elem.get("id", None) if datasource_elem is not None else None | ||
|
||
extract_item = cls(priority, refresh_type, workbook_id, datasource_id) | ||
extract_item._id = extract_id | ||
|
||
all_extract_items.append(extract_item) | ||
|
||
return all_extract_items |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?xml version='1.0' encoding='UTF-8'?> | ||
<tsResponse xmlns="http://tableau.com/api" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://tableau.com/api http://tableau.com/api/ts-api-2.3.xsd"> | ||
<extracts> | ||
<extract id="task1" | ||
priority="1" | ||
type="incremental-or-full" > | ||
<workbook id="workbook-id" /> | ||
</extract> | ||
<extract id="task2" | ||
priority="2" | ||
type="incremental-or-full" > | ||
<datasource id="datasource-id" /> | ||
</extract> | ||
</extracts> | ||
</tsResponse> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.