Skip to content

Commit 7841bde

Browse files
authored
feat(mongodb): add support for InstanceSnapshotSchedule (#1028)
1 parent d80ed61 commit 7841bde

File tree

6 files changed

+128
-0
lines changed

6 files changed

+128
-0
lines changed

scaleway-async/scaleway_async/mongodb/v1alpha1/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
from .types import EndpointSpecPublicDetails
1818
from .types import Endpoint
1919
from .types import InstanceSetting
20+
from .types import InstanceSnapshotSchedule
2021
from .types import Volume
2122
from .types import NodeTypeVolumeType
2223
from .types import SnapshotVolumeType
@@ -77,6 +78,7 @@
7778
"EndpointSpecPublicDetails",
7879
"Endpoint",
7980
"InstanceSetting",
81+
"InstanceSnapshotSchedule",
8082
"Volume",
8183
"NodeTypeVolumeType",
8284
"SnapshotVolumeType",

scaleway-async/scaleway_async/mongodb/v1alpha1/marshalling.py

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
EndpointPublicDetails,
1515
Endpoint,
1616
InstanceSetting,
17+
InstanceSnapshotSchedule,
1718
Volume,
1819
Instance,
1920
SnapshotVolumeType,
@@ -131,6 +132,43 @@ def unmarshal_InstanceSetting(data: Any) -> InstanceSetting:
131132
return InstanceSetting(**args)
132133

133134

135+
def unmarshal_InstanceSnapshotSchedule(data: Any) -> InstanceSnapshotSchedule:
136+
if not isinstance(data, dict):
137+
raise TypeError(
138+
"Unmarshalling the type 'InstanceSnapshotSchedule' failed as data isn't a dictionary."
139+
)
140+
141+
args: Dict[str, Any] = {}
142+
143+
field = data.get("frequency_hours", None)
144+
if field is not None:
145+
args["frequency_hours"] = field
146+
147+
field = data.get("retention_days", None)
148+
if field is not None:
149+
args["retention_days"] = field
150+
151+
field = data.get("enabled", None)
152+
if field is not None:
153+
args["enabled"] = field
154+
155+
field = data.get("next_update", None)
156+
if field is not None:
157+
args["next_update"] = (
158+
parser.isoparse(field) if isinstance(field, str) else field
159+
)
160+
else:
161+
args["next_update"] = None
162+
163+
field = data.get("last_run", None)
164+
if field is not None:
165+
args["last_run"] = parser.isoparse(field) if isinstance(field, str) else field
166+
else:
167+
args["last_run"] = None
168+
169+
return InstanceSnapshotSchedule(**args)
170+
171+
134172
def unmarshal_Volume(data: Any) -> Volume:
135173
if not isinstance(data, dict):
136174
raise TypeError(
@@ -218,6 +256,12 @@ def unmarshal_Instance(data: Any) -> Instance:
218256
else:
219257
args["created_at"] = None
220258

259+
field = data.get("snapshot_schedule", None)
260+
if field is not None:
261+
args["snapshot_schedule"] = unmarshal_InstanceSnapshotSchedule(field)
262+
else:
263+
args["snapshot_schedule"] = None
264+
221265
return Instance(**args)
222266

223267

scaleway-async/scaleway_async/mongodb/v1alpha1/types.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,19 @@ class InstanceSetting:
185185
"""
186186

187187

188+
@dataclass
189+
class InstanceSnapshotSchedule:
190+
frequency_hours: int
191+
192+
retention_days: int
193+
194+
enabled: bool
195+
196+
next_update: Optional[datetime]
197+
198+
last_run: Optional[datetime]
199+
200+
188201
@dataclass
189202
class Volume:
190203
type_: VolumeType
@@ -388,6 +401,11 @@ class Instance:
388401
Creation date (must follow the ISO 8601 format).
389402
"""
390403

404+
snapshot_schedule: Optional[InstanceSnapshotSchedule]
405+
"""
406+
Snapshot schedule configuration of the Database Instance.
407+
"""
408+
391409

392410
@dataclass
393411
class NodeType:

scaleway/scaleway/mongodb/v1alpha1/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
from .types import EndpointSpecPublicDetails
1818
from .types import Endpoint
1919
from .types import InstanceSetting
20+
from .types import InstanceSnapshotSchedule
2021
from .types import Volume
2122
from .types import NodeTypeVolumeType
2223
from .types import SnapshotVolumeType
@@ -77,6 +78,7 @@
7778
"EndpointSpecPublicDetails",
7879
"Endpoint",
7980
"InstanceSetting",
81+
"InstanceSnapshotSchedule",
8082
"Volume",
8183
"NodeTypeVolumeType",
8284
"SnapshotVolumeType",

scaleway/scaleway/mongodb/v1alpha1/marshalling.py

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
EndpointPublicDetails,
1515
Endpoint,
1616
InstanceSetting,
17+
InstanceSnapshotSchedule,
1718
Volume,
1819
Instance,
1920
SnapshotVolumeType,
@@ -131,6 +132,43 @@ def unmarshal_InstanceSetting(data: Any) -> InstanceSetting:
131132
return InstanceSetting(**args)
132133

133134

135+
def unmarshal_InstanceSnapshotSchedule(data: Any) -> InstanceSnapshotSchedule:
136+
if not isinstance(data, dict):
137+
raise TypeError(
138+
"Unmarshalling the type 'InstanceSnapshotSchedule' failed as data isn't a dictionary."
139+
)
140+
141+
args: Dict[str, Any] = {}
142+
143+
field = data.get("frequency_hours", None)
144+
if field is not None:
145+
args["frequency_hours"] = field
146+
147+
field = data.get("retention_days", None)
148+
if field is not None:
149+
args["retention_days"] = field
150+
151+
field = data.get("enabled", None)
152+
if field is not None:
153+
args["enabled"] = field
154+
155+
field = data.get("next_update", None)
156+
if field is not None:
157+
args["next_update"] = (
158+
parser.isoparse(field) if isinstance(field, str) else field
159+
)
160+
else:
161+
args["next_update"] = None
162+
163+
field = data.get("last_run", None)
164+
if field is not None:
165+
args["last_run"] = parser.isoparse(field) if isinstance(field, str) else field
166+
else:
167+
args["last_run"] = None
168+
169+
return InstanceSnapshotSchedule(**args)
170+
171+
134172
def unmarshal_Volume(data: Any) -> Volume:
135173
if not isinstance(data, dict):
136174
raise TypeError(
@@ -218,6 +256,12 @@ def unmarshal_Instance(data: Any) -> Instance:
218256
else:
219257
args["created_at"] = None
220258

259+
field = data.get("snapshot_schedule", None)
260+
if field is not None:
261+
args["snapshot_schedule"] = unmarshal_InstanceSnapshotSchedule(field)
262+
else:
263+
args["snapshot_schedule"] = None
264+
221265
return Instance(**args)
222266

223267

scaleway/scaleway/mongodb/v1alpha1/types.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,19 @@ class InstanceSetting:
185185
"""
186186

187187

188+
@dataclass
189+
class InstanceSnapshotSchedule:
190+
frequency_hours: int
191+
192+
retention_days: int
193+
194+
enabled: bool
195+
196+
next_update: Optional[datetime]
197+
198+
last_run: Optional[datetime]
199+
200+
188201
@dataclass
189202
class Volume:
190203
type_: VolumeType
@@ -388,6 +401,11 @@ class Instance:
388401
Creation date (must follow the ISO 8601 format).
389402
"""
390403

404+
snapshot_schedule: Optional[InstanceSnapshotSchedule]
405+
"""
406+
Snapshot schedule configuration of the Database Instance.
407+
"""
408+
391409

392410
@dataclass
393411
class NodeType:

0 commit comments

Comments
 (0)