Coverage for ocp_resources/data_import_cron.py: 0%
33 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 __future__ import annotations
4from ocp_resources.resource import MissingRequiredArgumentError, NamespacedResource
6from typing import Any
9class DataImportCron(NamespacedResource):
10 """
11 DataImportCron defines a cron job for recurring polling/importing disk images as PVCs into a golden image namespace
12 """
14 api_group: str = NamespacedResource.ApiGroup.CDI_KUBEVIRT_IO
16 def __init__(
17 self,
18 garbage_collect: str | None = None,
19 imports_to_keep: int | None = None,
20 managed_data_source: str | None = None,
21 retention_policy: str | None = None,
22 schedule: str | None = None,
23 template: dict[str, Any] | None = None,
24 **kwargs: Any,
25 ) -> None:
26 """
27 Args:
28 garbage_collect (str): GarbageCollect specifies whether old PVCs should be cleaned up after a
29 new PVC is imported. Options are currently "Outdated" and "Never",
30 defaults to "Outdated".
32 imports_to_keep (int): Number of import PVCs to keep when garbage collecting. Default is 3.
34 managed_data_source (str): ManagedDataSource specifies the name of the corresponding DataSource
35 this cron will manage. DataSource has to be in the same namespace.
37 retention_policy (str): RetentionPolicy specifies whether the created DataVolumes and
38 DataSources are retained when their DataImportCron is deleted.
39 Default is RatainAll.
41 schedule (str): Schedule specifies in cron format when and how often to look for new
42 imports
44 template (dict[str, Any]): Template specifies template for the DVs to be created
46 """
47 super().__init__(**kwargs)
49 self.garbage_collect = garbage_collect
50 self.imports_to_keep = imports_to_keep
51 self.managed_data_source = managed_data_source
52 self.retention_policy = retention_policy
53 self.schedule = schedule
54 self.template = template
56 def to_dict(self) -> None:
57 super().to_dict()
59 if not self.kind_dict and not self.yaml_file:
60 if self.managed_data_source is None:
61 raise MissingRequiredArgumentError(argument="self.managed_data_source")
63 if self.schedule is None:
64 raise MissingRequiredArgumentError(argument="self.schedule")
66 if self.template is None:
67 raise MissingRequiredArgumentError(argument="self.template")
69 self.res["spec"] = {}
70 _spec = self.res["spec"]
72 _spec["managedDataSource"] = self.managed_data_source
73 _spec["schedule"] = self.schedule
74 _spec["template"] = self.template
76 if self.garbage_collect is not None:
77 _spec["garbageCollect"] = self.garbage_collect
79 if self.imports_to_keep is not None:
80 _spec["importsToKeep"] = self.imports_to_keep
82 if self.retention_policy is not None:
83 _spec["retentionPolicy"] = self.retention_policy
85 # End of generated code