16
16
17
17
import json
18
18
import pprint
19
+ import re # noqa: F401
19
20
from typing import Any , ClassVar , Dict , List , Optional , Set
20
21
21
- from pydantic import BaseModel , ConfigDict , Field , StrictStr
22
- from typing_extensions import Self
22
+ from pydantic import BaseModel , ConfigDict , Field , StrictStr , field_validator
23
+ from typing_extensions import Annotated , Self
23
24
24
25
from stackit .stackitmarketplace .models .catalog_pricing_option_highlight import (
25
26
CatalogPricingOptionHighlight ,
@@ -38,6 +39,9 @@ class CatalogProductPricingOption(BaseModel):
38
39
highlights : List [CatalogPricingOptionHighlight ] = Field (description = "The list of highlights." )
39
40
name : StrictStr = Field (description = "The pricing option name." )
40
41
notice_period : Optional [NoticePeriod ] = Field (default = None , alias = "noticePeriod" )
42
+ plan_id : Annotated [str , Field (min_length = 10 , strict = True , max_length = 29 )] = Field (
43
+ description = "The user-readable plan ID of a pricing option." , alias = "planId"
44
+ )
41
45
price_type : Optional [PriceType ] = Field (default = None , alias = "priceType" )
42
46
pricing_plan : Optional [StrictStr ] = Field (
43
47
default = None , description = "Additional price type information." , alias = "pricingPlan"
@@ -54,6 +58,7 @@ class CatalogProductPricingOption(BaseModel):
54
58
"highlights" ,
55
59
"name" ,
56
60
"noticePeriod" ,
61
+ "planId" ,
57
62
"priceType" ,
58
63
"pricingPlan" ,
59
64
"rate" ,
@@ -63,6 +68,13 @@ class CatalogProductPricingOption(BaseModel):
63
68
"unit" ,
64
69
]
65
70
71
+ @field_validator ("plan_id" )
72
+ def plan_id_validate_regular_expression (cls , value ):
73
+ """Validates the regular expression"""
74
+ if not re .match (r"^[a-z0-9-]{1,20}-[0-9a-f]{8}$" , value ):
75
+ raise ValueError (r"must validate the regular expression /^[a-z0-9-]{1,20}-[0-9a-f]{8}$/" )
76
+ return value
77
+
66
78
model_config = ConfigDict (
67
79
populate_by_name = True ,
68
80
validate_assignment = True ,
@@ -133,6 +145,7 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
133
145
"noticePeriod" : (
134
146
NoticePeriod .from_dict (obj ["noticePeriod" ]) if obj .get ("noticePeriod" ) is not None else None
135
147
),
148
+ "planId" : obj .get ("planId" ),
136
149
"priceType" : obj .get ("priceType" ),
137
150
"pricingPlan" : obj .get ("pricingPlan" ),
138
151
"rate" : obj .get ("rate" ),
0 commit comments