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,238 @@
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 apps deployments commands."""
22
+ from typing import Dict, List, Optional
23
+
24
+ import typer
25
+ from peak.cli import args, helpers
26
+ from peak.press.apps import App
27
+ from rich.console import Console
28
+
29
+ app = typer.Typer()
30
+ console = Console()
31
+
32
+ _DEPLOYMENT_ID = typer.Argument(..., help="ID of the App deployment to be used in this operation.")
33
+
34
+
35
+ @app.command(short_help="Create an App 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*** an App deployment. This creates all the resources (Example - Workflow, Webapps, etc) described in the App Spec.
43
+
44
+ \b
45
+ 🧩 ***Input file schema (yaml):***
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 app 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 app spec to be deployed.
61
+ release (map | required: false):
62
+ version (string): A valid semantic release version of the app spec.
63
+ ```
64
+
65
+ \b
66
+ 📝 ***Example usage:***
67
+ ```bash
68
+ peak apps 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#/App%20Deployments/post_v1_apps_deployments)
80
+ """
81
+ body = helpers.template_handler(file, params_file, params)
82
+ app_client: App = ctx.obj["client"]
83
+ body = helpers.remove_unknown_args(body, app_client.create_deployment)
84
+ response: Dict[str, str] = app_client.create_deployment(**body)
85
+
86
+ console.print(response)
87
+
88
+
89
+ @app.command("list", short_help="List App deployments.")
90
+ def list_app_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
+ sort: Optional[List[str]] = args.SORT_KEYS,
97
+ ) -> None:
98
+ """***List*** all the App deployments that have been created for the tenant.
99
+
100
+ \b
101
+ 📝 ***Example usage:***<br/>
102
+ ```bash
103
+ peak apps deployments list --sort createdBy:asc,name --page-size 10 --page-number 1
104
+ ```
105
+
106
+ \b
107
+ 🆗 ***Response:***
108
+ ```
109
+ {
110
+ "deploymentCount": 1,
111
+ "deployments": [...],
112
+ "pageCount": 1,
113
+ "pageNumber": 1,
114
+ "pageSize": 10
115
+ }
116
+ ```
117
+
118
+ 🔗 [**API Documentation**](https://press.peak.ai/api-docs/index.htm#/App%20Deployments/get_v1_apps_deployments)
119
+ """
120
+ app_client = ctx.obj["client"]
121
+ response = app_client.list_deployments(
122
+ status=status,
123
+ name=name,
124
+ sort=sort,
125
+ page_size=page_size,
126
+ page_number=page_number,
127
+ return_iterator=False,
128
+ )
129
+ console.print(response)
130
+
131
+
132
+ @app.command(short_help="Describe an App deployment.")
133
+ def describe(
134
+ ctx: typer.Context,
135
+ deployment_id: str = _DEPLOYMENT_ID,
136
+ ) -> None:
137
+ """***Describe*** an App deployment with details of its latest revision.
138
+
139
+ \b
140
+ 📝 ***Example usage:***<br/>
141
+ ```bash
142
+ peak apps deployments describe "632a4e7c-ab86-4ecb-8f34-99b5da531ceb"
143
+ ```
144
+
145
+ \b
146
+ 🆗 ***Response:***
147
+ ```
148
+ {
149
+ "id": "632a4e7c-ab86-4ecb-8f34-99b5da531ceb",
150
+ "kind": "app",
151
+ "latestRevision": {...},
152
+ "metadata": {...},
153
+ "spec": {...}
154
+ }
155
+ ```
156
+
157
+ 🔗 [**API Documentation**](https://press.peak.ai/api-docs/index.htm#/App%20Deployments/get_v1_apps_deployments__deploymentId_)
158
+ """
159
+ app_client: App = ctx.obj["client"]
160
+ response = app_client.describe_deployment(deployment_id)
161
+ console.print(response)
162
+
163
+
164
+ @app.command(short_help="Delete an App deployment.")
165
+ def delete(
166
+ ctx: typer.Context,
167
+ deployment_id: str = _DEPLOYMENT_ID,
168
+ ) -> None:
169
+ """***Delete*** an App deployment. This deletes all the resources that were created as a part of the deployment.
170
+
171
+ \b
172
+ 📝 ***Example usage:***<br/>
173
+ ```bash
174
+ peak apps deployments delete "632a4e7c-ab86-4ecb-8f34-99b5da531ceb"
175
+ ```
176
+
177
+ \b
178
+ 🆗 ***Response:***
179
+ ```json
180
+ {}
181
+ ```
182
+
183
+ 🔗 [**API Documentation**](https://press.peak.ai/api-docs/index.htm#/App%20Deployments/delete_v1_apps_deployments__deploymentId_)
184
+ """
185
+ app_client = ctx.obj["client"]
186
+ response = app_client.delete_deployment(deployment_id)
187
+ console.print(response)
188
+
189
+
190
+ @app.command(short_help="Update the App deployment metadata.")
191
+ def update_metadata(
192
+ ctx: typer.Context,
193
+ deployment_id: str = _DEPLOYMENT_ID,
194
+ file: str = args.TEMPLATE_PATH,
195
+ params_file: Optional[str] = args.TEMPLATE_PARAMS_FILE,
196
+ params: Optional[List[str]] = args.TEMPLATE_PARAMS,
197
+ ) -> None:
198
+ """***Update*** the App deployment metadata.
199
+
200
+ \b
201
+ 🧩 ***Input file schema (yaml):***<br/>
202
+ ```yaml
203
+ body (map):
204
+ name (string | required: false): Name of the deployment. Must be unique within the tenant.
205
+ title (string | required: false): Title of the deployment.
206
+ summary (string | required: false): Summary of the deployment.
207
+ description (string | required: false): Description of the deployment.
208
+ descriptionContentType (string | required: false): Content type of the description. Should be one of "text/plain" or "text/markdown".
209
+ imageUrl (string | required: false): URL of the image to be associated with the app deployment.
210
+ tags (list(map) | required: false):
211
+ - name (string): Name of the tag.
212
+ ```
213
+
214
+ \b
215
+ 📝 ***Example usage:***
216
+ ```bash
217
+ peak apps deployments update-metadata "632a4e7c-ab86-4ecb-8f34-99b5da531ceb" /path/to/body.yaml -v /path/to/params.yaml
218
+ ```
219
+
220
+ \b
221
+ 🆗 ***Response:***
222
+ ```
223
+ {
224
+ "id": "632a4e7c-ab86-4ecb-8f34-99b5da531ceb"
225
+ "kind": "app",
226
+ "latestRevision": {...},
227
+ "metadata": {...},
228
+ "spec": {...}
229
+ }
230
+ ```
231
+
232
+ 🔗 [**API Documentation**](https://press.peak.ai/api-docs/index.htm#/App%20Deployments/patch_v1_apps_deployments__deploymentId_)
233
+ """
234
+ body = helpers.template_handler(file, params_file, params)
235
+ app_client = ctx.obj["client"]
236
+ body = helpers.remove_unknown_args(body, app_client.update_deployment_metadata)
237
+ response = app_client.update_deployment_metadata(deployment_id, **body)
238
+ console.print(response)
@@ -0,0 +1,387 @@
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 apps specs commands."""
22
+ from typing import Dict, List, Optional
23
+
24
+ import typer
25
+ from peak.cli import args, helpers
26
+ from peak.press.apps import App
27
+ from rich.console import Console
28
+
29
+ app = typer.Typer()
30
+ console = Console()
31
+
32
+ _SPEC_ID = typer.Argument(..., help="ID of the App spec to be used in this operation.")
33
+
34
+
35
+ @app.command(short_help="Create an App spec.")
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*** an App spec. A Spec is just a blueprint for an App and defines all the resources that need to be created for the App. This creates a version of the spec also known as ***Release***.
43
+
44
+ \b
45
+ 🧩 ***Input file schema (yaml):***<br/>
46
+ ```yaml
47
+ featured (bool | required: false): Boolean specifying whether to feature this spec.
48
+ scope (str | required: false): Specify what tenants can discover and deploy this spec.
49
+ tenants (list(str) | required: false): Given a shared scope, specify what other tenants can discover and deploy this spec.
50
+ body (map):
51
+ version (int): Version of the spec.
52
+ kind (string): Specifies the type of spec. Should be "app" in case of app spec.
53
+ metadata (map):
54
+ name (string): Name of the spec. Must be unique within the tenant.
55
+ title (string | required: false): Title of the spec.
56
+ summary (string): Summary of the spec.
57
+ description (string | required: false): Description of the spec.
58
+ descriptionContentType (string | required: false): Content type of the description. Should be one of "text/plain" or "text/markdown".
59
+ imageUrl (string | required: false): URL of the image to be associated with the app spec.
60
+ tags (list(map) | required: false):
61
+ - name (string): Name of the tag.
62
+ release (map):
63
+ version (string): A valid semantic release version of the spec.
64
+ notes (string | required: false): Notes for the release version.
65
+ config (list(map)):
66
+ - id (string): ID of the block spec.
67
+ release (map):
68
+ version (string): A valid semantic release version of the block spec.
69
+ ```
70
+
71
+ \b
72
+ 📝 ***Example usage:***
73
+ ```bash
74
+ peak apps specs create /path/to/body.yaml -v /path/to/params.yaml
75
+ ```
76
+
77
+ \b
78
+ 🆗 ***Response:***
79
+ ```json
80
+ {
81
+ "id": "632a4e7c-ab86-4ecb-8f34-99b5da531ceb"
82
+ }
83
+ ```
84
+
85
+ 🔗 [**API Documentation**](https://press.peak.ai/api-docs/index.htm#/App%20Specs/post_v1_apps_specs_)
86
+ """
87
+ body = helpers.template_handler(file, params_file, params)
88
+ app_client: App = ctx.obj["client"]
89
+ body = helpers.remove_unknown_args(body, app_client.create_spec)
90
+ response: Dict[str, str] = app_client.create_spec(**body)
91
+
92
+ console.print(response)
93
+
94
+
95
+ @app.command("list", short_help="List App specs.")
96
+ def list_app_specs(
97
+ ctx: typer.Context,
98
+ page_size: Optional[int] = args.PAGE_SIZE,
99
+ page_number: Optional[int] = args.PAGE_NUMBER,
100
+ status: Optional[List[str]] = args.STATUS_FILTER,
101
+ name: Optional[str] = args.NAME_FILTER,
102
+ title: Optional[str] = args.TITLE_FILTER,
103
+ sort: Optional[List[str]] = args.SORT_KEYS,
104
+ scope: Optional[List[str]] = args.SCOPES,
105
+ featured: Optional[bool] = args.FEATURED,
106
+ ) -> None:
107
+ """***List*** all App specs that have been created for the tenant along with the public-scoped ones.
108
+
109
+ \b
110
+ 📝 ***Example usage:***<br/>
111
+ ```bash
112
+ peak apps specs list --sort name:asc,title --page-size 10 --page-number 1
113
+ ```
114
+
115
+ \b
116
+ 🆗 ***Response:***
117
+ ```
118
+ {
119
+ "specCount": 1,
120
+ "specs": [...],
121
+ "pageCount": 1,
122
+ "pageNumber": 1,
123
+ "pageSize": 10
124
+ }
125
+ ```
126
+
127
+ 🔗 [**API Documentation**](https://press.peak.ai/api-docs/index.htm#/App%20Specs/get_v1_apps_specs_)
128
+ """
129
+ app_client: App = ctx.obj["client"]
130
+ response = app_client.list_specs(
131
+ status=status,
132
+ featured=featured,
133
+ name=name,
134
+ title=title,
135
+ sort=sort,
136
+ scope=scope,
137
+ page_size=page_size,
138
+ page_number=page_number,
139
+ return_iterator=False,
140
+ )
141
+ console.print(response)
142
+
143
+
144
+ @app.command(short_help="Describe an App spec.")
145
+ def describe(
146
+ ctx: typer.Context,
147
+ spec_id: str = _SPEC_ID,
148
+ ) -> None:
149
+ """***Describe*** an App spec with details of its latest release.
150
+
151
+ \b
152
+ 📝 ***Example usage:***<br/>
153
+ ```bash
154
+ peak apps specs describe "632a4e7c-ab86-4ecb-8f34-99b5da531ceb"
155
+ ```
156
+
157
+ \b
158
+ 🆗 ***Response:***
159
+ ```
160
+ {
161
+ "featured": true,
162
+ "id": "632a4e7c-ab86-4ecb-8f34-99b5da531ceb"
163
+ "kind": "app",
164
+ "latestRelease": {...},
165
+ "metadata": {...},
166
+ "scope": "private"
167
+ }
168
+ ```
169
+
170
+ 🔗 [**API Documentation**](https://press.peak.ai/api-docs/index.htm#/App%20Specs/get_v1_apps_specs__specId_)
171
+ """
172
+ app_client: App = ctx.obj["client"]
173
+ response = app_client.describe_spec(spec_id)
174
+ console.print(response)
175
+
176
+
177
+ @app.command(short_help="Update the App spec metadata.")
178
+ def update_metadata(
179
+ ctx: typer.Context,
180
+ spec_id: str = _SPEC_ID,
181
+ file: str = args.TEMPLATE_PATH,
182
+ params_file: Optional[str] = args.TEMPLATE_PARAMS_FILE,
183
+ params: Optional[List[str]] = args.TEMPLATE_PARAMS,
184
+ ) -> None:
185
+ """***Update*** the App spec metadata.
186
+
187
+ \b
188
+ 🧩 ***Input file schema (yaml):***<br/>
189
+ ```yaml
190
+ body (map):
191
+ featured (bool | required: false): Boolean specifying whether to feature this spec.
192
+ scope (str | required: false): Specify what tenants can discover and deploy this spec.
193
+ tenants (list(str) | required: false): Given a shared scope, specify what other tenants can discover and deploy this spec.
194
+ metadata (map):
195
+ name (string | required: false): Name of the spec. Must be unique within the tenant.
196
+ title (string | required: false): Title of the spec.
197
+ summary (string | required: false): Summary of the spec.
198
+ description (string | required: false): Description of the spec.
199
+ descriptionContentType (string | required: false): Content type of the description. Should be one of "text/plain" or "text/markdown".
200
+ imageUrl (string | required: false): URL of the image to be associated with the app spec.
201
+ status (string | required: false): Status of the app spec.
202
+ tags (list(map) | required: false):
203
+ - name (string): Name of the tag.
204
+ ```
205
+
206
+ \b
207
+ 📝 ***Example usage:***
208
+ ```bash
209
+ peak apps specs update-metadata "632a4e7c-ab86-4ecb-8f34-99b5da531ceb" /path/to/body.yaml -v /path/to/params.yaml
210
+ ```
211
+
212
+ \b
213
+ 🆗 ***Response:***
214
+ ```
215
+ {
216
+ "featured": false,
217
+ "id": "632a4e7c-ab86-4ecb-8f34-99b5da531ceb"
218
+ "kind": "app",
219
+ "latestRelease": {...},
220
+ "metadata": {...},
221
+ "scope": "private"
222
+ }
223
+ ```
224
+
225
+ 🔗 [**API Documentation**](https://press.peak.ai/api-docs/index.htm#/App%20Specs/patch_v1_apps_specs__specId_)
226
+ """
227
+ data = helpers.template_handler(file, params_file, params)
228
+ app_client: App = ctx.obj["client"]
229
+ data = helpers.remove_unknown_args(data, app_client.update_spec_metadata)
230
+ response: Dict[None, None] = app_client.update_spec_metadata(spec_id, **data)
231
+ console.print(response)
232
+
233
+
234
+ @app.command(short_help="Delete an App spec.")
235
+ def delete(
236
+ ctx: typer.Context,
237
+ spec_id: str = _SPEC_ID,
238
+ ) -> None:
239
+ """***Delete*** an App spec.
240
+
241
+ \b
242
+ 📝 ***Example usage:***<br/>
243
+ ```bash
244
+ peak apps specs delete "632a4e7c-ab86-4ecb-8f34-99b5da531ceb"
245
+ ```
246
+
247
+ \b
248
+ 🆗 ***Response:***
249
+ ```json
250
+ {}
251
+ ```
252
+
253
+ 🔗 [**API Documentation**](https://press.peak.ai/api-docs/index.htm#/App%20Specs/delete_v1_apps_specs__specId_)
254
+ """
255
+ app_client: App = ctx.obj["client"]
256
+ response = app_client.delete_spec(spec_id)
257
+ console.print(response)
258
+
259
+
260
+ @app.command(short_help="Create a new release of the App spec.")
261
+ def create_release(
262
+ ctx: typer.Context,
263
+ spec_id: str = _SPEC_ID,
264
+ file: str = args.TEMPLATE_PATH,
265
+ params_file: Optional[str] = args.TEMPLATE_PARAMS_FILE,
266
+ params: Optional[List[str]] = args.TEMPLATE_PARAMS,
267
+ ) -> None:
268
+ """***Create*** a new release of the App spec.
269
+
270
+ \b
271
+ 🧩 ***Input file schema (yaml):***<br/>
272
+ ```yaml
273
+ body (map):
274
+ release (map):
275
+ version (string): A valid semantic release version of the spec. Must be greater than previous release version.
276
+ notes (string | required: false): Notes for the release version.
277
+ config (list(map)):
278
+ - id (string): ID of the block spec.
279
+ release (map):
280
+ version (string): A valid semantic release version of the block spec.
281
+ ```
282
+
283
+ \b
284
+ 📝 ***Example usage:***
285
+ ```bash
286
+ peak apps specs create-release "632a4e7c-ab86-4ecb-8f34-99b5da531ceb" /path/to/body.yaml -v /path/to/params.yaml
287
+ ```
288
+
289
+ \b
290
+ 🆗 ***Response:***
291
+ ```json
292
+ {
293
+ "id": "632a4e7c-ab86-4ecb-8f34-99b5da531ceb",
294
+ "release": {
295
+ "version": "2.0.0"
296
+ }
297
+ }
298
+ ```
299
+
300
+ 🔗 [**API Documentation**](https://press.peak.ai/api-docs/index.htm#/App%20Specs/post_v1_apps_specs__specId__releases)
301
+ """
302
+ body = helpers.template_handler(file, params_file, params)
303
+ app_client: App = ctx.obj["client"]
304
+ body = helpers.remove_unknown_args(body, app_client.create_spec_release)
305
+ response: Dict[str, str] = app_client.create_spec_release(spec_id, **body)
306
+ console.print(response)
307
+
308
+
309
+ @app.command(short_help="Describe an App spec release.")
310
+ def describe_release(
311
+ ctx: typer.Context,
312
+ spec_id: str = args.SPEC_ID,
313
+ version: str = args.RELEASE_VERSION,
314
+ ) -> None:
315
+ """***Describe*** an App spec release.
316
+
317
+ \b
318
+ 📝 ***Example usage:***<br/>
319
+ ```bash
320
+ peak apps specs describe-release --spec-id "632a4e7c-ab86-4ecb-8f34-99b5da531ceb" --version 1.0.0
321
+ ```
322
+
323
+ \b
324
+ 🆗 ***Response:***
325
+ ```json
326
+ {
327
+ "config": [
328
+ {
329
+ "id": "632a4e7c-ab86-4ecb-8f34-99b5da531ceb",
330
+ "release": {
331
+ "version": "1.0.0"
332
+ }
333
+ }
334
+ ],
335
+ "createdAt": "2020-01-01T18:00:00.000Z",
336
+ "createdBy": "jane.smith@peak.ai",
337
+ "id": "6a6b9e08-638e-4116-a29d-077086135062",
338
+ "notes": "Updated workflows with new algorithms."
339
+ }
340
+ ```
341
+
342
+ 🔗 [**API Documentation**](https://press.peak.ai/api-docs/index.htm#/App%20Specs/get_v1_apps_specs__specId__releases__release_)
343
+ """
344
+ app_client: App = ctx.obj["client"]
345
+ response = app_client.describe_spec_release(spec_id, version)
346
+ console.print(response)
347
+
348
+
349
+ @app.command(short_help="List App specs releases.")
350
+ def list_releases(
351
+ ctx: typer.Context,
352
+ spec_id: str = args.SPEC_ID,
353
+ sort: Optional[List[str]] = args.SORT_KEYS,
354
+ page_size: Optional[int] = args.PAGE_SIZE,
355
+ page_number: Optional[int] = args.PAGE_NUMBER,
356
+ ) -> None:
357
+ """***List*** all the releases for a specific App Spec.
358
+
359
+ \b
360
+ 📝 ***Example usage:***<br/>
361
+ ```bash
362
+ peak apps specs list-releases --spec-id "632a4e7c-ab86-4ecb-8f34-99b5da531ceb" --sort createdAt:asc --page-size 10 --page-number 1
363
+ ```
364
+
365
+ \b
366
+ 🆗 ***Response:***
367
+ ```
368
+ {
369
+ "pageCount": 1,
370
+ "pageNumber": 1,
371
+ "pageSize": 10,
372
+ "releaseCount": 1,
373
+ "releases": [...]
374
+ }
375
+ ```
376
+
377
+ 🔗 [**API Documentation**](https://press.peak.ai/api-docs/index.htm#/App%20Specs/get_v1_apps_specs__specId__releases)
378
+ """
379
+ app_client: App = ctx.obj["client"]
380
+ response = app_client.list_spec_releases(
381
+ spec_id=spec_id,
382
+ sort=sort,
383
+ page_size=page_size,
384
+ page_number=page_number,
385
+ return_iterator=False,
386
+ )
387
+ console.print(response)
@@ -0,0 +1,40 @@
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
+ """Blocks Module."""
22
+ import typer
23
+ from peak.cli.press.blocks import deployments, specs
24
+
25
+ app = typer.Typer(
26
+ help="Create and manage Block specs and deployments.",
27
+ short_help="Create and manage Block specs and deployments.",
28
+ )
29
+ app.add_typer(
30
+ specs.app,
31
+ name="specs",
32
+ help="Create and manage Block specs which are blueprint for Peak resources.",
33
+ short_help="Create and manage Block Specs.",
34
+ )
35
+ app.add_typer(
36
+ deployments.app,
37
+ name="deployments",
38
+ help="Create and manage Block deployments which deploys the Peak resources based on the created specs.",
39
+ short_help="Create and manage Block Deployments.",
40
+ )