|
1 | 1 | # -*- coding: utf-8 -*- |
2 | 2 | from hcloud.actions.client import BoundAction |
3 | | -from hcloud.core.client import BoundModelBase, ClientEntityBase |
| 3 | +from hcloud.core.client import BoundModelBase, ClientEntityBase, GetEntityByNameMixin |
4 | 4 | from hcloud.core.domain import add_meta_to_result |
5 | 5 |
|
6 | 6 | from hcloud.images.domain import Image |
@@ -78,7 +78,7 @@ def change_protection(self, delete=None): |
78 | 78 | return self._client.change_protection(self, delete) |
79 | 79 |
|
80 | 80 |
|
81 | | -class ImagesClient(ClientEntityBase): |
| 81 | +class ImagesClient(ClientEntityBase, GetEntityByNameMixin): |
82 | 82 | results_list_attribute_name = 'images' |
83 | 83 |
|
84 | 84 | def get_actions_list(self, |
@@ -207,6 +207,16 @@ def get_all(self, |
207 | 207 | """ |
208 | 208 | return super(ImagesClient, self).get_all(name=name, label_selector=label_selector, bound_to=bound_to, type=type, sort=sort) |
209 | 209 |
|
| 210 | + def get_by_name(self, name): |
| 211 | + # type: (str) -> BoundImage |
| 212 | + """Get image by name |
| 213 | +
|
| 214 | + :param name: str |
| 215 | + Used to get image by name. |
| 216 | + :return: :class:`BoundImage <hcloud.images.client.BoundImage>` |
| 217 | + """ |
| 218 | + return super(ImagesClient, self).get_by_name(name) |
| 219 | + |
210 | 220 | def update(self, image, description=None, type=None, labels=None): |
211 | 221 | # type:(Image, Optional[str], Optional[str], Optional[Dict[str, str]]) -> BoundImage |
212 | 222 | """Updates the Image. You may change the description, convert a Backup image to a Snapshot Image or change the image labels. |
|
0 commit comments