Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(swagger): Allow setting shard-group durations for buckets via API #209

Merged
merged 2 commits into from
Mar 16, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
### Bug Fixes
1. [#206](https://github.com/influxdata/influxdb-client-python/pull/207): Use default (system) certificates instead of Mozilla's root certificates (certifi.where())

### API
1. [#209](https://github.com/influxdata/influxdb-client-python/pull/209): Allow setting shard-group durations for buckets via API

### Documentation
1. [#202](https://github.com/influxdata/influxdb-client-python/pull/202): Added an example how to use RxPY and sync batching

Expand Down
41 changes: 34 additions & 7 deletions influxdb_client/domain/bucket_retention_rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,22 +33,27 @@ class BucketRetentionRules(object):
"""
openapi_types = {
'type': 'str',
'every_seconds': 'int'
'every_seconds': 'int',
'shard_group_duration_seconds': 'int'
}

attribute_map = {
'type': 'type',
'every_seconds': 'everySeconds'
'every_seconds': 'everySeconds',
'shard_group_duration_seconds': 'shardGroupDurationSeconds'
}

def __init__(self, type='expire', every_seconds=None): # noqa: E501,D401,D403
def __init__(self, type='expire', every_seconds=None, shard_group_duration_seconds=None): # noqa: E501,D401,D403
"""BucketRetentionRules - a model defined in OpenAPI.""" # noqa: E501
self._type = None
self._every_seconds = None
self._shard_group_duration_seconds = None
self.discriminator = None

self.type = type
self.every_seconds = every_seconds
if shard_group_duration_seconds is not None:
self.shard_group_duration_seconds = shard_group_duration_seconds

@property
def type(self):
Expand All @@ -74,7 +79,7 @@ def type(self, type):
def every_seconds(self):
"""Get the every_seconds of this BucketRetentionRules.

Duration in seconds for how long data will be kept in the database.
Duration in seconds for how long data will be kept in the database. 0 means infinite.

:return: The every_seconds of this BucketRetentionRules.
:rtype: int
Expand All @@ -85,17 +90,39 @@ def every_seconds(self):
def every_seconds(self, every_seconds):
"""Set the every_seconds of this BucketRetentionRules.

Duration in seconds for how long data will be kept in the database.
Duration in seconds for how long data will be kept in the database. 0 means infinite.

:param every_seconds: The every_seconds of this BucketRetentionRules.
:type: int
""" # noqa: E501
if every_seconds is None:
raise ValueError("Invalid value for `every_seconds`, must not be `None`") # noqa: E501
if every_seconds is not None and every_seconds < 1: # noqa: E501
raise ValueError("Invalid value for `every_seconds`, must be a value greater than or equal to `1`") # noqa: E501
if every_seconds is not None and every_seconds < 0: # noqa: E501
raise ValueError("Invalid value for `every_seconds`, must be a value greater than or equal to `0`") # noqa: E501
self._every_seconds = every_seconds

@property
def shard_group_duration_seconds(self):
"""Get the shard_group_duration_seconds of this BucketRetentionRules.

Shard duration measured in seconds.

:return: The shard_group_duration_seconds of this BucketRetentionRules.
:rtype: int
""" # noqa: E501
return self._shard_group_duration_seconds

@shard_group_duration_seconds.setter
def shard_group_duration_seconds(self, shard_group_duration_seconds):
"""Set the shard_group_duration_seconds of this BucketRetentionRules.

Shard duration measured in seconds.

:param shard_group_duration_seconds: The shard_group_duration_seconds of this BucketRetentionRules.
:type: int
""" # noqa: E501
self._shard_group_duration_seconds = shard_group_duration_seconds

def to_dict(self):
"""Return the model properties as a dict."""
result = {}
Expand Down
6 changes: 3 additions & 3 deletions influxdb_client/domain/date_time_literal.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class DateTimeLiteral(object):
"""
openapi_types = {
'type': 'str',
'value': 'str'
'value': 'datetime'
}

attribute_map = {
Expand Down Expand Up @@ -79,7 +79,7 @@ def value(self):
"""Get the value of this DateTimeLiteral.

:return: The value of this DateTimeLiteral.
:rtype: str
:rtype: datetime
""" # noqa: E501
return self._value

Expand All @@ -88,7 +88,7 @@ def value(self, value):
"""Set the value of this DateTimeLiteral.

:param value: The value of this DateTimeLiteral.
:type: str
:type: datetime
""" # noqa: E501
self._value = value

Expand Down
3 changes: 1 addition & 2 deletions tests/test_BucketsApi.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,8 @@ def test_create_bucket_retention_list(self):

bucket_name = generate_bucket_name()

retention = BucketRetentionRules
ret_list = []
retention.every_seconds = 3600
retention = BucketRetentionRules(every_seconds=3600)
retention.type = "expire"
ret_list.append(retention)

Expand Down