-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathaudiences_async.py
More file actions
36 lines (26 loc) · 963 Bytes
/
audiences_async.py
File metadata and controls
36 lines (26 loc) · 963 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import asyncio
import os
import resend
if not os.environ["RESEND_API_KEY"]:
raise EnvironmentError("RESEND_API_KEY is missing")
# Set up async HTTP client
async def main() -> None:
create_params: resend.Segments.CreateParams = {
"name": "New Segment from Python SDK (Async)",
}
segment: resend.Segments.CreateSegmentResponse = await resend.Segments.create_async(
create_params
)
print(f"Created segment: {segment['id']}")
print(segment)
seg: resend.Segment = await resend.Segments.get_async(segment["id"])
print("Retrieved segment: ", seg)
segments: resend.Segments.ListResponse = await resend.Segments.list_async()
print("List of segments:", [s["id"] for s in segments["data"]])
rmed: resend.Segments.RemoveSegmentResponse = await resend.Segments.remove_async(
id=segment["id"]
)
print("Deleted segment")
print(rmed)
if __name__ == "__main__":
asyncio.run(main())