stackmachine 0.3.1__tar.gz → 0.3.2__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 (31) hide show
  1. {stackmachine-0.3.1 → stackmachine-0.3.2}/PKG-INFO +17 -21
  2. {stackmachine-0.3.1 → stackmachine-0.3.2}/README.md +16 -20
  3. {stackmachine-0.3.1 → stackmachine-0.3.2}/pyproject.toml +1 -1
  4. {stackmachine-0.3.1 → stackmachine-0.3.2}/src/stackmachine/__init__.py +1 -1
  5. {stackmachine-0.3.1 → stackmachine-0.3.2}/src/stackmachine/_async_client.py +20 -8
  6. {stackmachine-0.3.1 → stackmachine-0.3.2}/src/stackmachine/_client.py +20 -8
  7. {stackmachine-0.3.1 → stackmachine-0.3.2}/tests/test_package.py +18 -3
  8. {stackmachine-0.3.1 → stackmachine-0.3.2}/.gitignore +0 -0
  9. {stackmachine-0.3.1 → stackmachine-0.3.2}/examples/async_usage.py +0 -0
  10. {stackmachine-0.3.1 → stackmachine-0.3.2}/examples/basic_usage.py +0 -0
  11. {stackmachine-0.3.1 → stackmachine-0.3.2}/examples/deploy_app.py +0 -0
  12. {stackmachine-0.3.1 → stackmachine-0.3.2}/examples/list_apps.py +0 -0
  13. {stackmachine-0.3.1 → stackmachine-0.3.2}/src/stackmachine/_config.py +0 -0
  14. {stackmachine-0.3.1 → stackmachine-0.3.2}/src/stackmachine/_errors.py +0 -0
  15. {stackmachine-0.3.1 → stackmachine-0.3.2}/src/stackmachine/_graphql/__init__.py +0 -0
  16. {stackmachine-0.3.1 → stackmachine-0.3.2}/src/stackmachine/_graphql/operations.py +0 -0
  17. {stackmachine-0.3.1 → stackmachine-0.3.2}/src/stackmachine/_models.py +0 -0
  18. {stackmachine-0.3.1 → stackmachine-0.3.2}/src/stackmachine/_pagination.py +0 -0
  19. {stackmachine-0.3.1 → stackmachine-0.3.2}/src/stackmachine/_transport.py +0 -0
  20. {stackmachine-0.3.1 → stackmachine-0.3.2}/src/stackmachine/_types.py +0 -0
  21. {stackmachine-0.3.1 → stackmachine-0.3.2}/src/stackmachine/_uploads.py +0 -0
  22. {stackmachine-0.3.1 → stackmachine-0.3.2}/src/stackmachine/_utils.py +0 -0
  23. {stackmachine-0.3.1 → stackmachine-0.3.2}/src/stackmachine/py.typed +0 -0
  24. {stackmachine-0.3.1 → stackmachine-0.3.2}/src/stackmachine/resources/__init__.py +0 -0
  25. {stackmachine-0.3.1 → stackmachine-0.3.2}/src/stackmachine/resources/_shared.py +0 -0
  26. {stackmachine-0.3.1 → stackmachine-0.3.2}/src/stackmachine/resources/apps.py +0 -0
  27. {stackmachine-0.3.1 → stackmachine-0.3.2}/src/stackmachine/resources/deployments.py +0 -0
  28. {stackmachine-0.3.1 → stackmachine-0.3.2}/src/stackmachine/resources/domains.py +0 -0
  29. {stackmachine-0.3.1 → stackmachine-0.3.2}/src/stackmachine/resources/files.py +0 -0
  30. {stackmachine-0.3.1 → stackmachine-0.3.2}/src/stackmachine/resources/ssh.py +0 -0
  31. {stackmachine-0.3.1 → stackmachine-0.3.2}/src/stackmachine/resources/versions.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: stackmachine
3
- Version: 0.3.1
3
+ Version: 0.3.2
4
4
  Summary: Python SDK for StackMachine.
5
5
  Project-URL: Homepage, https://github.com/stackmachine/sdks/tree/main/python
6
6
  Project-URL: Repository, https://github.com/stackmachine/sdks
@@ -61,15 +61,13 @@ stackmachine = StackMachine("sk_stackmachine_...")
61
61
  async_stackmachine = AsyncStackMachine("sk_stackmachine_...")
62
62
  ```
63
63
 
64
- Both clients accept JavaScript-style aliases during initialization:
64
+ Both clients accept configuration options during initialization:
65
65
 
66
66
  ```python
67
- stackmachine = StackMachine.init(
68
- {
69
- "token": "sk_stackmachine_...",
70
- "apiUrl": "https://api.stackmachine.com/graphql",
71
- "maxNetworkRetries": 2,
72
- }
67
+ stackmachine = StackMachine(
68
+ "sk_stackmachine_...",
69
+ apiUrl="https://api.stackmachine.com/graphql",
70
+ maxNetworkRetries=2,
73
71
  )
74
72
  ```
75
73
 
@@ -101,10 +99,8 @@ async for app in apps:
101
99
 
102
100
  ```python
103
101
  deployment = stackmachine.deployments.create(
104
- {
105
- "file": "https://example.com/app.zip",
106
- "name": "my-app",
107
- }
102
+ upload_url="https://example.com/app.zip",
103
+ app_name="my-app",
108
104
  )
109
105
 
110
106
  version = deployment.wait()
@@ -112,10 +108,8 @@ version = deployment.wait()
112
108
 
113
109
  ```python
114
110
  deployment = stackmachine.apps.autobuild(
115
- {
116
- "file": "https://example.com/app.zip",
117
- "name": "my-app",
118
- }
111
+ upload_url="https://example.com/app.zip",
112
+ app_name="my-app",
119
113
  )
120
114
  ```
121
115
 
@@ -162,13 +156,15 @@ key = stackmachine.apps.ssh.users.authorized_keys.create(
162
156
  Most methods accept `request_options` for per-request configuration:
163
157
 
164
158
  ```python
159
+ from stackmachine import RequestOptions
160
+
165
161
  app = stackmachine.apps.retrieve(
166
162
  "app_id",
167
- request_options={
168
- "api_key": "sk_stackmachine_other",
169
- "timeout": 30,
170
- "idempotency_key": "deploy-123",
171
- },
163
+ request_options=RequestOptions(
164
+ api_key="sk_stackmachine_other",
165
+ timeout=30,
166
+ idempotency_key="deploy-123",
167
+ ),
172
168
  )
173
169
  ```
174
170
 
@@ -39,15 +39,13 @@ stackmachine = StackMachine("sk_stackmachine_...")
39
39
  async_stackmachine = AsyncStackMachine("sk_stackmachine_...")
40
40
  ```
41
41
 
42
- Both clients accept JavaScript-style aliases during initialization:
42
+ Both clients accept configuration options during initialization:
43
43
 
44
44
  ```python
45
- stackmachine = StackMachine.init(
46
- {
47
- "token": "sk_stackmachine_...",
48
- "apiUrl": "https://api.stackmachine.com/graphql",
49
- "maxNetworkRetries": 2,
50
- }
45
+ stackmachine = StackMachine(
46
+ "sk_stackmachine_...",
47
+ apiUrl="https://api.stackmachine.com/graphql",
48
+ maxNetworkRetries=2,
51
49
  )
52
50
  ```
53
51
 
@@ -79,10 +77,8 @@ async for app in apps:
79
77
 
80
78
  ```python
81
79
  deployment = stackmachine.deployments.create(
82
- {
83
- "file": "https://example.com/app.zip",
84
- "name": "my-app",
85
- }
80
+ upload_url="https://example.com/app.zip",
81
+ app_name="my-app",
86
82
  )
87
83
 
88
84
  version = deployment.wait()
@@ -90,10 +86,8 @@ version = deployment.wait()
90
86
 
91
87
  ```python
92
88
  deployment = stackmachine.apps.autobuild(
93
- {
94
- "file": "https://example.com/app.zip",
95
- "name": "my-app",
96
- }
89
+ upload_url="https://example.com/app.zip",
90
+ app_name="my-app",
97
91
  )
98
92
  ```
99
93
 
@@ -140,13 +134,15 @@ key = stackmachine.apps.ssh.users.authorized_keys.create(
140
134
  Most methods accept `request_options` for per-request configuration:
141
135
 
142
136
  ```python
137
+ from stackmachine import RequestOptions
138
+
143
139
  app = stackmachine.apps.retrieve(
144
140
  "app_id",
145
- request_options={
146
- "api_key": "sk_stackmachine_other",
147
- "timeout": 30,
148
- "idempotency_key": "deploy-123",
149
- },
141
+ request_options=RequestOptions(
142
+ api_key="sk_stackmachine_other",
143
+ timeout=30,
144
+ idempotency_key="deploy-123",
145
+ ),
150
146
  )
151
147
  ```
152
148
 
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "stackmachine"
7
- version = "0.3.1"
7
+ version = "0.3.2"
8
8
  description = "Python SDK for StackMachine."
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.9"
@@ -74,7 +74,7 @@ from ._uploads import create_zip
74
74
  try:
75
75
  __version__ = version("stackmachine")
76
76
  except PackageNotFoundError:
77
- __version__ = "0.3.1"
77
+ __version__ = "0.3.2"
78
78
 
79
79
  __all__ = [
80
80
  "AppAlias",
@@ -25,24 +25,36 @@ class AsyncStackMachine:
25
25
  self,
26
26
  api_key: str,
27
27
  *,
28
- api_url: str = DEFAULT_API_URL,
28
+ api_url: Optional[str] = None,
29
+ apiUrl: Optional[str] = None,
29
30
  headers: Optional[Headers] = None,
30
31
  timeout: float = DEFAULT_TIMEOUT,
31
- max_network_retries: int = DEFAULT_MAX_NETWORK_RETRIES,
32
+ max_network_retries: Optional[int] = None,
33
+ maxNetworkRetries: Optional[int] = None,
32
34
  http_client: Optional[httpx.AsyncClient] = None,
33
35
  http_transport: Optional[httpx.AsyncBaseTransport] = None,
34
36
  ) -> None:
37
+ resolved_api_url = (
38
+ api_url if api_url is not None else apiUrl or DEFAULT_API_URL
39
+ )
40
+ resolved_max_retries = (
41
+ max_network_retries
42
+ if max_network_retries is not None
43
+ else maxNetworkRetries
44
+ if maxNetworkRetries is not None
45
+ else DEFAULT_MAX_NETWORK_RETRIES
46
+ )
35
47
  self.api_key = api_key
36
- self.api_url = api_url
37
- self.apiUrl = api_url
48
+ self.api_url = resolved_api_url
49
+ self.apiUrl = resolved_api_url
38
50
  self.timeout = timeout
39
- self.max_network_retries = max_network_retries
40
- self.maxNetworkRetries = max_network_retries
51
+ self.max_network_retries = resolved_max_retries
52
+ self.maxNetworkRetries = resolved_max_retries
41
53
  self._config = ClientConfig(
42
- api_url=api_url,
54
+ api_url=resolved_api_url,
43
55
  headers=headers,
44
56
  timeout=timeout,
45
- max_network_retries=max_network_retries,
57
+ max_network_retries=resolved_max_retries,
46
58
  )
47
59
  self._transport = AsyncTransport(
48
60
  api_key,
@@ -25,24 +25,36 @@ class StackMachine:
25
25
  self,
26
26
  api_key: str,
27
27
  *,
28
- api_url: str = DEFAULT_API_URL,
28
+ api_url: Optional[str] = None,
29
+ apiUrl: Optional[str] = None,
29
30
  headers: Optional[Headers] = None,
30
31
  timeout: float = DEFAULT_TIMEOUT,
31
- max_network_retries: int = DEFAULT_MAX_NETWORK_RETRIES,
32
+ max_network_retries: Optional[int] = None,
33
+ maxNetworkRetries: Optional[int] = None,
32
34
  http_client: Optional[httpx.Client] = None,
33
35
  http_transport: Optional[httpx.BaseTransport] = None,
34
36
  ) -> None:
37
+ resolved_api_url = (
38
+ api_url if api_url is not None else apiUrl or DEFAULT_API_URL
39
+ )
40
+ resolved_max_retries = (
41
+ max_network_retries
42
+ if max_network_retries is not None
43
+ else maxNetworkRetries
44
+ if maxNetworkRetries is not None
45
+ else DEFAULT_MAX_NETWORK_RETRIES
46
+ )
35
47
  self.api_key = api_key
36
- self.api_url = api_url
37
- self.apiUrl = api_url
48
+ self.api_url = resolved_api_url
49
+ self.apiUrl = resolved_api_url
38
50
  self.timeout = timeout
39
- self.max_network_retries = max_network_retries
40
- self.maxNetworkRetries = max_network_retries
51
+ self.max_network_retries = resolved_max_retries
52
+ self.maxNetworkRetries = resolved_max_retries
41
53
  self._config = ClientConfig(
42
- api_url=api_url,
54
+ api_url=resolved_api_url,
43
55
  headers=headers,
44
56
  timeout=timeout,
45
- max_network_retries=max_network_retries,
57
+ max_network_retries=resolved_max_retries,
46
58
  )
47
59
  self._transport = SyncTransport(
48
60
  api_key,
@@ -65,9 +65,10 @@ def test_file_upload_signature_uses_public_types() -> None:
65
65
  assert hints["request_options"] == Optional[stackmachine.RequestOptionsLike]
66
66
 
67
67
 
68
- def test_client_init_accepts_js_style_aliases() -> None:
69
- client = StackMachine.init(
70
- {"token": "token-1", "apiUrl": "https://api.example/graphql"},
68
+ def test_client_constructor_accepts_configuration_aliases() -> None:
69
+ client = StackMachine(
70
+ "token-1",
71
+ apiUrl="https://api.example/graphql",
71
72
  maxNetworkRetries=3,
72
73
  http_transport=httpx.MockTransport(lambda _: graphql_response({})),
73
74
  )
@@ -81,6 +82,20 @@ def test_client_init_accepts_js_style_aliases() -> None:
81
82
  client.close()
82
83
 
83
84
 
85
+ def test_client_init_accepts_mapping_settings() -> None:
86
+ client = StackMachine.init(
87
+ {"token": "token-1", "apiUrl": "https://api.example/graphql"},
88
+ maxNetworkRetries=3,
89
+ http_transport=httpx.MockTransport(lambda _: graphql_response({})),
90
+ )
91
+ try:
92
+ assert client.api_key == "token-1"
93
+ assert client.api_url == "https://api.example/graphql"
94
+ assert client.max_network_retries == 3
95
+ finally:
96
+ client.close()
97
+
98
+
84
99
  def test_sync_viewer_sends_auth_header_and_returns_model() -> None:
85
100
  seen: dict[str, Any] = {}
86
101
 
File without changes