stackmachine 0.3.2__py3-none-any.whl → 0.3.3__py3-none-any.whl
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/__init__.py +3 -1
- stackmachine/_types.py +4 -2
- stackmachine/resources/apps.py +23 -3
- stackmachine/resources/deployments.py +59 -4
- {stackmachine-0.3.2.dist-info → stackmachine-0.3.3.dist-info}/METADATA +14 -5
- {stackmachine-0.3.2.dist-info → stackmachine-0.3.3.dist-info}/RECORD +7 -7
- {stackmachine-0.3.2.dist-info → stackmachine-0.3.3.dist-info}/WHEEL +0 -0
stackmachine/__init__.py
CHANGED
|
@@ -54,6 +54,7 @@ from ._types import (
|
|
|
54
54
|
DeployAppsSortBy,
|
|
55
55
|
DeployAppVersionsSortBy,
|
|
56
56
|
DeployAppWordPressExtraData,
|
|
57
|
+
DeploymentFilesInput,
|
|
57
58
|
DeploymentProgressCallback,
|
|
58
59
|
FileInput,
|
|
59
60
|
Headers,
|
|
@@ -74,7 +75,7 @@ from ._uploads import create_zip
|
|
|
74
75
|
try:
|
|
75
76
|
__version__ = version("stackmachine")
|
|
76
77
|
except PackageNotFoundError:
|
|
77
|
-
__version__ = "0.3.
|
|
78
|
+
__version__ = "0.3.3"
|
|
78
79
|
|
|
79
80
|
__all__ = [
|
|
80
81
|
"AppAlias",
|
|
@@ -105,6 +106,7 @@ __all__ = [
|
|
|
105
106
|
"DeployAppWordPressExtraData",
|
|
106
107
|
"DeployAppsListInput",
|
|
107
108
|
"DeployAppsSortBy",
|
|
109
|
+
"DeploymentFilesInput",
|
|
108
110
|
"DeploymentProgress",
|
|
109
111
|
"DeploymentProgressCallback",
|
|
110
112
|
"ExpectedDNSRecord",
|
stackmachine/_types.py
CHANGED
|
@@ -178,6 +178,7 @@ class DeployAppAutobuildInput(TypedDict, total=False):
|
|
|
178
178
|
envVars: Optional[Sequence[Optional[DeployAppEnvVarInput]]]
|
|
179
179
|
extra_data: Optional[DeployAppAutobuildExtraData]
|
|
180
180
|
extraData: Optional[DeployAppAutobuildExtraData]
|
|
181
|
+
files: Optional[DeploymentFilesInput]
|
|
181
182
|
install_cmd: Optional[str]
|
|
182
183
|
installCmd: Optional[str]
|
|
183
184
|
jobs: Optional[Sequence[Optional[DeployAppJobDefinitionInput]]]
|
|
@@ -240,15 +241,16 @@ class Readable(Protocol):
|
|
|
240
241
|
|
|
241
242
|
FileInput = Union[str, bytes, bytearray, memoryview, Path, Readable]
|
|
242
243
|
CreateZipFiles = Mapping[str, FileInput]
|
|
244
|
+
DeploymentFilesInput = CreateZipFiles
|
|
243
245
|
|
|
244
246
|
|
|
245
247
|
class UploadProgressCallback(Protocol):
|
|
246
|
-
def __call__(self, progress: "UploadProgress") -> None:
|
|
248
|
+
def __call__(self, progress: "UploadProgress", /) -> None:
|
|
247
249
|
...
|
|
248
250
|
|
|
249
251
|
|
|
250
252
|
class DeploymentProgressCallback(Protocol):
|
|
251
|
-
def __call__(self, progress: "DeploymentProgress") -> None:
|
|
253
|
+
def __call__(self, progress: "DeploymentProgress", /) -> None:
|
|
252
254
|
...
|
|
253
255
|
|
|
254
256
|
|
stackmachine/resources/apps.py
CHANGED
|
@@ -20,8 +20,8 @@ from .._types import (
|
|
|
20
20
|
DeployAppsSortBy,
|
|
21
21
|
PaginationOptions,
|
|
22
22
|
RequestOptionsLike,
|
|
23
|
+
UploadProgressCallback,
|
|
23
24
|
)
|
|
24
|
-
from .._utils import camelize, merge_input
|
|
25
25
|
from ._shared import page_variables, resource_missing_error
|
|
26
26
|
from .deployments import (
|
|
27
27
|
AsyncDeployment,
|
|
@@ -148,10 +148,20 @@ class DeployAppsResource:
|
|
|
148
148
|
input: Optional[DeployAppAutobuildInput] = None,
|
|
149
149
|
*,
|
|
150
150
|
request_options: Optional[RequestOptionsLike] = None,
|
|
151
|
+
chunk_size: Optional[int] = None,
|
|
152
|
+
on_upload_progress: Optional[UploadProgressCallback] = None,
|
|
153
|
+
timeout: Optional[float] = None,
|
|
154
|
+
max_network_retries: Optional[int] = None,
|
|
151
155
|
**kwargs: Unpack[DeployAppAutobuildInput],
|
|
152
156
|
) -> Deployment:
|
|
153
157
|
return self._deployments.create(
|
|
154
|
-
|
|
158
|
+
input,
|
|
159
|
+
request_options=request_options,
|
|
160
|
+
chunk_size=chunk_size,
|
|
161
|
+
on_upload_progress=on_upload_progress,
|
|
162
|
+
timeout=timeout,
|
|
163
|
+
max_network_retries=max_network_retries,
|
|
164
|
+
**kwargs,
|
|
155
165
|
)
|
|
156
166
|
|
|
157
167
|
del_ = delete
|
|
@@ -273,10 +283,20 @@ class AsyncDeployAppsResource:
|
|
|
273
283
|
input: Optional[DeployAppAutobuildInput] = None,
|
|
274
284
|
*,
|
|
275
285
|
request_options: Optional[RequestOptionsLike] = None,
|
|
286
|
+
chunk_size: Optional[int] = None,
|
|
287
|
+
on_upload_progress: Optional[UploadProgressCallback] = None,
|
|
288
|
+
timeout: Optional[float] = None,
|
|
289
|
+
max_network_retries: Optional[int] = None,
|
|
276
290
|
**kwargs: Unpack[DeployAppAutobuildInput],
|
|
277
291
|
) -> AsyncDeployment:
|
|
278
292
|
return await self._deployments.create(
|
|
279
|
-
|
|
293
|
+
input,
|
|
294
|
+
request_options=request_options,
|
|
295
|
+
chunk_size=chunk_size,
|
|
296
|
+
on_upload_progress=on_upload_progress,
|
|
297
|
+
timeout=timeout,
|
|
298
|
+
max_network_retries=max_network_retries,
|
|
299
|
+
**kwargs,
|
|
280
300
|
)
|
|
281
301
|
|
|
282
302
|
del_ = delete
|
|
@@ -3,24 +3,47 @@ from __future__ import annotations
|
|
|
3
3
|
import asyncio
|
|
4
4
|
import threading
|
|
5
5
|
import warnings
|
|
6
|
-
from typing import Any, Callable, Mapping, Optional
|
|
6
|
+
from typing import Any, Callable, Mapping, Optional, cast
|
|
7
7
|
|
|
8
8
|
from typing_extensions import Unpack
|
|
9
9
|
|
|
10
|
-
from .._errors import StackMachineAPIError
|
|
10
|
+
from .._errors import StackMachineAPIError, StackMachineValidationError
|
|
11
11
|
from .._graphql import operations as gql
|
|
12
12
|
from .._models import DeployAppVersion, DeploymentProgress
|
|
13
13
|
from .._types import (
|
|
14
|
+
CreateZipFiles,
|
|
14
15
|
DeployAppAutobuildInput,
|
|
15
16
|
DeploymentProgressCallback,
|
|
16
17
|
RequestOptionsLike,
|
|
18
|
+
UploadProgressCallback,
|
|
17
19
|
)
|
|
20
|
+
from .._uploads import create_zip
|
|
18
21
|
from .._utils import camelize, merge_input
|
|
19
22
|
from ._shared import required_payload, resource_missing_error
|
|
20
23
|
|
|
21
24
|
FAILED_STATUSES = {"CANCELLED", "FAILED", "INTERNAL_ERROR", "TIMEOUT"}
|
|
22
25
|
|
|
23
26
|
|
|
27
|
+
def _merge_deployment_create_input(
|
|
28
|
+
input: Optional[DeployAppAutobuildInput],
|
|
29
|
+
kwargs: DeployAppAutobuildInput,
|
|
30
|
+
) -> tuple[dict[str, object], Optional[CreateZipFiles]]:
|
|
31
|
+
deployment_input = merge_input(input, **kwargs)
|
|
32
|
+
files = deployment_input.pop("files", None)
|
|
33
|
+
has_upload_url = (
|
|
34
|
+
deployment_input.get("upload_url") is not None
|
|
35
|
+
or deployment_input.get("uploadUrl") is not None
|
|
36
|
+
)
|
|
37
|
+
if files is not None and has_upload_url:
|
|
38
|
+
raise StackMachineValidationError(
|
|
39
|
+
"`files` cannot be passed together with `upload_url`; "
|
|
40
|
+
"pass one deployment source.",
|
|
41
|
+
code="invalid_deployment_source",
|
|
42
|
+
param="files",
|
|
43
|
+
)
|
|
44
|
+
return deployment_input, cast(Optional[CreateZipFiles], files)
|
|
45
|
+
|
|
46
|
+
|
|
24
47
|
class Deployment:
|
|
25
48
|
def __init__(
|
|
26
49
|
self,
|
|
@@ -275,11 +298,27 @@ class DeploymentsResource:
|
|
|
275
298
|
input: Optional[DeployAppAutobuildInput] = None,
|
|
276
299
|
*,
|
|
277
300
|
request_options: Optional[RequestOptionsLike] = None,
|
|
301
|
+
chunk_size: Optional[int] = None,
|
|
302
|
+
on_upload_progress: Optional[UploadProgressCallback] = None,
|
|
303
|
+
timeout: Optional[float] = None,
|
|
304
|
+
max_network_retries: Optional[int] = None,
|
|
278
305
|
**kwargs: Unpack[DeployAppAutobuildInput],
|
|
279
306
|
) -> Deployment:
|
|
307
|
+
deployment_input, files = _merge_deployment_create_input(input, kwargs)
|
|
308
|
+
if files is not None:
|
|
309
|
+
upload_url = self._client.files.upload(
|
|
310
|
+
create_zip(files),
|
|
311
|
+
chunk_size=chunk_size,
|
|
312
|
+
on_progress=on_upload_progress,
|
|
313
|
+
timeout=timeout,
|
|
314
|
+
max_network_retries=max_network_retries,
|
|
315
|
+
request_options=request_options,
|
|
316
|
+
)
|
|
317
|
+
deployment_input["upload_url"] = upload_url
|
|
318
|
+
|
|
280
319
|
response = self._client._mutation(
|
|
281
320
|
gql.AUTOBUILD_MUTATION,
|
|
282
|
-
{"input": camelize(
|
|
321
|
+
{"input": camelize(deployment_input)},
|
|
283
322
|
request_options=request_options,
|
|
284
323
|
)
|
|
285
324
|
payload = required_payload(
|
|
@@ -358,11 +397,27 @@ class AsyncDeploymentsResource:
|
|
|
358
397
|
input: Optional[DeployAppAutobuildInput] = None,
|
|
359
398
|
*,
|
|
360
399
|
request_options: Optional[RequestOptionsLike] = None,
|
|
400
|
+
chunk_size: Optional[int] = None,
|
|
401
|
+
on_upload_progress: Optional[UploadProgressCallback] = None,
|
|
402
|
+
timeout: Optional[float] = None,
|
|
403
|
+
max_network_retries: Optional[int] = None,
|
|
361
404
|
**kwargs: Unpack[DeployAppAutobuildInput],
|
|
362
405
|
) -> AsyncDeployment:
|
|
406
|
+
deployment_input, files = _merge_deployment_create_input(input, kwargs)
|
|
407
|
+
if files is not None:
|
|
408
|
+
upload_url = await self._client.files.upload(
|
|
409
|
+
create_zip(files),
|
|
410
|
+
chunk_size=chunk_size,
|
|
411
|
+
on_progress=on_upload_progress,
|
|
412
|
+
timeout=timeout,
|
|
413
|
+
max_network_retries=max_network_retries,
|
|
414
|
+
request_options=request_options,
|
|
415
|
+
)
|
|
416
|
+
deployment_input["upload_url"] = upload_url
|
|
417
|
+
|
|
363
418
|
response = await self._client._mutation(
|
|
364
419
|
gql.AUTOBUILD_MUTATION,
|
|
365
|
-
{"input": camelize(
|
|
420
|
+
{"input": camelize(deployment_input)},
|
|
366
421
|
request_options=request_options,
|
|
367
422
|
)
|
|
368
423
|
payload = required_payload(
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: stackmachine
|
|
3
|
-
Version: 0.3.
|
|
3
|
+
Version: 0.3.3
|
|
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
|
|
@@ -99,8 +99,12 @@ async for app in apps:
|
|
|
99
99
|
|
|
100
100
|
```python
|
|
101
101
|
deployment = stackmachine.deployments.create(
|
|
102
|
-
|
|
103
|
-
|
|
102
|
+
app_name="hello-stackmachine",
|
|
103
|
+
owner="stackmachine",
|
|
104
|
+
files={
|
|
105
|
+
"index.html": "<html><body><h1>Hello StackMachine</h1></body></html>",
|
|
106
|
+
},
|
|
107
|
+
on_upload_progress=lambda progress: print("Uploading", progress.percent * 100),
|
|
104
108
|
)
|
|
105
109
|
|
|
106
110
|
version = deployment.wait()
|
|
@@ -108,13 +112,18 @@ version = deployment.wait()
|
|
|
108
112
|
|
|
109
113
|
```python
|
|
110
114
|
deployment = stackmachine.apps.autobuild(
|
|
111
|
-
|
|
112
|
-
|
|
115
|
+
app_name="hello-stackmachine",
|
|
116
|
+
owner="stackmachine",
|
|
117
|
+
files={
|
|
118
|
+
"index.html": "<html><body><h1>Hello StackMachine</h1></body></html>",
|
|
119
|
+
},
|
|
113
120
|
)
|
|
114
121
|
```
|
|
115
122
|
|
|
116
123
|
## Files
|
|
117
124
|
|
|
125
|
+
Use this path only for manual package uploads:
|
|
126
|
+
|
|
118
127
|
```python
|
|
119
128
|
from stackmachine import create_zip
|
|
120
129
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
stackmachine/__init__.py,sha256=
|
|
1
|
+
stackmachine/__init__.py,sha256=TRIOYAYdQGK0-CAdy6xBf3QTOrNqXsjn8UbPFioYKw4,3796
|
|
2
2
|
stackmachine/_async_client.py,sha256=nZ5Rxbw6Yk8-3cv124p3tKcf_xyRiuYNcWnCiviIaDs,6570
|
|
3
3
|
stackmachine/_client.py,sha256=e3pdGdrCqgSJ4iNxmbyQI74rs41HrbaWI18s9sVMTQg,6396
|
|
4
4
|
stackmachine/_config.py,sha256=vZUvZEIKRkCmAqq8dJ5B6r9cWF0rjHQ21AGS4hsaMKc,912
|
|
@@ -6,7 +6,7 @@ stackmachine/_errors.py,sha256=yVJ4U1wUK4kPDXs_PxSlg9VdN9cpmUluToqvKR9r5kc,2708
|
|
|
6
6
|
stackmachine/_models.py,sha256=sJBXZyN7o16iIsvbeVaSyE5XZmRsnV8zRnmgAmxKMa8,6211
|
|
7
7
|
stackmachine/_pagination.py,sha256=OLeqVZ5ClGjgtDVww3ghN0Va-ExwkZ_SI6FtqQH__ug,11730
|
|
8
8
|
stackmachine/_transport.py,sha256=Jah57TIssaq-zQxyIw8xuV-eROPkg-jE-_9qgzHUbi0,21048
|
|
9
|
-
stackmachine/_types.py,sha256=
|
|
9
|
+
stackmachine/_types.py,sha256=ZtfXaGPLlG6c4tTgHvfxZLs23K2wzbX5BOkspZUVUiE,6759
|
|
10
10
|
stackmachine/_uploads.py,sha256=fl0RIh3W0d0vcTOSB1zbg6fTk9lxxyXjLKEyUryAgao,12772
|
|
11
11
|
stackmachine/_utils.py,sha256=sdx1vsNQrGeoHubg7S1aE0v2UYa_95OyQ13iF9pAgmU,2329
|
|
12
12
|
stackmachine/py.typed,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
|
|
@@ -14,12 +14,12 @@ stackmachine/_graphql/__init__.py,sha256=pjh20cuYTQMGJn6lSQY-hYXJAXqYr8Y8z1Vc5si
|
|
|
14
14
|
stackmachine/_graphql/operations.py,sha256=HKBuWK_Rsz_qCKSfWyzclKq7pA1R6k9R-RdKP2mnrPw,9228
|
|
15
15
|
stackmachine/resources/__init__.py,sha256=tfjWfWceGbahDMmD_xt_xkapqSThD7tyP7_5cnKF3xQ,364
|
|
16
16
|
stackmachine/resources/_shared.py,sha256=u1lSxX3WYGd6JDOrxr9PBOHbaqBQ48kO5xIbJBsErIk,1227
|
|
17
|
-
stackmachine/resources/apps.py,sha256=
|
|
18
|
-
stackmachine/resources/deployments.py,sha256=
|
|
17
|
+
stackmachine/resources/apps.py,sha256=dB_1pjzqXMKNDxT2ewziumMJULMtKuBVMQccaU-0jCA,10508
|
|
18
|
+
stackmachine/resources/deployments.py,sha256=IcFiIbYiD_4cwvvE9sRY4JSnmANVShj3GaBCgv0o67U,16433
|
|
19
19
|
stackmachine/resources/domains.py,sha256=oBbtp2X6ya5BQvhFtXFz7aKUGZcqTO4Ky-kOo-GhX_8,10801
|
|
20
20
|
stackmachine/resources/files.py,sha256=j4fFnFuz2-zM8MRvmRxv7jC47Q_NiTQaYCpR0Kb4Gpk,2701
|
|
21
21
|
stackmachine/resources/ssh.py,sha256=tbqVWyAqeNf_eCjftF1b2Q1ED-ocpuRC2rSHyuzdRGM,22359
|
|
22
22
|
stackmachine/resources/versions.py,sha256=VYMUS2KdoEh4POHm5IFF0Sy1xNI8jrwpHhtoKqgUqfk,7426
|
|
23
|
-
stackmachine-0.3.
|
|
24
|
-
stackmachine-0.3.
|
|
25
|
-
stackmachine-0.3.
|
|
23
|
+
stackmachine-0.3.3.dist-info/METADATA,sha256=pXm3txC1GNNnrPsbAvIWRvPdsCi_NCh1A_Iv4ySz5i0,4627
|
|
24
|
+
stackmachine-0.3.3.dist-info/WHEEL,sha256=QccIxa26bgl1E6uMy58deGWi-0aeIkkangHcxk2kWfw,87
|
|
25
|
+
stackmachine-0.3.3.dist-info/RECORD,,
|
|
File without changes
|