messagebird-sdk 0.2.2__tar.gz → 0.4.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (32) hide show
  1. {messagebird_sdk-0.2.2 → messagebird_sdk-0.4.0}/PKG-INFO +1 -1
  2. {messagebird_sdk-0.2.2 → messagebird_sdk-0.4.0}/src/bird/__init__.py +64 -0
  3. {messagebird_sdk-0.2.2 → messagebird_sdk-0.4.0}/src/bird/_base_client.py +5 -0
  4. messagebird_sdk-0.4.0/src/bird/_caller.py +45 -0
  5. messagebird_sdk-0.4.0/src/bird/_caller_rules.py +32 -0
  6. {messagebird_sdk-0.2.2 → messagebird_sdk-0.4.0}/src/bird/_client.py +18 -0
  7. messagebird_sdk-0.4.0/src/bird/_generated.py +3715 -0
  8. messagebird_sdk-0.4.0/src/bird/_types.py +286 -0
  9. messagebird_sdk-0.4.0/src/bird/_version.py +1 -0
  10. messagebird_sdk-0.4.0/src/bird/resources/audiences.py +336 -0
  11. messagebird_sdk-0.4.0/src/bird/resources/contact_properties.py +219 -0
  12. messagebird_sdk-0.4.0/src/bird/resources/contacts.py +300 -0
  13. {messagebird_sdk-0.2.2 → messagebird_sdk-0.4.0}/src/bird/resources/email.py +32 -9
  14. messagebird_sdk-0.4.0/src/bird/resources/email_templates.py +325 -0
  15. messagebird_sdk-0.4.0/src/bird/resources/sms.py +238 -0
  16. messagebird_sdk-0.4.0/src/bird/resources/sms_templates.py +101 -0
  17. messagebird_sdk-0.2.2/src/bird/_generated.py +0 -2001
  18. messagebird_sdk-0.2.2/src/bird/_types.py +0 -134
  19. messagebird_sdk-0.2.2/src/bird/_version.py +0 -1
  20. {messagebird_sdk-0.2.2 → messagebird_sdk-0.4.0}/.gitignore +0 -0
  21. {messagebird_sdk-0.2.2 → messagebird_sdk-0.4.0}/LICENSE +0 -0
  22. {messagebird_sdk-0.2.2 → messagebird_sdk-0.4.0}/README.md +0 -0
  23. {messagebird_sdk-0.2.2 → messagebird_sdk-0.4.0}/pyproject.toml +0 -0
  24. {messagebird_sdk-0.2.2 → messagebird_sdk-0.4.0}/src/bird/_constants.py +0 -0
  25. {messagebird_sdk-0.2.2 → messagebird_sdk-0.4.0}/src/bird/_event_types.py +0 -0
  26. {messagebird_sdk-0.2.2 → messagebird_sdk-0.4.0}/src/bird/_exceptions.py +0 -0
  27. {messagebird_sdk-0.2.2 → messagebird_sdk-0.4.0}/src/bird/_models.py +0 -0
  28. {messagebird_sdk-0.2.2 → messagebird_sdk-0.4.0}/src/bird/_response.py +0 -0
  29. {messagebird_sdk-0.2.2 → messagebird_sdk-0.4.0}/src/bird/pagination.py +0 -0
  30. {messagebird_sdk-0.2.2 → messagebird_sdk-0.4.0}/src/bird/py.typed +0 -0
  31. {messagebird_sdk-0.2.2 → messagebird_sdk-0.4.0}/src/bird/resources/__init__.py +0 -0
  32. {messagebird_sdk-0.2.2 → messagebird_sdk-0.4.0}/src/bird/resources/webhooks.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: messagebird-sdk
3
- Version: 0.2.2
3
+ Version: 0.4.0
4
4
  Summary: The official Python SDK for the Bird email platform.
5
5
  Project-URL: Homepage, https://bird.com
6
6
  Project-URL: Documentation, https://bird.com/docs/sdks/python
@@ -12,15 +12,47 @@ from bird._client import AsyncBird, Bird
12
12
  from bird._response import APIResponse
13
13
  from bird._types import (
14
14
  Attachment,
15
+ AudienceContactsAddParams,
16
+ AudienceContactsRemoveParams,
17
+ AudienceCreateParams,
18
+ AudienceListContactsParams,
19
+ AudienceListParams,
20
+ AudienceUpdateParams,
21
+ ContactBatchParams,
22
+ ContactCreateParams,
23
+ ContactListParams,
24
+ ContactPropertyCreateParams,
25
+ ContactPropertyListParams,
26
+ ContactPropertyUpdateParams,
27
+ ContactUpdateParams,
15
28
  EmailDefaults,
16
29
  EmailListParams,
17
30
  EmailSendBatchParams,
18
31
  EmailSendParams,
19
32
  RequestOptions,
33
+ SmsSendParams,
20
34
  )
21
35
  from bird._generated import (
36
+ Audience,
37
+ AudienceList,
38
+ AudienceMember,
39
+ AudienceMemberList,
40
+ Contact,
41
+ ContactList,
42
+ ContactProperty,
43
+ ContactPropertyList,
44
+ ContactUpsertResult,
22
45
  EmailMessage,
23
46
  EmailMessageBatchResponse,
47
+ EmailTemplate,
48
+ EmailTemplateList,
49
+ EmailTemplateSummary,
50
+ EmailTemplateVersion,
51
+ EmailTemplateVersionList,
52
+ SMSMessage,
53
+ SMSMessageBatchResponse,
54
+ SMSTemplate,
55
+ SMSTemplateList,
24
56
  WebhookEvent,
25
57
  )
26
58
  from bird._event_types import WebhookEventType
@@ -50,11 +82,43 @@ __all__ = [
50
82
  "EmailSendParams",
51
83
  "EmailSendBatchParams",
52
84
  "EmailListParams",
85
+ "ContactCreateParams",
86
+ "ContactUpdateParams",
87
+ "ContactListParams",
88
+ "ContactBatchParams",
89
+ "Contact",
90
+ "ContactList",
91
+ "ContactUpsertResult",
92
+ "ContactPropertyCreateParams",
93
+ "ContactPropertyUpdateParams",
94
+ "ContactPropertyListParams",
95
+ "ContactProperty",
96
+ "ContactPropertyList",
97
+ "AudienceCreateParams",
98
+ "AudienceUpdateParams",
99
+ "AudienceListParams",
100
+ "AudienceListContactsParams",
101
+ "AudienceContactsAddParams",
102
+ "AudienceContactsRemoveParams",
103
+ "Audience",
104
+ "AudienceList",
105
+ "AudienceMember",
106
+ "AudienceMemberList",
53
107
  "APIResponse",
54
108
  "SyncPage",
55
109
  "AsyncPage",
56
110
  "EmailMessage",
57
111
  "EmailMessageBatchResponse",
112
+ "EmailTemplate",
113
+ "EmailTemplateSummary",
114
+ "EmailTemplateVersion",
115
+ "EmailTemplateList",
116
+ "EmailTemplateVersionList",
117
+ "SmsSendParams",
118
+ "SMSMessage",
119
+ "SMSMessageBatchResponse",
120
+ "SMSTemplate",
121
+ "SMSTemplateList",
58
122
  "WebhookEvent",
59
123
  "GenericWebhookEvent",
60
124
  "WebhookEventType",
@@ -20,6 +20,7 @@ from urllib.parse import urlsplit
20
20
 
21
21
  import httpx
22
22
 
23
+ from bird._caller import detect_caller
23
24
  from bird._constants import DEFAULT_MAX_RETRIES, DEFAULT_TIMEOUT, INITIAL_RETRY_DELAY, MAX_RETRY_DELAY
24
25
  from bird._exceptions import APIConnectionError, APITimeoutError, from_response, parse_retry_after
25
26
  from bird._types import NOT_GIVEN, NotGiven
@@ -37,6 +38,10 @@ _CLIENT_HEADERS = {
37
38
  "Bird-Os": platform.system().lower(),
38
39
  "Bird-Arch": platform.machine().lower(),
39
40
  }
41
+ # Bird-Caller (the driving agent harness) — omitted when no agent env is present.
42
+ _caller = detect_caller()
43
+ if _caller:
44
+ _CLIENT_HEADERS["Bird-Caller"] = _caller
40
45
 
41
46
  _MUTATING_METHODS = {"POST", "PUT", "PATCH", "DELETE"}
42
47
  # SDK-owned headers a caller's extra_headers must never override. Derived from
@@ -0,0 +1,45 @@
1
+ """Bird-Caller detection: which agent harness drives the SDK (ADR-0074).
2
+
3
+ Best-effort, non-authoritative usage telemetry -- it only labels traffic, never
4
+ gates behavior. The single source of truth is ``clients/caller-detection.yaml``
5
+ (shared with the CLI and the other SDKs); the ordered rule table in
6
+ ``_caller_rules`` is generated from it.
7
+ """
8
+
9
+ from __future__ import annotations
10
+
11
+ import os
12
+ import re
13
+ from collections.abc import Mapping
14
+
15
+ from ._caller_rules import CALLER_BOOLEANISH_SKIP, CALLER_DEFAULT, CALLER_RULES
16
+
17
+ _VALID = re.compile(r"^[a-z0-9._-]+$")
18
+
19
+
20
+ def detect_caller(environ: Mapping[str, str] | None = None) -> str:
21
+ """Infer the driving environment by walking the generated rules in order.
22
+
23
+ ``environ`` is injected in tests; production uses ``os.environ``.
24
+ """
25
+ env = os.environ if environ is None else environ
26
+ for rule in CALLER_RULES:
27
+ value = env.get(str(rule["env"]), "")
28
+ equals = rule.get("equals")
29
+ if not value or (equals is not None and value != equals):
30
+ continue
31
+ if not rule.get("passthrough"):
32
+ return str(rule["name"])
33
+ sanitized = _sanitize(value)
34
+ if sanitized:
35
+ return sanitized
36
+ return CALLER_DEFAULT
37
+
38
+
39
+ def _sanitize(value: str) -> str:
40
+ # Lowercase and bound a passthrough (AGENT=<name>) value the same charset+length
41
+ # way as the other Bird-* labels; drop boolean-ish values with no harness identity.
42
+ s = value.strip().lower()
43
+ if not s or len(s) > 32 or s in CALLER_BOOLEANISH_SKIP:
44
+ return ""
45
+ return s if _VALID.match(s) else ""
@@ -0,0 +1,32 @@
1
+ # Code generated by tools/callergen from clients/caller-detection.yaml. DO NOT EDIT.
2
+
3
+ CALLER_RULES = [
4
+ {"env": "CLAUDECODE", "name": "claude-code"},
5
+ {"env": "CODEX_CI", "name": "codex"},
6
+ {"env": "GEMINI_CLI", "name": "gemini"},
7
+ {"env": "QWEN_CODE", "name": "qwen"},
8
+ {"env": "PI_CODING_AGENT", "name": "pi"},
9
+ {"env": "OPENCODE", "name": "opencode"},
10
+ {"env": "CLINE_ACTIVE", "name": "cline"},
11
+ {"env": "ROO_ACTIVE", "name": "roo"},
12
+ {"env": "CURSOR_TRACE_ID", "name": "cursor"},
13
+ {"env": "CURSOR_AGENT", "name": "cursor"},
14
+ {"env": "ANTIGRAVITY_AGENT", "name": "antigravity"},
15
+ {"env": "AUGMENT_AGENT", "name": "augment"},
16
+ {"env": "AGENT", "passthrough": True},
17
+ {"env": "AI_AGENT", "passthrough": True},
18
+ {"env": "REPL_ID", "name": "replit"},
19
+ {"env": "CI", "name": "ci"},
20
+ {"env": "GITHUB_ACTIONS", "name": "ci"},
21
+ {"env": "TERM_PROGRAM", "equals": "zed", "name": "zed"},
22
+ {"env": "ZED_TERM", "name": "zed"},
23
+ {"env": "TERM_PROGRAM", "equals": "kiro", "name": "kiro"},
24
+ {"env": "TERM_PROGRAM", "equals": "WarpTerminal", "name": "warp"},
25
+ {"env": "TERMINAL_EMULATOR", "equals": "JetBrains-JediTerm", "name": "jetbrains"},
26
+ {"env": "__CFBundleIdentifier", "equals": "com.exafunction.windsurf", "name": "windsurf"},
27
+ {"env": "TERM_PROGRAM", "equals": "vscode", "name": "vscode"},
28
+ ]
29
+
30
+ CALLER_BOOLEANISH_SKIP = {"1", "0", "true", "false", "yes", "no", "on", "off"}
31
+
32
+ CALLER_DEFAULT = "shell"
@@ -20,7 +20,13 @@ from bird._base_client import AsyncAPIClient, SyncAPIClient
20
20
  from bird._constants import DEFAULT_MAX_RETRIES
21
21
  from bird._exceptions import BirdError
22
22
  from bird._types import NOT_GIVEN, EmailDefaults, NotGiven
23
+ from bird.resources.audiences import AsyncAudiences, Audiences
24
+ from bird.resources.contact_properties import AsyncContactProperties, ContactProperties
25
+ from bird.resources.contacts import AsyncContacts, Contacts
23
26
  from bird.resources.email import AsyncEmail, Email
27
+ from bird.resources.email_templates import AsyncEmailTemplates, EmailTemplates
28
+ from bird.resources.sms import AsyncSms, Sms
29
+ from bird.resources.sms_templates import AsyncSMSTemplates, SMSTemplates
24
30
  from bird.resources.webhooks import AsyncWebhooks, Webhooks
25
31
 
26
32
  _REGION_PREFIX = re.compile(r"^bk_([a-z]{2}[0-9]+)_")
@@ -139,6 +145,12 @@ class Bird(SyncAPIClient):
139
145
  super().__init__(**{k: v for k, v in self._config.items() if k not in ("webhook_secret", "email_defaults", "region")})
140
146
  self.webhook_secret = webhook_secret
141
147
  self.email = Email(self, email_defaults)
148
+ self.email_templates = EmailTemplates(self)
149
+ self.sms = Sms(self)
150
+ self.sms_templates = SMSTemplates(self)
151
+ self.contacts = Contacts(self)
152
+ self.contact_properties = ContactProperties(self)
153
+ self.audiences = Audiences(self)
142
154
  self.webhooks = Webhooks(webhook_secret)
143
155
 
144
156
  def with_options(
@@ -230,6 +242,12 @@ class AsyncBird(AsyncAPIClient):
230
242
  super().__init__(**{k: v for k, v in self._config.items() if k not in ("webhook_secret", "email_defaults", "region")})
231
243
  self.webhook_secret = webhook_secret
232
244
  self.email = AsyncEmail(self, email_defaults)
245
+ self.email_templates = AsyncEmailTemplates(self)
246
+ self.sms = AsyncSms(self)
247
+ self.sms_templates = AsyncSMSTemplates(self)
248
+ self.contacts = AsyncContacts(self)
249
+ self.contact_properties = AsyncContactProperties(self)
250
+ self.audiences = AsyncAudiences(self)
233
251
  self.webhooks = AsyncWebhooks(webhook_secret)
234
252
 
235
253
  def with_options(