pangea-sdk 6.3.0__py3-none-any.whl → 6.5.0b1__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 +152 -19
- pangea/asyncio/services/__init__.py +1 -0
- pangea/asyncio/services/ai_guard.py +205 -32
- pangea/asyncio/services/audit.py +301 -1
- pangea/asyncio/services/management.py +576 -0
- pangea/asyncio/services/prompt_guard.py +112 -2
- pangea/asyncio/services/redact.py +265 -4
- pangea/request.py +154 -19
- pangea/services/__init__.py +1 -0
- pangea/services/ai_guard.py +771 -59
- pangea/services/audit/audit.py +301 -1
- pangea/services/audit/models.py +273 -1
- pangea/services/management.py +720 -0
- pangea/services/prompt_guard.py +193 -2
- pangea/services/redact.py +473 -7
- {pangea_sdk-6.3.0.dist-info → pangea_sdk-6.5.0b1.dist-info}/METADATA +1 -1
- {pangea_sdk-6.3.0.dist-info → pangea_sdk-6.5.0b1.dist-info}/RECORD +19 -17
- {pangea_sdk-6.3.0.dist-info → pangea_sdk-6.5.0b1.dist-info}/WHEEL +0 -0
pangea/asyncio/services/audit.py
CHANGED
@@ -8,7 +8,10 @@ from __future__ import annotations
|
|
8
8
|
|
9
9
|
import datetime
|
10
10
|
from collections.abc import Mapping
|
11
|
-
from typing import Any, Dict, Iterable, List, Optional, Sequence, Union
|
11
|
+
from typing import Any, Dict, Iterable, List, Optional, Sequence, Union, cast, overload
|
12
|
+
|
13
|
+
from pydantic import TypeAdapter
|
14
|
+
from typing_extensions import Literal
|
12
15
|
|
13
16
|
import pangea.exceptions as pexc
|
14
17
|
from pangea.asyncio.services.base import ServiceBaseAsync
|
@@ -17,11 +20,13 @@ from pangea.response import PangeaResponse, PangeaResponseResult
|
|
17
20
|
from pangea.services.audit.audit import AuditBase
|
18
21
|
from pangea.services.audit.exceptions import AuditException
|
19
22
|
from pangea.services.audit.models import (
|
23
|
+
AuditSchema,
|
20
24
|
DownloadFormat,
|
21
25
|
DownloadRequest,
|
22
26
|
DownloadResult,
|
23
27
|
Event,
|
24
28
|
ExportRequest,
|
29
|
+
ForwardingConfiguration,
|
25
30
|
LogBulkResult,
|
26
31
|
LogResult,
|
27
32
|
PublishedRoot,
|
@@ -34,6 +39,9 @@ from pangea.services.audit.models import (
|
|
34
39
|
SearchRequest,
|
35
40
|
SearchResultOutput,
|
36
41
|
SearchResultRequest,
|
42
|
+
ServiceConfig,
|
43
|
+
ServiceConfigFilter,
|
44
|
+
ServiceConfigListResult,
|
37
45
|
)
|
38
46
|
from pangea.services.audit.util import format_datetime
|
39
47
|
|
@@ -595,6 +603,298 @@ class AuditAsync(ServiceBaseAsync, AuditBase):
|
|
595
603
|
)
|
596
604
|
return await self.request.post("v1/download_results", DownloadResult, data=input.model_dump(exclude_none=True))
|
597
605
|
|
606
|
+
async def get_service_config(self, config_id: str) -> PangeaResponse[ServiceConfig]:
|
607
|
+
"""
|
608
|
+
Get a service config.
|
609
|
+
|
610
|
+
OperationId: audit_post_v1beta_config
|
611
|
+
|
612
|
+
Args:
|
613
|
+
id: The config ID
|
614
|
+
"""
|
615
|
+
|
616
|
+
response = await self.request.post("v1beta/config", PangeaResponseResult, data={"id": config_id})
|
617
|
+
response.result = TypeAdapter(ServiceConfig).validate_python(response.json["result"])
|
618
|
+
return cast(PangeaResponse[ServiceConfig], response)
|
619
|
+
|
620
|
+
@overload
|
621
|
+
async def create_service_config(
|
622
|
+
self,
|
623
|
+
version: Literal[1],
|
624
|
+
name: str,
|
625
|
+
*,
|
626
|
+
cold_query_result_retention: str | None = None,
|
627
|
+
hot_storage: str | None = None,
|
628
|
+
query_result_retention: str | None = None,
|
629
|
+
redact_service_config_id: str | None = None,
|
630
|
+
redaction_fields: Sequence[str] | None = None,
|
631
|
+
retention: str | None = None,
|
632
|
+
vault_key_id: str | None = None,
|
633
|
+
vault_service_config_id: str | None = None,
|
634
|
+
vault_sign: bool | None = None,
|
635
|
+
) -> PangeaResponse[ServiceConfig]:
|
636
|
+
"""
|
637
|
+
Create a v1 service config.
|
638
|
+
|
639
|
+
OperationId: audit_post_v1beta_config_create
|
640
|
+
|
641
|
+
Args:
|
642
|
+
name: Configuration name
|
643
|
+
cold_query_result_retention: Retention window for cold query result / state information.
|
644
|
+
hot_storage: Retention window to keep audit logs in hot storage.
|
645
|
+
query_result_retention: Length of time to preserve server-side query result caching.
|
646
|
+
redact_service_config_id: A redact service config that will be used to redact PII from logs.
|
647
|
+
redaction_fields: Fields to perform redaction against.
|
648
|
+
retention: Retention window to store audit logs.
|
649
|
+
vault_key_id: ID of the Vault key used for signing. If missing, use a default Audit key.
|
650
|
+
vault_service_config_id: A vault service config that will be used to sign logs.
|
651
|
+
vault_sign: Enable/disable event signing.
|
652
|
+
"""
|
653
|
+
|
654
|
+
@overload
|
655
|
+
async def create_service_config(
|
656
|
+
self,
|
657
|
+
version: Literal[2],
|
658
|
+
name: str,
|
659
|
+
*,
|
660
|
+
schema: AuditSchema,
|
661
|
+
cold_query_result_retention: str | None = None,
|
662
|
+
forwarding_configuration: ForwardingConfiguration | None = None,
|
663
|
+
hot_storage: str | None = None,
|
664
|
+
query_result_retention: str | None = None,
|
665
|
+
redact_service_config_id: str | None = None,
|
666
|
+
retention: str | None = None,
|
667
|
+
vault_key_id: str | None = None,
|
668
|
+
vault_service_config_id: str | None = None,
|
669
|
+
vault_sign: bool | None = None,
|
670
|
+
) -> PangeaResponse[ServiceConfig]:
|
671
|
+
"""
|
672
|
+
Create a v2 service config.
|
673
|
+
|
674
|
+
OperationId: audit_post_v1beta_config_create
|
675
|
+
|
676
|
+
Args:
|
677
|
+
name: Configuration name
|
678
|
+
schema: Audit log field configuration. Only settable at create time.
|
679
|
+
cold_query_result_retention: Retention window for cold query result / state information.
|
680
|
+
forwarding_configuration: Configuration for forwarding audit logs to external systems.
|
681
|
+
hot_storage: Retention window to keep audit logs in hot storage.
|
682
|
+
query_result_retention: Length of time to preserve server-side query result caching.
|
683
|
+
redact_service_config_id: A redact service config that will be used to redact PII from logs.
|
684
|
+
retention: Retention window to store audit logs.
|
685
|
+
vault_key_id: ID of the Vault key used for signing. If missing, use a default Audit key.
|
686
|
+
vault_service_config_id: A vault service config that will be used to sign logs.
|
687
|
+
vault_sign: Enable/disable event signing.
|
688
|
+
"""
|
689
|
+
|
690
|
+
@overload
|
691
|
+
async def create_service_config(
|
692
|
+
self,
|
693
|
+
version: Literal[3],
|
694
|
+
name: str,
|
695
|
+
*,
|
696
|
+
schema: AuditSchema,
|
697
|
+
cold_storage: str | None = None,
|
698
|
+
hot_storage: str | None = None,
|
699
|
+
warm_storage: str | None = None,
|
700
|
+
redact_service_config_id: str | None = None,
|
701
|
+
vault_service_config_id: str | None = None,
|
702
|
+
vault_key_id: str | None = None,
|
703
|
+
vault_sign: bool | None = None,
|
704
|
+
forwarding_configuration: ForwardingConfiguration | None = None,
|
705
|
+
) -> PangeaResponse[ServiceConfig]:
|
706
|
+
"""
|
707
|
+
Create a v3 service config.
|
708
|
+
|
709
|
+
OperationId: audit_post_v1beta_config_create
|
710
|
+
|
711
|
+
Args:
|
712
|
+
name: Configuration name
|
713
|
+
schema: Audit log field configuration. Only settable at create time.
|
714
|
+
cold_storage: Retention window for logs in cold storage. Deleted afterwards.
|
715
|
+
hot_storage: Retention window for logs in hot storage. Migrated to warm, cold, or deleted afterwards.
|
716
|
+
warm_storage: Retention window for logs in warm storage. Migrated to cold or deleted afterwards.
|
717
|
+
redact_service_config_id: A redact service config that will be used to redact PII from logs.
|
718
|
+
vault_service_config_id: A vault service config that will be used to sign logs.
|
719
|
+
vault_key_id: ID of the Vault key used for signing. If missing, use a default Audit key.
|
720
|
+
vault_sign: Enable/disable event signing.
|
721
|
+
forwarding_configuration: Configuration for forwarding audit logs to external systems.
|
722
|
+
"""
|
723
|
+
|
724
|
+
async def create_service_config(
|
725
|
+
self,
|
726
|
+
version: Literal[1, 2, 3],
|
727
|
+
name: str,
|
728
|
+
*,
|
729
|
+
cold_query_result_retention: str | None = None,
|
730
|
+
cold_storage: str | None = None,
|
731
|
+
forwarding_configuration: ForwardingConfiguration | None = None,
|
732
|
+
hot_storage: str | None = None,
|
733
|
+
query_result_retention: str | None = None,
|
734
|
+
redact_service_config_id: str | None = None,
|
735
|
+
redaction_fields: Sequence[str] | None = None,
|
736
|
+
retention: str | None = None,
|
737
|
+
schema: AuditSchema | None = None,
|
738
|
+
vault_key_id: str | None = None,
|
739
|
+
vault_service_config_id: str | None = None,
|
740
|
+
vault_sign: bool | None = None,
|
741
|
+
warm_storage: str | None = None,
|
742
|
+
) -> PangeaResponse[ServiceConfig]:
|
743
|
+
"""
|
744
|
+
Create a service config.
|
745
|
+
|
746
|
+
OperationId: audit_post_v1beta_config_create
|
747
|
+
|
748
|
+
Args:
|
749
|
+
name: Configuration name
|
750
|
+
cold_query_result_retention: Retention window for cold query result / state information.
|
751
|
+
cold_storage: Retention window for logs in cold storage. Deleted afterwards.
|
752
|
+
forwarding_configuration: Configuration for forwarding audit logs to external systems.
|
753
|
+
hot_storage: Retention window to keep audit logs in hot storage.
|
754
|
+
query_result_retention: Length of time to preserve server-side query result caching.
|
755
|
+
redact_service_config_id: A redact service config that will be used to redact PII from logs.
|
756
|
+
redaction_fields: Fields to perform redaction against.
|
757
|
+
retention: Retention window to store audit logs.
|
758
|
+
schema: Audit log field configuration. Only settable at create time.
|
759
|
+
vault_key_id: ID of the Vault key used for signing. If missing, use a default Audit key.
|
760
|
+
vault_service_config_id: A vault service config that will be used to sign logs.
|
761
|
+
vault_sign: Enable/disable event signing.
|
762
|
+
warm_storage: Retention window for logs in warm storage. Migrated to cold or deleted afterwards.
|
763
|
+
"""
|
764
|
+
|
765
|
+
response = await self.request.post(
|
766
|
+
"v1beta/config/create",
|
767
|
+
PangeaResponseResult,
|
768
|
+
data={
|
769
|
+
"cold_query_result_retention": cold_query_result_retention,
|
770
|
+
"cold_storage": cold_storage,
|
771
|
+
"forwarding_configuration": forwarding_configuration,
|
772
|
+
"hot_storage": hot_storage,
|
773
|
+
"name": name,
|
774
|
+
"query_result_retention": query_result_retention,
|
775
|
+
"redact_service_config_id": redact_service_config_id,
|
776
|
+
"redaction_fields": redaction_fields,
|
777
|
+
"retention": retention,
|
778
|
+
"schema": schema,
|
779
|
+
"vault_key_id": vault_key_id,
|
780
|
+
"vault_service_config_id": vault_service_config_id,
|
781
|
+
"vault_sign": vault_sign,
|
782
|
+
"warm_storage": warm_storage,
|
783
|
+
"version": version,
|
784
|
+
},
|
785
|
+
)
|
786
|
+
response.result = TypeAdapter(ServiceConfig).validate_python(response.json["result"])
|
787
|
+
return cast(PangeaResponse[ServiceConfig], response)
|
788
|
+
|
789
|
+
async def update_service_config(
|
790
|
+
self,
|
791
|
+
config_id: str,
|
792
|
+
*,
|
793
|
+
name: str,
|
794
|
+
updated_at: datetime.datetime,
|
795
|
+
# Optionals.
|
796
|
+
cold_query_result_retention: str | None = None,
|
797
|
+
cold_storage: str | None = None,
|
798
|
+
forwarding_configuration: ForwardingConfiguration | None = None,
|
799
|
+
hot_storage: str | None = None,
|
800
|
+
query_result_retention: str | None = None,
|
801
|
+
redact_service_config_id: str | None = None,
|
802
|
+
retention: str | None = None,
|
803
|
+
schema: AuditSchema | None = None,
|
804
|
+
vault_key_id: str | None = None,
|
805
|
+
vault_service_config_id: str | None = None,
|
806
|
+
vault_sign: bool | None = None,
|
807
|
+
warm_storage: str | None = None,
|
808
|
+
) -> PangeaResponse[ServiceConfig]:
|
809
|
+
"""
|
810
|
+
Update a service config.
|
811
|
+
|
812
|
+
OperationId: audit_post_v1beta_config_update
|
813
|
+
|
814
|
+
Args:
|
815
|
+
id: The config ID
|
816
|
+
name: Configuration name
|
817
|
+
updated_at: The DB timestamp when this config was last updated at
|
818
|
+
cold_query_result_retention: Retention window for cold query result / state information.
|
819
|
+
cold_storage: Retention window for logs in cold storage. Deleted afterwards.
|
820
|
+
forwarding_configuration: Configuration for forwarding audit logs to external systems
|
821
|
+
hot_storage: Retention window to keep audit logs in hot storage
|
822
|
+
query_result_retention: Length of time to preserve server-side query result caching
|
823
|
+
redact_service_config_id: A redact service config that will be used to redact PII from logs
|
824
|
+
retention: Retention window to store audit logs
|
825
|
+
schema: Audit log field configuration
|
826
|
+
vault_key_id: ID of the Vault key used for signing. If missing, use a default Audit key.
|
827
|
+
vault_service_config_id: A vault service config that will be used to sign logs
|
828
|
+
vault_sign: Enable/disable event signing
|
829
|
+
warm_storage: Retention window for logs in warm storage. Migrated to cold or deleted afterwards.
|
830
|
+
"""
|
831
|
+
|
832
|
+
response = await self.request.post(
|
833
|
+
"v1beta/config/update",
|
834
|
+
PangeaResponseResult,
|
835
|
+
data={
|
836
|
+
"id": config_id,
|
837
|
+
"name": name,
|
838
|
+
"updated_at": updated_at,
|
839
|
+
# Optionals.
|
840
|
+
"cold_query_result_retention": cold_query_result_retention,
|
841
|
+
"cold_storage": cold_storage,
|
842
|
+
"forwarding_configuration": forwarding_configuration,
|
843
|
+
"hot_storage": hot_storage,
|
844
|
+
"query_result_retention": query_result_retention,
|
845
|
+
"redact_service_config_id": redact_service_config_id,
|
846
|
+
"retention": retention,
|
847
|
+
"schema": schema,
|
848
|
+
"vault_key_id": vault_key_id,
|
849
|
+
"vault_service_config_id": vault_service_config_id,
|
850
|
+
"vault_sign": vault_sign,
|
851
|
+
"warm_storage": warm_storage,
|
852
|
+
},
|
853
|
+
)
|
854
|
+
response.result = TypeAdapter(ServiceConfig).validate_python(response.json["result"])
|
855
|
+
return cast(PangeaResponse[ServiceConfig], response)
|
856
|
+
|
857
|
+
async def delete_service_config(self, config_id: str) -> PangeaResponse[ServiceConfig]:
|
858
|
+
"""
|
859
|
+
Delete a service config.
|
860
|
+
|
861
|
+
OperationId: audit_post_v1beta_config_delete
|
862
|
+
|
863
|
+
Args:
|
864
|
+
id: The config ID
|
865
|
+
"""
|
866
|
+
|
867
|
+
response = await self.request.post("v1beta/config/delete", PangeaResponseResult, data={"id": config_id})
|
868
|
+
response.result = TypeAdapter(ServiceConfig).validate_python(response.json["result"])
|
869
|
+
return cast(PangeaResponse[ServiceConfig], response)
|
870
|
+
|
871
|
+
async def list_service_configs(
|
872
|
+
self,
|
873
|
+
*,
|
874
|
+
filter: ServiceConfigFilter | None = None,
|
875
|
+
last: str | None = None,
|
876
|
+
order: Literal["asc", "desc"] | None = None,
|
877
|
+
order_by: Literal["id", "created_at", "updated_at"] | None = None,
|
878
|
+
size: int | None = None,
|
879
|
+
) -> PangeaResponse[ServiceConfigListResult]:
|
880
|
+
"""
|
881
|
+
List service configs.
|
882
|
+
|
883
|
+
OperationId: audit_post_v1beta_config_list
|
884
|
+
|
885
|
+
Args:
|
886
|
+
last: Reflected value from a previous response to obtain the next page of results.
|
887
|
+
order: Order results asc(ending) or desc(ending).
|
888
|
+
order_by: Which field to order results by.
|
889
|
+
size: Maximum results to include in the response.
|
890
|
+
"""
|
891
|
+
|
892
|
+
return await self.request.post(
|
893
|
+
"v1beta/config/list",
|
894
|
+
ServiceConfigListResult,
|
895
|
+
data={"filter": filter, "last": last, "order": order, "order_by": order_by, "size": size},
|
896
|
+
)
|
897
|
+
|
598
898
|
async def update_published_roots(self, result: SearchResultOutput):
|
599
899
|
"""Fetches series of published root hashes from Arweave
|
600
900
|
|