Coverage for ocp_resources/volume_snapshot.py: 0%
18 statements
« prev ^ index » next coverage.py v7.6.10, created at 2025-01-30 10:48 +0200
« prev ^ index » next coverage.py v7.6.10, created at 2025-01-30 10:48 +0200
1# Generated using https://github.com/RedHatQE/openshift-python-wrapper/blob/main/scripts/resource/README.md
3from typing import Any, Dict, Optional
4from ocp_resources.resource import NamespacedResource, MissingRequiredArgumentError
7class VolumeSnapshot(NamespacedResource):
8 """
9 VolumeSnapshot is a user's request for either creating a point-in-time snapshot of a persistent volume, or binding to a pre-existing snapshot.
10 """
12 api_group: str = NamespacedResource.ApiGroup.SNAPSHOT_STORAGE_K8S_IO
14 def __init__(
15 self,
16 source: Optional[Dict[str, Any]] = None,
17 volume_snapshot_class_name: Optional[str] = None,
18 **kwargs: Any,
19 ) -> None:
20 """
21 Args:
22 source (Dict[str, Any]): source specifies where a snapshot will be created from. This field is
23 immutable after creation. Required.
25 volume_snapshot_class_name (str): VolumeSnapshotClassName is the name of the VolumeSnapshotClass
26 requested by the VolumeSnapshot. VolumeSnapshotClassName may be
27 left nil to indicate that the default SnapshotClass should be
28 used. A given cluster may have multiple default Volume
29 SnapshotClasses: one default per CSI Driver. If a VolumeSnapshot
30 does not specify a SnapshotClass, VolumeSnapshotSource will be
31 checked to figure out what the associated CSI Driver is, and the
32 default VolumeSnapshotClass associated with that CSI Driver will
33 be used. If more than one VolumeSnapshotClass exist for a given
34 CSI Driver and more than one have been marked as default,
35 CreateSnapshot will fail and generate an event. Empty string is
36 not allowed for this field.
38 """
39 super().__init__(**kwargs)
41 self.source = source
42 self.volume_snapshot_class_name = volume_snapshot_class_name
44 def to_dict(self) -> None:
45 super().to_dict()
47 if not self.kind_dict and not self.yaml_file:
48 if not self.source:
49 raise MissingRequiredArgumentError(argument="self.source")
51 self.res["spec"] = {}
52 _spec = self.res["spec"]
54 _spec["source"] = self.source
56 if self.volume_snapshot_class_name is not None:
57 _spec["volumeSnapshotClassName"] = self.volume_snapshot_class_name
59 # End of generated code