From de6891901accd437b1bcd9818c8ba151b92e9ef5 Mon Sep 17 00:00:00 2001 From: Tyler Mairose Date: Thu, 6 Feb 2025 16:52:36 -0500 Subject: [PATCH] Update Python SDK to handle xml response types --- requirements.txt | 1 + sailpoint/beta/api_client.py | 3 +++ sailpoint/beta/test/test_account_usage.py | 2 +- .../test/test_non_employee_request_without_approval_item.py | 4 ++-- sailpoint/beta/test/test_source_usage.py | 2 +- sailpoint/v2024/api_client.py | 3 +++ sailpoint/v2024/test/test_account_usage.py | 2 +- .../test/test_non_employee_request_without_approval_item.py | 4 ++-- sailpoint/v2024/test/test_source_usage.py | 2 +- sailpoint/v3/api_client.py | 3 +++ sailpoint/v3/test/test_account_usage.py | 2 +- .../test/test_non_employee_request_without_approval_item.py | 4 ++-- sailpoint/v3/test/test_source_usage.py | 2 +- sdk-resources/resources/api_client.mustache | 3 +++ setup.py | 2 +- 15 files changed, 26 insertions(+), 13 deletions(-) diff --git a/requirements.txt b/requirements.txt index c86a1f3eb..e11444ec9 100644 --- a/requirements.txt +++ b/requirements.txt @@ -5,3 +5,4 @@ pydantic >= 2 aenum >= 3.1.11 mypy>=1.4.1 types-python-dateutil>=2.8.19 +xmltodict>=0.14.2 diff --git a/sailpoint/beta/api_client.py b/sailpoint/beta/api_client.py index 548edf66c..ca549458b 100644 --- a/sailpoint/beta/api_client.py +++ b/sailpoint/beta/api_client.py @@ -21,6 +21,7 @@ import os import re import tempfile +import xmltodict from urllib.parse import quote from typing import Tuple, Optional, List, Dict, Union @@ -427,6 +428,8 @@ def deserialize(self, response_text: str, response_type: str, content_type: Opti data = "" else: data = json.loads(response_text) + elif content_type.startswith("application/xml") or content_type.startswith("text/xml"): + data = xmltodict.parse(response_text) elif content_type.startswith("text/plain"): data = response_text else: diff --git a/sailpoint/beta/test/test_account_usage.py b/sailpoint/beta/test/test_account_usage.py index b77fe281a..a5644bea7 100644 --- a/sailpoint/beta/test/test_account_usage.py +++ b/sailpoint/beta/test/test_account_usage.py @@ -35,7 +35,7 @@ def make_instance(self, include_optional) -> AccountUsage: model = AccountUsage() if include_optional: return AccountUsage( - var_date = 'Fri Apr 21 00:00:00 UTC 2023', + var_date = 'Thu Apr 20 20:00:00 EDT 2023', count = 10 ) else: diff --git a/sailpoint/beta/test/test_non_employee_request_without_approval_item.py b/sailpoint/beta/test/test_non_employee_request_without_approval_item.py index 37371dd12..3570b285d 100644 --- a/sailpoint/beta/test/test_non_employee_request_without_approval_item.py +++ b/sailpoint/beta/test/test_non_employee_request_without_approval_item.py @@ -50,8 +50,8 @@ def make_instance(self, include_optional) -> NonEmployeeRequestWithoutApprovalIt approval_status = 'APPROVED', comment = 'approved', completion_date = '2020-03-24T11:11:41.139-05:00', - start_date = 'Tue Mar 24 00:00:00 UTC 2020', - end_date = 'Thu Mar 25 00:00:00 UTC 2021', + start_date = 'Mon Mar 23 20:00:00 EDT 2020', + end_date = 'Wed Mar 24 20:00:00 EDT 2021', modified = '2020-03-24T11:11:41.139-05:00', created = '2020-03-24T11:11:41.139-05:00' ) diff --git a/sailpoint/beta/test/test_source_usage.py b/sailpoint/beta/test/test_source_usage.py index 3047bab8c..16baffc28 100644 --- a/sailpoint/beta/test/test_source_usage.py +++ b/sailpoint/beta/test/test_source_usage.py @@ -35,7 +35,7 @@ def make_instance(self, include_optional) -> SourceUsage: model = SourceUsage() if include_optional: return SourceUsage( - var_date = 'Fri Apr 21 00:00:00 UTC 2023', + var_date = 'Thu Apr 20 20:00:00 EDT 2023', count = 10.45 ) else: diff --git a/sailpoint/v2024/api_client.py b/sailpoint/v2024/api_client.py index c1dd81378..df9160e65 100644 --- a/sailpoint/v2024/api_client.py +++ b/sailpoint/v2024/api_client.py @@ -21,6 +21,7 @@ import os import re import tempfile +import xmltodict from urllib.parse import quote from typing import Tuple, Optional, List, Dict, Union @@ -427,6 +428,8 @@ def deserialize(self, response_text: str, response_type: str, content_type: Opti data = "" else: data = json.loads(response_text) + elif content_type.startswith("application/xml") or content_type.startswith("text/xml"): + data = xmltodict.parse(response_text) elif content_type.startswith("text/plain"): data = response_text else: diff --git a/sailpoint/v2024/test/test_account_usage.py b/sailpoint/v2024/test/test_account_usage.py index 36baa784d..3896c566f 100644 --- a/sailpoint/v2024/test/test_account_usage.py +++ b/sailpoint/v2024/test/test_account_usage.py @@ -35,7 +35,7 @@ def make_instance(self, include_optional) -> AccountUsage: model = AccountUsage() if include_optional: return AccountUsage( - var_date = 'Fri Apr 21 00:00:00 UTC 2023', + var_date = 'Thu Apr 20 20:00:00 EDT 2023', count = 10 ) else: diff --git a/sailpoint/v2024/test/test_non_employee_request_without_approval_item.py b/sailpoint/v2024/test/test_non_employee_request_without_approval_item.py index d577f1e79..afdcd793f 100644 --- a/sailpoint/v2024/test/test_non_employee_request_without_approval_item.py +++ b/sailpoint/v2024/test/test_non_employee_request_without_approval_item.py @@ -50,8 +50,8 @@ def make_instance(self, include_optional) -> NonEmployeeRequestWithoutApprovalIt approval_status = 'APPROVED', comment = 'approved', completion_date = '2020-03-24T11:11:41.139-05:00', - start_date = 'Tue Mar 24 00:00:00 UTC 2020', - end_date = 'Thu Mar 25 00:00:00 UTC 2021', + start_date = 'Mon Mar 23 20:00:00 EDT 2020', + end_date = 'Wed Mar 24 20:00:00 EDT 2021', modified = '2020-03-24T11:11:41.139-05:00', created = '2020-03-24T11:11:41.139-05:00' ) diff --git a/sailpoint/v2024/test/test_source_usage.py b/sailpoint/v2024/test/test_source_usage.py index 017e3fef6..0749dfc52 100644 --- a/sailpoint/v2024/test/test_source_usage.py +++ b/sailpoint/v2024/test/test_source_usage.py @@ -35,7 +35,7 @@ def make_instance(self, include_optional) -> SourceUsage: model = SourceUsage() if include_optional: return SourceUsage( - var_date = 'Fri Apr 21 00:00:00 UTC 2023', + var_date = 'Thu Apr 20 20:00:00 EDT 2023', count = 10.45 ) else: diff --git a/sailpoint/v3/api_client.py b/sailpoint/v3/api_client.py index 07331e83f..1d1ef4b1a 100644 --- a/sailpoint/v3/api_client.py +++ b/sailpoint/v3/api_client.py @@ -21,6 +21,7 @@ import os import re import tempfile +import xmltodict from urllib.parse import quote from typing import Tuple, Optional, List, Dict, Union @@ -427,6 +428,8 @@ def deserialize(self, response_text: str, response_type: str, content_type: Opti data = "" else: data = json.loads(response_text) + elif content_type.startswith("application/xml") or content_type.startswith("text/xml"): + data = xmltodict.parse(response_text) elif content_type.startswith("text/plain"): data = response_text else: diff --git a/sailpoint/v3/test/test_account_usage.py b/sailpoint/v3/test/test_account_usage.py index cd8ce5991..f7f07a27f 100644 --- a/sailpoint/v3/test/test_account_usage.py +++ b/sailpoint/v3/test/test_account_usage.py @@ -35,7 +35,7 @@ def make_instance(self, include_optional) -> AccountUsage: model = AccountUsage() if include_optional: return AccountUsage( - var_date = 'Fri Apr 21 00:00:00 UTC 2023', + var_date = 'Thu Apr 20 20:00:00 EDT 2023', count = 10 ) else: diff --git a/sailpoint/v3/test/test_non_employee_request_without_approval_item.py b/sailpoint/v3/test/test_non_employee_request_without_approval_item.py index 7fe7afc14..3b69ed401 100644 --- a/sailpoint/v3/test/test_non_employee_request_without_approval_item.py +++ b/sailpoint/v3/test/test_non_employee_request_without_approval_item.py @@ -50,8 +50,8 @@ def make_instance(self, include_optional) -> NonEmployeeRequestWithoutApprovalIt approval_status = 'APPROVED', comment = 'approved', completion_date = '2020-03-24T11:11:41.139-05:00', - start_date = 'Tue Mar 24 00:00:00 UTC 2020', - end_date = 'Thu Mar 25 00:00:00 UTC 2021', + start_date = 'Mon Mar 23 20:00:00 EDT 2020', + end_date = 'Wed Mar 24 20:00:00 EDT 2021', modified = '2020-03-24T11:11:41.139-05:00', created = '2020-03-24T11:11:41.139-05:00' ) diff --git a/sailpoint/v3/test/test_source_usage.py b/sailpoint/v3/test/test_source_usage.py index e1dcaa569..ecf5f3112 100644 --- a/sailpoint/v3/test/test_source_usage.py +++ b/sailpoint/v3/test/test_source_usage.py @@ -35,7 +35,7 @@ def make_instance(self, include_optional) -> SourceUsage: model = SourceUsage() if include_optional: return SourceUsage( - var_date = 'Fri Apr 21 00:00:00 UTC 2023', + var_date = 'Thu Apr 20 20:00:00 EDT 2023', count = 10.45 ) else: diff --git a/sdk-resources/resources/api_client.mustache b/sdk-resources/resources/api_client.mustache index e8745a3eb..5c6f40291 100644 --- a/sdk-resources/resources/api_client.mustache +++ b/sdk-resources/resources/api_client.mustache @@ -11,6 +11,7 @@ import mimetypes import os import re import tempfile +import xmltodict from urllib.parse import quote from typing import Tuple, Optional, List, Dict, Union @@ -435,6 +436,8 @@ class ApiClient: data = "" else: data = json.loads(response_text) + elif content_type.startswith("application/xml") or content_type.startswith("text/xml"): + data = xmltodict.parse(response_text) elif content_type.startswith("text/plain"): data = response_text else: diff --git a/setup.py b/setup.py index ab573ee9a..671249816 100644 --- a/setup.py +++ b/setup.py @@ -18,7 +18,7 @@ PYTHON_REQUIRES = ">=3.7" REQUIRES = [ "urllib3 >= 1.25.3, < 2.1.0", "python-dateutil", "pydantic >= 2", - "typing-extensions >= 4.7.1", + "typing-extensions >= 4.7.1", "xmltodict>=0.14.2" ] setup(