8000 #4 rename common keywords and reorder properties on item classes by shinchris · Pull Request #13 · tableau/server-client-python · GitHub
[go: up one dir, main page]

Skip to content

#4 re 8000 name common keywords and reorder properties on item classes #13

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 3 commits into from
Sep 7, 2016
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
17 changes: 17 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
language: python
Copy link
Collaborator

Choose a reason for hiding this comment

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

All of your PRs have this commit, which is causing merge conflicts, it'll need to be removed from these branches I think

Copy link
Contributor

Choose a reason for hiding this comment

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

Hey @t8y8 this is a product of the rebasing usually if you don't force push to the branch, I'll take a look at Chris' changes on his machine when he gets in to make sure

python:
- "2.7"
- "3.3"
- "3.4"
- "3.5"
- "pypy"
# command to install dependencies
install:
- "pip install -e ."
# - "pip install pep8"
# command to run tests
script:
# Tests
- python setup.py test
# pep8 - disabled for now until we can scrub the files to make sure we pass before turning it on
# - pep8 .
24 changes: 12 additions & 12 deletions tableauserverapi/models/connection_item.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,15 @@

class ConnectionItem(object):
def __init__(self):
self._id = None
self._type = None
self._datasource_id = None
self._datasource_name = None
self._id = None
self._type = None
self.embed_password = None
self.password = None
self.server_address = None
self.server_port = None
self.username = None
self.password = None
self.embed_password = None

@property
def id(self):
return self._id

@property
def type(self):
return self._type

@property
def datasource_id(self):
Expand All @@ -30,6 +22,14 @@ def datasource_id(self):
def datasource_name(self):
return self._datasource_name

@property
def id(self):
return self._id

@property
def type(self):
return self._type

@classmethod
def from_response(cls, resp):
all_connection_items = list()
Expand Down
90 changes: 46 additions & 44 deletions tableauserverapi/models/datasource_item.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,38 +6,27 @@

class DatasourceItem(object):
def __init__(self, project_id, name=None):
self._connections = None
self._content_url = None
self._created_at = None
self._id = None
self._project_id = None
self._project_name = None
self._tags = set()
self._type = None
self._updated_at = None
self._connections = None
self._project_id = None
self.owner_id = None
self.project_id = project_id
self.name = name
self.owner_id = None

@property
def project_id(self):
return self._project_id

@project_id.setter
def project_id(self, value):
if value is None:
error = 'Project ID must be defined.'
raise ValueError(error)
else:
self._project_id = value

@property
def id(self):
return self._id
# Invoke setter
self.project_id = project_id

@property
def type(self):
return self._type
def connections(self):
if self._connections is None:
Copy link
Collaborator

Choose a reason for hiding this comment

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

This all seems fine, but I'm not sure it's related to the title of the PR?

error = 'Datasource item must be populated with connections first.'
raise UnpopulatedPropertyError(error)
return self._connections

@property
def content_url(self):
Expand All @@ -48,8 +37,20 @@ def created_at(self):
return self._created_at

@property
def updated_at(self):
return self._updated_at
def id(self):
return self._id

@property
def project_id(self):
return self._project_id

@project_id.setter
def project_id(self, value):
if value is None:
error = 'Project ID must be defined.'
raise ValueError(error)
else:
self._project_id = value

@property
def project_name(self):
Expand All @@ -60,30 +61,16 @@ def tags(self):
return self._tags

@property
def connections(self):
if self._connections is None:
error = 'Datasource item must be populated with connections first.'
raise UnpopulatedPropertyError(error)
return self._connections
def type(self):
return self._type

@property
def updated_at(self):
return self._updated_at

def _set_connections(self, connections):
self._connections = connections

@classmethod
def from_response(cls, resp):
all_datasource_items = list()
parsed_response = ET.fromstring(resp)
all_datasource_xml = parsed_response.findall('.//t:datasource', namespaces=NAMESPACE)

for datasource_xml in all_datasource_xml:
(id, name, type, content_url, created_at, updated_at,
tags, project_id, project_name, owner_id) = cls._parse_element(datasource_xml)
datasource_item = cls(project_id)
datasource_item._set_values(id, name, type, content_url, created_at, updated_at,
tags, None, project_name, owner_id)
all_datasource_items.append(datasource_item)
return all_datasource_items

def _parse_common_tags(self, datasource_xml):
if not isinstance(datasource_xml, ET.Element):
datasource_xml = ET.fromstring(datasource_xml).find('.//t:datasource', namespaces=NAMESPACE)
Expand Down Expand Up @@ -115,6 +102,21 @@ def _set_values(self, id, name, type, content_url, created_at,
if owner_id:
self.owner_id = owner_id

@classmethod
def from_response(cls, resp):
all_datasource_items = list()
parsed_response = ET.fromstring(resp)
all_datasource_xml = parsed_response.findall('.//t:datasource', namespaces=NAMESPACE)

for datasource_xml in all_datasource_xml:
(id, name, type, content_url, created_at, updated_at,
tags, project_id, project_name, owner_id) = cls._parse_element(datasource_xml)
datasource_item = cls(project_id)
datasource_item._set_values(id, name, type, content_url, created_at, updated_at,
tags, None, project_name, owner_id)
all_datasource_items.append(datasource_item)
return all_datasource_items

@staticmethod
def _parse_element(datasource_xml):
id = datasource_xml.get('id', None)
Expand All @@ -141,4 +143,4 @@ def _parse_element(datasource_xml):
if owner_elem is not None:
owner_id = owner_elem.get('id', None)

return id, name, type, content_url, created_at, updated_at, tags, project_id, project_name, owner_id
return id, name, type, content_url, created_at, updated_at, tags, project_id, project_name, owner_id
2 changes: 1 addition & 1 deletion tableauserverapi/models/fileupload_item.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

class FileuploadItem(object):
def __init__(self):
self._upload_session_id = None
self._file_size = None
self._upload_session_id = None

@property
def upload_session_id(self):
Expand Down
22 changes: 12 additions & 10 deletions tableauserverapi/models/group_item.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,22 @@

class GroupItem(object):
def __init__(self, name):
self._id = None
self._domain_name = None
self._users = None
self._id = None
self._name = None
self._users = None

# Invoke setter
self.name = name

@property
def domain_name(self):
return self._domain_name

@property
def id(self):
return self._id

@property
def name(self):
return self._name
Expand All @@ -23,14 +33,6 @@ def name(self, value):
else:
self._name = value

@property
def id(self):
return self._id

@property
def domain_name(self):
return self._domain_name

@property
def users(self):
if self._users is None:
Expand Down
8 changes: 4 additions & 4 deletions tableauserverapi/models/pagination_item.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,6 @@ def __init__(self):
self._page_size = None
self._total_available = None

@property
def total_available(self):
return self._total_available

@property
def page_number(self):
return self._page_number
Expand All @@ -20,6 +16,10 @@ def page_number(self):
def page_size(self):
return self._page_size

@property
def total_available(self):
return self._total_available

@classmethod
def from_response(cls, resp):
parsed_response = ET.fromstring(resp)
Expand Down
56 changes: 29 additions & 27 deletions tableauserverapi/models/project_item.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,32 +8,19 @@ class ContentPermissions:
ManagedByOwner = 'ManagedByOwner'

def __init__(self, name, description=None, content_permissions=None):
self._id = None
self._content_permissions = None
self._id = None
self._name = None
self.description = description

# Invoke setter
self.name = name

if content_permissions:
# In order to invoke the setter method to validate content_permissions,
# _content_permissions must be initialized first.
self.content_permissions = content_permissions

def is_default(self):
return self.name.lower() == 'default'

@property
def name(self):
return self._name

@name.setter
def name(self, value):
if not value:
error = 'Name must be defined.'
raise ValueError(error)
else:
self._name = value

@property
def content_permissions(self):
return self._content_permissions
Expand All @@ -50,18 +37,20 @@ def content_permissions(self, value):
def id(self):
return self._id

@classmethod
def from_response(cls, resp):
all_project_items = list()
parsed_response = ET.fromstring(resp)
all_project_xml = parsed_response.findall('.//t:project', namespaces=NAMESPACE)
@property
def name(self):
return self._name

for project_xml in all_project_xml:
(id, name, description, content_permissions) = cls._parse_element(project_xml)
project_item = cls(name)
project_item._set_values(id, name, description, content_permissions)
all_project_items.append(project_item)
return all_project_items
@name.setter
def name(self, value):
if not value:
error = 'Name must be defined.'
raise ValueError(error)
else:
self._name = value

def is_default(self):
return self.name.lower() == 'default'

def _parse_common_tags(self, project_xml):
if not isinstance(project_xml, ET.Element):
Expand All @@ -82,6 +71,19 @@ def _set_values(self, project_id, name, description, content_permissions):
if content_permissions:
self._content_permissions = content_permissions

@classmethod
def from_response(cls, resp):
all_project_items = list()
parsed_response = ET.fromstring(resp)
all_project_xml = parsed_response.findall('.//t:project', namespaces=NAMESPACE)

for project_xml in all_project_xml:
(id, name, description, content_permissions) = cls._parse_element(project_xml)
project_item = cls(name)
project_item._set_values(id, name, description, content_permissions)
all_project_items.append(project_item)
return all_project_items

@staticmethod
def _parse_element(project_xml):
id = project_xml.get('id', None)
Expand Down
Loading
0