@@ -976,6 +976,14 @@ def __init__(self):
976976
977977 group .add_argument ("--purge-interval" , dest = "purge_interval" , type = (float ),
978978 metavar = "<float>" , help = "Sets the frequency of the tombstone purge interval" )
979+ group .add_argument ("--history-retention-bytes" , dest = "history_retention_bytes" , default = None , type = (int ),
980+ metavar = "<bytes>" , help = "Set the maximum size of retained document history in bytes" )
981+ group .add_argument ("--history-retention-seconds" , dest = "history_retention_seconds" , default = None , type = (int ),
982+ metavar = "<seconds>" , help = "Set the maximum age of retained document history in seconds" )
983+ group .add_argument ("--enable-history-retention-by-default" ,
984+ dest = "enable_history_retention" , metavar = "<0|1>" , choices = ["0" , "1" ],
985+ help = "Enable history retention for new collections created in this bucket by default "
986+ "(0 or 1)" )
979987
980988 group .add_argument ("--enable-point-in-time" , dest = "enable_pitr" , metavar = "<0|1>" ,
981989 choices = ["0" , "1" ], help = "Enable the Point-In-Time feature on this bucket, which allows "
@@ -1036,6 +1044,25 @@ def execute(self, opts):
10361044 if opts .storage == "magma" :
10371045 storage_type = "magma"
10381046
1047+ if opts .type != "couchbase" :
1048+ if opts .history_retention_bytes is not None :
1049+ _exit_if_errors ([f"--history-retention-bytes cannot be specified for a { opts .type } bucket" ])
1050+ if opts .history_retention_seconds is not None :
1051+ _exit_if_errors ([f"--history-retention-seconds cannot be specified for a { opts .type } bucket" ])
1052+ if opts .enable_history_retention is not None :
1053+ _exit_if_errors ([f"--enable-history-retention-by-default cannot be specified for a { opts .type } bucket" ])
1054+
1055+ if storage_type != "magma" :
1056+ if opts .history_retention_bytes is not None :
1057+ _exit_if_errors ([f"--history-retention-bytes cannot be specified for a bucket with { storage_type } "
1058+ "backend" ])
1059+ if opts .history_retention_seconds is not None :
1060+ _exit_if_errors ([f"--history-retention-seconds cannot be specified for a bucket with { storage_type } "
1061+ "backend" ])
1062+ if opts .enable_history_retention is not None :
1063+ _exit_if_errors (["--enable-history-retention-by-default cannot be specified for a bucket with "
1064+ f"{ storage_type } backend" ])
1065+
10391066 priority = None
10401067 if opts .priority is not None :
10411068 if opts .priority == BUCKET_PRIORITY_HIGH_STR :
@@ -1057,7 +1084,9 @@ def execute(self, opts):
10571084 opts .db_frag_size , opts .view_frag_perc , opts .view_frag_size ,
10581085 opts .from_hour , opts .from_min , opts .to_hour , opts .to_min ,
10591086 opts .abort_outside , opts .paralleldb_and_view_compact , opts .purge_interval ,
1060- opts .enable_pitr , opts .pitr_granularity , opts .pitr_max_history_age )
1087+ opts .history_retention_bytes , opts .history_retention_seconds ,
1088+ opts .enable_history_retention , opts .enable_pitr , opts .pitr_granularity ,
1089+ opts .pitr_max_history_age )
10611090 _exit_if_errors (errors )
10621091 _success ("Bucket created" )
10631092
@@ -1158,6 +1187,15 @@ def __init__(self):
11581187 group .add_argument ("--purge-interval" , dest = "purge_interval" , type = (float ),
11591188 metavar = "<num>" , help = "Set the bucket metadata purge interval" )
11601189
1190+ group .add_argument ("--history-retention-bytes" , dest = "history_retention_bytes" , default = None , type = (int ),
1191+ metavar = "<bytes>" , help = "Set the maximum size of retained document history in bytes" )
1192+ group .add_argument ("--history-retention-seconds" , dest = "history_retention_seconds" , default = None , type = (int ),
1193+ metavar = "<seconds>" , help = "Set the maximum age of retained document history in seconds" )
1194+ group .add_argument ("--enable-history-retention-by-default" ,
1195+ dest = "enable_history_retention" , metavar = "<0|1>" , choices = ["0" , "1" ],
1196+ help = "Enable history retention for new collections created in this bucket by default "
1197+ "(0 or 1)" )
1198+
11611199 group .add_argument ("--enable-point-in-time" , dest = "enable_pitr" , metavar = "<0|1>" ,
11621200 choices = ["0" , "1" ], help = "Enable Point-In-Time backups and restores on this bucket (0 or 1)" )
11631201 group .add_argument ("--point-in-time-granularity" , dest = "pitr_granularity" , default = None , type = (int ),
@@ -1210,6 +1248,26 @@ def execute(self, opts):
12101248
12111249 is_couchbase_bucket = "bucketType" in bucket and bucket ["bucketType" ] == "membase"
12121250
1251+ if "bucketType" in bucket and bucket ["bucketType" ] != "membase" :
1252+ if opts .history_retention_bytes is not None :
1253+ _exit_if_errors ([f"--history-retention-bytes cannot be specified for a { bucket ['bucketType' ]} bucket" ])
1254+ if opts .history_retention_seconds is not None :
1255+ _exit_if_errors ([f"--history-retention-seconds cannot be specified for a { bucket ['bucketType' ]} "
1256+ "bucket" ])
1257+ if opts .enable_history_retention is not None :
1258+ _exit_if_errors (["--enable-history-retention-by-default cannot be specified for a "
1259+ f"{ bucket ['bucketType' ]} bucket" ])
1260+ if "storageBackend" in bucket and bucket ["storageBackend" ] != "magma" :
1261+ if opts .history_retention_bytes is not None :
1262+ _exit_if_errors (["--history-retention-bytes cannot be specified for a bucket with "
1263+ f"{ bucket ['storageBackend' ]} backend" ])
1264+ if opts .history_retention_seconds is not None :
1265+ _exit_if_errors (["--history-retention-seconds cannot be specified for a bucket with "
1266+ f"{ bucket ['storageBackend' ]} backend" ])
1267+ if opts .enable_history_retention is not None :
1268+ _exit_if_errors (["--enable-history-retention-by-default cannot be specified for a bucket with "
1269+ f"{ bucket ['storageBackend' ]} backend" ])
1270+
12131271 if not is_couchbase_bucket and (opts .enable_pitr is not None or opts .pitr_granularity is not None or
12141272 opts .pitr_max_history_age is not None ):
12151273 _exit_if_errors (["Point-In-Time options are only supported for 'couchbase' buckets" ])
@@ -1232,8 +1290,11 @@ def execute(self, opts):
12321290 opts .max_ttl , opts .compression_mode , opts .remove_port , opts .db_frag_perc ,
12331291 opts .db_frag_size , opts .view_frag_perc , opts .view_frag_size , opts .from_hour ,
12341292 opts .from_min , opts .to_hour , opts .to_min , opts .abort_outside ,
1235- opts .paralleldb_and_view_compact , opts .purge_interval , opts .enable_pitr ,
1236- opts .pitr_granularity , opts .pitr_max_history_age , is_couchbase_bucket )
1293+ opts .paralleldb_and_view_compact , opts .purge_interval ,
1294+ opts .history_retention_bytes , opts .history_retention_seconds ,
1295+ opts .enable_history_retention ,
1296+ opts .enable_pitr , opts .pitr_granularity , opts .pitr_max_history_age ,
1297+ is_couchbase_bucket )
12371298 _exit_if_errors (errors )
12381299
12391300 _success ("Bucket edited" )
@@ -2059,7 +2120,8 @@ def execute(self, opts):
20592120 _exit_if_errors (errors )
20602121
20612122 node = result ['otpNode' ]
2062- cookie = result ['otpCookie' ]
2123+ cookie , errors = self .rest .get_ns_server_cookie ()
2124+ _exit_if_errors (errors )
20632125
20642126 if opts .vm != 'ns_server' :
20652127 cookie , errors = self .rest .get_babysitter_cookie ()
@@ -4483,6 +4545,9 @@ def __init__(self):
44834545 help = "The blob endpoint of the link (required)" )
44844546
44854547 group = self .parser .add_argument_group ("Analytics Service GCS link setup options" )
4548+ group .add_argument ("--application-default-credentials" , dest = "application_default_credentials" ,
4549+ action = "store_true" ,
4550+ help = "The option to use application default credentials for authentication (optional)" )
44864551 group .add_argument ("--json-credentials" , dest = "json_credentials" , metavar = "<key>" ,
44874552 help = "The JSON credentials of the link (optional)" )
44884553
@@ -4519,6 +4584,12 @@ def _set(self, opts):
45194584 if opts .type == 'azureblob' or opts .type == 'azuredatalake' :
45204585 self ._verify_azure_options (opts )
45214586
4587+ if opts .type == 'gcs' :
4588+ # --application-default-credentials and --json-credentials are not allowed to be passed together
4589+ if opts .application_default_credentials and opts .json_credentials :
4590+ _exit_if_errors (['Parameter --json-credentials is not allowed if --application-default-credentials '
4591+ 'is provided' ])
4592+
45224593 if opts .dataverse :
45234594 opts .scope = opts .dataverse
45244595 if opts .certificates :
@@ -4700,6 +4771,8 @@ def __init__(self):
47004771 "are provided it will print all collections" )
47014772 group .add_argument ("--max-ttl" , dest = "max_ttl" , metavar = "<seconds>" , type = int ,
47024773 help = "Set the maximum TTL the collection will accept" )
4774+ group .add_argument ("--enable-history-retention" , dest = "enable_history" , metavar = "<0|1>" , choices = ["0" , "1" ],
4775+ help = "Enable history retention (0 or 1)" )
47034776
47044777 @rest_initialiser (cluster_init_check = True , version_check = True )
47054778 def execute (self , opts ):
@@ -4717,6 +4790,9 @@ def execute(self, opts):
47174790 if opts .max_ttl is not None and opts .create_collection is None :
47184791 _exit_if_errors (["--max-ttl can only be set with --create-collection" ])
47194792
4793+ if opts .enable_history is not None and opts .create_collection is None :
4794+ _exit_if_errors (["--enable-history-retention can only be set with --create-collection" ])
4795+
47204796 if opts .create_scope :
47214797 self ._create_scope (opts )
47224798 if opts .drop_scope :
@@ -4748,7 +4824,7 @@ def _list_scopes(self, opts):
47484824
47494825 def _create_collection (self , opts ):
47504826 scope , collection = self ._get_scope_collection (opts .create_collection )
4751- _ , errors = self .rest .create_collection (opts .bucket , scope , collection , opts .max_ttl )
4827+ _ , errors = self .rest .create_collection (opts .bucket , scope , collection , opts .max_ttl , opts . enable_history )
47524828 _exit_if_errors (errors )
47534829 _success ("Collection created" )
47544830
0 commit comments