10
10
11
11
from keeper .editiontracking import EditionTrackingModes
12
12
from keeper .exceptions import ValidationError
13
- from keeper .models import OrganizationLayoutMode
13
+ from keeper .models import EditionKind , OrganizationLayoutMode
14
14
from keeper .utils import (
15
15
format_utc_datetime ,
16
16
validate_path_slug ,
@@ -119,7 +119,6 @@ def from_organization(cls, org: Organization) -> OrganizationResponse:
119
119
120
120
121
121
class LayoutEnum (str , Enum ):
122
-
123
122
subdomain = "subdomain"
124
123
125
124
path = "path"
@@ -576,6 +575,9 @@ class EditionResponse(BaseModel):
576
575
mode : str
577
576
"""The edition tracking mode."""
578
577
578
+ kind : str
579
+ """The edition kind."""
580
+
579
581
@classmethod
580
582
def from_edition (
581
583
cls ,
@@ -609,6 +611,7 @@ def from_edition(
609
611
"date_rebuilt" : edition .date_rebuilt ,
610
612
"date_ended" : edition .date_ended ,
611
613
"mode" : edition .mode_name ,
614
+ "kind" : edition .kind_name ,
612
615
"tracked_ref" : tracked_ref ,
613
616
"pending_rebuild" : edition .pending_rebuild ,
614
617
"surrogate_key" : edition .surrogate_key ,
@@ -661,6 +664,9 @@ class EditionPostRequest(BaseModel):
661
664
mode : str = "git_refs"
662
665
"""Tracking mode."""
663
666
667
+ kind : Optional [str ] = None
668
+ """The edition kind."""
669
+
664
670
tracked_ref : Optional [str ] = None
665
671
"""Git ref being tracked if mode is ``git_ref``."""
666
672
@@ -708,6 +714,17 @@ def check_tracked_refs(
708
714
raise ValueError ('tracked_ref must be set if mode is "git_ref"' )
709
715
return v
710
716
717
+ @validator ("kind" )
718
+ def check_kind (cls , v : Optional [str ]) -> Optional [str ]:
719
+ if v is None :
720
+ return None
721
+
722
+ # Get all known kinds from the EditionKind enum
723
+ kind_names = [kind .name for kind in EditionKind ]
724
+ if v not in kind_names :
725
+ raise ValueError (f"Kind { v !r} is not known." )
726
+ return v
727
+
711
728
712
729
class EditionPatchRequest (BaseModel ):
713
730
"""The model for a PATCH /editions/:id request."""
@@ -731,6 +748,9 @@ class EditionPatchRequest(BaseModel):
731
748
mode : Optional [str ] = None
732
749
"""The edition tracking mode."""
733
750
751
+ kind : Optional [str ] = None
752
+ """The edition kind."""
753
+
734
754
build_url : Optional [HttpUrl ] = None
735
755
"""URL of the build to initially publish with the edition, if available.
736
756
"""
@@ -756,6 +776,17 @@ def check_mode(cls, v: Optional[str]) -> Optional[str]:
756
776
raise ValueError (f"Tracking mode { v !r} is not known." )
757
777
return v
758
778
779
+ @validator ("kind" )
780
+ def check_kind (cls , v : Optional [str ]) -> Optional [str ]:
781
+ if v is None :
782
+ return None
783
+
784
+ # Get all known kinds from the EditionKind enum
785
+ kind_names = [kind .name for kind in EditionKind ]
786
+ if v not in kind_names :
787
+ raise ValueError (f"Kind { v !r} is not known." )
788
+ return v
789
+
759
790
760
791
class QueuedResponse (BaseModel ):
761
792
"""Response that contains only a URL for the background task's status."""
0 commit comments