From 63a9a58fb958eff0aa55119082ad08b3123eb3a7 Mon Sep 17 00:00:00 2001 From: Sherzod Karimov Date: Wed, 26 Jul 2023 15:38:01 -0400 Subject: [PATCH 1/3] dump pl config during create --- datadog_sync/model/synthetics_private_locations.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/datadog_sync/model/synthetics_private_locations.py b/datadog_sync/model/synthetics_private_locations.py index bacfd4e4..4b81fab8 100644 --- a/datadog_sync/model/synthetics_private_locations.py +++ b/datadog_sync/model/synthetics_private_locations.py @@ -45,9 +45,9 @@ def pre_apply_hook(self) -> None: def create_resource(self, _id: str, resource: Dict) -> None: destination_client = self.config.destination_client - resp = destination_client.post(self.resource_config.base_path, resource).json()["private_location"] - - self.resource_config.destination_resources[_id] = resp + resp = destination_client.post(self.resource_config.base_path, resource).json() + self.resource_config.destination_resources[_id] = resp["private_location"] + self.resource_config.destination_resources[_id]["config"] = resp["config"] def update_resource(self, _id: str, resource: Dict) -> None: destination_client = self.config.destination_client From cf5ba347309133c746c85e56db7117433e760a18 Mon Sep 17 00:00:00 2001 From: Sherzod Karimov Date: Wed, 26 Jul 2023 15:54:10 -0400 Subject: [PATCH 2/3] use getter --- datadog_sync/model/synthetics_private_locations.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/datadog_sync/model/synthetics_private_locations.py b/datadog_sync/model/synthetics_private_locations.py index 4b81fab8..9a3d6d58 100644 --- a/datadog_sync/model/synthetics_private_locations.py +++ b/datadog_sync/model/synthetics_private_locations.py @@ -45,9 +45,12 @@ def pre_apply_hook(self) -> None: def create_resource(self, _id: str, resource: Dict) -> None: destination_client = self.config.destination_client + resp = destination_client.post(self.resource_config.base_path, resource).json() + self.resource_config.destination_resources[_id] = resp["private_location"] - self.resource_config.destination_resources[_id]["config"] = resp["config"] + self.resource_config.destination_resources[_id]["config"] = resp.get("config") + self.resource_config.destination_resources[_id]["result_encryption"] = resp.get("result_encryption") def update_resource(self, _id: str, resource: Dict) -> None: destination_client = self.config.destination_client From a5c7b0f6eca3db712eff84213ee4cc5ef54e0e68 Mon Sep 17 00:00:00 2001 From: Sherzod Karimov Date: Wed, 26 Jul 2023 16:08:02 -0400 Subject: [PATCH 3/3] black --- datadog_sync/model/synthetics_private_locations.py | 11 ++++++++++- datadog_sync/utils/custom_client.py | 1 + 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/datadog_sync/model/synthetics_private_locations.py b/datadog_sync/model/synthetics_private_locations.py index 9a3d6d58..57458c27 100644 --- a/datadog_sync/model/synthetics_private_locations.py +++ b/datadog_sync/model/synthetics_private_locations.py @@ -18,7 +18,16 @@ class SyntheticsPrivateLocations(BaseResource): resource_type = "synthetics_private_locations" resource_config = ResourceConfig( base_path="/api/v1/synthetics/private-locations", - excluded_attributes=["id", "modifiedAt", "createdAt", "createdBy", "metadata", "secrets", "config"], + excluded_attributes=[ + "id", + "modifiedAt", + "createdAt", + "createdBy", + "metadata", + "secrets", + "config", + "result_encryption", + ], ) # Additional SyntheticsPrivateLocations specific attributes base_locations_path: str = "/api/v1/synthetics/locations" diff --git a/datadog_sync/utils/custom_client.py b/datadog_sync/utils/custom_client.py index 4bf435e6..d8b5580a 100644 --- a/datadog_sync/utils/custom_client.py +++ b/datadog_sync/utils/custom_client.py @@ -154,6 +154,7 @@ def remaining_func(idx, resp, page_size, page_number): def page_number_func(idx, page_size, page_number): return page_number + 1 + @dataclass class PaginationConfig(object): page_size: Optional[int] = 100