Skip to content

Commit 267ff11

Browse files
authored
Add option for 'Use-Snapshot' header (#37)
1 parent 964e102 commit 267ff11

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

edfi_api_client/edfi_client.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ class EdFiClient:
2323
:param api_mode: ['shared_instance', 'sandbox', 'district_specific', 'year_specific', 'instance_year_specific']
2424
:param api_year: Required only for 'year_specific' or 'instance_year_specific' modes
2525
:param instance_code: Only required for 'instance_specific' or 'instance_year_specific modes'
26+
:param use_snapshot: Add 'Use-Snapshot' header to requests
2627
"""
2728
def __new__(cls, *args, **kwargs):
2829
"""
@@ -50,6 +51,7 @@ def __init__(self,
5051
api_mode : Optional[str] = None,
5152
api_year : Optional[int] = None,
5253
instance_code: Optional[str] = None,
54+
use_snapshot : bool = False,
5355

5456
verify_ssl : bool = True,
5557
verbose : bool = False,
@@ -66,6 +68,7 @@ def __init__(self,
6668
self.api_mode = api_mode or self.get_api_mode()
6769
self.api_year = api_year
6870
self.instance_code = instance_code
71+
self.use_snapshot = use_snapshot
6972

7073
# Build endpoint URL pieces
7174
self.version_url_string = self._get_version_url_string()
@@ -306,6 +309,8 @@ def connect(self) -> requests.Session:
306309
# Create a session and add headers to it.
307310
self.session = requests.Session()
308311
self.session.headers.update(req_header)
312+
if self.use_snapshot:
313+
self.session.headers.update({'Use-Snapshot': 'True'})
309314

310315
# Add new attributes to track when connection was established and when to refresh the access token.
311316
self.session.timestamp_unix = int(time.time())

0 commit comments

Comments
 (0)