-
Notifications
You must be signed in to change notification settings - Fork 447
Expand file tree
/
Copy pathconnection_credentials.py
More file actions
69 lines (52 loc) · 2.02 KB
/
connection_credentials.py
File metadata and controls
69 lines (52 loc) · 2.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
from .property_decorators import property_is_boolean
class ConnectionCredentials:
"""
Connection Credentials for Workbooks and Datasources publish request.
Consider removing this object and other variables holding secrets
as soon as possible after use to avoid them hanging around in memory.
Parameters
----------
name: str
The username for the connection.
password: str
The password used for the connection.
embed: bool, default True
Determines whether to embed the password (True) for the workbook or data source connection or not (False).
oauth: bool, default False
Determines whether to use OAuth for the connection (True) or not (False).
For more information see: https://help.tableau.com/current/server/en-us/protected_auth.htm
"""
def __init__(self, name, password, embed=True, oauth=False):
self.name = name
self.password = password
self.embed = embed
self.oauth = oauth
def __repr__(self):
if self.password:
print = "redacted"
else:
print = "None"
return f"<{self.__class__.__name__} name={self.name} password={print} embed={self.embed} oauth={self.oauth} >"
@property
def embed(self):
return self._embed
@embed.setter
@property_is_boolean
def embed(self, value):
self._embed = value
@property
def oauth(self):
return self._oauth
@oauth.setter
@property_is_boolean
def oauth(self, value):
self._oauth = value
@classmethod
def from_xml_element(cls, parsed_response, ns):
connection_creds_xml = parsed_response.find(".//t:connectionCredentials", namespaces=ns)
name = connection_creds_xml.get("name", None)
password = connection_creds_xml.get("password", None)
embed = connection_creds_xml.get("embed", None)
oAuth = connection_creds_xml.get("oAuth", None)
connection_creds = cls(name, password, embed, oAuth)
return connection_creds