pygeai 0.6.0b13__py3-none-any.whl → 0.6.1__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.
- pygeai/__init__.py +1 -2
- pygeai/_docs/source/content/api_reference/project.rst +392 -0
- pygeai/_docs/source/content/authentication.rst +130 -1
- pygeai/_docs/source/content/debugger.rst +327 -157
- pygeai/_docs/source/content/migration.rst +391 -7
- pygeai/_docs/source/pygeai.core.common.rst +8 -0
- pygeai/_docs/source/pygeai.tests.auth.rst +56 -0
- pygeai/_docs/source/pygeai.tests.cli.rst +8 -0
- pygeai/admin/clients.py +1 -3
- pygeai/analytics/clients.py +1 -1
- pygeai/assistant/clients.py +2 -7
- pygeai/assistant/data/clients.py +0 -8
- pygeai/assistant/data_analyst/clients.py +0 -2
- pygeai/assistant/managers.py +1 -1
- pygeai/assistant/rag/clients.py +0 -2
- pygeai/assistant/rag/mappers.py +9 -11
- pygeai/auth/clients.py +26 -7
- pygeai/auth/endpoints.py +2 -1
- pygeai/chat/clients.py +2 -2
- pygeai/chat/managers.py +1 -1
- pygeai/cli/commands/admin.py +13 -25
- pygeai/cli/commands/analytics.py +56 -88
- pygeai/cli/commands/assistant.py +84 -138
- pygeai/cli/commands/auth.py +23 -46
- pygeai/cli/commands/base.py +0 -1
- pygeai/cli/commands/chat.py +218 -209
- pygeai/cli/commands/common.py +5 -5
- pygeai/cli/commands/configuration.py +79 -29
- pygeai/cli/commands/docs.py +3 -4
- pygeai/cli/commands/embeddings.py +13 -19
- pygeai/cli/commands/evaluation.py +133 -344
- pygeai/cli/commands/feedback.py +7 -15
- pygeai/cli/commands/files.py +26 -53
- pygeai/cli/commands/gam.py +28 -69
- pygeai/cli/commands/lab/ai_lab.py +96 -142
- pygeai/cli/commands/lab/common.py +1 -1
- pygeai/cli/commands/lab/spec.py +12 -32
- pygeai/cli/commands/llm.py +9 -18
- pygeai/cli/commands/migrate.py +43 -99
- pygeai/cli/commands/organization.py +223 -196
- pygeai/cli/commands/rag.py +35 -58
- pygeai/cli/commands/rerank.py +21 -25
- pygeai/cli/commands/secrets.py +39 -67
- pygeai/cli/commands/usage_limits.py +50 -136
- pygeai/cli/commands/validators.py +1 -1
- pygeai/cli/geai.py +32 -3
- pygeai/cli/geai_proxy.py +6 -2
- pygeai/cli/install_man.py +1 -1
- pygeai/cli/parsers.py +1 -1
- pygeai/core/base/clients.py +90 -21
- pygeai/core/base/mappers.py +39 -55
- pygeai/core/base/session.py +134 -22
- pygeai/core/common/config.py +50 -13
- pygeai/core/common/constants.py +8 -0
- pygeai/core/common/exceptions.py +6 -0
- pygeai/core/embeddings/clients.py +0 -1
- pygeai/core/embeddings/managers.py +0 -1
- pygeai/core/feedback/clients.py +0 -2
- pygeai/core/feedback/models.py +1 -1
- pygeai/core/files/clients.py +0 -3
- pygeai/core/files/managers.py +1 -1
- pygeai/core/files/mappers.py +4 -5
- pygeai/core/llm/clients.py +0 -1
- pygeai/core/models.py +4 -4
- pygeai/core/plugins/clients.py +0 -3
- pygeai/core/plugins/models.py +2 -2
- pygeai/core/rerank/clients.py +0 -2
- pygeai/core/secrets/clients.py +0 -2
- pygeai/core/services/rest.py +80 -14
- pygeai/core/singleton.py +24 -0
- pygeai/dbg/__init__.py +2 -2
- pygeai/dbg/debugger.py +276 -38
- pygeai/evaluation/clients.py +2 -4
- pygeai/evaluation/dataset/clients.py +0 -1
- pygeai/evaluation/plan/clients.py +0 -2
- pygeai/evaluation/result/clients.py +0 -2
- pygeai/gam/clients.py +1 -3
- pygeai/health/clients.py +1 -3
- pygeai/lab/clients.py +0 -1
- pygeai/lab/managers.py +0 -1
- pygeai/lab/models.py +0 -1
- pygeai/lab/strategies/clients.py +1 -2
- pygeai/lab/tools/clients.py +2 -2
- pygeai/lab/tools/mappers.py +1 -1
- pygeai/migration/strategies.py +5 -6
- pygeai/migration/tools.py +1 -1
- pygeai/organization/clients.py +118 -12
- pygeai/organization/endpoints.py +1 -0
- pygeai/organization/limits/clients.py +4 -6
- pygeai/organization/limits/managers.py +1 -4
- pygeai/organization/managers.py +2 -2
- pygeai/proxy/config.py +1 -0
- pygeai/proxy/managers.py +6 -5
- pygeai/tests/admin/test_clients.py +11 -11
- pygeai/tests/assistants/rag/test_clients.py +1 -1
- pygeai/tests/assistants/rag/test_models.py +1 -2
- pygeai/tests/assistants/test_clients.py +1 -1
- pygeai/tests/assistants/test_managers.py +1 -3
- pygeai/tests/auth/test_cli_configuration.py +252 -0
- pygeai/tests/auth/test_client_initialization.py +411 -0
- pygeai/tests/auth/test_clients.py +29 -27
- pygeai/tests/auth/test_config_manager.py +305 -0
- pygeai/tests/auth/test_header_injection.py +294 -0
- pygeai/tests/auth/test_oauth.py +3 -1
- pygeai/tests/auth/test_session_logging.py +119 -0
- pygeai/tests/auth/test_session_validation.py +408 -0
- pygeai/tests/auth/test_singleton_reset.py +201 -0
- pygeai/tests/chat/test_clients.py +1 -1
- pygeai/tests/chat/test_iris.py +1 -1
- pygeai/tests/chat/test_ui.py +0 -2
- pygeai/tests/cli/commands/lab/test_ai_lab.py +1 -3
- pygeai/tests/cli/commands/lab/test_common.py +0 -1
- pygeai/tests/cli/commands/test_chat.py +1 -1
- pygeai/tests/cli/commands/test_common.py +0 -1
- pygeai/tests/cli/commands/test_embeddings.py +2 -2
- pygeai/tests/cli/commands/test_evaluation.py +1 -9
- pygeai/tests/cli/commands/test_llm.py +1 -1
- pygeai/tests/cli/commands/test_migrate.py +1 -1
- pygeai/tests/cli/commands/test_rerank.py +0 -1
- pygeai/tests/cli/commands/test_secrets.py +1 -1
- pygeai/tests/cli/commands/test_show_help.py +0 -1
- pygeai/tests/cli/commands/test_validators.py +0 -1
- pygeai/tests/cli/test_credentials_flag.py +312 -0
- pygeai/tests/cli/test_error_handler.py +0 -1
- pygeai/tests/core/base/test_mappers.py +2 -2
- pygeai/tests/core/base/test_models.py +4 -4
- pygeai/tests/core/common/test_config.py +2 -7
- pygeai/tests/core/common/test_decorators.py +0 -1
- pygeai/tests/core/embeddings/test_managers.py +1 -1
- pygeai/tests/core/feedback/test_clients.py +2 -2
- pygeai/tests/core/files/test_clients.py +6 -6
- pygeai/tests/core/files/test_models.py +0 -1
- pygeai/tests/core/files/test_responses.py +0 -1
- pygeai/tests/core/llm/test_clients.py +1 -1
- pygeai/tests/core/plugins/test_clients.py +4 -4
- pygeai/tests/core/rerank/test_mappers.py +1 -3
- pygeai/tests/core/secrets/test_clients.py +2 -3
- pygeai/tests/core/services/test_rest.py +10 -10
- pygeai/tests/core/utils/test_console.py +0 -1
- pygeai/tests/dbg/test_debugger.py +95 -8
- pygeai/tests/evaluation/dataset/test_clients.py +24 -27
- pygeai/tests/evaluation/plan/test_clients.py +16 -18
- pygeai/tests/evaluation/result/test_clients.py +4 -5
- pygeai/tests/health/test_clients.py +2 -2
- pygeai/tests/integration/lab/agents/test_create_agent.py +1 -3
- pygeai/tests/integration/lab/agents/test_get_agent.py +1 -1
- pygeai/tests/integration/lab/processes/test_create_process.py +2 -2
- pygeai/tests/integration/lab/processes/test_create_task.py +2 -3
- pygeai/tests/integration/lab/processes/test_delete_process.py +0 -1
- pygeai/tests/integration/lab/processes/test_get_process.py +2 -4
- pygeai/tests/integration/lab/processes/test_list_process_instances.py +1 -3
- pygeai/tests/integration/lab/processes/test_update_process.py +3 -9
- pygeai/tests/integration/lab/reasoning_strategies/test_update_reasoning_strategy.py +1 -2
- pygeai/tests/integration/lab/tools/test_delete_tool.py +1 -1
- pygeai/tests/integration/lab/tools/test_list_tools.py +1 -1
- pygeai/tests/integration/lab/tools/test_update_tool.py +1 -1
- pygeai/tests/lab/agents/test_clients.py +17 -17
- pygeai/tests/lab/processes/test_clients.py +67 -67
- pygeai/tests/lab/processes/test_mappers.py +23 -23
- pygeai/tests/lab/spec/test_loader.py +0 -2
- pygeai/tests/lab/spec/test_parsers.py +1 -2
- pygeai/tests/lab/strategies/test_clients.py +10 -10
- pygeai/tests/lab/test_managers.py +3 -5
- pygeai/tests/lab/test_mappers.py +1 -4
- pygeai/tests/lab/tools/test_clients.py +21 -21
- pygeai/tests/lab/tools/test_mappers.py +0 -1
- pygeai/tests/organization/limits/test_clients.py +33 -33
- pygeai/tests/organization/limits/test_managers.py +7 -7
- pygeai/tests/organization/test_clients.py +78 -60
- pygeai/tests/proxy/test_clients.py +1 -1
- pygeai/tests/proxy/test_integration.py +1 -4
- pygeai/tests/proxy/test_managers.py +1 -2
- pygeai/tests/proxy/test_servers.py +1 -2
- pygeai/tests/snippets/assistants/rag/delete_rag_assistant.py +0 -1
- pygeai/tests/snippets/assistants/rag/get_documents.py +0 -1
- pygeai/tests/snippets/assistants/rag/get_rag_assistant_data.py +0 -1
- pygeai/tests/snippets/chat/get_request_status.py +0 -1
- pygeai/tests/snippets/dbg/file_debugging.py +72 -0
- pygeai/tests/snippets/dbg/module_debugging.py +60 -0
- pygeai/tests/snippets/embeddings/cohere_example.py +2 -2
- pygeai/tests/snippets/embeddings/openai_base64_example.py +1 -1
- pygeai/tests/snippets/evaluation/dataset/complete_workflow_example.py +8 -8
- pygeai/tests/snippets/evaluation/plan/complete_workflow_example.py +5 -5
- pygeai/tests/snippets/evaluation/result/complete_workflow_example.py +3 -3
- pygeai/tests/snippets/lab/agentic_flow_example_1.py +1 -1
- pygeai/tests/snippets/lab/agentic_flow_example_2.py +3 -4
- pygeai/tests/snippets/lab/agents/create_agent_with_permissions.py +2 -2
- pygeai/tests/snippets/lab/agents/delete_agent.py +1 -2
- pygeai/tests/snippets/lab/agents/get_agent.py +1 -1
- pygeai/tests/snippets/lab/agents/get_agent_with_new_fields.py +10 -10
- pygeai/tests/snippets/lab/agents/get_sharing_link.py +0 -1
- pygeai/tests/snippets/lab/agents/list_agents.py +1 -1
- pygeai/tests/snippets/lab/agents/publish_agent_revision.py +0 -1
- pygeai/tests/snippets/lab/agents/update_agent_properties.py +1 -1
- pygeai/tests/snippets/lab/crud_ui.py +3 -5
- pygeai/tests/snippets/lab/processes/kbs/get_kb.py +0 -1
- pygeai/tests/snippets/lab/processes/kbs/list_kbs.py +0 -1
- pygeai/tests/snippets/lab/processes/list_processes.py +1 -1
- pygeai/tests/snippets/lab/samples/summarize_files.py +0 -3
- pygeai/tests/snippets/lab/strategies/get_reasoning_strategy.py +0 -1
- pygeai/tests/snippets/lab/strategies/list_reasoning_strategies.py +1 -1
- pygeai/tests/snippets/lab/tools/get_tool.py +1 -1
- pygeai/tests/snippets/lab/tools/publish_tool_revision.py +0 -1
- pygeai/tests/snippets/lab/tools/set_parameters.py +1 -2
- pygeai/tests/snippets/lab/use_cases/c_code_fixer_agent_flow.py +2 -3
- pygeai/tests/snippets/lab/use_cases/file_summarizer_example_2.py +1 -1
- pygeai/tests/snippets/lab/use_cases/update_cli_expert.py +0 -1
- pygeai/tests/snippets/lab/use_cases/update_lab_expert.py +0 -1
- pygeai/tests/snippets/lab/use_cases/update_web_designer.py +0 -1
- pygeai/tests/snippets/lab/use_cases/update_web_reader.py +0 -1
- pygeai/tests/snippets/migrate/orchestrator_examples.py +1 -1
- {pygeai-0.6.0b13.dist-info → pygeai-0.6.1.dist-info}/METADATA +32 -7
- {pygeai-0.6.0b13.dist-info → pygeai-0.6.1.dist-info}/RECORD +217 -206
- {pygeai-0.6.0b13.dist-info → pygeai-0.6.1.dist-info}/WHEEL +0 -0
- {pygeai-0.6.0b13.dist-info → pygeai-0.6.1.dist-info}/entry_points.txt +0 -0
- {pygeai-0.6.0b13.dist-info → pygeai-0.6.1.dist-info}/licenses/LICENSE +0 -0
- {pygeai-0.6.0b13.dist-info → pygeai-0.6.1.dist-info}/top_level.txt +0 -0
pygeai/cli/commands/rag.py
CHANGED
|
@@ -26,10 +26,8 @@ def get_assistants_from_project():
|
|
|
26
26
|
|
|
27
27
|
|
|
28
28
|
def get_assistant_detail(option_list: list):
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
if option_flag.name == "name":
|
|
32
|
-
name = option_arg
|
|
29
|
+
opts = {opt.name: arg for opt, arg in option_list}
|
|
30
|
+
name = opts.get("name")
|
|
33
31
|
|
|
34
32
|
if not name:
|
|
35
33
|
raise MissingRequirementException("Cannot retrieve assistant detail without name")
|
|
@@ -896,10 +894,8 @@ update_assistant_options = [
|
|
|
896
894
|
|
|
897
895
|
|
|
898
896
|
def delete_assistant(option_list: list):
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
if option_flag.name == "name":
|
|
902
|
-
name = option_arg
|
|
897
|
+
opts = {opt.name: arg for opt, arg in option_list}
|
|
898
|
+
name = opts.get("name")
|
|
903
899
|
|
|
904
900
|
if not name:
|
|
905
901
|
raise MissingRequirementException("Cannot delete assistant detail without name")
|
|
@@ -920,16 +916,13 @@ delete_assistant_options = [
|
|
|
920
916
|
|
|
921
917
|
|
|
922
918
|
def list_documents(option_list: list):
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
skip = int(option_arg) if str(option_arg).isdigit() else 0
|
|
931
|
-
if option_flag.name == "count":
|
|
932
|
-
count = int(option_arg) if str(option_arg).isdigit() else 10
|
|
919
|
+
opts = {opt.name: arg for opt, arg in option_list}
|
|
920
|
+
name = opts.get("name")
|
|
921
|
+
skip_arg = opts.get("skip", "0")
|
|
922
|
+
count_arg = opts.get("count", "10")
|
|
923
|
+
|
|
924
|
+
skip = int(skip_arg) if str(skip_arg).isdigit() else 0
|
|
925
|
+
count = int(count_arg) if str(count_arg).isdigit() else 10
|
|
933
926
|
|
|
934
927
|
if not name:
|
|
935
928
|
raise MissingRequirementException("Cannot list documents without assistant name")
|
|
@@ -966,10 +959,8 @@ list_documents_options = [
|
|
|
966
959
|
|
|
967
960
|
|
|
968
961
|
def delete_all_documents(option_list: list):
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
if option_flag.name == "name":
|
|
972
|
-
name = option_arg
|
|
962
|
+
opts = {opt.name: arg for opt, arg in option_list}
|
|
963
|
+
name = opts.get("name")
|
|
973
964
|
|
|
974
965
|
if not name:
|
|
975
966
|
raise MissingRequirementException("Cannot delete all documents without assistant name")
|
|
@@ -992,13 +983,9 @@ delete_all_documents_options = [
|
|
|
992
983
|
|
|
993
984
|
|
|
994
985
|
def get_document_data(option_list: list):
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
if option_flag.name == "name":
|
|
999
|
-
name = option_arg
|
|
1000
|
-
if option_flag.name == "document_id":
|
|
1001
|
-
document_id = option_arg
|
|
986
|
+
opts = {opt.name: arg for opt, arg in option_list}
|
|
987
|
+
name = opts.get("name")
|
|
988
|
+
document_id = opts.get("document_id")
|
|
1002
989
|
|
|
1003
990
|
if not (name and document_id):
|
|
1004
991
|
raise MissingRequirementException("Cannot retrieve document data without assistant name and id")
|
|
@@ -1028,29 +1015,23 @@ get_document_data_options = [
|
|
|
1028
1015
|
|
|
1029
1016
|
|
|
1030
1017
|
def upload_document(option_list: list):
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1018
|
+
opts = {opt.name: arg for opt, arg in option_list}
|
|
1019
|
+
name = opts.get("name")
|
|
1020
|
+
file_path = opts.get("file_path")
|
|
1021
|
+
upload_type = opts.get("upload_type", 'multipart')
|
|
1022
|
+
content_type = opts.get("content_type")
|
|
1023
|
+
|
|
1034
1024
|
metadata = {}
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
if not Path(metadata_str).is_file():
|
|
1046
|
-
try:
|
|
1047
|
-
metadata = json.loads(metadata_str)
|
|
1048
|
-
except Exception as e:
|
|
1049
|
-
raise WrongArgumentError(f"Metadata should be either a valid dictionary or a file path.")
|
|
1050
|
-
else:
|
|
1051
|
-
metadata = metadata_str
|
|
1052
|
-
if option_flag.name == "content_type":
|
|
1053
|
-
content_type = option_arg
|
|
1025
|
+
metadata_arg = opts.get("metadata")
|
|
1026
|
+
if metadata_arg:
|
|
1027
|
+
metadata_str = str(metadata_arg)
|
|
1028
|
+
if not Path(metadata_str).is_file():
|
|
1029
|
+
try:
|
|
1030
|
+
metadata = json.loads(metadata_str)
|
|
1031
|
+
except Exception:
|
|
1032
|
+
raise WrongArgumentError("Metadata should be either a valid dictionary or a file path.")
|
|
1033
|
+
else:
|
|
1034
|
+
metadata = metadata_str
|
|
1054
1035
|
|
|
1055
1036
|
if not (name and file_path):
|
|
1056
1037
|
raise MissingRequirementException("Cannot upload document without assistant name and file name")
|
|
@@ -1102,13 +1083,9 @@ upload_document_options = [
|
|
|
1102
1083
|
|
|
1103
1084
|
|
|
1104
1085
|
def delete_document(option_list: list):
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
if option_flag.name == "name":
|
|
1109
|
-
name = option_arg
|
|
1110
|
-
if option_flag.name == "document_id":
|
|
1111
|
-
document_id = option_arg
|
|
1086
|
+
opts = {opt.name: arg for opt, arg in option_list}
|
|
1087
|
+
name = opts.get("name")
|
|
1088
|
+
document_id = opts.get("document_id")
|
|
1112
1089
|
|
|
1113
1090
|
if not (name and document_id):
|
|
1114
1091
|
raise MissingRequirementException("Cannot delete document without assistant name and id")
|
pygeai/cli/commands/rerank.py
CHANGED
|
@@ -16,32 +16,28 @@ def show_help():
|
|
|
16
16
|
|
|
17
17
|
|
|
18
18
|
def rerank_chunks(option_list: list):
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
opts = {opt.name: arg for opt, arg in option_list}
|
|
20
|
+
query = opts.get('query')
|
|
21
|
+
model = opts.get('model')
|
|
22
|
+
top_n = opts.get('top_n', 3)
|
|
23
|
+
documents_arg = opts.get('documents')
|
|
24
|
+
|
|
21
25
|
documents = []
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
documents.append(option_arg)
|
|
31
|
-
else:
|
|
32
|
-
try:
|
|
33
|
-
documents_json = json.loads(option_arg)
|
|
34
|
-
if not isinstance(documents_json, list):
|
|
35
|
-
raise ValueError
|
|
26
|
+
if documents_arg:
|
|
27
|
+
if "[" not in documents_arg:
|
|
28
|
+
documents.append(documents_arg)
|
|
29
|
+
else:
|
|
30
|
+
try:
|
|
31
|
+
documents_json = json.loads(documents_arg)
|
|
32
|
+
if not isinstance(documents_json, list):
|
|
33
|
+
raise ValueError
|
|
36
34
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
if option_flag.name == "top_n":
|
|
44
|
-
top_n = option_arg
|
|
35
|
+
documents = documents_json
|
|
36
|
+
except Exception:
|
|
37
|
+
raise WrongArgumentError(
|
|
38
|
+
"Documents must be a list of strings: '[\\\"text_chunk_1\\\", \\\"text_chunk_2\\\"]'. "
|
|
39
|
+
"Each element in the list must be a string representing a text chunk.."
|
|
40
|
+
)
|
|
45
41
|
|
|
46
42
|
if not (model and query and documents):
|
|
47
43
|
raise MissingRequirementException("Cannot rerank chunks without model, query and documents")
|
|
@@ -53,7 +49,7 @@ def rerank_chunks(option_list: list):
|
|
|
53
49
|
documents=documents,
|
|
54
50
|
top_n=top_n
|
|
55
51
|
)
|
|
56
|
-
Console.write_stdout(f"Rerank details:
|
|
52
|
+
Console.write_stdout(f"Rerank details: \\n{result}")
|
|
57
53
|
|
|
58
54
|
|
|
59
55
|
rerank_chunks_options = [
|
pygeai/cli/commands/secrets.py
CHANGED
|
@@ -20,11 +20,8 @@ def get_secret(option_list: list):
|
|
|
20
20
|
"""
|
|
21
21
|
Retrieves a secret by its ID.
|
|
22
22
|
"""
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
for option_flag, option_arg in option_list:
|
|
26
|
-
if option_flag.name == "secret_id":
|
|
27
|
-
secret_id = option_arg
|
|
23
|
+
opts = {opt.name: arg for opt, arg in option_list}
|
|
24
|
+
secret_id = opts.get("secret_id")
|
|
28
25
|
|
|
29
26
|
if not secret_id:
|
|
30
27
|
raise MissingRequirementException("Cannot retrieve secret without specifying secret-id")
|
|
@@ -48,17 +45,10 @@ def create_secret(option_list: list):
|
|
|
48
45
|
"""
|
|
49
46
|
Creates a new secret with the specified details.
|
|
50
47
|
"""
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
for option_flag, option_arg in option_list:
|
|
56
|
-
if option_flag.name == "name":
|
|
57
|
-
name = option_arg
|
|
58
|
-
elif option_flag.name == "secret_string":
|
|
59
|
-
secret_string = option_arg
|
|
60
|
-
elif option_flag.name == "description":
|
|
61
|
-
description = option_arg
|
|
48
|
+
opts = {opt.name: arg for opt, arg in option_list}
|
|
49
|
+
name = opts.get("name")
|
|
50
|
+
secret_string = opts.get("secret_string")
|
|
51
|
+
description = opts.get("description")
|
|
62
52
|
|
|
63
53
|
if not (name and secret_string):
|
|
64
54
|
raise MissingRequirementException("Cannot create secret without specifying name and secret-string")
|
|
@@ -98,20 +88,11 @@ def update_secret(option_list: list):
|
|
|
98
88
|
"""
|
|
99
89
|
Updates an existing secret by its ID.
|
|
100
90
|
"""
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
for option_flag, option_arg in option_list:
|
|
107
|
-
if option_flag.name == "secret_id":
|
|
108
|
-
secret_id = option_arg
|
|
109
|
-
elif option_flag.name == "name":
|
|
110
|
-
name = option_arg
|
|
111
|
-
elif option_flag.name == "secret_string":
|
|
112
|
-
secret_string = option_arg
|
|
113
|
-
elif option_flag.name == "description":
|
|
114
|
-
description = option_arg
|
|
91
|
+
opts = {opt.name: arg for opt, arg in option_list}
|
|
92
|
+
secret_id = opts.get("secret_id")
|
|
93
|
+
name = opts.get("name")
|
|
94
|
+
secret_string = opts.get("secret_string")
|
|
95
|
+
description = opts.get("description")
|
|
115
96
|
|
|
116
97
|
if not (secret_id and name and secret_string):
|
|
117
98
|
raise MissingRequirementException("Cannot update secret without specifying secret-id, name, and secret-string")
|
|
@@ -158,26 +139,21 @@ def list_secrets(option_list: list):
|
|
|
158
139
|
"""
|
|
159
140
|
Lists secrets with optional filtering and pagination.
|
|
160
141
|
"""
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
elif option_flag.name == "count":
|
|
177
|
-
try:
|
|
178
|
-
count = int(option_arg) if option_arg else 10
|
|
179
|
-
except ValueError:
|
|
180
|
-
raise WrongArgumentError("count must be an integer")
|
|
142
|
+
opts = {opt.name: arg for opt, arg in option_list}
|
|
143
|
+
name = opts.get("name")
|
|
144
|
+
id = opts.get("id")
|
|
145
|
+
start_arg = opts.get("start")
|
|
146
|
+
count_arg = opts.get("count")
|
|
147
|
+
|
|
148
|
+
try:
|
|
149
|
+
start = int(start_arg) if start_arg else 0
|
|
150
|
+
except ValueError:
|
|
151
|
+
raise WrongArgumentError("start must be an integer")
|
|
152
|
+
|
|
153
|
+
try:
|
|
154
|
+
count = int(count_arg) if count_arg else 10
|
|
155
|
+
except ValueError:
|
|
156
|
+
raise WrongArgumentError("count must be an integer")
|
|
181
157
|
|
|
182
158
|
client = SecretClient()
|
|
183
159
|
result = client.list_secrets(
|
|
@@ -221,19 +197,18 @@ def set_secret_accesses(option_list: list):
|
|
|
221
197
|
"""
|
|
222
198
|
Sets access configurations for a secret by its ID.
|
|
223
199
|
"""
|
|
224
|
-
|
|
200
|
+
opts = {opt.name: arg for opt, arg in option_list}
|
|
201
|
+
secret_id = opts.get("secret_id")
|
|
202
|
+
access_list_arg = opts.get("access_list")
|
|
203
|
+
|
|
225
204
|
access_list = None
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
if not isinstance(access_list, list):
|
|
234
|
-
raise WrongArgumentError("access-list must be a JSON array")
|
|
235
|
-
except json.JSONDecodeError:
|
|
236
|
-
raise WrongArgumentError("access-list must be a valid JSON array")
|
|
205
|
+
if access_list_arg:
|
|
206
|
+
try:
|
|
207
|
+
access_list = json.loads(access_list_arg)
|
|
208
|
+
if not isinstance(access_list, list):
|
|
209
|
+
raise WrongArgumentError("access-list must be a JSON array")
|
|
210
|
+
except json.JSONDecodeError:
|
|
211
|
+
raise WrongArgumentError("access-list must be a valid JSON array")
|
|
237
212
|
|
|
238
213
|
if not (secret_id and access_list):
|
|
239
214
|
raise MissingRequirementException("Cannot set secret accesses without specifying secret-id and access-list")
|
|
@@ -266,11 +241,8 @@ def get_secret_accesses(option_list: list):
|
|
|
266
241
|
"""
|
|
267
242
|
Retrieves access configurations for a secret by its ID.
|
|
268
243
|
"""
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
for option_flag, option_arg in option_list:
|
|
272
|
-
if option_flag.name == "secret_id":
|
|
273
|
-
secret_id = option_arg
|
|
244
|
+
opts = {opt.name: arg for opt, arg in option_list}
|
|
245
|
+
secret_id = opts.get("secret_id")
|
|
274
246
|
|
|
275
247
|
if not secret_id:
|
|
276
248
|
raise MissingRequirementException("Cannot retrieve secret accesses without specifying secret-id")
|
|
@@ -18,28 +18,15 @@ def show_help():
|
|
|
18
18
|
|
|
19
19
|
|
|
20
20
|
def set_organization_usage_limit(option_list: list):
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
21
|
+
opts = {opt.name: arg for opt, arg in option_list}
|
|
22
|
+
organization = opts.get("organization")
|
|
23
|
+
subscription_type = opts.get("subscription_type")
|
|
24
|
+
usage_unit = opts.get("usage_unit")
|
|
25
|
+
soft_limit = opts.get("soft_limit")
|
|
26
|
+
hard_limit = opts.get("hard_limit")
|
|
27
|
+
renewal_status = opts.get("renewal_status")
|
|
28
|
+
|
|
27
29
|
usage_limit = {}
|
|
28
|
-
|
|
29
|
-
for option_flag, option_arg in option_list:
|
|
30
|
-
if option_flag.name == "organization":
|
|
31
|
-
organization = option_arg
|
|
32
|
-
if option_flag.name == "subscription_type":
|
|
33
|
-
subscription_type = option_arg
|
|
34
|
-
if option_flag.name == "usage_unit":
|
|
35
|
-
usage_unit = option_arg
|
|
36
|
-
if option_flag.name == "soft_limit":
|
|
37
|
-
soft_limit = option_arg
|
|
38
|
-
if option_flag.name == "hard_limit":
|
|
39
|
-
hard_limit = option_arg
|
|
40
|
-
if option_flag.name == "renewal_status":
|
|
41
|
-
renewal_status = option_arg
|
|
42
|
-
|
|
43
30
|
if subscription_type or usage_unit or soft_limit or hard_limit or renewal_status:
|
|
44
31
|
usage_limit.update({
|
|
45
32
|
"subscriptionType": subscription_type,
|
|
@@ -71,11 +58,8 @@ set_organization_usage_limit_options = [
|
|
|
71
58
|
|
|
72
59
|
|
|
73
60
|
def get_organization_latest_usage_limit(option_list: list):
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
for option_flag, option_arg in option_list:
|
|
77
|
-
if option_flag.name == "organization":
|
|
78
|
-
organization = option_arg
|
|
61
|
+
opts = {opt.name: arg for opt, arg in option_list}
|
|
62
|
+
organization = opts.get("organization")
|
|
79
63
|
|
|
80
64
|
if not organization:
|
|
81
65
|
raise MissingRequirementException("Cannot get latest usage limit for organization without organization ID")
|
|
@@ -93,11 +77,8 @@ get_organization_latest_usage_limit_options = [
|
|
|
93
77
|
|
|
94
78
|
|
|
95
79
|
def get_all_usage_limits_from_organization(option_list: list):
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
for option_flag, option_arg in option_list:
|
|
99
|
-
if option_flag.name == "organization":
|
|
100
|
-
organization = option_arg
|
|
80
|
+
opts = {opt.name: arg for opt, arg in option_list}
|
|
81
|
+
organization = opts.get("organization")
|
|
101
82
|
|
|
102
83
|
if not organization:
|
|
103
84
|
raise MissingRequirementException("Cannot get all usage limits for organization without organization ID")
|
|
@@ -115,14 +96,9 @@ get_all_usage_limits_from_organization_options = [
|
|
|
115
96
|
|
|
116
97
|
|
|
117
98
|
def delete_usage_limit_from_organization(option_list: list):
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
for option_flag, option_arg in option_list:
|
|
122
|
-
if option_flag.name == "organization":
|
|
123
|
-
organization = option_arg
|
|
124
|
-
if option_flag.name == "limit_id":
|
|
125
|
-
limit_id = option_arg
|
|
99
|
+
opts = {opt.name: arg for opt, arg in option_list}
|
|
100
|
+
organization = opts.get("organization")
|
|
101
|
+
limit_id = opts.get("limit_id")
|
|
126
102
|
|
|
127
103
|
if not (organization and limit_id):
|
|
128
104
|
raise MissingRequirementException("Cannot delete usage limit for organization without organization ID and limit ID")
|
|
@@ -142,23 +118,12 @@ delete_usage_limit_from_organization_options = [
|
|
|
142
118
|
|
|
143
119
|
|
|
144
120
|
def update_organization_usage_limit(option_list: list):
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
for option_flag, option_arg in option_list:
|
|
152
|
-
if option_flag.name == "organization":
|
|
153
|
-
organization = option_arg
|
|
154
|
-
if option_flag.name == "limit_id":
|
|
155
|
-
limit_id = option_arg
|
|
156
|
-
if option_flag.name == "hard_limit":
|
|
157
|
-
hard_limit = option_arg
|
|
158
|
-
if option_flag.name == "soft_limit":
|
|
159
|
-
soft_limit = option_arg
|
|
160
|
-
if option_flag.name == "renewal_status":
|
|
161
|
-
renewal_status = option_arg
|
|
121
|
+
opts = {opt.name: arg for opt, arg in option_list}
|
|
122
|
+
organization = opts.get("organization")
|
|
123
|
+
limit_id = opts.get("limit_id")
|
|
124
|
+
hard_limit = opts.get("hard_limit")
|
|
125
|
+
soft_limit = opts.get("soft_limit")
|
|
126
|
+
renewal_status = opts.get("renewal_status")
|
|
162
127
|
|
|
163
128
|
if not (organization and limit_id):
|
|
164
129
|
raise MissingRequirementException("Cannot update usage limit for organization without organization ID and limit ID")
|
|
@@ -217,32 +182,16 @@ def set_organization_renewal_status(organization, limit_id, renewal_status):
|
|
|
217
182
|
|
|
218
183
|
|
|
219
184
|
def set_project_usage_limit(option_list: list):
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
185
|
+
opts = {opt.name: arg for opt, arg in option_list}
|
|
186
|
+
organization = opts.get("organization")
|
|
187
|
+
project = opts.get("project")
|
|
188
|
+
subscription_type = opts.get("subscription_type")
|
|
189
|
+
usage_unit = opts.get("usage_unit")
|
|
190
|
+
soft_limit = opts.get("soft_limit")
|
|
191
|
+
hard_limit = opts.get("hard_limit")
|
|
192
|
+
renewal_status = opts.get("renewal_status")
|
|
193
|
+
|
|
227
194
|
usage_limit = {}
|
|
228
|
-
|
|
229
|
-
for option_flag, option_arg in option_list:
|
|
230
|
-
if option_flag.name == "organization":
|
|
231
|
-
organization = option_arg
|
|
232
|
-
if option_flag.name == "project":
|
|
233
|
-
project = option_arg
|
|
234
|
-
|
|
235
|
-
if option_flag.name == "subscription_type":
|
|
236
|
-
subscription_type = option_arg
|
|
237
|
-
if option_flag.name == "usage_unit":
|
|
238
|
-
usage_unit = option_arg
|
|
239
|
-
if option_flag.name == "soft_limit":
|
|
240
|
-
soft_limit = option_arg
|
|
241
|
-
if option_flag.name == "hard_limit":
|
|
242
|
-
hard_limit = option_arg
|
|
243
|
-
if option_flag.name == "renewal_status":
|
|
244
|
-
renewal_status = option_arg
|
|
245
|
-
|
|
246
195
|
if subscription_type or usage_unit or soft_limit or hard_limit or renewal_status:
|
|
247
196
|
usage_limit.update({
|
|
248
197
|
"subscriptionType": subscription_type,
|
|
@@ -276,14 +225,9 @@ set_project_usage_limit_options = [
|
|
|
276
225
|
|
|
277
226
|
|
|
278
227
|
def get_all_usage_limits_from_project(option_list: list):
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
for option_flag, option_arg in option_list:
|
|
283
|
-
if option_flag.name == "organization":
|
|
284
|
-
organization = option_arg
|
|
285
|
-
if option_flag.name == "project":
|
|
286
|
-
project = option_arg
|
|
228
|
+
opts = {opt.name: arg for opt, arg in option_list}
|
|
229
|
+
organization = opts.get("organization")
|
|
230
|
+
project = opts.get("project")
|
|
287
231
|
|
|
288
232
|
if not (organization and project):
|
|
289
233
|
raise MissingRequirementException("Cannot get usage limits for project without organization and project ID")
|
|
@@ -303,14 +247,9 @@ get_all_usage_limits_from_project_options = [
|
|
|
303
247
|
|
|
304
248
|
|
|
305
249
|
def get_latest_usage_limit_from_project(option_list: list):
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
for option_flag, option_arg in option_list:
|
|
310
|
-
if option_flag.name == "organization":
|
|
311
|
-
organization = option_arg
|
|
312
|
-
if option_flag.name == "project":
|
|
313
|
-
project = option_arg
|
|
250
|
+
opts = {opt.name: arg for opt, arg in option_list}
|
|
251
|
+
organization = opts.get("organization")
|
|
252
|
+
project = opts.get("project")
|
|
314
253
|
|
|
315
254
|
if not (organization and project):
|
|
316
255
|
raise MissingRequirementException("Cannot get latest usage limit for project without organization and project ID")
|
|
@@ -330,14 +269,9 @@ get_latest_usage_limit_from_project_options = [
|
|
|
330
269
|
|
|
331
270
|
|
|
332
271
|
def get_active_usage_limit_from_project(option_list: list):
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
for option_flag, option_arg in option_list:
|
|
337
|
-
if option_flag.name == "organization":
|
|
338
|
-
organization = option_arg
|
|
339
|
-
if option_flag.name == "project":
|
|
340
|
-
project = option_arg
|
|
272
|
+
opts = {opt.name: arg for opt, arg in option_list}
|
|
273
|
+
organization = opts.get("organization")
|
|
274
|
+
project = opts.get("project")
|
|
341
275
|
|
|
342
276
|
if not (organization and project):
|
|
343
277
|
raise MissingRequirementException("Cannot get active usage limit for project without organization and project ID")
|
|
@@ -357,17 +291,10 @@ get_active_usage_limit_from_project_options = [
|
|
|
357
291
|
|
|
358
292
|
|
|
359
293
|
def delete_usage_limit_from_project(option_list: list):
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
for option_flag, option_arg in option_list:
|
|
365
|
-
if option_flag.name == "organization":
|
|
366
|
-
organization = option_arg
|
|
367
|
-
if option_flag.name == "project":
|
|
368
|
-
project = option_arg
|
|
369
|
-
if option_flag.name == "limit_id":
|
|
370
|
-
limit_id = option_arg
|
|
294
|
+
opts = {opt.name: arg for opt, arg in option_list}
|
|
295
|
+
organization = opts.get("organization")
|
|
296
|
+
project = opts.get("project")
|
|
297
|
+
limit_id = opts.get("limit_id")
|
|
371
298
|
|
|
372
299
|
if not (organization and project and limit_id):
|
|
373
300
|
raise MissingRequirementException("Cannot delete usage limit for project without organization, project and limit ID")
|
|
@@ -389,26 +316,13 @@ delete_usage_limit_from_project_options = [
|
|
|
389
316
|
|
|
390
317
|
|
|
391
318
|
def update_project_usage_limit(option_list: list):
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
for option_flag, option_arg in option_list:
|
|
400
|
-
if option_flag.name == "organization":
|
|
401
|
-
organization = option_arg
|
|
402
|
-
if option_flag.name == "project":
|
|
403
|
-
project = option_arg
|
|
404
|
-
if option_flag.name == "limit_id":
|
|
405
|
-
limit_id = option_arg
|
|
406
|
-
if option_flag.name == "hard_limit":
|
|
407
|
-
hard_limit = option_arg
|
|
408
|
-
if option_flag.name == "soft_limit":
|
|
409
|
-
soft_limit = option_arg
|
|
410
|
-
if option_flag.name == "renewal_status":
|
|
411
|
-
renewal_status = option_arg
|
|
319
|
+
opts = {opt.name: arg for opt, arg in option_list}
|
|
320
|
+
organization = opts.get("organization")
|
|
321
|
+
project = opts.get("project")
|
|
322
|
+
limit_id = opts.get("limit_id")
|
|
323
|
+
hard_limit = opts.get("hard_limit")
|
|
324
|
+
soft_limit = opts.get("soft_limit")
|
|
325
|
+
renewal_status = opts.get("renewal_status")
|
|
412
326
|
|
|
413
327
|
if not (organization and project and limit_id):
|
|
414
328
|
raise MissingRequirementException("Cannot update usage limit for project without organization ID, project ID and limit ID")
|