Skip to content

Commit

Permalink
format w black
Browse files Browse the repository at this point in the history
  • Loading branch information
jacalata committed Dec 12, 2024
1 parent c54ace3 commit b630db6
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 19 deletions.
3 changes: 0 additions & 3 deletions samples/create_extract_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,5 @@ def main():
print(e)





if __name__ == "__main__":
main()
17 changes: 8 additions & 9 deletions samples/extracts.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ def main():
help="desired logging level (set to error by default)",
)
# Options specific to this sample
parser.add_argument("--create", action="store_true")
parser.add_argument("--create", action="store_true")
parser.add_argument("--delete", action="store_true")
parser.add_argument("--refresh", action="store_true")
parser.add_argument("--refresh", action="store_true")
parser.add_argument("--workbook", required=False)
parser.add_argument("--datasource", required=False)
args = parser.parse_args()
Expand All @@ -43,7 +43,7 @@ def main():
server.use_server_version()
with server.auth.sign_in(tableau_auth):

wb = None
wb = None
ds = None
if args.workbook:
wb = server.workbooks.get_by_id(args.workbook)
Expand All @@ -53,7 +53,7 @@ def main():
ds = server.datasources.get_by_id(args.datasource)
if ds is None:
raise ValueError(f"Datasource not found for id {args.datasource}")
else:
else:
# Gets all workbook items
all_workbooks, pagination_item = server.workbooks.get()
print(f"\nThere are {pagination_item.total_available} workbooks on site: ")
Expand All @@ -67,20 +67,19 @@ def main():
print("create extract on wb ", wb.name)
extract_job = server.workbooks.create_extract(wb, includeAll=True)
print(extract_job)

if args.refresh:
extract_job = None
if ds is not None:
if ds is not None:
print(f"refresh extract on datasource {ds.name}")
extract_job = server.datasources.refresh(ds, includeAll=True, incremental=True)
elif wb is not None:
print(f"refresh extract on workbook {wb.name}")
extract_job = server.workbooks.refresh(wb)
else:
else:
print("no content item selected to refresh")

print(extract_job)


if args.delete:
print("delete extract on wb ", wb.name)
Expand Down
2 changes: 1 addition & 1 deletion samples/publish_workbook.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def main():

# Step 1: Sign in to server.
tableau_auth = TSC.PersonalAccessTokenAuth(args.token_name, args.token_value, site_id=args.site)
server = TSC.Server(args.server, use_server_version=True, http_options={'verify': False})
server = TSC.Server(args.server, use_server_version=True, http_options={"verify": False})
with server.auth.sign_in(tableau_auth):
# Step2: Retrieve the project id, if a project name was passed
if args.project is not None:
Expand Down
5 changes: 2 additions & 3 deletions samples/refresh.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,8 @@ def main():
refresh_type = "Incremental"
incremental = True


tableau_auth = TSC.PersonalAccessTokenAuth(args.token_name, args.token_value, site_id=args.site)
server = TSC.Server(args.server, use_server_version=True, http_options={'verify': False})
server = TSC.Server(args.server, use_server_version=True, http_options={"verify": False})
with server.auth.sign_in(tableau_auth):
if args.resource_type == "workbook":
# Get the workbook by its Id to make sure it exists
Expand All @@ -61,7 +60,7 @@ def main():
# server.datasources.create_extract(resource)

# trigger the refresh, you'll get a job id back which can be used to poll for when the refresh is done
job = server.datasources.refresh(resource, incremental=incremental) # by default runs as a sync task,
job = server.datasources.refresh(resource, incremental=incremental) # by default runs as a sync task,

print(f"{refresh_type} job posted (ID: {job.id})")
if args.synchronous:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ def update_connection(
return connection

@api(version="2.8")
def refresh(self, datasource_item: DatasourceItem, incremental: bool=False) -> JobItem:
def refresh(self, datasource_item: DatasourceItem, incremental: bool = False) -> JobItem:
id_ = getattr(datasource_item, "id", datasource_item)
url = f"{self.baseurl}/{id_}/refresh"
refresh_req = RequestFactory.Task.refresh_req(incremental)
Expand Down
4 changes: 2 additions & 2 deletions tableauserverclient/server/request_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -1119,9 +1119,9 @@ def run_req(self, xml_request: ET.Element, task_item: Any) -> None:

@_tsrequest_wrapped
def refresh_req(self, xml_request: ET.Element, incremental: bool = False) -> bytes:
task_element = ET.SubElement(xml_request, 'extractRefresh')
task_element = ET.SubElement(xml_request, "extractRefresh")
if incremental:
task_element.attrib['incremental'] = "true"
task_element.attrib["incremental"] = "true"
return ET.tostring(xml_request)

@_tsrequest_wrapped
Expand Down

0 comments on commit b630db6

Please sign in to comment.