peak-sdk 1.3.0__py3-none-any.whl → 1.5.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.
@@ -20,7 +20,14 @@
20
20
  #
21
21
 
22
22
  #
23
- """Peak Webapps service commands."""
23
+
24
+ """Peak Webapps commands.
25
+
26
+ .. warning::
27
+ The ``Web Apps`` commands are deprecated and will eventually be removed. It is recommended that users begin transitioning to the ``Service`` commands, which offers all the features of ``Webapp`` along with the added capability of API deployment and other significant updates for enhanced functionality. Transitioning early to the ``Service`` commands will ensure easier adoption of its advanced features and future updates.
28
+
29
+ For guidance on migrating to the ``Service`` and taking full advantage of its capabilities, please refer to the ``Service`` documentation.
30
+ """
24
31
 
25
32
  from typing import Any, Dict, List, Optional
26
33
 
@@ -34,7 +41,11 @@ from peak.resources.webapps import Webapp
34
41
  from typing_extensions import Annotated
35
42
 
36
43
  app = typer.Typer(
37
- help="Visualize your data and predictions using Webapps. Please note that only generic (EKS-based) webapps are supported with CLI.",
44
+ help="""Visualize your data and predictions using Webapps.
45
+ ```yaml
46
+ NOTE: Please note that only generic (EKS-based) webapps are supported with CLI. **Note** that, the functionalities provided through the `Webapp` feature are deprecated and will eventually be removed. We recommend using the `Service` feature which offers a more comprehensive and flexible solution for managing web applications and API deployments.
47
+ ```
48
+ """,
38
49
  short_help="Create and Manage Webapps.",
39
50
  )
40
51
 
@@ -70,6 +81,8 @@ SESSION_STICKINESS = typer.Option(None, help="Enable session stickiness for the
70
81
 
71
82
  MAPPING = {"imageId": "imageDetails", "versionId": "imageDetails", "instanceTypeId": "resources"}
72
83
 
84
+ DEPRECATION_MESSAGE = "The Web App commands are deprecated and will eventually be removed. We recommend using the Service feature which offers a more comprehensive and flexible solution for managing web applications and API deployments.\n"
85
+
73
86
 
74
87
  @app.command("list", short_help="List webapps.", options_metavar="list_webapps")
75
88
  def list_webapps(
@@ -83,6 +96,14 @@ def list_webapps(
83
96
  ) -> None:
84
97
  """***List*** all webapps that exist for the tenant.
85
98
 
99
+ \b
100
+ ```yaml
101
+ NOTE: The Web Apps commands are deprecated and will eventually be removed. It is recommended that users begin transitioning to the Service commands, which offers all the features of Webapp along with the added capability of API deployment and other significant updates for enhanced functionality. Transitioning early to the Service commands will ensure easier adoption of its advanced features and future updates.
102
+ ```
103
+
104
+ \b
105
+ For more information on Services, please refer to the [**Service**](https://docs.peak.ai/sdk/latest/cli/reference.html#peak-services) documentation.
106
+
86
107
  \b
87
108
  📝 ***Example usage:***<br/>
88
109
  ```bash
@@ -101,7 +122,7 @@ def list_webapps(
101
122
  }
102
123
  ```
103
124
 
104
- 🔗 [**API Documentation**](https://service.peak.ai/webapps/api-docs/index.htm#/Webapps/list-webapp)
125
+ 🔗 [**API Documentation**](https://service.peak.ai/webapps/api-docs/index.htm#/Services/list-service)
105
126
  """
106
127
  webapp_client: Webapp = ctx.obj["client"]
107
128
  writer: Writer = ctx.obj["writer"]
@@ -114,7 +135,7 @@ def list_webapps(
114
135
  status=parse_list_of_strings(status),
115
136
  name=name,
116
137
  )
117
- writer.write(response)
138
+ writer.write(response, deprecation_message=DEPRECATION_MESSAGE)
118
139
 
119
140
 
120
141
  @app.command(short_help="Create a new webapp.", options_metavar="create_webapp")
@@ -137,6 +158,14 @@ def create(
137
158
  ) -> None:
138
159
  """***Create*** a new webapp and start its deployment.
139
160
 
161
+ \b
162
+ ```yaml
163
+ NOTE: The Web Apps commands are deprecated and will eventually be removed. It is recommended that users begin transitioning to the Service commands, which offers all the features of Webapp along with the added capability of API deployment and other significant updates for enhanced functionality. Transitioning early to the Service commands will ensure easier adoption of its advanced features and future updates.
164
+ ```
165
+
166
+ \b
167
+ For more information on Services, please refer to the [**Service**](https://docs.peak.ai/sdk/latest/cli/reference.html#peak-services) documentation.
168
+
140
169
  \b
141
170
  🧩 ***Input file schema(yaml):***<br/>
142
171
  ```yaml
@@ -172,7 +201,7 @@ def create(
172
201
  }
173
202
  ```
174
203
 
175
- 🔗 [**API Documentation**](https://service.peak.ai/webapps/api-docs/index.htm#/Webapps/create-webapp)
204
+ 🔗 [**API Documentation**](https://service.peak.ai/webapps/api-docs/index.htm#/Services/create-service)
176
205
  """
177
206
  webapp_client: Webapp = ctx.obj["client"]
178
207
  writer: Writer = ctx.obj["writer"]
@@ -197,7 +226,7 @@ def create(
197
226
 
198
227
  with writer.pager():
199
228
  response = webapp_client.create_webapp(body=body)
200
- writer.write(response)
229
+ writer.write(response, deprecation_message=DEPRECATION_MESSAGE)
201
230
 
202
231
 
203
232
  @app.command(short_help="Update an existing webapp.", options_metavar="update_webapp")
@@ -220,6 +249,14 @@ def update(
220
249
  ) -> None:
221
250
  """***Update*** an existing webapp.
222
251
 
252
+ \b
253
+ ```yaml
254
+ NOTE: The Web Apps commands are deprecated and will eventually be removed. It is recommended that users begin transitioning to the Service commands, which offers all the features of Webapp along with the added capability of API deployment and other significant updates for enhanced functionality. Transitioning early to the Service commands will ensure easier adoption of its advanced features and future updates.
255
+ ```
256
+
257
+ \b
258
+ For more information on Services, please refer to the [**Service**](https://docs.peak.ai/sdk/latest/cli/reference.html#peak-services) documentation.
259
+
223
260
  \b
224
261
  When updating the webapp, it will trigger a redeployment only under specific conditions.
225
262
  Redeployment is triggered if you make changes to any of the following parameters: imageId, versionId, instanceTypeId or sessionStickiness.
@@ -259,7 +296,7 @@ def update(
259
296
  }
260
297
  ```
261
298
 
262
- 🔗 [**API Documentation**](https://service.peak.ai/webapps/api-docs/index.htm#/Webapps/update-webapp)
299
+ 🔗 [**API Documentation**](https://service.peak.ai/webapps/api-docs/index.htm#/Services/update-service)
263
300
  """
264
301
  webapp_client: Webapp = ctx.obj["client"]
265
302
  writer: Writer = ctx.obj["writer"]
@@ -282,7 +319,7 @@ def update(
282
319
 
283
320
  with writer.pager():
284
321
  response = webapp_client.update_webapp(webapp_id=webapp_id, body=body)
285
- writer.write(response)
322
+ writer.write(response, deprecation_message=DEPRECATION_MESSAGE)
286
323
 
287
324
 
288
325
  @app.command(short_help="Create a new webapp or Update an existing webapp.", options_metavar="create_or_update_webapp")
@@ -303,6 +340,14 @@ def create_or_update(
303
340
  ) -> None:
304
341
  """***Create*** a new webapp or ***Update*** an existing webapp based on webapp name and start its deployment.
305
342
 
343
+ \b
344
+ ```yaml
345
+ NOTE: The Web Apps commands are deprecated and will eventually be removed. It is recommended that users begin transitioning to the Service commands, which offers all the features of Webapp along with the added capability of API deployment and other significant updates for enhanced functionality. Transitioning early to the Service commands will ensure easier adoption of its advanced features and future updates.
346
+ ```
347
+
348
+ \b
349
+ For more information on Services, please refer to the [**Service**](https://docs.peak.ai/sdk/latest/cli/reference.html#peak-services) documentation.
350
+
306
351
  \b
307
352
  When updating the webapp, it will trigger a redeployment only under specific conditions.
308
353
  Redeployment is triggered if you make changes to any of the following parameters: imageId, versionId, instanceTypeId or sessionStickiness.
@@ -343,7 +388,7 @@ def create_or_update(
343
388
  }
344
389
  ```
345
390
 
346
- 🔗 [**API Documentation**](https://service.peak.ai/webapps/api-docs/index.htm#/Webapps/create-webapp)
391
+ 🔗 [**API Documentation**](https://service.peak.ai/webapps/api-docs/index.htm#/Services/create-service)
347
392
  """
348
393
  webapp_client: Webapp = ctx.obj["client"]
349
394
  writer: Writer = ctx.obj["writer"]
@@ -367,7 +412,7 @@ def create_or_update(
367
412
  body = combine_dictionaries(body.get("body") or {}, user_options)
368
413
 
369
414
  response = webapp_client.create_or_update_webapp(body=body)
370
- writer.write(response)
415
+ writer.write(response, deprecation_message=DEPRECATION_MESSAGE)
371
416
 
372
417
 
373
418
  @app.command(short_help="Delete an existing webapp.", options_metavar="delete_webapp")
@@ -380,6 +425,14 @@ def delete(
380
425
  ) -> None:
381
426
  """***Delete*** an existing webapp.
382
427
 
428
+ \b
429
+ ```yaml
430
+ NOTE: The Web Apps commands are deprecated and will eventually be removed. It is recommended that users begin transitioning to the Service commands, which offers all the features of Webapp along with the added capability of API deployment and other significant updates for enhanced functionality. Transitioning early to the Service commands will ensure easier adoption of its advanced features and future updates.
431
+ ```
432
+
433
+ \b
434
+ For more information on Services, please refer to the [**Service**](https://docs.peak.ai/sdk/latest/cli/reference.html#peak-services) documentation.
435
+
383
436
  \b
384
437
  📝 ***Example usage:***<br/>
385
438
  ```bash
@@ -394,14 +447,14 @@ def delete(
394
447
  }
395
448
  ```
396
449
 
397
- 🔗 [**API Documentation**](https://service.peak.ai/webapps/api-docs/index.htm#/Webapps/delete-webapp)
450
+ 🔗 [**API Documentation**](https://service.peak.ai/webapps/api-docs/index.htm#/Services/delete-service)
398
451
  """
399
452
  webapp_client: Webapp = ctx.obj["client"]
400
453
  writer: Writer = ctx.obj["writer"]
401
454
 
402
455
  with writer.pager():
403
456
  response = webapp_client.delete_webapp(webapp_id=webapp_id)
404
- writer.write(response)
457
+ writer.write(response, deprecation_message=DEPRECATION_MESSAGE)
405
458
 
406
459
 
407
460
  @app.command(short_help="Describe details of a webapp.", options_metavar="describe_webapp")
@@ -413,6 +466,14 @@ def describe(
413
466
  ) -> None:
414
467
  """***Describe*** details for the specific webapp.
415
468
 
469
+ \b
470
+ ```yaml
471
+ NOTE: The Web Apps commands are deprecated and will eventually be removed. It is recommended that users begin transitioning to the Service commands, which offers all the features of Webapp along with the added capability of API deployment and other significant updates for enhanced functionality. Transitioning early to the Service commands will ensure easier adoption of its advanced features and future updates.
472
+ ```
473
+
474
+ \b
475
+ For more information on Services, please refer to the [**Service**](https://docs.peak.ai/sdk/latest/cli/reference.html#peak-services) documentation.
476
+
416
477
  \b
417
478
  📝 ***Example usage:***<br/>
418
479
  ```bash
@@ -442,11 +503,11 @@ def describe(
442
503
  }
443
504
  ```
444
505
 
445
- 🔗 [**API Documentation**](https://service.peak.ai/webapps/api-docs/index.htm#/Webapps/get-webapp)
506
+ 🔗 [**API Documentation**](https://service.peak.ai/webapps/api-docs/index.htm#/Services/get-service)
446
507
  """
447
508
  webapp_client: Webapp = ctx.obj["client"]
448
509
  writer: Writer = ctx.obj["writer"]
449
510
 
450
511
  with writer.pager():
451
512
  response = webapp_client.describe_webapp(webapp_id=webapp_id)
452
- writer.write(response)
513
+ writer.write(response, deprecation_message=DEPRECATION_MESSAGE)
@@ -106,7 +106,6 @@ def create(
106
106
  triggers (list(map) | required: false):
107
107
  - cron (string | required: false): A valid cron expression.
108
108
  webhook (boolean | required: false): Should be true if webhook type trigger is to be used.
109
- webhookPolicy (string | required: false): Policy of the webhook to be used. Should be "generate" when creating new worklfow.
110
109
  watchers (list(map) | required: false):
111
110
  - events (map):
112
111
  success (boolean | required: false): Whether to call event on success.
@@ -219,7 +218,6 @@ def update(
219
218
  triggers (list(map) | required: false):
220
219
  - cron (string | required: false): A valid cron expression.
221
220
  webhook (boolean | required: false): Should be true if webhook type trigger is to be used.
222
- webhookPolicy (string | required: false): Policy of the webhook to be used. Should be "generate" or "preserve".
223
221
  watchers (list(map) | required: false):
224
222
  - events (map):
225
223
  success (boolean | required: false): Whether to call event on success.
@@ -332,7 +330,6 @@ def create_or_update(
332
330
  triggers (list(map) | required: false):
333
331
  - cron (string | required: false): A valid cron expression.
334
332
  webhook (boolean | required: false): Should be true if webhook type trigger is to be used.
335
- webhookPolicy (string | required: false): Policy of the webhook to be used. Should be "generate" when creating new worklfow.
336
333
  watchers (list(map) | required: false):
337
334
  - events (map):
338
335
  success (boolean | required: false): Whether to call event on success.
@@ -475,7 +472,6 @@ def patch(
475
472
  triggers (list(map) | required: false):
476
473
  - cron (string | required: false): A valid cron expression.
477
474
  webhook (boolean | required: false): Should be true if webhook type trigger is to be used.
478
- webhookPolicy (string | required: false): Policy of the webhook to be used. Should be "generate" or "preserve".
479
475
  watchers (list(map) | required: false):
480
476
  - events (map):
481
477
  success (boolean | required: false): Whether to call event on success.
peak/helpers.py CHANGED
@@ -239,3 +239,30 @@ def download_logs_helper(
239
239
  if config.SOURCE == Sources.CLI:
240
240
  writer = Writer()
241
241
  writer.write(f"\nLog contents have been saved to: {file_name}")
242
+
243
+
244
+ def search_action(current_path: str, current_dict: Dict[str, Any], action: str) -> Dict[str, bool]:
245
+ """Search for a specified action within a nested dictionary structure and check if deeper levels exist.
246
+
247
+ Args:
248
+ current_path (str): The dot-separated path representing the feature hierarchy.
249
+ current_dict (Dict[str, Any]): The nested dictionary representing the permissions structure.
250
+ action (str): The action to search for (e.g., "read" or "write").
251
+
252
+ Returns:
253
+ bool: A dictionary with keys 'has_permission' indicating if the action is found and
254
+ 'deeper_levels' indicating if there are deeper levels that need specification.
255
+ """
256
+ keys = current_path.split(".")
257
+ for key in keys:
258
+ if key in current_dict:
259
+ current_dict = current_dict[key]
260
+ else:
261
+ return {"has_permission": False, "deeper_levels": False}
262
+
263
+ if "actions" in current_dict:
264
+ actions = current_dict["actions"]
265
+ has_permission = "*" in actions or action in actions or ("write" in actions and action == "read")
266
+ return {"has_permission": has_permission, "deeper_levels": False}
267
+
268
+ return {"has_permission": False, "deeper_levels": True}
peak/output.py CHANGED
@@ -24,6 +24,7 @@ from __future__ import annotations
24
24
 
25
25
  import contextlib
26
26
  import json
27
+ import sys
27
28
  from typing import Any, List
28
29
 
29
30
  import yaml
@@ -54,17 +55,21 @@ class Writer:
54
55
  def write(
55
56
  self,
56
57
  data: Any,
58
+ deprecation_message: str | None = None,
57
59
  ) -> None:
58
60
  """Write logs to the terminal.
59
61
 
60
62
  Args:
61
63
  data (Any): Data to be printed on the terminal.
62
64
  This handles dry-run, debug mode and exit code for the CLI.
65
+ deprecation_message (str, optional): Deprecation message to be printed on the terminal.
63
66
  """
64
67
  output_type = config.OUTPUT_TYPE
65
68
  table_params = config.TABLE_PARAMS
66
69
 
67
70
  if not config.DEBUG_MODE or self.ignore_debug_mode:
71
+ if deprecation_message:
72
+ self._print_deprecation_warning(deprecation_message)
68
73
  if output_type == OutputTypes.yaml.value:
69
74
  self.__yaml(data)
70
75
  elif output_type == OutputTypes.table.value:
@@ -178,5 +183,9 @@ class Writer:
178
183
  return console.pager(styles=True)
179
184
  return contextlib.nullcontext()
180
185
 
186
+ def _print_deprecation_warning(self, deprecation_message: str) -> None:
187
+ """Prints a deprecation warning message."""
188
+ print(f"\nNote: {deprecation_message}", file=sys.stderr) # noqa: T201
189
+
181
190
 
182
191
  __all__: List[str] = ["Writer"]
peak/press/blocks.py CHANGED
@@ -250,9 +250,6 @@ class Block(BaseClient):
250
250
  {
251
251
  "webhook": "boolean"
252
252
  },
253
- {
254
- "webhookPolicy": "string"
255
- }
256
253
  ],
257
254
  "watchers": [
258
255
  {
@@ -527,9 +524,6 @@ class Block(BaseClient):
527
524
  },
528
525
  {
529
526
  "webhook": "boolean"
530
- },
531
- {
532
- "webhookPolicy": "string"
533
527
  }
534
528
  ],
535
529
  "watchers": [
@@ -1271,15 +1265,16 @@ class Block(BaseClient):
1271
1265
  - "status" (str): The current status of the block. The platform resource status can be inferred from this.
1272
1266
 
1273
1267
  Example return value:
1274
- [
1275
- { "id": "12345",
1276
- "resource_id": "6789",
1277
- "kind": "workflow",
1278
- "name": "my-workflow",
1279
- "status": "deployed",
1280
- },
1281
- # Additional resources...
1282
- ]
1268
+ .. code-block:: json
1269
+
1270
+ [
1271
+ { "id": "12345",
1272
+ "resource_id": "6789",
1273
+ "kind": "workflow",
1274
+ "name": "my-workflow",
1275
+ "status": "deployed",
1276
+ },
1277
+ ]
1283
1278
 
1284
1279
  Raises:
1285
1280
  BadRequestException: The given parameters are invalid.
@@ -23,6 +23,6 @@ from __future__ import annotations
23
23
 
24
24
  from typing import List
25
25
 
26
- from peak.resources import artifacts, images, tenants, webapps, workflows
26
+ from peak.resources import artifacts, images, services, tenants, users, webapps, workflows
27
27
 
28
- __all__: List[str] = ["workflows", "images", "artifacts", "webapps", "tenants"]
28
+ __all__: List[str] = ["artifacts", "images", "services", "tenants", "users", "webapps", "workflows"]