volumes¶
Model and Manager for Volume resources.
- class Volume(attrs: Mapping[str, Any] | None = None, client: APIClient | None = None, collection: Manager | None = None)[source]¶
Bases:
PodmanResource
Details and configuration for an image managed by the Podman service.
Initialize base class for PodmanResource’s.
- Parameters:
attrs – Mapping of attributes for resource from Podman service.
client – Configured connection to a Podman service.
collection – Manager of this category of resource, named collection for compatibility
- reload() None ¶
Refresh this object’s data from the service.
- remove(force: bool | None = None) None [source]¶
Delete this volume.
- Parameters:
force – When true, force deletion of in-use volume
- Raises:
APIError – when service reports an error
- property id¶
Returns the identifier for the object.
- Type:
str
- property name¶
Returns the name of the volume.
- Type:
str
- property short_id¶
Returns truncated identifier. ‘sha256’ preserved when included in the id.
No attempt is made to ensure the returned value is semantically meaningful for all resources.
- Type:
str
- class VolumesManager(client: APIClient = None)[source]¶
Bases:
Manager
Specialized Manager for Volume resources.
Initialize Manager() object.
- Parameters:
client – APIClient() configured to connect to Podman service.
- create(name: str | None = None, **kwargs) Volume [source]¶
Create a Volume.
- Parameters:
name – Name given to new volume
- Keyword Arguments:
driver (str) – Volume driver to use
driver_opts (Dict[str, str]) – Options to use with driver
labels (Dict[str, str]) – Labels to apply to volume
- Raises:
APIError – when service reports error
- exists(key: str) bool [source]¶
Returns True if resource exists.
Podman only.
Notes
This method does _not_ provide any mutex mechanism.
- get(volume_id: str) Volume [source]¶
Returns and volume by name or id.
- Parameters:
volume_id – Volume id or name for which to search
- Raises:
NotFound – when volume could not be found
APIError – when service reports an error
- list(*_, **kwargs) List[Volume] [source]¶
Report on volumes.
- Keyword Arguments:
filters (Dict[str, str]) –
criteria to filter Volume list
driver (str): filter volumes by their driver
label (Dict[str, str]): filter by label and/or value
name (str): filter by volume’s name
- prepare_model(attrs: PodmanResource | Mapping[str, Any]) PodmanResourceType ¶
Create a model from a set of attributes.
- prune(filters: Dict[str, str] | None = None) Dict[Literal['VolumesDeleted', 'SpaceReclaimed'], Any] [source]¶
Delete unused volumes.
- Parameters:
filters – Criteria for selecting volumes to delete. Ignored.
- Raises:
APIError – when service reports error