peak-sdk 1.2.1__py3-none-any.whl → 1.4.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.
- peak/__init__.py +1 -1
- peak/_metadata.py +43 -0
- peak/_version.py +1 -1
- peak/cli/args.py +9 -0
- peak/cli/cli.py +2 -1
- peak/cli/helpers.py +50 -1
- peak/cli/press/apps/deployments.py +6 -2
- peak/cli/press/apps/specs.py +4 -2
- peak/cli/press/blocks/deployments.py +43 -2
- peak/cli/press/blocks/specs.py +4 -4
- peak/cli/resources/services.py +632 -0
- peak/cli/resources/webapps.py +75 -14
- peak/cli/resources/workflows.py +0 -4
- peak/output.py +9 -0
- peak/press/blocks.py +105 -13
- peak/resources/__init__.py +2 -2
- peak/resources/services.py +413 -0
- peak/resources/webapps.py +13 -7
- peak/resources/workflows.py +0 -4
- peak/sample_yaml/resources/services/create_or_update_service.yaml +24 -0
- peak/sample_yaml/resources/services/create_service.yaml +24 -0
- peak/sample_yaml/resources/services/test_service.yaml +8 -0
- peak/sample_yaml/resources/services/update_service.yaml +22 -0
- peak/sample_yaml/resources/workflows/create_or_update_workflow.yaml +0 -1
- peak/sample_yaml/resources/workflows/update_workflow.yaml +0 -1
- peak/template.py +9 -1
- {peak_sdk-1.2.1.dist-info → peak_sdk-1.4.0.dist-info}/LICENSE +1 -1
- {peak_sdk-1.2.1.dist-info → peak_sdk-1.4.0.dist-info}/METADATA +2 -2
- {peak_sdk-1.2.1.dist-info → peak_sdk-1.4.0.dist-info}/RECORD +31 -25
- {peak_sdk-1.2.1.dist-info → peak_sdk-1.4.0.dist-info}/WHEEL +0 -0
- {peak_sdk-1.2.1.dist-info → peak_sdk-1.4.0.dist-info}/entry_points.txt +0 -0
peak/cli/resources/webapps.py
CHANGED
@@ -20,7 +20,14 @@
|
|
20
20
|
#
|
21
21
|
|
22
22
|
#
|
23
|
-
|
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.
|
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#/
|
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#/
|
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#/
|
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#/
|
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#/
|
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#/
|
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)
|
peak/cli/resources/workflows.py
CHANGED
@@ -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/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
|
{
|
@@ -342,7 +339,7 @@ class Block(BaseClient):
|
|
342
339
|
🔗 `API Documentation <https://press.peak.ai/api-docs/index.htm#/Block%20Specs/get_v1_blocks_specs__specId_>`__
|
343
340
|
|
344
341
|
Args:
|
345
|
-
spec_id (str): The ID of the
|
342
|
+
spec_id (str): The ID of the block spec to retrieve.
|
346
343
|
|
347
344
|
Returns:
|
348
345
|
Dict[str, Any]: Dictionary containing the details of the spec.
|
@@ -351,7 +348,7 @@ class Block(BaseClient):
|
|
351
348
|
BadRequestException: The given parameters are invalid.
|
352
349
|
UnauthorizedException: The credentials are invalid.
|
353
350
|
ForbiddenException: The user does not have permission to perform the operation.
|
354
|
-
NotFoundException: The given
|
351
|
+
NotFoundException: The given block spec does not exist.
|
355
352
|
InternalServerErrorException: The server encountered an unexpected condition that
|
356
353
|
prevented it from fulfilling the request.
|
357
354
|
"""
|
@@ -406,7 +403,7 @@ class Block(BaseClient):
|
|
406
403
|
BadRequestException: The given parameters are invalid.
|
407
404
|
UnauthorizedException: The credentials are invalid.
|
408
405
|
ForbiddenException: The user does not have permission to perform the operation.
|
409
|
-
NotFoundException: The given
|
406
|
+
NotFoundException: The given block spec does not exist.
|
410
407
|
UnprocessableEntityException: The server was unable to process the request.
|
411
408
|
InternalServerErrorException: The server encountered an unexpected condition that
|
412
409
|
prevented it from fulfilling the request.
|
@@ -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": [
|
@@ -754,7 +748,7 @@ class Block(BaseClient):
|
|
754
748
|
BadRequestException: The given parameters are invalid.
|
755
749
|
UnauthorizedException: The credentials are invalid.
|
756
750
|
ForbiddenException: The user does not have permission to perform the operation.
|
757
|
-
NotFoundException: The given
|
751
|
+
NotFoundException: The given block spec release does not exist.
|
758
752
|
UnprocessableEntityException: The server was unable to process the request.
|
759
753
|
InternalServerErrorException: The server encountered an unexpected condition that
|
760
754
|
prevented it from fulfilling the request.
|
@@ -935,7 +929,7 @@ class Block(BaseClient):
|
|
935
929
|
BadRequestException: The given parameters are invalid.
|
936
930
|
UnauthorizedException: The credentials are invalid.
|
937
931
|
ForbiddenException: The user does not have permission to perform the operation.
|
938
|
-
NotFoundException: The given
|
932
|
+
NotFoundException: The given block spec does not exist.
|
939
933
|
UnprocessableEntityException: The server was unable to process the request.
|
940
934
|
InternalServerErrorException: The server encountered an unexpected condition that
|
941
935
|
prevented it from fulfilling the request.
|
@@ -1250,15 +1244,113 @@ class Block(BaseClient):
|
|
1250
1244
|
subdomain="press",
|
1251
1245
|
)
|
1252
1246
|
|
1247
|
+
def get_related_block_details(
|
1248
|
+
self,
|
1249
|
+
deployment_id: Optional[str] = None,
|
1250
|
+
fallback_details_file: Optional[str] = None,
|
1251
|
+
) -> List[Dict[str, Any]]:
|
1252
|
+
"""Get the info for related blocks within an app.
|
1253
|
+
|
1254
|
+
Args:
|
1255
|
+
deployment_id (str | None): The ID of the deployment.
|
1256
|
+
fallback_details_file (str | None): Path of the YAML file to be used when deployment_id is not present. should be a List of Dicts
|
1257
|
+
|
1258
|
+
Returns:
|
1259
|
+
A list of dictionaries, where each dictionary represents a block with the following keys:
|
1260
|
+
- "id" (str): The unique identifier of the block
|
1261
|
+
- "resource_id" (str | None): The unique identifier of the block's main platform resource.
|
1262
|
+
May be None if resource has been manually deleted or is awaiting creation
|
1263
|
+
- "kind" (str): The type or category of the resource.
|
1264
|
+
- "name" (str): The name of the resource.
|
1265
|
+
- "status" (str): The current status of the block. The platform resource status can be inferred from this.
|
1266
|
+
|
1267
|
+
Example return value:
|
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
|
+
]
|
1278
|
+
|
1279
|
+
Raises:
|
1280
|
+
BadRequestException: The given parameters are invalid.
|
1281
|
+
UnauthorizedException: The credentials are invalid.
|
1282
|
+
ForbiddenException: The user does not have permission to perform the operation.
|
1283
|
+
NotFoundException: The given deployment does not exist.
|
1284
|
+
InternalServerErrorException: The server encountered an unexpected condition that
|
1285
|
+
prevented it from fulfilling the request.
|
1286
|
+
TypeError: The YAML file is invalid.
|
1287
|
+
ValueError: The YAML file is empty.
|
1288
|
+
FileNotFoundError: File specified in fallback_details_file is not present.
|
1289
|
+
"""
|
1290
|
+
final_deployment_id = os.getenv("PRESS_DEPLOYMENT_ID", deployment_id)
|
1291
|
+
|
1292
|
+
if not final_deployment_id:
|
1293
|
+
if not fallback_details_file:
|
1294
|
+
msg = "Please pass in a fallback details file when deployment id is not present"
|
1295
|
+
raise TypeError(msg) from None
|
1296
|
+
|
1297
|
+
file_path = Path(fallback_details_file)
|
1298
|
+
if not file_path.is_file():
|
1299
|
+
msg = f"File - {fallback_details_file} does not exist. Please check the path again."
|
1300
|
+
raise FileNotFoundError(msg) from None
|
1301
|
+
|
1302
|
+
with file_path.open() as file:
|
1303
|
+
file_content = file.read().strip()
|
1304
|
+
if not file_content:
|
1305
|
+
msg = f"{fallback_details_file} is an empty YAML file."
|
1306
|
+
raise ValueError(msg)
|
1307
|
+
|
1308
|
+
try:
|
1309
|
+
return list(yaml.safe_load(file_content))
|
1310
|
+
|
1311
|
+
except yaml.YAMLError:
|
1312
|
+
msg = f"{fallback_details_file} is not a valid YAML. Please validate the file content."
|
1313
|
+
raise TypeError(msg) from None
|
1314
|
+
|
1315
|
+
this_block = self.session.create_request(
|
1316
|
+
f"v1/blocks/deployments/{final_deployment_id}",
|
1317
|
+
HttpMethods.GET,
|
1318
|
+
content_type=ContentType.APPLICATION_JSON,
|
1319
|
+
subdomain="press",
|
1320
|
+
)
|
1321
|
+
|
1322
|
+
if not isinstance(this_block, dict) or this_block.get("parent") is None:
|
1323
|
+
return []
|
1324
|
+
|
1325
|
+
parent_id = this_block["parent"].get("id")
|
1326
|
+
|
1327
|
+
this_app = self.session.create_request(
|
1328
|
+
f"v1/apps/deployments/{parent_id}",
|
1329
|
+
HttpMethods.GET,
|
1330
|
+
content_type=ContentType.APPLICATION_JSON,
|
1331
|
+
subdomain="press",
|
1332
|
+
)
|
1333
|
+
|
1334
|
+
return [
|
1335
|
+
{
|
1336
|
+
"id": block["deploymentId"],
|
1337
|
+
"resource_id": block["platformId"],
|
1338
|
+
"kind": block["kind"],
|
1339
|
+
"name": block["name"],
|
1340
|
+
"status": block["status"],
|
1341
|
+
}
|
1342
|
+
for block in this_app["latestRevision"]["blocks"]
|
1343
|
+
]
|
1344
|
+
|
1253
1345
|
|
1254
1346
|
def get_client(session: Optional[Session] = None) -> Block:
|
1255
|
-
"""Returns a
|
1347
|
+
"""Returns a Block client.
|
1256
1348
|
|
1257
1349
|
Args:
|
1258
1350
|
session (Optional[Session]): A Session Object. If no session is provided, a default session is used.
|
1259
1351
|
|
1260
1352
|
Returns:
|
1261
|
-
Block: the
|
1353
|
+
Block: the Block client object
|
1262
1354
|
"""
|
1263
1355
|
return Block(session)
|
1264
1356
|
|
peak/resources/__init__.py
CHANGED
@@ -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, webapps, workflows
|
27
27
|
|
28
|
-
__all__: List[str] = ["workflows", "images", "artifacts", "webapps", "tenants"]
|
28
|
+
__all__: List[str] = ["workflows", "images", "artifacts", "webapps", "tenants", "services"]
|