pangea-sdk 6.2.0b2__py3-none-any.whl → 6.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.
- pangea/__init__.py +1 -1
- pangea/asyncio/request.py +25 -154
- pangea/asyncio/services/__init__.py +0 -1
- pangea/asyncio/services/ai_guard.py +40 -130
- pangea/asyncio/services/audit.py +1 -301
- pangea/asyncio/services/authn.py +7 -9
- pangea/asyncio/services/authz.py +45 -11
- pangea/asyncio/services/intel.py +20 -26
- pangea/asyncio/services/prompt_guard.py +2 -112
- pangea/asyncio/services/redact.py +4 -265
- pangea/asyncio/services/vault.py +52 -40
- pangea/request.py +30 -167
- pangea/response.py +6 -6
- pangea/services/__init__.py +0 -1
- pangea/services/ai_guard.py +96 -542
- pangea/services/audit/audit.py +2 -301
- pangea/services/audit/models.py +65 -307
- pangea/services/authn/authn.py +6 -8
- pangea/services/authn/models.py +183 -151
- pangea/services/authz.py +101 -57
- pangea/services/base.py +2 -3
- pangea/services/intel.py +32 -19
- pangea/services/prompt_guard.py +2 -193
- pangea/services/redact.py +7 -473
- pangea/services/vault/models/common.py +11 -12
- pangea/services/vault/models/keys.py +4 -9
- pangea/services/vault/models/secret.py +3 -8
- pangea/services/vault/vault.py +52 -40
- {pangea_sdk-6.2.0b2.dist-info → pangea_sdk-6.4.0.dist-info}/METADATA +34 -15
- pangea_sdk-6.4.0.dist-info/RECORD +60 -0
- pangea/asyncio/services/management.py +0 -576
- pangea/services/management.py +0 -720
- pangea_sdk-6.2.0b2.dist-info/RECORD +0 -62
- {pangea_sdk-6.2.0b2.dist-info → pangea_sdk-6.4.0.dist-info}/WHEEL +0 -0
pangea/services/audit/audit.py
CHANGED
@@ -9,17 +9,13 @@ from __future__ import annotations
|
|
9
9
|
import datetime
|
10
10
|
import json
|
11
11
|
from collections.abc import Mapping
|
12
|
-
from typing import Any, Dict, Iterable, List, Optional, Sequence, Set, Tuple, Union
|
13
|
-
|
14
|
-
from pydantic import TypeAdapter
|
15
|
-
from typing_extensions import Literal
|
12
|
+
from typing import Any, Dict, Iterable, List, Optional, Sequence, Set, Tuple, Union
|
16
13
|
|
17
14
|
import pangea.exceptions as pexc
|
18
15
|
from pangea.config import PangeaConfig
|
19
16
|
from pangea.response import PangeaResponse, PangeaResponseResult
|
20
17
|
from pangea.services.audit.exceptions import AuditException, EventCorruption
|
21
18
|
from pangea.services.audit.models import (
|
22
|
-
AuditSchema,
|
23
19
|
DownloadFormat,
|
24
20
|
DownloadRequest,
|
25
21
|
DownloadResult,
|
@@ -27,7 +23,6 @@ from pangea.services.audit.models import (
|
|
27
23
|
EventEnvelope,
|
28
24
|
EventVerification,
|
29
25
|
ExportRequest,
|
30
|
-
ForwardingConfiguration,
|
31
26
|
LogBulkRequest,
|
32
27
|
LogBulkResult,
|
33
28
|
LogEvent,
|
@@ -45,9 +40,6 @@ from pangea.services.audit.models import (
|
|
45
40
|
SearchRequest,
|
46
41
|
SearchResultOutput,
|
47
42
|
SearchResultRequest,
|
48
|
-
ServiceConfig,
|
49
|
-
ServiceConfigFilter,
|
50
|
-
ServiceConfigListResult,
|
51
43
|
)
|
52
44
|
from pangea.services.audit.signing import Signer, Verifier
|
53
45
|
from pangea.services.audit.util import (
|
@@ -346,6 +338,7 @@ class AuditBase:
|
|
346
338
|
public_key = get_public_key(audit_envelope.public_key)
|
347
339
|
|
348
340
|
if audit_envelope and audit_envelope.signature and public_key:
|
341
|
+
assert audit_envelope.event
|
349
342
|
v = Verifier()
|
350
343
|
verification = v.verify_signature(
|
351
344
|
audit_envelope.signature,
|
@@ -929,298 +922,6 @@ class Audit(ServiceBase, AuditBase):
|
|
929
922
|
)
|
930
923
|
return self.request.post("v1/download_results", DownloadResult, data=input.model_dump(exclude_none=True))
|
931
924
|
|
932
|
-
def get_service_config(self, config_id: str) -> PangeaResponse[ServiceConfig]:
|
933
|
-
"""
|
934
|
-
Get a service config.
|
935
|
-
|
936
|
-
OperationId: audit_post_v1beta_config
|
937
|
-
|
938
|
-
Args:
|
939
|
-
id: The config ID
|
940
|
-
"""
|
941
|
-
|
942
|
-
response = self.request.post("v1beta/config", PangeaResponseResult, data={"id": config_id})
|
943
|
-
response.result = TypeAdapter(ServiceConfig).validate_python(response.json["result"])
|
944
|
-
return cast(PangeaResponse[ServiceConfig], response)
|
945
|
-
|
946
|
-
@overload
|
947
|
-
def create_service_config(
|
948
|
-
self,
|
949
|
-
version: Literal[1],
|
950
|
-
name: str,
|
951
|
-
*,
|
952
|
-
cold_query_result_retention: str | None = None,
|
953
|
-
hot_storage: str | None = None,
|
954
|
-
query_result_retention: str | None = None,
|
955
|
-
redact_service_config_id: str | None = None,
|
956
|
-
redaction_fields: Sequence[str] | None = None,
|
957
|
-
retention: str | None = None,
|
958
|
-
vault_key_id: str | None = None,
|
959
|
-
vault_service_config_id: str | None = None,
|
960
|
-
vault_sign: bool | None = None,
|
961
|
-
) -> PangeaResponse[ServiceConfig]:
|
962
|
-
"""
|
963
|
-
Create a v1 service config.
|
964
|
-
|
965
|
-
OperationId: audit_post_v1beta_config_create
|
966
|
-
|
967
|
-
Args:
|
968
|
-
name: Configuration name
|
969
|
-
cold_query_result_retention: Retention window for cold query result / state information.
|
970
|
-
hot_storage: Retention window to keep audit logs in hot storage.
|
971
|
-
query_result_retention: Length of time to preserve server-side query result caching.
|
972
|
-
redact_service_config_id: A redact service config that will be used to redact PII from logs.
|
973
|
-
redaction_fields: Fields to perform redaction against.
|
974
|
-
retention: Retention window to store audit logs.
|
975
|
-
vault_key_id: ID of the Vault key used for signing. If missing, use a default Audit key.
|
976
|
-
vault_service_config_id: A vault service config that will be used to sign logs.
|
977
|
-
vault_sign: Enable/disable event signing.
|
978
|
-
"""
|
979
|
-
|
980
|
-
@overload
|
981
|
-
def create_service_config(
|
982
|
-
self,
|
983
|
-
version: Literal[2],
|
984
|
-
name: str,
|
985
|
-
*,
|
986
|
-
schema: AuditSchema,
|
987
|
-
cold_query_result_retention: str | None = None,
|
988
|
-
forwarding_configuration: ForwardingConfiguration | None = None,
|
989
|
-
hot_storage: str | None = None,
|
990
|
-
query_result_retention: str | None = None,
|
991
|
-
redact_service_config_id: str | None = None,
|
992
|
-
retention: str | None = None,
|
993
|
-
vault_key_id: str | None = None,
|
994
|
-
vault_service_config_id: str | None = None,
|
995
|
-
vault_sign: bool | None = None,
|
996
|
-
) -> PangeaResponse[ServiceConfig]:
|
997
|
-
"""
|
998
|
-
Create a v2 service config.
|
999
|
-
|
1000
|
-
OperationId: audit_post_v1beta_config_create
|
1001
|
-
|
1002
|
-
Args:
|
1003
|
-
name: Configuration name
|
1004
|
-
schema: Audit log field configuration. Only settable at create time.
|
1005
|
-
cold_query_result_retention: Retention window for cold query result / state information.
|
1006
|
-
forwarding_configuration: Configuration for forwarding audit logs to external systems.
|
1007
|
-
hot_storage: Retention window to keep audit logs in hot storage.
|
1008
|
-
query_result_retention: Length of time to preserve server-side query result caching.
|
1009
|
-
redact_service_config_id: A redact service config that will be used to redact PII from logs.
|
1010
|
-
retention: Retention window to store audit logs.
|
1011
|
-
vault_key_id: ID of the Vault key used for signing. If missing, use a default Audit key.
|
1012
|
-
vault_service_config_id: A vault service config that will be used to sign logs.
|
1013
|
-
vault_sign: Enable/disable event signing.
|
1014
|
-
"""
|
1015
|
-
|
1016
|
-
@overload
|
1017
|
-
def create_service_config(
|
1018
|
-
self,
|
1019
|
-
version: Literal[3],
|
1020
|
-
name: str,
|
1021
|
-
*,
|
1022
|
-
schema: AuditSchema,
|
1023
|
-
cold_storage: str | None = None,
|
1024
|
-
hot_storage: str | None = None,
|
1025
|
-
warm_storage: str | None = None,
|
1026
|
-
redact_service_config_id: str | None = None,
|
1027
|
-
vault_service_config_id: str | None = None,
|
1028
|
-
vault_key_id: str | None = None,
|
1029
|
-
vault_sign: bool | None = None,
|
1030
|
-
forwarding_configuration: ForwardingConfiguration | None = None,
|
1031
|
-
) -> PangeaResponse[ServiceConfig]:
|
1032
|
-
"""
|
1033
|
-
Create a v3 service config.
|
1034
|
-
|
1035
|
-
OperationId: audit_post_v1beta_config_create
|
1036
|
-
|
1037
|
-
Args:
|
1038
|
-
name: Configuration name
|
1039
|
-
schema: Audit log field configuration. Only settable at create time.
|
1040
|
-
cold_storage: Retention window for logs in cold storage. Deleted afterwards.
|
1041
|
-
hot_storage: Retention window for logs in hot storage. Migrated to warm, cold, or deleted afterwards.
|
1042
|
-
warm_storage: Retention window for logs in warm storage. Migrated to cold or deleted afterwards.
|
1043
|
-
redact_service_config_id: A redact service config that will be used to redact PII from logs.
|
1044
|
-
vault_service_config_id: A vault service config that will be used to sign logs.
|
1045
|
-
vault_key_id: ID of the Vault key used for signing. If missing, use a default Audit key.
|
1046
|
-
vault_sign: Enable/disable event signing.
|
1047
|
-
forwarding_configuration: Configuration for forwarding audit logs to external systems.
|
1048
|
-
"""
|
1049
|
-
|
1050
|
-
def create_service_config(
|
1051
|
-
self,
|
1052
|
-
version: Literal[1, 2, 3],
|
1053
|
-
name: str,
|
1054
|
-
*,
|
1055
|
-
cold_query_result_retention: str | None = None,
|
1056
|
-
cold_storage: str | None = None,
|
1057
|
-
forwarding_configuration: ForwardingConfiguration | None = None,
|
1058
|
-
hot_storage: str | None = None,
|
1059
|
-
query_result_retention: str | None = None,
|
1060
|
-
redact_service_config_id: str | None = None,
|
1061
|
-
redaction_fields: Sequence[str] | None = None,
|
1062
|
-
retention: str | None = None,
|
1063
|
-
schema: AuditSchema | None = None,
|
1064
|
-
vault_key_id: str | None = None,
|
1065
|
-
vault_service_config_id: str | None = None,
|
1066
|
-
vault_sign: bool | None = None,
|
1067
|
-
warm_storage: str | None = None,
|
1068
|
-
) -> PangeaResponse[ServiceConfig]:
|
1069
|
-
"""
|
1070
|
-
Create a service config.
|
1071
|
-
|
1072
|
-
OperationId: audit_post_v1beta_config_create
|
1073
|
-
|
1074
|
-
Args:
|
1075
|
-
name: Configuration name
|
1076
|
-
cold_query_result_retention: Retention window for cold query result / state information.
|
1077
|
-
cold_storage: Retention window for logs in cold storage. Deleted afterwards.
|
1078
|
-
forwarding_configuration: Configuration for forwarding audit logs to external systems.
|
1079
|
-
hot_storage: Retention window to keep audit logs in hot storage.
|
1080
|
-
query_result_retention: Length of time to preserve server-side query result caching.
|
1081
|
-
redact_service_config_id: A redact service config that will be used to redact PII from logs.
|
1082
|
-
redaction_fields: Fields to perform redaction against.
|
1083
|
-
retention: Retention window to store audit logs.
|
1084
|
-
schema: Audit log field configuration. Only settable at create time.
|
1085
|
-
vault_key_id: ID of the Vault key used for signing. If missing, use a default Audit key.
|
1086
|
-
vault_service_config_id: A vault service config that will be used to sign logs.
|
1087
|
-
vault_sign: Enable/disable event signing.
|
1088
|
-
warm_storage: Retention window for logs in warm storage. Migrated to cold or deleted afterwards.
|
1089
|
-
"""
|
1090
|
-
|
1091
|
-
response = self.request.post(
|
1092
|
-
"v1beta/config/create",
|
1093
|
-
PangeaResponseResult,
|
1094
|
-
data={
|
1095
|
-
"cold_query_result_retention": cold_query_result_retention,
|
1096
|
-
"cold_storage": cold_storage,
|
1097
|
-
"forwarding_configuration": forwarding_configuration,
|
1098
|
-
"hot_storage": hot_storage,
|
1099
|
-
"name": name,
|
1100
|
-
"query_result_retention": query_result_retention,
|
1101
|
-
"redact_service_config_id": redact_service_config_id,
|
1102
|
-
"redaction_fields": redaction_fields,
|
1103
|
-
"retention": retention,
|
1104
|
-
"schema": schema,
|
1105
|
-
"vault_key_id": vault_key_id,
|
1106
|
-
"vault_service_config_id": vault_service_config_id,
|
1107
|
-
"vault_sign": vault_sign,
|
1108
|
-
"warm_storage": warm_storage,
|
1109
|
-
"version": version,
|
1110
|
-
},
|
1111
|
-
)
|
1112
|
-
response.result = TypeAdapter(ServiceConfig).validate_python(response.json["result"])
|
1113
|
-
return cast(PangeaResponse[ServiceConfig], response)
|
1114
|
-
|
1115
|
-
def update_service_config(
|
1116
|
-
self,
|
1117
|
-
config_id: str,
|
1118
|
-
*,
|
1119
|
-
name: str,
|
1120
|
-
updated_at: datetime.datetime,
|
1121
|
-
# Optionals.
|
1122
|
-
cold_query_result_retention: str | None = None,
|
1123
|
-
cold_storage: str | None = None,
|
1124
|
-
forwarding_configuration: ForwardingConfiguration | None = None,
|
1125
|
-
hot_storage: str | None = None,
|
1126
|
-
query_result_retention: str | None = None,
|
1127
|
-
redact_service_config_id: str | None = None,
|
1128
|
-
retention: str | None = None,
|
1129
|
-
schema: AuditSchema | None = None,
|
1130
|
-
vault_key_id: str | None = None,
|
1131
|
-
vault_service_config_id: str | None = None,
|
1132
|
-
vault_sign: bool | None = None,
|
1133
|
-
warm_storage: str | None = None,
|
1134
|
-
) -> PangeaResponse[ServiceConfig]:
|
1135
|
-
"""
|
1136
|
-
Update a service config.
|
1137
|
-
|
1138
|
-
OperationId: audit_post_v1beta_config_update
|
1139
|
-
|
1140
|
-
Args:
|
1141
|
-
id: The config ID
|
1142
|
-
name: Configuration name
|
1143
|
-
updated_at: The DB timestamp when this config was last updated at
|
1144
|
-
cold_query_result_retention: Retention window for cold query result / state information.
|
1145
|
-
cold_storage: Retention window for logs in cold storage. Deleted afterwards.
|
1146
|
-
forwarding_configuration: Configuration for forwarding audit logs to external systems
|
1147
|
-
hot_storage: Retention window to keep audit logs in hot storage
|
1148
|
-
query_result_retention: Length of time to preserve server-side query result caching
|
1149
|
-
redact_service_config_id: A redact service config that will be used to redact PII from logs
|
1150
|
-
retention: Retention window to store audit logs
|
1151
|
-
schema: Audit log field configuration
|
1152
|
-
vault_key_id: ID of the Vault key used for signing. If missing, use a default Audit key.
|
1153
|
-
vault_service_config_id: A vault service config that will be used to sign logs
|
1154
|
-
vault_sign: Enable/disable event signing
|
1155
|
-
warm_storage: Retention window for logs in warm storage. Migrated to cold or deleted afterwards.
|
1156
|
-
"""
|
1157
|
-
|
1158
|
-
response = self.request.post(
|
1159
|
-
"v1beta/config/update",
|
1160
|
-
PangeaResponseResult,
|
1161
|
-
data={
|
1162
|
-
"id": config_id,
|
1163
|
-
"name": name,
|
1164
|
-
"updated_at": updated_at,
|
1165
|
-
# Optionals.
|
1166
|
-
"cold_query_result_retention": cold_query_result_retention,
|
1167
|
-
"cold_storage": cold_storage,
|
1168
|
-
"forwarding_configuration": forwarding_configuration,
|
1169
|
-
"hot_storage": hot_storage,
|
1170
|
-
"query_result_retention": query_result_retention,
|
1171
|
-
"redact_service_config_id": redact_service_config_id,
|
1172
|
-
"retention": retention,
|
1173
|
-
"schema": schema,
|
1174
|
-
"vault_key_id": vault_key_id,
|
1175
|
-
"vault_service_config_id": vault_service_config_id,
|
1176
|
-
"vault_sign": vault_sign,
|
1177
|
-
"warm_storage": warm_storage,
|
1178
|
-
},
|
1179
|
-
)
|
1180
|
-
response.result = TypeAdapter(ServiceConfig).validate_python(response.json["result"])
|
1181
|
-
return cast(PangeaResponse[ServiceConfig], response)
|
1182
|
-
|
1183
|
-
def delete_service_config(self, config_id: str) -> PangeaResponse[ServiceConfig]:
|
1184
|
-
"""
|
1185
|
-
Delete a service config.
|
1186
|
-
|
1187
|
-
OperationId: audit_post_v1beta_config_delete
|
1188
|
-
|
1189
|
-
Args:
|
1190
|
-
id: The config ID
|
1191
|
-
"""
|
1192
|
-
|
1193
|
-
response = self.request.post("v1beta/config/delete", PangeaResponseResult, data={"id": config_id})
|
1194
|
-
response.result = TypeAdapter(ServiceConfig).validate_python(response.json["result"])
|
1195
|
-
return cast(PangeaResponse[ServiceConfig], response)
|
1196
|
-
|
1197
|
-
def list_service_configs(
|
1198
|
-
self,
|
1199
|
-
*,
|
1200
|
-
filter: ServiceConfigFilter | None = None,
|
1201
|
-
last: str | None = None,
|
1202
|
-
order: Literal["asc", "desc"] | None = None,
|
1203
|
-
order_by: Literal["id", "created_at", "updated_at"] | None = None,
|
1204
|
-
size: int | None = None,
|
1205
|
-
) -> PangeaResponse[ServiceConfigListResult]:
|
1206
|
-
"""
|
1207
|
-
List service configs.
|
1208
|
-
|
1209
|
-
OperationId: audit_post_v1beta_config_list
|
1210
|
-
|
1211
|
-
Args:
|
1212
|
-
last: Reflected value from a previous response to obtain the next page of results.
|
1213
|
-
order: Order results asc(ending) or desc(ending).
|
1214
|
-
order_by: Which field to order results by.
|
1215
|
-
size: Maximum results to include in the response.
|
1216
|
-
"""
|
1217
|
-
|
1218
|
-
return self.request.post(
|
1219
|
-
"v1beta/config/list",
|
1220
|
-
ServiceConfigListResult,
|
1221
|
-
data={"filter": filter, "last": last, "order": order, "order_by": order_by, "size": size},
|
1222
|
-
)
|
1223
|
-
|
1224
925
|
def update_published_roots(self, result: SearchResultOutput):
|
1225
926
|
"""Fetches series of published root hashes from Arweave
|
1226
927
|
|