Skip to content
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

Add connection credentials #80

Merged
merged 12 commits into from Oct 27, 2016

Conversation

geordielad
Copy link
Contributor

No description provided.

@graysonarts
Copy link
Contributor

Something about your changes are breaking tests to a point where they cannot run at all. Also, there is a merge conflict because I believe you based your changes on master and not development.

To resolve this in your fork, can you do the following:

git checkout master
git checkout -b development
git pull origin development
git checkout Add-Connection-Credentials # or whatever your branch name is locally
git rebase development

This last command will retarget your changes against development, but will probably require you to address merge conflicts along the way. If you aren't familiar with git, it can be daunting. https://help.github.com/articles/resolving-merge-conflicts-after-a-git-rebase/ provides a brief overview of how to fix the merge conflicts that may happen.

Then you'll need to repush your branch to github. To do this you will need to do git push --force origin Add-Connection-Credentials in order to update the PR.

Let me know if you have any questions.

@geordielad
Copy link
Contributor Author

I think I have fixed the conflict. Do I need to do a new pull request now?

@geordielad geordielad closed this Oct 27, 2016
@geordielad geordielad reopened this Oct 27, 2016
@geordielad
Copy link
Contributor Author

Commenting seemed to closed the pull request Lets try that again.

@graysonarts
Copy link
Contributor

Robin, looks like there is still a merge conflict. Did you rebase against development? that should have allowed you to fix the conflict for it to work in Github.

You don't need to create a new PR, the existing PR gets updated with your new commits when you push to your fork's branch.

Allow users to add connection credentials to Datasources and workbook
publish requests. Should work for smaller requests and chunked requests
@geordielad
Copy link
Contributor Author

Last time I aborted the rebase. Now I rand the rebase steps. fixed the conflict, added the changed file then did rebase continue then the git push

@geordielad
Copy link
Contributor Author

I see the tests failing because of coding style. Lets see if I can fix that

The command "python setup.py test" exited with 0.
1.27s$ pycodestyle .
./tableauserverclient/__init__.py:10:26: W292 no newline at end of file
./tableauserverclient/server/request_factory.py:40:67: E231 missing
whitespace after ','
./tableauserverclient/server/request_factory.py:268:42: E231 missing
whitespace after ','
./tableauserverclient/server/request_factory.py:277:65: E231 missing
whitespace after ','
./tableauserverclient/server/endpoint/datasources_endpoint.py:125:121:
E501 line too long (126 > 120 characters)
./tableauserverclient/server/endpoint/workbooks_endpoint.py:174:121:
E501 line too long (122 > 120 characters)
@graysonarts
Copy link
Contributor

Rad! Looks like it can merge correctly! Thanks! I'll take a look right now

Copy link
Contributor

@graysonarts graysonarts left a comment

Choose a reason for hiding this comment

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

Straight forward implementation. We'll need to add some tests before release next week, but should be easy enough to tackle. Thanks! 🚀

xml_request = ET.Element('tsRequest')
datasource_element = ET.SubElement(xml_request, 'datasource')
datasource_element.attrib['name'] = datasource_item.name
project_element = ET.SubElement(datasource_element, 'project')
project_element.attrib['id'] = datasource_item.project_id
if connection_credentials:
Copy link
Contributor

Choose a reason for hiding this comment

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

(not a shipblocker)
Since this is common code, we might consider pulling this into its own helper method.

Copy link
Collaborator

@t8y8 t8y8 left a comment

Choose a reason for hiding this comment

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

A few minor things, and then can you add a test that covers this element?

I think a test in test_workbooks and do a publish where you check that this serialized properly would be fine.

EDIT: @RussTheAerialist said tests can come from a different PR, I'm OK with that (since we don't have serializer tests, I think I can actually do that PR, I have an idea)

credentials_element = ET.SubElement(workbook_element, 'connectionCredentials')
credentials_element.attrib['name'] = connection_credentials.name
credentials_element.attrib['password'] = connection_credentials.password
credentials_element.attrib['embed'] = str(connection_credentials.embed).lower()
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can you do a more explicit assignment instead of relying on str(True).lower() == 'true'?

credentials_element.attrib['embed'] = 'true' if connection_credentials.embed else 'false'

Or even more explicit

if connection_credentials.embed:
    credentials_element.attrib['embed'] = 'true'
else:
    credentials_element.attrib['embed'] = 'false'

@@ -0,0 +1,5 @@
class ConnectionCredentials(object):
def __init__(self, name, password, embed=True):
self.password = password
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nit: Reorder these to match the order in the function signature

Copy link
Contributor Author

Choose a reason for hiding this comment

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

if I fix order of property set in credentials do you want me to fix auth while I am doing it as I copied the code for this class from auth. New code would be

class TableauAuth(object):
    def __init__(self, username, password, site='', user_id_to_impersonate=None):
        self.username = username
        self.password = password
        self.site = site
        self.user_id_to_impersonate = user_id_to_impersonate

@@ -0,0 +1,5 @@
class ConnectionCredentials(object):
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can you add a docstring on this class that tells users they should delete this object when they're done using it?

Explicit convert of boolean to true/false string
Ordering of class properties to match signature
Docstring on connection credentials and auth classes
def __init__(self, name, password, embed=True):
self.name = name
Copy link
Collaborator

Choose a reason for hiding this comment

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

indenting got all messed up here -- maybe it's tabs instead of 4 spaces?

@t8y8
Copy link
Collaborator

t8y8 commented Oct 27, 2016

Almost there @geordielad

./tableauserverclient/models/connection_credentials.py:4:1: W191 indentation contains tabs
./tableauserverclient/models/connection_credentials.py:4:67: W291 trailing whitespace
./tableauserverclient/models/connection_credentials.py:5:1: W191 indentation contains tabs
./tableauserverclient/models/connection_credentials.py:7:1: W191 indentation contains tabs
./tableauserverclient/models/connection_credentials.py:8:5: E901 IndentationError: unindent does not match any outer indentation level

Looks like your editor is using tabs instead of 4 spaces -- if using Sublime you can fix that in View > Indentation > Convert Tabs to Spaces

"""Connection Credentials for Workbooks and Datasources publish request.

Consider removing this object and other variables holding secrets
as soon as poobible after use to avoid them hanging around in memory.
Copy link
Collaborator

Choose a reason for hiding this comment

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

possible

@t8y8
Copy link
Collaborator

t8y8 commented Oct 27, 2016

🚀

@t8y8
Copy link
Collaborator

t8y8 commented Oct 27, 2016

Nah, it's ok to limit your PR to just your code for now. This is more
preventative maintenance... That'll get cleaned up the next time we visit
it :)

On Oct 27, 2016 12:22, "geordielad" notifications@github.com wrote:

@geordielad commented on this pull request.

In tableauserverclient/models/connection_credentials.py
#80:

@@ -0,0 +1,5 @@
+class ConnectionCredentials(object):

  • def init(self, name, password, embed=True):
  •    self.password = password
    

if I fix order of property set in credentials do you want me to fix auth
while I am doing it as I copied the code for this class from auth. New code
would be

class TableauAuth(object):
def init(self, username, password, site='',
user_id_to_impersonate=None):
self.username = username
self.password = password
self.site = site
self.user_id_to_impersonate = user_id_to_impersonate


You are receiving this because you commented.
Reply to this email directly, view it on GitHub
#80, or mute the
thread
https://github.com/notifications/unsubscribe-auth/AEKwZVKly-3MvU2EfR8snDTKOk1FyMUYks5q4PnagaJpZM4Khx53
.

@LGraber
Copy link
Contributor

LGraber commented Oct 27, 2016

taking a look now

def __init__(self, name, password, embed=True):
self.name = name
self.password = password
self.embed = embed
Copy link
Contributor

Choose a reason for hiding this comment

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

Please make this an explicit property and add the property_is_boolean decorator

if connection_credentials.embed:
credentials_element.attrib['embed'] = 'true'
else:
credentials_element.attrib['embed'] = 'false'
Copy link
Contributor

Choose a reason for hiding this comment

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

I believe credentials_"element.attrib['embed'] = str(connection_credentials).lower()" is all you need and you can ditch the if/else. Especially after adding the check that embed is a boolean in the credentials object

Copy link
Collaborator

@t8y8 t8y8 Oct 27, 2016

Choose a reason for hiding this comment

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

I asked him to not do that because I don't like relying on the str value, what if someone passes in an overridden True?

This makes it explicit what two values are allowed from reading the serializer

(And, minor edge case, but in PY2, True/False can be reassigned, you could make True == '3')

@LGraber
Copy link
Contributor

LGraber commented Oct 27, 2016

Made two small requests:

  1. Type safety on the 'embed' member
  2. With that you can simplify your serialization code.

@LGraber
Copy link
Contributor

LGraber commented Oct 27, 2016

what is an "overriden true"? If you don't want that, then I would prefer:
element.attrib['embed'] = 'true' if connection_credentials.embed else 'false'

I don't like 4 lines of code cause it is too bulky.

@graysonarts
Copy link
Contributor

Under python3, you need to use relative imports

from .property_decorators import [things to import]

Copy link
Contributor

@graysonarts graysonarts left a comment

Choose a reason for hiding this comment

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

🚀

Copy link
Collaborator

@t8y8 t8y8 left a comment

Choose a reason for hiding this comment

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

🚀

@LGraber
Copy link
Contributor

LGraber commented Oct 27, 2016

🚀

@graysonarts graysonarts merged commit 7c41a0a into tableau:development Oct 27, 2016
bryceglarsen pushed a commit to bryceglarsen/server-client-python that referenced this pull request Dec 28, 2023
bryceglarsen pushed a commit to bryceglarsen/server-client-python that referenced this pull request Dec 28, 2023
bryceglarsen pushed a commit to bryceglarsen/server-client-python that referenced this pull request Dec 28, 2023
* Updating link in readme

We renamed Examples to samples, but forgot to update the readme.

* Adding tableau#80 to changelog
bryceglarsen pushed a commit to bryceglarsen/server-client-python that referenced this pull request Dec 28, 2023
bryceglarsen pushed a commit to bryceglarsen/server-client-python that referenced this pull request Dec 28, 2023
bryceglarsen pushed a commit to bryceglarsen/server-client-python that referenced this pull request Dec 28, 2023
* Updating link in readme

We renamed Examples to samples, but forgot to update the readme.

* Adding tableau#80 to changelog
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants