-
Notifications
You must be signed in to change notification settings - Fork 421
/
connection_credentials.py
53 lines (40 loc) · 1.52 KB
/
connection_credentials.py
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
from .property_decorators import property_is_boolean
class ConnectionCredentials(object):
"""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.
"""
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