@@ -1794,7 +1794,7 @@ def __init__(self, is_backup_enabled: Optional[bool] = None, backup_region: Opti
17941794 customer_notification_type : Optional [CustomerNotificationType ] = None ):
17951795 self .is_backup_enabled = is_backup_enabled if is_backup_enabled is not None else False
17961796 self .backup_region = backup_region
1797- self .customer_notification_type = customer_notification_type if customer_notification_type is not None else CustomerNotificationType .NONE
1797+ self .customer_notification_type = customer_notification_type or CustomerNotificationType .NONE
17981798
17991799 def to_dict (self ) -> Dict :
18001800 """Serializes the backup settings into a dictionary."""
@@ -1810,7 +1810,7 @@ def from_dict(cls, data: Dict) -> 'ModelBackupSetting':
18101810 return cls (
18111811 is_backup_enabled = data .get ("is_backup_enabled" ),
18121812 backup_region = data .get ("backup_region" ),
1813- customer_notification_type = CustomerNotificationType (data .get ("customer_notification_type" , CustomerNotificationType . NONE . value ))
1813+ customer_notification_type = CustomerNotificationType (data .get ("customer_notification_type" )) or None
18141814 )
18151815
18161816 def to_json (self ) -> str :
@@ -1838,7 +1838,8 @@ def validate(self) -> bool:
18381838 return True
18391839
18401840 def __repr__ (self ):
1841- return f"ModelBackupSetting(is_backup_enabled={ self .is_backup_enabled } , backup_region={ self .backup_region } , customer_notification_type={ self .customer_notification_type } )"
1841+ return self .to_yaml ()
1842+
18421843
18431844
18441845class ModelRetentionSetting :
@@ -1865,7 +1866,7 @@ def __init__(self, archive_after_days: Optional[int] = None, delete_after_days:
18651866 customer_notification_type : Optional [CustomerNotificationType ] = None ):
18661867 self .archive_after_days = archive_after_days
18671868 self .delete_after_days = delete_after_days
1868- self .customer_notification_type = customer_notification_type if customer_notification_type is not None else CustomerNotificationType .NONE
1869+ self .customer_notification_type = customer_notification_type or CustomerNotificationType .NONE
18691870
18701871 def to_dict (self ) -> Dict :
18711872 """Serializes the retention settings into a dictionary."""
@@ -1881,7 +1882,7 @@ def from_dict(cls, data: Dict) -> 'ModelRetentionSetting':
18811882 return cls (
18821883 archive_after_days = data .get ("archive_after_days" ),
18831884 delete_after_days = data .get ("delete_after_days" ),
1884- customer_notification_type = CustomerNotificationType (data .get ("customer_notification_type" , CustomerNotificationType . NONE . value ))
1885+ customer_notification_type = CustomerNotificationType (data .get ("customer_notification_type" )) or None
18851886 )
18861887
18871888 def to_json (self ) -> str :
@@ -1909,7 +1910,7 @@ def validate(self) -> bool:
19091910 return True
19101911
19111912 def __repr__ (self ):
1912- return f"ModelRetentionSetting(archive_after_days= { self .archive_after_days } , delete_after_days= { self . delete_after_days } , customer_notification_type= { self . customer_notification_type } )"
1913+ return self .to_yaml ()
19131914
19141915
19151916class SettingStatus (str , ExtendedEnumMeta ):
@@ -1945,19 +1946,19 @@ def __init__(self,
19451946 delete_state_details : Optional [str ] = None ,
19461947 time_archival_scheduled : Optional [int ] = None ,
19471948 time_deletion_scheduled : Optional [int ] = None ):
1948- self .archive_state = archive_state if archive_state is not None else SettingStatus . PENDING
1949+ self .archive_state = archive_state
19491950 self .archive_state_details = archive_state_details
1950- self .delete_state = delete_state if delete_state is not None else SettingStatus . PENDING
1951+ self .delete_state = delete_state
19511952 self .delete_state_details = delete_state_details
19521953 self .time_archival_scheduled = time_archival_scheduled
19531954 self .time_deletion_scheduled = time_deletion_scheduled
19541955
19551956 def to_dict (self ) -> Dict :
19561957 """Serializes the retention operation details into a dictionary."""
19571958 return {
1958- "archive_state" : self .archive_state .value ,
1959+ "archive_state" : self .archive_state .value or None ,
19591960 "archive_state_details" : self .archive_state_details ,
1960- "delete_state" : self .delete_state .value ,
1961+ "delete_state" : self .delete_state .value or None ,
19611962 "delete_state_details" : self .delete_state_details ,
19621963 "time_archival_scheduled" : self .time_archival_scheduled ,
19631964 "time_deletion_scheduled" : self .time_deletion_scheduled
@@ -1967,9 +1968,9 @@ def to_dict(self) -> Dict:
19671968 def from_dict (cls , data : Dict ) -> 'ModelRetentionOperationDetails' :
19681969 """Constructs retention operation details from a dictionary."""
19691970 return cls (
1970- archive_state = SettingStatus (data .get ("archive_state" , SettingStatus . PENDING . value )) ,
1971+ archive_state = SettingStatus (data .get ("archive_state" )) or None ,
19711972 archive_state_details = data .get ("archive_state_details" ),
1972- delete_state = SettingStatus (data .get ("delete_state" , SettingStatus . PENDING . value )) ,
1973+ delete_state = SettingStatus (data .get ("delete_state" )) or None ,
19731974 delete_state_details = data .get ("delete_state_details" ),
19741975 time_archival_scheduled = data .get ("time_archival_scheduled" ),
19751976 time_deletion_scheduled = data .get ("time_deletion_scheduled" )
@@ -1991,24 +1992,16 @@ def to_yaml(self) -> str:
19911992
19921993 def validate (self ) -> bool :
19931994 """Validates the retention operation details."""
1994- if not isinstance (self .archive_state , SettingStatus ):
1995- return False
1996- if not isinstance (self .delete_state , SettingStatus ):
1997- return False
1998- if self .time_archival_scheduled is not None and not isinstance (self .time_archival_scheduled , int ):
1999- return False
2000- if self .time_deletion_scheduled is not None and not isinstance (self .time_deletion_scheduled , int ):
2001- return False
2002- return True
1995+ return all ([
1996+ self .archive_state is None or isinstance (self .archive_state , SettingStatus ),
1997+ self .delete_state is None or isinstance (self .delete_state , SettingStatus ),
1998+ self .time_archival_scheduled is None or isinstance (self .time_archival_scheduled , int ),
1999+ self .time_deletion_scheduled is None or isinstance (self .time_deletion_scheduled , int ),
2000+ ])
2001+
20032002
20042003 def __repr__ (self ):
2005- return (f"ModelRetentionOperationDetails("
2006- f"archive_state={ self .archive_state } , "
2007- f"archive_state_details={ self .archive_state_details } , "
2008- f"delete_state={ self .delete_state } , "
2009- f"delete_state_details={ self .delete_state_details } , "
2010- f"time_archival_scheduled={ self .time_archival_scheduled } , "
2011- f"time_deletion_scheduled={ self .time_deletion_scheduled } )" )
2004+ return self .to_yaml ()
20122005
20132006
20142007class ModelBackupOperationDetails :
@@ -2032,17 +2025,17 @@ class ModelBackupOperationDetails:
20322025 """
20332026
20342027 def __init__ (self ,
2035- backup_state : Optional [' SettingStatus' ] = None ,
2028+ backup_state : Optional [SettingStatus ] = None ,
20362029 backup_state_details : Optional [str ] = None ,
20372030 time_last_backed_up : Optional [int ] = None ):
2038- self .backup_state = backup_state if backup_state is not None else SettingStatus . PENDING
2031+ self .backup_state = backup_state
20392032 self .backup_state_details = backup_state_details
20402033 self .time_last_backed_up = time_last_backed_up
20412034
20422035 def to_dict (self ) -> Dict :
20432036 """Serializes the backup operation details into a dictionary."""
20442037 return {
2045- "backup_state" : self .backup_state .value ,
2038+ "backup_state" : self .backup_state .value or None ,
20462039 "backup_state_details" : self .backup_state_details ,
20472040 "time_last_backed_up" : self .time_last_backed_up
20482041 }
@@ -2051,7 +2044,7 @@ def to_dict(self) -> Dict:
20512044 def from_dict (cls , data : Dict ) -> 'ModelBackupOperationDetails' :
20522045 """Constructs backup operation details from a dictionary."""
20532046 return cls (
2054- backup_state = SettingStatus (data .get ("backup_state" , SettingStatus . PENDING . value )) ,
2047+ backup_state = SettingStatus (data .get ("backup_state" )) or None ,
20552048 backup_state_details = data .get ("backup_state_details" ),
20562049 time_last_backed_up = data .get ("time_last_backed_up" )
20572050 )
@@ -2072,17 +2065,11 @@ def to_yaml(self) -> str:
20722065
20732066 def validate (self ) -> bool :
20742067 """Validates the backup operation details."""
2075- if not isinstance (self .backup_state , SettingStatus ):
2068+ if self . backup_state is not None and not isinstance (self .backup_state , SettingStatus ):
20762069 return False
20772070 if self .time_last_backed_up is not None and not isinstance (self .time_last_backed_up , int ):
20782071 return False
20792072 return True
20802073
20812074 def __repr__ (self ):
2082- return (f"ModelBackupOperationDetails("
2083- f"backup_state={ self .backup_state } , "
2084- f"backup_state_details={ self .backup_state_details } , "
2085- f"time_last_backed_up={ self .time_last_backed_up } )" )
2086-
2087-
2088-
2075+ return self .to_yaml ()
0 commit comments