8000 Release with security and functionality updates by jacalata · Pull Request #1021 · tableau/server-client-python · GitHub
[go: up one dir, main page]

Skip to content

Release with security and functionality updates #1021

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 44 commits into from
Apr 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
3317584
Jac/publish samples (#918)
jacalata Oct 23, 2021
e037631
Type hinting on Datasources and Workbooks (#804)
jorwoods Nov 1, 2021
da9e316
Add type hints to `Job` (#939)
jorwoods Nov 7, 2021
aedfc89
Clean up hidden_views by making it an attribute of WorkbookItem (#617)
scuml Nov 9, 2021
240ce4e
Add support to datasource and workbook revisions (#931)
elsherif Nov 10, 2021
9752d85
Jorwoods/type hint revisions (#956)
jorwoods Nov 11, 2021
c8c23f1
WIP: Enable Black for CI and add as dependency (#935)
bcantoni Jan 28, 2022
aa91b99
Jorwoods/type hint data alert (#934)
jorwoods Jan 28, 2022
e06cea1
Jorwoods/type hint favorites (#936)
jorwoods Jan 28, 2022
686eee0
Jorwoods/type hint flows (#937)
jorwoods Jan 28, 2022
9c3efd1
make tests run even if code style fails (#980)
jacalata Jan 28, 2022
2373133
Add type hints for schedules (#969)
jorwoods Jan 28, 2022
ce144d0
Jorwoods/type hint groups (#938)
jorwoods Jan 28, 2022
82c1305
Jorwoods/type hint permissions (#940)
jorwoods Jan 28, 2022
5565a36
Jorwoods/type hint projects (#941)
jorwoods Jan 28, 2022
b351b89
Jorwoods/type hint flow runs (#950)
jorwoods Jan 28, 2022
f2793c4
Type hint site (#942)
jorwoods Jan 28, 2022
5b1e66a
Type hint subscriptions (#943)
jorwoods Jan 28, 2022
6a85032
Jorwoods/type hint user (#944)
jorwoods Jan 28, 2022
083eb2c
Type hint webhooks (#945)
jorwoods Jan 28, 2022
820005c
Type hint views (#949)
jorwoods Jan 28, 2022
31554c5
Accept `None` as parameter for the `site_id` of `TableauAuth` and `Pe…
vogelsgesang Jan 28, 2022
da9d5e0
Fix typings for clean run in mypy (#982)
jacalata Jan 31, 2022
213a70c
Jorwoods/default to server version (#989)
jorwoods Feb 18, 2022
921d554
Use defusedxml library to reduce xml attack surface (#1002)
jacalata Mar 11, 2022
84e7371
Null user_quota if tiered license levels exist (#981)
jorwoods Mar 12, 2022
5682b8e
Jorwoods/download excel files from views (#968)
jorwoods Mar 13, 2022
ea6d494
PEP 561 compliance for types (#992)
jorwoods Mar 13, 2022
2194c0d
Add support for metric items and endpoints (#960)
jorwoods Mar 13, 2022
6a56f08
Jorwoods/query endpoint paging (#881)
jorwoods Mar 15, 2022
66c763c
Add back old format for setting hidden views on publish (#955)
jacalata Mar 17, 2022
854240c
Add comments to clarify queryset iteration (#1004)
jorwoods Mar 18, 2022
edcba83
Add some sample functionality (#1003)
jacalata Mar 18, 2022
95aaba3
add get_by_id method and test for schedules (#1011)
jacalata Mar 24, 2022
457ea55
Add examples for simplified queryset to samples (#1010)
jorwoods Mar 24, 2022
634ff90
Jac/no cert check (#1009)
jacalata Mar 24, 2022
73c2b02
Add powerpoint export functionality to TSC (#1012)
jorwoods Mar 25, 2022
e907101
Jorwoods/quota tiers allow null (#1015)
jorwoods Mar 30, 2022
d9ea195
update readme (#1018)
jacalata Mar 30, 2022
2e7ce97
fix workbook.delete_extract (#1013)
jacalata Apr 2, 2022
b02eec3
add publish to pypi action (#1017)
jacalata Apr 5, 2022
4b474bc
Jac/add flow to schedule (#1019)
jacalata Apr 5, 2022
fd07b1d
Fix typing for schedule_extract_refresh (#1022)
jorwoods Apr 6, 2022
505f4c8
update Changelog.md
jacalata Apr 6, 2022
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
35 changes: 35 additions & 0 deletions .github/workflows/meta-checks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: types and style checks

on: [push, pull_request]

jobs:
build:
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: ['3.10']

runs-on: ${{ matrix.os }}

steps:
- uses: actions/checkout@v2

- name: Set up Python ${{ matrix.python-version }} on ${{ matrix.os }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -e .[test]

- name: Format with black
run: |
black --check --line-length 120 tableauserverclient samples test

- name: Run Mypy tests
if: always()
run: |
mypy --show-error-codes --disable-error-code misc --disable-error-code import tableauserverclient test
37 changes: 37 additions & 0 deletions .github/workflows/publish-pypi.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Publish to PyPi

# This will publish a package to TestPyPi (and real Pypi if run on master) with a version
# number generated by versioneer from the most recent tag looking like v____
# TODO: maybe move this into the package job so all release-based actions are together
on:
workflow_dispatch:
push:
branches:
- master

jobs:
build-n-publish:
name: Build dist files for PyPi
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: actions/setup-python@v1
with:
python-version: 3.8
- name: Build dist files
run: |
python -m pip install --upgrade pip
pip install -e .[test]
python setup.py sdist --formats=gztar
- name: Publish distribution 📦 to Test PyPI
uses: pypa/gh-action-pypi-publish@release/v1 # license BSD-2
with:
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
repository_url: https://test.pypi.org/legacy/
- name: Publish distribution 📦 to PyPI
if: github.ref == 'refs/heads/master'
uses: pypa/gh-action-pypi-publish@release/v1 # license BSD-2
with:
password: ${{ secrets.PYPI_API_TOKEN }}
9 changes: 4 additions & 5 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: Python tests

on: [push]
on: [push, pull_request]

jobs:
build:
Expand All @@ -24,13 +24,12 @@ jobs:
run: |
python -m pip install --upgrade pip
pip install -e .[test]
pip install mypy

- name: Test with pytest
if: always()
run: |
pytest test

- name: Run Mypy but allow failures
- name: Run Mypy tests
run: |
mypy --show-error-codes --disable-error-code misc tableauserverclient
continue-on-error: true
mypy --show-error-codes --disable-error-code misc --disable-error-code import tableauserverclient test
1 change: 1 addition & 0 deletions .github/workflows/slack.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ jobs:
name: Sends a message to Slack when a push, a pull request or an issue is made
steps:
- name: Send message to Slack API
continue-on-error: true
uses: archive/github-actions-slack@v2.2.2
id: notify
with:
Expand Down
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@

## 0.18.0 (6 April 2022)
* Switched to using defused_xml for xml attack protection
* added linting and type hints
* improve experience with self-signed certificates/invalid ssl
* updated samples
* new item types: metrics, revisions for datasources and workbooks
* features: support adding flows to schedules, exporting workbooks to powerpoint
* fixes: delete extracts

## 0.17.0 (20 October 2021)
* Added support for accepting parameters for post request of the metadata api (#850)
* Fixed jobs.get_by_id(job_id) example & reference docs (#867, #868)
Expand Down
7 changes: 2 additions & 5 deletions MANIFEST.in
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,6 @@ recursive-include test *.json
recursive-include test *.pdf
recursive-include test *.png
recursive-include test *.py
recursive-include test *.tde
recursive-include test *.tds
recursive-include test *.tdsx
recursive-include test *.twb
recursive-include test *.twbx
recursive-include test *.xml
global-include *.pyi
global-include *.typed
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ Use the Tableau Server Client (TSC) library to increase your productivity as you
* Create users and groups.
* Query projects, sites, and more.

This repository contains Python source code and sample files. Python versions 3.6 and up are supported.
This repository contains Python source code for the library and sample files showing how to use it. Python versions 3.6 and up are supported.

To see sample code that works directly with the REST API (in Java, Python, or Postman), visit the [REST API Samples](https://github.com/tableau/rest-api-samples) repo.

For more information on installing and using TSC, see the documentation:
<https://tableau.github.io/server-client-python/docs/>
Expand Down
13 changes: 11 additions & 2 deletions contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,23 @@ python setup.py build
python setup.py test
```

### To use your locally built version
```shell
pip install .
```

### Before Committing

Our CI runs include a Python lint run, so you should run this locally and fix complaints before committing as this will fail your checkin.

```shell
# this will run the formatter without making changes
black --line-length 120 tableauserverclient --check
black --line-length 120 tableauserverclient test samples --check

# this will format the directory and code for you
black --line-length 120 tableauserverclient
black --line-length 120 tableauserverclient test samples

# this will run type checking
pip install mypy
mypy --show-error-codes --disable-error-code misc --disable-error-code import tableauserverclient test
```
32 changes: 18 additions & 14 deletions samples/add_default_permission.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,23 @@


def main():
parser = argparse.ArgumentParser(description='Add workbook default permissions for a given project.')
parser = argparse.ArgumentParser(description="Add workbook default permissions for a given project.")
# Common options; please keep those in sync across all samples
parser.add_argument('--server', '-s', required=True, help='server address')
parser.add_argument('--site', '-S', help='site name')
parser.add_argument('--token-name', '-p', required=True,
help='name of the personal access token used to sign into the server')
parser.add_argument('--token-value', '-v', required=True,
help='value of the personal access token used to sign into the server')
parser.add_argument('--logging-level', '-l', choices=['debug', 'info', 'error'], default='error',
help='desired logging level (set to error by default)')
parser.add_argument("--server", "-s", required=True, help="server address")
parser.add_argument("--site", "-S", help="site name")
parser.add_argument(
"--token-name", "-p", required=True, help="name of the personal access token used to sign into the server"
)
parser.add_argument(
"--token-value", "-v", required=True, help="value of the personal access token used to sign into the server"
)
parser.add_argument(
"--logging-level",
"-l",
choices=["debug", "info", "error"],
default="error",
help="desired logging level (set to error by default)",
)
# Options specific to this sample
# This sample has no additional options, yet. If you add some, please add them here

Expand Down Expand Up @@ -53,10 +60,7 @@ def main():
new_capabilities = {TSC.Permission.Capability.ExportXml: TSC.Permission.Mode.Allow}

# Each PermissionRule in the list contains a grantee and a dict of capabilities
new_rules = [TSC.PermissionsRule(
grantee=default_permissions.grantee,
capabilities=new_capabilities
)]
new_rules = [TSC.PermissionsRule(grantee=default_permissions.grantee, capabilities=new_capabilities)]

new_default_permissions = server.projects.update_workbook_default_permissions(project, new_rules)

Expand All @@ -78,5 +82,5 @@ def main():
# server.projects.delete(project.id)


if __name__ == '__main__':
if __name__ == "__main__":
main()
29 changes: 18 additions & 11 deletions samples/create_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,23 @@

def main():

parser = argparse.ArgumentParser(description='Creates a sample user group.')
parser = argparse.ArgumentParser(description="Creates a sample user group.")
# Common options; please keep those in sync across all samples
parser.add_argument('--server', '-s', required=True, help='server address')
parser.add_argument('--site', '-S', help='site name')
parser.add_argument('--token-name', '-p', required=True,
help='name of the personal access token used to sign into the server')
parser.add_argument('--token-value', '-v', required=True,
help='value of the personal access token used to sign into the server')
parser.add_argument('--logging-level', '-l', choices=['debug', 'info', 'error'], default='error',
help='desired logging level (set to error by default)')
parser.add_argument("--server", "-s", required=True, help="server address")
parser.add_argument("--site", "-S", help="site name")
parser.add_argument(
"--token-name", "-p", required=True, help="name of the personal access token used to sign into the server"
)
parser.add_argument(
"--token-value", "-v", required=True, help="value of the personal access token used to sign into the server"
)
parser.add_argument(
"--logging-level",
"-l",
choices=["debug", "info", "error"],
default="error",
help="desired logging level (set to error by default)",
)
# Options specific to this sample
# This sample has no additional options, yet. If you add some, please add them here

Expand All @@ -38,10 +45,10 @@ def main():
tableau_auth = TSC.PersonalAccessTokenAuth(args.token_name, args.token_value, site_id=args.site)
server = TSC.Server(args.server, use_server_version=True)
with server.auth.sign_in(tableau_auth):
group = TSC.GroupItem('test')
group = TSC.GroupItem("test")
group = server.groups.create(group)
print(group)


if __name__ == '__main__':
if __name__ == "__main__":
main()
49 changes: 30 additions & 19 deletions samples/create_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,27 +14,34 @@
import tableauserverclient as TSC


def create_project(server, project_item):
def create_project(server, project_item, samples=False):
try:
project_item = server.projects.create(project_item)
print('Created a new project called: %s' % project_item.name)
project_item = server.projects.create(project_item, samples)
print("Created a new project called: %s" % project_item.name)
return project_item
except TSC.ServerResponseError:
print('We have already created this project: %s' % project_item.name)
print("We have already created this project: %s" % project_item.name)
sys.exit(1)


def main():
parser = argparse.ArgumentParser(description='Create new projects.')
parser = argparse.ArgumentParser(description="Create new projects.")
# Common options; please keep those in sync across all samples
parser.add_argument('--server', '-s', required=True, help='server address')
parser.add_argument('--site', '-S', help='site name')
parser.add_argument('--token-name', '-p', required=True,
help='name of the personal access token used to sign into the server')
parser.add_argument('--token-value', '-v', required=True,
help='value of the personal access token used to sign into the server')
parser.add_argument('--logging-level', '-l', choices=['debug', 'info', 'error'], default='error',
help='desired logging level (set to error by default)')
parser.add_argument("--server", "-s", required=True, help="server address")
parser.add_argument("--site", "-S", help="site name")
parser.add_argument(
"--token-name", "-p", required=True, help="name of the personal access token used to sign into the server"
)
parser.add_argument(
"--token-value", "-v", required=True, help="value of the personal access token used to sign into the server"
)
parser.add_argument(
"--logging-level",
"-l",
choices=["debug", "info", "error"],
default="error",
help="desired logging level (set to error by default)",
)
# Options specific to this sample
# This sample has no additional options, yet. If you add some, please add them here

Expand All @@ -45,23 +52,27 @@ def main():
logging.basicConfig(level=logging_level)

tableau_auth = TSC.PersonalAccessTokenAuth(args.token_name, args.token_value, site_id=args.site)
server = TSC.Server(args.server, use_server_version=True)
server = TSC.Server(args.server)
server.use_server_version()
with server.auth.sign_in(tableau_auth):
# Use highest Server REST API version available
server.use_server_version()

# Without parent_id specified, projects are created at the top level.
top_level_project = TSC.ProjectItem(name='Top Level Project')
top_level_project = TSC.ProjectItem(name="Top Level Project")
top_level_project = create_project(server, top_level_project)

# Specifying parent_id creates a nested projects.
child_project = TSC.ProjectItem(name='Child Project', parent_id=top_level_project.id)
child_project = create_project(server, child_project)
child_project = TSC.ProjectItem(name="Child Project", parent_id=top_level_project.id)
child_project = create_project(server, child_project, samples=True)

# Projects can be nested at any level.
grand_child_project = TSC.ProjectItem(name='Grand Child Project', parent_id=child_project.id)
grand_child_project = TSC.ProjectItem(name="Grand Child Project", parent_id=child_project.id)
grand_child_project = create_project(server, grand_child_project)

# Projects can be updated
changed_project = server.projects.update(grand_child_project, samples=True)

if __name__ == '__main__':

if __name__ == "__main__":
main()
Loading
0