@@ -709,6 +709,147 @@ def __repr__(self) -> str:
709
709
)
710
710
711
711
712
+ class DetectorType (str , Enum ):
713
+ SPECIFIC = "specific"
714
+ GENERIC = "generic"
715
+ CUSTOM = "custom"
716
+
717
+
718
+ class DetectorDetailsSchema (BaseSchema ):
719
+ name = fields .String (required = True )
720
+ display_name = fields .String (required = True )
721
+ type = fields .Enum (DetectorType , by_value = True , required = True )
722
+ category = fields .String (required = True )
723
+ is_active = fields .Boolean (required = True )
724
+ scans_code_only = fields .Boolean (required = True )
725
+ checkable = fields .Boolean (required = True )
726
+ use_with_validity_check_disabled = fields .Boolean (required = True )
727
+ frequency = fields .Float (required = True )
728
+ removed_at = fields .String (required = False , load_default = None , dump_default = None )
729
+ open_incidents_count = fields .Int (required = True )
730
+ ignored_incidents_count = fields .Int (required = True )
731
+ resolved_incidents_count = fields .Int (required = True )
732
+
733
+ @post_load
734
+ def make_detector (self , data : Dict [str , Any ], ** kwargs : Any ) -> "DetectorDetails" :
735
+ return DetectorDetails (** data )
736
+
737
+
738
+ class DetectorDetails (Base , FromDictMixin ):
739
+ """ "
740
+ Response from /v1/detectors, to retrieve a detetor details
741
+ from the API
742
+ {
743
+ "name": "aws_iam",
744
+ "display_name": "AWS Keys",
745
+ "type": "specific",
746
+ "category": "Cloud Provider",
747
+ "is_active": true,
748
+ "scans_code_only": false,
749
+ "checkable": true,
750
+ "use_with_validity_check_disabled": true,
751
+ "frequency": "1O3.74",
752
+ "removed_at": null,
753
+ "open_incidents_count": 17,
754
+ "ignored_incidents_count": 9,
755
+ "resolved_incidents_count": 42
756
+ }
757
+ """
758
+
759
+ SCHEMA = DetectorDetailsSchema ()
760
+
761
+ def __init__ (
762
+ self ,
763
+ name : str ,
764
+ display_name : str ,
765
+ type : DetectorType ,
766
+ category : str ,
767
+ is_active : bool ,
768
+ scans_code_only : bool ,
769
+ checkable : bool ,
770
+ use_with_validity_check_disabled : bool ,
771
+ frequency : float ,
772
+ removed_at : str | None ,
773
+ open_incidents_count : int ,
774
+ ignored_incidents_count : int ,
775
+ resolved_incidents_count : int ,
776
+ ** kwargs : Any ,
777
+ ):
778
+ super ().__init__ ()
779
+ self .name = name
780
+ self .display_name = display_name
781
+ self .type = type
782
+ self .category = category
783
+ self .is_active = is_active
784
+ self .scans_code_only = scans_code_only
785
+ self .checkable = checkable
786
+ self .use_with_validity_check_disabled = use_with_validity_check_disabled
787
+ self .frequency = frequency
788
+ self .removed_at = removed_at
789
+ self .open_incidents_count = open_incidents_count
790
+ self .ignored_incidents_count = ignored_incidents_count
791
+ self .resolved_incidents_count = resolved_incidents_count
792
+
793
+
794
+ class DetectorDetailsResponseSchema (BaseSchema ):
795
+ name = fields .String (required = True )
796
+ display_name = fields .String (required = True )
797
+ type = fields .Enum (DetectorType , by_value = True , required = True )
798
+ category = fields .String (required = True )
799
+ is_active = fields .Boolean (required = True )
800
+ scans_code_only = fields .Boolean (required = True )
801
+ checkable = fields .Boolean (required = True )
802
+ use_with_validity_check_disabled = fields .Boolean (required = True )
803
+ frequency = fields .Float (required = True )
804
+ removed_at = fields .String (required = False , load_default = None , dump_default = None )
805
+ open_incidents_count = fields .Int (required = True )
806
+ ignored_incidents_count = fields .Int (required = True )
807
+ resolved_incidents_count = fields .Int (required = True )
808
+
809
+ @post_load
810
+ def make_detector (self , data : Dict [str , Any ], ** kwargs : Any ) -> "DetectorDetails" :
811
+ return DetectorDetails (** data )
812
+
813
+
814
+ class DetectorDetailsResponse (Base , FromDictMixin ):
815
+ SCHEMA = DetectorDetailsResponseSchema ()
816
+
817
+ def __init__ (self , detector : DetectorDetails , ** kwargs : Any ):
818
+ super ().__init__ ()
819
+ self .name = detector .name
820
+ self .display_name = detector .display_name
821
+ self .type = detector .type
822
+ self .category = detector .category
823
+ self .is_active = detector .is_active
824
+ self .scans_code_only = detector .scans_code_only
825
+ self .checkable = detector .checkable
826
+ self .use_with_validity_check_disabled = (
827
+ detector .use_with_validity_check_disabled
828
+ )
829
+ self .frequency = detector .frequency
830
+ self .removed_at = detector .removed_at
831
+ self .open_incidents_count = detector .open_incidents_count
832
+ self .ignored_incidents_count = detector .ignored_incidents_count
833
+ self .resolved_incidents_count = detector .resolved_incidents_count
834
+
835
+ def __repr__ (self ) -> str :
836
+ return (
837
+ f"name:{ self .name } , "
838
+ f"display_name:{ self .display_name } , "
839
+ f"type:{ self .type } , "
840
+ f"category:{ self .category } , "
841
+ f"is_active:{ self .is_active } , "
842
+ f"scans_code_only:{ self .scans_code_only } , "
843
+ f"checkable:{ self .checkable } , "
844
+ f"use_with_validity_check_disabled:{ self .use_with_validity_check_disabled } , "
845
+ f"frequency:{ self .frequency } , "
846
+ f"removed_at:{ self .removed_at } , "
847
+ f"open_incidents_count:{ self .open_incidents_count } , "
848
+ f"ignored_incidents_count:{ self .ignored_incidents_count } , "
849
+ f"resolved_incidents_count:{ self .resolved_incidents_count } "
850
+ )
851
+
852
+
712
853
class TokenType (str , Enum ):
713
854
PERSONAL_ACCESS_TOKEN = "personal_access_token"
714
855
SERVICE_ACCOUNT = "service_account"
0 commit comments