@@ -482,7 +482,8 @@ def drop_database(self, dbname):
482
482
self .query ("DROP DATABASE \" %s\" " % dbname )
483
483
484
484
def create_retention_policy (self , name , duration , replication ,
485
- database = None , default = False ):
485
+ database = None , default = False ,
486
+ shard_duration = None ):
486
487
"""Create a retention policy for a database.
487
488
488
489
:param name: the name of the new retention policy
@@ -501,19 +502,26 @@ def create_retention_policy(self, name, duration, replication,
501
502
:type database: str
502
503
:param default: whether or not to set the policy as default
503
504
:type default: bool
505
+ :param shard_duration: the shard duration of the retention policy.
506
+ Durations are similar to those allowed in the duration param.
507
+ :type shard_duration: str
504
508
"""
505
509
query_string = \
506
510
"CREATE RETENTION POLICY \" %s\" ON \" %s\" " \
507
511
"DURATION %s REPLICATION %s" % \
508
512
(name , database or self ._database , duration , replication )
509
513
514
+ if shard_duration :
515
+ query_string += " SHARD DURATION %s" % shard_duration
516
+
510
517
if default is True :
511
518
query_string += " DEFAULT"
512
519
513
520
self .query (query_string )
514
521
515
522
def alter_retention_policy (self , name , database = None ,
516
- duration = None , replication = None , default = None ):
523
+ duration = None , replication = None , default = None ,
524
+ shard_duration = None ):
517
525
"""Mofidy an existing retention policy for a database.
518
526
519
527
:param name: the name of the retention policy to modify
@@ -533,9 +541,13 @@ def alter_retention_policy(self, name, database=None,
533
541
:type replication: str
534
542
:param default: whether or not to set the modified policy as default
535
543
:type default: bool
544
+ :param shard_duration: the shard duration of the retention policy.
545
+ Durations are similar to those allowed in the duration param.
546
+ :type shard_duration: str
536
547
537
- .. note:: at least one of duration, replication, or default flag
538
- should be set. Otherwise the operation will fail.
548
+ .. note:: at least one of duration, replication, default or
549
+ shard_duration flag should be set. Otherwise the operation
550
+ will fail.
539
551
"""
540
552
query_string = (
541
553
"ALTER RETENTION POLICY \" {0}\" ON \" {1}\" "
@@ -544,6 +556,8 @@ def alter_retention_policy(self, name, database=None,
544
556
query_string += " DURATION {0}" .format (duration )
545
557
if replication :
546
558
query_string += " REPLICATION {0}" .format (replication )
559
+ if shard_duration :
560
+ query_string += " SHARD DURATION {0}" .format (shard_duration )
547
561
if default is True :
548
562
query_string += " DEFAULT"
549
563
0 commit comments