Skip to content

Commit

Permalink
Merge pull request #169 from ibm-watson-iot/destinationRetention
Browse files Browse the repository at this point in the history
Add dsc connector type and destination retention time
  • Loading branch information
stonepd authored Aug 12, 2019
2 parents 5fbd7b7 + a3f0626 commit 548d2f6
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
9 changes: 9 additions & 0 deletions src/wiotp/sdk/api/dsc/destinations.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
8 changes: 7 additions & 1 deletion test/test_api_dsc_cloudant.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand All @@ -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:
Expand Down

0 comments on commit 548d2f6

Please sign in to comment.