Skip to content

Commit 6cb038f

Browse files
authored
feat: add maas_auth_policy and maas_subscription resources and deprecate old. (#2670)
* feat: add maas_auth_policy and maas_subscription resources and deprecate old * fix: move MaaSAuthPolicy and MaaSSubscription deprecation warning to module level after class definition
1 parent 7c92608 commit 6cb038f

5 files changed

Lines changed: 146 additions & 0 deletions

File tree

419 Bytes
Binary file not shown.

ocp_resources/maa_s_auth_policy.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33

44
from typing import Any
5+
from warnings import warn
56

67
from ocp_resources.exceptions import MissingRequiredArgumentError
78
from ocp_resources.resource import NamespacedResource
@@ -57,3 +58,11 @@ def to_dict(self) -> None:
5758
_spec["meteringMetadata"] = self.metering_metadata
5859

5960
# End of generated code
61+
62+
63+
warn(
64+
"MaaSAuthPolicy from maa_s_auth_policy.py is deprecated and will be removed in a future release. "
65+
"Please use `MaaSAuthPolicy` from maas_auth_policy.py instead.",
66+
DeprecationWarning,
67+
stacklevel=2,
68+
)

ocp_resources/maa_s_subscription.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33

44
from typing import Any
5+
from warnings import warn
56

67
from ocp_resources.exceptions import MissingRequiredArgumentError
78
from ocp_resources.resource import NamespacedResource
@@ -66,3 +67,11 @@ def to_dict(self) -> None:
6667
_spec["priority"] = self.priority
6768

6869
# End of generated code
70+
71+
72+
warn(
73+
"MaaSSubscription from maa_s_subscription.py is deprecated and will be removed in a future release. "
74+
"Please use `MaaSSubscription` from maas_subscription.py instead.",
75+
DeprecationWarning,
76+
stacklevel=2,
77+
)

ocp_resources/maas_auth_policy.py

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
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 models (by name and namespace) that this policy
29+
grants access to
30+
31+
subjects (dict[str, Any]): Subjects defines who has access (OR logic - any match grants access)
32+
33+
"""
34+
super().__init__(**kwargs)
35+
36+
self.metering_metadata = metering_metadata
37+
self.model_refs = model_refs
38+
self.subjects = subjects
39+
40+
def to_dict(self) -> None:
41+
42+
super().to_dict()
43+
44+
if not self.kind_dict and not self.yaml_file:
45+
if self.model_refs is None:
46+
raise MissingRequiredArgumentError(argument="self.model_refs")
47+
48+
if self.subjects is None:
49+
raise MissingRequiredArgumentError(argument="self.subjects")
50+
51+
self.res["spec"] = {}
52+
_spec = self.res["spec"]
53+
54+
_spec["modelRefs"] = self.model_refs
55+
_spec["subjects"] = self.subjects
56+
57+
if self.metering_metadata is not None:
58+
_spec["meteringMetadata"] = self.metering_metadata
59+
60+
# End of generated code

ocp_resources/maas_subscription.py

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+
model_refs: list[Any] | None = None,
20+
owner: dict[str, Any] | None = None,
21+
priority: int | None = None,
22+
token_metadata: dict[str, Any] | None = None,
23+
**kwargs: Any,
24+
) -> None:
25+
r"""
26+
Args:
27+
model_refs (list[Any]): ModelRefs defines which models are included with per-model token rate
28+
limits
29+
30+
owner (dict[str, Any]): Owner defines who owns this subscription
31+
32+
priority (int): Priority determines subscription priority when user has multiple
33+
subscriptions Higher numbers have higher priority. Defaults to 0.
34+
35+
token_metadata (dict[str, Any]): TokenMetadata contains metadata for token attribution and metering
36+
37+
"""
38+
super().__init__(**kwargs)
39+
40+
self.model_refs = model_refs
41+
self.owner = owner
42+
self.priority = priority
43+
self.token_metadata = token_metadata
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.priority is not None:
63+
_spec["priority"] = self.priority
64+
65+
if self.token_metadata is not None:
66+
_spec["tokenMetadata"] = self.token_metadata
67+
68+
# End of generated code

0 commit comments

Comments
 (0)