peak-sdk 1.5.0__py3-none-any.whl → 1.7.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 (69) hide show
  1. peak/_metadata.py +80 -5
  2. peak/_version.py +1 -1
  3. peak/cli/args.py +1 -0
  4. peak/cli/cli.py +3 -2
  5. peak/cli/helpers.py +1 -0
  6. peak/cli/press/apps/specs.py +2 -0
  7. peak/cli/press/blocks/specs.py +68 -24
  8. peak/cli/press/deployments.py +41 -0
  9. peak/cli/press/specs.py +4 -2
  10. peak/cli/resources/alerts/__init__.py +35 -0
  11. peak/cli/resources/alerts/emails.py +360 -0
  12. peak/cli/resources/images.py +19 -7
  13. peak/cli/resources/services.py +23 -0
  14. peak/cli/resources/tenants.py +4 -1
  15. peak/cli/resources/workflows.py +81 -19
  16. peak/cli/ruff.toml +5 -3
  17. peak/compression.py +2 -2
  18. peak/exceptions.py +4 -6
  19. peak/handler.py +3 -5
  20. peak/helpers.py +8 -9
  21. peak/output.py +2 -2
  22. peak/press/apps.py +18 -19
  23. peak/press/blocks.py +396 -155
  24. peak/press/deployments.py +30 -4
  25. peak/press/specs.py +12 -14
  26. peak/resources/__init__.py +3 -2
  27. peak/resources/alerts.py +309 -0
  28. peak/resources/artifacts.py +2 -4
  29. peak/resources/images.py +317 -100
  30. peak/resources/services.py +7 -6
  31. peak/resources/webapps.py +3 -5
  32. peak/resources/workflows.py +103 -13
  33. peak/sample_yaml/press/apps/specs/create_app_spec.yaml +2 -0
  34. peak/sample_yaml/press/apps/specs/create_app_spec_release.yaml +2 -0
  35. peak/sample_yaml/press/blocks/specs/service/api/create_block_spec.yaml +102 -0
  36. peak/sample_yaml/press/blocks/specs/service/api/create_block_spec_release.yaml +88 -0
  37. peak/sample_yaml/press/blocks/specs/service/webapp/create_block_spec.yaml +103 -0
  38. peak/sample_yaml/press/blocks/specs/service/webapp/create_block_spec_release.yaml +89 -0
  39. peak/sample_yaml/press/blocks/specs/{create_block_spec.yaml → workflow/create_block_spec.yaml} +20 -1
  40. peak/sample_yaml/press/blocks/specs/{create_block_spec_release.yaml → workflow/create_block_spec_release.yaml} +20 -1
  41. peak/sample_yaml/resources/emails/send_email.yaml +15 -0
  42. peak/sample_yaml/resources/images/dockerfile/create_image.yaml +3 -0
  43. peak/sample_yaml/resources/images/dockerfile/create_image_version.yaml +3 -0
  44. peak/sample_yaml/resources/images/dockerfile/update_version.yaml +3 -0
  45. peak/sample_yaml/resources/images/github/create_image.yaml +3 -0
  46. peak/sample_yaml/resources/images/github/create_image_version.yaml +3 -0
  47. peak/sample_yaml/resources/images/github/update_version.yaml +3 -0
  48. peak/sample_yaml/resources/images/upload/create_image.yaml +3 -0
  49. peak/sample_yaml/resources/images/upload/create_image_version.yaml +3 -0
  50. peak/sample_yaml/resources/images/upload/create_or_update_image.yaml +3 -0
  51. peak/sample_yaml/resources/images/upload/update_version.yaml +3 -0
  52. peak/sample_yaml/resources/services/create_or_update_service.yaml +1 -0
  53. peak/sample_yaml/resources/services/create_service.yaml +1 -0
  54. peak/sample_yaml/resources/services/update_service.yaml +1 -0
  55. peak/sample_yaml/resources/workflows/create_or_update_workflow.yaml +36 -0
  56. peak/sample_yaml/resources/workflows/create_workflow.yaml +19 -1
  57. peak/sample_yaml/resources/workflows/patch_workflow.yaml +36 -0
  58. peak/sample_yaml/resources/workflows/update_workflow.yaml +36 -0
  59. peak/session.py +1 -1
  60. peak/telemetry.py +1 -1
  61. peak/template.py +6 -4
  62. peak/tools/logging/__init__.py +26 -268
  63. peak/tools/logging/log_level.py +35 -3
  64. peak/tools/logging/logger.py +389 -0
  65. {peak_sdk-1.5.0.dist-info → peak_sdk-1.7.0.dist-info}/METADATA +19 -20
  66. {peak_sdk-1.5.0.dist-info → peak_sdk-1.7.0.dist-info}/RECORD +69 -60
  67. {peak_sdk-1.5.0.dist-info → peak_sdk-1.7.0.dist-info}/WHEEL +1 -1
  68. {peak_sdk-1.5.0.dist-info → peak_sdk-1.7.0.dist-info}/LICENSE +0 -0
  69. {peak_sdk-1.5.0.dist-info → peak_sdk-1.7.0.dist-info}/entry_points.txt +0 -0
peak/resources/images.py CHANGED
@@ -19,6 +19,7 @@
19
19
  # # along with this program. If not, see <https://apache.org/licenses/LICENSE-2.0>
20
20
  #
21
21
  """image client module."""
22
+
22
23
  from __future__ import annotations
23
24
 
24
25
  from typing import Any, Dict, Iterator, List, Literal, Optional, Tuple, overload
@@ -55,8 +56,7 @@ class Image(BaseClient):
55
56
  tags: Optional[List[str]] = None,
56
57
  *,
57
58
  return_iterator: Literal[False],
58
- ) -> Dict[str, Any]:
59
- ...
59
+ ) -> Dict[str, Any]: ...
60
60
 
61
61
  @overload
62
62
  def list_images(
@@ -70,8 +70,7 @@ class Image(BaseClient):
70
70
  tags: Optional[List[str]] = None,
71
71
  *,
72
72
  return_iterator: Literal[True] = True,
73
- ) -> Iterator[Dict[str, Any]]:
74
- ...
73
+ ) -> Iterator[Dict[str, Any]]: ...
75
74
 
76
75
  def list_images(
77
76
  self,
@@ -96,7 +95,7 @@ class Image(BaseClient):
96
95
  name: (str | None): Image Name or version to search for.
97
96
  status (List[str] | None): Filter images on the basis of the status of the latest version.
98
97
  Valid values are `not-ready`, `ready`, `in-use`, `deleting`, `delete-failed`.
99
- scope (List[str] | None): Filter out on the basis of the type of the image - global or custom.
98
+ scope (List[str] | None): Filter out on the basis of the type of the image - `global` or `custom`.
100
99
  last_build_status (List[str] | None): Filter out on the basis of last build status of the latest version.
101
100
  Valid values are `building`, `failed`, `success`, `stopped`, `stopping`.
102
101
  tags (List[str] | None): Filter out on the basis of the tags attached to the latest version.
@@ -152,8 +151,7 @@ class Image(BaseClient):
152
151
  tags: Optional[List[str]] = None,
153
152
  *,
154
153
  return_iterator: Literal[False],
155
- ) -> Dict[str, Any]:
156
- ...
154
+ ) -> Dict[str, Any]: ...
157
155
 
158
156
  @overload
159
157
  def list_image_versions(
@@ -167,8 +165,7 @@ class Image(BaseClient):
167
165
  tags: Optional[List[str]] = None,
168
166
  *,
169
167
  return_iterator: Literal[True] = True,
170
- ) -> Iterator[Dict[str, Any]]:
171
- ...
168
+ ) -> Iterator[Dict[str, Any]]: ...
172
169
 
173
170
  def list_image_versions(
174
171
  self,
@@ -250,36 +247,92 @@ class Image(BaseClient):
250
247
  body (Dict[str, Any]): Represents the body to be used to create image. Schema can be found below.
251
248
  artifact (Optional[ArtifactInfo]): Mapping of artifact attributes that specifies how the artifact will be generated,
252
249
  it accepts two keys `path`, which is required and `ignore_files` which is optional, and defaults to `.dockerignore`, it is strongly advised that users use `ignore_files` when generating artifacts to avoid copying any extra files in artifact.
250
+ Required for image of source `upload`.
253
251
 
254
252
  Returns:
255
253
  Dict[str, Any]: `buildId`, `imageId`, and `versionId` of the newly created image and the corresponding version.
256
254
 
257
255
  SCHEMA:
258
- .. code-block:: json
259
-
260
- {
261
- "name": "string(required)",
262
- "type": "string(required)",
263
- "description": "string",
264
- "version": "string",
265
- "buildDetails":
256
+ Images can be created by three ways:
257
+
258
+ .. tabs::
259
+
260
+ .. tab:: Upload
261
+
262
+ .. code-block:: json
263
+
264
+ {
265
+ "name": "string (required)",
266
+ "type": "string (required)",
267
+ "description": "string",
268
+ "version": "string",
269
+ "buildDetails":
270
+ {
271
+ "source": "string",
272
+ "buildArguments": [
273
+ {
274
+ "name": "string",
275
+ "value": "string"
276
+ }
277
+ ],
278
+ "secrets": [],
279
+ "useCache": "boolean",
280
+ "dockerfilePath": "string",
281
+ "context": "string"
282
+ },
283
+ }
284
+
285
+ .. tab:: Github
286
+
287
+ .. code-block:: json
288
+
266
289
  {
267
- "source": "string",
268
- "buildArguments": [
290
+ "name": "string (required)",
291
+ "type": "string (required)",
292
+ "description": "string",
293
+ "version": "string",
294
+ "buildDetails":
269
295
  {
270
- "name": "string",
271
- "value": "string"
272
- }
273
- ],
274
- "useCache": "boolean",
275
- "dockerfile": "string",
276
- "branch": "string",
277
- "repository": "string",
278
- "token": "string",
279
- "dockerfilePath": "string",
280
- "context": "string"
281
- },
282
- }
296
+ "source": "string",
297
+ "buildArguments": [
298
+ {
299
+ "name": "string",
300
+ "value": "string"
301
+ }
302
+ ],
303
+ "secrets": [],
304
+ "useCache": "boolean",
305
+ "branch": "string",
306
+ "repository": "string",
307
+ "token": "string",
308
+ "dockerfilePath": "string",
309
+ "context": "string"
310
+ },
311
+ }
312
+
313
+ .. tab:: Dockerfile
314
+
315
+ .. code-block:: json
316
+
317
+ {
318
+ "name": "string (required)",
319
+ "type": "string (required)",
320
+ "description": "string",
321
+ "version": "string",
322
+ "buildDetails":
323
+ {
324
+ "source": "string",
325
+ "buildArguments": [
326
+ {
327
+ "name": "string",
328
+ "value": "string"
329
+ }
330
+ ],
331
+ "secrets": [],
332
+ "useCache": "boolean",
333
+ "dockerfile": "string"
334
+ },
335
+ }
283
336
 
284
337
  Raises:
285
338
  BadRequestException: The given request parameters are invalid.
@@ -323,29 +376,86 @@ class Image(BaseClient):
323
376
  Dict[str, Any]: `imageId`, `buildId`, `versionId` and `autodeploymentId` of the newly created version.
324
377
 
325
378
  SCHEMA:
326
- .. code-block:: json
379
+ Image versions can be created by three ways:
380
+
381
+ .. tabs::
382
+
383
+ .. tab:: Upload
384
+
385
+ .. code-block:: json
386
+
387
+ {
388
+ "name": "string (required)",
389
+ "type": "string (required)",
390
+ "description": "string",
391
+ "version": "string",
392
+ "buildDetails":
393
+ {
394
+ "source": "string",
395
+ "buildArguments": [
396
+ {
397
+ "name": "string",
398
+ "value": "string"
399
+ }
400
+ ],
401
+ "secrets": [],
402
+ "useCache": "boolean",
403
+ "dockerfilePath": "string",
404
+ "context": "string"
405
+ },
406
+ }
407
+
408
+ .. tab:: Github
409
+
410
+ .. code-block:: json
411
+
412
+ {
413
+ "name": "string (required)",
414
+ "type": "string (required)",
415
+ "description": "string",
416
+ "version": "string",
417
+ "buildDetails":
418
+ {
419
+ "source": "string",
420
+ "buildArguments": [
421
+ {
422
+ "name": "string",
423
+ "value": "string"
424
+ }
425
+ ],
426
+ "secrets": [],
427
+ "useCache": "boolean",
428
+ "branch": "string",
429
+ "repository": "string",
430
+ "token": "string",
431
+ "dockerfilePath": "string",
432
+ "context": "string"
433
+ },
434
+ }
435
+
436
+ .. tab:: Dockerfile
437
+
438
+ .. code-block:: json
327
439
 
328
- {
329
- "description": "string",
330
- "version": "string",
331
- "buildDetails":
332
440
  {
333
- "source": "string",
334
- "buildArguments": [
441
+ "name": "string (required)",
442
+ "type": "string (required)",
443
+ "description": "string",
444
+ "version": "string",
445
+ "buildDetails":
335
446
  {
336
- "name": "string",
337
- "value": "string"
338
- }
339
- ],
340
- "useCache": "boolean",
341
- "dockerfile": "string",
342
- "branch": "string",
343
- "repository": "string",
344
- "token": "string",
345
- "dockerfilePath": "string",
346
- "context": "string"
347
- },
348
- }
447
+ "source": "string",
448
+ "buildArguments": [
449
+ {
450
+ "name": "string",
451
+ "value": "string"
452
+ }
453
+ ],
454
+ "secrets": [],
455
+ "useCache": "boolean",
456
+ "dockerfile": "string"
457
+ },
458
+ }
349
459
 
350
460
  Raises:
351
461
  BadRequestException: The given request parameters are invalid.
@@ -455,28 +565,84 @@ class Image(BaseClient):
455
565
  Dict[str, Any]: `imageId`, `buildId`, `versionId` and `autodeploymentId` of the updated version.
456
566
 
457
567
  SCHEMA:
458
- .. code-block:: json
568
+ .. tabs::
569
+
570
+ .. tab:: Upload
571
+
572
+ .. code-block:: json
573
+
574
+ {
575
+ "name": "string (required)",
576
+ "type": "string (required)",
577
+ "description": "string",
578
+ "version": "string",
579
+ "buildDetails":
580
+ {
581
+ "source": "string",
582
+ "buildArguments": [
583
+ {
584
+ "name": "string",
585
+ "value": "string"
586
+ }
587
+ ],
588
+ "secrets": [],
589
+ "useCache": "boolean",
590
+ "dockerfilePath": "string",
591
+ "context": "string"
592
+ },
593
+ }
594
+
595
+ .. tab:: Github
596
+
597
+ .. code-block:: json
598
+
599
+ {
600
+ "name": "string (required)",
601
+ "type": "string (required)",
602
+ "description": "string",
603
+ "version": "string",
604
+ "buildDetails":
605
+ {
606
+ "source": "string",
607
+ "buildArguments": [
608
+ {
609
+ "name": "string",
610
+ "value": "string"
611
+ }
612
+ ],
613
+ "secrets": [],
614
+ "useCache": "boolean",
615
+ "branch": "string",
616
+ "repository": "string",
617
+ "token": "string",
618
+ "dockerfilePath": "string",
619
+ "context": "string"
620
+ },
621
+ }
622
+
623
+ .. tab:: Dockerfile
624
+
625
+ .. code-block:: json
459
626
 
460
- {
461
- "description": "string",
462
- "buildDetails":
463
627
  {
464
- "source": "string",
465
- "buildArguments": [
628
+ "name": "string (required)",
629
+ "type": "string (required)",
630
+ "description": "string",
631
+ "version": "string",
632
+ "buildDetails":
466
633
  {
467
- "name": "string",
468
- "value": "string"
469
- }
470
- ],
471
- "useCache": "boolean",
472
- "dockerfile": "string",
473
- "branch": "string",
474
- "repository": "string",
475
- "token": "string",
476
- "dockerfilePath": "string",
477
- "context": "string"
478
- },
479
- }
634
+ "source": "string",
635
+ "buildArguments": [
636
+ {
637
+ "name": "string",
638
+ "value": "string"
639
+ }
640
+ ],
641
+ "secrets": [],
642
+ "useCache": "boolean",
643
+ "dockerfile": "string"
644
+ },
645
+ }
480
646
 
481
647
  Raises:
482
648
  BadRequestException: The given request parameters are invalid.
@@ -523,31 +689,84 @@ class Image(BaseClient):
523
689
  In case when image and version exists, it will return `buildId` for the updated version along with `imageId` and `versionId` of the existing image / version.
524
690
 
525
691
  SCHEMA:
526
- .. code-block:: json
527
-
528
- {
529
- "name": "string(required)",
530
- "type": "string(required)",
531
- "description": "string",
532
- "version": "string",
533
- "buildDetails":
692
+ .. tabs::
693
+
694
+ .. tab:: Upload
695
+
696
+ .. code-block:: json
697
+
698
+ {
699
+ "name": "string (required)",
700
+ "type": "string (required)",
701
+ "description": "string",
702
+ "version": "string",
703
+ "buildDetails":
704
+ {
705
+ "source": "string",
706
+ "buildArguments": [
707
+ {
708
+ "name": "string",
709
+ "value": "string"
710
+ }
711
+ ],
712
+ "secrets": [],
713
+ "useCache": "boolean",
714
+ "dockerfilePath": "string",
715
+ "context": "string"
716
+ },
717
+ }
718
+
719
+ .. tab:: Github
720
+
721
+ .. code-block:: json
722
+
534
723
  {
535
- "source": "string",
536
- "buildArguments": [
724
+ "name": "string (required)",
725
+ "type": "string (required)",
726
+ "description": "string",
727
+ "version": "string",
728
+ "buildDetails":
537
729
  {
538
- "name": "string",
539
- "value": "string"
540
- }
541
- ],
542
- "useCache": "boolean",
543
- "dockerfile": "string",
544
- "branch": "string",
545
- "repository": "string",
546
- "token": "string",
547
- "dockerfilePath": "string",
548
- "context": "string"
549
- },
550
- }
730
+ "source": "string",
731
+ "buildArguments": [
732
+ {
733
+ "name": "string",
734
+ "value": "string"
735
+ }
736
+ ],
737
+ "secrets": [],
738
+ "useCache": "boolean",
739
+ "branch": "string",
740
+ "repository": "string",
741
+ "token": "string",
742
+ "dockerfilePath": "string",
743
+ "context": "string"
744
+ },
745
+ }
746
+
747
+ .. tab:: Dockerfile
748
+
749
+ .. code-block:: json
750
+
751
+ {
752
+ "name": "string (required)",
753
+ "type": "string (required)",
754
+ "description": "string",
755
+ "version": "string",
756
+ "buildDetails":
757
+ {
758
+ "source": "string",
759
+ "buildArguments": [
760
+ {
761
+ "name": "string",
762
+ "value": "string"
763
+ }
764
+ ],
765
+ "secrets": [],
766
+ "useCache": "boolean",
767
+ "dockerfile": "string"
768
+ },
769
+ }
551
770
 
552
771
  Raises:
553
772
  BadRequestException: The given request parameters are invalid.
@@ -556,8 +775,8 @@ class Image(BaseClient):
556
775
  PayloadTooLargeException: The artifact exceeds maximum size.
557
776
  InternalServerErrorException: The server failed to process the request.
558
777
  """
559
- image_name = body["name"] if "name" in body else ""
560
- version = body["version"] if "version" in body else ""
778
+ image_name = body.get("name", "")
779
+ version = body.get("version", "")
561
780
  response = (
562
781
  {} if not len(image_name) else self.list_images(page_size=100, return_iterator=False, name=image_name)
563
782
  )
@@ -698,8 +917,7 @@ class Image(BaseClient):
698
917
  build_status: Optional[List[str]] = None,
699
918
  *,
700
919
  return_iterator: Literal[False],
701
- ) -> Dict[str, Any]:
702
- ...
920
+ ) -> Dict[str, Any]: ...
703
921
 
704
922
  @overload
705
923
  def list_image_builds(
@@ -714,8 +932,7 @@ class Image(BaseClient):
714
932
  build_status: Optional[List[str]] = None,
715
933
  *,
716
934
  return_iterator: Literal[True] = True,
717
- ) -> Iterator[Dict[str, Any]]:
718
- ...
935
+ ) -> Iterator[Dict[str, Any]]: ...
719
936
 
720
937
  def list_image_builds(
721
938
  self,
@@ -44,8 +44,7 @@ class Service(BaseClient):
44
44
  service_type: Optional[List[str]] = None,
45
45
  *,
46
46
  return_iterator: Literal[False],
47
- ) -> Dict[str, Any]:
48
- ...
47
+ ) -> Dict[str, Any]: ...
49
48
 
50
49
  @overload
51
50
  def list_services(
@@ -57,8 +56,7 @@ class Service(BaseClient):
57
56
  service_type: Optional[List[str]] = None,
58
57
  *,
59
58
  return_iterator: Literal[True] = True,
60
- ) -> Iterator[Dict[str, Any]]:
61
- ...
59
+ ) -> Iterator[Dict[str, Any]]: ...
62
60
 
63
61
  def list_services(
64
62
  self,
@@ -155,7 +153,8 @@ class Service(BaseClient):
155
153
  "description": "string",
156
154
  "sessionStickiness": "boolean. Not required for 'api' service type.",
157
155
  "entrypoint": "string",
158
- "healthCheckURL": "string"
156
+ "healthCheckURL": "string",
157
+ "minInstances": "number. Default is 1 and maximum is 2",
159
158
  }
160
159
 
161
160
  Raises:
@@ -218,6 +217,7 @@ class Service(BaseClient):
218
217
  "sessionStickiness": "boolean. Not required for 'api' service type.",
219
218
  "entrypoint": "string",
220
219
  "healthCheckURL": "string",
220
+ "minInstances": "number. Default is 1 and maximum is 2",
221
221
  }
222
222
 
223
223
  Raises:
@@ -276,6 +276,7 @@ class Service(BaseClient):
276
276
  "sessionStickiness": "boolean. Not required for 'api' service type.",
277
277
  "entrypoint": "string",
278
278
  "healthCheckURL": "string",
279
+ "minInstances": "number. Default is 1 and maximum is 2",
279
280
  }
280
281
 
281
282
 
@@ -285,7 +286,7 @@ class Service(BaseClient):
285
286
  ForbiddenException: The user does not have permission to perform the operation.
286
287
  InternalServerErrorException: The server failed to process the request.
287
288
  """
288
- service_name = body["name"] if "name" in body else ""
289
+ service_name = body.get("name", "")
289
290
  response = (
290
291
  {} if not len(service_name) else self.list_services(page_size=100, return_iterator=False, name=service_name)
291
292
  )
peak/resources/webapps.py CHANGED
@@ -49,8 +49,7 @@ class Webapp(BaseClient):
49
49
  name: Optional[str] = None,
50
50
  *,
51
51
  return_iterator: Literal[False],
52
- ) -> Dict[str, Any]:
53
- ...
52
+ ) -> Dict[str, Any]: ...
54
53
 
55
54
  @overload
56
55
  def list_webapps(
@@ -61,8 +60,7 @@ class Webapp(BaseClient):
61
60
  name: Optional[str] = None,
62
61
  *,
63
62
  return_iterator: Literal[True] = True,
64
- ) -> Iterator[Dict[str, Any]]:
65
- ...
63
+ ) -> Iterator[Dict[str, Any]]: ...
66
64
 
67
65
  def list_webapps(
68
66
  self,
@@ -253,7 +251,7 @@ class Webapp(BaseClient):
253
251
  ForbiddenException: The user does not have permission to perform the operation.
254
252
  InternalServerErrorException: The server failed to process the request.
255
253
  """
256
- webapp_name = body["name"] if "name" in body else ""
254
+ webapp_name = body.get("name", "")
257
255
  response = (
258
256
  {} if not len(webapp_name) else self.list_webapps(page_size=100, return_iterator=False, name=webapp_name)
259
257
  )