Skip to content

Commit 37f78b2

Browse files
committed
credentials-export-domain: save cursor for next execution
1 parent a53b3f9 commit 37f78b2

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

docs/guides/credentials-export-domain.mdx

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,19 +40,18 @@ These are end-to-end examples in various programming languages.
4040
<Accordion title="Python SDK Example">
4141
```python
4242
import csv
43-
import os
4443
import sys
4544
import time
4645

4746
from flareio import FlareApiClient
4847

4948

50-
api_client = FlareApiClient(
51-
api_key=os.environ["FLARE_API_KEY"],
52-
)
49+
api_client = FlareApiClient.from_env()
5350

5451
domain_name: str = "scatterholt.com"
55-
from_: str | None = None
52+
53+
# The cursor from which we are starting the current execution.
54+
last_from: str | None = None
5655

5756
writer = csv.DictWriter(
5857
sys.stdout,
@@ -71,7 +70,7 @@ for resp in api_client.scroll(
7170
"type": "domain",
7271
"fqdn": "scatterholt.com",
7372
},
74-
"from": from_,
73+
"from": last_from,
7574
},
7675
):
7776
# Print results
@@ -85,8 +84,13 @@ for resp in api_client.scroll(
8584
},
8685
)
8786

87+
# Save the cursor for the next execution
88+
last_from = resp.json().get("next") or last_from
89+
8890
# Rate limiting.
8991
time.sleep(0.25)
92+
93+
print(f"The next execution could resume using {last_from=}.")
9094
```
9195
</Accordion>
9296

0 commit comments

Comments
 (0)