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.
- {stackmachine-0.3.1 → stackmachine-0.3.2}/PKG-INFO +17 -21
- {stackmachine-0.3.1 → stackmachine-0.3.2}/README.md +16 -20
- {stackmachine-0.3.1 → stackmachine-0.3.2}/pyproject.toml +1 -1
- {stackmachine-0.3.1 → stackmachine-0.3.2}/src/stackmachine/__init__.py +1 -1
- {stackmachine-0.3.1 → stackmachine-0.3.2}/src/stackmachine/_async_client.py +20 -8
- {stackmachine-0.3.1 → stackmachine-0.3.2}/src/stackmachine/_client.py +20 -8
- {stackmachine-0.3.1 → stackmachine-0.3.2}/tests/test_package.py +18 -3
- {stackmachine-0.3.1 → stackmachine-0.3.2}/.gitignore +0 -0
- {stackmachine-0.3.1 → stackmachine-0.3.2}/examples/async_usage.py +0 -0
- {stackmachine-0.3.1 → stackmachine-0.3.2}/examples/basic_usage.py +0 -0
- {stackmachine-0.3.1 → stackmachine-0.3.2}/examples/deploy_app.py +0 -0
- {stackmachine-0.3.1 → stackmachine-0.3.2}/examples/list_apps.py +0 -0
- {stackmachine-0.3.1 → stackmachine-0.3.2}/src/stackmachine/_config.py +0 -0
- {stackmachine-0.3.1 → stackmachine-0.3.2}/src/stackmachine/_errors.py +0 -0
- {stackmachine-0.3.1 → stackmachine-0.3.2}/src/stackmachine/_graphql/__init__.py +0 -0
- {stackmachine-0.3.1 → stackmachine-0.3.2}/src/stackmachine/_graphql/operations.py +0 -0
- {stackmachine-0.3.1 → stackmachine-0.3.2}/src/stackmachine/_models.py +0 -0
- {stackmachine-0.3.1 → stackmachine-0.3.2}/src/stackmachine/_pagination.py +0 -0
- {stackmachine-0.3.1 → stackmachine-0.3.2}/src/stackmachine/_transport.py +0 -0
- {stackmachine-0.3.1 → stackmachine-0.3.2}/src/stackmachine/_types.py +0 -0
- {stackmachine-0.3.1 → stackmachine-0.3.2}/src/stackmachine/_uploads.py +0 -0
- {stackmachine-0.3.1 → stackmachine-0.3.2}/src/stackmachine/_utils.py +0 -0
- {stackmachine-0.3.1 → stackmachine-0.3.2}/src/stackmachine/py.typed +0 -0
- {stackmachine-0.3.1 → stackmachine-0.3.2}/src/stackmachine/resources/__init__.py +0 -0
- {stackmachine-0.3.1 → stackmachine-0.3.2}/src/stackmachine/resources/_shared.py +0 -0
- {stackmachine-0.3.1 → stackmachine-0.3.2}/src/stackmachine/resources/apps.py +0 -0
- {stackmachine-0.3.1 → stackmachine-0.3.2}/src/stackmachine/resources/deployments.py +0 -0
- {stackmachine-0.3.1 → stackmachine-0.3.2}/src/stackmachine/resources/domains.py +0 -0
- {stackmachine-0.3.1 → stackmachine-0.3.2}/src/stackmachine/resources/files.py +0 -0
- {stackmachine-0.3.1 → stackmachine-0.3.2}/src/stackmachine/resources/ssh.py +0 -0
- {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.
|
|
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
|
|
64
|
+
Both clients accept configuration options during initialization:
|
|
65
65
|
|
|
66
66
|
```python
|
|
67
|
-
stackmachine = StackMachine
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
169
|
-
|
|
170
|
-
|
|
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
|
|
42
|
+
Both clients accept configuration options during initialization:
|
|
43
43
|
|
|
44
44
|
```python
|
|
45
|
-
stackmachine = StackMachine
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
147
|
-
|
|
148
|
-
|
|
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
|
|
|
@@ -25,24 +25,36 @@ class AsyncStackMachine:
|
|
|
25
25
|
self,
|
|
26
26
|
api_key: str,
|
|
27
27
|
*,
|
|
28
|
-
api_url: str =
|
|
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 =
|
|
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 =
|
|
37
|
-
self.apiUrl =
|
|
48
|
+
self.api_url = resolved_api_url
|
|
49
|
+
self.apiUrl = resolved_api_url
|
|
38
50
|
self.timeout = timeout
|
|
39
|
-
self.max_network_retries =
|
|
40
|
-
self.maxNetworkRetries =
|
|
51
|
+
self.max_network_retries = resolved_max_retries
|
|
52
|
+
self.maxNetworkRetries = resolved_max_retries
|
|
41
53
|
self._config = ClientConfig(
|
|
42
|
-
api_url=
|
|
54
|
+
api_url=resolved_api_url,
|
|
43
55
|
headers=headers,
|
|
44
56
|
timeout=timeout,
|
|
45
|
-
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 =
|
|
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 =
|
|
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 =
|
|
37
|
-
self.apiUrl =
|
|
48
|
+
self.api_url = resolved_api_url
|
|
49
|
+
self.apiUrl = resolved_api_url
|
|
38
50
|
self.timeout = timeout
|
|
39
|
-
self.max_network_retries =
|
|
40
|
-
self.maxNetworkRetries =
|
|
51
|
+
self.max_network_retries = resolved_max_retries
|
|
52
|
+
self.maxNetworkRetries = resolved_max_retries
|
|
41
53
|
self._config = ClientConfig(
|
|
42
|
-
api_url=
|
|
54
|
+
api_url=resolved_api_url,
|
|
43
55
|
headers=headers,
|
|
44
56
|
timeout=timeout,
|
|
45
|
-
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
|
|
69
|
-
client = StackMachine
|
|
70
|
-
|
|
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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|