pangea-sdk 6.2.0b1__py3-none-any.whl → 6.3.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.
Files changed (55) hide show
  1. pangea/__init__.py +9 -1
  2. pangea/asyncio/__init__.py +1 -0
  3. pangea/asyncio/file_uploader.py +4 -2
  4. pangea/asyncio/request.py +70 -169
  5. pangea/asyncio/services/__init__.py +2 -1
  6. pangea/asyncio/services/ai_guard.py +9 -12
  7. pangea/asyncio/services/audit.py +13 -307
  8. pangea/asyncio/services/authn.py +40 -32
  9. pangea/asyncio/services/authz.py +51 -17
  10. pangea/asyncio/services/base.py +4 -0
  11. pangea/asyncio/services/file_scan.py +8 -2
  12. pangea/asyncio/services/intel.py +26 -28
  13. pangea/asyncio/services/redact.py +11 -268
  14. pangea/asyncio/services/sanitize.py +5 -1
  15. pangea/asyncio/services/share.py +5 -1
  16. pangea/asyncio/services/vault.py +71 -55
  17. pangea/audit_logger.py +3 -1
  18. pangea/deep_verify.py +13 -13
  19. pangea/deprecated.py +1 -1
  20. pangea/dump_audit.py +2 -3
  21. pangea/exceptions.py +8 -5
  22. pangea/file_uploader.py +4 -0
  23. pangea/request.py +80 -200
  24. pangea/response.py +21 -18
  25. pangea/services/__init__.py +2 -1
  26. pangea/services/ai_guard.py +35 -24
  27. pangea/services/audit/audit.py +17 -314
  28. pangea/services/audit/models.py +69 -307
  29. pangea/services/audit/signing.py +1 -1
  30. pangea/services/audit/util.py +10 -10
  31. pangea/services/authn/authn.py +39 -31
  32. pangea/services/authn/models.py +183 -148
  33. pangea/services/authz.py +108 -60
  34. pangea/services/base.py +7 -4
  35. pangea/services/embargo.py +6 -0
  36. pangea/services/file_scan.py +8 -2
  37. pangea/services/intel.py +36 -19
  38. pangea/services/redact.py +14 -476
  39. pangea/services/sanitize.py +5 -1
  40. pangea/services/share/share.py +13 -7
  41. pangea/services/vault/models/asymmetric.py +4 -0
  42. pangea/services/vault/models/common.py +15 -12
  43. pangea/services/vault/models/keys.py +4 -9
  44. pangea/services/vault/models/secret.py +3 -8
  45. pangea/services/vault/models/symmetric.py +4 -0
  46. pangea/services/vault/vault.py +69 -59
  47. pangea/tools.py +13 -9
  48. pangea/utils.py +3 -5
  49. pangea/verify_audit.py +23 -27
  50. {pangea_sdk-6.2.0b1.dist-info → pangea_sdk-6.3.0.dist-info}/METADATA +36 -17
  51. pangea_sdk-6.3.0.dist-info/RECORD +60 -0
  52. {pangea_sdk-6.2.0b1.dist-info → pangea_sdk-6.3.0.dist-info}/WHEEL +1 -1
  53. pangea/asyncio/services/management.py +0 -576
  54. pangea/services/management.py +0 -720
  55. pangea_sdk-6.2.0b1.dist-info/RECORD +0 -62
@@ -1,6 +1,10 @@
1
1
  from __future__ import annotations
2
2
 
3
- from typing import Any, Dict, Generic, List, Literal, Optional, TypeVar, overload
3
+ from collections.abc import Sequence
4
+ from typing import Generic, Literal, Optional, overload
5
+
6
+ from pydantic import BaseModel, ConfigDict
7
+ from typing_extensions import TypeVar
4
8
 
5
9
  from pangea.config import PangeaConfig
6
10
  from pangea.response import APIRequestModel, APIResponseModel, PangeaResponse, PangeaResponseResult
@@ -17,6 +21,13 @@ MaliciousEntityAction = Literal["report", "defang", "disabled", "block"]
17
21
  PiiEntityAction = Literal["disabled", "report", "block", "mask", "partial_masking", "replacement", "hash", "fpe"]
18
22
 
19
23
 
24
+ class Message(BaseModel):
25
+ model_config = ConfigDict(extra="forbid")
26
+
27
+ role: str
28
+ content: str
29
+
30
+
20
31
  class CodeDetectionOverride(APIRequestModel):
21
32
  disabled: Optional[bool] = None
22
33
  action: Optional[Literal["report", "block"]] = None
@@ -24,14 +35,14 @@ class CodeDetectionOverride(APIRequestModel):
24
35
 
25
36
  class LanguageDetectionOverride(APIRequestModel):
26
37
  disabled: Optional[bool] = None
27
- allow: Optional[List[str]] = None
28
- block: Optional[List[str]] = None
29
- report: Optional[List[str]] = None
38
+ allow: Optional[list[str]] = None
39
+ block: Optional[list[str]] = None
40
+ report: Optional[list[str]] = None
30
41
 
31
42
 
32
43
  class TopicDetectionOverride(APIRequestModel):
33
44
  disabled: Optional[bool] = None
34
- block: Optional[List[str]] = None
45
+ block: Optional[list[str]] = None
35
46
 
36
47
 
37
48
  class PromptInjectionOverride(APIRequestModel):
@@ -179,7 +190,7 @@ class PromptInjectionResult(APIResponseModel):
179
190
  action: str
180
191
  """The action taken by this Detector"""
181
192
 
182
- analyzer_responses: List[AnalyzerResponse]
193
+ analyzer_responses: list[AnalyzerResponse]
183
194
  """Triggered prompt injection analyzers."""
184
195
 
185
196
 
@@ -192,20 +203,20 @@ class PiiEntity(APIResponseModel):
192
203
 
193
204
 
194
205
  class PiiEntityResult(APIResponseModel):
195
- entities: List[PiiEntity]
206
+ entities: list[PiiEntity]
196
207
  """Detected redaction rules."""
197
208
 
198
209
 
199
210
  class MaliciousEntity(APIResponseModel):
200
211
  type: str
201
212
  value: str
202
- action: str
213
+ action: Optional[str] = None
203
214
  start_pos: Optional[int] = None
204
- raw: Optional[Dict[str, Any]] = None
215
+ raw: Optional[dict[str, object]] = None
205
216
 
206
217
 
207
218
  class MaliciousEntityResult(APIResponseModel):
208
- entities: List[MaliciousEntity]
219
+ entities: list[MaliciousEntity]
209
220
  """Detected harmful items."""
210
221
 
211
222
 
@@ -215,11 +226,11 @@ class CustomEntity(APIResponseModel):
215
226
  action: str
216
227
  """The action taken on this Entity"""
217
228
  start_pos: Optional[int] = None
218
- raw: Optional[Dict[str, Any]] = None
229
+ raw: Optional[dict[str, object]] = None
219
230
 
220
231
 
221
232
  class CustomEntityResult(APIResponseModel):
222
- entities: List[CustomEntity]
233
+ entities: list[CustomEntity]
223
234
  """Detected redaction rules."""
224
235
 
225
236
 
@@ -233,7 +244,7 @@ class SecretsEntity(APIResponseModel):
233
244
 
234
245
 
235
246
  class SecretsEntityResult(APIResponseModel):
236
- entities: List[SecretsEntity]
247
+ entities: list[SecretsEntity]
237
248
  """Detected redaction rules."""
238
249
 
239
250
 
@@ -266,22 +277,22 @@ class TextGuardDetectors(APIResponseModel):
266
277
  prompt_injection: Optional[TextGuardDetector[PromptInjectionResult]] = None
267
278
  pii_entity: Optional[TextGuardDetector[PiiEntityResult]] = None
268
279
  malicious_entity: Optional[TextGuardDetector[MaliciousEntityResult]] = None
269
- custom_entity: Optional[TextGuardDetector[Any]] = None
280
+ custom_entity: Optional[TextGuardDetector[object]] = None
270
281
  secrets_detection: Optional[TextGuardDetector[SecretsEntityResult]] = None
271
- profanity_and_toxicity: Optional[TextGuardDetector[Any]] = None
282
+ profanity_and_toxicity: Optional[TextGuardDetector[object]] = None
272
283
  language_detection: Optional[TextGuardDetector[LanguageDetectionResult]] = None
273
284
  topic_detection: Optional[TextGuardDetector[TopicDetectionResult]] = None
274
285
  code_detection: Optional[TextGuardDetector[CodeDetectionResult]] = None
275
286
 
276
287
 
277
- class TextGuardResult(PangeaResponseResult, Generic[_T]):
288
+ class TextGuardResult(PangeaResponseResult):
278
289
  detectors: TextGuardDetectors
279
290
  """Result of the recipe analyzing and input prompt."""
280
291
 
281
292
  prompt_text: Optional[str] = None
282
293
  """Updated prompt text, if applicable."""
283
294
 
284
- prompt_messages: Optional[_T] = None
295
+ prompt_messages: Optional[object] = None
285
296
  """Updated structured prompt, if applicable."""
286
297
 
287
298
  blocked: bool
@@ -345,7 +356,7 @@ class AIGuard(ServiceBase):
345
356
  debug: bool | None = None,
346
357
  overrides: Overrides | None = None,
347
358
  log_fields: LogFields | None = None,
348
- ) -> PangeaResponse[TextGuardResult[None]]:
359
+ ) -> PangeaResponse[TextGuardResult]:
349
360
  """
350
361
  Text Guard for scanning LLM inputs and outputs
351
362
 
@@ -373,12 +384,12 @@ class AIGuard(ServiceBase):
373
384
  def guard_text(
374
385
  self,
375
386
  *,
376
- messages: _T,
387
+ messages: Sequence[Message],
377
388
  recipe: str | None = None,
378
389
  debug: bool | None = None,
379
390
  overrides: Overrides | None = None,
380
391
  log_fields: LogFields | None = None,
381
- ) -> PangeaResponse[TextGuardResult[_T]]:
392
+ ) -> PangeaResponse[TextGuardResult]:
382
393
  """
383
394
  Text Guard for scanning LLM inputs and outputs
384
395
 
@@ -400,19 +411,19 @@ class AIGuard(ServiceBase):
400
411
  log_field: Additional fields to include in activity log
401
412
 
402
413
  Examples:
403
- response = ai_guard.guard_text(messages=[{"role": "user", "content": "hello world"}])
414
+ response = ai_guard.guard_text(messages=[Message(role="user", content="hello world")])
404
415
  """
405
416
 
406
- def guard_text( # type: ignore[misc]
417
+ def guard_text(
407
418
  self,
408
419
  text: str | None = None,
409
420
  *,
410
- messages: _T | None = None,
421
+ messages: Sequence[Message] | None = None,
411
422
  recipe: str | None = None,
412
423
  debug: bool | None = None,
413
424
  overrides: Overrides | None = None,
414
425
  log_fields: LogFields | None = None,
415
- ) -> PangeaResponse[TextGuardResult[None]]:
426
+ ) -> PangeaResponse[TextGuardResult]:
416
427
  """
417
428
  Text Guard for scanning LLM inputs and outputs
418
429
 
@@ -1,20 +1,21 @@
1
1
  # Copyright 2022 Pangea Cyber Corporation
2
2
  # Author: Pangea Cyber Corporation
3
+
4
+ # TODO: Modernize.
5
+ # ruff: noqa: UP006, UP035
6
+
3
7
  from __future__ import annotations
4
8
 
5
9
  import datetime
6
10
  import json
7
- from typing import Any, Dict, Iterable, List, Optional, Sequence, Set, Tuple, Union, cast, overload
8
-
9
- from pydantic import TypeAdapter
10
- from typing_extensions import Literal
11
+ from collections.abc import Mapping
12
+ from typing import Any, Dict, Iterable, List, Optional, Sequence, Set, Tuple, Union
11
13
 
12
14
  import pangea.exceptions as pexc
13
15
  from pangea.config import PangeaConfig
14
16
  from pangea.response import PangeaResponse, PangeaResponseResult
15
17
  from pangea.services.audit.exceptions import AuditException, EventCorruption
16
18
  from pangea.services.audit.models import (
17
- AuditSchema,
18
19
  DownloadFormat,
19
20
  DownloadRequest,
20
21
  DownloadResult,
@@ -22,7 +23,6 @@ from pangea.services.audit.models import (
22
23
  EventEnvelope,
23
24
  EventVerification,
24
25
  ExportRequest,
25
- ForwardingConfiguration,
26
26
  LogBulkRequest,
27
27
  LogBulkResult,
28
28
  LogEvent,
@@ -40,9 +40,6 @@ from pangea.services.audit.models import (
40
40
  SearchRequest,
41
41
  SearchResultOutput,
42
42
  SearchResultRequest,
43
- ServiceConfig,
44
- ServiceConfigFilter,
45
- ServiceConfigListResult,
46
43
  )
47
44
  from pangea.services.audit.signing import Signer, Verifier
48
45
  from pangea.services.audit.util import (
@@ -63,7 +60,7 @@ from pangea.utils import canonicalize_nested_json
63
60
 
64
61
  class AuditBase:
65
62
  def __init__(
66
- self, private_key_file: str = "", public_key_info: dict[str, str] = {}, tenant_id: str | None = None
63
+ self, private_key_file: str = "", public_key_info: Mapping[str, str] = {}, tenant_id: str | None = None
67
64
  ) -> None:
68
65
  self.pub_roots: Dict[int, PublishedRoot] = {}
69
66
  self.buffer_data: Optional[str] = None
@@ -98,7 +95,7 @@ class AuditBase:
98
95
  return input # type: ignore[return-value]
99
96
 
100
97
  def _process_log(self, event: dict, sign_local: bool) -> LogEvent:
101
- if event.get("tenant_id", None) is None and self.tenant_id:
98
+ if event.get("tenant_id") is None and self.tenant_id:
102
99
  event["tenant_id"] = self.tenant_id
103
100
 
104
101
  event = {k: v for k, v in event.items() if v is not None}
@@ -229,10 +226,7 @@ class AuditBase:
229
226
  tree_sizes.add(result.root.size)
230
227
  tree_sizes.difference_update(self.pub_roots.keys())
231
228
 
232
- if tree_sizes:
233
- arweave_roots = get_arweave_published_roots(result.root.tree_name, tree_sizes)
234
- else:
235
- arweave_roots = {}
229
+ arweave_roots = get_arweave_published_roots(result.root.tree_name, tree_sizes) if tree_sizes else {}
236
230
 
237
231
  return tree_sizes, arweave_roots
238
232
 
@@ -344,6 +338,7 @@ class AuditBase:
344
338
  public_key = get_public_key(audit_envelope.public_key)
345
339
 
346
340
  if audit_envelope and audit_envelope.signature and public_key:
341
+ assert audit_envelope.event
347
342
  v = Verifier()
348
343
  verification = v.verify_signature(
349
344
  audit_envelope.signature,
@@ -393,7 +388,7 @@ class Audit(ServiceBase, AuditBase):
393
388
  token: str,
394
389
  config: PangeaConfig | None = None,
395
390
  private_key_file: str = "",
396
- public_key_info: dict[str, str] = {},
391
+ public_key_info: Mapping[str, str] = {},
397
392
  tenant_id: str | None = None,
398
393
  logger_name: str = "pangea",
399
394
  config_id: str | None = None,
@@ -465,7 +460,7 @@ class Audit(ServiceBase, AuditBase):
465
460
  A PangeaResponse where the hash of event data and optional verbose
466
461
  results are returned in the response.result field.
467
462
  Available response fields can be found in our
468
- [API documentation](https://pangea.cloud/docs/api/audit#/v1/log).
463
+ [API documentation](https://pangea.cloud/docs/api/audit#/v1/log-post).
469
464
 
470
465
  Examples:
471
466
  log_response = audit.log(
@@ -513,7 +508,7 @@ class Audit(ServiceBase, AuditBase):
513
508
  Returns:
514
509
  A PangeaResponse where the hash of event data and optional verbose
515
510
  results are returned in the response.result field.
516
- Available response fields can be found in our [API documentation](https://pangea.cloud/docs/api/audit#/v1/log).
511
+ Available response fields can be found in our [API documentation](https://pangea.cloud/docs/api/audit#/v1/log-post).
517
512
 
518
513
  Examples:
519
514
  response = audit.log_event({"message": "hello world"}, verbose=True)
@@ -551,7 +546,7 @@ class Audit(ServiceBase, AuditBase):
551
546
  Returns:
552
547
  A PangeaResponse where the hash of event data and optional verbose
553
548
  results are returned in the response.result field.
554
- Available response fields can be found in our [API documentation](https://pangea.cloud/docs/api/audit#/v2/log).
549
+ Available response fields can be found in our [API documentation](https://pangea.cloud/docs/api/audit#/v2/log-post).
555
550
 
556
551
  Examples:
557
552
  log_response = audit.log_bulk(
@@ -592,7 +587,7 @@ class Audit(ServiceBase, AuditBase):
592
587
  Returns:
593
588
  A PangeaResponse where the hash of event data and optional verbose
594
589
  results are returned in the response.result field.
595
- Available response fields can be found in our [API documentation](https://pangea.cloud/docs/api/audit#/v2/log_async).
590
+ Available response fields can be found in our [API documentation](https://pangea.cloud/docs/api/audit#/v2/log_async-post).
596
591
 
597
592
  Examples:
598
593
  log_response = audit.log_bulk_async(
@@ -667,8 +662,8 @@ class Audit(ServiceBase, AuditBase):
667
662
 
668
663
  Returns:
669
664
  A PangeaResponse[SearchOutput] where the first page of matched events is returned in the
670
- response.result field. Available response fields can be found in our [API documentation](https://pangea.cloud/docs/api/audit#/v1/search).
671
- Pagination can be found in the [search results endpoint](https://pangea.cloud/docs/api/audit#/v1/results).
665
+ response.result field. Available response fields can be found in our [API documentation](https://pangea.cloud/docs/api/audit#/v1/search-post).
666
+ Pagination can be found in the [search results endpoint](https://pangea.cloud/docs/api/audit#/v1/results-post).
672
667
 
673
668
  Examples:
674
669
  response = audit.search(
@@ -927,298 +922,6 @@ class Audit(ServiceBase, AuditBase):
927
922
  )
928
923
  return self.request.post("v1/download_results", DownloadResult, data=input.model_dump(exclude_none=True))
929
924
 
930
- def get_service_config(self, config_id: str) -> PangeaResponse[ServiceConfig]:
931
- """
932
- Get a service config.
933
-
934
- OperationId: audit_post_v1beta_config
935
-
936
- Args:
937
- id: The config ID
938
- """
939
-
940
- response = self.request.post("v1beta/config", PangeaResponseResult, data={"id": config_id})
941
- response.result = TypeAdapter(ServiceConfig).validate_python(response.json["result"])
942
- return cast(PangeaResponse[ServiceConfig], response)
943
-
944
- @overload
945
- def create_service_config(
946
- self,
947
- version: Literal[1],
948
- name: str,
949
- *,
950
- cold_query_result_retention: str | None = None,
951
- hot_storage: str | None = None,
952
- query_result_retention: str | None = None,
953
- redact_service_config_id: str | None = None,
954
- redaction_fields: Sequence[str] | None = None,
955
- retention: str | None = None,
956
- vault_key_id: str | None = None,
957
- vault_service_config_id: str | None = None,
958
- vault_sign: bool | None = None,
959
- ) -> PangeaResponse[ServiceConfig]:
960
- """
961
- Create a v1 service config.
962
-
963
- OperationId: audit_post_v1beta_config_create
964
-
965
- Args:
966
- name: Configuration name
967
- cold_query_result_retention: Retention window for cold query result / state information.
968
- hot_storage: Retention window to keep audit logs in hot storage.
969
- query_result_retention: Length of time to preserve server-side query result caching.
970
- redact_service_config_id: A redact service config that will be used to redact PII from logs.
971
- redaction_fields: Fields to perform redaction against.
972
- retention: Retention window to store audit logs.
973
- vault_key_id: ID of the Vault key used for signing. If missing, use a default Audit key.
974
- vault_service_config_id: A vault service config that will be used to sign logs.
975
- vault_sign: Enable/disable event signing.
976
- """
977
-
978
- @overload
979
- def create_service_config(
980
- self,
981
- version: Literal[2],
982
- name: str,
983
- *,
984
- schema: AuditSchema,
985
- cold_query_result_retention: str | None = None,
986
- forwarding_configuration: ForwardingConfiguration | None = None,
987
- hot_storage: str | None = None,
988
- query_result_retention: str | None = None,
989
- redact_service_config_id: str | None = None,
990
- retention: str | None = None,
991
- vault_key_id: str | None = None,
992
- vault_service_config_id: str | None = None,
993
- vault_sign: bool | None = None,
994
- ) -> PangeaResponse[ServiceConfig]:
995
- """
996
- Create a v2 service config.
997
-
998
- OperationId: audit_post_v1beta_config_create
999
-
1000
- Args:
1001
- name: Configuration name
1002
- schema: Audit log field configuration. Only settable at create time.
1003
- cold_query_result_retention: Retention window for cold query result / state information.
1004
- forwarding_configuration: Configuration for forwarding audit logs to external systems.
1005
- hot_storage: Retention window to keep audit logs in hot storage.
1006
- query_result_retention: Length of time to preserve server-side query result caching.
1007
- redact_service_config_id: A redact service config that will be used to redact PII from logs.
1008
- retention: Retention window to store audit logs.
1009
- vault_key_id: ID of the Vault key used for signing. If missing, use a default Audit key.
1010
- vault_service_config_id: A vault service config that will be used to sign logs.
1011
- vault_sign: Enable/disable event signing.
1012
- """
1013
-
1014
- @overload
1015
- def create_service_config(
1016
- self,
1017
- version: Literal[3],
1018
- name: str,
1019
- *,
1020
- schema: AuditSchema,
1021
- cold_storage: str | None = None,
1022
- hot_storage: str | None = None,
1023
- warm_storage: str | None = None,
1024
- redact_service_config_id: str | None = None,
1025
- vault_service_config_id: str | None = None,
1026
- vault_key_id: str | None = None,
1027
- vault_sign: bool | None = None,
1028
- forwarding_configuration: ForwardingConfiguration | None = None,
1029
- ) -> PangeaResponse[ServiceConfig]:
1030
- """
1031
- Create a v3 service config.
1032
-
1033
- OperationId: audit_post_v1beta_config_create
1034
-
1035
- Args:
1036
- name: Configuration name
1037
- schema: Audit log field configuration. Only settable at create time.
1038
- cold_storage: Retention window for logs in cold storage. Deleted afterwards.
1039
- hot_storage: Retention window for logs in hot storage. Migrated to warm, cold, or deleted afterwards.
1040
- warm_storage: Retention window for logs in warm storage. Migrated to cold or deleted afterwards.
1041
- redact_service_config_id: A redact service config that will be used to redact PII from logs.
1042
- vault_service_config_id: A vault service config that will be used to sign logs.
1043
- vault_key_id: ID of the Vault key used for signing. If missing, use a default Audit key.
1044
- vault_sign: Enable/disable event signing.
1045
- forwarding_configuration: Configuration for forwarding audit logs to external systems.
1046
- """
1047
-
1048
- def create_service_config(
1049
- self,
1050
- version: Literal[1, 2, 3],
1051
- name: str,
1052
- *,
1053
- cold_query_result_retention: str | None = None,
1054
- cold_storage: str | None = None,
1055
- forwarding_configuration: ForwardingConfiguration | None = None,
1056
- hot_storage: str | None = None,
1057
- query_result_retention: str | None = None,
1058
- redact_service_config_id: str | None = None,
1059
- redaction_fields: Sequence[str] | None = None,
1060
- retention: str | None = None,
1061
- schema: AuditSchema | None = None,
1062
- vault_key_id: str | None = None,
1063
- vault_service_config_id: str | None = None,
1064
- vault_sign: bool | None = None,
1065
- warm_storage: str | None = None,
1066
- ) -> PangeaResponse[ServiceConfig]:
1067
- """
1068
- Create a service config.
1069
-
1070
- OperationId: audit_post_v1beta_config_create
1071
-
1072
- Args:
1073
- name: Configuration name
1074
- cold_query_result_retention: Retention window for cold query result / state information.
1075
- cold_storage: Retention window for logs in cold storage. Deleted afterwards.
1076
- forwarding_configuration: Configuration for forwarding audit logs to external systems.
1077
- hot_storage: Retention window to keep audit logs in hot storage.
1078
- query_result_retention: Length of time to preserve server-side query result caching.
1079
- redact_service_config_id: A redact service config that will be used to redact PII from logs.
1080
- redaction_fields: Fields to perform redaction against.
1081
- retention: Retention window to store audit logs.
1082
- schema: Audit log field configuration. Only settable at create time.
1083
- vault_key_id: ID of the Vault key used for signing. If missing, use a default Audit key.
1084
- vault_service_config_id: A vault service config that will be used to sign logs.
1085
- vault_sign: Enable/disable event signing.
1086
- warm_storage: Retention window for logs in warm storage. Migrated to cold or deleted afterwards.
1087
- """
1088
-
1089
- response = self.request.post(
1090
- "v1beta/config/create",
1091
- PangeaResponseResult,
1092
- data={
1093
- "cold_query_result_retention": cold_query_result_retention,
1094
- "cold_storage": cold_storage,
1095
- "forwarding_configuration": forwarding_configuration,
1096
- "hot_storage": hot_storage,
1097
- "name": name,
1098
- "query_result_retention": query_result_retention,
1099
- "redact_service_config_id": redact_service_config_id,
1100
- "redaction_fields": redaction_fields,
1101
- "retention": retention,
1102
- "schema": schema,
1103
- "vault_key_id": vault_key_id,
1104
- "vault_service_config_id": vault_service_config_id,
1105
- "vault_sign": vault_sign,
1106
- "warm_storage": warm_storage,
1107
- "version": version,
1108
- },
1109
- )
1110
- response.result = TypeAdapter(ServiceConfig).validate_python(response.json["result"])
1111
- return cast(PangeaResponse[ServiceConfig], response)
1112
-
1113
- def update_service_config(
1114
- self,
1115
- config_id: str,
1116
- *,
1117
- name: str,
1118
- updated_at: datetime.datetime,
1119
- # Optionals.
1120
- cold_query_result_retention: str | None = None,
1121
- cold_storage: str | None = None,
1122
- forwarding_configuration: ForwardingConfiguration | None = None,
1123
- hot_storage: str | None = None,
1124
- query_result_retention: str | None = None,
1125
- redact_service_config_id: str | None = None,
1126
- retention: str | None = None,
1127
- schema: AuditSchema | None = None,
1128
- vault_key_id: str | None = None,
1129
- vault_service_config_id: str | None = None,
1130
- vault_sign: bool | None = None,
1131
- warm_storage: str | None = None,
1132
- ) -> PangeaResponse[ServiceConfig]:
1133
- """
1134
- Update a service config.
1135
-
1136
- OperationId: audit_post_v1beta_config_update
1137
-
1138
- Args:
1139
- id: The config ID
1140
- name: Configuration name
1141
- updated_at: The DB timestamp when this config was last updated at
1142
- cold_query_result_retention: Retention window for cold query result / state information.
1143
- cold_storage: Retention window for logs in cold storage. Deleted afterwards.
1144
- forwarding_configuration: Configuration for forwarding audit logs to external systems
1145
- hot_storage: Retention window to keep audit logs in hot storage
1146
- query_result_retention: Length of time to preserve server-side query result caching
1147
- redact_service_config_id: A redact service config that will be used to redact PII from logs
1148
- retention: Retention window to store audit logs
1149
- schema: Audit log field configuration
1150
- vault_key_id: ID of the Vault key used for signing. If missing, use a default Audit key.
1151
- vault_service_config_id: A vault service config that will be used to sign logs
1152
- vault_sign: Enable/disable event signing
1153
- warm_storage: Retention window for logs in warm storage. Migrated to cold or deleted afterwards.
1154
- """
1155
-
1156
- response = self.request.post(
1157
- "v1beta/config/update",
1158
- PangeaResponseResult,
1159
- data={
1160
- "id": config_id,
1161
- "name": name,
1162
- "updated_at": updated_at,
1163
- # Optionals.
1164
- "cold_query_result_retention": cold_query_result_retention,
1165
- "cold_storage": cold_storage,
1166
- "forwarding_configuration": forwarding_configuration,
1167
- "hot_storage": hot_storage,
1168
- "query_result_retention": query_result_retention,
1169
- "redact_service_config_id": redact_service_config_id,
1170
- "retention": retention,
1171
- "schema": schema,
1172
- "vault_key_id": vault_key_id,
1173
- "vault_service_config_id": vault_service_config_id,
1174
- "vault_sign": vault_sign,
1175
- "warm_storage": warm_storage,
1176
- },
1177
- )
1178
- response.result = TypeAdapter(ServiceConfig).validate_python(response.json["result"])
1179
- return cast(PangeaResponse[ServiceConfig], response)
1180
-
1181
- def delete_service_config(self, config_id: str) -> PangeaResponse[ServiceConfig]:
1182
- """
1183
- Delete a service config.
1184
-
1185
- OperationId: audit_post_v1beta_config_delete
1186
-
1187
- Args:
1188
- id: The config ID
1189
- """
1190
-
1191
- response = self.request.post("v1beta/config/delete", PangeaResponseResult, data={"id": config_id})
1192
- response.result = TypeAdapter(ServiceConfig).validate_python(response.json["result"])
1193
- return cast(PangeaResponse[ServiceConfig], response)
1194
-
1195
- def list_service_configs(
1196
- self,
1197
- *,
1198
- filter: ServiceConfigFilter | None = None,
1199
- last: str | None = None,
1200
- order: Literal["asc", "desc"] | None = None,
1201
- order_by: Literal["id", "created_at", "updated_at"] | None = None,
1202
- size: int | None = None,
1203
- ) -> PangeaResponse[ServiceConfigListResult]:
1204
- """
1205
- List service configs.
1206
-
1207
- OperationId: audit_post_v1beta_config_list
1208
-
1209
- Args:
1210
- last: Reflected value from a previous response to obtain the next page of results.
1211
- order: Order results asc(ending) or desc(ending).
1212
- order_by: Which field to order results by.
1213
- size: Maximum results to include in the response.
1214
- """
1215
-
1216
- return self.request.post(
1217
- "v1beta/config/list",
1218
- ServiceConfigListResult,
1219
- data={"filter": filter, "last": last, "order": order, "order_by": order_by, "size": size},
1220
- )
1221
-
1222
925
  def update_published_roots(self, result: SearchResultOutput):
1223
926
  """Fetches series of published root hashes from Arweave
1224
927