8000 Encode tag-name before deleting by shinchris · Pull Request #687 · tableau/server-client-python · GitHub
[go: up one dir, main page]

Skip to content

Encode tag-name before deleting #687

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 2 commits into from
Sep 10, 2020
Merged
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
3 changes: 2 additions & 1 deletion tableauserverclient/models/view_item.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from ..datetime_helpers import parse_datetime
from .exceptions import UnpopulatedPropertyError
from .tag_item import TagItem
import copy


class ViewItem(object):
Expand Down Expand Up @@ -158,7 +159,7 @@ def from_xml_element(cls, parsed_response, ns, workbook_id=''):
if tags_elem is not None:
tags = TagItem.from_xml_element(tags_elem, ns)
view_item.tags = tags
view_item._initial_tags = tags
view_item._initial_tags = copy.copy(tags)

all_view_items.append(view_item)
return all_view_items
9 changes: 6 additions & 3 deletions tableauserverclient/server/endpoint/resource_tagger.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from ...models.tag_item import TagItem
import logging
import copy
import urllib.parse

logger = logging.getLogger('tableau.endpoint.resource_tagger')

Expand All @@ -18,21 +19,23 @@ def _add_tags(self, baseurl, resource_id, tag_set):
server_response = self.put_request(url, add_req)
return TagItem.from_response(server_response.content, self.parent_srv.namespace)
except ServerResponseError as e:
if e.code == "404003":
if e.code == "404008":
error = "Adding tags to this resource type is only available with REST API version 2.6 and later."
raise EndpointUnavailableError(error)
raise # Some other error

# Delete a resource's tag by name
def _delete_tag(self, baseurl, resource_id, tag_name):
url = "{0}/{1}/tags/{2}".format(baseurl, resource_id, tag_name)
encoded_tag_name = urllib.parse.quote(tag_name)
url = "{0}/{1}/tags/{2}".format(baseurl, resource_id, encoded_tag_name)

try:
self.delete_request(url)
except ServerResponseError as e:
if e.code == "404003":
if e.code == "404008":
error = "Deleting tags from this resource type is only available with REST API version 2.6 and later."
raise EndpointUnavailableError(error)
raise # Some other error

# Remove and add tags to match the resource item's tag set
def update_tags(self, baseurl, resource_item):
Expand Down
0