Skip to content

Commit 0076612

Browse files
CM-60184-Move to V4 controllers
1 parent dec4f9f commit 0076612

3 files changed

Lines changed: 11 additions & 11 deletions

File tree

cycode/cli/apps/scan/code_scanner.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ def scan_documents(
217217
print_local_scan_results(ctx, local_scan_results, errors)
218218

219219

220-
def _perform_scan_v2_async(
220+
def _perform_scan_v4_async(
221221
cycode_client: 'ScanClient',
222222
zipped_documents: 'InMemoryZip',
223223
scan_type: str,
@@ -228,13 +228,13 @@ def _perform_scan_v2_async(
228228
upload_link = cycode_client.get_upload_link(scan_type)
229229
logger.debug('Got upload link, %s', {'upload_id': upload_link.upload_id})
230230

231-
cycode_client.upload_to_presigned_post(upload_link.url, upload_link.fields, zipped_documents)
231+
cycode_client.upload_to_presigned_post(upload_link.url, upload_link.presigned_post_fields, zipped_documents)
232232
logger.debug('Uploaded zip to presigned URL')
233233

234234
scan_async_result = cycode_client.scan_repository_from_upload_id(
235235
scan_type, upload_link.upload_id, scan_parameters, is_git_diff, is_commit_range
236236
)
237-
logger.debug('V2 scan request triggered, %s', {'scan_id': scan_async_result.scan_id})
237+
logger.debug('V4 scan request triggered, %s', {'scan_id': scan_async_result.scan_id})
238238

239239
return poll_scan_results(cycode_client, scan_async_result.scan_id, scan_type, scan_parameters)
240240

@@ -285,7 +285,7 @@ def _perform_scan(
285285
return _perform_scan_sync(cycode_client, zipped_documents, scan_type, scan_parameters, is_git_diff)
286286

287287
if scan_type == consts.SAST_SCAN_TYPE:
288-
return _perform_scan_v2_async(
288+
return _perform_scan_v4_async(
289289
cycode_client, zipped_documents, scan_type, scan_parameters, is_git_diff, is_commit_range
290290
)
291291

cycode/cyclient/models.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ def build_dto(self, data: dict[str, Any], **_) -> 'ScanResult':
118118
class UploadLinkResponse:
119119
upload_id: str
120120
url: str
121-
fields: dict[str, str]
121+
presigned_post_fields: dict[str, str]
122122

123123

124124
class UploadLinkResponseSchema(Schema):
@@ -127,7 +127,7 @@ class Meta:
127127

128128
upload_id = fields.String()
129129
url = fields.String()
130-
fields = fields.Dict(keys=fields.String(), values=fields.String())
130+
presigned_post_fields = fields.Dict(keys=fields.String(), values=fields.String())
131131

132132
@post_load
133133
def build_dto(self, data: dict[str, Any], **_) -> 'UploadLinkResponse':

cycode/cyclient/scan_client.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def __init__(
2626
self.scan_config = scan_config
2727

2828
self._SCAN_SERVICE_CLI_CONTROLLER_PATH = 'api/v1/cli-scan'
29-
self._SCAN_SERVICE_V2_CLI_CONTROLLER_PATH = 'api/v2/cli-scan'
29+
self._SCAN_SERVICE_V4_CLI_CONTROLLER_PATH = 'api/v4/scans/cli'
3030
self._DETECTIONS_SERVICE_CLI_CONTROLLER_PATH = 'api/v1/detections/cli'
3131
self._POLICIES_SERVICE_CONTROLLER_PATH_V3 = 'api/v3/policies'
3232

@@ -58,9 +58,9 @@ def get_scan_aggregation_report_url(self, aggregation_id: str, scan_type: str) -
5858
)
5959
return models.ScanReportUrlResponseSchema().build_dto(response.json())
6060

61-
def get_scan_service_v2_url_path(self, scan_type: str) -> str:
61+
def get_scan_service_v4_url_path(self, scan_type: str) -> str:
6262
service_path = self.scan_config.get_service_name(scan_type)
63-
return f'{service_path}/{self._SCAN_SERVICE_V2_CLI_CONTROLLER_PATH}'
63+
return f'{service_path}/{self._SCAN_SERVICE_V4_CLI_CONTROLLER_PATH}'
6464

6565
def get_zipped_file_scan_async_url_path(self, scan_type: str, should_use_sync_flow: bool = False) -> str:
6666
async_scan_type = self.scan_config.get_async_scan_type(scan_type)
@@ -131,7 +131,7 @@ def zipped_file_scan_async(
131131

132132
def get_upload_link(self, scan_type: str) -> models.UploadLinkResponse:
133133
async_scan_type = self.scan_config.get_async_scan_type(scan_type)
134-
url_path = f'{self.get_scan_service_v2_url_path(scan_type)}/{async_scan_type}/upload-link'
134+
url_path = f'{self.get_scan_service_v4_url_path(scan_type)}/{async_scan_type}/upload-link'
135135
response = self.scan_cycode_client.get(url_path=url_path, hide_response_content_log=self._hide_response_log)
136136
return models.UploadLinkResponseSchema().load(response.json())
137137

@@ -150,7 +150,7 @@ def scan_repository_from_upload_id(
150150
is_commit_range: bool = False,
151151
) -> models.ScanInitializationResponse:
152152
async_scan_type = self.scan_config.get_async_scan_type(scan_type)
153-
url_path = f'{self.get_scan_service_v2_url_path(scan_type)}/{async_scan_type}/repository'
153+
url_path = f'{self.get_scan_service_v4_url_path(scan_type)}/{async_scan_type}/repository'
154154
response = self.scan_cycode_client.post(
155155
url_path=url_path,
156156
data={

0 commit comments

Comments
 (0)