|
20 | 20 | CreateVolumeRequest, |
21 | 21 | CreateVolumeRequestFromEmpty, |
22 | 22 | CreateVolumeRequestFromSnapshot, |
| 23 | + ImportSnapshotFromS3Request, |
23 | 24 | ListSnapshotsResponse, |
24 | 25 | ListVolumeTypesResponse, |
25 | 26 | ListVolumesResponse, |
|
41 | 42 | unmarshal_ListVolumesResponse, |
42 | 43 | marshal_CreateSnapshotRequest, |
43 | 44 | marshal_CreateVolumeRequest, |
| 45 | + marshal_ImportSnapshotFromS3Request, |
44 | 46 | marshal_UpdateSnapshotRequest, |
45 | 47 | marshal_UpdateVolumeRequest, |
46 | 48 | ) |
@@ -643,6 +645,62 @@ async def create_snapshot( |
643 | 645 | self._throw_on_error(res) |
644 | 646 | return unmarshal_Snapshot(res.json()) |
645 | 647 |
|
| 648 | + async def import_snapshot_from_s3( |
| 649 | + self, |
| 650 | + *, |
| 651 | + bucket: str, |
| 652 | + key: str, |
| 653 | + name: str, |
| 654 | + zone: Optional[Zone] = None, |
| 655 | + project_id: Optional[str] = None, |
| 656 | + tags: Optional[List[str]] = None, |
| 657 | + size: Optional[int] = None, |
| 658 | + ) -> Snapshot: |
| 659 | + """ |
| 660 | + Import a snapshot from a Scaleway Object Storage bucket. |
| 661 | + The bucket must contain a QCOW2 image. |
| 662 | + The bucket can be imported into any Availability Zone as long as it is in the same region as the bucket. |
| 663 | + :param bucket: Scaleway Object Storage bucket where the object is stored. |
| 664 | + :param key: The object key inside the given bucket. |
| 665 | + :param name: Name of the snapshot. |
| 666 | + :param zone: Zone to target. If none is passed will use default zone from the config. |
| 667 | + :param project_id: UUID of the Project to which the volume and the snapshot belong. |
| 668 | + :param tags: List of tags assigned to the snapshot. |
| 669 | + :param size: Size of the snapshot. |
| 670 | + :return: :class:`Snapshot <Snapshot>` |
| 671 | +
|
| 672 | + Usage: |
| 673 | + :: |
| 674 | +
|
| 675 | + result = await api.import_snapshot_from_s3( |
| 676 | + bucket="example", |
| 677 | + key="example", |
| 678 | + name="example", |
| 679 | + ) |
| 680 | + """ |
| 681 | + |
| 682 | + param_zone = validate_path_param("zone", zone or self.client.default_zone) |
| 683 | + |
| 684 | + res = self._request( |
| 685 | + "POST", |
| 686 | + f"/block/v1alpha1/zones/{param_zone}/snapshots/import-from-s3", |
| 687 | + body=marshal_ImportSnapshotFromS3Request( |
| 688 | + ImportSnapshotFromS3Request( |
| 689 | + bucket=bucket, |
| 690 | + key=key, |
| 691 | + name=name, |
| 692 | + zone=zone, |
| 693 | + project_id=project_id, |
| 694 | + tags=tags, |
| 695 | + size=size, |
| 696 | + ), |
| 697 | + self.client, |
| 698 | + ), |
| 699 | + ) |
| 700 | + |
| 701 | + self._throw_on_error(res) |
| 702 | + return unmarshal_Snapshot(res.json()) |
| 703 | + |
646 | 704 | async def delete_snapshot( |
647 | 705 | self, |
648 | 706 | *, |
|
0 commit comments