1717
1818
1919class Nightfall :
20- """A python interface for the Nightfall API.
21- .. data:: MAX_PAYLOAD_SIZE
22- Maximum payload size in bytes that the Nightfall API will accept
23- .. data:: MAX_NUM_ITEMS
24- Maximum number of items that the Nightfall API will accept
25- """
26- MAX_PAYLOAD_SIZE = 500_000
27- MAX_NUM_ITEMS = 50_000
28-
2920 PLATFORM_URL = "https://api.nightfall.ai"
30- TEXT_SCAN_ENDPOINT_V2 = PLATFORM_URL + "/v2/scan"
3121 TEXT_SCAN_ENDPOINT_V3 = PLATFORM_URL + "/v3/scan"
3222 FILE_SCAN_INITIALIZE_ENDPOINT = PLATFORM_URL + "/v3/upload"
3323 FILE_SCAN_UPLOAD_ENDPOINT = PLATFORM_URL + "/v3/upload/{0}"
@@ -36,7 +26,7 @@ class Nightfall:
3626
3727 def __init__ (self , key : str = None , signing_secret : str = None ):
3828 """Instantiate a new Nightfall object.
39- :param key: Your Nightfall API key.
29+ :param key: Your Nightfall API key. If None it will be read from the environment variable NIGHTFALL_API_KEY.
4030 :type key: str or None
4131 :param signing_secret: Your Nightfall signing secret used for webhook validation.
4232 :type signing_secret: str or None
@@ -52,14 +42,11 @@ def __init__(self, key: str = None, signing_secret: str = None):
5242 self ._headers = {
5343 "Content-Type" : "application/json" ,
5444 "User-Agent" : "nightfall-python-sdk/1.0.0" ,
55- "x-api-key" : self .key , # v2
56- 'Authorization' : f'Bearer { self .key } ' , # v3
45+ 'Authorization' : f'Bearer { self .key } ' ,
5746 }
5847 self .signing_secret = signing_secret
5948 self .logger = logging .getLogger (__name__ )
6049
61- # Text Scan V3
62-
6350 def scan_text (self , texts : list [str ], detection_rule_uuids : list [str ] = None ,
6451 detection_rules : list [DetectionRule ] = None ):
6552 """Scan text with Nightfall.
@@ -135,7 +122,6 @@ def scan_file(self, location: str, webhook_url: str, policy_uuid: str = None,
135122
136123 :param location: location of file to scan.
137124 :param webhook_url: webhook endpoint which will receive the results of the scan.
138- :type text: str
139125 :param policy_uuid: policy UUID.
140126 :type policy_uuid: str or None
141127 :param detection_rule_uuids: list of detection rule UUIDs.
0 commit comments