diff --git a/src/wiotp/sdk/api/dsc/destinations.py b/src/wiotp/sdk/api/dsc/destinations.py index 229bf43b..4f5c9c3a 100644 --- a/src/wiotp/sdk/api/dsc/destinations.py +++ b/src/wiotp/sdk/api/dsc/destinations.py @@ -49,6 +49,15 @@ def bucketInterval(self): else: return None + # Cloudant only configuration + @property + def retentionDays(self): + # this is an optional parameter so check if it exists + if "configuration" in self and "retentionDays" in self["configuration"]: + return self["configuration"]["retentionDays"] + else: + return None + class IterableDestinationList(IterableList): def __init__(self, apiClient, connectorId, filters=None): diff --git a/test/test_api_dsc_cloudant.py b/test/test_api_dsc_cloudant.py index 86c1478e..2dc2ade6 100644 --- a/test/test_api_dsc_cloudant.py +++ b/test/test_api_dsc_cloudant.py @@ -109,7 +109,9 @@ def testCreateService2(self): # Create a destination under the connector destination1 = createdConnector.destinations.create(name="test-destination-cloudant1", bucketInterval="DAY") - destination2 = createdConnector.destinations.create(name="test-destination-cloudant2", bucketInterval="DAY") + destination2 = createdConnector.destinations.create( + name="test-destination-cloudant2", bucketInterval="DAY", retentionDays=60 + ) destination3 = createdConnector.destinations.create(name="test-destination-cloudant3", bucketInterval="WEEK") destination4 = createdConnector.destinations.create(name="test-destination-cloudant4", bucketInterval="MONTH") @@ -118,6 +120,10 @@ def testCreateService2(self): count += 1 assert d.bucketInterval is not None assert d.partitions is None + if d.name == "test-destination-cloudant2": + assert d.retentionDays == 60 + else: + assert d.retentionDays is None assert count == 4 with pytest.raises(ApiException) as e: