Skip to content

Commit c82b140

Browse files
committed
feat(metadata): add general server payload maximum to secret scan preferences
1 parent 7cf0356 commit c82b140

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed

pygitguardian/client.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -584,7 +584,9 @@ def read_metadata(self) -> Optional[Detail]:
584584
result.status_code = resp.status_code
585585
return result
586586
metadata = ServerMetadata.from_dict(resp.json())
587-
587+
metadata.secret_scan_preferences.general__maximum_payload_size = (
588+
metadata.preferences["general__maximum_payload_size"]
589+
)
588590
self.secret_scan_preferences = metadata.secret_scan_preferences
589591
return None
590592

pygitguardian/config.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@
44

55
MULTI_DOCUMENT_LIMIT = 20
66
DOCUMENT_SIZE_THRESHOLD_BYTES = 1048576 # 1MB
7+
GENERAL_MAXIMUM_PAYLOAD = 2621440 # 2.5MB

pygitguardian/models.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,11 @@
1616
)
1717
from typing_extensions import Self
1818

19-
from .config import DOCUMENT_SIZE_THRESHOLD_BYTES, MULTI_DOCUMENT_LIMIT
19+
from .config import (
20+
DOCUMENT_SIZE_THRESHOLD_BYTES,
21+
GENERAL_MAXIMUM_PAYLOAD,
22+
MULTI_DOCUMENT_LIMIT,
23+
)
2024

2125

2226
class ToDictMixin:
@@ -658,6 +662,7 @@ def __repr__(self) -> str:
658662
class SecretScanPreferences:
659663
maximum_document_size: int = DOCUMENT_SIZE_THRESHOLD_BYTES
660664
maximum_documents_per_scan: int = MULTI_DOCUMENT_LIMIT
665+
general__maximum_payload_size: int = GENERAL_MAXIMUM_PAYLOAD
661666

662667

663668
@dataclass

0 commit comments

Comments
 (0)