turnkey-http 0.1.0__tar.gz → 0.2.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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: turnkey-http
3
- Version: 0.1.0
3
+ Version: 0.2.0
4
4
  Summary: HTTP client for Turnkey API
5
5
  Author-email: Turnkey <hello@turnkey.com>
6
6
  License-Expression: Apache-2.0
@@ -68,6 +68,38 @@ response = client.get_whoami()
68
68
  print(response)
69
69
  ```
70
70
 
71
+ ## Handling activity outcomes
72
+
73
+ 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`.
74
+
75
+ 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.
76
+
77
+ ```python
78
+ from turnkey_http import PollingConfig, TurnkeyClient
79
+ from turnkey_sdk_types import (
80
+ TurnkeyActivityAuthenticatorsNeededError,
81
+ TurnkeyActivityConsensusNeededError,
82
+ TurnkeyActivityError,
83
+ )
84
+
85
+ client = TurnkeyClient(
86
+ base_url="https://api.turnkey.com",
87
+ stamper=stamper,
88
+ organization_id="your-org-id",
89
+ consensus_polling=PollingConfig(interval_ms=500, timeout_ms=30_000),
90
+ mfa_polling=PollingConfig(interval_ms=500, timeout_ms=30_000),
91
+ )
92
+
93
+ try:
94
+ response = ... # any activity method
95
+ except TurnkeyActivityConsensusNeededError as err:
96
+ activity_id = err.activity_id
97
+ except TurnkeyActivityAuthenticatorsNeededError as err:
98
+ activity_id = err.activity_id
99
+ except TurnkeyActivityError as err:
100
+ print(err.activity_status, err.failure)
101
+ ```
102
+
71
103
  ## Code Generation
72
104
 
73
105
  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.0"
8
8
  description = "HTTP client for Turnkey API"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.8"