peak-sdk 1.0.0__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.
Files changed (51) hide show
  1. peak/__init__.py +36 -0
  2. peak/_version.py +21 -0
  3. peak/auth.py +22 -0
  4. peak/base_client.py +52 -0
  5. peak/cli/__init_.py +20 -0
  6. peak/cli/args.py +84 -0
  7. peak/cli/cli.py +56 -0
  8. peak/cli/helpers.py +187 -0
  9. peak/cli/press/__init__.py +21 -0
  10. peak/cli/press/apps/__init__.py +40 -0
  11. peak/cli/press/apps/deployments.py +238 -0
  12. peak/cli/press/apps/specs.py +387 -0
  13. peak/cli/press/blocks/__init__.py +40 -0
  14. peak/cli/press/blocks/deployments.py +240 -0
  15. peak/cli/press/blocks/specs.py +492 -0
  16. peak/cli/press/deployments.py +78 -0
  17. peak/cli/press/specs.py +131 -0
  18. peak/cli/resources/__init__.py +21 -0
  19. peak/cli/resources/artifacts.py +310 -0
  20. peak/cli/resources/images.py +886 -0
  21. peak/cli/resources/webapps.py +356 -0
  22. peak/cli/resources/workflows.py +703 -0
  23. peak/cli/ruff.toml +11 -0
  24. peak/cli/version.py +49 -0
  25. peak/compression.py +162 -0
  26. peak/config.py +24 -0
  27. peak/constants.py +105 -0
  28. peak/exceptions.py +217 -0
  29. peak/handler.py +358 -0
  30. peak/helpers.py +184 -0
  31. peak/logger.py +48 -0
  32. peak/press/__init__.py +28 -0
  33. peak/press/apps.py +669 -0
  34. peak/press/blocks.py +707 -0
  35. peak/press/deployments.py +145 -0
  36. peak/press/specs.py +260 -0
  37. peak/py.typed +0 -0
  38. peak/resources/__init__.py +28 -0
  39. peak/resources/artifacts.py +343 -0
  40. peak/resources/images.py +675 -0
  41. peak/resources/webapps.py +278 -0
  42. peak/resources/workflows.py +625 -0
  43. peak/session.py +259 -0
  44. peak/telemetry.py +201 -0
  45. peak/template.py +231 -0
  46. peak/validators.py +48 -0
  47. peak_sdk-1.0.0.dist-info/LICENSE +201 -0
  48. peak_sdk-1.0.0.dist-info/METADATA +199 -0
  49. peak_sdk-1.0.0.dist-info/RECORD +51 -0
  50. peak_sdk-1.0.0.dist-info/WHEEL +4 -0
  51. peak_sdk-1.0.0.dist-info/entry_points.txt +3 -0
@@ -0,0 +1,240 @@
1
+ #
2
+ # # Copyright © 2023 Peak AI Limited. or its affiliates. All Rights Reserved.
3
+ # #
4
+ # # Licensed under the Apache License, Version 2.0 (the "License"). You
5
+ # # may not use this file except in compliance with the License. A copy of
6
+ # # the License is located at:
7
+ # #
8
+ # # https://github.com/PeakBI/peak-sdk/blob/main/LICENSE
9
+ # #
10
+ # # or in the "license" file accompanying this file. This file is
11
+ # # distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
12
+ # # ANY KIND, either express or implied. See the License for the specific
13
+ # # language governing permissions and limitations under the License.
14
+ # #
15
+ # # This file is part of the peak-sdk.
16
+ # # see (https://github.com/PeakBI/peak-sdk)
17
+ # #
18
+ # # You should have received a copy of the APACHE LICENSE, VERSION 2.0
19
+ # # along with this program. If not, see <https://apache.org/licenses/LICENSE-2.0>
20
+ #
21
+ """Peak blocks deployments commands."""
22
+ from typing import Dict, List, Optional
23
+
24
+ import typer
25
+ from peak.cli import args, helpers
26
+ from peak.press.blocks import Block
27
+ from rich.console import Console
28
+
29
+ app = typer.Typer()
30
+ console = Console()
31
+
32
+ _DEPLOYMENT_ID = typer.Argument(..., help="ID of the Block deployment to be used in this operation")
33
+
34
+
35
+ @app.command(short_help="Create a Block deployment.")
36
+ def create(
37
+ ctx: typer.Context,
38
+ file: str = args.TEMPLATE_PATH,
39
+ params_file: Optional[str] = args.TEMPLATE_PARAMS_FILE,
40
+ params: Optional[List[str]] = args.TEMPLATE_PARAMS,
41
+ ) -> None:
42
+ """***Create*** a Block deployment This creates the resource described in the Block Spec.
43
+
44
+ \b
45
+ 🧩 ***Input file schema (yaml):***<br/>
46
+ ```yaml
47
+ body (map):
48
+ metadata (map):
49
+ name (string | required: false): Name of the deployment. Must be unique within the tenant.
50
+ title (string | required: false): Title of the deployment.
51
+ summary (string | required: false): Summary of the deployment.
52
+ description (string | required: false): Description of the deployment.
53
+ descriptionContentType (string | required: false): Content type of the description. Should be one of "text/plain" or "text/markdown".
54
+ imageUrl (string | required: false): URL of the image to be associated with the block deployment.
55
+ tags (list(map) | required: false):
56
+ - name (string): Name of the tag.
57
+ revision (map | required: false):
58
+ notes (string | required: false): Notes for the deployment revision.
59
+ spec (map):
60
+ id (string): ID of the block spec to be deployed.
61
+ release (map | required: false):
62
+ version (string): A valid semantic release version of the block spec.
63
+ ```
64
+
65
+ \b
66
+ 📝 ***Example usage:***
67
+ ```bash
68
+ peak blocks deployments create /path/to/body.yaml -v /path/to/params.yaml
69
+ ```
70
+
71
+ \b
72
+ 🆗 ***Response:***
73
+ ```json
74
+ {
75
+ "id": "632a4e7c-ab86-4ecb-8f34-99b5da531ceb"
76
+ }
77
+ ```
78
+
79
+ 🔗 [**API Documentation**](https://press.peak.ai/api-docs/index.htm#/Block%20Deployments/post_v1_blocks_deployments)
80
+ """
81
+ body = helpers.template_handler(file, params_file, params)
82
+ blocks_client: Block = ctx.obj["client"]
83
+ body = helpers.remove_unknown_args(body, blocks_client.create_deployment)
84
+ response: Dict[str, str] = blocks_client.create_deployment(**body)
85
+
86
+ console.print(response)
87
+
88
+
89
+ @app.command("list", short_help="List Block deployments.")
90
+ def list_block_deployments(
91
+ ctx: typer.Context,
92
+ page_size: Optional[int] = args.PAGE_SIZE,
93
+ page_number: Optional[int] = args.PAGE_NUMBER,
94
+ status: Optional[List[str]] = args.STATUS_FILTER,
95
+ name: Optional[str] = args.NAME_FILTER,
96
+ title: Optional[str] = args.TITLE_FILTER,
97
+ sort: Optional[List[str]] = args.SORT_KEYS,
98
+ ) -> None:
99
+ """***List*** Block deployments that have been created for the given tenant.
100
+
101
+ \b
102
+ 📝 ***Example usage:***<br/>
103
+ ```bash
104
+ peak blocks deployments list --status=deployed,failed --page-size 10 --page-number 1
105
+ ```
106
+
107
+ \b
108
+ 🆗 ***Response:***
109
+ ```
110
+ {
111
+ "deploymentsCount": 1,
112
+ "deployments": [...],
113
+ "pageCount": 1,
114
+ "pageNumber": 1,
115
+ "pageSize": 25
116
+ }
117
+ ```
118
+
119
+ 🔗 [**API Documentation**](https://press.peak.ai/api-docs/index.htm#/Block%20Deployments/get_v1_blocks_deployments)
120
+ """
121
+ blocks_client: Block = ctx.obj["client"]
122
+ response = blocks_client.list_deployments(
123
+ status=status,
124
+ name=name,
125
+ sort=sort,
126
+ title=title,
127
+ page_size=page_size,
128
+ page_number=page_number,
129
+ return_iterator=False,
130
+ )
131
+ console.print(response)
132
+
133
+
134
+ @app.command(short_help="Describe the Block deployment.")
135
+ def describe(
136
+ ctx: typer.Context,
137
+ deployment_id: str = _DEPLOYMENT_ID,
138
+ ) -> None:
139
+ """***Describe*** the Block deployment with details of its latest revision.
140
+
141
+ \b
142
+ 📝 ***Example usage:***<br/>
143
+ ```bash
144
+ peak blocks deployments describe "632a4e7c-ab86-4ecb-8f34-99b5da531ceb"
145
+ ```
146
+
147
+ \b
148
+ 🆗 ***Response:***
149
+ ```
150
+ {
151
+ "id": "632a4e7c-ab86-4ecb-8f34-99b5da531ceb",
152
+ "kind": "app",
153
+ "latestRevision": {...},
154
+ "metadata": {...},
155
+ "spec": {...}
156
+ }
157
+ ```
158
+
159
+ 🔗 [**API Documentation**](https://press.peak.ai/api-docs/index.htm#/Block%20Deployments/get_v1_blocks_deployments__deploymentId_)
160
+ """
161
+ blocks_client: Block = ctx.obj["client"]
162
+ response = blocks_client.describe_deployment(deployment_id)
163
+ console.print(response)
164
+
165
+
166
+ @app.command(short_help="Update the Block deployment metadata.")
167
+ def update_metadata(
168
+ ctx: typer.Context,
169
+ deployment_id: str = _DEPLOYMENT_ID,
170
+ file: str = args.TEMPLATE_PATH,
171
+ params_file: Optional[str] = args.TEMPLATE_PARAMS_FILE,
172
+ params: Optional[List[str]] = args.TEMPLATE_PARAMS,
173
+ ) -> None:
174
+ """***Update*** the Block deployment metadata.
175
+
176
+ \b
177
+ 🧩 ***Input file schema (yaml):***<br/>
178
+ ```yaml
179
+ body (map):
180
+ name (string | required: false): Name of the deployment. Must be unique within the tenant.
181
+ title (string | required: false): Title of the deployment.
182
+ summary (string | required: false): Summary of the deployment.
183
+ description (string | required: false): Description of the deployment.
184
+ descriptionContentType (string | required: false): Content type of the description. Should be one of "text/plain" or "text/markdown".
185
+ imageUrl (string | required: false): URL of the image to be associated with the block deployment.
186
+ tags (list(map) | required: false):
187
+ - name (string): Name of the tag.
188
+ ```
189
+
190
+ \b
191
+ 📝 ***Example usage:***
192
+ ```bash
193
+ peak blocks deployments update-metadata "632a4e7c-ab86-4ecb-8f34-99b5da531ceb" /path/to/body.yaml -v /path/to/params.yaml
194
+ ```
195
+
196
+ \b
197
+ 🆗 ***Response:***
198
+ ```
199
+ {
200
+ "id": "632a4e7c-ab86-4ecb-8f34-99b5da531ceb"
201
+ "kind": "workflow",
202
+ "latestRevision": {...},
203
+ "metadata": {...},
204
+ "spec": {...}
205
+ }
206
+ ```
207
+
208
+ 🔗 [**API Documentation**](https://press.peak.ai/api-docs/index.htm#/Block%20Deployments/patch_v1_blocks_deployments__deploymentId_)
209
+ """
210
+ body = helpers.template_handler(file, params_file, params)
211
+ blocks_client: Block = ctx.obj["client"]
212
+ body = helpers.remove_unknown_args(body, blocks_client.update_deployment_metadata)
213
+ response = blocks_client.update_deployment_metadata(deployment_id, **body)
214
+ console.print(response)
215
+
216
+
217
+ @app.command(short_help="Delete a Block deployment.")
218
+ def delete(
219
+ ctx: typer.Context,
220
+ deployment_id: str = _DEPLOYMENT_ID,
221
+ ) -> None:
222
+ """***Delete*** a Block deployment. This will delete the resource that was created as part of the deployment.
223
+
224
+ \b
225
+ 📝 ***Example usage:***<br/>
226
+ ```bash
227
+ peak blocks deployments delete "632a4e7c-ab86-4ecb-8f34-99b5da531ceb"
228
+ ```
229
+
230
+ \b
231
+ 🆗 ***Response:***
232
+ ```json
233
+ {}
234
+ ```
235
+
236
+ 🔗 [**API Documentation**](https://press.peak.ai/api-docs/index.htm#/Block%20Deployments/delete_v1_blocks_deployments__deploymentId_)
237
+ """
238
+ blocks_client: Block = ctx.obj["client"]
239
+ response = blocks_client.delete_deployment(deployment_id)
240
+ console.print(response)