@@ -1794,7 +1794,7 @@ def __init__(self, is_backup_enabled: Optional[bool] = None, backup_region: Opti
1794
1794
customer_notification_type : Optional [CustomerNotificationType ] = None ):
1795
1795
self .is_backup_enabled = is_backup_enabled if is_backup_enabled is not None else False
1796
1796
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
1798
1798
1799
1799
def to_dict (self ) -> Dict :
1800
1800
"""Serializes the backup settings into a dictionary."""
@@ -1810,7 +1810,7 @@ def from_dict(cls, data: Dict) -> 'ModelBackupSetting':
1810
1810
return cls (
1811
1811
is_backup_enabled = data .get ("is_backup_enabled" ),
1812
1812
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
1814
1814
)
1815
1815
1816
1816
def to_json (self ) -> str :
@@ -1838,7 +1838,8 @@ def validate(self) -> bool:
1838
1838
return True
1839
1839
1840
1840
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
+
1842
1843
1843
1844
1844
1845
class ModelRetentionSetting :
@@ -1865,7 +1866,7 @@ def __init__(self, archive_after_days: Optional[int] = None, delete_after_days:
1865
1866
customer_notification_type : Optional [CustomerNotificationType ] = None ):
1866
1867
self .archive_after_days = archive_after_days
1867
1868
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
1869
1870
1870
1871
def to_dict (self ) -> Dict :
1871
1872
"""Serializes the retention settings into a dictionary."""
@@ -1881,7 +1882,7 @@ def from_dict(cls, data: Dict) -> 'ModelRetentionSetting':
1881
1882
return cls (
1882
1883
archive_after_days = data .get ("archive_after_days" ),
1883
1884
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
1885
1886
)
1886
1887
1887
1888
def to_json (self ) -> str :
@@ -1909,7 +1910,7 @@ def validate(self) -> bool:
1909
1910
return True
1910
1911
1911
1912
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 ()
1913
1914
1914
1915
1915
1916
class SettingStatus (str , ExtendedEnumMeta ):
@@ -1945,19 +1946,19 @@ def __init__(self,
1945
1946
delete_state_details : Optional [str ] = None ,
1946
1947
time_archival_scheduled : Optional [int ] = None ,
1947
1948
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
1949
1950
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
1951
1952
self .delete_state_details = delete_state_details
1952
1953
self .time_archival_scheduled = time_archival_scheduled
1953
1954
self .time_deletion_scheduled = time_deletion_scheduled
1954
1955
1955
1956
def to_dict (self ) -> Dict :
1956
1957
"""Serializes the retention operation details into a dictionary."""
1957
1958
return {
1958
- "archive_state" : self .archive_state .value ,
1959
+ "archive_state" : self .archive_state .value or None ,
1959
1960
"archive_state_details" : self .archive_state_details ,
1960
- "delete_state" : self .delete_state .value ,
1961
+ "delete_state" : self .delete_state .value or None ,
1961
1962
"delete_state_details" : self .delete_state_details ,
1962
1963
"time_archival_scheduled" : self .time_archival_scheduled ,
1963
1964
"time_deletion_scheduled" : self .time_deletion_scheduled
@@ -1967,9 +1968,9 @@ def to_dict(self) -> Dict:
1967
1968
def from_dict (cls , data : Dict ) -> 'ModelRetentionOperationDetails' :
1968
1969
"""Constructs retention operation details from a dictionary."""
1969
1970
return cls (
1970
- archive_state = SettingStatus (data .get ("archive_state" , SettingStatus . PENDING . value )) ,
1971
+ archive_state = SettingStatus (data .get ("archive_state" )) or None ,
1971
1972
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 ,
1973
1974
delete_state_details = data .get ("delete_state_details" ),
1974
1975
time_archival_scheduled = data .get ("time_archival_scheduled" ),
1975
1976
time_deletion_scheduled = data .get ("time_deletion_scheduled" )
@@ -1991,24 +1992,16 @@ def to_yaml(self) -> str:
1991
1992
1992
1993
def validate (self ) -> bool :
1993
1994
"""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
+
2003
2002
2004
2003
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 ()
2012
2005
2013
2006
2014
2007
class ModelBackupOperationDetails :
@@ -2032,17 +2025,17 @@ class ModelBackupOperationDetails:
2032
2025
"""
2033
2026
2034
2027
def __init__ (self ,
2035
- backup_state : Optional [' SettingStatus' ] = None ,
2028
+ backup_state : Optional [SettingStatus ] = None ,
2036
2029
backup_state_details : Optional [str ] = None ,
2037
2030
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
2039
2032
self .backup_state_details = backup_state_details
2040
2033
self .time_last_backed_up = time_last_backed_up
2041
2034
2042
2035
def to_dict (self ) -> Dict :
2043
2036
"""Serializes the backup operation details into a dictionary."""
2044
2037
return {
2045
- "backup_state" : self .backup_state .value ,
2038
+ "backup_state" : self .backup_state .value or None ,
2046
2039
"backup_state_details" : self .backup_state_details ,
2047
2040
"time_last_backed_up" : self .time_last_backed_up
2048
2041
}
@@ -2051,7 +2044,7 @@ def to_dict(self) -> Dict:
2051
2044
def from_dict (cls , data : Dict ) -> 'ModelBackupOperationDetails' :
2052
2045
"""Constructs backup operation details from a dictionary."""
2053
2046
return cls (
2054
- backup_state = SettingStatus (data .get ("backup_state" , SettingStatus . PENDING . value )) ,
2047
+ backup_state = SettingStatus (data .get ("backup_state" )) or None ,
2055
2048
backup_state_details = data .get ("backup_state_details" ),
2056
2049
time_last_backed_up = data .get ("time_last_backed_up" )
2057
2050
)
@@ -2072,17 +2065,11 @@ def to_yaml(self) -> str:
2072
2065
2073
2066
def validate (self ) -> bool :
2074
2067
"""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 ):
2076
2069
return False
2077
2070
if self .time_last_backed_up is not None and not isinstance (self .time_last_backed_up , int ):
2078
2071
return False
2079
2072
return True
2080
2073
2081
2074
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