@@ -31,28 +31,36 @@ def content_scan(self, scan_type: str, file_name: str, content: str, is_git_diff
3131        )
3232        return  self .parse_scan_response (response )
3333
34+     def  get_zipped_file_scan_url_path (self , scan_type : str ) ->  str :
35+         return  f'{ self .scan_config .get_service_name (scan_type )} { self .SCAN_CONTROLLER_PATH }  
36+ 
3437    def  zipped_file_scan (
3538        self , scan_type : str , zip_file : InMemoryZip , scan_id : str , scan_parameters : dict , is_git_diff : bool  =  False 
3639    ) ->  models .ZippedFileScanResult :
37-         url_path  =  f'{ self .scan_config .get_service_name (scan_type )} { self .SCAN_CONTROLLER_PATH }  
3840        files  =  {'file' : ('multiple_files_scan.zip' , zip_file .read ())}
3941
4042        response  =  self .scan_cycode_client .post (
41-             url_path = url_path ,
43+             url_path = self . get_zipped_file_scan_url_path ( scan_type ) ,
4244            data = {'scan_id' : scan_id , 'is_git_diff' : is_git_diff , 'scan_parameters' : json .dumps (scan_parameters )},
4345            files = files ,
4446            hide_response_content_log = self ._hide_response_log ,
4547        )
4648
4749        return  self .parse_zipped_file_scan_response (response )
4850
51+     def  get_zipped_file_scan_async_url_path (self , scan_type : str ) ->  str :
52+         async_scan_type  =  self .scan_config .get_async_scan_type (scan_type )
53+         async_entity_type  =  self .scan_config .get_async_entity_type (scan_type )
54+ 
55+         url_prefix  =  self .scan_config .get_scans_prefix ()
56+         return  f'{ url_prefix } { self .SCAN_CONTROLLER_PATH } { async_scan_type } { async_entity_type }  
57+ 
4958    def  zipped_file_scan_async (
5059        self , zip_file : InMemoryZip , scan_type : str , scan_parameters : dict , is_git_diff : bool  =  False 
5160    ) ->  models .ScanInitializationResponse :
52-         url_path  =  f'{ self .scan_config .get_scans_prefix ()} { self .SCAN_CONTROLLER_PATH } { scan_type }  
5361        files  =  {'file' : ('multiple_files_scan.zip' , zip_file .read ())}
5462        response  =  self .scan_cycode_client .post (
55-             url_path = url_path ,
63+             url_path = self . get_zipped_file_scan_async_url_path ( scan_type ) ,
5664            data = {'is_git_diff' : is_git_diff , 'scan_parameters' : json .dumps (scan_parameters )},
5765            files = files ,
5866        )
@@ -80,13 +88,17 @@ def multiple_zipped_file_scan_async(
8088        )
8189        return  models .ScanInitializationResponseSchema ().load (response .json ())
8290
91+     def  get_scan_details_path (self , scan_id : str ) ->  str :
92+         return  f'{ self .scan_config .get_scans_prefix ()} { self .SCAN_CONTROLLER_PATH } { scan_id }  
93+ 
8394    def  get_scan_details (self , scan_id : str ) ->  models .ScanDetailsResponse :
84-         url_path  =  f'{ self .scan_config .get_scans_prefix ()} { self .SCAN_CONTROLLER_PATH } { scan_id }  
85-         response  =  self .scan_cycode_client .get (url_path = url_path )
95+         response  =  self .scan_cycode_client .get (url_path = self .get_scan_details_path (scan_id ))
8696        return  models .ScanDetailsResponseSchema ().load (response .json ())
8797
98+     def  get_scan_detections_path (self ) ->  str :
99+         return  f'{ self .scan_config .get_detections_prefix ()} { self .DETECTIONS_SERVICE_CONTROLLER_PATH }  
100+ 
88101    def  get_scan_detections (self , scan_id : str ) ->  List [dict ]:
89-         url_path  =  f'{ self .scan_config .get_detections_prefix ()} { self .DETECTIONS_SERVICE_CONTROLLER_PATH }  
90102        params  =  {'scan_id' : scan_id }
91103
92104        page_size  =  200 
@@ -100,7 +112,9 @@ def get_scan_detections(self, scan_id: str) -> List[dict]:
100112            params ['page_number' ] =  page_number 
101113
102114            response  =  self .scan_cycode_client .get (
103-                 url_path = url_path , params = params , hide_response_content_log = self ._hide_response_log 
115+                 url_path = self .get_scan_detections_path (),
116+                 params = params ,
117+                 hide_response_content_log = self ._hide_response_log ,
104118            ).json ()
105119            detections .extend (response )
106120
@@ -109,9 +123,13 @@ def get_scan_detections(self, scan_id: str) -> List[dict]:
109123
110124        return  detections 
111125
126+     def  get_get_scan_detections_count_path (self ) ->  str :
127+         return  f'{ self .scan_config .get_detections_prefix ()} { self .DETECTIONS_SERVICE_CONTROLLER_PATH }  
128+ 
112129    def  get_scan_detections_count (self , scan_id : str ) ->  int :
113-         url_path  =  f'{ self .scan_config .get_detections_prefix ()} { self .DETECTIONS_SERVICE_CONTROLLER_PATH }  
114-         response  =  self .scan_cycode_client .get (url_path = url_path , params = {'scan_id' : scan_id })
130+         response  =  self .scan_cycode_client .get (
131+             url_path = self .get_get_scan_detections_count_path (), params = {'scan_id' : scan_id }
132+         )
115133        return  response .json ().get ('count' , 0 )
116134
117135    def  commit_range_zipped_file_scan (
@@ -126,9 +144,11 @@ def commit_range_zipped_file_scan(
126144        )
127145        return  self .parse_zipped_file_scan_response (response )
128146
147+     def  get_report_scan_status_path (self , scan_type : str , scan_id : str ) ->  str :
148+         return  f'{ self .scan_config .get_service_name (scan_type )} { self .SCAN_CONTROLLER_PATH } { scan_id }  
149+ 
129150    def  report_scan_status (self , scan_type : str , scan_id : str , scan_status : dict ) ->  None :
130-         url_path  =  f'{ self .scan_config .get_service_name (scan_type )} { self .SCAN_CONTROLLER_PATH } { scan_id }  
131-         self .scan_cycode_client .post (url_path = url_path , body = scan_status )
151+         self .scan_cycode_client .post (url_path = self .get_report_scan_status_path (scan_type , scan_id ), body = scan_status )
132152
133153    @staticmethod  
134154    def  parse_scan_response (response : Response ) ->  models .ScanResult :
@@ -140,6 +160,7 @@ def parse_zipped_file_scan_response(response: Response) -> models.ZippedFileScan
140160
141161    @staticmethod  
142162    def  get_service_name (scan_type : str ) ->  Optional [str ]:
163+         # TODO(MarshalX): get_service_name should be removed from ScanClient? Because it exists in ScanConfig 
143164        if  scan_type  ==  'secret' :
144165            return  'secret' 
145166        if  scan_type  ==  'iac' :
0 commit comments