Skip to content

Commit 387325e

Browse files
authored
Merge pull request #27 from Copyleaks/features/OP-373-add-missing-webhook-properties
features/OP-373-add-missing-webhook-properties
2 parents ccca45f + ef77b5c commit 387325e

File tree

2 files changed

+40
-3
lines changed

2 files changed

+40
-3
lines changed

copyleaks/clients/ai_detection_client.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,10 @@
2323
SOFTWARE.
2424
'''
2525

26-
from aifc import Error
2726
import requests
2827
from copyleaks.consts import Consts
28+
from copyleaks.exceptions.command_error import CommandError
29+
from copyleaks.exceptions.under_maintenance_error import UnderMaintenanceError
2930
from copyleaks.helpers.copyleaks_client_helper import CopyleaksClientHelper
3031

3132
class _AIDetectionClient:
@@ -45,9 +46,9 @@ def __submit(url, auth_token, scan_id, submission):
4546
if response.ok:
4647
return response.json()
4748
elif response.status_code == 503:
48-
raise Error()
49+
raise UnderMaintenanceError()
4950
else:
50-
raise Error(response)
51+
raise CommandError(response)
5152

5253
@staticmethod
5354
def submit_natural_language(auth_token, scan_id, submission):

copyleaks/models/submit/properties/submit_webhooks.py

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,3 +58,39 @@ def set_status(self, value):
5858
assert value
5959

6060
self.status = value
61+
62+
def get_status_headers(self):
63+
'''
64+
Get the headers for the status webhook.
65+
'''
66+
return self.statusHeaders
67+
68+
def set_status_headers(self, value):
69+
'''
70+
Parameters:
71+
value: List of list of strings.
72+
73+
Example:
74+
[["header-key1", "header-value1"], ["header-key2", "header-value2"]]
75+
'''
76+
assert isinstance(value, list)
77+
self.statusHeaders = value
78+
79+
def get_new_result_headers(self):
80+
'''
81+
Get the headers for the new result webhook.
82+
'''
83+
return self.newResultHeaders
84+
85+
def set_new_result_headers(self, value):
86+
'''
87+
Set the headers for the new result webhook.
88+
89+
Parameters:
90+
value: List of list of strings.
91+
92+
Example:
93+
[["header-key1", "header-value1"], ["header-key2", "header-value2"]]
94+
'''
95+
assert isinstance(value, list)
96+
self.newResultHeaders = value

0 commit comments

Comments
 (0)