pangea-sdk 6.5.0b1__py3-none-any.whl → 6.6.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 +3 -11
- pangea/_constants.py +4 -0
- pangea/_typing.py +30 -0
- pangea/asyncio/__init__.py +2 -1
- pangea/asyncio/file_uploader.py +3 -2
- pangea/asyncio/request.py +66 -162
- pangea/asyncio/services/__init__.py +19 -3
- pangea/asyncio/services/ai_guard.py +23 -169
- pangea/asyncio/services/audit.py +1 -301
- pangea/asyncio/services/authn.py +25 -8
- pangea/asyncio/services/base.py +21 -6
- pangea/asyncio/services/file_scan.py +1 -1
- pangea/asyncio/services/intel.py +160 -95
- pangea/asyncio/services/prompt_guard.py +5 -112
- pangea/asyncio/services/redact.py +4 -265
- pangea/config.py +4 -2
- pangea/file_uploader.py +4 -1
- pangea/request.py +91 -166
- pangea/response.py +5 -1
- pangea/services/__init__.py +19 -3
- pangea/services/ai_guard.py +84 -694
- pangea/services/audit/audit.py +3 -301
- pangea/services/audit/models.py +1 -273
- pangea/services/audit/util.py +2 -0
- pangea/services/authn/authn.py +4 -5
- pangea/services/base.py +3 -0
- pangea/services/file_scan.py +3 -2
- pangea/services/intel.py +187 -252
- pangea/services/prompt_guard.py +5 -193
- pangea/services/redact.py +7 -473
- pangea/services/vault/vault.py +3 -0
- {pangea_sdk-6.5.0b1.dist-info → pangea_sdk-6.6.0.dist-info}/METADATA +17 -18
- pangea_sdk-6.6.0.dist-info/RECORD +62 -0
- pangea_sdk-6.6.0.dist-info/WHEEL +4 -0
- pangea/asyncio/services/management.py +0 -576
- pangea/services/management.py +0 -720
- pangea_sdk-6.5.0b1.dist-info/RECORD +0 -62
- pangea_sdk-6.5.0b1.dist-info/WHEEL +0 -4
pangea/asyncio/services/audit.py
CHANGED
@@ -8,10 +8,7 @@ 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
|
12
|
-
|
13
|
-
from pydantic import TypeAdapter
|
14
|
-
from typing_extensions import Literal
|
11
|
+
from typing import Any, Dict, Iterable, List, Optional, Sequence, Union
|
15
12
|
|
16
13
|
import pangea.exceptions as pexc
|
17
14
|
from pangea.asyncio.services.base import ServiceBaseAsync
|
@@ -20,13 +17,11 @@ from pangea.response import PangeaResponse, PangeaResponseResult
|
|
20
17
|
from pangea.services.audit.audit import AuditBase
|
21
18
|
from pangea.services.audit.exceptions import AuditException
|
22
19
|
from pangea.services.audit.models import (
|
23
|
-
AuditSchema,
|
24
20
|
DownloadFormat,
|
25
21
|
DownloadRequest,
|
26
22
|
DownloadResult,
|
27
23
|
Event,
|
28
24
|
ExportRequest,
|
29
|
-
ForwardingConfiguration,
|
30
25
|
LogBulkResult,
|
31
26
|
LogResult,
|
32
27
|
PublishedRoot,
|
@@ -39,9 +34,6 @@ from pangea.services.audit.models import (
|
|
39
34
|
SearchRequest,
|
40
35
|
SearchResultOutput,
|
41
36
|
SearchResultRequest,
|
42
|
-
ServiceConfig,
|
43
|
-
ServiceConfigFilter,
|
44
|
-
ServiceConfigListResult,
|
45
37
|
)
|
46
38
|
from pangea.services.audit.util import format_datetime
|
47
39
|
|
@@ -603,298 +595,6 @@ class AuditAsync(ServiceBaseAsync, AuditBase):
|
|
603
595
|
)
|
604
596
|
return await self.request.post("v1/download_results", DownloadResult, data=input.model_dump(exclude_none=True))
|
605
597
|
|
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
|
-
|
898
598
|
async def update_published_roots(self, result: SearchResultOutput):
|
899
599
|
"""Fetches series of published root hashes from Arweave
|
900
600
|
|
pangea/asyncio/services/authn.py
CHANGED
@@ -10,9 +10,9 @@ from collections.abc import Mapping
|
|
10
10
|
from typing import Dict, List, Literal, Optional, Union
|
11
11
|
|
12
12
|
import pangea.services.authn.models as m
|
13
|
+
from pangea import PangeaResponse, PangeaResponseResult
|
13
14
|
from pangea.asyncio.services.base import ServiceBaseAsync
|
14
15
|
from pangea.config import PangeaConfig
|
15
|
-
from pangea.response import PangeaResponse, PangeaResponseResult
|
16
16
|
|
17
17
|
__all__ = ["AuthNAsync"]
|
18
18
|
|
@@ -66,11 +66,18 @@ class AuthNAsync(ServiceBaseAsync):
|
|
66
66
|
authn = AuthNAsync(token="pangea_token", config=config)
|
67
67
|
"""
|
68
68
|
super().__init__(token, config, logger_name=logger_name)
|
69
|
-
self.
|
70
|
-
self.flow = AuthNAsync.FlowAsync(token, config, logger_name=logger_name)
|
69
|
+
self.agreements = AuthNAsync.AgreementsAsync(token, config, logger_name=logger_name)
|
71
70
|
self.client = AuthNAsync.ClientAsync(token, config, logger_name=logger_name)
|
71
|
+
self.flow = AuthNAsync.FlowAsync(token, config, logger_name=logger_name)
|
72
72
|
self.session = AuthNAsync.SessionAsync(token, config, logger_name=logger_name)
|
73
|
-
self.
|
73
|
+
self.user = AuthNAsync.UserAsync(token, config, logger_name=logger_name)
|
74
|
+
|
75
|
+
async def close(self) -> None:
|
76
|
+
await self.agreements.close()
|
77
|
+
await self.client.close()
|
78
|
+
await self.flow.close()
|
79
|
+
await self.session.close()
|
80
|
+
await self.user.close()
|
74
81
|
|
75
82
|
class SessionAsync(ServiceBaseAsync):
|
76
83
|
service_name = _SERVICE_NAME
|
@@ -179,10 +186,15 @@ class AuthNAsync(ServiceBaseAsync):
|
|
179
186
|
logger_name: str = "pangea",
|
180
187
|
) -> None:
|
181
188
|
super().__init__(token, config, logger_name=logger_name)
|
182
|
-
self.session = AuthNAsync.ClientAsync.SessionAsync(token, config, logger_name=logger_name)
|
183
189
|
self.password = AuthNAsync.ClientAsync.PasswordAsync(token, config, logger_name=logger_name)
|
190
|
+
self.session = AuthNAsync.ClientAsync.SessionAsync(token, config, logger_name=logger_name)
|
184
191
|
self.token_endpoints = AuthNAsync.ClientAsync.TokenAsync(token, config, logger_name=logger_name)
|
185
192
|
|
193
|
+
async def close(self) -> None:
|
194
|
+
await self.password.close()
|
195
|
+
await self.session.close()
|
196
|
+
await self.token_endpoints.close()
|
197
|
+
|
186
198
|
async def userinfo(self, code: str) -> PangeaResponse[m.ClientUserinfoResult]:
|
187
199
|
"""
|
188
200
|
Get User (client token)
|
@@ -470,9 +482,14 @@ class AuthNAsync(ServiceBaseAsync):
|
|
470
482
|
logger_name: str = "pangea",
|
471
483
|
) -> None:
|
472
484
|
super().__init__(token, config, logger_name=logger_name)
|
473
|
-
self.profile = AuthNAsync.UserAsync.ProfileAsync(token, config, logger_name=logger_name)
|
474
485
|
self.authenticators = AuthNAsync.UserAsync.AuthenticatorsAsync(token, config, logger_name=logger_name)
|
475
486
|
self.invites = AuthNAsync.UserAsync.InvitesAsync(token, config, logger_name=logger_name)
|
487
|
+
self.profile = AuthNAsync.UserAsync.ProfileAsync(token, config, logger_name=logger_name)
|
488
|
+
|
489
|
+
async def close(self) -> None:
|
490
|
+
await self.authenticators.close()
|
491
|
+
await self.invites.close()
|
492
|
+
await self.profile.close()
|
476
493
|
|
477
494
|
async def create(
|
478
495
|
self,
|
@@ -932,7 +949,7 @@ class AuthNAsync(ServiceBaseAsync):
|
|
932
949
|
return await self.request.post(
|
933
950
|
"v2/user/group/assign",
|
934
951
|
data={"id": user_id, "group_ids": group_ids},
|
935
|
-
result_class=
|
952
|
+
result_class=PangeaResponseResult,
|
936
953
|
)
|
937
954
|
|
938
955
|
async def remove(self, user_id: str, group_id: str) -> PangeaResponse[PangeaResponseResult]:
|
@@ -946,7 +963,7 @@ class AuthNAsync(ServiceBaseAsync):
|
|
946
963
|
return await self.request.post(
|
947
964
|
"v2/user/group/remove",
|
948
965
|
data={"id": user_id, "group_id": group_id},
|
949
|
-
result_class=
|
966
|
+
result_class=PangeaResponseResult,
|
950
967
|
)
|
951
968
|
|
952
969
|
async def list(self, user_id: str) -> PangeaResponse[m.GroupList]:
|
pangea/asyncio/services/base.py
CHANGED
@@ -6,14 +6,20 @@
|
|
6
6
|
|
7
7
|
from __future__ import annotations
|
8
8
|
|
9
|
+
from types import TracebackType
|
9
10
|
from typing import Dict, Optional, Type, Union
|
10
11
|
|
11
12
|
from typing_extensions import override
|
12
13
|
|
14
|
+
from pangea import PangeaResponse, PangeaResponseResult
|
15
|
+
from pangea._typing import T
|
13
16
|
from pangea.asyncio.request import PangeaRequestAsync
|
14
17
|
from pangea.exceptions import AcceptedRequestException
|
15
|
-
from pangea.
|
16
|
-
from pangea.
|
18
|
+
from pangea.request import PangeaRequest
|
19
|
+
from pangea.response import AttachedFile
|
20
|
+
from pangea.services.base import ServiceBase
|
21
|
+
|
22
|
+
__all__ = ("ServiceBaseAsync",)
|
17
23
|
|
18
24
|
|
19
25
|
class ServiceBaseAsync(ServiceBase):
|
@@ -85,8 +91,17 @@ class ServiceBaseAsync(ServiceBase):
|
|
85
91
|
return await self.request.download_file(url=url, filename=filename)
|
86
92
|
|
87
93
|
async def close(self):
|
94
|
+
"""Close the underlying aiohttp client."""
|
95
|
+
|
88
96
|
await self.request.session.close()
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
97
|
+
|
98
|
+
async def __aenter__(self: T) -> T:
|
99
|
+
return self
|
100
|
+
|
101
|
+
async def __aexit__(
|
102
|
+
self,
|
103
|
+
exc_type: type[BaseException] | None,
|
104
|
+
exc: BaseException | None,
|
105
|
+
exc_tb: TracebackType | None,
|
106
|
+
) -> None:
|
107
|
+
await self.close()
|
@@ -11,9 +11,9 @@ import logging
|
|
11
11
|
from typing import Dict, List, Optional, Tuple
|
12
12
|
|
13
13
|
import pangea.services.file_scan as m
|
14
|
+
from pangea import PangeaConfig
|
14
15
|
from pangea.asyncio.request import PangeaRequestAsync
|
15
16
|
from pangea.asyncio.services.base import ServiceBaseAsync
|
16
|
-
from pangea.request import PangeaConfig
|
17
17
|
from pangea.response import PangeaResponse, TransferMethod
|
18
18
|
from pangea.utils import FileUploadParams, get_file_upload_params
|
19
19
|
|