ImagesClient

class ImagesClient(client: Client)[source]
actions: ResourceActionsClient

Images scoped actions client

Type:

ResourceActionsClient

change_protection(image: Image | BoundImage, delete: bool | None = None) BoundAction[source]

Changes the protection configuration of the image. Can only be used on snapshots.

Parameters:
  • imageBoundImage or Image

  • delete – bool If true, prevents the snapshot from being deleted

Returns:

BoundAction

delete(image: Image | BoundImage) bool[source]

Deletes an Image. Only images of type snapshot and backup can be deleted.

:param BoundImage or Image :return: bool

get_actions(image: Image | BoundImage, sort: list[str] | None = None, status: list[str] | None = None) list[BoundAction][source]

Returns all action objects for an image.

Parameters:
  • imageBoundImage or Image

  • status – List[str] (optional) Response will have only actions with specified statuses. Choices: running success error

  • sort – List[str] (optional) Specify how the results are sorted. Choices: id command status progress started finished . You can add one of “:asc”, “:desc” to modify sort order. ( “:asc” is default)

Returns:

List[BoundAction]

get_actions_list(image: Image | BoundImage, sort: list[str] | None = None, page: int | None = None, per_page: int | None = None, status: list[str] | None = None) ActionsPageResult[source]

Returns a list of action objects for an image.

Parameters:
  • imageBoundImage or Image

  • status – List[str] (optional) Response will have only actions with specified statuses. Choices: running success error

  • sort – List[str] (optional) Specify how the results are sorted. Choices: id id:asc id:desc command command:asc command:desc status status:asc status:desc progress progress:asc progress:desc started started:asc started:desc finished finished:asc finished:desc

  • page – int (optional) Specifies the page to fetch

  • per_page – int (optional) Specifies how many results are returned by page

Returns:

(List[BoundAction], Meta)

get_all(name: str | None = None, label_selector: str | None = None, bound_to: list[str] | None = None, type: list[str] | None = None, architecture: list[str] | None = None, sort: list[str] | None = None, status: list[str] | None = None, include_deprecated: bool | None = None) list[BoundImage][source]

Get all images

Parameters:
  • name – str (optional) Can be used to filter images by their name.

  • label_selector – str (optional) Can be used to filter servers by labels. The response will only contain servers matching the label selector.

  • bound_to – List[str] (optional) Server Id linked to the image. Only available for images of type backup

  • type – List[str] (optional) Choices: system snapshot backup

  • architecture – List[str] (optional) Choices: x86 arm

  • status – List[str] (optional) Can be used to filter images by their status. The response will only contain images matching the status.

  • sort – List[str] (optional) Choices: id name created (You can add one of “:asc”, “:desc” to modify sort order. ( “:asc” is default))

  • include_deprecated – bool (optional) Include deprecated images in the response. Default: False

Returns:

List[BoundImage]

get_by_id(id: int) BoundImage[source]

Get a specific Image

Parameters:

id – int

Returns:

BoundImage <hcloud.images.client.BoundImage

get_by_name(name: str) BoundImage | None[source]

Get image by name

Parameters:

name – str Used to get image by name.

Returns:

BoundImage

Deprecated since version 1.19: Use hcloud.images.client.ImagesClient.get_by_name_and_architecture() instead.

get_by_name_and_architecture(name: str, architecture: str, *, include_deprecated: bool | None = None) BoundImage | None[source]

Get image by name

Parameters:
  • name – str Used to identify the image.

  • architecture – str Used to identify the image.

  • include_deprecated – bool (optional) Include deprecated images. Default: False

Returns:

BoundImage

get_list(name: str | None = None, label_selector: str | None = None, bound_to: list[str] | None = None, type: list[str] | None = None, architecture: list[str] | None = None, sort: list[str] | None = None, page: int | None = None, per_page: int | None = None, status: list[str] | None = None, include_deprecated: bool | None = None) ImagesPageResult[source]

Get all images

Parameters:
  • name – str (optional) Can be used to filter images by their name.

  • label_selector – str (optional) Can be used to filter servers by labels. The response will only contain servers matching the label selector.

  • bound_to – List[str] (optional) Server Id linked to the image. Only available for images of type backup

  • type – List[str] (optional) Choices: system snapshot backup

  • architecture – List[str] (optional) Choices: x86 arm

  • status – List[str] (optional) Can be used to filter images by their status. The response will only contain images matching the status.

  • sort – List[str] (optional) Choices: id id:asc id:desc name name:asc name:desc created created:asc created:desc

  • include_deprecated – bool (optional) Include deprecated images in the response. Default: False

  • page – int (optional) Specifies the page to fetch

  • per_page – int (optional) Specifies how many results are returned by page

Returns:

(List[BoundImage], Meta)

update(image: Image | BoundImage, description: str | None = None, type: str | None = None, labels: dict[str, str] | None = None) BoundImage[source]

Updates the Image. You may change the description, convert a Backup image to a Snapshot Image or change the image labels.

Parameters:
  • imageBoundImage or Image

  • description – str (optional) New description of Image

  • type – str (optional) Destination image type to convert to Choices: snapshot

  • labels – Dict[str, str] (optional) User-defined labels (key-value pairs)

Returns:

BoundImage

class BoundImage(client: ImagesClient, data: dict)[source]
change_protection(delete: bool | None = None) BoundAction[source]

Changes the protection configuration of the image. Can only be used on snapshots.

Parameters:

delete – bool If true, prevents the snapshot from being deleted

Returns:

BoundAction

delete() bool[source]

Deletes an Image. Only images of type snapshot and backup can be deleted.

Returns:

bool

get_actions(sort: list[str] | None = None, status: list[str] | None = None) list[BoundAction][source]

Returns all action objects for the image.

Parameters:
  • status – List[str] (optional) Response will have only actions with specified statuses. Choices: running success error

  • sort – List[str] (optional) Specify how the results are sorted. Choices: id id:asc id:desc command command:asc command:desc status status:asc status:desc progress progress:asc progress:desc started started:asc started:desc finished finished:asc finished:desc

Returns:

List[BoundAction]

get_actions_list(sort: list[str] | None = None, page: int | None = None, per_page: int | None = None, status: list[str] | None = None) ActionsPageResult[source]

Returns a list of action objects for the image.

Parameters:
  • status – List[str] (optional) Response will have only actions with specified statuses. Choices: running success error

  • sort – List[str] (optional) Specify how the results are sorted. Choices: id id:asc id:desc command command:asc command:desc status status:asc status:desc progress progress:asc progress:desc started started:asc started:desc finished finished:asc finished:desc

  • page – int (optional) Specifies the page to fetch

  • per_page – int (optional) Specifies how many results are returned by page

Returns:

(List[BoundAction], Meta)

model

alias of Image

update(description: str | None = None, type: str | None = None, labels: dict[str, str] | None = None) BoundImage[source]

Updates the Image. You may change the description, convert a Backup image to a Snapshot Image or change the image labels.

Parameters:
  • description – str (optional) New description of Image

  • type – str (optional) Destination image type to convert to Choices: snapshot

  • labels – Dict[str, str] (optional) User-defined labels (key-value pairs)

Returns:

BoundImage

class Image(id: int | None = None, name: str | None = None, type: str | None = None, created: str | None = None, description: str | None = None, image_size: int | None = None, disk_size: int | None = None, deprecated: str | None = None, bound_to: Server | BoundServer | None = None, os_flavor: str | None = None, os_version: str | None = None, architecture: str | None = None, rapid_deploy: bool | None = None, created_from: Server | BoundServer | None = None, protection: dict | None = None, labels: dict[str, str] | None = None, status: str | None = None)[source]

Image Domain

Parameters:
  • id – int ID of the image

  • type – str Type of the image Choices: system, snapshot, backup, app

  • status – str Whether the image can be used or if it’s still being created Choices: available, creating

  • name – str, None Unique identifier of the image. This value is only set for system images.

  • description – str Description of the image

  • image_size – number, None Size of the image file in our storage in GB. For snapshot images this is the value relevant for calculating costs for the image.

  • disk_size – number Size of the disk contained in the image in GB.

  • created – datetime Point in time when the image was created

  • created_fromBoundServer, None Information about the server the image was created from

  • bound_toBoundServer, None ID of server the image is bound to. Only set for images of type backup.

  • os_flavor – str Flavor of operating system contained in the image Choices: ubuntu, centos, debian, fedora, unknown

  • os_version – str, None Operating system version

  • architecture – str CPU Architecture that the image is compatible with. Choices: x86, arm

  • rapid_deploy – bool Indicates that rapid deploy of the image is available

  • protection – dict Protection configuration for the image

  • deprecated – datetime, None Point in time when the image is considered to be deprecated (in ISO-8601 format)

  • labels – Dict User-defined labels (key-value pairs)

class CreateImageResponse(action: BoundAction, image: BoundImage)[source]

Create Image Response Domain

Parameters:
  • imageBoundImage The Image which was created

  • actionBoundAction The Action which shows the progress of the Floating IP Creation