stytch-management 1.0.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 (58) hide show
  1. stytch_management-1.0.0/LICENSE +21 -0
  2. stytch_management-1.0.0/PKG-INFO +242 -0
  3. stytch_management-1.0.0/README.md +206 -0
  4. stytch_management-1.0.0/setup.cfg +4 -0
  5. stytch_management-1.0.0/setup.py +62 -0
  6. stytch_management-1.0.0/stytch_management/__init__.py +5 -0
  7. stytch_management-1.0.0/stytch_management/attribute.py +7 -0
  8. stytch_management-1.0.0/stytch_management/client.py +100 -0
  9. stytch_management-1.0.0/stytch_management/country_code_allowlist.py +145 -0
  10. stytch_management-1.0.0/stytch_management/emailtemplates.py +309 -0
  11. stytch_management-1.0.0/stytch_management/environments.py +289 -0
  12. stytch_management-1.0.0/stytch_management/errors.py +96 -0
  13. stytch_management-1.0.0/stytch_management/event_log_streaming.py +253 -0
  14. stytch_management-1.0.0/stytch_management/http_client.py +173 -0
  15. stytch_management-1.0.0/stytch_management/jwttemplates.py +97 -0
  16. stytch_management-1.0.0/stytch_management/models/__init__.py +1 -0
  17. stytch_management-1.0.0/stytch_management/models/attribute.py +10 -0
  18. stytch_management-1.0.0/stytch_management/models/country_code_allowlist.py +66 -0
  19. stytch_management-1.0.0/stytch_management/models/emailtemplates.py +217 -0
  20. stytch_management-1.0.0/stytch_management/models/environments.py +151 -0
  21. stytch_management-1.0.0/stytch_management/models/event_log_streaming.py +211 -0
  22. stytch_management-1.0.0/stytch_management/models/jwttemplates.py +62 -0
  23. stytch_management-1.0.0/stytch_management/models/passwordstrengthconfig.py +68 -0
  24. stytch_management-1.0.0/stytch_management/models/project.py +10 -0
  25. stytch_management-1.0.0/stytch_management/models/projects.py +102 -0
  26. stytch_management-1.0.0/stytch_management/models/publictokens.py +75 -0
  27. stytch_management-1.0.0/stytch_management/models/rbacpolicy.py +120 -0
  28. stytch_management-1.0.0/stytch_management/models/redirecturls.py +111 -0
  29. stytch_management-1.0.0/stytch_management/models/sdk.py +446 -0
  30. stytch_management-1.0.0/stytch_management/models/secrets.py +92 -0
  31. stytch_management-1.0.0/stytch_management/models/trustedtokenprofiles.py +159 -0
  32. stytch_management-1.0.0/stytch_management/passwordstrengthconfig.py +102 -0
  33. stytch_management-1.0.0/stytch_management/project.py +7 -0
  34. stytch_management-1.0.0/stytch_management/projects.py +136 -0
  35. stytch_management-1.0.0/stytch_management/publictokens.py +149 -0
  36. stytch_management-1.0.0/stytch_management/py.typed +1 -0
  37. stytch_management-1.0.0/stytch_management/rbacpolicy.py +124 -0
  38. stytch_management-1.0.0/stytch_management/redirecturls.py +211 -0
  39. stytch_management-1.0.0/stytch_management/sdk.py +153 -0
  40. stytch_management-1.0.0/stytch_management/secrets.py +153 -0
  41. stytch_management-1.0.0/stytch_management/trustedtokenprofiles.py +350 -0
  42. stytch_management-1.0.0/stytch_management/version.py +1 -0
  43. stytch_management-1.0.0/stytch_management.egg-info/PKG-INFO +242 -0
  44. stytch_management-1.0.0/stytch_management.egg-info/SOURCES.txt +56 -0
  45. stytch_management-1.0.0/stytch_management.egg-info/dependency_links.txt +1 -0
  46. stytch_management-1.0.0/stytch_management.egg-info/requires.txt +2 -0
  47. stytch_management-1.0.0/stytch_management.egg-info/top_level.txt +1 -0
  48. stytch_management-1.0.0/test/test_client.py +97 -0
  49. stytch_management-1.0.0/test/test_countrycodeallowlist.py +304 -0
  50. stytch_management-1.0.0/test/test_emailtemplates.py +392 -0
  51. stytch_management-1.0.0/test/test_environments.py +296 -0
  52. stytch_management-1.0.0/test/test_jwttemplates.py +193 -0
  53. stytch_management-1.0.0/test/test_passwordstrengthconfig.py +116 -0
  54. stytch_management-1.0.0/test/test_path_validation.py +99 -0
  55. stytch_management-1.0.0/test/test_projects.py +76 -0
  56. stytch_management-1.0.0/test/test_publictokens.py +163 -0
  57. stytch_management-1.0.0/test/test_redirecturls.py +314 -0
  58. stytch_management-1.0.0/test/test_secrets.py +181 -0
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 Stytch
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,242 @@
1
+ Metadata-Version: 2.4
2
+ Name: stytch-management
3
+ Version: 1.0.0
4
+ Summary: Stytch Management API Python client
5
+ Download-URL: https://github.com/stytchauth/stytch-management-python
6
+ Author: Stytch
7
+ Author-email: hello@stytch.com
8
+ License: MIT
9
+ Keywords: stytch,management,api,workspace,programmatic
10
+ Classifier: License :: OSI Approved :: MIT License
11
+ Classifier: Intended Audience :: Developers
12
+ Classifier: Programming Language :: Python :: 3
13
+ Classifier: Programming Language :: Python :: 3 :: Only
14
+ Classifier: Programming Language :: Python :: 3.8
15
+ Classifier: Programming Language :: Python :: 3.9
16
+ Classifier: Programming Language :: Python :: 3.10
17
+ Classifier: Programming Language :: Python :: 3.11
18
+ Classifier: Programming Language :: Python :: 3.12
19
+ Requires-Python: >=3.8
20
+ Description-Content-Type: text/markdown
21
+ License-File: LICENSE
22
+ Requires-Dist: requests>=2.7.0
23
+ Requires-Dist: pydantic>=2.0.0
24
+ Dynamic: author
25
+ Dynamic: author-email
26
+ Dynamic: classifier
27
+ Dynamic: description
28
+ Dynamic: description-content-type
29
+ Dynamic: download-url
30
+ Dynamic: keywords
31
+ Dynamic: license
32
+ Dynamic: license-file
33
+ Dynamic: requires-dist
34
+ Dynamic: requires-python
35
+ Dynamic: summary
36
+
37
+ # Stytch Management Python Library
38
+
39
+ The Stytch Management Python library makes it easy to use Stytch's Programmatic Workspace Actions API in Python applications.
40
+
41
+ This library requires Python 3.8 or later.
42
+
43
+ ## Installation
44
+
45
+ ```bash
46
+ pip install stytch-management
47
+ ```
48
+
49
+ ## Pre-requisites
50
+
51
+ You need your Stytch Management API credentials from the workspace management section of your
52
+ [Stytch Dashboard](https://stytch.com/dashboard/settings/management-api).
53
+
54
+ **Note:** These credentials allow you to perform read and write actions on your workspace,
55
+ potentially modifying or deleting important Stytch resources like projects, environments, or secrets.
56
+
57
+ ## Examples
58
+
59
+ ### Create a new API client:
60
+
61
+ ```python
62
+ from stytch_management import Client
63
+
64
+ # Set your Stytch Management API credentials
65
+ client = Client(
66
+ workspace_key_id="workspace-test-...",
67
+ workspace_key_secret="secret-test-..."
68
+ )
69
+ ```
70
+
71
+ ### Create a new B2B project:
72
+
73
+ ```python
74
+ response = client.projects.create(
75
+ name="My new project",
76
+ vertical="B2B"
77
+ )
78
+
79
+ new_project = response.project
80
+ print(f"Created project: {new_project.project_slug}")
81
+ ```
82
+
83
+ ### Get the live environment in the new project:
84
+
85
+ ```python
86
+ response = client.environments.get_all(
87
+ project_slug=new_project.project_slug
88
+ )
89
+
90
+ live_env = next((env for env in response.environments if env.type == "LIVE"), None)
91
+ print(f"Live environment: {live_env.environment_slug}")
92
+ ```
93
+
94
+ ### Alternatively, create a new custom environment:
95
+
96
+ ```python
97
+ response = client.environments.create(
98
+ project_slug=new_project.project_slug,
99
+ name="My custom environment",
100
+ type="TEST"
101
+ )
102
+
103
+ custom_env = response.environment
104
+ print(f"Created environment: {custom_env.environment_slug}")
105
+ ```
106
+
107
+ ### Create a new secret in the live environment:
108
+
109
+ ```python
110
+ response = client.secrets.create(
111
+ project_slug=new_project.project_slug,
112
+ environment_slug=live_env.environment_slug
113
+ )
114
+
115
+ secret = response.secret
116
+ print(f"Created secret: {secret.secret_id}")
117
+ ```
118
+
119
+ ### Get SDK configuration:
120
+
121
+ ```python
122
+ response = client.sdk.get_consumer_config(
123
+ project_slug=new_project.project_slug,
124
+ environment_slug=live_env.environment_slug
125
+ )
126
+
127
+ print("Consumer SDK config:", response.config)
128
+ ```
129
+
130
+ ## Type Safety
131
+
132
+ All request and response types are fully typed using Pydantic models. Import them from the models subpackages:
133
+
134
+ ```python
135
+ from stytch_management.models import projects, environments, secrets
136
+
137
+ # Responses are typed
138
+ response: projects.CreateResponse = client.projects.create(
139
+ name="My project",
140
+ vertical="B2B"
141
+ )
142
+ ```
143
+
144
+ ## Error Handling
145
+
146
+ ```python
147
+ from stytch_management import Client, StytchError, ClientError
148
+
149
+ client = Client(
150
+ workspace_key_id="workspace-test-...",
151
+ workspace_key_secret="secret-test-..."
152
+ )
153
+
154
+ try:
155
+ client.projects.get(project_slug="invalid-slug")
156
+ except StytchError as e:
157
+ print(f"Stytch error: {e.error_type}")
158
+ print(f"Message: {e.error_message}")
159
+ print(f"Request ID: {e.request_id}")
160
+ except ClientError as e:
161
+ print(f"Client error: {e.message}")
162
+ ```
163
+
164
+ ## Running Tests
165
+
166
+ This library includes comprehensive integration tests that verify functionality against the Stytch API. These tests create and clean up disposable projects and resources.
167
+
168
+ ### Prerequisites
169
+
170
+ To run the tests, you need valid Stytch Management API credentials:
171
+
172
+ ```bash
173
+ export STYTCH_WORKSPACE_KEY_ID="your-workspace-key-id"
174
+ export STYTCH_WORKSPACE_KEY_SECRET="your-workspace-key-secret"
175
+ ```
176
+
177
+ **Important:** Tests will be skipped if these environment variables are not set. The tests create real resources in your workspace but clean them up automatically.
178
+
179
+ ### Running All Tests
180
+
181
+ ```bash
182
+ # Install dependencies (if not already installed)
183
+ pip install -r requirements_dev.txt
184
+
185
+ # Run all tests
186
+ python -m unittest discover test/
187
+
188
+ # Run a specific test file
189
+ python test/test_secrets.py
190
+ ```
191
+
192
+ ### Test Coverage
193
+
194
+ The test suite includes integration tests for:
195
+
196
+ - **Email Templates** - Create, get, update, delete, and default management
197
+ - **Environments** - Environment lifecycle with user locking and IDP configurations
198
+ - **Secrets** - Secret creation, retrieval, and deletion
199
+ - **Public Tokens** - Public token management
200
+ - **JWT Templates** - Session and M2M JWT template configuration
201
+ - **Redirect URLs** - URL validation and type management
202
+ - **Password Strength Config** - LUDS and ZXCVBN policy configuration
203
+ - **Country Code Allowlist** - SMS and WhatsApp country code management
204
+
205
+ Each test suite:
206
+
207
+ - ✓ Creates disposable projects/environments
208
+ - ✓ Tests all CRUD operations
209
+ - ✓ Validates error handling
210
+ - ✓ Cleans up all resources automatically
211
+ - ✓ Runs independently without side effects
212
+
213
+ ### Continuous Integration
214
+
215
+ Tests are designed to run in CI environments. Set the environment variables in your CI configuration:
216
+
217
+ ```yaml
218
+ # Example GitHub Actions
219
+ env:
220
+ STYTCH_WORKSPACE_KEY_ID: ${{ secrets.STYTCH_WORKSPACE_KEY_ID }}
221
+ STYTCH_WORKSPACE_KEY_SECRET: ${{ secrets.STYTCH_WORKSPACE_KEY_SECRET }}
222
+ ```
223
+
224
+ ## Development
225
+
226
+ See [DEVELOPMENT.md](./DEVELOPMENT.md) for information on building and testing the SDK.
227
+
228
+ ## Documentation
229
+
230
+ See the full [Stytch Management API documentation](https://stytch.com/docs/workspaces/management-api) for more details on available endpoints and functionality.
231
+
232
+ ## Support
233
+
234
+ If you've found a bug, [open an issue](https://github.com/stytchauth/stytch-management-python/issues/new)!
235
+
236
+ If you have questions or want help troubleshooting, join us in [Slack](https://stytch.com/docs/resources/support/overview) or email support@stytch.com.
237
+
238
+ If you've found a security vulnerability, please follow our [responsible disclosure instructions](https://stytch.com/docs/resources/security-and-trust/security#:~:text=Responsible%20disclosure%20program).
239
+
240
+ ## License
241
+
242
+ MIT
@@ -0,0 +1,206 @@
1
+ # Stytch Management Python Library
2
+
3
+ The Stytch Management Python library makes it easy to use Stytch's Programmatic Workspace Actions API in Python applications.
4
+
5
+ This library requires Python 3.8 or later.
6
+
7
+ ## Installation
8
+
9
+ ```bash
10
+ pip install stytch-management
11
+ ```
12
+
13
+ ## Pre-requisites
14
+
15
+ You need your Stytch Management API credentials from the workspace management section of your
16
+ [Stytch Dashboard](https://stytch.com/dashboard/settings/management-api).
17
+
18
+ **Note:** These credentials allow you to perform read and write actions on your workspace,
19
+ potentially modifying or deleting important Stytch resources like projects, environments, or secrets.
20
+
21
+ ## Examples
22
+
23
+ ### Create a new API client:
24
+
25
+ ```python
26
+ from stytch_management import Client
27
+
28
+ # Set your Stytch Management API credentials
29
+ client = Client(
30
+ workspace_key_id="workspace-test-...",
31
+ workspace_key_secret="secret-test-..."
32
+ )
33
+ ```
34
+
35
+ ### Create a new B2B project:
36
+
37
+ ```python
38
+ response = client.projects.create(
39
+ name="My new project",
40
+ vertical="B2B"
41
+ )
42
+
43
+ new_project = response.project
44
+ print(f"Created project: {new_project.project_slug}")
45
+ ```
46
+
47
+ ### Get the live environment in the new project:
48
+
49
+ ```python
50
+ response = client.environments.get_all(
51
+ project_slug=new_project.project_slug
52
+ )
53
+
54
+ live_env = next((env for env in response.environments if env.type == "LIVE"), None)
55
+ print(f"Live environment: {live_env.environment_slug}")
56
+ ```
57
+
58
+ ### Alternatively, create a new custom environment:
59
+
60
+ ```python
61
+ response = client.environments.create(
62
+ project_slug=new_project.project_slug,
63
+ name="My custom environment",
64
+ type="TEST"
65
+ )
66
+
67
+ custom_env = response.environment
68
+ print(f"Created environment: {custom_env.environment_slug}")
69
+ ```
70
+
71
+ ### Create a new secret in the live environment:
72
+
73
+ ```python
74
+ response = client.secrets.create(
75
+ project_slug=new_project.project_slug,
76
+ environment_slug=live_env.environment_slug
77
+ )
78
+
79
+ secret = response.secret
80
+ print(f"Created secret: {secret.secret_id}")
81
+ ```
82
+
83
+ ### Get SDK configuration:
84
+
85
+ ```python
86
+ response = client.sdk.get_consumer_config(
87
+ project_slug=new_project.project_slug,
88
+ environment_slug=live_env.environment_slug
89
+ )
90
+
91
+ print("Consumer SDK config:", response.config)
92
+ ```
93
+
94
+ ## Type Safety
95
+
96
+ All request and response types are fully typed using Pydantic models. Import them from the models subpackages:
97
+
98
+ ```python
99
+ from stytch_management.models import projects, environments, secrets
100
+
101
+ # Responses are typed
102
+ response: projects.CreateResponse = client.projects.create(
103
+ name="My project",
104
+ vertical="B2B"
105
+ )
106
+ ```
107
+
108
+ ## Error Handling
109
+
110
+ ```python
111
+ from stytch_management import Client, StytchError, ClientError
112
+
113
+ client = Client(
114
+ workspace_key_id="workspace-test-...",
115
+ workspace_key_secret="secret-test-..."
116
+ )
117
+
118
+ try:
119
+ client.projects.get(project_slug="invalid-slug")
120
+ except StytchError as e:
121
+ print(f"Stytch error: {e.error_type}")
122
+ print(f"Message: {e.error_message}")
123
+ print(f"Request ID: {e.request_id}")
124
+ except ClientError as e:
125
+ print(f"Client error: {e.message}")
126
+ ```
127
+
128
+ ## Running Tests
129
+
130
+ This library includes comprehensive integration tests that verify functionality against the Stytch API. These tests create and clean up disposable projects and resources.
131
+
132
+ ### Prerequisites
133
+
134
+ To run the tests, you need valid Stytch Management API credentials:
135
+
136
+ ```bash
137
+ export STYTCH_WORKSPACE_KEY_ID="your-workspace-key-id"
138
+ export STYTCH_WORKSPACE_KEY_SECRET="your-workspace-key-secret"
139
+ ```
140
+
141
+ **Important:** Tests will be skipped if these environment variables are not set. The tests create real resources in your workspace but clean them up automatically.
142
+
143
+ ### Running All Tests
144
+
145
+ ```bash
146
+ # Install dependencies (if not already installed)
147
+ pip install -r requirements_dev.txt
148
+
149
+ # Run all tests
150
+ python -m unittest discover test/
151
+
152
+ # Run a specific test file
153
+ python test/test_secrets.py
154
+ ```
155
+
156
+ ### Test Coverage
157
+
158
+ The test suite includes integration tests for:
159
+
160
+ - **Email Templates** - Create, get, update, delete, and default management
161
+ - **Environments** - Environment lifecycle with user locking and IDP configurations
162
+ - **Secrets** - Secret creation, retrieval, and deletion
163
+ - **Public Tokens** - Public token management
164
+ - **JWT Templates** - Session and M2M JWT template configuration
165
+ - **Redirect URLs** - URL validation and type management
166
+ - **Password Strength Config** - LUDS and ZXCVBN policy configuration
167
+ - **Country Code Allowlist** - SMS and WhatsApp country code management
168
+
169
+ Each test suite:
170
+
171
+ - ✓ Creates disposable projects/environments
172
+ - ✓ Tests all CRUD operations
173
+ - ✓ Validates error handling
174
+ - ✓ Cleans up all resources automatically
175
+ - ✓ Runs independently without side effects
176
+
177
+ ### Continuous Integration
178
+
179
+ Tests are designed to run in CI environments. Set the environment variables in your CI configuration:
180
+
181
+ ```yaml
182
+ # Example GitHub Actions
183
+ env:
184
+ STYTCH_WORKSPACE_KEY_ID: ${{ secrets.STYTCH_WORKSPACE_KEY_ID }}
185
+ STYTCH_WORKSPACE_KEY_SECRET: ${{ secrets.STYTCH_WORKSPACE_KEY_SECRET }}
186
+ ```
187
+
188
+ ## Development
189
+
190
+ See [DEVELOPMENT.md](./DEVELOPMENT.md) for information on building and testing the SDK.
191
+
192
+ ## Documentation
193
+
194
+ See the full [Stytch Management API documentation](https://stytch.com/docs/workspaces/management-api) for more details on available endpoints and functionality.
195
+
196
+ ## Support
197
+
198
+ If you've found a bug, [open an issue](https://github.com/stytchauth/stytch-management-python/issues/new)!
199
+
200
+ If you have questions or want help troubleshooting, join us in [Slack](https://stytch.com/docs/resources/support/overview) or email support@stytch.com.
201
+
202
+ If you've found a security vulnerability, please follow our [responsible disclosure instructions](https://stytch.com/docs/resources/security-and-trust/security#:~:text=Responsible%20disclosure%20program).
203
+
204
+ ## License
205
+
206
+ MIT
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,62 @@
1
+ #!/usr/bin/env python3
2
+
3
+ import pathlib
4
+ import re
5
+
6
+ from setuptools import find_packages, setup
7
+
8
+ # The directory containing this file
9
+ HERE = pathlib.Path(__file__).parent
10
+
11
+ # The text of the README file
12
+ README = (HERE / "README.md").read_text()
13
+
14
+ with open("stytch_management/version.py", "r") as f:
15
+ match = re.search(r'^__version__\s*=\s*[\'"]([^\'"]*)[\'"]', f.read(), re.MULTILINE)
16
+ assert match is not None
17
+ version = match.group(1)
18
+
19
+ if not version:
20
+ raise RuntimeError("Cannot find version information")
21
+
22
+ # This call to setup() does all the work
23
+ setup(
24
+ name="stytch-management",
25
+ version=version,
26
+ description="Stytch Management API Python client",
27
+ long_description=README,
28
+ long_description_content_type="text/markdown",
29
+ download_url="https://github.com/stytchauth/stytch-management-python",
30
+ keywords=[
31
+ "stytch",
32
+ "management",
33
+ "api",
34
+ "workspace",
35
+ "programmatic",
36
+ ],
37
+ author="Stytch",
38
+ author_email="hello@stytch.com",
39
+ license="MIT",
40
+ classifiers=[
41
+ "License :: OSI Approved :: MIT License",
42
+ "Intended Audience :: Developers",
43
+ "Programming Language :: Python :: 3",
44
+ "Programming Language :: Python :: 3 :: Only",
45
+ "Programming Language :: Python :: 3.8",
46
+ "Programming Language :: Python :: 3.9",
47
+ "Programming Language :: Python :: 3.10",
48
+ "Programming Language :: Python :: 3.11",
49
+ "Programming Language :: Python :: 3.12",
50
+ ],
51
+ python_requires=">=3.8",
52
+ packages=find_packages(
53
+ include=["stytch_management*"],
54
+ exclude=["*.test", "*.tests", "*.test.*", "*.tests.*", "test", "tests"],
55
+ ),
56
+ package_data={"stytch_management": ["py.typed"]},
57
+ include_package_data=True,
58
+ install_requires=[
59
+ "requests>=2.7.0",
60
+ "pydantic>=2.0.0",
61
+ ],
62
+ )
@@ -0,0 +1,5 @@
1
+ from stytch_management.client import Client
2
+ from stytch_management.errors import ClientError, StytchError
3
+ from stytch_management.version import __version__
4
+
5
+ __all__ = ["Client", "ClientError", "StytchError", "__version__"]
@@ -0,0 +1,7 @@
1
+ # !!!
2
+ # WARNING: This file is autogenerated
3
+ # Only modify code within MANUAL() sections
4
+ # or your changes may be overwritten later!
5
+ # !!!
6
+
7
+ from __future__ import annotations
@@ -0,0 +1,100 @@
1
+ #!/usr/bin/env python3
2
+
3
+ # !!!
4
+ # WARNING: This file is autogenerated
5
+ # Only modify code within MANUAL() sections
6
+ # or your changes may be overwritten later!
7
+ # !!!
8
+
9
+
10
+ from typing import Optional
11
+
12
+ import requests
13
+ from stytch_management.country_code_allowlist import CountryCodeAllowlist
14
+ from stytch_management.emailtemplates import EmailTemplates
15
+ from stytch_management.environments import Environments
16
+ from stytch_management.event_log_streaming import EventLogStreaming
17
+ from stytch_management.http_client import DEFAULT_BASE_URL, HTTPClient
18
+ from stytch_management.jwttemplates import JWTTemplates
19
+ from stytch_management.passwordstrengthconfig import PasswordStrengthConfig
20
+ from stytch_management.projects import Projects
21
+ from stytch_management.publictokens import PublicTokens
22
+ from stytch_management.rbacpolicy import RBACPolicy
23
+ from stytch_management.redirecturls import RedirectURLs
24
+ from stytch_management.sdk import SDK
25
+ from stytch_management.secrets import Secrets
26
+ from stytch_management.trustedtokenprofiles import TrustedTokenProfiles
27
+
28
+
29
+ class Client:
30
+ """
31
+ Main client for interacting with the Stytch Management API.
32
+
33
+ This client provides access to all Stytch Management API resources for programmatic
34
+ workspace actions.
35
+
36
+ Example:
37
+ >>> from stytch_management import Client
38
+ >>> client = Client(
39
+ ... workspace_key_id="workspace-test-...",
40
+ ... workspace_key_secret="secret-test-..."
41
+ ... )
42
+ >>> projects = client.projects.get_all()
43
+ """
44
+
45
+ def __init__(
46
+ self,
47
+ workspace_key_id: str,
48
+ workspace_key_secret: str,
49
+ base_url: str = DEFAULT_BASE_URL,
50
+ timeout: int = 30,
51
+ session: Optional[requests.Session] = None,
52
+ ):
53
+ """
54
+ Initialize a new ManagementClient.
55
+
56
+ Args:
57
+ workspace_key_id: Your Stytch workspace key ID
58
+ workspace_key_secret: Your Stytch workspace key secret
59
+ base_url: Base URL for the Stytch Management API (defaults to production)
60
+ timeout: Request timeout in seconds (default: 30)
61
+ session: Optional requests.Session for connection pooling
62
+
63
+ Raises:
64
+ ValueError: If workspace_key_id or workspace_key_secret is missing
65
+ ValueError: If base_url doesn't use HTTPS scheme
66
+ """
67
+ if not workspace_key_id:
68
+ raise ValueError('Missing "workspace_key_id"')
69
+ if not workspace_key_secret:
70
+ raise ValueError('Missing "workspace_key_secret"')
71
+
72
+ if not base_url.startswith("https://"):
73
+ raise ValueError("base_url must use HTTPS scheme")
74
+
75
+ # Ensure base_url ends with a trailing slash
76
+ if not base_url.endswith("/"):
77
+ base_url = base_url + "/"
78
+
79
+ self._http_client = HTTPClient(
80
+ workspace_key_id=workspace_key_id,
81
+ workspace_key_secret=workspace_key_secret,
82
+ base_url=base_url,
83
+ timeout=timeout,
84
+ session=session,
85
+ )
86
+
87
+ # Resource clients
88
+ self.projects = Projects(self._http_client)
89
+ self.country_code_allowlist = CountryCodeAllowlist(self._http_client)
90
+ self.email_templates = EmailTemplates(self._http_client)
91
+ self.environments = Environments(self._http_client)
92
+ self.event_log_streaming = EventLogStreaming(self._http_client)
93
+ self.jwt_templates = JWTTemplates(self._http_client)
94
+ self.password_strength_config = PasswordStrengthConfig(self._http_client)
95
+ self.public_tokens = PublicTokens(self._http_client)
96
+ self.rbac_policy = RBACPolicy(self._http_client)
97
+ self.redirect_urls = RedirectURLs(self._http_client)
98
+ self.sdk = SDK(self._http_client)
99
+ self.secrets = Secrets(self._http_client)
100
+ self.trusted_token_profiles = TrustedTokenProfiles(self._http_client)