turnkey-http 0.1.0__tar.gz → 0.2.1__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: turnkey-http
3
- Version: 0.1.0
3
+ Version: 0.2.1
4
4
  Summary: HTTP client for Turnkey API
5
5
  Author-email: Turnkey <hello@turnkey.com>
6
6
  License-Expression: Apache-2.0
@@ -19,6 +19,7 @@ Requires-Python: >=3.8
19
19
  Description-Content-Type: text/markdown
20
20
  License-File: LICENSE
21
21
  Requires-Dist: requests>=2.31.0
22
+ Requires-Dist: certifi>=2026.10.19
22
23
  Requires-Dist: turnkey-api-key-stamper
23
24
  Requires-Dist: turnkey-sdk-types
24
25
  Provides-Extra: dev
@@ -68,6 +69,38 @@ response = client.get_whoami()
68
69
  print(response)
69
70
  ```
70
71
 
72
+ ## Handling activity outcomes
73
+
74
+ Activity methods poll until the activity finishes. If it does not complete, they raise an error. `TurnkeyActivityConsensusNeededError` means the activity needs more approvals. `TurnkeyActivityAuthenticatorsNeededError` means it needs authenticator approval. `TurnkeyActivityError` means it failed, was rejected, or was still pending when polling stopped. These errors carry `activity_id`, `activity_status`, `activity_type`, and `failure`. Catch the subclasses first, because they extend `TurnkeyActivityError`.
75
+
76
+ Consensus-needed and authenticators-needed each stop the normal activity poll. Pass a `PollingConfig` as `consensus_polling` or `mfa_polling` to keep polling that status. The MFA interval doubles on each attempt, up to 5 seconds. The consensus interval stays fixed. Omit a config to raise that status's error immediately. A timeout raises the same error. Use `activity_id` with `get_activity` after the missing approvals are in place.
77
+
78
+ ```python
79
+ from turnkey_http import PollingConfig, TurnkeyClient
80
+ from turnkey_sdk_types import (
81
+ TurnkeyActivityAuthenticatorsNeededError,
82
+ TurnkeyActivityConsensusNeededError,
83
+ TurnkeyActivityError,
84
+ )
85
+
86
+ client = TurnkeyClient(
87
+ base_url="https://api.turnkey.com",
88
+ stamper=stamper,
89
+ organization_id="your-org-id",
90
+ consensus_polling=PollingConfig(interval_ms=500, timeout_ms=30_000),
91
+ mfa_polling=PollingConfig(interval_ms=500, timeout_ms=30_000),
92
+ )
93
+
94
+ try:
95
+ response = ... # any activity method
96
+ except TurnkeyActivityConsensusNeededError as err:
97
+ activity_id = err.activity_id
98
+ except TurnkeyActivityAuthenticatorsNeededError as err:
99
+ activity_id = err.activity_id
100
+ except TurnkeyActivityError as err:
101
+ print(err.activity_status, err.failure)
102
+ ```
103
+
71
104
  ## Code Generation
72
105
 
73
106
  This package uses code generation to create HTTP client methods from the OpenAPI specification located in `schema/public_api.swagger.json`.
@@ -39,6 +39,38 @@ response = client.get_whoami()
39
39
  print(response)
40
40
  ```
41
41
 
42
+ ## Handling activity outcomes
43
+
44
+ Activity methods poll until the activity finishes. If it does not complete, they raise an error. `TurnkeyActivityConsensusNeededError` means the activity needs more approvals. `TurnkeyActivityAuthenticatorsNeededError` means it needs authenticator approval. `TurnkeyActivityError` means it failed, was rejected, or was still pending when polling stopped. These errors carry `activity_id`, `activity_status`, `activity_type`, and `failure`. Catch the subclasses first, because they extend `TurnkeyActivityError`.
45
+
46
+ Consensus-needed and authenticators-needed each stop the normal activity poll. Pass a `PollingConfig` as `consensus_polling` or `mfa_polling` to keep polling that status. The MFA interval doubles on each attempt, up to 5 seconds. The consensus interval stays fixed. Omit a config to raise that status's error immediately. A timeout raises the same error. Use `activity_id` with `get_activity` after the missing approvals are in place.
47
+
48
+ ```python
49
+ from turnkey_http import PollingConfig, TurnkeyClient
50
+ from turnkey_sdk_types import (
51
+ TurnkeyActivityAuthenticatorsNeededError,
52
+ TurnkeyActivityConsensusNeededError,
53
+ TurnkeyActivityError,
54
+ )
55
+
56
+ client = TurnkeyClient(
57
+ base_url="https://api.turnkey.com",
58
+ stamper=stamper,
59
+ organization_id="your-org-id",
60
+ consensus_polling=PollingConfig(interval_ms=500, timeout_ms=30_000),
61
+ mfa_polling=PollingConfig(interval_ms=500, timeout_ms=30_000),
62
+ )
63
+
64
+ try:
65
+ response = ... # any activity method
66
+ except TurnkeyActivityConsensusNeededError as err:
67
+ activity_id = err.activity_id
68
+ except TurnkeyActivityAuthenticatorsNeededError as err:
69
+ activity_id = err.activity_id
70
+ except TurnkeyActivityError as err:
71
+ print(err.activity_status, err.failure)
72
+ ```
73
+
42
74
  ## Code Generation
43
75
 
44
76
  This package uses code generation to create HTTP client methods from the OpenAPI specification located in `schema/public_api.swagger.json`.
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "turnkey-http"
7
- version = "0.1.0"
7
+ version = "0.2.1"
8
8
  description = "HTTP client for Turnkey API"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.8"
@@ -25,6 +25,7 @@ classifiers = [
25
25
  ]
26
26
  dependencies = [
27
27
  "requests>=2.31.0",
28
+ "certifi>=2026.10.19",
28
29
  "turnkey-api-key-stamper",
29
30
  "turnkey-sdk-types",
30
31
  ]