From 714d8f879ba2e8cc0dbc75ce56bdcfa7679fafe6 Mon Sep 17 00:00:00 2001 From: Sibasish Behera Date: Tue, 24 Dec 2024 04:52:16 +0530 Subject: [PATCH] added new fields to VolumeSnapshot --- volume.go | 18 +++++++++--------- volume_snapshot.go | 4 +++- volume_snapshot_test.go | 8 ++++++++ volume_test.go | 12 ++++++++++++ 4 files changed, 32 insertions(+), 10 deletions(-) diff --git a/volume.go b/volume.go index a2f2ae1..f56cc0d 100644 --- a/volume.go +++ b/volume.go @@ -33,15 +33,15 @@ type VolumeResult struct { // VolumeConfig are the settings required to create a new Volume type VolumeConfig struct { - Name string `json:"name"` - Namespace string `json:"namespace"` - ClusterID string `json:"cluster_id"` - NetworkID string `json:"network_id"` - Region string `json:"region"` - SizeGigabytes int `json:"size_gb"` - Bootable bool `json:"bootable"` - VolumeType string `json:"volume_type"` - SnapshotID *string `json:"snapshot_id,omitempty"` + Name string `json:"name"` + Namespace string `json:"namespace"` + ClusterID string `json:"cluster_id"` + NetworkID string `json:"network_id"` + Region string `json:"region"` + SizeGigabytes int `json:"size_gb"` + Bootable bool `json:"bootable"` + VolumeType string `json:"volume_type"` + SnapshotID string `json:"snapshot_id,omitempty"` } // VolumeAttachConfig is the configuration used to attach volume diff --git a/volume_snapshot.go b/volume_snapshot.go index f1fadd1..decebad 100644 --- a/volume_snapshot.go +++ b/volume_snapshot.go @@ -12,9 +12,11 @@ type VolumeSnapshot struct { SnapshotID string `json:"snapshot_id"` SnapshotDescription string `json:"snapshot_description"` VolumeID string `json:"volume_id"` + InstanceID string `json:"instance_id,omitempty"` + SourceVolumeName string `json:"source_volume_name"` RestoreSize int `json:"restore_size"` State string `json:"state"` - CreationTime string `json:"creation_time"` + CreationTime string `json:"creation_time,omitempty"` } // VolumeSnapshotConfig is the configuration for creating a new VolumeSnapshot diff --git a/volume_snapshot_test.go b/volume_snapshot_test.go index dd1d78a..c425801 100644 --- a/volume_snapshot_test.go +++ b/volume_snapshot_test.go @@ -12,6 +12,8 @@ func TestListVolumeSnapshots(t *testing.T) { "snapshot_id": "12345", "snapshot_description": "snapshot for test", "volume_id": "12345", + "source_volume_name": "test-volume", + "instance_id": "ins1234", "restore_size": 20, "state": "available", "creation_time": "2020-01-01T00:00:00Z" @@ -32,6 +34,8 @@ func TestListVolumeSnapshots(t *testing.T) { SnapshotID: "12345", SnapshotDescription: "snapshot for test", VolumeID: "12345", + SourceVolumeName: "test-volume", + InstanceID: "ins1234", RestoreSize: 20, State: "available", CreationTime: "2020-01-01T00:00:00Z", @@ -50,6 +54,8 @@ func TestGetVolumeSnapshot(t *testing.T) { "snapshot_id": "snapshot-uuid", "snapshot_description": "snapshot for testing", "volume_id": "12345", + "source_volume_name": "test-volume", + "instance_id": "ins1234", "restore_size": 20, "state": "available", "creation_time": "2020-01-01T00:00:00Z" @@ -68,6 +74,8 @@ func TestGetVolumeSnapshot(t *testing.T) { SnapshotID: "snapshot-uuid", SnapshotDescription: "snapshot for testing", VolumeID: "12345", + SourceVolumeName: "test-volume", + InstanceID: "ins1234", RestoreSize: 20, State: "available", CreationTime: "2020-01-01T00:00:00Z", diff --git a/volume_test.go b/volume_test.go index 3e6fdb7..943b82f 100644 --- a/volume_test.go +++ b/volume_test.go @@ -268,6 +268,8 @@ func TestCreateVolumeSnapshot(t *testing.T) { "name": "test-snapshot", "snapshot_description": "snapshot for testing", "volume_id": "12346", + "instance_id": "instance-123", + "source_volume_name": "source-volume", "state": "available", "creation_time": "2020-01-01T00:00:00Z" }`, @@ -285,6 +287,8 @@ func TestCreateVolumeSnapshot(t *testing.T) { Name: "test-snapshot", SnapshotDescription: "snapshot for testing", VolumeID: "12346", + InstanceID: "instance-123", + SourceVolumeName: "source-volume", State: "available", CreationTime: "2020-01-01T00:00:00Z", } @@ -300,6 +304,8 @@ func TestGetVolumeSnapshotByVolumeID(t *testing.T) { "name": "test-snapshot", "snapshot_description": "snapshot for testing", "volume_id": "12346", + "instance_id": "instance-123", + "source_volume_name": "source-volume", "state": "available", "creation_time": "2020-01-01T00:00:00Z" }`, @@ -317,6 +323,8 @@ func TestGetVolumeSnapshotByVolumeID(t *testing.T) { Name: "test-snapshot", SnapshotDescription: "snapshot for testing", VolumeID: "12346", + InstanceID: "instance-123", + SourceVolumeName: "source-volume", State: "available", CreationTime: "2020-01-01T00:00:00Z", } @@ -333,6 +341,8 @@ func TestListVolumeSnapshotsByVolumeID(t *testing.T) { "name": "test-snapshot", "snapshot_description": "snapshot for testing", "volume_id": "12346", + "instance_id": "instance-123", + "source_volume_name": "source-volume", "state": "available", "creation_time": "2020-01-01T00:00:00Z" }]`, @@ -351,6 +361,8 @@ func TestListVolumeSnapshotsByVolumeID(t *testing.T) { Name: "test-snapshot", SnapshotDescription: "snapshot for testing", VolumeID: "12346", + InstanceID: "instance-123", + SourceVolumeName: "source-volume", State: "available", CreationTime: "2020-01-01T00:00:00Z", },