Coverage for ocp_resources/application_aware_cluster_resource_quota.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# API reference: https://github.com/kubevirt/application-aware-quota/tree/main/staging/src/kubevirt.io/application-aware-quota-api/pkg/apis/core/v1alpha1
2# TODO: update API reference when OCP doc is available
3from __future__ import annotations
4from typing import Dict, Any
6from ocp_resources.resource import MissingRequiredArgumentError, Resource
9class ApplicationAwareClusterResourceQuota(Resource):
10 api_group = Resource.ApiGroup.AAQ_KUBEVIRT_IO
12 def __init__(
13 self,
14 quota: Dict[str, Any] | None = None,
15 selector: Dict[str, Any] | None = None,
16 **kwargs: Any,
17 ) -> None:
18 """
19 Create ApplicationAwareClusterResourceQuota object.
21 Args:
22 quota (dict): defines the desired quota
23 example: {"hard": {"pod": 3, "requests.cpu": "500m"}}
24 selector (dict): Dict of Namespace labels/annotations to match
25 example: {"annotations": {"acrq-annotation": "true"}, "labels": {"matchLabels": {"acrq-label": "true"}}}
26 """
27 super().__init__(**kwargs)
28 self.quota = quota
29 self.selector = selector
31 def to_dict(self):
32 super().to_dict()
33 if not self.kind_dict and not self.yaml_file:
34 if not (self.quota or self.selector):
35 raise MissingRequiredArgumentError(argument="'quota' or 'selector'")
37 self.res["spec"] = {}
38 _spec = self.res["spec"]
40 _spec["quota"] = self.quota
41 _spec["selector"] = self.selector