Skip to content
Closed
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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.12.1 (22 July 2020)

* Fixed login.py sample to properly handle sitename (#652)

## 0.12 (10 July 2020)

* Added hidden_views parameter to workbook publish method (#614)
Expand Down
11 changes: 8 additions & 3 deletions samples/login.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def main():
group = parser.add_mutually_exclusive_group(required=True)
group.add_argument('--username', '-u', help='username to sign into the server')
group.add_argument('--token-name', '-n', help='name of the personal access token used to sign into the server')
parser.add_argument('--sitename', '-S', default=None)
parser.add_argument('--sitename', '-S', default='')

args = parser.parse_args()

Expand All @@ -36,13 +36,18 @@ def main():
if args.username:
# Trying to authenticate using username and password.
password = getpass.getpass("Password: ")
tableau_auth = TSC.TableauAuth(args.username, password)

print("\nSigning in...\nServer: {}\nSite: {}\nUsername: {}".format(args.server, args.sitename, args.username))
tableau_auth = TSC.TableauAuth(args.username, password, site_id=args.sitename)
with server.auth.sign_in(tableau_auth):
print('Logged in successfully')

else:
# Trying to authenticate using personal access tokens.
personal_access_token = input("Personal Access Token: ")
personal_access_token = getpass.getpass("Personal Access Token: ")

print("\nSigning in...\nServer: {}\nSite: {}\nToken name: {}"
.format(args.server, args.sitename, args.token_name))
tableau_auth = TSC.PersonalAccessTokenAuth(token_name=args.token_name,
personal_access_token=personal_access_token, site_id=args.sitename)
with server.auth.sign_in_with_personal_access_token(tableau_auth):
Expand Down
11 changes: 11 additions & 0 deletions tableauserverclient/server/endpoint/views_endpoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,17 @@ def get(self, req_options=None, usage=False):
all_view_items = ViewItem.from_response(server_response.content, self.parent_srv.namespace)
return all_view_items, pagination_item

# Get 1 view by ID
@api(version="2.2")
Copy link
Contributor

Choose a reason for hiding this comment

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

Querying view by ID was introduced with v3.1

def get_by_id(self, view_id):
if not view_id:
error = "View ID undefined."
raise ValueError(error)
logger.info('Querying single view (ID: {0})'.format(view_id))
url = "{0}/{1}".format(self.baseurl, view_id)
server_response = self.get_request(url)
return ViewItem.from_response(server_response.content, self.parent_srv.namespace)[0]

@api(version="2.0")
def populate_preview_image(self, view_item):
if not view_item.id or not view_item.workbook_id:
Expand Down