Skip to content

Commit

Permalink
More type hinting / definitions. Hunting for an issue with update_pro…
Browse files Browse the repository at this point in the history
…ject not working quite right
  • Loading branch information
Bryant Howell committed Jan 6, 2020
1 parent c327dea commit 4f44efc
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 15 deletions.
6 changes: 3 additions & 3 deletions tableau_rest_api/methods/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ def update_project(self, name_or_luid: str, new_project_name: Optional[str] = No

response = self.send_update_request(url, tsr)
self.end_log_block()
return self.get_published_project_object(project_luid, response)
return self.get_published_project_object(project_name_or_luid=project_luid, project_xml_obj=response)

def delete_projects(self, project_name_or_luid_s: Union[List[str], str]):
self.start_log_block()
Expand Down Expand Up @@ -252,7 +252,7 @@ def update_project(self, name_or_luid: str, parent_project_name_or_luid: Optiona

response = self.send_update_request(url, tsr)
self.end_log_block()
return self.get_published_project_object(project_luid, response)
return self.get_published_project_object(project_name_or_luid=project_luid, project_xml_obj=response)

def query_project(self, project_name_or_luid: str) -> Project28:

Expand Down Expand Up @@ -379,7 +379,7 @@ def update_project(self, name_or_luid: str, parent_project_name_or_luid: Optiona

response = self.send_update_request(url, tsr)
self.end_log_block()
return self.get_published_project_object(project_luid, response)
return self.get_published_project_object(project_name_or_luid=project_luid, project_xml_obj=response)

class ProjectMethods34(ProjectMethods33):
def __init__(self, rest_api_base: TableauRestApiBase34):
Expand Down
30 changes: 18 additions & 12 deletions tableau_rest_api/published_content.py
Original file line number Diff line number Diff line change
Expand Up @@ -659,8 +659,9 @@ def convert_capabilities_xml_into_obj_list(xml_obj: ET.Element) -> List['Datasou
return obj_list

class Datasource28(Datasource):
def __init__(self, luid, tableau_rest_api_obj, default=False, logger_obj=None,
content_xml_obj=None):
def __init__(self, luid: str, tableau_rest_api_obj: Union['TableauRestApiConnection', 'TableauServerRest'],
default: bool = False, logger_obj: Optional[Logger] = None,
content_xml_obj: Optional[ET.Element] = None):
Datasource.__init__(self, luid=luid, tableau_rest_api_obj=tableau_rest_api_obj,
default=default, logger_obj=logger_obj, content_xml_obj=content_xml_obj)
self.__available_capabilities = Permissions.available_capabilities[self.api_version]["datasource"]
Expand All @@ -672,8 +673,9 @@ def get_permissions_obj(self, group_name_or_luid: Optional[str] = None, username
role=role)

class View(PublishedContent):
def __init__(self, luid, tableau_rest_api_obj, default=False, logger_obj=None,
content_xml_obj=None):
def __init__(self, luid: str, tableau_rest_api_obj: Union['TableauRestApiConnection', 'TableauServerRest'],
default: bool = False, logger_obj: Optional[Logger] = None,
content_xml_obj: Optional[ET.Element] = None):
PublishedContent.__init__(self, luid, "view", tableau_rest_api_obj,
default=default, logger_obj=logger_obj, content_xml_obj=content_xml_obj)
self.__available_capabilities = Permissions.available_capabilities[self.api_version]["workbook"]
Expand Down Expand Up @@ -763,10 +765,12 @@ def get_permissions_obj(self, group_name_or_luid: Optional[str] = None, username


class Project(PublishedContent):
def __init__(self, luid, tableau_rest_api_obj, logger_obj=None,
content_xml_obj=None):
PublishedContent.__init__(self, luid, "project", tableau_rest_api_obj,
def __init__(self, luid: str, tableau_rest_api_obj: Union['TableauRestApiConnection', 'TableauServerRest'],
logger_obj: Optional[Logger] = None, content_xml_obj: Optional[ET.Element] = None):
PublishedContent.__init__(self, luid=luid, obj_type="project", tableau_rest_api_obj=tableau_rest_api_obj,
logger_obj=logger_obj, content_xml_obj=content_xml_obj)
self.log('Building Project object from this XML: ')
self.log_xml_response(content_xml_obj)
# projects in 9.2 have child workbook and datasource permissions
self._workbook_defaults = Workbook(self.luid, self.t_rest_api,
default=True, logger_obj=logger_obj)
Expand All @@ -783,7 +787,7 @@ def luid(self):
return self._luid

@luid.setter
def luid(self, name_or_luid):
def luid(self, name_or_luid: str):
if TableauRestXml.is_luid(name_or_luid):
luid = name_or_luid
else:
Expand Down Expand Up @@ -1032,8 +1036,9 @@ def convert_all_permissions_to_list(self, all_permissions: Dict):


class Project28(Project):
def __init__(self, luid, tableau_rest_api_obj, logger_obj=None,
content_xml_obj=None, parent_project_luid=None):
def __init__(self, luid: str, tableau_rest_api_obj: Union['TableauRestApiConnection', 'TableauServerRest'],
logger_obj: Optional[Logger] = None,
content_xml_obj: Optional[ET.Element] = None, parent_project_luid: Optional[str] = None):
Project.__init__(self, luid=luid, tableau_rest_api_obj=tableau_rest_api_obj, logger_obj=logger_obj,
content_xml_obj=content_xml_obj)
self._parent_project_luid = parent_project_luid
Expand Down Expand Up @@ -1121,8 +1126,9 @@ def create_datasource_permissions_object_for_user(self, username_or_luid: str,


class Project33(Project28):
def __init__(self, luid, tableau_rest_api_obj, logger_obj=None,
content_xml_obj=None, parent_project_luid=None):
def __init__(self, luid: str, tableau_rest_api_obj: Union['TableauRestApiConnection', 'TableauServerRest'],
logger_obj: Optional[Logger] = None, content_xml_obj: Optional[ET.Element] = None,
parent_project_luid:str = None):
Project28.__init__(self, luid=luid, tableau_rest_api_obj=tableau_rest_api_obj, logger_obj=logger_obj,
content_xml_obj=content_xml_obj, parent_project_luid=parent_project_luid)
self.flow_defaults = Flow33(self.luid, self.t_rest_api, default=True, logger_obj=logger_obj)
Expand Down

0 comments on commit 4f44efc

Please sign in to comment.