peak-sdk 1.11.0__py3-none-any.whl → 1.13.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 +3 -2
- peak/_metadata.py +185 -1
- peak/_version.py +1 -1
- peak/callbacks.py +22 -2
- peak/cli/cli.py +2 -0
- peak/cli/helpers.py +2 -0
- peak/cli/metrics/__init__.py +21 -0
- peak/cli/metrics/metrics.py +707 -0
- peak/cli/press/apps/deployments.py +12 -6
- peak/cli/press/apps/specs.py +20 -0
- peak/cli/press/blocks/deployments.py +5 -6
- peak/cli/press/blocks/specs.py +2 -0
- peak/cli/press/deployments.py +49 -3
- peak/cli/resources/services.py +20 -5
- peak/handler.py +16 -7
- peak/metrics/__init__.py +26 -0
- peak/metrics/metrics.py +553 -0
- peak/output.py +9 -1
- peak/press/apps.py +100 -5
- peak/press/blocks.py +2 -0
- peak/press/deployments.py +35 -0
- peak/resources/__init__.py +10 -1
- peak/resources/services.py +5 -2
- peak/sample_yaml/metrics/create_collection.yaml +8 -0
- peak/sample_yaml/metrics/publish.yaml +6 -0
- peak/sample_yaml/metrics/query.yaml +25 -0
- peak/sample_yaml/press/apps/deployments/create_app_deployment.yaml +12 -0
- peak/sample_yaml/press/apps/deployments/create_app_deployment_revision.yaml +12 -0
- peak/sample_yaml/press/apps/specs/create_app_spec.yaml +63 -0
- peak/sample_yaml/press/apps/specs/create_app_spec_release.yaml +63 -0
- peak/sample_yaml/press/blocks/specs/service/api/create_block_spec.yaml +28 -28
- peak/sample_yaml/press/blocks/specs/service/api/create_block_spec_release.yaml +28 -28
- peak/sample_yaml/press/blocks/specs/service/webapp/create_block_spec.yaml +29 -28
- peak/sample_yaml/press/blocks/specs/service/webapp/create_block_spec_release.yaml +29 -28
- peak/sample_yaml/press/blocks/specs/workflow/create_block_spec.yaml +32 -32
- peak/sample_yaml/press/blocks/specs/workflow/create_block_spec_release.yaml +32 -32
- peak/sample_yaml/press/patch_parameters.yaml +9 -0
- peak/sample_yaml/resources/services/create_or_update_service.yaml +1 -0
- peak/sample_yaml/resources/services/create_service.yaml +1 -0
- peak/sample_yaml/resources/services/update_service.yaml +1 -0
- peak/sample_yaml/resources/webapps/create_or_update_webapp.yaml +1 -0
- peak/sample_yaml/resources/webapps/create_webapp.yaml +1 -0
- peak/sample_yaml/resources/webapps/update_webapp.yaml +1 -0
- {peak_sdk-1.11.0.dist-info → peak_sdk-1.13.0.dist-info}/METADATA +45 -7
- {peak_sdk-1.11.0.dist-info → peak_sdk-1.13.0.dist-info}/RECORD +48 -40
- {peak_sdk-1.11.0.dist-info → peak_sdk-1.13.0.dist-info}/LICENSE +0 -0
- {peak_sdk-1.11.0.dist-info → peak_sdk-1.13.0.dist-info}/WHEEL +0 -0
- {peak_sdk-1.11.0.dist-info → peak_sdk-1.13.0.dist-info}/entry_points.txt +0 -0
peak/__init__.py
CHANGED
@@ -24,13 +24,14 @@ Copyright © 2024 Peak AI
|
|
24
24
|
|
25
25
|
Unauthorized copying of this file, via any medium is strictly prohibited.
|
26
26
|
"""
|
27
|
+
|
27
28
|
from __future__ import annotations
|
28
29
|
|
29
30
|
from typing import List
|
30
31
|
|
31
|
-
from peak import press, resources, tools
|
32
|
+
from peak import metrics, press, resources, tools
|
32
33
|
from peak.session import Session
|
33
34
|
|
34
35
|
from ._version import __version__
|
35
36
|
|
36
|
-
__all__: List[str] = ["Session", "press", "resources", "tools", "__version__"]
|
37
|
+
__all__: List[str] = ["Session", "metrics", "press", "resources", "tools", "__version__"]
|
peak/_metadata.py
CHANGED
@@ -695,6 +695,168 @@ command_metadata: Dict[str, Any] = {
|
|
695
695
|
"subheader_key": "templateCount",
|
696
696
|
},
|
697
697
|
},
|
698
|
+
"metrics>list": {
|
699
|
+
"table_params": {
|
700
|
+
"output_keys": {
|
701
|
+
"name": {
|
702
|
+
"label": "Name",
|
703
|
+
},
|
704
|
+
"type": {
|
705
|
+
"label": "Type",
|
706
|
+
},
|
707
|
+
"description": {
|
708
|
+
"label": "Description",
|
709
|
+
},
|
710
|
+
"collectionId": {
|
711
|
+
"label": "Collection ID",
|
712
|
+
},
|
713
|
+
"publicationId": {
|
714
|
+
"label": "Publication ID",
|
715
|
+
},
|
716
|
+
"metadata": {
|
717
|
+
"label": "Metadata",
|
718
|
+
},
|
719
|
+
},
|
720
|
+
"title": "Metrics",
|
721
|
+
"data_key": "data",
|
722
|
+
"subheader_key": "totalCount",
|
723
|
+
},
|
724
|
+
},
|
725
|
+
"metrics>list>measure": {
|
726
|
+
"table_params": {
|
727
|
+
"output_keys": {
|
728
|
+
"name": {
|
729
|
+
"label": "Name",
|
730
|
+
},
|
731
|
+
"type": {
|
732
|
+
"label": "Type",
|
733
|
+
},
|
734
|
+
"aggType": {
|
735
|
+
"label": "Aggregation Type",
|
736
|
+
},
|
737
|
+
"cube": {
|
738
|
+
"label": "Cube",
|
739
|
+
},
|
740
|
+
"description": {
|
741
|
+
"label": "Description",
|
742
|
+
},
|
743
|
+
"collectionId": {
|
744
|
+
"label": "Collection ID",
|
745
|
+
},
|
746
|
+
"publicationId": {
|
747
|
+
"label": "Publication ID",
|
748
|
+
},
|
749
|
+
"metadata": {
|
750
|
+
"label": "Metadata",
|
751
|
+
},
|
752
|
+
},
|
753
|
+
"title": "Measures",
|
754
|
+
"data_key": "data",
|
755
|
+
"subheader_key": "totalCount",
|
756
|
+
},
|
757
|
+
},
|
758
|
+
"metrics>list>dimension": {
|
759
|
+
"table_params": {
|
760
|
+
"output_keys": {
|
761
|
+
"name": {
|
762
|
+
"label": "Name",
|
763
|
+
},
|
764
|
+
"type": {
|
765
|
+
"label": "Type",
|
766
|
+
},
|
767
|
+
"primaryKey": {
|
768
|
+
"label": "Primary Key",
|
769
|
+
},
|
770
|
+
"cube": {
|
771
|
+
"label": "Cube",
|
772
|
+
},
|
773
|
+
"description": {
|
774
|
+
"label": "Description",
|
775
|
+
},
|
776
|
+
"collectionId": {
|
777
|
+
"label": "Collection ID",
|
778
|
+
},
|
779
|
+
"publicationId": {
|
780
|
+
"label": "Publication ID",
|
781
|
+
},
|
782
|
+
"metadata": {
|
783
|
+
"label": "Metadata",
|
784
|
+
},
|
785
|
+
},
|
786
|
+
"title": "Dimensions",
|
787
|
+
"data_key": "data",
|
788
|
+
"subheader_key": "totalCount",
|
789
|
+
},
|
790
|
+
},
|
791
|
+
"metrics>list>segment": {
|
792
|
+
"table_params": {
|
793
|
+
"output_keys": {
|
794
|
+
"name": {
|
795
|
+
"label": "Name",
|
796
|
+
},
|
797
|
+
"cube": {
|
798
|
+
"label": "Cube",
|
799
|
+
},
|
800
|
+
"description": {
|
801
|
+
"label": "Description",
|
802
|
+
},
|
803
|
+
"collectionId": {
|
804
|
+
"label": "Collection ID",
|
805
|
+
},
|
806
|
+
"publicationId": {
|
807
|
+
"label": "Publication ID",
|
808
|
+
},
|
809
|
+
"metadata": {
|
810
|
+
"label": "Metadata",
|
811
|
+
},
|
812
|
+
},
|
813
|
+
"title": "Segments",
|
814
|
+
"data_key": "data",
|
815
|
+
"subheader_key": "totalCount",
|
816
|
+
},
|
817
|
+
},
|
818
|
+
"metrics>list-collections": {
|
819
|
+
"table_params": {
|
820
|
+
"output_keys": {
|
821
|
+
"id": {
|
822
|
+
"label": "ID",
|
823
|
+
},
|
824
|
+
"name": {
|
825
|
+
"label": "Name",
|
826
|
+
},
|
827
|
+
"description": {
|
828
|
+
"label": "Description",
|
829
|
+
},
|
830
|
+
"scope": {
|
831
|
+
"label": "Scope",
|
832
|
+
},
|
833
|
+
"createdAt": {
|
834
|
+
"label": "Created At",
|
835
|
+
},
|
836
|
+
"createdBy": {
|
837
|
+
"label": "Created By",
|
838
|
+
},
|
839
|
+
},
|
840
|
+
"title": "Collections",
|
841
|
+
"data_key": "collections",
|
842
|
+
"subheader_key": "totalCount",
|
843
|
+
},
|
844
|
+
},
|
845
|
+
"metrics>list-namespaces": {
|
846
|
+
"table_params": {
|
847
|
+
"output_keys": {
|
848
|
+
"name": {
|
849
|
+
"label": "Name",
|
850
|
+
},
|
851
|
+
"models": {
|
852
|
+
"label": "Models",
|
853
|
+
},
|
854
|
+
},
|
855
|
+
"title": "Namespaces",
|
856
|
+
"data_key": "namespaces",
|
857
|
+
"subheader_key": "totalCount",
|
858
|
+
},
|
859
|
+
},
|
698
860
|
"artifacts>create": {
|
699
861
|
"request_body_yaml_path": "sample_yaml/resources/artifacts/create_artifact.yaml",
|
700
862
|
},
|
@@ -794,6 +956,28 @@ command_metadata: Dict[str, Any] = {
|
|
794
956
|
"blocks>deployments>patch-parameters": {
|
795
957
|
"request_body_yaml_path": "sample_yaml/press/blocks/deployments/patch_block_parameters.yaml",
|
796
958
|
},
|
959
|
+
"deployments>patch-parameters": {
|
960
|
+
"request_body_yaml_path": "sample_yaml/press/patch_parameters.yaml",
|
961
|
+
},
|
962
|
+
"metrics>publish": {
|
963
|
+
"request_body_yaml_path": "sample_yaml/metrics/publish.yaml",
|
964
|
+
},
|
965
|
+
"metrics>query": {
|
966
|
+
"request_body_yaml_path": "sample_yaml/metrics/query.yaml",
|
967
|
+
"table_params": {
|
968
|
+
"output_keys": {},
|
969
|
+
"title": "Query Data",
|
970
|
+
"data_key": "data",
|
971
|
+
"subheader_key": "totalCount",
|
972
|
+
},
|
973
|
+
},
|
974
|
+
"metrics>create-collection": {
|
975
|
+
"request_body_yaml_path": "sample_yaml/metrics/create_collection.yaml",
|
976
|
+
},
|
977
|
+
}
|
978
|
+
|
979
|
+
command_parameter: Dict[str, str] = {
|
980
|
+
"metrics>list": "type",
|
797
981
|
}
|
798
982
|
|
799
|
-
__all__: List[str] = ["command_metadata"]
|
983
|
+
__all__: List[str] = ["command_metadata", "command_parameter"]
|
peak/_version.py
CHANGED
peak/callbacks.py
CHANGED
@@ -27,7 +27,7 @@ import click
|
|
27
27
|
import typer
|
28
28
|
|
29
29
|
import peak.config
|
30
|
-
from peak._metadata import command_metadata
|
30
|
+
from peak._metadata import command_metadata, command_parameter
|
31
31
|
from peak.constants import OutputTypes
|
32
32
|
from peak.output import Writer
|
33
33
|
|
@@ -44,6 +44,20 @@ def paging(*, enable_paging: bool) -> None:
|
|
44
44
|
peak.config.ENABLE_PAGING = enable_paging
|
45
45
|
|
46
46
|
|
47
|
+
def update_command(ctx: typer.Context, command: str) -> str:
|
48
|
+
"""Callback to update the command based on the command parameter."""
|
49
|
+
if not ctx or not hasattr(ctx, "params") or command not in command_parameter:
|
50
|
+
return command
|
51
|
+
|
52
|
+
param = command_parameter[command]
|
53
|
+
param_value = ctx.params.get(param)
|
54
|
+
if param_value:
|
55
|
+
command_with_params = f"{command}>{param_value}"
|
56
|
+
if command_with_params in command_metadata and "table_params" in command_metadata[command_with_params]:
|
57
|
+
return command_with_params
|
58
|
+
return command
|
59
|
+
|
60
|
+
|
47
61
|
def get_full_command_name(ctx: typer.Context | click.core.Context | None) -> str:
|
48
62
|
"""Callback to get the full command name."""
|
49
63
|
if ctx:
|
@@ -66,6 +80,7 @@ def handle_output(output_type: OutputTypes, ctx: typer.Context) -> None:
|
|
66
80
|
peak.config.OUTPUT_TYPE = output_type
|
67
81
|
|
68
82
|
command = get_command_name(ctx)
|
83
|
+
command = update_command(ctx, command)
|
69
84
|
|
70
85
|
if (command not in command_metadata) or ("table_params" not in command_metadata[command]):
|
71
86
|
return
|
@@ -76,8 +91,13 @@ def handle_output(output_type: OutputTypes, ctx: typer.Context) -> None:
|
|
76
91
|
def generate_yaml(ctx: typer.Context, generate_yaml: bool) -> None: # noqa: FBT001 # pragma: no cover
|
77
92
|
"""Callback to generate yaml file."""
|
78
93
|
command = get_command_name(ctx)
|
94
|
+
output_type = peak.config.OUTPUT_TYPE
|
79
95
|
|
80
|
-
if (
|
96
|
+
if (
|
97
|
+
(command not in command_metadata)
|
98
|
+
or ("request_body_yaml_path" not in command_metadata[command])
|
99
|
+
or output_type == "table"
|
100
|
+
):
|
81
101
|
return
|
82
102
|
|
83
103
|
if generate_yaml:
|
peak/cli/cli.py
CHANGED
@@ -24,6 +24,7 @@ import sys
|
|
24
24
|
import peak.config
|
25
25
|
import typer
|
26
26
|
from peak.cli import args, helpers
|
27
|
+
from peak.cli.metrics import metrics
|
27
28
|
from peak.cli.press import apps, blocks, deployments, specs
|
28
29
|
from peak.cli.resources import alerts, artifacts, images, services, tenants, users, webapps, workflows
|
29
30
|
from peak.constants import Sources
|
@@ -34,6 +35,7 @@ typer.rich_utils.STYLE_HELPTEXT = ""
|
|
34
35
|
|
35
36
|
typer_app = typer.Typer(rich_markup_mode="markdown", help="Create and Manage Peak Resources")
|
36
37
|
typer_app.add_typer(images.app, name="images")
|
38
|
+
typer_app.add_typer(metrics.app, name="metrics")
|
37
39
|
typer_app.add_typer(alerts.app, name="alerts")
|
38
40
|
typer_app.add_typer(artifacts.app, name="artifacts")
|
39
41
|
typer_app.add_typer(workflows.app, name="workflows")
|
peak/cli/helpers.py
CHANGED
@@ -31,6 +31,7 @@ import yaml
|
|
31
31
|
from peak import base_client, press, resources
|
32
32
|
from peak.exceptions import BadParameterException
|
33
33
|
from peak.helpers import format_date, remove_none_values
|
34
|
+
from peak.metrics import metrics
|
34
35
|
from peak.template import load_template
|
35
36
|
from rich.console import Console
|
36
37
|
|
@@ -257,5 +258,6 @@ def get_client(command: str) -> base_client.BaseClient:
|
|
257
258
|
"tenants": resources.tenants,
|
258
259
|
"users": resources.users,
|
259
260
|
"alerts": resources.alerts,
|
261
|
+
"metrics": metrics,
|
260
262
|
}
|
261
263
|
return command_client_map[command].get_client() # type: ignore[no-any-return]
|
@@ -0,0 +1,21 @@
|
|
1
|
+
#
|
2
|
+
# # Copyright © 2024 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
|
+
"""CLI module for Peak Metrics."""
|