diff --git a/linode_api4/objects/image.py b/linode_api4/objects/image.py index 50dc23f74..bc9079c85 100644 --- a/linode_api4/objects/image.py +++ b/linode_api4/objects/image.py @@ -50,6 +50,7 @@ class ImageSharingSharedBy(JSONObject): sharegroup_uuid: Optional[str] = None sharegroup_label: Optional[str] = None source_image_id: Optional[str] = None + source_image_label: Optional[str] = None @dataclass diff --git a/test/unit/objects/image_test.py b/test/unit/objects/image_test.py index 1ea2fd66e..6a2056d6c 100644 --- a/test/unit/objects/image_test.py +++ b/test/unit/objects/image_test.py @@ -132,3 +132,36 @@ def test_image_replication(self): m.call_data, {"regions": ["us-east", "us-west"]}, ) + + def test_shared_image_source_label(self): + for shared_by, expected in ( + ({"source_image_label": "original-image"}, "original-image"), + ({"source_image_label": None}, None), + ({}, None), + ): + with self.subTest(shared_by=shared_by): + image_data = { + "id": "shared/1", + "image_sharing": {"shared_by": shared_by}, + } + + with self.mock_get(image_data): + image = self.client.load(Image, "shared/1") + + self.assertEqual( + image.image_sharing.shared_by.source_image_label, expected + ) + + with self.mock_get( + { + "data": [image_data], + "page": 1, + "pages": 1, + "results": 1, + } + ): + image = self.client.images().first() + + self.assertEqual( + image.image_sharing.shared_by.source_image_label, expected + )