VolumesClient

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

Volumes scoped actions client

Type:

ResourceActionsClient

attach(volume: Volume | BoundVolume, server: Server | BoundServer, automount: bool | None = None) BoundAction[source]

Attaches a volume to a server. Works only if the server is in the same location as the volume.

Parameters:
Returns:

BoundAction

change_protection(volume: Volume | BoundVolume, delete: bool | None = None) BoundAction[source]

Changes the protection configuration of a volume.

Parameters:
  • volumeBoundVolume or Volume

  • delete – boolean If True, prevents the volume from being deleted

Returns:

BoundAction

create(size: int, name: str, labels: str | None = None, location: Location | None = None, server: Server | None = None, automount: bool | None = None, format: str | None = None) CreateVolumeResponse[source]

Creates a new volume attached to a server.

Parameters:
  • size – int Size of the volume in GB

  • name – str Name of the volume

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

  • locationBoundLocation or Location

  • serverBoundServer or Server

  • automount – boolean (optional) Auto mount volumes after attach.

  • format – str (optional) Format volume after creation. One of: xfs, ext4

Returns:

CreateVolumeResponse

delete(volume: Volume | BoundVolume) bool[source]

Deletes a volume. All volume data is irreversibly destroyed. The volume must not be attached to a server and it must not have delete protection enabled.

Parameters:

volumeBoundVolume or Volume

Returns:

boolean

detach(volume: Volume | BoundVolume) BoundAction[source]

Detaches a volume from the server it’s attached to. You may attach it to a server again at a later time.

Parameters:

volumeBoundVolume or Volume

Returns:

BoundAction

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

Returns all action objects for a volume.

Parameters:
  • volumeBoundVolume or Volume

  • 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(volume: Volume | BoundVolume, status: list[str] | None = None, sort: list[str] | None = None, page: int | None = None, per_page: int | None = None) ActionsPageResult[source]

Returns all action objects for a volume.

Parameters:
  • volumeBoundVolume or Volume

  • 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(label_selector: str | None = None, status: list[str] | None = None) list[BoundVolume][source]

Get all volumes from this account

Parameters:
  • label_selector – Can be used to filter volumes by labels. The response will only contain volumes matching the label selector.

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

Returns:

List[BoundVolume]

get_by_id(id: int) BoundVolume[source]

Get a specific volume by its id

Parameters:

id – int

Returns:

BoundVolume

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

Get volume by name

Parameters:

name – str Used to get volume by name.

Returns:

BoundVolume

get_list(name: str | None = None, label_selector: str | None = None, page: int | None = None, per_page: int | None = None, status: list[str] | None = None) VolumesPageResult[source]

Get a list of volumes from this account

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

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

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

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

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

Returns:

(List[BoundVolume], Meta)

resize(volume: Volume | BoundVolume, size: int) BoundAction[source]

Changes the size of a volume. Note that downsizing a volume is not possible.

Parameters:
  • volumeBoundVolume or Volume

  • size – int New volume size in GB (must be greater than current size)

Returns:

BoundAction

update(volume: Volume | BoundVolume, name: str | None = None, labels: dict[str, str] | None = None) BoundVolume[source]

Updates the volume properties.

Parameters:
  • volumeBoundVolume or Volume

  • name – str (optional) New volume name

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

Returns:

BoundAction

class BoundVolume(client: VolumesClient, data: dict, complete: bool = True)[source]
attach(server: Server | BoundServer, automount: bool | None = None) BoundAction[source]

Attaches a volume to a server. Works only if the server is in the same location as the volume.

Parameters:
Returns:

BoundAction

change_protection(delete: bool | None = None) BoundAction[source]

Changes the protection configuration of a volume.

Parameters:

delete – boolean If True, prevents the volume from being deleted

Returns:

BoundAction

delete() bool[source]

Deletes a volume. All volume data is irreversibly destroyed. The volume must not be attached to a server and it must not have delete protection enabled.

Returns:

boolean

detach() BoundAction[source]

Detaches a volume from the server it’s attached to. You may attach it to a server again at a later time.

Returns:

BoundAction

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

Returns all action objects for a volume.

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(status: list[str] | None = None, sort: list[str] | None = None, page: int | None = None, per_page: int | None = None) ActionsPageResult[source]

Returns all action objects for a volume.

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 Volume

resize(size: int) BoundAction[source]

Changes the size of a volume. Note that downsizing a volume is not possible.

Parameters:

size – int New volume size in GB (must be greater than current size)

Returns:

BoundAction

update(name: str | None = None, labels: dict[str, str] | None = None) BoundVolume[source]

Updates the volume properties.

Parameters:
  • name – str (optional) New volume name

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

Returns:

BoundAction

class Volume(id: int, name: str | None = None, server: Server | BoundServer | None = None, created: str | None = None, location: Location | BoundLocation | None = None, size: int | None = None, linux_device: str | None = None, format: str | None = None, protection: dict | None = None, labels: dict[str, str] | None = None, status: str | None = None)[source]

Volume Domain

Parameters:
  • id – int ID of the Volume

  • name – str Name of the Volume

  • serverBoundServer, None Server the Volume is attached to, None if it is not attached at all.

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

  • locationBoundLocation Location of the Volume. Volume can only be attached to Servers in the same location.

  • size – int Size in GB of the Volume

  • linux_device – str Device path on the file system for the Volume

  • protection – dict Protection configuration for the Volume

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

  • status – str Current status of the volume Choices: creating, available

  • format – str, None Filesystem of the volume if formatted on creation, None if not formatted on creation.

STATUS_AVAILABLE = 'available'

Volume Status available

STATUS_CREATING = 'creating'

Volume Status creating

class CreateVolumeResponse(volume: BoundVolume, action: BoundAction, next_actions: list[BoundAction])[source]

Create Volume Response Domain

Parameters:
  • volumeBoundVolume The created volume

  • actionBoundAction The action that shows the progress of the Volume Creation

  • next_actions – List[BoundAction] List of actions that are performed after the creation, like attaching to a server