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

Multi-Credential Support in TSC #276

Merged
merged 10 commits into from
Apr 20, 2018
Merged

Conversation

t8y8
Copy link
Collaborator

@t8y8 t8y8 commented Mar 10, 2018

Following on from @marianotn's work, I rebased on top of the latest Development and reorganized a few things for readability and back-compat.

Still need to update tests, I'm probably going to test RequestFactory.Workbook.publish_req specifically, which would be one of the few serializer tests, but I think it's worth the coverage.

Thoughts on the approach? I tried to make it so connections would work older than 2.8, but it was getting really nasty.

I also need to add support to Data Sources too.

@@ -32,11 +32,11 @@ def _safe_to_log(server_response):
'''Checks if the server_response content is not xml (eg binary image or zip)
and and replaces it with a constant
'''
ALLOWED_CONTENT_TYPES = ('application/xml',)
ALLOWED_CONTENT_TYPES = ('application/xml', 'application/xml;charset=utf-8')
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I should allow this type through as well, missed it in first PR

if server_response.headers.get('Content-Type', None) not in ALLOWED_CONTENT_TYPES:
return '[Truncated File Contents]'
else:
return server_response.content
return server_response.content[:300]
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Will remove this.

@@ -231,15 +238,18 @@ def publish(self, workbook_item, file_path, mode, connection_credentials=None):
upload_session_id = Fileuploads.upload_chunks(self.parent_srv, file_path)
url = "{0}&uploadSessionId={1}".format(url, upload_session_id)
xml_request, content_type = RequestFactory.Workbook.publish_req_chunked(workbook_item,
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I need to pipe this through to 'chunked' code paths as well

if connection_credentials is not None and connections is not None:
raise RuntimeError('You cannot set both `connections` and `connection_credentials`')

if connection_credentials is not None:
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is redundant, will remove

return ET.tostring(xml_request)

def _add_connections_element(self, connections_element, connection):
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Can make these static, or move to a helper class for datasources to share

@t8y8
Copy link
Collaborator Author

t8y8 commented Mar 11, 2018

The rabbit hole goes deeper -- I'm adding parsers so we can extract returned values from requests... at least for testing.

@t8y8
Copy link
Collaborator Author

t8y8 commented Mar 12, 2018

Alright, I'm ready to declare this ready for review.

But I realized something: We don't support multi-credential Data Source publish, so you can't publish a federated data source that requires multiple credentials. Only workbooks.

I can leave the code in for data sources and protect that parameter with a parameter_added_in(connections='99.99') so the code is ready for the feature to be added to Server.

Or I can remove it, let me know

@t8y8 t8y8 changed the title [WIP] Multi-Credential Support in TSC Multi-Credential Support in TSC Mar 12, 2018
Copy link
Contributor

@shinchris shinchris left a comment

Choose a reason for hiding this comment

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

🚀

@@ -230,16 +237,21 @@ def publish(self, workbook_item, file_path, mode, connection_credentials=None):
logger.info('Publishing {0} to server with chunking method (workbook over 64MB)'.format(filename))
upload_session_id = Fileuploads.upload_chunks(self.parent_srv, file_path)
url = "{0}&uploadSessionId={1}".format(url, upload_session_id)
conn_creds = 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.

Is conn_creds variable necessary?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Only because of line-length limits 🤷‍♂️


if connection_credentials is not None:
import warnings
warnings.warn("connection_credendials is being deprecated. Use connections instead, see http://...",
Copy link
Contributor

Choose a reason for hiding this comment

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

Typo in connection_credendials. Also I'm not too familiar with connection_credentials but should this warning also be in datasources_endpoint.py?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

If this were supported in Datasources then yes, but it turns out my code is ahead of the curve here, datasources don’t do multi-credential publishing yet.

@t8y8 t8y8 merged commit 48df0ef into tableau:development Apr 20, 2018
@t8y8 t8y8 deleted the 275-feature-multiconn branch April 20, 2018 17:07
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

2 participants