|
9 | 9 | if TYPE_CHECKING: |
10 | 10 | from tableauserverclient.server import Server |
11 | 11 |
|
| 12 | +# this file could be largely replaced if we were willing to import the huge file from generateDS |
| 13 | + |
12 | 14 |
|
13 | 15 | def _add_multipart(parts: Dict) -> Tuple[Any, str]: |
14 | 16 | mime_multipart_parts = list() |
@@ -146,21 +148,28 @@ def update_req(self, database_item): |
146 | 148 |
|
147 | 149 |
|
148 | 150 | class DatasourceRequest(object): |
149 | | - def _generate_xml(self, datasource_item, connection_credentials=None, connections=None): |
| 151 | + def _generate_xml(self, datasource_item: DatasourceItem, connection_credentials=None, connections=None): |
150 | 152 | xml_request = ET.Element("tsRequest") |
151 | 153 | datasource_element = ET.SubElement(xml_request, "datasource") |
152 | | - datasource_element.attrib["name"] = datasource_item.name |
| 154 | + if datasource_item.name: |
| 155 | + datasource_element.attrib["name"] = datasource_item.name |
153 | 156 | if datasource_item.description: |
154 | 157 | datasource_element.attrib["description"] = str(datasource_item.description) |
155 | 158 | if datasource_item.use_remote_query_agent is not None: |
156 | 159 | datasource_element.attrib["useRemoteQueryAgent"] = str(datasource_item.use_remote_query_agent).lower() |
157 | 160 |
|
158 | 161 | if datasource_item.ask_data_enablement: |
159 | 162 | ask_data_element = ET.SubElement(datasource_element, "askData") |
160 | | - ask_data_element.attrib["enablement"] = datasource_item.ask_data_enablement |
| 163 | + ask_data_element.attrib["enablement"] = datasource_item.ask_data_enablement.__str__() |
161 | 164 |
|
162 | | - project_element = ET.SubElement(datasource_element, "project") |
163 | | - project_element.attrib["id"] = datasource_item.project_id |
| 165 | + if datasource_item.certified: |
| 166 | + datasource_element.attrib["isCertified"] = datasource_item.certified.__str__() |
| 167 | + if datasource_item.certification_note: |
| 168 | + datasource_element.attrib["certificationNote"] = datasource_item.certification_note |
| 169 | + |
| 170 | + if datasource_item.project_id: |
| 171 | + project_element = ET.SubElement(datasource_element, "project") |
| 172 | + project_element.attrib["id"] = datasource_item.project_id |
164 | 173 |
|
165 | 174 | if connection_credentials is not None and connections is not None: |
166 | 175 | raise RuntimeError("You cannot set both `connections` and `connection_credentials`") |
|
0 commit comments