Skip to content

refactor request_options, add language param #1481

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 15 commits into from
Oct 11, 2024
Merged

Conversation

jacalata
Copy link
Contributor

I have refactored the classes to separate options that can be used in querying content, and options that can be used for exporting data.

In the new Data Exports section, I've added the parameter "language" which can be used to change how the data in a workbook is localized for export.

jacalata and others added 2 commits September 17, 2024 16:51
v0.33

Features:
- add name, datasource-name to Job item
- enable bulk add and remove users
- Linked Tasks: get, get by ID, run Now
- implement Tags: create new, add/delete for workbooks, flows, datasources
- get page and chunk size from env vars
- add some repr implementations
- implement virtual connections

Bugfix:
- #1447
- #1449
I have refactored the classes to separate options that can be used in querying content, and options that can be used for exporting data. "language" is only available for data exporting.
@jacalata jacalata changed the base branch from master to development September 30, 2024 05:29
Copy link

github-actions bot commented Sep 30, 2024

Coverage

Coverage Report
FileStmtsMissCoverMissing
tableauserverclient
   __init__.py50100% 
   _version.py278163163 41%
   config.py150100% 
   datetime_helpers.py2511 96%
   exponential_backoff.py200100% 
   filesys_helpers.py310100% 
   namespace.py2633 88%
tableauserverclient/helpers
   __init__.py10100% 
   headers.py1388 38%
   logging.py20100% 
   strings.py2711 96%
tableauserverclient/models
   __init__.py410100% 
   column_item.py553232 42%
   connection_credentials.py351111 69%
   connection_item.py771010 87%
   custom_view_item.py11999 92%
   data_acceleration_report_item.py5411 98%
   data_alert_item.py15933 98%
   data_freshness_policy_item.py1561515 90%
   database_item.py2073636 83%
   datasource_item.py2471111 96%
   dqw_item.py10455 95%
   exceptions.py40100% 
   favorites_item.py5688 86%
   fileupload_item.py190100% 
   flow_item.py1491010 93%
   flow_run_item.py720100% 
   group_item.py8133 96%
   groupset_item.py3911 97%
   interval_item.py1823232 82%
   job_item.py1871010 95%
   linked_tasks_item.py8011 99%
   metric_item.py1301212 91%
   pagination_item.py340100% 
   permissions_item.py1091212 89%
   project_item.py1573333 79%
   property_decorators.py1001818 82%
   reference_item.py2311 96%
   revision_item.py600100% 
   schedule_item.py20666 97%
   server_info_item.py3744 89%
   site_item.py6101212 98%
   subscription_item.py10333 97%
   table_item.py1181818 85%
   tableau_auth.py612424 61%
   tableau_types.py2511 96%
   tag_item.py150100% 
   target.py60100% 
   task_item.py5722 96%
   user_item.py2771717 94%
   view_item.py1791515 92%
   virtual_connection_item.py6488 88%
   webhook_item.py660100% 
   workbook_item.py2751616 94%
tableauserverclient/server
   __init__.py90100% 
   exceptions.py40100% 
   filter.py2111 95%
   pager.py3511 97%
   query.py1391515 89%
   request_factory.py1090148148 86%
   request_options.py23622 99%
   server.py1671717 90%
   sort.py60100% 
tableauserverclient/server/endpoint
   __init__.py330100% 
   auth_endpoint.py761212 84%
   custom_views_endpoint.py11877 94%
   data_acceleration_report_endpoint.py210100% 
   data_alert_endpoint.py972525 74%
   databases_endpoint.py1103030 73%
   datasources_endpoint.py3113636 88%
   default_permissions_endpoint.py4755 89%
   dqw_endpoint.py431616 63%
   endpoint.py1812020 89%
   exceptions.py6866 91%
   favorites_endpoint.py952222 77%
   fileuploads_endpoint.py510100% 
   flow_runs_endpoint.py651111 83%
   flow_task_endpoint.py2333 87%
   flows_endpoint.py2165858 73%
   groups_endpoint.py1271010 92%
   groupsets_endpoint.py7488 89%
   jobs_endpoint.py711212 83%
   linked_tasks_endpoint.py380100% 
   metadata_endpoint.py881414 84%
   metrics_endpoint.py5888 86%
   permissions_endpoint.py4755 89%
   projects_endpoint.py1522929 81%
   resource_tagger.py1354343 68%
   schedules_endpoint.py1001111 89%
   server_info_endpoint.py351010 71%
   sites_endpoint.py1262828 78%
   subscriptions_endpoint.py581515 74%
   tables_endpoint.py1083636 67%
   tasks_endpoint.py6577 89%
   users_endpoint.py1301616 88%
   views_endpoint.py1381010 93%
   virtual_connections_endpoint.py1151111 90%
   webhooks_endpoint.py571111 81%
   workbooks_endpoint.py3332727 92%
TOTAL10595132288% 

def page_number(self, page_number):
self.pagenumber = page_number
return self
class _DataExportOptions(RequestOptionsBase):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: is _VizExportOptions a better class name here as I believe options like maxAge are limited to exporting API endpoints

# if 'high' isn't specified, the REST API endpoint returns an image with standard resolution
class Resolution:
High = "high"

def __init__(self, imageresolution=None, maxage=-1):
super().__init__()
super().__init__(maxage=maxage)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

may be a good time to add viz_height & viz_width to image request options?

if self.max_age != -1:
params["maxAge"] = self.max_age
if self.language:
params["language"] = self._language

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
params["language"] = self._language
params["language"] = self.language

jacalata and others added 5 commits October 10, 2024 16:31
Seems unnecessary since they aren't actually doing any checks.
This reverts some of the files edited by black locally
@jacalata jacalata merged commit 89e1ddf into development Oct 11, 2024
26 checks passed
@jacalata jacalata deleted the jac/export-language branch October 11, 2024 21:00
jacalata added a commit that referenced this pull request Oct 24, 2024
* Feature: export custom views #999 (#1506)
* feat(exceptions): separate failed signin error (#1478)
* refactor request_options, add language param (#1481)
* Set FILESIZE_LIMIT_MB via environment variables (#1466)
* added PulseMetricDefine cap (#1490)
* Adding project permissions handling for databases, tables and virtual connections (#1482)
* fix: queryset support for flowruns (#1460)
* fix: set unknown size to sys.maxsize
* fix: handle 0 item response in querysets (#1501)
* chore: support VizqlDataApiAccess capability (#1504)
* refactor(test): extract error factory to _utils
* chore(typing): flowruns.cancel can also accept a FlowRunItem
* chore: type hint default permissions endpoints (#1493)
* chore(versions): update remaining f-strings (#1477)
* Make urllib3 dependency more flexible (#1468)
* Update requests library for CVE CVE-2024-35195 (#1507)

* chore(versions): Upgrade minimum python version (#1465)
* ci: cache dependencies for faster builds (#1497)
* ci: build on python 3.13 (#1492)
* Update samples for Python 3.x compatibility (#1479)
* chore: remove  py2 holdover code (#1496)
* #Add 'description' to datasource sample code (#1475)
* Remove sample code showing group name encoding (#1486)
* chore(typing): include samples in type checks (#1455)

* fix: docstring on QuerySet
* docs: add docstrings to auth objects and endpoints (#1484)
* docs: docstrings for Server and ServerInfo (#1494)
* docs: docstrings for user item and endpoint (#1485)
* docs: docstrings for site item and endpoint (#1495)
* docs: workbook docstrings (#1488)
* #1464 - docs update for filtering on boolean values (#1471)

---------
Co-authored-by: Brian Cantoni <bcantoni@salesforce.com>
Co-authored-by: Jordan Woods <jorwoods@users.noreply.github.com>
Co-authored-by: Jordan Woods <13803242+jorwoods@users.noreply.github.com>
Co-authored-by: Jac <jacalata@users.noreply.github.com>
Co-authored-by: Henning Merklinger <henning.merklinger@gmail.com>
Co-authored-by: AlbertWangXu <albert.xuwang@yahoo.com>
Co-authored-by: TrimPeachu <77048868+TrimPeachu@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants