VolumesClient
- class VolumesClient(client: Client)[source]
- actions: ResourceActionsClient
Volumes scoped actions client
- Type:
- 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:
volume –
BoundVolume
orVolume
server –
BoundServer
orServer
automount – boolean
- Returns:
- change_protection(volume: Volume | BoundVolume, delete: bool | None = None) BoundAction [source]
Changes the protection configuration of a volume.
- Parameters:
volume –
BoundVolume
orVolume
delete – boolean If True, prevents the volume from being deleted
- Returns:
- 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)
location –
BoundLocation
orLocation
server –
BoundServer
orServer
automount – boolean (optional) Auto mount volumes after attach.
format – str (optional) Format volume after creation. One of: xfs, ext4
- Returns:
- 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:
volume –
BoundVolume
orVolume
- 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:
volume –
BoundVolume
orVolume
- Returns:
- 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:
volume –
BoundVolume
orVolume
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:
volume –
BoundVolume
orVolume
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:
- get_by_name(name: str) BoundVolume | None [source]
Get volume by name
- Parameters:
name – str Used to get volume by name.
- Returns:
- 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:
volume –
BoundVolume
orVolume
size – int New volume size in GB (must be greater than current size)
- Returns:
- update(volume: Volume | BoundVolume, name: str | None = None, labels: dict[str, str] | None = None) BoundVolume [source]
Updates the volume properties.
- Parameters:
volume –
BoundVolume
orVolume
name – str (optional) New volume name
labels – Dict[str, str] (optional) User-defined labels (key-value pairs)
- Returns:
- 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:
server –
BoundServer
orServer
automount – boolean
- Returns:
- 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:
- 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:
- 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
)
- 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:
- 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:
- 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
server –
BoundServer
, 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
location –
BoundLocation
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:
volume –
BoundVolume
The created volumeaction –
BoundAction
The action that shows the progress of the Volume Creationnext_actions – List[
BoundAction
] List of actions that are performed after the creation, like attaching to a server