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,492 @@
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 specs 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
+ _SPEC_ID = typer.Argument(..., help="ID of the Block spec to be used in this operation.")
33
+
34
+
35
+ @app.command("list", short_help="List Block specs.")
36
+ def list_block_specs(
37
+ ctx: typer.Context,
38
+ page_size: Optional[int] = args.PAGE_SIZE,
39
+ page_number: Optional[int] = args.PAGE_NUMBER,
40
+ status: Optional[List[str]] = args.STATUS_FILTER,
41
+ name: Optional[str] = args.NAME_FILTER,
42
+ title: Optional[str] = args.TITLE_FILTER,
43
+ sort: Optional[List[str]] = args.SORT_KEYS,
44
+ scope: Optional[List[str]] = args.SCOPES,
45
+ featured: Optional[bool] = args.FEATURED,
46
+ ) -> None:
47
+ """***List*** all Block specs that exists in the tenant along with the public-scoped ones.
48
+
49
+ \b
50
+ 📝 ***Example usage:***<br/>
51
+ ```bash
52
+ peak blocks specs list --featured --scope shared,private --page-size 10 --page-number 1
53
+ ```
54
+
55
+ \b
56
+ 🆗 ***Response:***
57
+ ```
58
+ {
59
+ "specsCount": 1,
60
+ "specs": [...],
61
+ "pageCount": 1,
62
+ "pageNumber": 1,
63
+ "pageSize": 10
64
+ }
65
+ ```
66
+
67
+ 🔗 [**API Documentation**](https://press.peak.ai/api-docs/index.htm#/Block%20Specs/get_v1_blocks_specs)
68
+ """
69
+ block_client: Block = ctx.obj["client"]
70
+ response = block_client.list_specs(
71
+ status=status,
72
+ featured=featured,
73
+ name=name,
74
+ title=title,
75
+ sort=sort,
76
+ scope=scope,
77
+ page_size=page_size,
78
+ page_number=page_number,
79
+ return_iterator=False,
80
+ )
81
+ console.print(response)
82
+
83
+
84
+ @app.command(short_help="Create a Block spec.")
85
+ def create(
86
+ ctx: typer.Context,
87
+ file: str = args.TEMPLATE_PATH,
88
+ params_file: Optional[str] = args.TEMPLATE_PARAMS_FILE,
89
+ params: Optional[List[str]] = args.TEMPLATE_PARAMS,
90
+ ) -> None:
91
+ """***Create*** a Block spec. A Block spec is just a blueprint for a specific resource. This creates a version of the spec also know as a ***Release***.
92
+
93
+ \b
94
+ 🧩 ***Input file schema (yaml):***<br/>
95
+ ```yaml
96
+ featured (bool | required: false): Boolean specifying whether to feature this spec.
97
+ scope (str | required: false): Specify what tenants can discover and deploy this spec.
98
+ tenants (list(str) | required: false): Given a shared scope, specify what other tenants can discover and deploy this spec.
99
+ body (map):
100
+ version (int): Version of the spec.
101
+ kind (string): Specifies the type of spec.
102
+ metadata (map):
103
+ name (string): Name of the spec. Must be unique within the tenant.
104
+ title (string | required: false): Title of the spec.
105
+ summary (string): Summary of the spec.
106
+ description (string | required: false): Description of the spec.
107
+ descriptionContentType (string | required: false): Content type of the description. Should be one of "text/plain" or "text/markdown".
108
+ imageUrl (string | required: false): URL of the image to be associated with the app spec.
109
+ tags (list(map) | required: false):
110
+ - name (string): Name of the tag.
111
+ release (map):
112
+ version (string): A valid semantic release version of the spec.
113
+ notes (string | required: false): Notes for the release version.
114
+ config (map):
115
+ images(map | required: false): # To be used only in case of workflow block.
116
+ image-name (map): Dictionary containing the image configuration. Here the key is name of the image.
117
+ version (string | required: false): A valid semantic image version.
118
+ dockerfile (string | required: false): Path to the Dockerfile inside artifact.
119
+ context (string | required: false): The path within the artifact where the code to be executed by the Dockerfile is located.
120
+ useCache (boolean | required: false): Whether to enable image caching to reduce build time, is enabled by default.
121
+ buildArguments (map | required: false): Dictionary containing build args. Here the key is the name of the arg and value is the value of the arg.
122
+ secrets (list(str)) | required: false): List of secret names to be passed.
123
+ steps (map | required: false): # To be used only in case of workflow block.
124
+ <stepName> (map): Dictionary containing the step configuration. Here the key is name of the step.
125
+ image: (map | required: false):
126
+ version (string | required: false): A valid semantic image version.
127
+ dockerfile (string | required: false): Path to the Dockerfile inside artifact.
128
+ context (string | required: false): The path within the artifact where the code to be executed by the Dockerfile is located.
129
+ useCache (boolean | required: false): Whether to enable image caching to reduce build time, is enabled by default.
130
+ buildArguments (map | required: false): Dictionary containing build args. Here the key is the name of the arg and value is the value of the arg.
131
+ secrets (list(str)) | required: false): List of secret names to be passed.
132
+ imageDetails (map | required: false):
133
+ id (int): ID of the existing image.
134
+ versionId: (int): ID of the existing image version.
135
+ imageRef (string | required: false): Name of the image defined above.
136
+ type (string | required: false): Type of workflow step. Currently only standard type is supported.
137
+ command (string): Command to run when step is executed.
138
+ clearImageCache (boolean | required: false): Whether to clear image cache on workflow execution.
139
+ stepTimeout (int | required: false): Time after which the step timeouts.
140
+ parameters (map | required: false):
141
+ env (map | required: false): Key-Value pair where key is the name of the env.
142
+ secrets (list(str) | required: false): List of secret names to be passed.
143
+ parents (list(str) | required: false): List containing names of steps on which this step is dependent on.
144
+ repository (map | required: false):
145
+ branch (string): Branch of the repository containing the required files.
146
+ token (string | required: false): The token to be used to clone the repository.
147
+ url (string): URL of the repository.
148
+ resources (map | required: false):
149
+ instanceTypeId (int): ID of the instance type to be used in the step.
150
+ storage (string): Storage in GB. For example, "10GB".
151
+ triggers (list(map)):
152
+ - cron (string | required: false): A valid cron expression.
153
+ webhook (boolean | required: false): Should be true if webhook type trigger is to be used.
154
+ webhookId (string | required: false): ID of the webhook.
155
+ webhookPolicy (string | required: false): Policy of the webhook to be used. Should be one of "generate" or "preserve". It is "generate" by default.
156
+ image (map | required: false): # To be used only in case of webapp block.
157
+ version (string | required: false): A valid semantic image version.
158
+ dockerfile (string | required: false): Path to the Dockerfile inside artifact.
159
+ context (string | required: false): The path within the artifact where the code to be executed by the Dockerfile is located.
160
+ useCache (boolean | required: false): Whether to enable image caching to reduce build time, is enabled by default.
161
+ buildArguments (map | required: false): Dictionary containing build args. Here the key is the name of the arg and value is the value of the arg.
162
+ secrets (list(str)) | required: false): List of secret names to be passed.
163
+ imageDetails (map | required: false): # To be used only in case of webapp block.
164
+ id (int): ID of the existing image.
165
+ versionId: (int): ID of the existing image version.
166
+ artifact (map | required: false):
167
+ path (str): Path to the artifact.
168
+ ignore_files (list(str) | required: false) : Ignore files to use when creating artifact.
169
+ ```
170
+
171
+ \b
172
+ 📝 ***Example usage:***
173
+ ```bash
174
+ peak blocks specs create /path/to/body.yaml -v /path/to/params.yaml
175
+ ```
176
+
177
+ \b
178
+ 🆗 ***Response:***
179
+ ```json
180
+ {
181
+ "id": "632a4e7c-ab86-4ecb-8f34-99b5da531ceb"
182
+ }
183
+ ```
184
+
185
+ 🔗 [**API Documentation**](https://press.peak.ai/api-docs/index.htm#/Block%20Specs/post_v1_blocks_specs)
186
+ """
187
+ block_client: Block = ctx.obj["client"]
188
+ body = helpers.template_handler(file, params_file, params)
189
+ body = helpers.remove_unknown_args(body, block_client.create_spec)
190
+ response: Dict[str, str] = block_client.create_spec(**body)
191
+
192
+ console.print(response)
193
+
194
+
195
+ @app.command(short_help="Describe a Block spec.")
196
+ def describe(
197
+ ctx: typer.Context,
198
+ spec_id: str = _SPEC_ID,
199
+ ) -> None:
200
+ """***Describe*** a Block spec with details of its latest release.
201
+
202
+ \b
203
+ 📝 ***Example usage:***<br/>
204
+ ```bash
205
+ peak blocks specs describe "632a4e7c-ab86-4ecb-8f34-99b5da531ceb"
206
+ ```
207
+
208
+ \b
209
+ 🆗 ***Response:***
210
+ ```
211
+ {
212
+ "featured": true,
213
+ "id": "632a4e7c-ab86-4ecb-8f34-99b5da531ceb"
214
+ "kind": "app",
215
+ "latestRelease": {...},
216
+ "metadata": {...},
217
+ "scope": "private"
218
+ }
219
+ ```
220
+
221
+ 🔗 [**API Documentation**](https://press.peak.ai/api-docs/index.htm#/Block%20Specs/get_v1_blocks_specs__specId_)
222
+ """
223
+ block_client: Block = ctx.obj["client"]
224
+ response = block_client.describe_spec(spec_id)
225
+ console.print(response)
226
+
227
+
228
+ @app.command(short_help="Update the Block spec metadata.")
229
+ def update_metadata(
230
+ ctx: typer.Context,
231
+ spec_id: str = _SPEC_ID,
232
+ file: str = args.TEMPLATE_PATH,
233
+ params_file: Optional[str] = args.TEMPLATE_PARAMS_FILE,
234
+ params: Optional[List[str]] = args.TEMPLATE_PARAMS,
235
+ ) -> None:
236
+ """***Update*** the Block spec metadata.
237
+
238
+ \b
239
+ 🧩 ***Input file schema (yaml):***<br/>
240
+ ```yaml
241
+ body (map):
242
+ featured (bool | required: false): Boolean specifying whether to feature this spec.
243
+ scope (str | required: false): Specify what tenants can discover and deploy this spec.
244
+ tenants (list(str) | required: false): Given a shared scope, specify what other tenants can discover and deploy this spec.
245
+ metadata (map):
246
+ name (string | required: false): Name of the spec. Must be unique within the tenant.
247
+ title (string | required: false): Title of the spec.
248
+ summary (string | required: false): Summary of the spec.
249
+ description (string | required: false): Description of the spec.
250
+ descriptionContentType (string | required: false): Content type of the description. Should be one of "text/plain" or "text/markdown".
251
+ imageUrl (string | required: false): URL of the image to be associated with the block spec.
252
+ status (string | required: false): Status of the block spec.
253
+ tags (list(map) | required: false):
254
+ - name (string): Name of the tag.
255
+ ```
256
+
257
+ \b
258
+ 📝 ***Example usage:***
259
+ ```bash
260
+ peak blocks specs update-metadata "632a4e7c-ab86-4ecb-8f34-99b5da531ceb" /path/to/body.yaml -v /path/to/params.yaml
261
+ ```
262
+
263
+ \b
264
+ 🆗 ***Response:***
265
+ ```
266
+ {
267
+ "featured": false,
268
+ "id": "632a4e7c-ab86-4ecb-8f34-99b5da531ceb"
269
+ "kind": "workflow",
270
+ "latestRelease": {...},
271
+ "metadata": {...},
272
+ "scope": "private"
273
+ }
274
+ ```
275
+
276
+ 🔗 [**API Documentation**](https://press.peak.ai/api-docs/index.htm#/Block%20Specs/patch_v1_blocks_specs__specId_)
277
+ """
278
+ body = helpers.template_handler(file, params_file, params)
279
+ block_client: Block = ctx.obj["client"]
280
+ body = helpers.remove_unknown_args(body, block_client.update_spec_metadata)
281
+ response: Dict[None, None] = block_client.update_spec_metadata(spec_id, **body)
282
+ console.print(response)
283
+
284
+
285
+ @app.command(short_help="Delete a Block spec.")
286
+ def delete(
287
+ ctx: typer.Context,
288
+ spec_id: str = _SPEC_ID,
289
+ ) -> None:
290
+ """***Delete*** a Block spec.
291
+
292
+ \b
293
+ 📝 ***Example usage:***<br/>
294
+ ```bash
295
+ peak blocks specs delete "632a4e7c-ab86-4ecb-8f34-99b5da531ceb"
296
+ ```
297
+
298
+ \b
299
+ 🆗 ***Response:***
300
+ ```json
301
+ {}
302
+ ```
303
+
304
+ 🔗 [**API Documentation**](https://press.peak.ai/api-docs/index.htm#/Block%20Specs/delete_v1_blocks_specs__specId_)
305
+ """
306
+ block_client: Block = ctx.obj["client"]
307
+ response = block_client.delete_spec(spec_id)
308
+ console.print(response)
309
+
310
+
311
+ @app.command(short_help="Create a new release for a Block spec.")
312
+ def create_release(
313
+ ctx: typer.Context,
314
+ spec_id: str = _SPEC_ID,
315
+ file: str = args.TEMPLATE_PATH,
316
+ params_file: Optional[str] = args.TEMPLATE_PARAMS_FILE,
317
+ params: Optional[List[str]] = args.TEMPLATE_PARAMS,
318
+ ) -> None:
319
+ """***Create*** a new release for a Block spec.
320
+
321
+ \b
322
+ 🧩 ***Input file schema (yaml):***<br/>
323
+ ```yaml
324
+ body (map):
325
+ release (map):
326
+ version (string): A valid semantic release version of the spec. Must be greater than previous release version.
327
+ notes (string | required: false): Notes for the release version.
328
+ config (map):
329
+ images(map | required: false): # To be used only in case of workflow block.
330
+ image-name(map): Dictionary containing the image configuration. Here the key is name of the image.
331
+ version (string | required: false): A valid semantic image version.
332
+ dockerfile (string | required: false): Path to the Dockerfile inside artifact.
333
+ context (string | required: false): The path within the artifact where the code to be executed by the Dockerfile is located.
334
+ useCache (boolean | required: false): Whether to enable image caching to reduce build time, is enabled by default.
335
+ buildArguments (map | required: false): Dictionary containing build args. Here the key is the name of the arg and value is the value of the arg.
336
+ secrets (list(str)) | required: false): List of secret names to be passed.
337
+ steps(map | required: false): # To be used only in case of workflow block.
338
+ <stepName> (map): Dictionary containing the step configuration. Here the key is name of the step.
339
+ image: (map | required: false):
340
+ version (string | required: false): A valid semantic image version.
341
+ dockerfile (string | required: false): Path to the Dockerfile inside artifact.
342
+ context (string | required: false): The path within the artifact where the code to be executed by the Dockerfile is located.
343
+ useCache (boolean | required: false): Whether to enable image caching to reduce build time, is enabled by default.
344
+ buildArguments (map | required: false): Dictionary containing build args. Here the key is the name of the arg and value is the value of the arg.
345
+ secrets (list(str)) | required: false): List of secret names to be passed.
346
+ imageDetails (map | required: false):
347
+ id (int): ID of the existing image.
348
+ versionId: (int): ID of the existing image version.
349
+ imageRef (string | required: false): Name of the image defined above.
350
+ type (string | required: false): Type of workflow step. Currently only standard type is supported.
351
+ command (string): Command to run when step is executed.
352
+ clearImageCache (boolean | required: false): Whether to clear image cache on workflow execution.
353
+ stepTimeout (int | required: false): Time after which the step timeouts.
354
+ parameters (map | required: false):
355
+ env (map | required: false): Key-Value pair where key is the name of the env.
356
+ secrets (list(str) | required: false): List of secret names to be passed.
357
+ parents (list(str) | required: false): List containing names of steps on which this step is dependent on.
358
+ repository (map | required: false):
359
+ branch (string): Branch of the repository containing the required files.
360
+ token (string | required: false): The token to be used to clone the repository.
361
+ url (string): URL of the repository.
362
+ resources (map | required: false):
363
+ instanceTypeId (int): ID of the instance type to be used in the step.
364
+ storage (string): Storage in GB. For example, "10GB".
365
+ triggers (list(map)):
366
+ cron (string | required: false): A valid cron expression.
367
+ webhook (boolean | required: false): Should be true if webhook type trigger is to be used.
368
+ webhookId (string | required: false): ID of the webhook.
369
+ webhookPolicy (string | required: false): Policy of the webhook to be used. Should be one of "generate" or "preserve". It is "generate" by default.
370
+ image (map | required: false): # To be used only in case of webapp block.
371
+ version (string | required: false): A valid semantic image version.
372
+ dockerfile (string | required: false): Path to the Dockerfile inside artifact.
373
+ context (string | required: false): The path within the artifact where the code to be executed by the Dockerfile is located.
374
+ useCache (boolean | required: false): Whether to enable image caching to reduce build time, is enabled by default.
375
+ buildArguments (map | required: false): Dictionary containing build args. Here the key is the name of the arg and value is the value of the arg.
376
+ secrets (list(str)) | required: false): List of secret names to be passed.
377
+ imageDetails (map | required: false): # To be used only in case of webapp block.
378
+ id (int): ID of the existing image.
379
+ versionId: (int): ID of the existing image version.
380
+ artifact (map | required: false):
381
+ path (str): Path to the artifact.
382
+ ignore_files (list(str) | required: false) : Ignore files to use when creating artifact.
383
+ ```
384
+
385
+ \b
386
+ 📝 ***Example usage:***
387
+ ```bash
388
+ peak blocks specs create-release "632a4e7c-ab86-4ecb-8f34-99b5da531ceb" '/path/to/body.yaml' -v '/path/to/params.yaml'
389
+ ```
390
+
391
+ \b
392
+ 🆗 ***Response:***
393
+ ```json
394
+ {
395
+ "id": "632a4e7c-ab86-4ecb-8f34-99b5da531ceb",
396
+ "release": {
397
+ "version": "2.0.0"
398
+ }
399
+ }
400
+ ```
401
+
402
+ 🔗 [**API Documentation**](https://press.peak.ai/api-docs/index.htm#/Block%20Specs/post_v1_blocks_specs__specId__releases)
403
+ """
404
+ body = helpers.template_handler(file, params_file, params)
405
+ block_client: Block = ctx.obj["client"]
406
+ body = helpers.remove_unknown_args(body, block_client.create_spec_release)
407
+ response: Dict[str, str] = block_client.create_spec_release(spec_id, **body)
408
+ console.print(response)
409
+
410
+
411
+ @app.command(short_help="Describe a Block spec release.")
412
+ def describe_release(
413
+ ctx: typer.Context,
414
+ spec_id: str = args.SPEC_ID,
415
+ version: str = args.RELEASE_VERSION,
416
+ ) -> None:
417
+ """***Describe*** a Block spec release.
418
+
419
+ \b
420
+ 📝 ***Example usage:***<br/>
421
+ ```bash
422
+ peak blocks specs describe-release --spec-id "632a4e7c-ab86-4ecb-8f34-99b5da531ceb" --version 1.0.0
423
+ ```
424
+
425
+ \b
426
+ 🆗 ***Response:***
427
+ ```
428
+ {
429
+ "artifact": {
430
+ "id": "721d738a-29f3-43b2-af52-c9055abe60b6",
431
+ "version": 1
432
+ },
433
+ "config": {
434
+ "images": {...},
435
+ "steps": {...},
436
+ "triggers": [
437
+ {...}
438
+ ]
439
+ },
440
+ "createdAt": "2020-01-01T18:00:00.000Z",
441
+ "createdBy": "someoneh@peak.ai",
442
+ "id": "df113d64-ff44-4aa0-9278-edb03dae7a3f",
443
+ "notes": "This is the original release"
444
+ }
445
+ ```
446
+
447
+ 🔗 [**API Documentation**](https://press.peak.ai/api-docs/index.htm#/Block%20Specs/get_v1_blocks_specs__specId__releases__release_)
448
+ """
449
+ block_client: Block = ctx.obj["client"]
450
+ response = block_client.describe_spec_release(spec_id, version)
451
+ console.print(response)
452
+
453
+
454
+ @app.command(short_help="List releases of a Block spec.")
455
+ def list_releases(
456
+ ctx: typer.Context,
457
+ spec_id: str = args.SPEC_ID,
458
+ sort: Optional[List[str]] = args.SORT_KEYS,
459
+ page_size: Optional[int] = args.PAGE_SIZE,
460
+ page_number: Optional[int] = args.PAGE_NUMBER,
461
+ ) -> None:
462
+ """***List*** all releases for a given Block spec.
463
+
464
+ \b
465
+ 📝 ***Example usage:***<br/>
466
+ ```bash
467
+ peak blocks specs list-releases --spec-id "632a4e7c-ab86-4ecb-8f34-99b5da531ceb" --sort createdBy:asc,createdAt --page-size 10 --page-number 1
468
+ ```
469
+
470
+ \b
471
+ 🆗 ***Response:***
472
+ ```
473
+ {
474
+ "pageCount": 1,
475
+ "pageNumber": 1,
476
+ "pageSize": 10,
477
+ "releaseCount": 1,
478
+ "releases": [...]
479
+ }
480
+ ```
481
+
482
+ 🔗 [**API Documentation**](https://press.peak.ai/api-docs/index.htm#/Block%20Specs/get_v1_blocks_specs__specId__releases)
483
+ """
484
+ block_client: Block = ctx.obj["client"]
485
+ response = block_client.list_spec_releases(
486
+ spec_id,
487
+ sort=sort,
488
+ page_size=page_size,
489
+ page_number=page_number,
490
+ return_iterator=False,
491
+ )
492
+ console.print(response)
@@ -0,0 +1,78 @@
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 deployments commands."""
22
+ from typing import List, Optional
23
+
24
+ import typer
25
+ from peak.cli import args
26
+ from peak.press.deployments import Deployment
27
+ from rich.console import Console
28
+
29
+ app = typer.Typer(
30
+ help="Manage both Block and App deployments.",
31
+ short_help="Manage both Block and App deployments.",
32
+ )
33
+ console = Console()
34
+
35
+
36
+ @app.command("list", short_help="List App and Block deployments.")
37
+ def list_deployments(
38
+ ctx: typer.Context,
39
+ page_size: Optional[int] = args.PAGE_SIZE,
40
+ page_number: Optional[int] = args.PAGE_NUMBER,
41
+ status: Optional[List[str]] = args.STATUS_FILTER,
42
+ kind: Optional[str] = args.KIND_FILTER,
43
+ term: Optional[str] = args.TERM_FILTER,
44
+ sort: Optional[List[str]] = args.SORT_KEYS,
45
+ ) -> None:
46
+ """***List*** all the App and Block deployments that have been created for the tenant.
47
+
48
+ \b
49
+ 📝 ***Example usage:***<br/>
50
+ ```bash
51
+ peak deployments list --page-size 10 --page-number 1
52
+ ```
53
+
54
+ \b
55
+ 🆗 ***Response:***
56
+ ```
57
+ {
58
+ "deploymentCount": 1,
59
+ "deployments": [...],
60
+ "pageCount": 1,
61
+ "pageNumber": 1,
62
+ "pageSize": 10
63
+ }
64
+ ```
65
+
66
+ 🔗 [**API Documentation**](https://press.peak.ai/api-docs/index.htm#/Deployments/get_v1_deployments)
67
+ """
68
+ deployment_client: Deployment = ctx.obj["client"]
69
+ response = deployment_client.list_deployments(
70
+ status=status,
71
+ kind=kind,
72
+ term=term,
73
+ sort=sort,
74
+ page_size=page_size,
75
+ page_number=page_number,
76
+ return_iterator=False,
77
+ )
78
+ console.print(response)