Skip to content

Commit 5a73a28

Browse files
authored
feat: Add MaaSAuthPolicy,MaaSSubscription,MaaSModel resources (#2660)
* feat: Add MaaSAuthPolicy,MaaSSubscription,MaaSModel * fix: sort ApiGroup alphabetically
1 parent 3780106 commit 5a73a28

6 files changed

Lines changed: 2288 additions & 0 deletions

File tree

5.36 KB
Binary file not shown.

class_generator/schema/_definitions.json

Lines changed: 2116 additions & 0 deletions
Large diffs are not rendered by default.

ocp_resources/maa_s_auth_policy.py

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
# Generated using https://github.com/RedHatQE/openshift-python-wrapper/blob/main/scripts/resource/README.md
2+
3+
4+
from typing import Any
5+
6+
from ocp_resources.exceptions import MissingRequiredArgumentError
7+
from ocp_resources.resource import NamespacedResource
8+
9+
10+
class MaaSAuthPolicy(NamespacedResource):
11+
"""
12+
MaaSAuthPolicy is the Schema for the maasauthpolicies API
13+
"""
14+
15+
api_group: str = NamespacedResource.ApiGroup.MAAS_OPENDATAHUB_IO
16+
17+
def __init__(
18+
self,
19+
metering_metadata: dict[str, Any] | None = None,
20+
model_refs: list[Any] | None = None,
21+
subjects: dict[str, Any] | None = None,
22+
**kwargs: Any,
23+
) -> None:
24+
r"""
25+
Args:
26+
metering_metadata (dict[str, Any]): MeteringMetadata contains billing and tracking information
27+
28+
model_refs (list[Any]): ModelRefs is a list of model names that this policy grants access to
29+
30+
subjects (dict[str, Any]): Subjects defines who has access (OR logic - any match grants access)
31+
32+
"""
33+
super().__init__(**kwargs)
34+
35+
self.metering_metadata = metering_metadata
36+
self.model_refs = model_refs
37+
self.subjects = subjects
38+
39+
def to_dict(self) -> None:
40+
41+
super().to_dict()
42+
43+
if not self.kind_dict and not self.yaml_file:
44+
if self.model_refs is None:
45+
raise MissingRequiredArgumentError(argument="self.model_refs")
46+
47+
if self.subjects is None:
48+
raise MissingRequiredArgumentError(argument="self.subjects")
49+
50+
self.res["spec"] = {}
51+
_spec = self.res["spec"]
52+
53+
_spec["modelRefs"] = self.model_refs
54+
_spec["subjects"] = self.subjects
55+
56+
if self.metering_metadata is not None:
57+
_spec["meteringMetadata"] = self.metering_metadata
58+
59+
# End of generated code

ocp_resources/maa_s_model.py

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# Generated using https://github.com/RedHatQE/openshift-python-wrapper/blob/main/scripts/resource/README.md
2+
3+
4+
from typing import Any
5+
6+
from ocp_resources.exceptions import MissingRequiredArgumentError
7+
from ocp_resources.resource import NamespacedResource
8+
9+
10+
class MaaSModel(NamespacedResource):
11+
"""
12+
MaaSModel is the Schema for the maasmodels API
13+
"""
14+
15+
api_group: str = NamespacedResource.ApiGroup.MAAS_OPENDATAHUB_IO
16+
17+
def __init__(
18+
self,
19+
model_ref: dict[str, Any] | None = None,
20+
**kwargs: Any,
21+
) -> None:
22+
r"""
23+
Args:
24+
model_ref (dict[str, Any]): ModelRef references the actual model endpoint
25+
26+
"""
27+
super().__init__(**kwargs)
28+
29+
self.model_ref = model_ref
30+
31+
def to_dict(self) -> None:
32+
33+
super().to_dict()
34+
35+
if not self.kind_dict and not self.yaml_file:
36+
if self.model_ref is None:
37+
raise MissingRequiredArgumentError(argument="self.model_ref")
38+
39+
self.res["spec"] = {}
40+
_spec = self.res["spec"]
41+
42+
_spec["modelRef"] = self.model_ref
43+
44+
# End of generated code
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
# Generated using https://github.com/RedHatQE/openshift-python-wrapper/blob/main/scripts/resource/README.md
2+
3+
4+
from typing import Any
5+
6+
from ocp_resources.exceptions import MissingRequiredArgumentError
7+
from ocp_resources.resource import NamespacedResource
8+
9+
10+
class MaaSSubscription(NamespacedResource):
11+
"""
12+
MaaSSubscription is the Schema for the maassubscriptions API
13+
"""
14+
15+
api_group: str = NamespacedResource.ApiGroup.MAAS_OPENDATAHUB_IO
16+
17+
def __init__(
18+
self,
19+
billing_metadata: dict[str, Any] | None = None,
20+
model_refs: list[Any] | None = None,
21+
owner: dict[str, Any] | None = None,
22+
priority: int | None = None,
23+
**kwargs: Any,
24+
) -> None:
25+
r"""
26+
Args:
27+
billing_metadata (dict[str, Any]): BillingMetadata contains billing information
28+
29+
model_refs (list[Any]): ModelRefs defines which models are included with per-model token rate
30+
limits
31+
32+
owner (dict[str, Any]): Owner defines who owns this subscription
33+
34+
priority (int): Priority determines subscription priority when user has multiple
35+
subscriptions Higher numbers have higher priority. Defaults to 0.
36+
37+
"""
38+
super().__init__(**kwargs)
39+
40+
self.billing_metadata = billing_metadata
41+
self.model_refs = model_refs
42+
self.owner = owner
43+
self.priority = priority
44+
45+
def to_dict(self) -> None:
46+
47+
super().to_dict()
48+
49+
if not self.kind_dict and not self.yaml_file:
50+
if self.model_refs is None:
51+
raise MissingRequiredArgumentError(argument="self.model_refs")
52+
53+
if self.owner is None:
54+
raise MissingRequiredArgumentError(argument="self.owner")
55+
56+
self.res["spec"] = {}
57+
_spec = self.res["spec"]
58+
59+
_spec["modelRefs"] = self.model_refs
60+
_spec["owner"] = self.owner
61+
62+
if self.billing_metadata is not None:
63+
_spec["billingMetadata"] = self.billing_metadata
64+
65+
if self.priority is not None:
66+
_spec["priority"] = self.priority
67+
68+
# End of generated code

ocp_resources/resource.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -519,6 +519,7 @@ class ApiGroup:
519519
KUBEVIRT_KUBEVIRT_IO: str = "kubevirt.kubevirt.io"
520520
LITMUS_IO: str = "litmuschaos.io"
521521
LLAMASTACK_IO: str = "llamastack.io"
522+
MAAS_OPENDATAHUB_IO: str = "maas.opendatahub.io"
522523
MACHINE_OPENSHIFT_IO: str = "machine.openshift.io"
523524
MACHINECONFIGURATION_OPENSHIFT_IO: str = "machineconfiguration.openshift.io"
524525
MAISTRA_IO: str = "maistra.io"

0 commit comments

Comments
 (0)