File tree Expand file tree Collapse file tree 2 files changed +11
-3
lines changed
Expand file tree Collapse file tree 2 files changed +11
-3
lines changed Original file line number Diff line number Diff line change @@ -26,10 +26,12 @@ class ReplicationRule:
2626 name : str
2727 file_name_prefix : str = ''
2828 is_enabled : bool = True
29- priority : int = 1
29+ priority : int = 128
3030 include_existing_files : bool = False
3131
3232 REPLICATION_RULE_REGEX : ClassVar = re .compile (r'^[a-zA-Z0-9_\-]{1,64}$' )
33+ MIN_PRIORITY : ClassVar [int ] = 1
34+ MAX_PRIORITY : ClassVar [int ] = 2147483647
3335
3436 def __post_init__ (self ):
3537 if not self .destination_bucket_id :
@@ -38,6 +40,12 @@ def __post_init__(self):
3840 if not self .REPLICATION_RULE_REGEX .match (self .name ):
3941 raise ValueError ('replication rule name is invalid' )
4042
43+ if not (self .MIN_PRIORITY <= self .priority <= self .MAX_PRIORITY ):
44+ raise ValueError ('priority should be within [%d, %d] interval' % (
45+ self .MIN_PRIORITY ,
46+ self .MAX_PRIORITY ,
47+ ))
48+
4149 def as_dict (self ) -> dict :
4250 return {
4351 'destinationBucketId' : self .destination_bucket_id ,
Original file line number Diff line number Diff line change 3333class ReplicationSetupHelper (metaclass = B2TraceMeta ):
3434 """ class with various methods that help with repliction management """
3535 PRIORITY_OFFSET : ClassVar [int ] = 5 #: how far to to put the new rule from the existing rules
36- DEFAULT_PRIORITY : ClassVar [int ] = 128 #: what priority to set if there are no preexisting rules
37- MAX_PRIORITY : ClassVar [int ] = 255 #: maximum allowed priority of a replication rule
36+ DEFAULT_PRIORITY : ClassVar [int ] = ReplicationRule . priority #: what priority to set if there are no preexisting rules
37+ MAX_PRIORITY : ClassVar [int ] = ReplicationRule . MAX_PRIORITY #: maximum allowed priority of a replication rule
3838 DEFAULT_SOURCE_CAPABILITIES : ClassVar [Tuple [str , ...]] = (
3939 'readFiles' ,
4040 'readFileLegalHolds' ,
You can’t perform that action at this time.
0 commit comments